我已将 objdumped 文件转换为临时 C 代码,并试图弄清楚它的作用。特别是,我被困在了一次部分。我将首先给出较大的部分,然后给出我所坚持的部分。
较大的代码部分:
while (true) {
bool v3 = v2 == 5 | v2 < 5 ^ (4 - v2 & v2) < 0; // 0x8048600
// branch -> 0x80485a7
while (true) {
// 0x80485a7
if ((int32_t)file == g1) {
// 0x80485af
printf("guess %d (of 5)? ", v2);
// branch -> 0x80485bf
}
// 0x80485bf
int32_t str2;
char * str = fgets((char *)&str2, 512, file); // 0x80485d2
if (str == NULL) {
// 0x80485fd
if (!v3) {
// break -> 0x8048602
break;
}
// continue -> 0x80485a7
continue;
} else {
int32_t str3 = *(int32_t *)(4 * v2 + 0x80498ec); // 0x80485db
if (strcmp(str, (char *)str3) != 0) {
// 0x80485ee
bomb();
// branch -> 0x80485f3
}
int32_t v4 = v2 + 1; // 0x80485f3
if (v4 >= 6) {
// break (via goto) -> 0x8048602
goto lab_0x8048602;
}
v2 = v4;
// continue (via goto) -> 0x80485a7
goto lab_0x80485a7;
}
// 0x8048602
success();
return 0;
}
lab_0x8048602:
// 0x8048602
success();
return 0;
}
特别给我带来麻烦的部分:
int32_t str3 = *(int32_t *)(4 * v2 + 0x80498ec); // 0x80485db
if (strcmp(str, (char *)str3) != 0) {
// 0x80485ee
bomb();
// branch -> 0x80485f3
}
我知道strcmp返回1,0,-1,但是这个语句到底测试什么?我不完全确定 str3 的值是什么:*(int32_t *)(4 * v2 + 0x80498ec);
。我知道这会将该地址的值转换为某个值,但我不确定是什么。
最佳答案
显然,0x80498ec 是一个指向 char 的指针数组
char *msg [] = {"One", "two", "three", "four", "five"};
和v2是该指针数组的索引。
该行最初可能已读取
if (strcmp (str, msg[v2]) != 0)
bomb ();
关于c - 这个半反编译代码有什么作用(C),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35928859/