From 45605fce9df49679bcac1b99933ce59112c4c270 Mon Sep 17 00:00:00 2001 From: pancake Date: Mon, 26 Dec 2022 11:18:01 +0100 Subject: [PATCH] Implement `pvp` and `wvp` to print and write pointers ##print * Uses wv8/wv4 depending on asm.bits --- libr/core/cmd_print.c | 5 ++++- libr/core/cmd_write.c | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libr/core/cmd_print.c b/libr/core/cmd_print.c index 77ec9d4a06..d0fb08ff0a 100644 --- a/libr/core/cmd_print.c +++ b/libr/core/cmd_print.c @@ -534,7 +534,7 @@ static const char *help_msg_pv[] = { "pv2", "", "print 2 bytes in memory", "pv4", "", "print 4 bytes in memory", "pv8", "", "print 8 bytes in memory", - "pv8", "", "print 8 bytes in memory", + "pvp", "", "print 4 or 8 bytes depending on asm.bits" "pve", " [1234] ([bsize])", "print value with any endian (1234, ", "pvz", "", "print value as string (alias for ps)", NULL @@ -3488,6 +3488,9 @@ static void cmd_print_pv(RCore *core, const char *input, bool useBytes) { int type = 'v'; bool fixed_size = true; switch (input[0]) { + case 'p': // "pvp" + input++; + break; case '1': // "pv1" n = 1; input++; diff --git a/libr/core/cmd_write.c b/libr/core/cmd_write.c index ed83a69117..21ab775ea6 100644 --- a/libr/core/cmd_write.c +++ b/libr/core/cmd_write.c @@ -160,6 +160,7 @@ static const char *help_msg_wv[] = { "wv2", " 234", "write unsigned short (2 bytes) with this number", "wv4", " 1 2 3", "write N space-separated dword (4 bytes)", "wv8", " 234", "write qword (8 bytes) with this number", + "wvp", " 934", "write 4 or 8 byte pointer, depending on asm.bits", "wvf", " 3.14", "write float value (4 bytes)", "wvF", " 3.14", "write double value (8 bytes)", "wvG", " 3.14", "write long double value (10/16 bytes)", @@ -458,8 +459,12 @@ static void cmd_write_value(RCore *core, const char *input) { bool be = r_config_get_b (core->config, "cfg.bigendian"); r_core_return_value (core, R_CMD_RC_SUCCESS); + char op = input[0]; + if (op == 'p') { + op = (r_config_get_i (core->config, "asm.bits") == 64)? '8': '4'; + } - switch (input[0]) { + switch (op) { case '?': // "wv?" r_core_cmd_help (core, help_msg_wv); return;