Kernel32.dll Functions
A
C
E
F
G
L
R
S
V
W
VirtualAlloc
Allocates a region of memory in the virtual address space of the calling process.
Syntax
LPVOID VirtualAlloc(
LPVOID lpAddress,
SIZE_T dwSize,
DWORD flAllocationType,
DWORD flProtect
);
Parameters
Parameter | Type | Description |
---|---|---|
lpAddress |
LPVOID |
The starting address of the region to allocate. This parameter can be NULL. If NULL, the system determines where to allocate the region. |
dwSize |
SIZE_T |
The size of the region of memory to allocate, in bytes. |
flAllocationType |
DWORD |
The type of memory allocation. This parameter can be one of the following values:
|
flProtect |
DWORD |
The memory protection for the region of pages to be allocated. This parameter can be one of the following values:
|
Return Value
If the function succeeds, the return value is the base address of the allocated region of pages. If the function fails, the return value is NULL. To get extended error information, call GetLastError
.
Remarks
This function allows you to allocate memory with specific protection attributes. It's often used for allocating executable code or memory that requires specific read/write/execute permissions.