Hex-Rays 生成的 C 代码添加了大量冗余代码,我无法弄清楚原因,在逆向工程过程中手动删除它们真的让我感到沮丧。
if ( v1 )
{
v15.ObjectID = *(_DWORD *)Obj.ObjectID;
v6 = AccessObject((Object)&v15);
ObjectType::setTypeID(&v16, v6->Type.TypeID);
v7 = ObjectType::getFlag(&v16, BANK);
v4 = 0;
if ( !v7 )
{
v16.TypeID = *(_DWORD *)Obj.ObjectID;
v8 = AccessObject((Object)&v16);
ObjectType::setTypeID((ObjectType *const )&v15, v8->Type.TypeID);
v9 = ObjectType::getFlag((ObjectType *const )&v15, CLIP);
v4 = 1;
if ( !v9 )
{
v16.TypeID = *(_DWORD *)Obj.ObjectID;
v10 = AccessObject((Object)&v16);
ObjectType::setTypeID((ObjectType *const )&v15, v10->Type.TypeID);
v11 = ObjectType::getFlag((ObjectType *const )&v15, BOTTOM);
v4 = 2;
if ( !v11 )
{
v16.TypeID = *(_DWORD *)Obj.ObjectID;
v12 = AccessObject((Object)&v16);
ObjectType::setTypeID((ObjectType *const )&v15, v12->Type.TypeID);
v13 = ObjectType::getFlag((ObjectType *const )&v15, TOP);
v4 = 3;
if ( !v13 )
{
v16.TypeID = *(_DWORD *)Obj.ObjectID;
v14 = AccessObject((Object)&v16);
ObjectType::setTypeID((ObjectType *const )&v15, v14->Type.TypeID);
v4 = (v15.ObjectID != 99) + 4;
}
}
}
}
}
else
{
error("GetObjectPriority: _bergebenes Objekt existiert nicht.\n");
v4 = 0x7FFFFFFF;
}
对 v15 堆栈变量进行了连续赋值,这完全没有意义,我怀疑这个二进制文件的实际程序员是否有这个意图。
我可以很容易地这样做:
int32_t Priority = 0;
if (Object)
{
if (!Object->getFlag(BANK))
{
Priority = 1;
if (!Object->getFlag(CLIP))
{
Priority = 2;
if (!Object->getFlag(BOTTOM))
{
Priority = 3;
if (!Object->getFlag(TOP))
{
Priority = (Object->TypeID != 99) + 4;
}
}
}
}
}
else
{
std::cout << "GetObjectPriority: Object is NULL." << std::endl;
Priority = -1;
}
return Priority;
我怎么能弄乱 IDA 来阻止这种疯狂?