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

WerRegisterMemoryBlock

関数
ダンプに含めるメモリブロックをWERに登録する。
DLLKERNEL32.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT WerRegisterMemoryBlock(
    void* pvAddress,
    DWORD dwSize
);

パラメーター

名前方向
pvAddressvoid*in
dwSizeDWORDin

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WerRegisterMemoryBlock(
    void* pvAddress,
    DWORD dwSize
);
[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern int WerRegisterMemoryBlock(
    IntPtr pvAddress,   // void*
    uint dwSize   // DWORD
);
<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function WerRegisterMemoryBlock(
    pvAddress As IntPtr,   ' void*
    dwSize As UInteger   ' DWORD
) As Integer
End Function
' pvAddress : void*
' dwSize : DWORD
Declare PtrSafe Function WerRegisterMemoryBlock Lib "kernel32" ( _
    ByVal pvAddress As LongPtr, _
    ByVal dwSize As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WerRegisterMemoryBlock = ctypes.windll.kernel32.WerRegisterMemoryBlock
WerRegisterMemoryBlock.restype = ctypes.c_int
WerRegisterMemoryBlock.argtypes = [
    ctypes.POINTER(None),  # pvAddress : void*
    wintypes.DWORD,  # dwSize : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
WerRegisterMemoryBlock = Fiddle::Function.new(
  lib['WerRegisterMemoryBlock'],
  [
    Fiddle::TYPE_VOIDP,  # pvAddress : void*
    -Fiddle::TYPE_INT,  # dwSize : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn WerRegisterMemoryBlock(
        pvAddress: *mut (),  // void*
        dwSize: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("KERNEL32.dll")]
public static extern int WerRegisterMemoryBlock(IntPtr pvAddress, uint dwSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_WerRegisterMemoryBlock' -Namespace Win32 -PassThru
# $api::WerRegisterMemoryBlock(pvAddress, dwSize)
#uselib "KERNEL32.dll"
#func global WerRegisterMemoryBlock "WerRegisterMemoryBlock" sptr, sptr
; WerRegisterMemoryBlock pvAddress, dwSize   ; 戻り値は stat
; pvAddress : void* -> "sptr"
; dwSize : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global WerRegisterMemoryBlock "WerRegisterMemoryBlock" sptr, int
; res = WerRegisterMemoryBlock(pvAddress, dwSize)
; pvAddress : void* -> "sptr"
; dwSize : DWORD -> "int"
; HRESULT WerRegisterMemoryBlock(void* pvAddress, DWORD dwSize)
#uselib "KERNEL32.dll"
#cfunc global WerRegisterMemoryBlock "WerRegisterMemoryBlock" intptr, int
; res = WerRegisterMemoryBlock(pvAddress, dwSize)
; pvAddress : void* -> "intptr"
; dwSize : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procWerRegisterMemoryBlock = kernel32.NewProc("WerRegisterMemoryBlock")
)

// pvAddress (void*), dwSize (DWORD)
r1, _, err := procWerRegisterMemoryBlock.Call(
	uintptr(pvAddress),
	uintptr(dwSize),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WerRegisterMemoryBlock(
  pvAddress: Pointer;   // void*
  dwSize: DWORD   // DWORD
): Integer; stdcall;
  external 'KERNEL32.dll' name 'WerRegisterMemoryBlock';
result := DllCall("KERNEL32\WerRegisterMemoryBlock"
    , "Ptr", pvAddress   ; void*
    , "UInt", dwSize   ; DWORD
    , "Int")   ; return: HRESULT
●WerRegisterMemoryBlock(pvAddress, dwSize) = DLL("KERNEL32.dll", "int WerRegisterMemoryBlock(void*, dword)")
# 呼び出し: WerRegisterMemoryBlock(pvAddress, dwSize)
# pvAddress : void* -> "void*"
# dwSize : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。