Renamed windbg plugin (#8117)
This commit is contained in:
parent
e0f0c89783
commit
3d681b0fe5
32 changed files with 1296 additions and 1217 deletions
|
|
@ -50,7 +50,7 @@ LDFLAGS+=../../shlr/grub/libgrubfs.a
|
|||
LDFLAGS+=../../shlr/capstone/libcapstone.a
|
||||
LDFLAGS+=../../shlr/sdb/src/libsdb.a
|
||||
LDFLAGS+=../../shlr/gdb/lib/libgdbr.a
|
||||
LDFLAGS+=../../shlr/wind/libr_wind.a
|
||||
LDFLAGS+=../../shlr/windbg/libr_windbg.a
|
||||
LDFLAGS+=../../shlr/java/libr_java.a
|
||||
LDFLAGS+=-lm
|
||||
LDFLAGS+=../../libr/socket/libr_socket.a
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ LDFLAGS+=$(shell for a in ${BINDEPS} ; do b=`echo $$a |sed -e s,r_,,g`; echo ../
|
|||
LDFLAGS+=../../shlr/sdb/src/libsdb.a
|
||||
LDFLAGS+=../../shlr/grub/libgrubfs.a
|
||||
LDFLAGS+=../../shlr/gdb/lib/libgdbr.a
|
||||
LDFLAGS+=../../shlr/wind/libr_wind.a
|
||||
LDFLAGS+=../../shlr/windbg/libr_windbg.a
|
||||
LDFLAGS+=../../shlr/capstone/libcapstone.a
|
||||
LDFLAGS+=../../shlr/java/libr_java.a
|
||||
LDFLAGS+=../../libr/socket/libr_socket.a
|
||||
|
|
|
|||
|
|
@ -204,10 +204,10 @@ See doc/qnx
|
|||
|
||||
See doc/rap
|
||||
|
||||
### libr/debug/p/debug_wind.c
|
||||
### libr/debug/p/debug_windbg.c
|
||||
|
||||
A debugger plugin that enables debugging code remotely via WinDbg protocol. WinDbg protocol
|
||||
parser is located in shlr/wind. Corresponding IO plugin located in libr/io/p/io_windbg.c
|
||||
parser is located in shlr/windbg. Corresponding IO plugin located in libr/io/p/io_windbg.c
|
||||
See doc/windbg
|
||||
|
||||
## Conclusion
|
||||
|
|
|
|||
14
doc/windbg
14
doc/windbg
|
|
@ -20,13 +20,13 @@ Enable WinDBG support on Windows Vista and higher like this:
|
|||
|
||||
Or like this for Windows XP:
|
||||
Open boot.ini and add /debug /debugport=COM1 /baudrate=115200:
|
||||
|
||||
|
||||
[boot loader]
|
||||
timeout=30
|
||||
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
|
||||
[operating systems]
|
||||
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Debugging with Cable" /fastdetect /debug /debugport=COM1 /baudrate=57600
|
||||
|
||||
|
||||
|
||||
Configure the VirtualBox Machine like this:
|
||||
|
||||
|
|
@ -42,18 +42,18 @@ Or just spawn the VM with qemu like this:
|
|||
|
||||
$ qemu-system-x86_64 -chardev socket,id=serial0,\
|
||||
path=/tmp/windbg.pipe,nowait,server \
|
||||
-serial chardev:serial0 -hda Windows7-VM.vdi
|
||||
-serial chardev:serial0 -hda Windows7-VM.vdi
|
||||
|
||||
|
||||
Radare2 will use the 'windbg' io plugin to connect to a socket file
|
||||
created by virtualbox or qemu. Also, the 'wind' debugger plugin and
|
||||
created by virtualbox or qemu. Also, the 'windbg' debugger plugin and
|
||||
we should specify the x86-32 too. (32 and 64 bit debugging is supported)
|
||||
|
||||
$ r2 -a x86 -b 32 -D wind windbg:///tmp/windbg.pipe
|
||||
$ r2 -a x86 -b 32 -D windbg windbg:///tmp/windbg.pipe
|
||||
|
||||
On Windows you should run the following line:
|
||||
|
||||
$ radare2 -D wind windbg://\\.\pipe\com_1
|
||||
$ radare2 -D windbg windbg://\\.\pipe\com_1
|
||||
|
||||
At this point, we will get stuck here:
|
||||
|
||||
|
|
@ -76,6 +76,6 @@ In order to skip that trap we will need to change eip and run 'dc' twice:
|
|||
Now the Windows VM will be interactive again. We will need to kill r2 and
|
||||
attach again to get back to control the kernel.
|
||||
|
||||
In addition, the `dp` command can be used to list all processes, and
|
||||
In addition, the `dp` command can be used to list all processes, and
|
||||
`dpa` or `dp=` to attach to the process. This will display the base
|
||||
address of the process in the physical memory layout.
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ LINK+=../../util/libr_util.${EXT_AR}
|
|||
LINK+=../../magic/libr_magic.${EXT_AR}
|
||||
LINK+=../../socket/libr_socket.${EXT_AR}
|
||||
LINK+=../../../shlr/gdb/lib/libgdbr.${EXT_AR}
|
||||
LINK+=../../../shlr/wind/libr_wind.${EXT_AR}
|
||||
LINK+=../../../shlr/windbg/libr_windbg.${EXT_AR}
|
||||
LINK+=../../../shlr/qnx/lib/libqnxr.${EXT_AR}
|
||||
LINK+=../../../shlr/bochs/lib/libbochs.${EXT_AR}
|
||||
LINK+=../../../shlr/java/libr_java.${EXT_AR}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ include ../../../shlr/zip/deps.mk
|
|||
|
||||
CFLAGS+=-I../../include -Wall -shared ${PIC_CFLAGS} ${LDFLAGS_LIB} ${LDFLAGS_LINKPATH}..
|
||||
CFLAGS+=-L../../util -lr_util -L../../reg -lr_reg -L.. -lr_core
|
||||
#CFLAGS+=-L../../db -lr_db
|
||||
#CFLAGS+=-L../../db -lr_db
|
||||
CFLAGS+=-L../../cons -lr_cons -L../../bin -lr_bin
|
||||
CFLAGS+=-L../../parse -lr_parse -L../../io -lr_io -L../../fs -lr_fs
|
||||
CFLAGS+=-L../../magic -lr_magic -L../../hash -lr_hash -L../../config -lr_config
|
||||
|
|
@ -18,7 +18,7 @@ CFLAGS+=-L../../bp -lr_bp -L../../reg -lr_reg -L../../asm -lr_asm
|
|||
LDFLAGS+=$(STOP)/sdb/src/libsdb.a
|
||||
include $(STOP)/java/deps.mk
|
||||
include $(STOP)/gdb/deps.mk
|
||||
include $(STOP)/wind/deps.mk
|
||||
include $(STOP)/windbg/deps.mk
|
||||
#CFLAGS+=-L../../anal -lr_anal -L../../core -lr_core
|
||||
LDFLAGS+=${LINK}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ files=[
|
|||
'p/debug_native.c',
|
||||
#'p/debug_qnx.c',
|
||||
'p/debug_rap.c',
|
||||
#'p/debug_wind.c',
|
||||
#'p/debug_windbg.c',
|
||||
#'p/native/arm.c',
|
||||
#'p/native/bt/fuzzy-all.c',
|
||||
#'p/native/bt/generic-x64.c',
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ CFLAGS+=-I../../include -Wall ${PIC_FLAGS} ${LDFLAGS_LIB} ${LDFLAGS_LINKPATH}..
|
|||
foo: all
|
||||
|
||||
ALL_TARGETS=
|
||||
DEBUGS=native.mk gdb.mk qnx.mk wind.mk bochs.mk
|
||||
DEBUGS=native.mk gdb.mk qnx.mk windbg.mk bochs.mk
|
||||
include $(DEBUGS)
|
||||
|
||||
all: ${ALL_TARGETS}
|
||||
|
|
|
|||
|
|
@ -15,19 +15,19 @@
|
|||
|
||||
#include <r_asm.h>
|
||||
#include <r_debug.h>
|
||||
#include <wind.h>
|
||||
#include <windbg.h>
|
||||
#include <kd.h>
|
||||
|
||||
static WindCtx *wctx = NULL;
|
||||
static bool dbreak = false;
|
||||
|
||||
static int r_debug_wind_step (RDebug *dbg) {
|
||||
static int r_debug_windbg_step (RDebug *dbg) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static int r_debug_wind_reg_read (RDebug *dbg, int type, ut8 *buf, int size) {
|
||||
static int r_debug_windbg_reg_read (RDebug *dbg, int type, ut8 *buf, int size) {
|
||||
(void)type;
|
||||
int ret = wind_read_reg(wctx, buf, size);
|
||||
int ret = windbg_read_reg(wctx, buf, size);
|
||||
if (!ret || size != ret) {
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ static int r_debug_wind_reg_read (RDebug *dbg, int type, ut8 *buf, int size) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int r_debug_wind_reg_write(RDebug *dbg, int type, const ut8 *buf, int size) {
|
||||
static int r_debug_windbg_reg_write(RDebug *dbg, int type, const ut8 *buf, int size) {
|
||||
(void)buf;
|
||||
(void)size;
|
||||
if (!dbg->reg) {
|
||||
|
|
@ -48,21 +48,21 @@ static int r_debug_wind_reg_write(RDebug *dbg, int type, const ut8 *buf, int siz
|
|||
eprintf ("Could not retrieve the register arena!\n");
|
||||
return false;
|
||||
}
|
||||
int ret = wind_write_reg (wctx, arena, arena_size);
|
||||
int ret = windbg_write_reg (wctx, arena, arena_size);
|
||||
free (arena);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int r_debug_wind_continue(RDebug *dbg, int pid, int tid, int sig) {
|
||||
return wind_continue(wctx);
|
||||
static int r_debug_windbg_continue(RDebug *dbg, int pid, int tid, int sig) {
|
||||
return windbg_continue(wctx);
|
||||
}
|
||||
|
||||
static void wstatic_debug_break(void *u) {
|
||||
dbreak = true;
|
||||
wind_break_read (wctx);
|
||||
windbg_break_read (wctx);
|
||||
}
|
||||
|
||||
static int r_debug_wind_wait (RDebug *dbg, int pid) {
|
||||
static int r_debug_windbg_wait (RDebug *dbg, int pid) {
|
||||
# define STATE_EXCEPTION 0x3030
|
||||
kd_packet_t *pkt;
|
||||
kd_stc_64 *stc;
|
||||
|
|
@ -70,10 +70,10 @@ static int r_debug_wind_wait (RDebug *dbg, int pid) {
|
|||
dbreak = false;
|
||||
r_cons_break_push (wstatic_debug_break, dbg);
|
||||
for (;;) {
|
||||
ret = wind_wait_packet (wctx, KD_PACKET_TYPE_STATE_CHANGE, &pkt);
|
||||
ret = windbg_wait_packet (wctx, KD_PACKET_TYPE_STATE_CHANGE, &pkt);
|
||||
if (dbreak) {
|
||||
dbreak = false;
|
||||
wind_break (wctx);
|
||||
windbg_break (wctx);
|
||||
continue;
|
||||
}
|
||||
if (ret != KD_E_OK || !pkt) {
|
||||
|
|
@ -82,7 +82,7 @@ static int r_debug_wind_wait (RDebug *dbg, int pid) {
|
|||
stc = (kd_stc_64 *)pkt->data;
|
||||
// Handle exceptions only
|
||||
if (stc->state == STATE_EXCEPTION) {
|
||||
wind_set_cpu (wctx, stc->cpu);
|
||||
windbg_set_cpu (wctx, stc->cpu);
|
||||
dbg->reason.type = R_DEBUG_REASON_INT;
|
||||
dbg->reason.addr = stc->pc;
|
||||
dbg->reason.tid = stc->kthread;
|
||||
|
|
@ -90,7 +90,7 @@ static int r_debug_wind_wait (RDebug *dbg, int pid) {
|
|||
free (pkt);
|
||||
break;
|
||||
}
|
||||
wind_continue (wctx);
|
||||
windbg_continue (wctx);
|
||||
free (pkt);
|
||||
}
|
||||
r_cons_break_pop ();
|
||||
|
|
@ -98,7 +98,7 @@ static int r_debug_wind_wait (RDebug *dbg, int pid) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static int r_debug_wind_attach (RDebug *dbg, int pid) {
|
||||
static int r_debug_windbg_attach (RDebug *dbg, int pid) {
|
||||
RIODesc *desc = dbg->iob.io->desc;
|
||||
|
||||
if (!desc || !desc->plugin || !desc->plugin->name || !desc->data) {
|
||||
|
|
@ -117,14 +117,14 @@ static int r_debug_wind_attach (RDebug *dbg, int pid) {
|
|||
}
|
||||
|
||||
// Handshake
|
||||
if (!wind_sync(wctx)) {
|
||||
if (!windbg_sync(wctx)) {
|
||||
eprintf("Could not connect to windbg\n");
|
||||
wind_ctx_free(wctx);
|
||||
windbg_ctx_free(wctx);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!wind_read_ver(wctx)) {
|
||||
wind_ctx_free(wctx);
|
||||
if (!windbg_read_ver(wctx)) {
|
||||
windbg_ctx_free(wctx);
|
||||
return false;
|
||||
}
|
||||
// Make r_debug_is_dead happy
|
||||
|
|
@ -132,11 +132,11 @@ static int r_debug_wind_attach (RDebug *dbg, int pid) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static int r_debug_wind_detach (RDebug *dbg, int pid) {
|
||||
static int r_debug_windbg_detach (RDebug *dbg, int pid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static char *r_debug_wind_reg_profile(RDebug *dbg) {
|
||||
static char *r_debug_windbg_reg_profile(RDebug *dbg) {
|
||||
if (!dbg) return NULL;
|
||||
if (dbg->arch && strcmp (dbg->arch, "x86"))
|
||||
return NULL;
|
||||
|
|
@ -148,19 +148,19 @@ static char *r_debug_wind_reg_profile(RDebug *dbg) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static int r_debug_wind_breakpoint (RBreakpointItem *bp, int set, void *user) {
|
||||
static int r_debug_windbg_breakpoint (RBreakpointItem *bp, int set, void *user) {
|
||||
int *tag;
|
||||
if (!bp) return false;
|
||||
// Use a 32 bit word here to keep this compatible with 32 bit hosts
|
||||
tag = (int *)&bp->data;
|
||||
return wind_bkpt (wctx, bp->addr, set, bp->hw, tag);
|
||||
return windbg_bkpt (wctx, bp->addr, set, bp->hw, tag);
|
||||
}
|
||||
|
||||
static int r_debug_wind_init(RDebug *dbg) {
|
||||
static int r_debug_windbg_init(RDebug *dbg) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static RList *r_debug_wind_pids (RDebug *dbg, int pid) {
|
||||
static RList *r_debug_windbg_pids (RDebug *dbg, int pid) {
|
||||
RListIter *it;
|
||||
WindProc *p;
|
||||
|
||||
|
|
@ -169,7 +169,7 @@ static RList *r_debug_wind_pids (RDebug *dbg, int pid) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
RList *pids = wind_list_process(wctx);
|
||||
RList *pids = windbg_list_process(wctx);
|
||||
if (!pids) {
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -189,44 +189,44 @@ static RList *r_debug_wind_pids (RDebug *dbg, int pid) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int r_debug_wind_select (int pid, int tid) {
|
||||
ut32 old = wind_get_target (wctx);
|
||||
int ret = wind_set_target (wctx, pid);
|
||||
static int r_debug_windbg_select (int pid, int tid) {
|
||||
ut32 old = windbg_get_target (wctx);
|
||||
int ret = windbg_set_target (wctx, pid);
|
||||
if (!ret) {
|
||||
return false;
|
||||
}
|
||||
ut64 base = wind_get_target_base (wctx);
|
||||
ut64 base = windbg_get_target_base (wctx);
|
||||
if (!base) {
|
||||
wind_set_target (wctx, old);
|
||||
windbg_set_target (wctx, old);
|
||||
return false;
|
||||
}
|
||||
eprintf ("Process base is 0x%"PFMT64x"\n", base);
|
||||
return true;
|
||||
}
|
||||
|
||||
RDebugPlugin r_debug_plugin_wind = {
|
||||
.name = "wind",
|
||||
RDebugPlugin r_debug_plugin_windbg = {
|
||||
.name = "windbg",
|
||||
.license = "LGPL3",
|
||||
.arch = "x86",
|
||||
.bits = R_SYS_BITS_32 | R_SYS_BITS_64,
|
||||
.pids = r_debug_wind_pids,
|
||||
.select = r_debug_wind_select,
|
||||
.step = r_debug_wind_step,
|
||||
.init = r_debug_wind_init,
|
||||
.cont = r_debug_wind_continue,
|
||||
.attach = &r_debug_wind_attach,
|
||||
.detach = &r_debug_wind_detach,
|
||||
.wait = &r_debug_wind_wait,
|
||||
.breakpoint = &r_debug_wind_breakpoint,
|
||||
.reg_read = &r_debug_wind_reg_read,
|
||||
.reg_write = &r_debug_wind_reg_write,
|
||||
.reg_profile = r_debug_wind_reg_profile,
|
||||
.pids = r_debug_windbg_pids,
|
||||
.select = r_debug_windbg_select,
|
||||
.step = r_debug_windbg_step,
|
||||
.init = r_debug_windbg_init,
|
||||
.cont = r_debug_windbg_continue,
|
||||
.attach = &r_debug_windbg_attach,
|
||||
.detach = &r_debug_windbg_detach,
|
||||
.wait = &r_debug_windbg_wait,
|
||||
.breakpoint = &r_debug_windbg_breakpoint,
|
||||
.reg_read = &r_debug_windbg_reg_read,
|
||||
.reg_write = &r_debug_windbg_reg_write,
|
||||
.reg_profile = r_debug_windbg_reg_profile,
|
||||
};
|
||||
|
||||
#ifndef CORELIB
|
||||
RLibStruct radare_plugin = {
|
||||
.type = R_LIB_TYPE_DBG,
|
||||
.data = &r_debug_plugin_wind,
|
||||
.data = &r_debug_plugin_winddbg,
|
||||
.version = R2_VERSION
|
||||
};
|
||||
#endif
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
#include ../../config.mk
|
||||
#BINDEPS=r_reg r_bp r_util r_io r_anal
|
||||
|
||||
CFLAGS+=-I$(SHLR)/wind/
|
||||
LIB_PATH=$(SHLR)/wind/
|
||||
|
||||
-include ../../global.mk
|
||||
-include ../../../global.mk
|
||||
LDFLAGS+=-L$(LTOP)/util -lr_util
|
||||
LDFLAGS+=-L$(LTOP)/cons -lr_cons
|
||||
LDFLAGS+=-L$(LTOP)/parse -lr_parse
|
||||
LDFLAGS+=-L$(LTOP)/anal -lr_anal
|
||||
LDFLAGS+=-L$(LTOP)/reg -lr_reg
|
||||
LDFLAGS+=-L$(LTOP)/bp -lr_bp
|
||||
LDFLAGS+=-L$(LTOP)/io -lr_io
|
||||
|
||||
include $(STOP)/wind/deps.mk
|
||||
|
||||
OBJ_WIND=debug_wind.o
|
||||
|
||||
STATIC_OBJ+=${OBJ_WIND}
|
||||
TARGET_WIND=debug_wind.${EXT_SO}
|
||||
|
||||
ALL_TARGETS+=${TARGET_WIND}
|
||||
|
||||
${TARGET_WIND}: ${OBJ_WIND}
|
||||
${CC} $(call libname,debug_wind) ${OBJ_WIND} ${CFLAGS} ${LDFLAGS}
|
||||
24
libr/debug/p/windbg.mk
Normal file
24
libr/debug/p/windbg.mk
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
CFLAGS+=-I$(SHLR)/windbg/
|
||||
LIB_PATH=$(SHLR)/windbg/
|
||||
|
||||
-include ../../global.mk
|
||||
-include ../../../global.mk
|
||||
LDFLAGS+=-L$(LTOP)/util -lr_util
|
||||
LDFLAGS+=-L$(LTOP)/cons -lr_cons
|
||||
LDFLAGS+=-L$(LTOP)/parse -lr_parse
|
||||
LDFLAGS+=-L$(LTOP)/anal -lr_anal
|
||||
LDFLAGS+=-L$(LTOP)/reg -lr_reg
|
||||
LDFLAGS+=-L$(LTOP)/bp -lr_bp
|
||||
LDFLAGS+=-L$(LTOP)/io -lr_io
|
||||
|
||||
include $(STOP)/windbg/deps.mk
|
||||
|
||||
OBJ_WINDBG=debug_windbg.o
|
||||
|
||||
STATIC_OBJ+=${OBJ_WINDBG}
|
||||
TARGET_WINDBG=debug_windbg.${EXT_SO}
|
||||
|
||||
ALL_TARGETS+=${TARGET_WINDBG}
|
||||
|
||||
${TARGET_WINDBG}: ${OBJ_WINDBG}
|
||||
${CC} $(call libname,debug_windbg) ${OBJ_WINDBG} ${CFLAGS} ${LDFLAGS}
|
||||
|
|
@ -597,7 +597,7 @@ extern RDebugPlugin r_debug_plugin_rap;
|
|||
extern RDebugPlugin r_debug_plugin_gdb;
|
||||
extern RDebugPlugin r_debug_plugin_bf;
|
||||
extern RDebugPlugin r_debug_plugin_io;
|
||||
extern RDebugPlugin r_debug_plugin_wind;
|
||||
extern RDebugPlugin r_debug_plugin_windbg;
|
||||
extern RDebugPlugin r_debug_plugin_bochs;
|
||||
extern RDebugPlugin r_debug_plugin_qnx;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -53,10 +53,10 @@ r_io = library('r_io', files,
|
|||
'../../shlr/bochs/include',
|
||||
'../../shlr/gdb/include',
|
||||
'../../shlr/qnx/include',
|
||||
'../../shlr/wind',
|
||||
'../../shlr/windbg',
|
||||
'../../shlr/zip/include']
|
||||
)],
|
||||
link_with: [r_util, r_socket, libr2qnx, libr2bochs, libr2wind, libr2gdb, libr2zip],
|
||||
link_with: [r_util, r_socket, libr2qnx, libr2bochs, libr2windbg, libr2gdb, libr2zip],
|
||||
c_args : ['-DCORELIB=1', '-I' + meson.current_build_dir() + '/../..'],
|
||||
install: true
|
||||
)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
#include <r_socket.h>
|
||||
#include <r_util.h>
|
||||
#include <transport.h>
|
||||
#include <wind.h>
|
||||
#include <windbg.h>
|
||||
|
||||
static bool __plugin_open(RIO *io, const char *file, bool many) {
|
||||
return !strncmp (file, "windbg://", strlen ("windbg://"));
|
||||
|
|
@ -42,7 +42,7 @@ static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
ctx = wind_ctx_new (io_ctx);
|
||||
ctx = windbg_ctx_new (io_ctx);
|
||||
|
||||
if (!ctx)
|
||||
return NULL;
|
||||
|
|
@ -54,14 +54,14 @@ static int __write(RIO *io, RIODesc *fd, const ut8 *buf, int count) {
|
|||
if (!fd)
|
||||
return -1;
|
||||
|
||||
if (wind_get_target(fd->data)) {
|
||||
if (windbg_get_target(fd->data)) {
|
||||
ut64 va;
|
||||
if (!wind_va_to_pa (fd->data, io->off, &va))
|
||||
if (!windbg_va_to_pa (fd->data, io->off, &va))
|
||||
return -1;
|
||||
return wind_write_at_phys (fd->data, buf, va, count);
|
||||
return windbg_write_at_phys (fd->data, buf, va, count);
|
||||
}
|
||||
|
||||
return wind_write_at (fd->data, buf, io->off, count);
|
||||
return windbg_write_at (fd->data, buf, io->off, count);
|
||||
}
|
||||
|
||||
static ut64 __lseek(RIO *io, RIODesc *fd, ut64 offset, int whence) {
|
||||
|
|
@ -72,18 +72,18 @@ static int __read(RIO *io, RIODesc *fd, ut8 *buf, int count) {
|
|||
if (!fd)
|
||||
return -1;
|
||||
|
||||
if (wind_get_target(fd->data)) {
|
||||
if (windbg_get_target(fd->data)) {
|
||||
ut64 va;
|
||||
if (!wind_va_to_pa (fd->data, io->off, &va))
|
||||
if (!windbg_va_to_pa (fd->data, io->off, &va))
|
||||
return -1;
|
||||
return wind_read_at_phys(fd->data, buf, va, count);
|
||||
return windbg_read_at_phys(fd->data, buf, va, count);
|
||||
}
|
||||
|
||||
return wind_read_at(fd->data, buf, io->off, count);
|
||||
return windbg_read_at(fd->data, buf, io->off, count);
|
||||
}
|
||||
|
||||
static int __close(RIODesc *fd) {
|
||||
wind_ctx_free (fd->data);
|
||||
windbg_ctx_free (fd->data);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ STATIC_OBJ+=${OBJ_WINDBG}
|
|||
TARGET_WINDBG=io_windbg.${EXT_SO}
|
||||
ALL_TARGETS+=${TARGET_WINDBG}
|
||||
|
||||
LIB_PATH=$(SHLR)/wind
|
||||
CFLAGS+=-I$(SHLR)/wind
|
||||
LDFLAGS+=$(SHLR)/wind/libr_wind.$(EXT_AR)
|
||||
LIB_PATH=$(SHLR)/windbg
|
||||
CFLAGS+=-I$(SHLR)/windbg
|
||||
LDFLAGS+=$(SHLR)/windbg/libr_windbg.$(EXT_AR)
|
||||
|
||||
ifeq (${WITHPIC},0)
|
||||
LINKFLAGS+=../../util/libr_util.a
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ debug.gdb
|
|||
debug.qnx
|
||||
debug.native
|
||||
debug.rap
|
||||
debug.wind
|
||||
debug.windbg
|
||||
debug.bochs
|
||||
egg.exec
|
||||
egg.xor
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ debug.esil
|
|||
debug.gdb
|
||||
debug.native
|
||||
debug.rap
|
||||
debug.wind
|
||||
debug.windbg
|
||||
egg.exec
|
||||
egg.xor
|
||||
fs.cpio
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ CS_REV=
|
|||
CS_PATCHES=1
|
||||
endif
|
||||
|
||||
.PHONY: capstone-sync capstone-build all clean mrproper libgdbr libwind bochs
|
||||
.PHONY: capstone-sync capstone-build all clean mrproper libgdbr libwindbg bochs
|
||||
|
||||
HOST_CC?=gcc
|
||||
SHLR?=$(shell pwd)
|
||||
|
|
@ -58,14 +58,14 @@ all:
|
|||
exit 1
|
||||
endif
|
||||
|
||||
preall: targets libwind capstone-build bochs
|
||||
preall: targets libwindbg capstone-build bochs
|
||||
@for MOD in ${MODS} ; do \
|
||||
echo $(MAKE) -C $$MOD ; \
|
||||
$(MAKE) -C $$MOD HAVE_VALA= ROOT="${PWD}/../" CC="${CC}" ; \
|
||||
done
|
||||
|
||||
SDBFILES=sdb/src/.sdb${EXT_EXE} sdb/sdb${EXT_EXE} sdb/src/.sdb sdb/sdb
|
||||
PREMODS=capstone gdb wind sdb bochs
|
||||
PREMODS=capstone gdb windbg sdb bochs
|
||||
|
||||
clean mrproper:
|
||||
rm -f ${SDBFILES}
|
||||
|
|
@ -139,8 +139,8 @@ I=../libr/include
|
|||
libgdbr:
|
||||
$(MAKE) -C gdb all
|
||||
|
||||
libwind:
|
||||
$(MAKE) -C wind all
|
||||
libwindbg:
|
||||
$(MAKE) -C windbg all
|
||||
|
||||
bochs:
|
||||
$(MAKE) -C bochs all
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ libr2bochs = static_library('libr2bochs', bochs_files,
|
|||
'bochs/include'
|
||||
])]
|
||||
)
|
||||
|
||||
|
||||
|
||||
gdb_files=[
|
||||
'gdb/src/arch.c',
|
||||
|
|
@ -62,14 +62,14 @@ tcc_files=[
|
|||
'tcc/libtcc.c',
|
||||
'tcc/tccgen.c',
|
||||
'tcc/tccpp.c'
|
||||
]
|
||||
]
|
||||
|
||||
libr2tcc = static_library('libr2tcc', tcc_files,
|
||||
include_directories: [platform_inc, include_directories([
|
||||
'tcc'
|
||||
])]
|
||||
)
|
||||
|
||||
|
||||
spp_files=[
|
||||
'spp/spp.c'
|
||||
]
|
||||
|
|
@ -80,7 +80,7 @@ libr2spp = static_library('libr2spp', spp_files,
|
|||
])],
|
||||
c_args: ['-DHAVE_R_UTIL']
|
||||
)
|
||||
|
||||
|
||||
sdb_files=[
|
||||
'sdb/src/array.c',
|
||||
'sdb/src/base64.c',
|
||||
|
|
@ -290,7 +290,7 @@ libr2capstone = static_library('libr2capstone', cs_files,
|
|||
'capstone/include'
|
||||
])
|
||||
)
|
||||
|
||||
|
||||
grub_files=[
|
||||
'grub/fs/affs.c',
|
||||
#'grub/fs/afs.c',
|
||||
|
|
@ -351,16 +351,16 @@ libr2grub = static_library('libr2grub', grub_files,
|
|||
])]
|
||||
)
|
||||
|
||||
wind_files=[
|
||||
'wind/iob_pipe.c',
|
||||
'wind/kd.c',
|
||||
'wind/transport.c',
|
||||
'wind/wind.c',
|
||||
windbg_files=[
|
||||
'windbg/iob_pipe.c',
|
||||
'windbg/kd.c',
|
||||
'windbg/transport.c',
|
||||
'windbg/windbg.c',
|
||||
]
|
||||
|
||||
libr2wind = static_library('libr2wind', wind_files,
|
||||
libr2windbg = static_library('libr2windbg', windbg_files,
|
||||
include_directories: [platform_inc, include_directories([
|
||||
'wind'
|
||||
'windbg'
|
||||
])]
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
LINK+=$(STOP)/wind/libr_wind.${EXT_AR}
|
||||
1032
shlr/wind/wind.c
1032
shlr/wind/wind.c
File diff suppressed because it is too large
Load diff
|
|
@ -1,57 +0,0 @@
|
|||
// Copyright (c) 2014, The Lemon Man, All rights reserved.
|
||||
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 3.0 of the License, or (at your option) any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library.
|
||||
|
||||
#ifndef _WIND_H_
|
||||
#define _WIND_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "kd.h"
|
||||
|
||||
typedef struct _WindCtx WindCtx;
|
||||
|
||||
typedef struct WindProc {
|
||||
ut32 uniqueid;
|
||||
ut64 vadroot;
|
||||
ut64 dir_base_table;
|
||||
ut64 peb;
|
||||
char name[17];
|
||||
} WindProc;
|
||||
|
||||
// grep -e "^wind_" shlr/wind/wind.c | sed -e 's/ {$/;/' -e 's/^/int /'
|
||||
ut64 wind_get_target_base (WindCtx *ctx);
|
||||
ut32 wind_get_target (WindCtx *ctx);
|
||||
bool wind_set_target (WindCtx *ctx, ut32 pid);
|
||||
RList *wind_list_process (WindCtx *ctx);
|
||||
int wind_get_cpus (WindCtx *ctx);
|
||||
bool wind_set_cpu (WindCtx *ctx, int cpu);
|
||||
int wind_get_cpu (WindCtx *ctx);
|
||||
WindCtx * wind_ctx_new (void *io_ptr);
|
||||
void wind_ctx_free (WindCtx *ctx);
|
||||
int wind_wait_packet (WindCtx *ctx, const ut32 type, kd_packet_t **p);
|
||||
int wind_sync (WindCtx *ctx);
|
||||
bool wind_read_ver (WindCtx *ctx);
|
||||
int wind_continue (WindCtx *ctx);
|
||||
bool wind_write_reg (WindCtx *ctx, const uint8_t *buf, int size);
|
||||
int wind_read_reg (WindCtx *ctx, uint8_t *buf, int size);
|
||||
int wind_query_mem (WindCtx *ctx, const ut64 addr, int *address_space, int *flags);
|
||||
int wind_bkpt (WindCtx *ctx, const ut64 addr, const int set, const int hw, int *handle);
|
||||
int wind_read_at (WindCtx *ctx, uint8_t *buf, const ut64 offset, const int count);
|
||||
int wind_read_at_phys (WindCtx *ctx, uint8_t *buf, const ut64 offset, const int count);
|
||||
int wind_write_at (WindCtx *ctx, const uint8_t *buf, const ut64 offset, const int count);
|
||||
int wind_write_at_phys (WindCtx *ctx, const uint8_t *buf, const ut64 offset, const int count);
|
||||
bool wind_va_to_pa (WindCtx *ctx, ut64 va, ut64 *pa);
|
||||
bool wind_break (WindCtx *ctx);
|
||||
int wind_break_read(WindCtx *ctx);
|
||||
#endif
|
||||
|
|
@ -27,11 +27,11 @@ endif
|
|||
endif
|
||||
|
||||
CFLAGS+=-I../../libr/include
|
||||
LIBAR=libr_wind.${EXT_AR}
|
||||
LIBAR=libr_windbg.${EXT_AR}
|
||||
LDFLAGS+=-L../../libr/util
|
||||
LIBS=-lr_util
|
||||
|
||||
OFILES=transport.o kd.o wind.o iob_pipe.o
|
||||
OFILES=transport.o kd.o windbg.o iob_pipe.o
|
||||
|
||||
all: ${LIBAR}
|
||||
|
||||
1
shlr/windbg/deps.mk
Normal file
1
shlr/windbg/deps.mk
Normal file
|
|
@ -0,0 +1 @@
|
|||
LINK+=$(STOP)/windbg/libr_windbg.${EXT_AR}
|
||||
1087
shlr/windbg/windbg.c
Normal file
1087
shlr/windbg/windbg.c
Normal file
File diff suppressed because it is too large
Load diff
84
shlr/windbg/windbg.h
Normal file
84
shlr/windbg/windbg.h
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
// Copyright (c) 2014, The Lemon Man, All rights reserved.
|
||||
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 3.0 of the License, or (at your option) any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library.
|
||||
|
||||
#ifndef _windbg_H_
|
||||
#define _windbg_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "kd.h"
|
||||
|
||||
typedef struct _WindCtx WindCtx;
|
||||
|
||||
typedef struct WindProc {
|
||||
ut32 uniqueid;
|
||||
ut64 vadroot;
|
||||
ut64 dir_base_table;
|
||||
ut64 peb;
|
||||
char name[17];
|
||||
} WindProc;
|
||||
|
||||
enum {
|
||||
K_PaeEnabled = 0x036,
|
||||
K_PsActiveProcessHead = 0x050,
|
||||
K_CmNtCSDVersion = 0x268,
|
||||
};
|
||||
|
||||
enum {
|
||||
E_ActiveProcessLinks, // EPROCESS
|
||||
E_UniqueProcessId, // EPROCESS
|
||||
E_Peb, // EPROCESS
|
||||
E_ImageFileName, // EPROCESS
|
||||
E_VadRoot, // EPROCESS
|
||||
P_DirectoryTableBase, // PCB
|
||||
P_ImageBaseAddress, // PEB
|
||||
P_ProcessParameters, // PEB
|
||||
R_ImagePathName, // RTL_USER_PROCESS_PARAMETERS
|
||||
O_Max,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int build;
|
||||
int sp;
|
||||
int bits;
|
||||
int flags;
|
||||
int f[O_Max];
|
||||
} Profile;
|
||||
|
||||
// grep -e "^windbg_" shlr/wind/wind.c | sed -e 's/ {$/;/' -e 's/^/int /'
|
||||
ut64 windbg_get_target_base (WindCtx *ctx);
|
||||
ut32 windbg_get_target (WindCtx *ctx);
|
||||
bool windbg_set_target (WindCtx *ctx, ut32 pid);
|
||||
RList *windbg_list_process (WindCtx *ctx);
|
||||
int windbg_get_cpus (WindCtx *ctx);
|
||||
bool windbg_set_cpu (WindCtx *ctx, int cpu);
|
||||
int windbg_get_cpu (WindCtx *ctx);
|
||||
WindCtx * windbg_ctx_new (void *io_ptr);
|
||||
void windbg_ctx_free (WindCtx *ctx);
|
||||
int windbg_wait_packet (WindCtx *ctx, const ut32 type, kd_packet_t **p);
|
||||
int windbg_sync (WindCtx *ctx);
|
||||
bool windbg_read_ver (WindCtx *ctx);
|
||||
int windbg_continue (WindCtx *ctx);
|
||||
bool windbg_write_reg (WindCtx *ctx, const uint8_t *buf, int size);
|
||||
int windbg_read_reg (WindCtx *ctx, uint8_t *buf, int size);
|
||||
int windbg_query_mem (WindCtx *ctx, const ut64 addr, int *address_space, int *flags);
|
||||
int windbg_bkpt (WindCtx *ctx, const ut64 addr, const int set, const int hw, int *handle);
|
||||
int windbg_read_at (WindCtx *ctx, uint8_t *buf, const ut64 offset, const int count);
|
||||
int windbg_read_at_phys (WindCtx *ctx, uint8_t *buf, const ut64 offset, const int count);
|
||||
int windbg_write_at (WindCtx *ctx, const uint8_t *buf, const ut64 offset, const int count);
|
||||
int windbg_write_at_phys (WindCtx *ctx, const uint8_t *buf, const ut64 offset, const int count);
|
||||
bool windbg_va_to_pa (WindCtx *ctx, ut64 va, ut64 *pa);
|
||||
bool windbg_break (WindCtx *ctx);
|
||||
int windbg_break_read(WindCtx *ctx);
|
||||
#endif
|
||||
Loading…
Reference in a new issue