Rizin
unix-like reverse engineering framework and cli tools
w32dbg_wrap.h File Reference

Go to the source code of this file.

Classes

struct  W32DbgWParams
 
struct  W32DbgWInst
 

Macros

#define w32dbgw_ret(inst)   inst->params.ret
 
#define w32dbgw_err(inst)   (SetLastError(inst->params.err), inst->params.err)
 

Enumerations

enum  w32dbg_wrap_req {
  W32_NONE , W32_CONTINUE , W32_ATTACH , W32_DETACH ,
  W32_WAIT , W32_STOP , W32_CALL_FUNC
}
 

Functions

W32DbgWInstw32dbg_wrap_new (void)
 
int w32dbg_wrap_wait_ret (W32DbgWInst *inst)
 
void w32dbg_wrap_free (W32DbgWInst *inst)
 

Macro Definition Documentation

◆ w32dbgw_err

#define w32dbgw_err (   inst)    (SetLastError(inst->params.err), inst->params.err)

Definition at line 46 of file w32dbg_wrap.h.

◆ w32dbgw_ret

#define w32dbgw_ret (   inst)    inst->params.ret

Definition at line 45 of file w32dbg_wrap.h.

Enumeration Type Documentation

◆ w32dbg_wrap_req

Enumerator
W32_NONE 
W32_CONTINUE 
W32_ATTACH 
W32_DETACH 
W32_WAIT 
W32_STOP 
W32_CALL_FUNC 

Definition at line 7 of file w32dbg_wrap.h.

7  {
8  W32_NONE,
10  W32_ATTACH,
11  W32_DETACH,
12  W32_WAIT,
13  W32_STOP,
w32dbg_wrap_req
Definition: w32dbg_wrap.h:7
@ W32_NONE
Definition: w32dbg_wrap.h:8
@ W32_ATTACH
Definition: w32dbg_wrap.h:10
@ W32_STOP
Definition: w32dbg_wrap.h:13
@ W32_CONTINUE
Definition: w32dbg_wrap.h:9
@ W32_DETACH
Definition: w32dbg_wrap.h:11
@ W32_CALL_FUNC
Definition: w32dbg_wrap.h:14
@ W32_WAIT
Definition: w32dbg_wrap.h:12

Function Documentation

◆ w32dbg_wrap_free()

void w32dbg_wrap_free ( W32DbgWInst inst)

Definition at line 58 of file w32dbg_wrap.c.

58  {
59  if (!inst) {
60  return;
61  }
62  inst->params.type = W32_STOP;
64  WaitForSingleObject(inst->debugThread, INFINITE);
65  CloseHandle(inst->request_sem);
66  CloseHandle(inst->result_sem);
67  CloseHandle(inst->debugThread);
68  free(inst);
69 }
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
HANDLE result_sem
Definition: w32dbg_wrap.h:38
W32DbgWParams params
Definition: w32dbg_wrap.h:36
HANDLE debugThread
Definition: w32dbg_wrap.h:35
HANDLE request_sem
Definition: w32dbg_wrap.h:37
w32dbg_wrap_req type
Definition: w32dbg_wrap.h:18
int w32dbg_wrap_wait_ret(W32DbgWInst *inst)
Definition: w32dbg_wrap.c:71

References W32DbgWInst::debugThread, free(), W32DbgWInst::params, W32DbgWInst::request_sem, W32DbgWInst::result_sem, W32DbgWParams::type, W32_STOP, and w32dbg_wrap_wait_ret().

Referenced by rz_io_fini().

◆ w32dbg_wrap_new()

W32DbgWInst* w32dbg_wrap_new ( void  )

Definition at line 48 of file w32dbg_wrap.c.

48  {
49  W32DbgWInst *inst = calloc(1, sizeof(W32DbgWInst));
50  if (inst) {
51  inst->request_sem = CreateSemaphore(NULL, 0, 1, NULL);
52  inst->result_sem = CreateSemaphore(NULL, 0, 1, NULL);
53  inst->debugThread = CreateThread(NULL, 0, __w32dbg_thread, inst, 0, NULL);
54  }
55  return inst;
56 }
#define NULL
Definition: cris-opc.c:27
void * calloc(size_t number, size_t size)
Definition: malloc.c:102
static DWORD WINAPI __w32dbg_thread(LPVOID param)
Definition: w32dbg_wrap.c:7

References __w32dbg_thread(), calloc(), W32DbgWInst::debugThread, NULL, W32DbgWInst::request_sem, and W32DbgWInst::result_sem.

◆ w32dbg_wrap_wait_ret()

int w32dbg_wrap_wait_ret ( W32DbgWInst inst)

Definition at line 71 of file w32dbg_wrap.c.

71  {
72  ReleaseSemaphore(inst->request_sem, 1, NULL);
73  WaitForSingleObject(inst->result_sem, INFINITE);
74  return w32dbgw_ret(inst);
75 }
#define w32dbgw_ret(inst)
Definition: w32dbg_wrap.h:45

References NULL, W32DbgWInst::request_sem, W32DbgWInst::result_sem, and w32dbgw_ret.

Referenced by w32_attach(), w32_continue(), w32_dbg_wait(), w32_detach(), and w32dbg_wrap_free().