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

MapViewOfFileExNuma

関数
ベースアドレスとNUMAノードを指定してビューをマップする。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

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

MEMORY_MAPPED_VIEW_ADDRESS MapViewOfFileExNuma(
    HANDLE hFileMappingObject,
    FILE_MAP dwDesiredAccess,
    DWORD dwFileOffsetHigh,
    DWORD dwFileOffsetLow,
    UINT_PTR dwNumberOfBytesToMap,
    void* lpBaseAddress,   // optional
    DWORD nndPreferred
);

パラメーター

名前方向
hFileMappingObjectHANDLEin
dwDesiredAccessFILE_MAPin
dwFileOffsetHighDWORDin
dwFileOffsetLowDWORDin
dwNumberOfBytesToMapUINT_PTRin
lpBaseAddressvoid*inoptional
nndPreferredDWORDin

戻り値の型: MEMORY_MAPPED_VIEW_ADDRESS

各言語での呼び出し定義

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

MEMORY_MAPPED_VIEW_ADDRESS MapViewOfFileExNuma(
    HANDLE hFileMappingObject,
    FILE_MAP dwDesiredAccess,
    DWORD dwFileOffsetHigh,
    DWORD dwFileOffsetLow,
    UINT_PTR dwNumberOfBytesToMap,
    void* lpBaseAddress,   // optional
    DWORD nndPreferred
);
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern MEMORY_MAPPED_VIEW_ADDRESS MapViewOfFileExNuma(
    IntPtr hFileMappingObject,   // HANDLE
    uint dwDesiredAccess,   // FILE_MAP
    uint dwFileOffsetHigh,   // DWORD
    uint dwFileOffsetLow,   // DWORD
    UIntPtr dwNumberOfBytesToMap,   // UINT_PTR
    IntPtr lpBaseAddress,   // void* optional
    uint nndPreferred   // DWORD
);
<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function MapViewOfFileExNuma(
    hFileMappingObject As IntPtr,   ' HANDLE
    dwDesiredAccess As UInteger,   ' FILE_MAP
    dwFileOffsetHigh As UInteger,   ' DWORD
    dwFileOffsetLow As UInteger,   ' DWORD
    dwNumberOfBytesToMap As UIntPtr,   ' UINT_PTR
    lpBaseAddress As IntPtr,   ' void* optional
    nndPreferred As UInteger   ' DWORD
) As MEMORY_MAPPED_VIEW_ADDRESS
End Function
' hFileMappingObject : HANDLE
' dwDesiredAccess : FILE_MAP
' dwFileOffsetHigh : DWORD
' dwFileOffsetLow : DWORD
' dwNumberOfBytesToMap : UINT_PTR
' lpBaseAddress : void* optional
' nndPreferred : DWORD
Declare PtrSafe Function MapViewOfFileExNuma Lib "kernel32" ( _
    ByVal hFileMappingObject As LongPtr, _
    ByVal dwDesiredAccess As Long, _
    ByVal dwFileOffsetHigh As Long, _
    ByVal dwFileOffsetLow As Long, _
    ByVal dwNumberOfBytesToMap As LongPtr, _
    ByVal lpBaseAddress As LongPtr, _
    ByVal nndPreferred As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MapViewOfFileExNuma = ctypes.windll.kernel32.MapViewOfFileExNuma
MapViewOfFileExNuma.restype = ctypes.c_void_p
MapViewOfFileExNuma.argtypes = [
    wintypes.HANDLE,  # hFileMappingObject : HANDLE
    wintypes.DWORD,  # dwDesiredAccess : FILE_MAP
    wintypes.DWORD,  # dwFileOffsetHigh : DWORD
    wintypes.DWORD,  # dwFileOffsetLow : DWORD
    ctypes.c_size_t,  # dwNumberOfBytesToMap : UINT_PTR
    ctypes.POINTER(None),  # lpBaseAddress : void* optional
    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')
MapViewOfFileExNuma = Fiddle::Function.new(
  lib['MapViewOfFileExNuma'],
  [
    Fiddle::TYPE_VOIDP,  # hFileMappingObject : HANDLE
    -Fiddle::TYPE_INT,  # dwDesiredAccess : FILE_MAP
    -Fiddle::TYPE_INT,  # dwFileOffsetHigh : DWORD
    -Fiddle::TYPE_INT,  # dwFileOffsetLow : DWORD
    Fiddle::TYPE_UINTPTR_T,  # dwNumberOfBytesToMap : UINT_PTR
    Fiddle::TYPE_VOIDP,  # lpBaseAddress : void* optional
    -Fiddle::TYPE_INT,  # nndPreferred : DWORD
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "kernel32")]
extern "system" {
    fn MapViewOfFileExNuma(
        hFileMappingObject: *mut core::ffi::c_void,  // HANDLE
        dwDesiredAccess: u32,  // FILE_MAP
        dwFileOffsetHigh: u32,  // DWORD
        dwFileOffsetLow: u32,  // DWORD
        dwNumberOfBytesToMap: usize,  // UINT_PTR
        lpBaseAddress: *mut (),  // void* optional
        nndPreferred: u32  // DWORD
    ) -> MEMORY_MAPPED_VIEW_ADDRESS;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern MEMORY_MAPPED_VIEW_ADDRESS MapViewOfFileExNuma(IntPtr hFileMappingObject, uint dwDesiredAccess, uint dwFileOffsetHigh, uint dwFileOffsetLow, UIntPtr dwNumberOfBytesToMap, IntPtr lpBaseAddress, uint nndPreferred);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_MapViewOfFileExNuma' -Namespace Win32 -PassThru
# $api::MapViewOfFileExNuma(hFileMappingObject, dwDesiredAccess, dwFileOffsetHigh, dwFileOffsetLow, dwNumberOfBytesToMap, lpBaseAddress, nndPreferred)
#uselib "KERNEL32.dll"
#func global MapViewOfFileExNuma "MapViewOfFileExNuma" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; MapViewOfFileExNuma hFileMappingObject, dwDesiredAccess, dwFileOffsetHigh, dwFileOffsetLow, dwNumberOfBytesToMap, lpBaseAddress, nndPreferred   ; 戻り値は stat
; hFileMappingObject : HANDLE -> "sptr"
; dwDesiredAccess : FILE_MAP -> "sptr"
; dwFileOffsetHigh : DWORD -> "sptr"
; dwFileOffsetLow : DWORD -> "sptr"
; dwNumberOfBytesToMap : UINT_PTR -> "sptr"
; lpBaseAddress : void* optional -> "sptr"
; nndPreferred : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global MapViewOfFileExNuma "MapViewOfFileExNuma" sptr, int, int, int, sptr, sptr, int
; res = MapViewOfFileExNuma(hFileMappingObject, dwDesiredAccess, dwFileOffsetHigh, dwFileOffsetLow, dwNumberOfBytesToMap, lpBaseAddress, nndPreferred)
; hFileMappingObject : HANDLE -> "sptr"
; dwDesiredAccess : FILE_MAP -> "int"
; dwFileOffsetHigh : DWORD -> "int"
; dwFileOffsetLow : DWORD -> "int"
; dwNumberOfBytesToMap : UINT_PTR -> "sptr"
; lpBaseAddress : void* optional -> "sptr"
; nndPreferred : DWORD -> "int"
; MEMORY_MAPPED_VIEW_ADDRESS MapViewOfFileExNuma(HANDLE hFileMappingObject, FILE_MAP dwDesiredAccess, DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, UINT_PTR dwNumberOfBytesToMap, void* lpBaseAddress, DWORD nndPreferred)
#uselib "KERNEL32.dll"
#cfunc global MapViewOfFileExNuma "MapViewOfFileExNuma" intptr, int, int, int, intptr, intptr, int
; res = MapViewOfFileExNuma(hFileMappingObject, dwDesiredAccess, dwFileOffsetHigh, dwFileOffsetLow, dwNumberOfBytesToMap, lpBaseAddress, nndPreferred)
; hFileMappingObject : HANDLE -> "intptr"
; dwDesiredAccess : FILE_MAP -> "int"
; dwFileOffsetHigh : DWORD -> "int"
; dwFileOffsetLow : DWORD -> "int"
; dwNumberOfBytesToMap : UINT_PTR -> "intptr"
; lpBaseAddress : void* optional -> "intptr"
; nndPreferred : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procMapViewOfFileExNuma = kernel32.NewProc("MapViewOfFileExNuma")
)

// hFileMappingObject (HANDLE), dwDesiredAccess (FILE_MAP), dwFileOffsetHigh (DWORD), dwFileOffsetLow (DWORD), dwNumberOfBytesToMap (UINT_PTR), lpBaseAddress (void* optional), nndPreferred (DWORD)
r1, _, err := procMapViewOfFileExNuma.Call(
	uintptr(hFileMappingObject),
	uintptr(dwDesiredAccess),
	uintptr(dwFileOffsetHigh),
	uintptr(dwFileOffsetLow),
	uintptr(dwNumberOfBytesToMap),
	uintptr(lpBaseAddress),
	uintptr(nndPreferred),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // MEMORY_MAPPED_VIEW_ADDRESS
function MapViewOfFileExNuma(
  hFileMappingObject: THandle;   // HANDLE
  dwDesiredAccess: DWORD;   // FILE_MAP
  dwFileOffsetHigh: DWORD;   // DWORD
  dwFileOffsetLow: DWORD;   // DWORD
  dwNumberOfBytesToMap: NativeUInt;   // UINT_PTR
  lpBaseAddress: Pointer;   // void* optional
  nndPreferred: DWORD   // DWORD
): MEMORY_MAPPED_VIEW_ADDRESS; stdcall;
  external 'KERNEL32.dll' name 'MapViewOfFileExNuma';
result := DllCall("KERNEL32\MapViewOfFileExNuma"
    , "Ptr", hFileMappingObject   ; HANDLE
    , "UInt", dwDesiredAccess   ; FILE_MAP
    , "UInt", dwFileOffsetHigh   ; DWORD
    , "UInt", dwFileOffsetLow   ; DWORD
    , "UPtr", dwNumberOfBytesToMap   ; UINT_PTR
    , "Ptr", lpBaseAddress   ; void* optional
    , "UInt", nndPreferred   ; DWORD
    , "Ptr")   ; return: MEMORY_MAPPED_VIEW_ADDRESS
●MapViewOfFileExNuma(hFileMappingObject, dwDesiredAccess, dwFileOffsetHigh, dwFileOffsetLow, dwNumberOfBytesToMap, lpBaseAddress, nndPreferred) = DLL("KERNEL32.dll", "void* MapViewOfFileExNuma(void*, dword, dword, dword, int, void*, dword)")
# 呼び出し: MapViewOfFileExNuma(hFileMappingObject, dwDesiredAccess, dwFileOffsetHigh, dwFileOffsetLow, dwNumberOfBytesToMap, lpBaseAddress, nndPreferred)
# hFileMappingObject : HANDLE -> "void*"
# dwDesiredAccess : FILE_MAP -> "dword"
# dwFileOffsetHigh : DWORD -> "dword"
# dwFileOffsetLow : DWORD -> "dword"
# dwNumberOfBytesToMap : UINT_PTR -> "int"
# lpBaseAddress : void* optional -> "void*"
# nndPreferred : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。