Skip to content

Commit

Permalink
Fix wrong variable name when using ESP as base register ##disasm
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Mar 1, 2021
1 parent 2fe490c commit 78dff27
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libr/core/disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1635,7 +1635,7 @@ static ut32 tmp_get_realsize (RAnalFunction *f) {
}

static void ds_show_functions_argvar(RDisasmState *ds, RAnalFunction *fcn, RAnalVar *var, const char *base, bool is_var, char sign) {
int delta = var->kind == 'b' ? R_ABS (var->delta + fcn->bp_off) : R_ABS (var->delta);
int delta = var->kind == 'b' ? R_ABS (var->delta + fcn->bp_off) : R_ABS (var->delta - ((var->kind=='s')?8:0));
const char *pfx = is_var ? "var" : "arg";
char *constr = r_anal_var_get_constraints_readable (var);
r_cons_printf ("%s%s %s%s%s%s %s%s%s%s@ %s%c0x%x", COLOR_ARG (ds, color_func_var), pfx,
Expand Down
30 changes: 30 additions & 0 deletions test/db/anal/vars
Original file line number Diff line number Diff line change
Expand Up @@ -326,3 +326,33 @@ afvW
var_4h 0x27
EOF
RUN

NAME=Labe07 stack vars
FILE=bins/pe/Lab07_01.exe
CMDS=<<EOF
aa
s..000
pdf
EOF
EXPECT=<<EOF
; CALL XREF from entry0 @ 0x40123f
;-- section..text:
/ 59: fcn.00401000 ();
| ; var int32_t var_8h @ esp+0x8
| ; var int32_t var_ch @ esp+0xc
| ; var int32_t var_10h @ esp+0x10
| 0x00401000 83ec10 sub esp, 0x10 ; [00] -r-x section size 12288 named .text
| 0x00401003 8d442400 lea eax, [esp]
| 0x00401007 c74424003050. mov dword [esp], str.MalService ; [0x405030:4]=0x536c614d ; "MalService"
| 0x0040100f 50 push eax
| 0x00401010 c74424084010. mov dword [var_8h], fcn.00401040 ; [0x401040:4]=0x400ec81
| 0x00401018 c744240c0000. mov dword [var_ch], 0
| 0x00401020 c74424100000. mov dword [var_10h], 0
| 0x00401028 ff1504404000 call dword [sym.imp.ADVAPI32.dll_StartServiceCtrlDispatcherA] ; 0x404004 ; "&F" ; BOOL StartServiceCtrlDispatcherA(const SERVICE_TABLE_ENTRYA *lpServiceStartTable)
| 0x0040102e 6a00 push 0
| 0x00401030 6a00 push 0
| 0x00401032 e809000000 call fcn.00401040
| 0x00401037 83c418 add esp, 0x18
\ 0x0040103a c3 ret
EOF
RUN

0 comments on commit 78dff27

Please sign in to comment.