所以我决定尝试使用 Ghidra 反编译/反汇编一个带有虚函数和非虚函数的简单 c++ 类。然而; 反编译让我有点困惑。下面是我的源代码和我的反编译。我不明白为什么对非虚函数的调用由诸如打印字符串和其他 3 个奇怪的参数之类的参数组成。这些其他参数是什么?我只能假设其中一个是“This”指针?如果是这样,另外两个是什么?
在 Visual Studio 2k17 x64 版本上编译,没有 pdb
资源
#include <iostream>
#include <stdio.h>
class Person
{
public:
Person(int val)
{
myval = val;
}
void PersonFunction()
{
printf("this is a person func/n");
}
virtual void PersonFunction2()
{
printf("this is a person func2/n");
}
protected:
int myval = 5;
};
int main(int argc, char** argv)
{
Person * person = new Person(10);
std::cout << "Hello World!\n";
person->PersonFunction();
person->PersonFunction2();
}
反编译
undefined8
FUN_140001080(undefined8 param_1,undefined8 param_2,undefined8 param_3,undefined8 param_4)
{
code **ppcVar1;
ppcVar1 = (code **)operator_new(0x10);
*ppcVar1 = (code *)Person::vftable;
*(undefined4 *)(ppcVar1 + 1) = 10;
FUN_1400010e0((longlong *)cout_exref);
FUN_140001010("this is a person func/n",param_2,param_3,param_4); #what is going on here.. why 3 params?
(**(code **)*ppcVar1)(ppcVar1); # this, i assume is the virtual function call passing in this ptr
return 0;
}
// furthermore inside FUN140001010
void FUN_140001010(undefined8 param_1,undefined8 param_2,undefined8 param_3,undefined8 param_4)
{
undefined8 uVar1;
undefined8 *puVar2;
undefined8 local_res10;
undefined8 local_res18;
undefined8 local_res20;
local_res10 = param_2;
local_res18 = param_3;
local_res20 = param_4;
uVar1 = __acrt_iob_func(1);
puVar2 = (undefined8 *)FUN_140001000();
__stdio_common_vfprintf(*puVar2,uVar1,param_1,0,&local_res10);
return;
}
谁能解释接受我的字符串和三个参数的函数发生了什么?参数是什么?为什么要传递字符串?