ホーム › System.Memory › VirtualAllocExNuma
VirtualAllocExNuma
関数指定NUMAノードを優先して仮想メモリを予約またはコミットする。
シグネチャ
// KERNEL32.dll
#include <windows.h>
void* VirtualAllocExNuma(
HANDLE hProcess,
void* lpAddress, // optional
UINT_PTR dwSize,
VIRTUAL_ALLOCATION_TYPE flAllocationType,
DWORD flProtect,
DWORD nndPreferred
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hProcess | HANDLE | in |
| lpAddress | void* | inoptional |
| dwSize | UINT_PTR | in |
| flAllocationType | VIRTUAL_ALLOCATION_TYPE | in |
| flProtect | DWORD | in |
| nndPreferred | DWORD | in |
戻り値の型: void*
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
void* VirtualAllocExNuma(
HANDLE hProcess,
void* lpAddress, // optional
UINT_PTR dwSize,
VIRTUAL_ALLOCATION_TYPE flAllocationType,
DWORD flProtect,
DWORD nndPreferred
);[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr VirtualAllocExNuma(
IntPtr hProcess, // HANDLE
IntPtr lpAddress, // void* optional
UIntPtr dwSize, // UINT_PTR
uint flAllocationType, // VIRTUAL_ALLOCATION_TYPE
uint flProtect, // DWORD
uint nndPreferred // DWORD
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function VirtualAllocExNuma(
hProcess As IntPtr, ' HANDLE
lpAddress As IntPtr, ' void* optional
dwSize As UIntPtr, ' UINT_PTR
flAllocationType As UInteger, ' VIRTUAL_ALLOCATION_TYPE
flProtect As UInteger, ' DWORD
nndPreferred As UInteger ' DWORD
) As IntPtr
End Function' hProcess : HANDLE
' lpAddress : void* optional
' dwSize : UINT_PTR
' flAllocationType : VIRTUAL_ALLOCATION_TYPE
' flProtect : DWORD
' nndPreferred : DWORD
Declare PtrSafe Function VirtualAllocExNuma Lib "kernel32" ( _
ByVal hProcess As LongPtr, _
ByVal lpAddress As LongPtr, _
ByVal dwSize As LongPtr, _
ByVal flAllocationType As Long, _
ByVal flProtect As Long, _
ByVal nndPreferred As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
VirtualAllocExNuma = ctypes.windll.kernel32.VirtualAllocExNuma
VirtualAllocExNuma.restype = ctypes.c_void_p
VirtualAllocExNuma.argtypes = [
wintypes.HANDLE, # hProcess : HANDLE
ctypes.POINTER(None), # lpAddress : void* optional
ctypes.c_size_t, # dwSize : UINT_PTR
wintypes.DWORD, # flAllocationType : VIRTUAL_ALLOCATION_TYPE
wintypes.DWORD, # flProtect : DWORD
wintypes.DWORD, # nndPreferred : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
VirtualAllocExNuma = Fiddle::Function.new(
lib['VirtualAllocExNuma'],
[
Fiddle::TYPE_VOIDP, # hProcess : HANDLE
Fiddle::TYPE_VOIDP, # lpAddress : void* optional
Fiddle::TYPE_UINTPTR_T, # dwSize : UINT_PTR
-Fiddle::TYPE_INT, # flAllocationType : VIRTUAL_ALLOCATION_TYPE
-Fiddle::TYPE_INT, # flProtect : DWORD
-Fiddle::TYPE_INT, # nndPreferred : DWORD
],
Fiddle::TYPE_VOIDP)#[link(name = "kernel32")]
extern "system" {
fn VirtualAllocExNuma(
hProcess: *mut core::ffi::c_void, // HANDLE
lpAddress: *mut (), // void* optional
dwSize: usize, // UINT_PTR
flAllocationType: u32, // VIRTUAL_ALLOCATION_TYPE
flProtect: u32, // DWORD
nndPreferred: u32 // DWORD
) -> *mut ();
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern IntPtr VirtualAllocExNuma(IntPtr hProcess, IntPtr lpAddress, UIntPtr dwSize, uint flAllocationType, uint flProtect, uint nndPreferred);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_VirtualAllocExNuma' -Namespace Win32 -PassThru
# $api::VirtualAllocExNuma(hProcess, lpAddress, dwSize, flAllocationType, flProtect, nndPreferred)#uselib "KERNEL32.dll"
#func global VirtualAllocExNuma "VirtualAllocExNuma" sptr, sptr, sptr, sptr, sptr, sptr
; VirtualAllocExNuma hProcess, lpAddress, dwSize, flAllocationType, flProtect, nndPreferred ; 戻り値は stat
; hProcess : HANDLE -> "sptr"
; lpAddress : void* optional -> "sptr"
; dwSize : UINT_PTR -> "sptr"
; flAllocationType : VIRTUAL_ALLOCATION_TYPE -> "sptr"
; flProtect : DWORD -> "sptr"
; nndPreferred : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global VirtualAllocExNuma "VirtualAllocExNuma" sptr, sptr, sptr, int, int, int
; res = VirtualAllocExNuma(hProcess, lpAddress, dwSize, flAllocationType, flProtect, nndPreferred)
; hProcess : HANDLE -> "sptr"
; lpAddress : void* optional -> "sptr"
; dwSize : UINT_PTR -> "sptr"
; flAllocationType : VIRTUAL_ALLOCATION_TYPE -> "int"
; flProtect : DWORD -> "int"
; nndPreferred : DWORD -> "int"; void* VirtualAllocExNuma(HANDLE hProcess, void* lpAddress, UINT_PTR dwSize, VIRTUAL_ALLOCATION_TYPE flAllocationType, DWORD flProtect, DWORD nndPreferred)
#uselib "KERNEL32.dll"
#cfunc global VirtualAllocExNuma "VirtualAllocExNuma" intptr, intptr, intptr, int, int, int
; res = VirtualAllocExNuma(hProcess, lpAddress, dwSize, flAllocationType, flProtect, nndPreferred)
; hProcess : HANDLE -> "intptr"
; lpAddress : void* optional -> "intptr"
; dwSize : UINT_PTR -> "intptr"
; flAllocationType : VIRTUAL_ALLOCATION_TYPE -> "int"
; flProtect : DWORD -> "int"
; nndPreferred : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procVirtualAllocExNuma = kernel32.NewProc("VirtualAllocExNuma")
)
// hProcess (HANDLE), lpAddress (void* optional), dwSize (UINT_PTR), flAllocationType (VIRTUAL_ALLOCATION_TYPE), flProtect (DWORD), nndPreferred (DWORD)
r1, _, err := procVirtualAllocExNuma.Call(
uintptr(hProcess),
uintptr(lpAddress),
uintptr(dwSize),
uintptr(flAllocationType),
uintptr(flProtect),
uintptr(nndPreferred),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // void*function VirtualAllocExNuma(
hProcess: THandle; // HANDLE
lpAddress: Pointer; // void* optional
dwSize: NativeUInt; // UINT_PTR
flAllocationType: DWORD; // VIRTUAL_ALLOCATION_TYPE
flProtect: DWORD; // DWORD
nndPreferred: DWORD // DWORD
): Pointer; stdcall;
external 'KERNEL32.dll' name 'VirtualAllocExNuma';result := DllCall("KERNEL32\VirtualAllocExNuma"
, "Ptr", hProcess ; HANDLE
, "Ptr", lpAddress ; void* optional
, "UPtr", dwSize ; UINT_PTR
, "UInt", flAllocationType ; VIRTUAL_ALLOCATION_TYPE
, "UInt", flProtect ; DWORD
, "UInt", nndPreferred ; DWORD
, "Ptr") ; return: void*●VirtualAllocExNuma(hProcess, lpAddress, dwSize, flAllocationType, flProtect, nndPreferred) = DLL("KERNEL32.dll", "void* VirtualAllocExNuma(void*, void*, int, dword, dword, dword)")
# 呼び出し: VirtualAllocExNuma(hProcess, lpAddress, dwSize, flAllocationType, flProtect, nndPreferred)
# hProcess : HANDLE -> "void*"
# lpAddress : void* optional -> "void*"
# dwSize : UINT_PTR -> "int"
# flAllocationType : VIRTUAL_ALLOCATION_TYPE -> "dword"
# flProtect : DWORD -> "dword"
# nndPreferred : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。