ホーム › System.Diagnostics.Debug › WaitForDebugEvent
WaitForDebugEvent
関数デバッグ対象プロセスのデバッグイベント発生を待機する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL WaitForDebugEvent(
DEBUG_EVENT* lpDebugEvent,
DWORD dwMilliseconds
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpDebugEvent | DEBUG_EVENT* | out |
| dwMilliseconds | DWORD | in |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL WaitForDebugEvent(
DEBUG_EVENT* lpDebugEvent,
DWORD dwMilliseconds
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool WaitForDebugEvent(
IntPtr lpDebugEvent, // DEBUG_EVENT* out
uint dwMilliseconds // DWORD
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function WaitForDebugEvent(
lpDebugEvent As IntPtr, ' DEBUG_EVENT* out
dwMilliseconds As UInteger ' DWORD
) As Boolean
End Function' lpDebugEvent : DEBUG_EVENT* out
' dwMilliseconds : DWORD
Declare PtrSafe Function WaitForDebugEvent Lib "kernel32" ( _
ByVal lpDebugEvent As LongPtr, _
ByVal dwMilliseconds As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WaitForDebugEvent = ctypes.windll.kernel32.WaitForDebugEvent
WaitForDebugEvent.restype = wintypes.BOOL
WaitForDebugEvent.argtypes = [
ctypes.c_void_p, # lpDebugEvent : DEBUG_EVENT* out
wintypes.DWORD, # dwMilliseconds : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
WaitForDebugEvent = Fiddle::Function.new(
lib['WaitForDebugEvent'],
[
Fiddle::TYPE_VOIDP, # lpDebugEvent : DEBUG_EVENT* out
-Fiddle::TYPE_INT, # dwMilliseconds : DWORD
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn WaitForDebugEvent(
lpDebugEvent: *mut DEBUG_EVENT, // DEBUG_EVENT* out
dwMilliseconds: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern bool WaitForDebugEvent(IntPtr lpDebugEvent, uint dwMilliseconds);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_WaitForDebugEvent' -Namespace Win32 -PassThru
# $api::WaitForDebugEvent(lpDebugEvent, dwMilliseconds)#uselib "KERNEL32.dll"
#func global WaitForDebugEvent "WaitForDebugEvent" sptr, sptr
; WaitForDebugEvent varptr(lpDebugEvent), dwMilliseconds ; 戻り値は stat
; lpDebugEvent : DEBUG_EVENT* out -> "sptr"
; dwMilliseconds : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global WaitForDebugEvent "WaitForDebugEvent" var, int ; res = WaitForDebugEvent(lpDebugEvent, dwMilliseconds) ; lpDebugEvent : DEBUG_EVENT* out -> "var" ; dwMilliseconds : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global WaitForDebugEvent "WaitForDebugEvent" sptr, int ; res = WaitForDebugEvent(varptr(lpDebugEvent), dwMilliseconds) ; lpDebugEvent : DEBUG_EVENT* out -> "sptr" ; dwMilliseconds : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL WaitForDebugEvent(DEBUG_EVENT* lpDebugEvent, DWORD dwMilliseconds) #uselib "KERNEL32.dll" #cfunc global WaitForDebugEvent "WaitForDebugEvent" var, int ; res = WaitForDebugEvent(lpDebugEvent, dwMilliseconds) ; lpDebugEvent : DEBUG_EVENT* out -> "var" ; dwMilliseconds : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL WaitForDebugEvent(DEBUG_EVENT* lpDebugEvent, DWORD dwMilliseconds) #uselib "KERNEL32.dll" #cfunc global WaitForDebugEvent "WaitForDebugEvent" intptr, int ; res = WaitForDebugEvent(varptr(lpDebugEvent), dwMilliseconds) ; lpDebugEvent : DEBUG_EVENT* out -> "intptr" ; dwMilliseconds : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procWaitForDebugEvent = kernel32.NewProc("WaitForDebugEvent")
)
// lpDebugEvent (DEBUG_EVENT* out), dwMilliseconds (DWORD)
r1, _, err := procWaitForDebugEvent.Call(
uintptr(lpDebugEvent),
uintptr(dwMilliseconds),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction WaitForDebugEvent(
lpDebugEvent: Pointer; // DEBUG_EVENT* out
dwMilliseconds: DWORD // DWORD
): BOOL; stdcall;
external 'KERNEL32.dll' name 'WaitForDebugEvent';result := DllCall("KERNEL32\WaitForDebugEvent"
, "Ptr", lpDebugEvent ; DEBUG_EVENT* out
, "UInt", dwMilliseconds ; DWORD
, "Int") ; return: BOOL●WaitForDebugEvent(lpDebugEvent, dwMilliseconds) = DLL("KERNEL32.dll", "bool WaitForDebugEvent(void*, dword)")
# 呼び出し: WaitForDebugEvent(lpDebugEvent, dwMilliseconds)
# lpDebugEvent : DEBUG_EVENT* out -> "void*"
# dwMilliseconds : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。