Skip to content

Commit

Permalink
Convert dW command to the rzshell
Browse files Browse the repository at this point in the history
  • Loading branch information
XVilka committed Sep 30, 2022
1 parent 2a22a1f commit 7c0bd7c
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 9 deletions.
29 changes: 20 additions & 9 deletions librz/core/cmd/cmd_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -2050,15 +2050,6 @@ RZ_IPI int rz_cmd_debug(void *data, const char *input) {
case 'k': // "dk"
rz_core_debug_kill(core, input + 1);
break;
#if __WINDOWS__
case 'W': // "dW"
if (input[1] == 'i') {
rz_w32_identify_window();
} else {
rz_w32_print_windows(core->dbg);
}
break;
#endif
case '?': // "d?"
default:
rz_core_cmd_help(core, help_msg_d);
Expand Down Expand Up @@ -3404,3 +3395,23 @@ RZ_IPI RzCmdStatus rz_cmd_debug_wait_handler(RzCore *core, int argc, const char
rz_cons_break_pop();
return RZ_CMD_STATUS_OK;
}

RZ_IPI RzCmdStatus rz_cmd_debug_windows_list_handler(RzCore *core, int argc, const char **argv) {
#if __WINDOWS__
rz_w32_print_windows(core->dbg);
return RZ_CMD_STATUS_OK;
#else
RZ_LOG_ERROR("This command works only on Microsoft Windows\n");
return RZ_CMD_STATUS_ERROR;
#endif
}

RZ_IPI RzCmdStatus rz_cmd_debug_window_identify_handler(RzCore *core, int argc, const char **argv) {
#if __WINDOWS__
rz_w32_identify_window();
return RZ_CMD_STATUS_OK;
#else
RZ_LOG_ERROR("This command works only on Microsoft Windows\n");
return RZ_CMD_STATUS_ERROR;
#endif
}
11 changes: 11 additions & 0 deletions librz/core/cmd_descs/cmd_debug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,17 @@ commands:
- name: pid
type: RZ_CMD_ARG_TYPE_NUM
optional: true
- name: dW
summary: Windows process commands
subcommands:
- name: dW
summary: List process windows
cname: cmd_debug_windows_list
args: []
- name: dWi
summary: Identify window under cursor
cname: cmd_debug_window_identify
args: []
- name: dx
summary: Code injection commands
subcommands:
Expand Down
24 changes: 24 additions & 0 deletions librz/core/cmd_descs/cmd_descs.c
Original file line number Diff line number Diff line change
Expand Up @@ -8610,6 +8610,25 @@ static const RzCmdDescHelp cmd_debug_wait_help = {
.args = cmd_debug_wait_args,
};

static const RzCmdDescHelp dW_help = {
.summary = "Windows process commands",
};
static const RzCmdDescArg cmd_debug_windows_list_args[] = {
{ 0 },
};
static const RzCmdDescHelp cmd_debug_windows_list_help = {
.summary = "List process windows",
.args = cmd_debug_windows_list_args,
};

static const RzCmdDescArg cmd_debug_window_identify_args[] = {
{ 0 },
};
static const RzCmdDescHelp cmd_debug_window_identify_help = {
.summary = "Identify window under cursor",
.args = cmd_debug_window_identify_args,
};

static const RzCmdDescHelp dx_help = {
.summary = "Code injection commands",
};
Expand Down Expand Up @@ -17269,6 +17288,11 @@ RZ_IPI void rzshell_cmddescs_init(RzCore *core) {
RzCmdDesc *cmd_debug_wait_cd = rz_cmd_desc_argv_new(core->rcmd, cmd_debug_cd, "dw", rz_cmd_debug_wait_handler, &cmd_debug_wait_help);
rz_warn_if_fail(cmd_debug_wait_cd);

RzCmdDesc *dW_cd = rz_cmd_desc_group_new(core->rcmd, cmd_debug_cd, "dW", rz_cmd_debug_windows_list_handler, &cmd_debug_windows_list_help, &dW_help);
rz_warn_if_fail(dW_cd);
RzCmdDesc *cmd_debug_window_identify_cd = rz_cmd_desc_argv_new(core->rcmd, dW_cd, "dWi", rz_cmd_debug_window_identify_handler, &cmd_debug_window_identify_help);
rz_warn_if_fail(cmd_debug_window_identify_cd);

RzCmdDesc *dx_cd = rz_cmd_desc_group_new(core->rcmd, cmd_debug_cd, "dx", rz_cmd_debug_inject_opcode_handler, &cmd_debug_inject_opcode_help, &dx_help);
rz_warn_if_fail(dx_cd);
RzCmdDesc *cmd_debug_inject_assembly_cd = rz_cmd_desc_argv_new(core->rcmd, dx_cd, "dxa", rz_cmd_debug_inject_assembly_handler, &cmd_debug_inject_assembly_help);
Expand Down
2 changes: 2 additions & 0 deletions librz/core/cmd_descs/cmd_descs.h
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,8 @@ RZ_IPI RzCmdStatus rz_debug_reg_roles_handler(RzCore *core, int argc, const char
RZ_IPI RzCmdStatus rz_debug_drx_handler(RzCore *core, int argc, const char **argv);
RZ_IPI RzCmdStatus rz_debug_drx_unset_handler(RzCore *core, int argc, const char **argv);
RZ_IPI RzCmdStatus rz_cmd_debug_wait_handler(RzCore *core, int argc, const char **argv);
RZ_IPI RzCmdStatus rz_cmd_debug_windows_list_handler(RzCore *core, int argc, const char **argv);
RZ_IPI RzCmdStatus rz_cmd_debug_window_identify_handler(RzCore *core, int argc, const char **argv);
RZ_IPI RzCmdStatus rz_cmd_debug_inject_opcode_handler(RzCore *core, int argc, const char **argv);
RZ_IPI RzCmdStatus rz_cmd_debug_inject_assembly_handler(RzCore *core, int argc, const char **argv);
RZ_IPI RzCmdStatus rz_cmd_debug_inject_egg_handler(RzCore *core, int argc, const char **argv);
Expand Down

0 comments on commit 7c0bd7c

Please sign in to comment.