UE4 - IDA快速定位查找GName
FNamePool::FNamePool()
: AnsiCount(0)
, WideCount(0)
{
// Register all hardcoded names
#define REGISTER_NAME(num, name) ENameToEntry[num] = Store(FNameStringView(#name, FCStringAnsi::Strlen(#name)));
#include "UObject/UnrealNames.inl"
#undef REGISTER_NAME
// Verify all ENames are unique
if (NumAnsiEntries() != EntryToEName.Num())
{
// we can't print out here because there may be no log yet if this happens before main starts
if (FPlatformMisc::IsDebuggerPresent())
{
UE_DEBUG_BREAK();
}
else
{
FPlatformMisc::PromptForRemoteDebugging(false);
FMessageDialog::Open(EAppMsgType::Ok, NSLOCTEXT("UnrealEd", "DuplicatedHardcodedName", "Duplicate hardcoded name"));
FPlatformMisc::RequestExit(false);
}
}
}
这里劈里啪啦贴了一坨代码,众所周知,这个是一个C++类的构造函数,那么在逆向的时候这个函数的x0寄存器也就是入参的第一个他就是this指向FNamePool类的一个指针
,我们可以按照上个文章的传统方法去搜索字符串,包括不限于网上满天飞的ByteProperty
,也可以是Duplicate hardcoded name
,反正你爱搜什么搜什么!
搜索出来可以定位到一个函数(我顺手给他改了个名字嘻嘻
随便挑一个xrefs的,跳过去,你会看到这样的结构如果长这样,那么一般来说就说明找对了,因为源代码长这样:
static bool bNamePoolInitialized;
alignas(FNamePool) static uint8 NamePoolData[sizeof(FNamePool)];
// Only call this once per public FName function called
//
// Not using magic statics to run as little code as possible
static FNamePool& GetNamePool()
{
if (bNamePoolInitialized)
{
return *(FNamePool*)NamePoolData;
}
FNamePool* Singleton = new (NamePoolData) FNamePool;
bNamePoolInitialized = true;
return *Singleton;
}