ホーム › System.ErrorReporting › WerRegisterExcludedMemoryBlock
WerRegisterExcludedMemoryBlock
関数ダンプから除外するメモリブロックを登録する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
HRESULT WerRegisterExcludedMemoryBlock(
const void* address,
DWORD size
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| address | void* | in | ダンプから除外するメモリブロックの先頭アドレス。 |
| size | DWORD | in | 除外するメモリブロックのサイズ(バイト)。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
HRESULT WerRegisterExcludedMemoryBlock(
const void* address,
DWORD size
);[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern int WerRegisterExcludedMemoryBlock(
IntPtr address, // void*
uint size // DWORD
);<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function WerRegisterExcludedMemoryBlock(
address As IntPtr, ' void*
size As UInteger ' DWORD
) As Integer
End Function' address : void*
' size : DWORD
Declare PtrSafe Function WerRegisterExcludedMemoryBlock Lib "kernel32" ( _
ByVal address As LongPtr, _
ByVal size As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WerRegisterExcludedMemoryBlock = ctypes.windll.kernel32.WerRegisterExcludedMemoryBlock
WerRegisterExcludedMemoryBlock.restype = ctypes.c_int
WerRegisterExcludedMemoryBlock.argtypes = [
ctypes.POINTER(None), # address : void*
wintypes.DWORD, # size : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
WerRegisterExcludedMemoryBlock = Fiddle::Function.new(
lib['WerRegisterExcludedMemoryBlock'],
[
Fiddle::TYPE_VOIDP, # address : void*
-Fiddle::TYPE_INT, # size : DWORD
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn WerRegisterExcludedMemoryBlock(
address: *const (), // void*
size: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll")]
public static extern int WerRegisterExcludedMemoryBlock(IntPtr address, uint size);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_WerRegisterExcludedMemoryBlock' -Namespace Win32 -PassThru
# $api::WerRegisterExcludedMemoryBlock(address, size)#uselib "KERNEL32.dll"
#func global WerRegisterExcludedMemoryBlock "WerRegisterExcludedMemoryBlock" sptr, sptr
; WerRegisterExcludedMemoryBlock address, size ; 戻り値は stat
; address : void* -> "sptr"
; size : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global WerRegisterExcludedMemoryBlock "WerRegisterExcludedMemoryBlock" sptr, int
; res = WerRegisterExcludedMemoryBlock(address, size)
; address : void* -> "sptr"
; size : DWORD -> "int"; HRESULT WerRegisterExcludedMemoryBlock(void* address, DWORD size)
#uselib "KERNEL32.dll"
#cfunc global WerRegisterExcludedMemoryBlock "WerRegisterExcludedMemoryBlock" intptr, int
; res = WerRegisterExcludedMemoryBlock(address, size)
; address : void* -> "intptr"
; size : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procWerRegisterExcludedMemoryBlock = kernel32.NewProc("WerRegisterExcludedMemoryBlock")
)
// address (void*), size (DWORD)
r1, _, err := procWerRegisterExcludedMemoryBlock.Call(
uintptr(address),
uintptr(size),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WerRegisterExcludedMemoryBlock(
address: Pointer; // void*
size: DWORD // DWORD
): Integer; stdcall;
external 'KERNEL32.dll' name 'WerRegisterExcludedMemoryBlock';result := DllCall("KERNEL32\WerRegisterExcludedMemoryBlock"
, "Ptr", address ; void*
, "UInt", size ; DWORD
, "Int") ; return: HRESULT●WerRegisterExcludedMemoryBlock(address, size) = DLL("KERNEL32.dll", "int WerRegisterExcludedMemoryBlock(void*, dword)")
# 呼び出し: WerRegisterExcludedMemoryBlock(address, size)
# address : void* -> "void*"
# size : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "kernel32" fn WerRegisterExcludedMemoryBlock(
address: ?*anyopaque, // void*
size: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc WerRegisterExcludedMemoryBlock(
address: pointer, # void*
size: uint32 # DWORD
): int32 {.importc: "WerRegisterExcludedMemoryBlock", stdcall, dynlib: "KERNEL32.dll".}pragma(lib, "kernel32");
extern(Windows)
int WerRegisterExcludedMemoryBlock(
void* address, // void*
uint size // DWORD
);ccall((:WerRegisterExcludedMemoryBlock, "KERNEL32.dll"), stdcall, Int32,
(Ptr{Cvoid}, UInt32),
address, size)
# address : void* -> Ptr{Cvoid}
# size : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WerRegisterExcludedMemoryBlock(
void* address,
uint32_t size);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.WerRegisterExcludedMemoryBlock(address, size)
-- address : void*
-- size : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const WerRegisterExcludedMemoryBlock = lib.func('__stdcall', 'WerRegisterExcludedMemoryBlock', 'int32_t', ['void *', 'uint32_t']);
// WerRegisterExcludedMemoryBlock(address, size)
// address : void* -> 'void *'
// size : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("KERNEL32.dll", {
WerRegisterExcludedMemoryBlock: { parameters: ["pointer", "u32"], result: "i32" },
});
// lib.symbols.WerRegisterExcludedMemoryBlock(address, size)
// address : void* -> "pointer"
// size : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WerRegisterExcludedMemoryBlock(
void* address,
uint32_t size);
C, "KERNEL32.dll");
// $ffi->WerRegisterExcludedMemoryBlock(address, size);
// address : void*
// size : 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 Kernel32 extends StdCallLibrary {
Kernel32 INSTANCE = Native.load("kernel32", Kernel32.class);
int WerRegisterExcludedMemoryBlock(
Pointer address, // void*
int size // DWORD
);
}@[Link("kernel32")]
lib LibKERNEL32
fun WerRegisterExcludedMemoryBlock = WerRegisterExcludedMemoryBlock(
address : Void*, # void*
size : UInt32 # DWORD
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WerRegisterExcludedMemoryBlockNative = Int32 Function(Pointer<Void>, Uint32);
typedef WerRegisterExcludedMemoryBlockDart = int Function(Pointer<Void>, int);
final WerRegisterExcludedMemoryBlock = DynamicLibrary.open('KERNEL32.dll')
.lookupFunction<WerRegisterExcludedMemoryBlockNative, WerRegisterExcludedMemoryBlockDart>('WerRegisterExcludedMemoryBlock');
// address : void* -> Pointer<Void>
// size : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WerRegisterExcludedMemoryBlock(
address: Pointer; // void*
size: DWORD // DWORD
): Integer; stdcall;
external 'KERNEL32.dll' name 'WerRegisterExcludedMemoryBlock';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WerRegisterExcludedMemoryBlock"
c_WerRegisterExcludedMemoryBlock :: Ptr () -> Word32 -> IO Int32
-- address : void* -> Ptr ()
-- size : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let werregisterexcludedmemoryblock =
foreign "WerRegisterExcludedMemoryBlock"
((ptr void) @-> uint32_t @-> returning int32_t)
(* address : void* -> (ptr void) *)
(* size : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)
(cffi:defcfun ("WerRegisterExcludedMemoryBlock" wer-register-excluded-memory-block :convention :stdcall) :int32
(address :pointer) ; void*
(size :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WerRegisterExcludedMemoryBlock = Win32::API::More->new('KERNEL32',
'int WerRegisterExcludedMemoryBlock(LPVOID address, DWORD size)');
# my $ret = $WerRegisterExcludedMemoryBlock->Call($address, $size);
# address : void* -> LPVOID
# size : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。