使用c++中从IDA导出的带有指针的结构体

Using a struct exported from IDA with pointers in C++

本文关键字:指针 结构体 c++ 中从 IDA 使用      更新时间:2023-10-16

所以我已经从IDA Pro导出了一个结构体,并把它放在一个头文件中,像这样:

#pragma pack(push, 1)
struct CPed
{
     float health;
     CPed *closestPeds[10];
};
#pragma pack(pop)

在主界面中我是这样使用的:

unsigned int ClosestPed = *(unsigned int *)(*(unsigned int *)PlayerPointer + NearestPeds);
CPed *nearestPed = (CPed *)ClosestPed;
nearestPed->health = 0;

正如我所看到的,主代码中的第一行代码应该将NearestPeds的偏移量添加到PlayerPointer中,并将其放入ClosestPed中。

现在ClosestPed保存了最近的ped的地址。

现在我将该地址传递给*nearestPed,然后最后将最近的ped的健康值设置为0,只是,ped的健康值永远不会设置为0。它永不消逝。

谁能帮我弄清楚是怎么回事?

你想做这样的事情吗?

CPed* nearestPed = (CPed*)(*(PlayerPointer+9));
nearestPed->health = 0;