ホーム › System.Memory › MapViewOfFile3FromApp
MapViewOfFile3FromApp
関数UWPアプリ向けに拡張パラメータ付きでビューをマップする。
シグネチャ
// api-ms-win-core-memory-l1-1-6.dll
#include <windows.h>
MEMORY_MAPPED_VIEW_ADDRESS MapViewOfFile3FromApp(
HANDLE FileMapping,
HANDLE Process, // optional
void* BaseAddress, // optional
ULONGLONG Offset,
UINT_PTR ViewSize,
VIRTUAL_ALLOCATION_TYPE AllocationType,
DWORD PageProtection,
MEM_EXTENDED_PARAMETER* ExtendedParameters, // optional
DWORD ParameterCount
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| FileMapping | HANDLE | in |
| Process | HANDLE | inoptional |
| BaseAddress | void* | inoptional |
| Offset | ULONGLONG | in |
| ViewSize | UINT_PTR | in |
| AllocationType | VIRTUAL_ALLOCATION_TYPE | in |
| PageProtection | DWORD | in |
| ExtendedParameters | MEM_EXTENDED_PARAMETER* | inoutoptional |
| ParameterCount | DWORD | in |
戻り値の型: MEMORY_MAPPED_VIEW_ADDRESS
各言語での呼び出し定義
// api-ms-win-core-memory-l1-1-6.dll
#include <windows.h>
MEMORY_MAPPED_VIEW_ADDRESS MapViewOfFile3FromApp(
HANDLE FileMapping,
HANDLE Process, // optional
void* BaseAddress, // optional
ULONGLONG Offset,
UINT_PTR ViewSize,
VIRTUAL_ALLOCATION_TYPE AllocationType,
DWORD PageProtection,
MEM_EXTENDED_PARAMETER* ExtendedParameters, // optional
DWORD ParameterCount
);[DllImport("api-ms-win-core-memory-l1-1-6.dll", SetLastError = true, ExactSpelling = true)]
static extern MEMORY_MAPPED_VIEW_ADDRESS MapViewOfFile3FromApp(
IntPtr FileMapping, // HANDLE
IntPtr Process, // HANDLE optional
IntPtr BaseAddress, // void* optional
ulong Offset, // ULONGLONG
UIntPtr ViewSize, // UINT_PTR
uint AllocationType, // VIRTUAL_ALLOCATION_TYPE
uint PageProtection, // DWORD
IntPtr ExtendedParameters, // MEM_EXTENDED_PARAMETER* optional, in/out
uint ParameterCount // DWORD
);<DllImport("api-ms-win-core-memory-l1-1-6.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function MapViewOfFile3FromApp(
FileMapping As IntPtr, ' HANDLE
Process As IntPtr, ' HANDLE optional
BaseAddress As IntPtr, ' void* optional
Offset As ULong, ' ULONGLONG
ViewSize As UIntPtr, ' UINT_PTR
AllocationType As UInteger, ' VIRTUAL_ALLOCATION_TYPE
PageProtection As UInteger, ' DWORD
ExtendedParameters As IntPtr, ' MEM_EXTENDED_PARAMETER* optional, in/out
ParameterCount As UInteger ' DWORD
) As MEMORY_MAPPED_VIEW_ADDRESS
End Function' FileMapping : HANDLE
' Process : HANDLE optional
' BaseAddress : void* optional
' Offset : ULONGLONG
' ViewSize : UINT_PTR
' AllocationType : VIRTUAL_ALLOCATION_TYPE
' PageProtection : DWORD
' ExtendedParameters : MEM_EXTENDED_PARAMETER* optional, in/out
' ParameterCount : DWORD
Declare PtrSafe Function MapViewOfFile3FromApp Lib "api-ms-win-core-memory-l1-1-6" ( _
ByVal FileMapping As LongPtr, _
ByVal Process As LongPtr, _
ByVal BaseAddress As LongPtr, _
ByVal Offset As LongLong, _
ByVal ViewSize As LongPtr, _
ByVal AllocationType As Long, _
ByVal PageProtection As Long, _
ByVal ExtendedParameters As LongPtr, _
ByVal ParameterCount As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MapViewOfFile3FromApp = ctypes.windll.LoadLibrary("api-ms-win-core-memory-l1-1-6.dll").MapViewOfFile3FromApp
MapViewOfFile3FromApp.restype = ctypes.c_void_p
MapViewOfFile3FromApp.argtypes = [
wintypes.HANDLE, # FileMapping : HANDLE
wintypes.HANDLE, # Process : HANDLE optional
ctypes.POINTER(None), # BaseAddress : void* optional
ctypes.c_ulonglong, # Offset : ULONGLONG
ctypes.c_size_t, # ViewSize : UINT_PTR
wintypes.DWORD, # AllocationType : VIRTUAL_ALLOCATION_TYPE
wintypes.DWORD, # PageProtection : DWORD
ctypes.c_void_p, # ExtendedParameters : MEM_EXTENDED_PARAMETER* optional, in/out
wintypes.DWORD, # ParameterCount : 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-6.dll')
MapViewOfFile3FromApp = Fiddle::Function.new(
lib['MapViewOfFile3FromApp'],
[
Fiddle::TYPE_VOIDP, # FileMapping : HANDLE
Fiddle::TYPE_VOIDP, # Process : HANDLE optional
Fiddle::TYPE_VOIDP, # BaseAddress : void* optional
-Fiddle::TYPE_LONG_LONG, # Offset : ULONGLONG
Fiddle::TYPE_UINTPTR_T, # ViewSize : UINT_PTR
-Fiddle::TYPE_INT, # AllocationType : VIRTUAL_ALLOCATION_TYPE
-Fiddle::TYPE_INT, # PageProtection : DWORD
Fiddle::TYPE_VOIDP, # ExtendedParameters : MEM_EXTENDED_PARAMETER* optional, in/out
-Fiddle::TYPE_INT, # ParameterCount : DWORD
],
Fiddle::TYPE_VOIDP)#[link(name = "api-ms-win-core-memory-l1-1-6")]
extern "system" {
fn MapViewOfFile3FromApp(
FileMapping: *mut core::ffi::c_void, // HANDLE
Process: *mut core::ffi::c_void, // HANDLE optional
BaseAddress: *mut (), // void* optional
Offset: u64, // ULONGLONG
ViewSize: usize, // UINT_PTR
AllocationType: u32, // VIRTUAL_ALLOCATION_TYPE
PageProtection: u32, // DWORD
ExtendedParameters: *mut MEM_EXTENDED_PARAMETER, // MEM_EXTENDED_PARAMETER* optional, in/out
ParameterCount: 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-6.dll", SetLastError = true)]
public static extern MEMORY_MAPPED_VIEW_ADDRESS MapViewOfFile3FromApp(IntPtr FileMapping, IntPtr Process, IntPtr BaseAddress, ulong Offset, UIntPtr ViewSize, uint AllocationType, uint PageProtection, IntPtr ExtendedParameters, uint ParameterCount);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-memory-l1-1-6_MapViewOfFile3FromApp' -Namespace Win32 -PassThru
# $api::MapViewOfFile3FromApp(FileMapping, Process, BaseAddress, Offset, ViewSize, AllocationType, PageProtection, ExtendedParameters, ParameterCount)#uselib "api-ms-win-core-memory-l1-1-6.dll"
#func global MapViewOfFile3FromApp "MapViewOfFile3FromApp" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; MapViewOfFile3FromApp FileMapping, Process, BaseAddress, Offset, ViewSize, AllocationType, PageProtection, varptr(ExtendedParameters), ParameterCount ; 戻り値は stat
; FileMapping : HANDLE -> "sptr"
; Process : HANDLE optional -> "sptr"
; BaseAddress : void* optional -> "sptr"
; Offset : ULONGLONG -> "sptr"
; ViewSize : UINT_PTR -> "sptr"
; AllocationType : VIRTUAL_ALLOCATION_TYPE -> "sptr"
; PageProtection : DWORD -> "sptr"
; ExtendedParameters : MEM_EXTENDED_PARAMETER* optional, in/out -> "sptr"
; ParameterCount : DWORD -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "api-ms-win-core-memory-l1-1-6.dll" #cfunc global MapViewOfFile3FromApp "MapViewOfFile3FromApp" sptr, sptr, sptr, int64, sptr, int, int, var, int ; res = MapViewOfFile3FromApp(FileMapping, Process, BaseAddress, Offset, ViewSize, AllocationType, PageProtection, ExtendedParameters, ParameterCount) ; FileMapping : HANDLE -> "sptr" ; Process : HANDLE optional -> "sptr" ; BaseAddress : void* optional -> "sptr" ; Offset : ULONGLONG -> "int64" ; ViewSize : UINT_PTR -> "sptr" ; AllocationType : VIRTUAL_ALLOCATION_TYPE -> "int" ; PageProtection : DWORD -> "int" ; ExtendedParameters : MEM_EXTENDED_PARAMETER* optional, in/out -> "var" ; ParameterCount : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。#uselib "api-ms-win-core-memory-l1-1-6.dll" #cfunc global MapViewOfFile3FromApp "MapViewOfFile3FromApp" sptr, sptr, sptr, int64, sptr, int, int, sptr, int ; res = MapViewOfFile3FromApp(FileMapping, Process, BaseAddress, Offset, ViewSize, AllocationType, PageProtection, varptr(ExtendedParameters), ParameterCount) ; FileMapping : HANDLE -> "sptr" ; Process : HANDLE optional -> "sptr" ; BaseAddress : void* optional -> "sptr" ; Offset : ULONGLONG -> "int64" ; ViewSize : UINT_PTR -> "sptr" ; AllocationType : VIRTUAL_ALLOCATION_TYPE -> "int" ; PageProtection : DWORD -> "int" ; ExtendedParameters : MEM_EXTENDED_PARAMETER* optional, in/out -> "sptr" ; ParameterCount : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
出力引数:
; MEMORY_MAPPED_VIEW_ADDRESS MapViewOfFile3FromApp(HANDLE FileMapping, HANDLE Process, void* BaseAddress, ULONGLONG Offset, UINT_PTR ViewSize, VIRTUAL_ALLOCATION_TYPE AllocationType, DWORD PageProtection, MEM_EXTENDED_PARAMETER* ExtendedParameters, DWORD ParameterCount) #uselib "api-ms-win-core-memory-l1-1-6.dll" #cfunc global MapViewOfFile3FromApp "MapViewOfFile3FromApp" intptr, intptr, intptr, int64, intptr, int, int, var, int ; res = MapViewOfFile3FromApp(FileMapping, Process, BaseAddress, Offset, ViewSize, AllocationType, PageProtection, ExtendedParameters, ParameterCount) ; FileMapping : HANDLE -> "intptr" ; Process : HANDLE optional -> "intptr" ; BaseAddress : void* optional -> "intptr" ; Offset : ULONGLONG -> "int64" ; ViewSize : UINT_PTR -> "intptr" ; AllocationType : VIRTUAL_ALLOCATION_TYPE -> "int" ; PageProtection : DWORD -> "int" ; ExtendedParameters : MEM_EXTENDED_PARAMETER* optional, in/out -> "var" ; ParameterCount : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; MEMORY_MAPPED_VIEW_ADDRESS MapViewOfFile3FromApp(HANDLE FileMapping, HANDLE Process, void* BaseAddress, ULONGLONG Offset, UINT_PTR ViewSize, VIRTUAL_ALLOCATION_TYPE AllocationType, DWORD PageProtection, MEM_EXTENDED_PARAMETER* ExtendedParameters, DWORD ParameterCount) #uselib "api-ms-win-core-memory-l1-1-6.dll" #cfunc global MapViewOfFile3FromApp "MapViewOfFile3FromApp" intptr, intptr, intptr, int64, intptr, int, int, intptr, int ; res = MapViewOfFile3FromApp(FileMapping, Process, BaseAddress, Offset, ViewSize, AllocationType, PageProtection, varptr(ExtendedParameters), ParameterCount) ; FileMapping : HANDLE -> "intptr" ; Process : HANDLE optional -> "intptr" ; BaseAddress : void* optional -> "intptr" ; Offset : ULONGLONG -> "int64" ; ViewSize : UINT_PTR -> "intptr" ; AllocationType : VIRTUAL_ALLOCATION_TYPE -> "int" ; PageProtection : DWORD -> "int" ; ExtendedParameters : MEM_EXTENDED_PARAMETER* optional, in/out -> "intptr" ; ParameterCount : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
api_ms_win_core_memory_l1_1_6 = windows.NewLazySystemDLL("api-ms-win-core-memory-l1-1-6.dll")
procMapViewOfFile3FromApp = api_ms_win_core_memory_l1_1_6.NewProc("MapViewOfFile3FromApp")
)
// FileMapping (HANDLE), Process (HANDLE optional), BaseAddress (void* optional), Offset (ULONGLONG), ViewSize (UINT_PTR), AllocationType (VIRTUAL_ALLOCATION_TYPE), PageProtection (DWORD), ExtendedParameters (MEM_EXTENDED_PARAMETER* optional, in/out), ParameterCount (DWORD)
r1, _, err := procMapViewOfFile3FromApp.Call(
uintptr(FileMapping),
uintptr(Process),
uintptr(BaseAddress),
uintptr(Offset),
uintptr(ViewSize),
uintptr(AllocationType),
uintptr(PageProtection),
uintptr(ExtendedParameters),
uintptr(ParameterCount),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // MEMORY_MAPPED_VIEW_ADDRESSfunction MapViewOfFile3FromApp(
FileMapping: THandle; // HANDLE
Process: THandle; // HANDLE optional
BaseAddress: Pointer; // void* optional
Offset: UInt64; // ULONGLONG
ViewSize: NativeUInt; // UINT_PTR
AllocationType: DWORD; // VIRTUAL_ALLOCATION_TYPE
PageProtection: DWORD; // DWORD
ExtendedParameters: Pointer; // MEM_EXTENDED_PARAMETER* optional, in/out
ParameterCount: DWORD // DWORD
): MEMORY_MAPPED_VIEW_ADDRESS; stdcall;
external 'api-ms-win-core-memory-l1-1-6.dll' name 'MapViewOfFile3FromApp';result := DllCall("api-ms-win-core-memory-l1-1-6\MapViewOfFile3FromApp"
, "Ptr", FileMapping ; HANDLE
, "Ptr", Process ; HANDLE optional
, "Ptr", BaseAddress ; void* optional
, "Int64", Offset ; ULONGLONG
, "UPtr", ViewSize ; UINT_PTR
, "UInt", AllocationType ; VIRTUAL_ALLOCATION_TYPE
, "UInt", PageProtection ; DWORD
, "Ptr", ExtendedParameters ; MEM_EXTENDED_PARAMETER* optional, in/out
, "UInt", ParameterCount ; DWORD
, "Ptr") ; return: MEMORY_MAPPED_VIEW_ADDRESS●MapViewOfFile3FromApp(FileMapping, Process, BaseAddress, Offset, ViewSize, AllocationType, PageProtection, ExtendedParameters, ParameterCount) = DLL("api-ms-win-core-memory-l1-1-6.dll", "void* MapViewOfFile3FromApp(void*, void*, void*, qword, int, dword, dword, void*, dword)")
# 呼び出し: MapViewOfFile3FromApp(FileMapping, Process, BaseAddress, Offset, ViewSize, AllocationType, PageProtection, ExtendedParameters, ParameterCount)
# FileMapping : HANDLE -> "void*"
# Process : HANDLE optional -> "void*"
# BaseAddress : void* optional -> "void*"
# Offset : ULONGLONG -> "qword"
# ViewSize : UINT_PTR -> "int"
# AllocationType : VIRTUAL_ALLOCATION_TYPE -> "dword"
# PageProtection : DWORD -> "dword"
# ExtendedParameters : MEM_EXTENDED_PARAMETER* optional, in/out -> "void*"
# ParameterCount : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。