1 #ifndef W32DBG_WRAP 2 #define W32DBG_WRAP 3 4 typedef enum { 5 W32_NONE, 6 W32_CONTINUE, 7 W32_ATTACH, 8 W32_DETACH, 9 W32_WAIT, 10 W32_STOP, 11 W32_CALL_FUNC 12 } w32dbg_wrap_req; 13 14 typedef struct { 15 w32dbg_wrap_req type; 16 union { 17 DWORD continue_status; 18 struct { 19 DEBUG_EVENT *de; 20 DWORD wait_time; 21 } wait; 22 struct { 23 int (*func)(void *); 24 void *user; 25 } func; 26 }; 27 int ret; 28 DWORD err; 29 } W32DbgWParams; 30 31 typedef struct { 32 HANDLE debugThread; 33 W32DbgWParams params; 34 HANDLE request_sem; 35 HANDLE result_sem; 36 ULONG_PTR winbase; 37 PROCESS_INFORMATION pi; 38 // Stores the TID of the thread DebugBreakProcess creates to ignore it's breakpoint 39 DWORD break_tid; 40 } W32DbgWInst; 41 42 #define w32dbgw_ret(inst) inst->params.ret 43 #define w32dbgw_err(inst) (SetLastError (inst->params.err), inst->params.err) 44 45 W32DbgWInst *w32dbg_wrap_new(void); 46 int w32dbg_wrap_wait_ret(W32DbgWInst *inst); 47 void w32dbg_wrap_fini(W32DbgWInst *inst); 48 49 #endif 50