ホーム › System.Memory › MapViewOfFileNuma2
MapViewOfFileNuma2
関数NUMAノードを指定してファイルマッピングのビューをマップする。
シグネチャ
// api-ms-win-core-memory-l1-1-5.dll
#include <windows.h>
MEMORY_MAPPED_VIEW_ADDRESS MapViewOfFileNuma2(
HANDLE FileMappingHandle,
HANDLE ProcessHandle,
ULONGLONG Offset,
void* BaseAddress, // optional
UINT_PTR ViewSize,
DWORD AllocationType,
DWORD PageProtection,
DWORD PreferredNode
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| FileMappingHandle | HANDLE | in | 指定したプロセスのアドレス空間にマップするセクションへの HANDLE。 |
| ProcessHandle | HANDLE | in | セクションのマップ先となるプロセスへの HANDLE。 |
| Offset | ULONGLONG | in | セクションの先頭からのオフセット。 64k 境界に整列している必要があります。 |
| BaseAddress | void* | inoptional | ビューに割り当てる希望のベースアドレス。 アドレスは直近の 64k 境界へ切り下げられます。 このパラメーターが NULL の場合、システムがベースアドレスを選択します。 |
| ViewSize | UINT_PTR | in | マップするバイト数。ゼロ (0) を指定すると、セクション全体がマップされます。 |
| AllocationType | DWORD | in | 割り当ての種類。このパラメーターにはゼロ (0)、または次の定数値のいずれかを指定できます。
|
| PageProtection | DWORD | in | 希望のページ保護。 SEC_IMAGE 属性を指定して作成されたファイルマッピングオブジェクトの場合、 PageProtection パラメーターは効果を持たないため、 PAGE_READONLY など有効な任意の値を設定してください。 |
| PreferredNode | DWORD | in | このメモリに対して優先される NUMA ノード。 |
戻り値の型: MEMORY_MAPPED_VIEW_ADDRESS
公式ドキュメント
ファイルまたはページファイルでバックされたセクションのビューを、指定したプロセスのアドレス空間にマップします。(MapViewOfFileNuma2)
戻り値
成功した場合、マップされたビューのベースアドレスを返します。失敗した場合は NULL を返し、拡張エラー情報は GetLastError で取得できます。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// api-ms-win-core-memory-l1-1-5.dll
#include <windows.h>
MEMORY_MAPPED_VIEW_ADDRESS MapViewOfFileNuma2(
HANDLE FileMappingHandle,
HANDLE ProcessHandle,
ULONGLONG Offset,
void* BaseAddress, // optional
UINT_PTR ViewSize,
DWORD AllocationType,
DWORD PageProtection,
DWORD PreferredNode
);[DllImport("api-ms-win-core-memory-l1-1-5.dll", SetLastError = true, ExactSpelling = true)]
static extern MEMORY_MAPPED_VIEW_ADDRESS MapViewOfFileNuma2(
IntPtr FileMappingHandle, // HANDLE
IntPtr ProcessHandle, // HANDLE
ulong Offset, // ULONGLONG
IntPtr BaseAddress, // void* optional
UIntPtr ViewSize, // UINT_PTR
uint AllocationType, // DWORD
uint PageProtection, // DWORD
uint PreferredNode // DWORD
);<DllImport("api-ms-win-core-memory-l1-1-5.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function MapViewOfFileNuma2(
FileMappingHandle As IntPtr, ' HANDLE
ProcessHandle As IntPtr, ' HANDLE
Offset As ULong, ' ULONGLONG
BaseAddress As IntPtr, ' void* optional
ViewSize As UIntPtr, ' UINT_PTR
AllocationType As UInteger, ' DWORD
PageProtection As UInteger, ' DWORD
PreferredNode As UInteger ' DWORD
) As MEMORY_MAPPED_VIEW_ADDRESS
End Function' FileMappingHandle : HANDLE
' ProcessHandle : HANDLE
' Offset : ULONGLONG
' BaseAddress : void* optional
' ViewSize : UINT_PTR
' AllocationType : DWORD
' PageProtection : DWORD
' PreferredNode : DWORD
Declare PtrSafe Function MapViewOfFileNuma2 Lib "api-ms-win-core-memory-l1-1-5" ( _
ByVal FileMappingHandle As LongPtr, _
ByVal ProcessHandle As LongPtr, _
ByVal Offset As LongLong, _
ByVal BaseAddress As LongPtr, _
ByVal ViewSize As LongPtr, _
ByVal AllocationType As Long, _
ByVal PageProtection As Long, _
ByVal PreferredNode As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MapViewOfFileNuma2 = ctypes.windll.LoadLibrary("api-ms-win-core-memory-l1-1-5.dll").MapViewOfFileNuma2
MapViewOfFileNuma2.restype = ctypes.c_void_p
MapViewOfFileNuma2.argtypes = [
wintypes.HANDLE, # FileMappingHandle : HANDLE
wintypes.HANDLE, # ProcessHandle : HANDLE
ctypes.c_ulonglong, # Offset : ULONGLONG
ctypes.POINTER(None), # BaseAddress : void* optional
ctypes.c_size_t, # ViewSize : UINT_PTR
wintypes.DWORD, # AllocationType : DWORD
wintypes.DWORD, # PageProtection : DWORD
wintypes.DWORD, # PreferredNode : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('api-ms-win-core-memory-l1-1-5.dll')
MapViewOfFileNuma2 = Fiddle::Function.new(
lib['MapViewOfFileNuma2'],
[
Fiddle::TYPE_VOIDP, # FileMappingHandle : HANDLE
Fiddle::TYPE_VOIDP, # ProcessHandle : HANDLE
-Fiddle::TYPE_LONG_LONG, # Offset : ULONGLONG
Fiddle::TYPE_VOIDP, # BaseAddress : void* optional
Fiddle::TYPE_UINTPTR_T, # ViewSize : UINT_PTR
-Fiddle::TYPE_INT, # AllocationType : DWORD
-Fiddle::TYPE_INT, # PageProtection : DWORD
-Fiddle::TYPE_INT, # PreferredNode : DWORD
],
Fiddle::TYPE_VOIDP)#[link(name = "api-ms-win-core-memory-l1-1-5")]
extern "system" {
fn MapViewOfFileNuma2(
FileMappingHandle: *mut core::ffi::c_void, // HANDLE
ProcessHandle: *mut core::ffi::c_void, // HANDLE
Offset: u64, // ULONGLONG
BaseAddress: *mut (), // void* optional
ViewSize: usize, // UINT_PTR
AllocationType: u32, // DWORD
PageProtection: u32, // DWORD
PreferredNode: u32 // DWORD
) -> MEMORY_MAPPED_VIEW_ADDRESS;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("api-ms-win-core-memory-l1-1-5.dll", SetLastError = true)]
public static extern MEMORY_MAPPED_VIEW_ADDRESS MapViewOfFileNuma2(IntPtr FileMappingHandle, IntPtr ProcessHandle, ulong Offset, IntPtr BaseAddress, UIntPtr ViewSize, uint AllocationType, uint PageProtection, uint PreferredNode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-memory-l1-1-5_MapViewOfFileNuma2' -Namespace Win32 -PassThru
# $api::MapViewOfFileNuma2(FileMappingHandle, ProcessHandle, Offset, BaseAddress, ViewSize, AllocationType, PageProtection, PreferredNode)#uselib "api-ms-win-core-memory-l1-1-5.dll"
#func global MapViewOfFileNuma2 "MapViewOfFileNuma2" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; MapViewOfFileNuma2 FileMappingHandle, ProcessHandle, Offset, BaseAddress, ViewSize, AllocationType, PageProtection, PreferredNode ; 戻り値は stat
; FileMappingHandle : HANDLE -> "sptr"
; ProcessHandle : HANDLE -> "sptr"
; Offset : ULONGLONG -> "sptr"
; BaseAddress : void* optional -> "sptr"
; ViewSize : UINT_PTR -> "sptr"
; AllocationType : DWORD -> "sptr"
; PageProtection : DWORD -> "sptr"
; PreferredNode : DWORD -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "api-ms-win-core-memory-l1-1-5.dll"
#cfunc global MapViewOfFileNuma2 "MapViewOfFileNuma2" sptr, sptr, int64, sptr, sptr, int, int, int
; res = MapViewOfFileNuma2(FileMappingHandle, ProcessHandle, Offset, BaseAddress, ViewSize, AllocationType, PageProtection, PreferredNode)
; FileMappingHandle : HANDLE -> "sptr"
; ProcessHandle : HANDLE -> "sptr"
; Offset : ULONGLONG -> "int64"
; BaseAddress : void* optional -> "sptr"
; ViewSize : UINT_PTR -> "sptr"
; AllocationType : DWORD -> "int"
; PageProtection : DWORD -> "int"
; PreferredNode : DWORD -> "int"
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。; MEMORY_MAPPED_VIEW_ADDRESS MapViewOfFileNuma2(HANDLE FileMappingHandle, HANDLE ProcessHandle, ULONGLONG Offset, void* BaseAddress, UINT_PTR ViewSize, DWORD AllocationType, DWORD PageProtection, DWORD PreferredNode)
#uselib "api-ms-win-core-memory-l1-1-5.dll"
#cfunc global MapViewOfFileNuma2 "MapViewOfFileNuma2" intptr, intptr, int64, intptr, intptr, int, int, int
; res = MapViewOfFileNuma2(FileMappingHandle, ProcessHandle, Offset, BaseAddress, ViewSize, AllocationType, PageProtection, PreferredNode)
; FileMappingHandle : HANDLE -> "intptr"
; ProcessHandle : HANDLE -> "intptr"
; Offset : ULONGLONG -> "int64"
; BaseAddress : void* optional -> "intptr"
; ViewSize : UINT_PTR -> "intptr"
; AllocationType : DWORD -> "int"
; PageProtection : DWORD -> "int"
; PreferredNode : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
api_ms_win_core_memory_l1_1_5 = windows.NewLazySystemDLL("api-ms-win-core-memory-l1-1-5.dll")
procMapViewOfFileNuma2 = api_ms_win_core_memory_l1_1_5.NewProc("MapViewOfFileNuma2")
)
// FileMappingHandle (HANDLE), ProcessHandle (HANDLE), Offset (ULONGLONG), BaseAddress (void* optional), ViewSize (UINT_PTR), AllocationType (DWORD), PageProtection (DWORD), PreferredNode (DWORD)
r1, _, err := procMapViewOfFileNuma2.Call(
uintptr(FileMappingHandle),
uintptr(ProcessHandle),
uintptr(Offset),
uintptr(BaseAddress),
uintptr(ViewSize),
uintptr(AllocationType),
uintptr(PageProtection),
uintptr(PreferredNode),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // MEMORY_MAPPED_VIEW_ADDRESSfunction MapViewOfFileNuma2(
FileMappingHandle: THandle; // HANDLE
ProcessHandle: THandle; // HANDLE
Offset: UInt64; // ULONGLONG
BaseAddress: Pointer; // void* optional
ViewSize: NativeUInt; // UINT_PTR
AllocationType: DWORD; // DWORD
PageProtection: DWORD; // DWORD
PreferredNode: DWORD // DWORD
): MEMORY_MAPPED_VIEW_ADDRESS; stdcall;
external 'api-ms-win-core-memory-l1-1-5.dll' name 'MapViewOfFileNuma2';result := DllCall("api-ms-win-core-memory-l1-1-5\MapViewOfFileNuma2"
, "Ptr", FileMappingHandle ; HANDLE
, "Ptr", ProcessHandle ; HANDLE
, "Int64", Offset ; ULONGLONG
, "Ptr", BaseAddress ; void* optional
, "UPtr", ViewSize ; UINT_PTR
, "UInt", AllocationType ; DWORD
, "UInt", PageProtection ; DWORD
, "UInt", PreferredNode ; DWORD
, "Ptr") ; return: MEMORY_MAPPED_VIEW_ADDRESS●MapViewOfFileNuma2(FileMappingHandle, ProcessHandle, Offset, BaseAddress, ViewSize, AllocationType, PageProtection, PreferredNode) = DLL("api-ms-win-core-memory-l1-1-5.dll", "void* MapViewOfFileNuma2(void*, void*, qword, void*, int, dword, dword, dword)")
# 呼び出し: MapViewOfFileNuma2(FileMappingHandle, ProcessHandle, Offset, BaseAddress, ViewSize, AllocationType, PageProtection, PreferredNode)
# FileMappingHandle : HANDLE -> "void*"
# ProcessHandle : HANDLE -> "void*"
# Offset : ULONGLONG -> "qword"
# BaseAddress : void* optional -> "void*"
# ViewSize : UINT_PTR -> "int"
# AllocationType : DWORD -> "dword"
# PageProtection : DWORD -> "dword"
# PreferredNode : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "api-ms-win-core-memory-l1-1-5" fn MapViewOfFileNuma2(
FileMappingHandle: ?*anyopaque, // HANDLE
ProcessHandle: ?*anyopaque, // HANDLE
Offset: u64, // ULONGLONG
BaseAddress: ?*anyopaque, // void* optional
ViewSize: usize, // UINT_PTR
AllocationType: u32, // DWORD
PageProtection: u32, // DWORD
PreferredNode: u32 // DWORD
) callconv(std.os.windows.WINAPI) MEMORY_MAPPED_VIEW_ADDRESS;proc MapViewOfFileNuma2(
FileMappingHandle: pointer, # HANDLE
ProcessHandle: pointer, # HANDLE
Offset: uint64, # ULONGLONG
BaseAddress: pointer, # void* optional
ViewSize: uint, # UINT_PTR
AllocationType: uint32, # DWORD
PageProtection: uint32, # DWORD
PreferredNode: uint32 # DWORD
): MEMORY_MAPPED_VIEW_ADDRESS {.importc: "MapViewOfFileNuma2", stdcall, dynlib: "api-ms-win-core-memory-l1-1-5.dll".}pragma(lib, "api-ms-win-core-memory-l1-1-5");
extern(Windows)
MEMORY_MAPPED_VIEW_ADDRESS MapViewOfFileNuma2(
void* FileMappingHandle, // HANDLE
void* ProcessHandle, // HANDLE
ulong Offset, // ULONGLONG
void* BaseAddress, // void* optional
size_t ViewSize, // UINT_PTR
uint AllocationType, // DWORD
uint PageProtection, // DWORD
uint PreferredNode // DWORD
);ccall((:MapViewOfFileNuma2, "api-ms-win-core-memory-l1-1-5.dll"), stdcall, MEMORY_MAPPED_VIEW_ADDRESS,
(Ptr{Cvoid}, Ptr{Cvoid}, UInt64, Ptr{Cvoid}, Csize_t, UInt32, UInt32, UInt32),
FileMappingHandle, ProcessHandle, Offset, BaseAddress, ViewSize, AllocationType, PageProtection, PreferredNode)
# FileMappingHandle : HANDLE -> Ptr{Cvoid}
# ProcessHandle : HANDLE -> Ptr{Cvoid}
# Offset : ULONGLONG -> UInt64
# BaseAddress : void* optional -> Ptr{Cvoid}
# ViewSize : UINT_PTR -> Csize_t
# AllocationType : DWORD -> UInt32
# PageProtection : DWORD -> UInt32
# PreferredNode : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
MEMORY_MAPPED_VIEW_ADDRESS MapViewOfFileNuma2(
void* FileMappingHandle,
void* ProcessHandle,
uint64_t Offset,
void* BaseAddress,
uintptr_t ViewSize,
uint32_t AllocationType,
uint32_t PageProtection,
uint32_t PreferredNode);
]]
local api-ms-win-core-memory-l1-1-5 = ffi.load("api-ms-win-core-memory-l1-1-5")
-- api-ms-win-core-memory-l1-1-5.MapViewOfFileNuma2(FileMappingHandle, ProcessHandle, Offset, BaseAddress, ViewSize, AllocationType, PageProtection, PreferredNode)
-- FileMappingHandle : HANDLE
-- ProcessHandle : HANDLE
-- Offset : ULONGLONG
-- BaseAddress : void* optional
-- ViewSize : UINT_PTR
-- AllocationType : DWORD
-- PageProtection : DWORD
-- PreferredNode : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('api-ms-win-core-memory-l1-1-5.dll');
const MapViewOfFileNuma2 = lib.func('__stdcall', 'MapViewOfFileNuma2', 'MEMORY_MAPPED_VIEW_ADDRESS', ['void *', 'void *', 'uint64_t', 'void *', 'uintptr_t', 'uint32_t', 'uint32_t', 'uint32_t']);
// MapViewOfFileNuma2(FileMappingHandle, ProcessHandle, Offset, BaseAddress, ViewSize, AllocationType, PageProtection, PreferredNode)
// FileMappingHandle : HANDLE -> 'void *'
// ProcessHandle : HANDLE -> 'void *'
// Offset : ULONGLONG -> 'uint64_t'
// BaseAddress : void* optional -> 'void *'
// ViewSize : UINT_PTR -> 'uintptr_t'
// AllocationType : DWORD -> 'uint32_t'
// PageProtection : DWORD -> 'uint32_t'
// PreferredNode : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("api-ms-win-core-memory-l1-1-5.dll", {
MapViewOfFileNuma2: { parameters: ["pointer", "pointer", "u64", "pointer", "usize", "u32", "u32", "u32"], result: "pointer" },
});
// lib.symbols.MapViewOfFileNuma2(FileMappingHandle, ProcessHandle, Offset, BaseAddress, ViewSize, AllocationType, PageProtection, PreferredNode)
// FileMappingHandle : HANDLE -> "pointer"
// ProcessHandle : HANDLE -> "pointer"
// Offset : ULONGLONG -> "u64"
// BaseAddress : void* optional -> "pointer"
// ViewSize : UINT_PTR -> "usize"
// AllocationType : DWORD -> "u32"
// PageProtection : DWORD -> "u32"
// PreferredNode : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
MEMORY_MAPPED_VIEW_ADDRESS MapViewOfFileNuma2(
void* FileMappingHandle,
void* ProcessHandle,
uint64_t Offset,
void* BaseAddress,
size_t ViewSize,
uint32_t AllocationType,
uint32_t PageProtection,
uint32_t PreferredNode);
C, "api-ms-win-core-memory-l1-1-5.dll");
// $ffi->MapViewOfFileNuma2(FileMappingHandle, ProcessHandle, Offset, BaseAddress, ViewSize, AllocationType, PageProtection, PreferredNode);
// FileMappingHandle : HANDLE
// ProcessHandle : HANDLE
// Offset : ULONGLONG
// BaseAddress : void* optional
// ViewSize : UINT_PTR
// AllocationType : DWORD
// PageProtection : DWORD
// PreferredNode : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Api-ms-win-core-memory-l1-1-5 extends StdCallLibrary {
Api-ms-win-core-memory-l1-1-5 INSTANCE = Native.load("api-ms-win-core-memory-l1-1-5", Api-ms-win-core-memory-l1-1-5.class);
MEMORY_MAPPED_VIEW_ADDRESS MapViewOfFileNuma2(
Pointer FileMappingHandle, // HANDLE
Pointer ProcessHandle, // HANDLE
long Offset, // ULONGLONG
Pointer BaseAddress, // void* optional
long ViewSize, // UINT_PTR
int AllocationType, // DWORD
int PageProtection, // DWORD
int PreferredNode // DWORD
);
}@[Link("api-ms-win-core-memory-l1-1-5")]
lib Libapi-ms-win-core-memory-l1-1-5
fun MapViewOfFileNuma2 = MapViewOfFileNuma2(
FileMappingHandle : Void*, # HANDLE
ProcessHandle : Void*, # HANDLE
Offset : UInt64, # ULONGLONG
BaseAddress : Void*, # void* optional
ViewSize : LibC::SizeT, # UINT_PTR
AllocationType : UInt32, # DWORD
PageProtection : UInt32, # DWORD
PreferredNode : UInt32 # DWORD
) : MEMORY_MAPPED_VIEW_ADDRESS
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MapViewOfFileNuma2Native = MEMORY_MAPPED_VIEW_ADDRESS Function(Pointer<Void>, Pointer<Void>, Uint64, Pointer<Void>, UintPtr, Uint32, Uint32, Uint32);
typedef MapViewOfFileNuma2Dart = int Function(Pointer<Void>, Pointer<Void>, int, Pointer<Void>, int, int, int, int);
final MapViewOfFileNuma2 = DynamicLibrary.open('api-ms-win-core-memory-l1-1-5.dll')
.lookupFunction<MapViewOfFileNuma2Native, MapViewOfFileNuma2Dart>('MapViewOfFileNuma2');
// FileMappingHandle : HANDLE -> Pointer<Void>
// ProcessHandle : HANDLE -> Pointer<Void>
// Offset : ULONGLONG -> Uint64
// BaseAddress : void* optional -> Pointer<Void>
// ViewSize : UINT_PTR -> UintPtr
// AllocationType : DWORD -> Uint32
// PageProtection : DWORD -> Uint32
// PreferredNode : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MapViewOfFileNuma2(
FileMappingHandle: THandle; // HANDLE
ProcessHandle: THandle; // HANDLE
Offset: UInt64; // ULONGLONG
BaseAddress: Pointer; // void* optional
ViewSize: NativeUInt; // UINT_PTR
AllocationType: DWORD; // DWORD
PageProtection: DWORD; // DWORD
PreferredNode: DWORD // DWORD
): MEMORY_MAPPED_VIEW_ADDRESS; stdcall;
external 'api-ms-win-core-memory-l1-1-5.dll' name 'MapViewOfFileNuma2';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MapViewOfFileNuma2"
c_MapViewOfFileNuma2 :: Ptr () -> Ptr () -> Word64 -> Ptr () -> CUIntPtr -> Word32 -> Word32 -> Word32 -> IO MEMORY_MAPPED_VIEW_ADDRESS
-- FileMappingHandle : HANDLE -> Ptr ()
-- ProcessHandle : HANDLE -> Ptr ()
-- Offset : ULONGLONG -> Word64
-- BaseAddress : void* optional -> Ptr ()
-- ViewSize : UINT_PTR -> CUIntPtr
-- AllocationType : DWORD -> Word32
-- PageProtection : DWORD -> Word32
-- PreferredNode : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
-- ※値渡し構造体は GHC FFI で直接渡せません。Ptr で渡すラッパ(C側)経由にしてください。open Ctypes
open Foreign
let mapviewoffilenuma2 =
foreign "MapViewOfFileNuma2"
((ptr void) @-> (ptr void) @-> uint64_t @-> (ptr void) @-> size_t @-> uint32_t @-> uint32_t @-> uint32_t @-> returning MEMORY_MAPPED_VIEW_ADDRESS)
(* FileMappingHandle : HANDLE -> (ptr void) *)
(* ProcessHandle : HANDLE -> (ptr void) *)
(* Offset : ULONGLONG -> uint64_t *)
(* BaseAddress : void* optional -> (ptr void) *)
(* ViewSize : UINT_PTR -> size_t *)
(* AllocationType : DWORD -> uint32_t *)
(* PageProtection : DWORD -> uint32_t *)
(* PreferredNode : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library api-ms-win-core-memory-l1-1-5 (t "api-ms-win-core-memory-l1-1-5.dll"))
(cffi:use-foreign-library api-ms-win-core-memory-l1-1-5)
(cffi:defcfun ("MapViewOfFileNuma2" map-view-of-file-numa2 :convention :stdcall) (:struct memory-mapped-view-address)
(file-mapping-handle :pointer) ; HANDLE
(process-handle :pointer) ; HANDLE
(offset :uint64) ; ULONGLONG
(base-address :pointer) ; void* optional
(view-size :uint64) ; UINT_PTR
(allocation-type :uint32) ; DWORD
(page-protection :uint32) ; DWORD
(preferred-node :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MapViewOfFileNuma2 = Win32::API::More->new('api-ms-win-core-memory-l1-1-5',
'LPVOID MapViewOfFileNuma2(HANDLE FileMappingHandle, HANDLE ProcessHandle, UINT64 Offset, LPVOID BaseAddress, WPARAM ViewSize, DWORD AllocationType, DWORD PageProtection, DWORD PreferredNode)');
# my $ret = $MapViewOfFileNuma2->Call($FileMappingHandle, $ProcessHandle, $Offset, $BaseAddress, $ViewSize, $AllocationType, $PageProtection, $PreferredNode);
# FileMappingHandle : HANDLE -> HANDLE
# ProcessHandle : HANDLE -> HANDLE
# Offset : ULONGLONG -> UINT64
# BaseAddress : void* optional -> LPVOID
# ViewSize : UINT_PTR -> WPARAM
# AllocationType : DWORD -> DWORD
# PageProtection : DWORD -> DWORD
# PreferredNode : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f MapViewOfFile — ファイルマッピングのビューを呼び出し元プロセスのアドレス空間にマップする。