asm.strenc (latin1) (#7857)

This commit is contained in:
Khairul Azhar Kasmiran 2017-07-05 00:56:14 +08:00 committed by radare
parent e04b82059a
commit 41b944b357
4 changed files with 16 additions and 9 deletions

View File

@ -2110,7 +2110,7 @@ R_API int r_core_config_init(RCore *core) {
SETPREF ("asm.payloads", "false", "Show payload bytes in disasm");
n = NODECB ("asm.strenc", "guess", &cb_asmstrenc);
SETDESC (n, "Assumed string encoding for disasm");
SETOPTIONS (n, "utf8", "guess", NULL);
SETOPTIONS (n, "latin1", "utf8", "guess", NULL);
SETCB ("bin.strpurge", "false", &cb_strpurge, "Try to purge false positive strings");
SETPREF ("bin.libs", "false", "Try to load libraries after loading main binary");
n = NODECB ("bin.strfilter", "", &cb_strfilter);

View File

@ -2644,7 +2644,14 @@ static void ds_print_asmop_payload(RDisasmState *ds, const ut8 *buf) {
static void ds_print_str(RDisasmState *ds, const char *str, int len) {
const char *nl = ds->show_comment_right ? "" : "\n";
if (!strcmp (ds->strenc, "utf8")) {
if (!strcmp (ds->strenc, "latin1")) {
char *escstr = r_str_escape_latin1 (str);
if (escstr) {
ALIGN;
ds_comment (ds, true, "; \"%s\"%s", escstr, nl);
free (escstr);
}
} else if (!strcmp (ds->strenc, "utf8")) {
char *escstr = r_str_escape_utf8 (str);
if (escstr) {
ALIGN;
@ -2665,7 +2672,7 @@ static void ds_print_str(RDisasmState *ds, const char *str, int len) {
&& str[i] != '"' && str[i] != '\\') {
ds_comment (ds, false, "%c", str[i]);
} else {
char *escchar = r_str_escape_all (&str[i]);
char *escchar = r_str_escape_latin1 (&str[i]);
if (escchar) {
ds_comment (ds, false, "%s", escchar);
free (escchar);
@ -2677,7 +2684,7 @@ static void ds_print_str(RDisasmState *ds, const char *str, int len) {
}
ds_comment (ds, false, "\"%s", nl);
} else {
char *escstr = r_str_escape_all (str);
char *escstr = r_str_escape_latin1 (str);
if (escstr) {
ALIGN;
ds_comment (ds, true, "; \"%s\"%s", escstr, nl);

View File

@ -101,7 +101,7 @@ R_API int r_str_re_replace(const char *str, const char *reg, const char *sub);
R_API int r_str_unescape(char *buf);
R_API char *r_str_escape(const char *buf);
R_API char *r_str_escape_dot(const char *buf);
R_API char *r_str_escape_all(const char *buf);
R_API char *r_str_escape_latin1(const char *buf);
R_API char *r_str_escape_utf8(const char *buf);
R_API void r_str_uri_decode(char *buf);
R_API char *r_str_uri_encode(const char *buf);

View File

@ -1290,14 +1290,14 @@ R_API char *r_str_escape(const char *buf) {
return r_str_escape_ (buf, false, true);
}
R_API char *r_str_escape_all(const char *buf) {
return r_str_escape_ (buf, false, false);
}
R_API char *r_str_escape_dot(const char *buf) {
return r_str_escape_ (buf, true, true);
}
R_API char *r_str_escape_latin1(const char *buf) {
return r_str_escape_ (buf, false, false);
}
R_API char *r_str_escape_utf8(const char *buf) {
char *new_buf, *q;
const char *p, *end;