mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-27 15:10:53 +00:00
parent
e7086d0253
commit
3da3958db8
@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2014-2016, The Lemon Man, All rights reserved.
|
||||
// Copyright (c) 2014-2017, The Lemon Man, All rights reserved. LGPLv3
|
||||
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -319,7 +319,7 @@ static bool __plugin_open_default(RIO *io, const char *file, bool many) {
|
||||
return r_io_def_mmap_check_default (file);
|
||||
}
|
||||
|
||||
// default open should permit opening
|
||||
// default open should permit opening
|
||||
static RIODesc *__open_default(RIO *io, const char *file, int flags, int mode) {
|
||||
RIODesc *iod;
|
||||
if (!r_io_def_mmap_check_default (file) ) return NULL;
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2014, The Lemon Man, All rights reserved.
|
||||
// Copyright (c) 2014-2017, The Lemon Man, All rights reserved. LGPLv3
|
||||
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
@ -21,15 +21,16 @@
|
||||
#include <windbg.h>
|
||||
|
||||
static bool __plugin_open(RIO *io, const char *file, bool many) {
|
||||
return !strncmp (file, "windbg://", strlen ("windbg://"));
|
||||
return (!strncmp (file, "windbg://", 9));
|
||||
}
|
||||
|
||||
static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
|
||||
void *io_ctx;
|
||||
WindCtx *ctx;
|
||||
|
||||
if (!__plugin_open (io, file, 0))
|
||||
if (!__plugin_open (io, file, 0)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!iob_select ("pipe")) {
|
||||
eprintf("Could not initialize the IO backend\n");
|
||||
@ -44,20 +45,24 @@ static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
|
||||
|
||||
ctx = windbg_ctx_new (io_ctx);
|
||||
|
||||
if (!ctx)
|
||||
if (!ctx) {
|
||||
eprintf ("Failed to initialize windbg context\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return r_io_desc_new (&r_io_plugin_windbg, -1, file, true, mode, ctx);
|
||||
}
|
||||
|
||||
static int __write(RIO *io, RIODesc *fd, const ut8 *buf, int count) {
|
||||
if (!fd)
|
||||
if (!fd) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (windbg_get_target(fd->data)) {
|
||||
if (windbg_get_target (fd->data)) {
|
||||
ut64 va;
|
||||
if (!windbg_va_to_pa (fd->data, io->off, &va))
|
||||
if (!windbg_va_to_pa (fd->data, io->off, &va)) {
|
||||
return -1;
|
||||
}
|
||||
return windbg_write_at_phys (fd->data, buf, va, count);
|
||||
}
|
||||
|
||||
@ -65,21 +70,31 @@ static int __write(RIO *io, RIODesc *fd, const ut8 *buf, int count) {
|
||||
}
|
||||
|
||||
static ut64 __lseek(RIO *io, RIODesc *fd, ut64 offset, int whence) {
|
||||
return offset;
|
||||
switch (whence) {
|
||||
case R_IO_SEEK_SET:
|
||||
return offset;
|
||||
case R_IO_SEEK_CUR:
|
||||
return io->off + offset;
|
||||
case R_IO_SEEK_END:
|
||||
return UT64_MAX;
|
||||
default:
|
||||
return offset;
|
||||
}
|
||||
}
|
||||
|
||||
static int __read(RIO *io, RIODesc *fd, ut8 *buf, int count) {
|
||||
if (!fd)
|
||||
if (!fd) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (windbg_get_target(fd->data)) {
|
||||
if (windbg_get_target (fd->data)) {
|
||||
ut64 va;
|
||||
if (!windbg_va_to_pa (fd->data, io->off, &va))
|
||||
return -1;
|
||||
return windbg_read_at_phys(fd->data, buf, va, count);
|
||||
return windbg_read_at_phys (fd->data, buf, va, count);
|
||||
}
|
||||
|
||||
return windbg_read_at(fd->data, buf, io->off, count);
|
||||
return windbg_read_at (fd->data, buf, io->off, count);
|
||||
}
|
||||
|
||||
static int __close(RIODesc *fd) {
|
||||
@ -89,13 +104,21 @@ static int __close(RIODesc *fd) {
|
||||
|
||||
RIOPlugin r_io_plugin_windbg = {
|
||||
.name = "windbg",
|
||||
.desc = "Attach to a KD debugger",
|
||||
.desc = "Attach to a KD debugger (windbg://socket)",
|
||||
.license = "LGPL3",
|
||||
.open = __open,
|
||||
.close = __close,
|
||||
.read = __read,
|
||||
.write = __write,
|
||||
.check = __plugin_open,
|
||||
.lseek = __lseek,
|
||||
.isdbg = true,
|
||||
.write = __write,
|
||||
.isdbg = true
|
||||
};
|
||||
|
||||
#ifndef CORELIB
|
||||
RLibStruct radare_plugin = {
|
||||
.type = R_LIB_TYPE_IO,
|
||||
.data = &r_io_plugin_windbg,
|
||||
.version = R2_VERSION
|
||||
};
|
||||
#endif
|
||||
|
@ -43,7 +43,6 @@ enum {
|
||||
#define KD_RET_OK 0x00000000
|
||||
#define KD_RET_ERR 0xC0000001
|
||||
#define KD_RET_ENOENT 0xC000000F
|
||||
#define KD_DBG_CONT 0x00010001
|
||||
|
||||
#define KD_MACH_I386 0x014C
|
||||
#define KD_MACH_IA64 0x0200
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2014-2015, The Lemon Man, All rights reserved. LGPLv3
|
||||
// Copyright (c) 2014-2017, The Lemon Man, All rights reserved. LGPLv3
|
||||
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
@ -429,7 +429,7 @@ bool windbg_va_to_pa(WindCtx *ctx, ut64 va, ut64 *pa) {
|
||||
tmp = ctx->target->dir_base_table;
|
||||
tmp &= ~0x1f;
|
||||
|
||||
WIND_DBG eprintf ("cr3 : %016"PFMT64x "\n", tmp);
|
||||
WIND_DBG eprintf ("CR3 : %016"PFMT64x "\n", tmp);
|
||||
|
||||
if (ctx->is_x64) {
|
||||
// PML4 lookup
|
||||
|
Loading…
Reference in New Issue
Block a user