ホーム › System.Memory › AllocateUserPhysicalPages
AllocateUserPhysicalPages
関数AWE用に物理メモリページを割り当てる。
シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL AllocateUserPhysicalPages(
HANDLE hProcess,
UINT_PTR* NumberOfPages,
UINT_PTR* PageArray
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hProcess | HANDLE | in |
| NumberOfPages | UINT_PTR* | inout |
| PageArray | UINT_PTR* | out |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL AllocateUserPhysicalPages(
HANDLE hProcess,
UINT_PTR* NumberOfPages,
UINT_PTR* PageArray
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool AllocateUserPhysicalPages(
IntPtr hProcess, // HANDLE
ref UIntPtr NumberOfPages, // UINT_PTR* in/out
out UIntPtr PageArray // UINT_PTR* out
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function AllocateUserPhysicalPages(
hProcess As IntPtr, ' HANDLE
ByRef NumberOfPages As UIntPtr, ' UINT_PTR* in/out
<Out> ByRef PageArray As UIntPtr ' UINT_PTR* out
) As Boolean
End Function' hProcess : HANDLE
' NumberOfPages : UINT_PTR* in/out
' PageArray : UINT_PTR* out
Declare PtrSafe Function AllocateUserPhysicalPages Lib "kernel32" ( _
ByVal hProcess As LongPtr, _
ByRef NumberOfPages As LongPtr, _
ByRef PageArray As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
AllocateUserPhysicalPages = ctypes.windll.kernel32.AllocateUserPhysicalPages
AllocateUserPhysicalPages.restype = wintypes.BOOL
AllocateUserPhysicalPages.argtypes = [
wintypes.HANDLE, # hProcess : HANDLE
ctypes.POINTER(ctypes.c_size_t), # NumberOfPages : UINT_PTR* in/out
ctypes.POINTER(ctypes.c_size_t), # PageArray : UINT_PTR* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
AllocateUserPhysicalPages = Fiddle::Function.new(
lib['AllocateUserPhysicalPages'],
[
Fiddle::TYPE_VOIDP, # hProcess : HANDLE
Fiddle::TYPE_VOIDP, # NumberOfPages : UINT_PTR* in/out
Fiddle::TYPE_VOIDP, # PageArray : UINT_PTR* out
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn AllocateUserPhysicalPages(
hProcess: *mut core::ffi::c_void, // HANDLE
NumberOfPages: *mut usize, // UINT_PTR* in/out
PageArray: *mut usize // UINT_PTR* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern bool AllocateUserPhysicalPages(IntPtr hProcess, ref UIntPtr NumberOfPages, out UIntPtr PageArray);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_AllocateUserPhysicalPages' -Namespace Win32 -PassThru
# $api::AllocateUserPhysicalPages(hProcess, NumberOfPages, PageArray)#uselib "KERNEL32.dll"
#func global AllocateUserPhysicalPages "AllocateUserPhysicalPages" sptr, sptr, sptr
; AllocateUserPhysicalPages hProcess, varptr(NumberOfPages), varptr(PageArray) ; 戻り値は stat
; hProcess : HANDLE -> "sptr"
; NumberOfPages : UINT_PTR* in/out -> "sptr"
; PageArray : UINT_PTR* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global AllocateUserPhysicalPages "AllocateUserPhysicalPages" sptr, var, var ; res = AllocateUserPhysicalPages(hProcess, NumberOfPages, PageArray) ; hProcess : HANDLE -> "sptr" ; NumberOfPages : UINT_PTR* in/out -> "var" ; PageArray : UINT_PTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global AllocateUserPhysicalPages "AllocateUserPhysicalPages" sptr, sptr, sptr ; res = AllocateUserPhysicalPages(hProcess, varptr(NumberOfPages), varptr(PageArray)) ; hProcess : HANDLE -> "sptr" ; NumberOfPages : UINT_PTR* in/out -> "sptr" ; PageArray : UINT_PTR* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL AllocateUserPhysicalPages(HANDLE hProcess, UINT_PTR* NumberOfPages, UINT_PTR* PageArray) #uselib "KERNEL32.dll" #cfunc global AllocateUserPhysicalPages "AllocateUserPhysicalPages" intptr, var, var ; res = AllocateUserPhysicalPages(hProcess, NumberOfPages, PageArray) ; hProcess : HANDLE -> "intptr" ; NumberOfPages : UINT_PTR* in/out -> "var" ; PageArray : UINT_PTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL AllocateUserPhysicalPages(HANDLE hProcess, UINT_PTR* NumberOfPages, UINT_PTR* PageArray) #uselib "KERNEL32.dll" #cfunc global AllocateUserPhysicalPages "AllocateUserPhysicalPages" intptr, intptr, intptr ; res = AllocateUserPhysicalPages(hProcess, varptr(NumberOfPages), varptr(PageArray)) ; hProcess : HANDLE -> "intptr" ; NumberOfPages : UINT_PTR* in/out -> "intptr" ; PageArray : UINT_PTR* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procAllocateUserPhysicalPages = kernel32.NewProc("AllocateUserPhysicalPages")
)
// hProcess (HANDLE), NumberOfPages (UINT_PTR* in/out), PageArray (UINT_PTR* out)
r1, _, err := procAllocateUserPhysicalPages.Call(
uintptr(hProcess),
uintptr(NumberOfPages),
uintptr(PageArray),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction AllocateUserPhysicalPages(
hProcess: THandle; // HANDLE
NumberOfPages: Pointer; // UINT_PTR* in/out
PageArray: Pointer // UINT_PTR* out
): BOOL; stdcall;
external 'KERNEL32.dll' name 'AllocateUserPhysicalPages';result := DllCall("KERNEL32\AllocateUserPhysicalPages"
, "Ptr", hProcess ; HANDLE
, "Ptr", NumberOfPages ; UINT_PTR* in/out
, "Ptr", PageArray ; UINT_PTR* out
, "Int") ; return: BOOL●AllocateUserPhysicalPages(hProcess, NumberOfPages, PageArray) = DLL("KERNEL32.dll", "bool AllocateUserPhysicalPages(void*, void*, void*)")
# 呼び出し: AllocateUserPhysicalPages(hProcess, NumberOfPages, PageArray)
# hProcess : HANDLE -> "void*"
# NumberOfPages : UINT_PTR* in/out -> "void*"
# PageArray : UINT_PTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。