Win32 API 日本語リファレンス
ホームSystem.Memory › MapUserPhysicalPagesScatter

MapUserPhysicalPagesScatter

関数
複数の仮想アドレスへAWE物理ページを散在的にマップする。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

// KERNEL32.dll
#include <windows.h>

BOOL MapUserPhysicalPagesScatter(
    void** VirtualAddresses,
    UINT_PTR NumberOfPages,
    UINT_PTR* PageArray   // optional
);

パラメーター

名前方向
VirtualAddressesvoid**in
NumberOfPagesUINT_PTRin
PageArrayUINT_PTR*inoptional

戻り値の型: BOOL

各言語での呼び出し定義

// KERNEL32.dll
#include <windows.h>

BOOL MapUserPhysicalPagesScatter(
    void** VirtualAddresses,
    UINT_PTR NumberOfPages,
    UINT_PTR* PageArray   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool MapUserPhysicalPagesScatter(
    IntPtr VirtualAddresses,   // void**
    UIntPtr NumberOfPages,   // UINT_PTR
    IntPtr PageArray   // UINT_PTR* optional
);
<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function MapUserPhysicalPagesScatter(
    VirtualAddresses As IntPtr,   ' void**
    NumberOfPages As UIntPtr,   ' UINT_PTR
    PageArray As IntPtr   ' UINT_PTR* optional
) As Boolean
End Function
' VirtualAddresses : void**
' NumberOfPages : UINT_PTR
' PageArray : UINT_PTR* optional
Declare PtrSafe Function MapUserPhysicalPagesScatter Lib "kernel32" ( _
    ByVal VirtualAddresses As LongPtr, _
    ByVal NumberOfPages As LongPtr, _
    ByVal PageArray As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MapUserPhysicalPagesScatter = ctypes.windll.kernel32.MapUserPhysicalPagesScatter
MapUserPhysicalPagesScatter.restype = wintypes.BOOL
MapUserPhysicalPagesScatter.argtypes = [
    ctypes.c_void_p,  # VirtualAddresses : void**
    ctypes.c_size_t,  # NumberOfPages : UINT_PTR
    ctypes.POINTER(ctypes.c_size_t),  # PageArray : UINT_PTR* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
MapUserPhysicalPagesScatter = Fiddle::Function.new(
  lib['MapUserPhysicalPagesScatter'],
  [
    Fiddle::TYPE_VOIDP,  # VirtualAddresses : void**
    Fiddle::TYPE_UINTPTR_T,  # NumberOfPages : UINT_PTR
    Fiddle::TYPE_VOIDP,  # PageArray : UINT_PTR* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn MapUserPhysicalPagesScatter(
        VirtualAddresses: *mut *mut (),  // void**
        NumberOfPages: usize,  // UINT_PTR
        PageArray: *mut usize  // UINT_PTR* optional
    ) -> 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 MapUserPhysicalPagesScatter(IntPtr VirtualAddresses, UIntPtr NumberOfPages, IntPtr PageArray);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_MapUserPhysicalPagesScatter' -Namespace Win32 -PassThru
# $api::MapUserPhysicalPagesScatter(VirtualAddresses, NumberOfPages, PageArray)
#uselib "KERNEL32.dll"
#func global MapUserPhysicalPagesScatter "MapUserPhysicalPagesScatter" sptr, sptr, sptr
; MapUserPhysicalPagesScatter VirtualAddresses, NumberOfPages, varptr(PageArray)   ; 戻り値は stat
; VirtualAddresses : void** -> "sptr"
; NumberOfPages : UINT_PTR -> "sptr"
; PageArray : UINT_PTR* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "KERNEL32.dll"
#cfunc global MapUserPhysicalPagesScatter "MapUserPhysicalPagesScatter" sptr, sptr, var
; res = MapUserPhysicalPagesScatter(VirtualAddresses, NumberOfPages, PageArray)
; VirtualAddresses : void** -> "sptr"
; NumberOfPages : UINT_PTR -> "sptr"
; PageArray : UINT_PTR* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL MapUserPhysicalPagesScatter(void** VirtualAddresses, UINT_PTR NumberOfPages, UINT_PTR* PageArray)
#uselib "KERNEL32.dll"
#cfunc global MapUserPhysicalPagesScatter "MapUserPhysicalPagesScatter" intptr, intptr, var
; res = MapUserPhysicalPagesScatter(VirtualAddresses, NumberOfPages, PageArray)
; VirtualAddresses : void** -> "intptr"
; NumberOfPages : UINT_PTR -> "intptr"
; PageArray : UINT_PTR* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procMapUserPhysicalPagesScatter = kernel32.NewProc("MapUserPhysicalPagesScatter")
)

// VirtualAddresses (void**), NumberOfPages (UINT_PTR), PageArray (UINT_PTR* optional)
r1, _, err := procMapUserPhysicalPagesScatter.Call(
	uintptr(VirtualAddresses),
	uintptr(NumberOfPages),
	uintptr(PageArray),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function MapUserPhysicalPagesScatter(
  VirtualAddresses: Pointer;   // void**
  NumberOfPages: NativeUInt;   // UINT_PTR
  PageArray: Pointer   // UINT_PTR* optional
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'MapUserPhysicalPagesScatter';
result := DllCall("KERNEL32\MapUserPhysicalPagesScatter"
    , "Ptr", VirtualAddresses   ; void**
    , "UPtr", NumberOfPages   ; UINT_PTR
    , "Ptr", PageArray   ; UINT_PTR* optional
    , "Int")   ; return: BOOL
●MapUserPhysicalPagesScatter(VirtualAddresses, NumberOfPages, PageArray) = DLL("KERNEL32.dll", "bool MapUserPhysicalPagesScatter(void*, int, void*)")
# 呼び出し: MapUserPhysicalPagesScatter(VirtualAddresses, NumberOfPages, PageArray)
# VirtualAddresses : void** -> "void*"
# NumberOfPages : UINT_PTR -> "int"
# PageArray : UINT_PTR* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。