ホーム › System.Memory › VirtualUnlockEx
VirtualUnlockEx
関数指定プロセスのロックされたメモリ範囲のロックを解除する。
シグネチャ
// api-ms-win-core-memory-l1-1-5.dll
#include <windows.h>
BOOL VirtualUnlockEx(
HANDLE Process, // optional
void* Address,
UINT_PTR Size
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Process | HANDLE | inoptional |
| Address | void* | in |
| Size | UINT_PTR | in |
戻り値の型: BOOL
各言語での呼び出し定義
// api-ms-win-core-memory-l1-1-5.dll
#include <windows.h>
BOOL VirtualUnlockEx(
HANDLE Process, // optional
void* Address,
UINT_PTR Size
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("api-ms-win-core-memory-l1-1-5.dll", ExactSpelling = true)]
static extern bool VirtualUnlockEx(
IntPtr Process, // HANDLE optional
IntPtr Address, // void*
UIntPtr Size // UINT_PTR
);<DllImport("api-ms-win-core-memory-l1-1-5.dll", ExactSpelling:=True)>
Public Shared Function VirtualUnlockEx(
Process As IntPtr, ' HANDLE optional
Address As IntPtr, ' void*
Size As UIntPtr ' UINT_PTR
) As Boolean
End Function' Process : HANDLE optional
' Address : void*
' Size : UINT_PTR
Declare PtrSafe Function VirtualUnlockEx Lib "api-ms-win-core-memory-l1-1-5" ( _
ByVal Process As LongPtr, _
ByVal Address As LongPtr, _
ByVal Size As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
VirtualUnlockEx = ctypes.windll.LoadLibrary("api-ms-win-core-memory-l1-1-5.dll").VirtualUnlockEx
VirtualUnlockEx.restype = wintypes.BOOL
VirtualUnlockEx.argtypes = [
wintypes.HANDLE, # Process : HANDLE optional
ctypes.POINTER(None), # Address : void*
ctypes.c_size_t, # Size : UINT_PTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('api-ms-win-core-memory-l1-1-5.dll')
VirtualUnlockEx = Fiddle::Function.new(
lib['VirtualUnlockEx'],
[
Fiddle::TYPE_VOIDP, # Process : HANDLE optional
Fiddle::TYPE_VOIDP, # Address : void*
Fiddle::TYPE_UINTPTR_T, # Size : UINT_PTR
],
Fiddle::TYPE_INT)#[link(name = "api-ms-win-core-memory-l1-1-5")]
extern "system" {
fn VirtualUnlockEx(
Process: *mut core::ffi::c_void, // HANDLE optional
Address: *mut (), // void*
Size: usize // UINT_PTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("api-ms-win-core-memory-l1-1-5.dll")]
public static extern bool VirtualUnlockEx(IntPtr Process, IntPtr Address, UIntPtr Size);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-memory-l1-1-5_VirtualUnlockEx' -Namespace Win32 -PassThru
# $api::VirtualUnlockEx(Process, Address, Size)#uselib "api-ms-win-core-memory-l1-1-5.dll"
#func global VirtualUnlockEx "VirtualUnlockEx" sptr, sptr, sptr
; VirtualUnlockEx Process, Address, Size ; 戻り値は stat
; Process : HANDLE optional -> "sptr"
; Address : void* -> "sptr"
; Size : UINT_PTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "api-ms-win-core-memory-l1-1-5.dll"
#cfunc global VirtualUnlockEx "VirtualUnlockEx" sptr, sptr, sptr
; res = VirtualUnlockEx(Process, Address, Size)
; Process : HANDLE optional -> "sptr"
; Address : void* -> "sptr"
; Size : UINT_PTR -> "sptr"; BOOL VirtualUnlockEx(HANDLE Process, void* Address, UINT_PTR Size)
#uselib "api-ms-win-core-memory-l1-1-5.dll"
#cfunc global VirtualUnlockEx "VirtualUnlockEx" intptr, intptr, intptr
; res = VirtualUnlockEx(Process, Address, Size)
; Process : HANDLE optional -> "intptr"
; Address : void* -> "intptr"
; Size : UINT_PTR -> "intptr"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")
procVirtualUnlockEx = api_ms_win_core_memory_l1_1_5.NewProc("VirtualUnlockEx")
)
// Process (HANDLE optional), Address (void*), Size (UINT_PTR)
r1, _, err := procVirtualUnlockEx.Call(
uintptr(Process),
uintptr(Address),
uintptr(Size),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction VirtualUnlockEx(
Process: THandle; // HANDLE optional
Address: Pointer; // void*
Size: NativeUInt // UINT_PTR
): BOOL; stdcall;
external 'api-ms-win-core-memory-l1-1-5.dll' name 'VirtualUnlockEx';result := DllCall("api-ms-win-core-memory-l1-1-5\VirtualUnlockEx"
, "Ptr", Process ; HANDLE optional
, "Ptr", Address ; void*
, "UPtr", Size ; UINT_PTR
, "Int") ; return: BOOL●VirtualUnlockEx(Process, Address, Size) = DLL("api-ms-win-core-memory-l1-1-5.dll", "bool VirtualUnlockEx(void*, void*, int)")
# 呼び出し: VirtualUnlockEx(Process, Address, Size)
# Process : HANDLE optional -> "void*"
# Address : void* -> "void*"
# Size : UINT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。