Kernel32VirtualAlloc(IntPtr, IntPtr, MemoryAllocationType, MemoryProtectionOptions) Method
Namespace: DevCase.Win32.NativeMethodsAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("Kernel32.dll", ExactSpelling = true, SetLastError = true)]
public static IntPtr VirtualAlloc(
IntPtr address,
IntPtr size,
MemoryAllocationType allocationType,
MemoryProtectionOptions protection
)
<DllImportAttribute("Kernel32.dll", ExactSpelling := true, SetLastError := true>]
Public Shared Function VirtualAlloc (
address As IntPtr,
size As IntPtr,
allocationType As MemoryAllocationType,
protection As MemoryProtectionOptions
) As IntPtr
Dim address As IntPtr
Dim size As IntPtr
Dim allocationType As MemoryAllocationType
Dim protection As MemoryProtectionOptions
Dim returnValue As IntPtr
returnValue = Kernel32.VirtualAlloc(address,
size, allocationType, protection)
public:
[DllImportAttribute(L"Kernel32.dll", ExactSpelling = true, SetLastError = true)]
static IntPtr VirtualAlloc(
IntPtr address,
IntPtr size,
MemoryAllocationType allocationType,
MemoryProtectionOptions protection
)
[<DllImportAttribute("Kernel32.dll", ExactSpelling = true, SetLastError = true)>]
static member VirtualAlloc :
address : IntPtr *
size : IntPtr *
allocationType : MemoryAllocationType *
protection : MemoryProtectionOptions -> IntPtr
No code example is currently available or this language may not be supported.
- address IntPtr
-
The starting address of the region to allocate.
If the memory is being reserved,
the specified address is rounded down to the nearest multiple of the allocation granularity.
If the memory is already reserved and is being committed,
the address is rounded down to the next page boundary.
To determine the size of a page and the allocation granularity on the host computer,
use the GetSystemInfo function.
If this parameter is Zero, the system determines where to allocate the region.
If this address is within an enclave that you have not initialized by calling InitializeEnclave,
VirtualAlloc(IntPtr, IntPtr, MemoryAllocationType, MemoryProtectionOptions) allocates a page of zeros for the enclave at that address.
The page must be previously uncommitted, and will not be measured with the EEXTEND instruction
of the Intel Software Guard Extensions programming model.
If the address in within an enclave that you initialized,
then the allocation operation fails with the ERROR_INVALID_ADDRESS error.
- size IntPtr
-
The size of the region, in bytes.
If the address parameter is Zero,
this value is rounded up to the next page boundary.
Otherwise, the allocated pages include all pages containing one or more bytes
in the range from address to address+size.
This means that a 2-byte range straddling a page boundary causes both pages to be included
in the allocated region.
- allocationType MemoryAllocationType
-
The type of memory allocation.
- protection MemoryProtectionOptions
-
The memory protection for the region of pages to be allocated.
If address parameter specifies an address within an enclave,
protection cannot be any of the following values:
NoAccess,
Guard,
NoCache,
WriteCombine
IntPtr
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
Zero.
To get extended error information, call
GetLastWin32Error.