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

GetWriteWatch

関数
指定メモリ領域内で書き込みのあったページのアドレスを取得する。
DLLKERNEL32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

DWORD GetWriteWatch(
    DWORD dwFlags,
    void* lpBaseAddress,
    UINT_PTR dwRegionSize,
    void** lpAddresses,   // optional
    UINT_PTR* lpdwCount,   // optional
    DWORD* lpdwGranularity   // optional
);

パラメーター

名前方向
dwFlagsDWORDin
lpBaseAddressvoid*in
dwRegionSizeUINT_PTRin
lpAddressesvoid**outoptional
lpdwCountUINT_PTR*inoutoptional
lpdwGranularityDWORD*outoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD GetWriteWatch(
    DWORD dwFlags,
    void* lpBaseAddress,
    UINT_PTR dwRegionSize,
    void** lpAddresses,   // optional
    UINT_PTR* lpdwCount,   // optional
    DWORD* lpdwGranularity   // optional
);
[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern uint GetWriteWatch(
    uint dwFlags,   // DWORD
    IntPtr lpBaseAddress,   // void*
    UIntPtr dwRegionSize,   // UINT_PTR
    IntPtr lpAddresses,   // void** optional, out
    IntPtr lpdwCount,   // UINT_PTR* optional, in/out
    IntPtr lpdwGranularity   // DWORD* optional, out
);
<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function GetWriteWatch(
    dwFlags As UInteger,   ' DWORD
    lpBaseAddress As IntPtr,   ' void*
    dwRegionSize As UIntPtr,   ' UINT_PTR
    lpAddresses As IntPtr,   ' void** optional, out
    lpdwCount As IntPtr,   ' UINT_PTR* optional, in/out
    lpdwGranularity As IntPtr   ' DWORD* optional, out
) As UInteger
End Function
' dwFlags : DWORD
' lpBaseAddress : void*
' dwRegionSize : UINT_PTR
' lpAddresses : void** optional, out
' lpdwCount : UINT_PTR* optional, in/out
' lpdwGranularity : DWORD* optional, out
Declare PtrSafe Function GetWriteWatch Lib "kernel32" ( _
    ByVal dwFlags As Long, _
    ByVal lpBaseAddress As LongPtr, _
    ByVal dwRegionSize As LongPtr, _
    ByVal lpAddresses As LongPtr, _
    ByVal lpdwCount As LongPtr, _
    ByVal lpdwGranularity As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetWriteWatch = ctypes.windll.kernel32.GetWriteWatch
GetWriteWatch.restype = wintypes.DWORD
GetWriteWatch.argtypes = [
    wintypes.DWORD,  # dwFlags : DWORD
    ctypes.POINTER(None),  # lpBaseAddress : void*
    ctypes.c_size_t,  # dwRegionSize : UINT_PTR
    ctypes.c_void_p,  # lpAddresses : void** optional, out
    ctypes.POINTER(ctypes.c_size_t),  # lpdwCount : UINT_PTR* optional, in/out
    ctypes.POINTER(wintypes.DWORD),  # lpdwGranularity : DWORD* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
GetWriteWatch = Fiddle::Function.new(
  lib['GetWriteWatch'],
  [
    -Fiddle::TYPE_INT,  # dwFlags : DWORD
    Fiddle::TYPE_VOIDP,  # lpBaseAddress : void*
    Fiddle::TYPE_UINTPTR_T,  # dwRegionSize : UINT_PTR
    Fiddle::TYPE_VOIDP,  # lpAddresses : void** optional, out
    Fiddle::TYPE_VOIDP,  # lpdwCount : UINT_PTR* optional, in/out
    Fiddle::TYPE_VOIDP,  # lpdwGranularity : DWORD* optional, out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn GetWriteWatch(
        dwFlags: u32,  // DWORD
        lpBaseAddress: *mut (),  // void*
        dwRegionSize: usize,  // UINT_PTR
        lpAddresses: *mut *mut (),  // void** optional, out
        lpdwCount: *mut usize,  // UINT_PTR* optional, in/out
        lpdwGranularity: *mut u32  // DWORD* optional, out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("KERNEL32.dll")]
public static extern uint GetWriteWatch(uint dwFlags, IntPtr lpBaseAddress, UIntPtr dwRegionSize, IntPtr lpAddresses, IntPtr lpdwCount, IntPtr lpdwGranularity);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetWriteWatch' -Namespace Win32 -PassThru
# $api::GetWriteWatch(dwFlags, lpBaseAddress, dwRegionSize, lpAddresses, lpdwCount, lpdwGranularity)
#uselib "KERNEL32.dll"
#func global GetWriteWatch "GetWriteWatch" sptr, sptr, sptr, sptr, sptr, sptr
; GetWriteWatch dwFlags, lpBaseAddress, dwRegionSize, lpAddresses, varptr(lpdwCount), varptr(lpdwGranularity)   ; 戻り値は stat
; dwFlags : DWORD -> "sptr"
; lpBaseAddress : void* -> "sptr"
; dwRegionSize : UINT_PTR -> "sptr"
; lpAddresses : void** optional, out -> "sptr"
; lpdwCount : UINT_PTR* optional, in/out -> "sptr"
; lpdwGranularity : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "KERNEL32.dll"
#cfunc global GetWriteWatch "GetWriteWatch" int, sptr, sptr, sptr, var, var
; res = GetWriteWatch(dwFlags, lpBaseAddress, dwRegionSize, lpAddresses, lpdwCount, lpdwGranularity)
; dwFlags : DWORD -> "int"
; lpBaseAddress : void* -> "sptr"
; dwRegionSize : UINT_PTR -> "sptr"
; lpAddresses : void** optional, out -> "sptr"
; lpdwCount : UINT_PTR* optional, in/out -> "var"
; lpdwGranularity : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD GetWriteWatch(DWORD dwFlags, void* lpBaseAddress, UINT_PTR dwRegionSize, void** lpAddresses, UINT_PTR* lpdwCount, DWORD* lpdwGranularity)
#uselib "KERNEL32.dll"
#cfunc global GetWriteWatch "GetWriteWatch" int, intptr, intptr, intptr, var, var
; res = GetWriteWatch(dwFlags, lpBaseAddress, dwRegionSize, lpAddresses, lpdwCount, lpdwGranularity)
; dwFlags : DWORD -> "int"
; lpBaseAddress : void* -> "intptr"
; dwRegionSize : UINT_PTR -> "intptr"
; lpAddresses : void** optional, out -> "intptr"
; lpdwCount : UINT_PTR* optional, in/out -> "var"
; lpdwGranularity : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procGetWriteWatch = kernel32.NewProc("GetWriteWatch")
)

// dwFlags (DWORD), lpBaseAddress (void*), dwRegionSize (UINT_PTR), lpAddresses (void** optional, out), lpdwCount (UINT_PTR* optional, in/out), lpdwGranularity (DWORD* optional, out)
r1, _, err := procGetWriteWatch.Call(
	uintptr(dwFlags),
	uintptr(lpBaseAddress),
	uintptr(dwRegionSize),
	uintptr(lpAddresses),
	uintptr(lpdwCount),
	uintptr(lpdwGranularity),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function GetWriteWatch(
  dwFlags: DWORD;   // DWORD
  lpBaseAddress: Pointer;   // void*
  dwRegionSize: NativeUInt;   // UINT_PTR
  lpAddresses: Pointer;   // void** optional, out
  lpdwCount: Pointer;   // UINT_PTR* optional, in/out
  lpdwGranularity: Pointer   // DWORD* optional, out
): DWORD; stdcall;
  external 'KERNEL32.dll' name 'GetWriteWatch';
result := DllCall("KERNEL32\GetWriteWatch"
    , "UInt", dwFlags   ; DWORD
    , "Ptr", lpBaseAddress   ; void*
    , "UPtr", dwRegionSize   ; UINT_PTR
    , "Ptr", lpAddresses   ; void** optional, out
    , "Ptr", lpdwCount   ; UINT_PTR* optional, in/out
    , "Ptr", lpdwGranularity   ; DWORD* optional, out
    , "UInt")   ; return: DWORD
●GetWriteWatch(dwFlags, lpBaseAddress, dwRegionSize, lpAddresses, lpdwCount, lpdwGranularity) = DLL("KERNEL32.dll", "dword GetWriteWatch(dword, void*, int, void*, void*, void*)")
# 呼び出し: GetWriteWatch(dwFlags, lpBaseAddress, dwRegionSize, lpAddresses, lpdwCount, lpdwGranularity)
# dwFlags : DWORD -> "dword"
# lpBaseAddress : void* -> "void*"
# dwRegionSize : UINT_PTR -> "int"
# lpAddresses : void** optional, out -> "void*"
# lpdwCount : UINT_PTR* optional, in/out -> "void*"
# lpdwGranularity : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。