mirror of
https://github.com/capstone-engine/capstone.git
synced 2024-11-30 08:50:42 +00:00
Done fixing
This commit is contained in:
parent
cd2e9567a2
commit
8f4bf69f62
@ -27,7 +27,7 @@
|
||||
0x40,0xf0,0x7f,0x80 = bne.w #258
|
||||
0xc0,0xf6,0x00,0x80 = blt.w #-1048572
|
||||
0xbf,0xf2,0xff,0xaf = bge.w #1048578
|
||||
0x80,0xd1 = bne #-256
|
||||
0x80,0xd1 = bne #-252
|
||||
0x7f,0xdc = bgt #258
|
||||
0x7f,0xf4,0x7f,0xaf = bne.w #-254
|
||||
0x00,0xf3,0x80,0x80 = bgt.w #260
|
||||
@ -44,7 +44,7 @@
|
||||
0x00,0xf0,0xff,0xbb = b.w #2050
|
||||
0x66,0xf6,0x30,0xbc = b.w #-1677212
|
||||
0x99,0xf1,0xcf,0xbb = b.w #1677218
|
||||
0x00,0xe4 = b #-2048
|
||||
0x00,0xe4 = b #-2044
|
||||
0xff,0xe3 = b #2050
|
||||
0xff,0xf7,0xff,0xbb = b.w #-2046
|
||||
0x00,0xf0,0x00,0xbc = b.w #2052
|
||||
|
@ -105,9 +105,10 @@ void add_str(char **src, const char *format, ...)
|
||||
|
||||
void replace_hex(char *src)
|
||||
{
|
||||
char *tmp, *result, *found, *origin;
|
||||
int i;
|
||||
char *tmp, *result, *found, *origin, *orig_found;
|
||||
int i, valid;
|
||||
unsigned long long int value;
|
||||
char *tmp_tmp;
|
||||
|
||||
result = (char *)malloc(sizeof(char));
|
||||
result[0] = '\0';
|
||||
@ -115,11 +116,14 @@ void replace_hex(char *src)
|
||||
origin = tmp;
|
||||
|
||||
while ((found = strstr(tmp, "0x")) != NULL) {
|
||||
*found = '\0';
|
||||
orig_found = found;
|
||||
found += 2;
|
||||
value = 0;
|
||||
valid = 0;
|
||||
|
||||
tmp_tmp = strndup(tmp, orig_found - tmp);
|
||||
while (*found != '\0' && isxdigit(*found)) {
|
||||
valid = 1;
|
||||
if (*found >= 'a' && *found <='f')
|
||||
value = value*0x10 + (*found - 'a' + 10);
|
||||
else
|
||||
@ -128,8 +132,10 @@ void replace_hex(char *src)
|
||||
found++;
|
||||
}
|
||||
|
||||
add_str(&result, "%s%llu", tmp, value);
|
||||
if (valid == 1) add_str(&result, "%s%llu", tmp_tmp, value);
|
||||
else add_str(&result, "%s0x", tmp_tmp);
|
||||
tmp = found;
|
||||
free(tmp_tmp);
|
||||
}
|
||||
|
||||
add_str(&result, "%s", tmp);
|
||||
@ -149,7 +155,7 @@ void replace_negative(char *src, int mode)
|
||||
{
|
||||
char *tmp, *result, *found, *origin, *orig_found;
|
||||
int i, cnt, valid;
|
||||
char *value;
|
||||
char *value, *tmp_tmp;
|
||||
unsigned short int tmp_short;
|
||||
unsigned int tmp_int;
|
||||
unsigned long int tmp_long;
|
||||
@ -158,7 +164,6 @@ void replace_negative(char *src, int mode)
|
||||
result[0] = '\0';
|
||||
tmp = strdup(src);
|
||||
origin = tmp;
|
||||
puts(tmp);
|
||||
|
||||
while ((found = strstr(tmp, "-")) != NULL) {
|
||||
orig_found = found;
|
||||
@ -177,24 +182,27 @@ void replace_negative(char *src, int mode)
|
||||
found++;
|
||||
}
|
||||
|
||||
tmp_tmp = strndup(tmp, orig_found - tmp);
|
||||
if (valid == 1) {
|
||||
*orig_found = '\0';
|
||||
if (mode == X86_16) {
|
||||
sscanf(value, "%hu", &tmp_short);
|
||||
add_str(&result, "%s%hu", tmp, tmp_short);
|
||||
add_str(&result, "%s%hu", tmp_tmp, tmp_short);
|
||||
} else if (mode == X86_32) {
|
||||
sscanf(value, "%u", &tmp_int);
|
||||
add_str(&result, "%s%u", tmp, tmp_int);
|
||||
add_str(&result, "%s%u", tmp_tmp, tmp_int);
|
||||
} else if (mode == X86_64) {
|
||||
sscanf(value, "%lu", &tmp_long);
|
||||
add_str(&result, "%s%lu", tmp, tmp_long);
|
||||
add_str(&result, "%s%lu", tmp_tmp, tmp_long);
|
||||
}
|
||||
tmp = found;
|
||||
}
|
||||
else add_str(&result, "%s-", tmp_tmp);
|
||||
|
||||
tmp = found;
|
||||
free(value);
|
||||
free(tmp_tmp);
|
||||
}
|
||||
|
||||
puts(tmp);
|
||||
add_str(&result, "%s", tmp);
|
||||
if (strlen(result) >= MAXMEM) {
|
||||
fprintf(stderr, "[ Error ] --- Buffer Overflow in replace_negative()\n");
|
||||
|
@ -334,9 +334,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (flag == 0) {
|
||||
printf("Usage: %s [-e] [-f <file_name.cs>] [-d <directory>]\n", argv[0]);
|
||||
char tmp[] = "bsoctr- cr2";
|
||||
replace_negative(tmp, 1);
|
||||
puts(tmp);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user