Kernel32.dll
The Kernel32.dll library provides access to the core functionality of the Windows operating system. It includes functions for memory management, process and thread management, I/O operations, and more.
Core Concepts
Kernel32.dll is fundamental to Windows application development. Understanding its functions is crucial for efficient and robust system programming.
Key Functions
CreateProcess
BOOL CreateProcess(
_In_opt_ LPCTSTR lpApplicationName,
_Inout_opt_ LPTSTR lpCommandLine,
_In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes,
_In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes,
_In_ BOOL bInheritHandles,
_In_ DWORD dwCreationFlags,
_In_opt_ LPVOID lpEnvironment,
_In_opt_ LPCTSTR lpCurrentDirectory,
_In_ LPSTARTUPINFO lpStartupInfo,
_Out_ LPPROCESS_INFORMATION lpProcessInformation
);
Creates a new process and its primary thread. The new process has two handles that are not inherited: one for the process and one for the primary thread. The calling process must use the handles returned in lpProcessInformation to close them when they are no longer needed.
ReadFile
BOOL ReadFile(
_In_ HANDLE hFile,
_Out_ LPVOID lpBuffer,
_In_ DWORD nNumberOfBytesToRead,
_Out_opt_ LPDWORD lpNumberOfBytesRead,
_Inout_opt_ LPOVERLAPPED lpOverlapped
);
Reads data from a file or from the communication device identified by a handle. The function starts at the position indicated by the file pointer and includes the number of bytes specified by nNumberOfBytesToRead.
WriteFile
BOOL WriteFile(
_In_ HANDLE hFile,
_In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer,
_In_ DWORD nNumberOfBytesToWrite,
_Out_opt_ LPDWORD lpNumberOfBytesWritten,
_Inout_opt_ LPOVERLAPPED lpOverlapped
);
Writes data to a file or to the communication device identified by a handle. The function begins at the current file position and writes the specified number of bytes from the buffer.
HeapAlloc
LPVOID HeapAlloc(
_In_ HANDLE hHeap,
_In_ DWORD dwFlags,
_In_ SIZE_T dwBytes
);
Allocates a block of memory from a heap. The memory must be freed by calling the HeapFree function.
CreateThread
HANDLE CreateThread(
_In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes,
_In_ SIZE_T dwStackSize,
_In_ LPTHREAD_START_ROUTINE lpStartAddress,
_In_opt_ LPVOID lpParameter,
_In_ DWORD dwCreationFlags,
_Out_opt_ LPDWORD lpThreadId
);
Creates a thread to execute within the virtual address space of the calling process. The thread runs on the given processor, with the given priority, and in the context of the process.