* Apply some fixes for w32

* More nullptr checks
  - Fix 'drp'
* Fix build
This commit is contained in:
pancake 2010-10-14 19:01:14 +02:00
parent 93e69bab0e
commit 5d946a8b21
5 changed files with 25 additions and 19 deletions

View File

@ -725,8 +725,7 @@ static void cmd_reg(RCore *core, const char *str) {
// TODO: 'drs' to swap register arenas and display old register valuez
break;
case 'p':
if (str[1]) {
eprintf ("profile: \n");
if (!str[1]) {
if (core->dbg->reg_profile)
r_cons_printf ("%s\n", core->dbg->reg_profile);
else eprintf ("No register profile defined. Try 'dr.'\n");

View File

@ -899,6 +899,7 @@ static int r_debug_native_bp_read(int pid, ut64 addr, int hw, int rwx) {
#if __i386__
/* TODO: Can I use this as in a coroutine? */
static RList *r_debug_native_frames(RDebug *dbg) {
RRegItem *ri;
RReg *reg = dbg->reg;
ut32 i, _esp, esp, ebp2;
RList *list = r_list_new ();
@ -906,22 +907,25 @@ static RList *r_debug_native_frames(RDebug *dbg) {
ut8 buf[4];
list->free = free;
_esp = r_reg_get_value (reg, r_reg_get (reg, "esp", R_REG_TYPE_GPR));
// TODO: implement [stack] map uptrace method too
esp = _esp;
for (i=0; i<MAXBT; i++) {
bio->read_at (bio->io, esp, (void *)&ebp2, 4);
*buf = '\0';
bio->read_at (bio->io, (ebp2-5)-(ebp2-5)%4, (void *)&buf, 4);
ri = r_reg_get (reg, "esp", R_REG_TYPE_GPR);
if (ri != NULL) {
_esp = r_reg_get_value (reg, ri);
// TODO: implement [stack] map uptrace method too
esp = _esp;
for (i=0; i<MAXBT; i++) {
bio->read_at (bio->io, esp, (void *)&ebp2, 4);
*buf = '\0';
bio->read_at (bio->io, (ebp2-5)-(ebp2-5)%4, (void *)&buf, 4);
// TODO: arch_is_call() here and this fun will be portable
if (buf[(ebp2-5)%4]==0xe8) {
RDebugFrame *frame = R_NEW (RDebugFrame);
frame->addr = ebp2;
frame->size = esp-_esp;
r_list_append (list, frame);
// TODO: arch_is_call() here and this fun will be portable
if (buf[(ebp2-5)%4]==0xe8) {
RDebugFrame *frame = R_NEW (RDebugFrame);
frame->addr = ebp2;
frame->size = esp-_esp;
r_list_append (list, frame);
}
esp += 4;
}
esp += 4;
}
return list;
}

View File

@ -228,7 +228,7 @@ R_API RRegItem *r_reg_get(RReg *reg, const char *name, int type) {
RListIter *iter;
RRegItem *r;
int i, e;
if (!reg)
if (!reg || !name)
return NULL;
if (type == -1) {
i = 0;

View File

@ -10,8 +10,11 @@ R_API ut64 r_reg_get_value(RReg *reg, RRegItem *item) {
ut32 v32;
ut16 v16;
ut8 v8;
int off;
ut64 ret = 0LL;
int off = BITS2BYTES(item->offset);
if (reg == NULL || item == NULL)
return 0LL;
off = BITS2BYTES (item->offset);
regset = &reg->regset[item->type];
if (item)
switch (item->size) {

View File

@ -87,7 +87,7 @@ R_API int r_sys_setenv(const char *key, const char *value) {
#if __WINDOWS__
R_API const char *r_sys_getenv(const char *key) {
static const char envbuf[1024];
static char envbuf[1024];
envbuf[0] = 0;
GetEnvironmentVariable (key, (LPSTR)&envbuf, sizeof (envbuf));
return envbuf;