diff --git a/LE1DebugLogger/DebugLogger.cpp b/LE1DebugLogger/DebugLogger.cpp index c6fc1d1..c3319f1 100644 --- a/LE1DebugLogger/DebugLogger.cpp +++ b/LE1DebugLogger/DebugLogger.cpp @@ -38,6 +38,28 @@ UObject* CreateImport_hook(ULinkerLoad* Context, int i) return object; } + +UObject* CreateExport_hook(ULinkerLoad* Context, int i) +{ + logger.writeToLog(wstring_format(L"Creating UExport %i in %s\n", i + 1, Context->Filename.Data), true); + UObject* object = CreateExport_orig(Context, i); + if (object != nullptr) { + logger.writeToLog(wstring_format(L"Loaded UExport %i (%hs)\n", i + 1, object->GetName()), true); + } + else { + logger.writeToLog(wstring_format(L"FAILED TO LOAD UEXPORT %i!\n", i + 1), true); + } + logger.flush(); + + /*if (object == nullptr) + { + FObjectImport importEntry = Context->ImportMap(i); + logger.writeToLog(wstring_format(L"Could not resolve #%d: %hs (%hs) in file: %s\n", -i - 1, importEntry.ObjectName.GetName(), importEntry.ClassName.GetName(), Context->Filename.Data), true); + logger.flush(); + }*/ + return object; +} + // Logs a message from a source void logMessage(const wchar_t* logSource, wchar_t* formatStr, void* param1, void* param2) { @@ -267,6 +289,13 @@ SPI_IMPLEMENT_ATTACH INIT_FIND_PATTERN_POSTHOOK(CreateImport, /*48 8b c4 55 41*/ "54 41 55 41 56 41 57 48 8b ec 48 83 ec 70 48 c7 45 d0 fe ff ff ff 48 89 58 10 48 89 70 18 48 89 78 20 4c 63 e2"); INIT_HOOK_PATTERN(CreateImport); + if (nullptr != std::wcsstr(GetCommandLineW(), L" -debugexportcreation")) { + // Hook CreateExport - this will print a ton of logs! + // This is game specific since pattern has to extend into memory addressing + INIT_FIND_PATTERN_POSTHOOK(CreateExport, /*89 54 24 10 55*/ "56 57 41 54 41 55 41 56 41 57 48 8b ec 48 83 ec 70 48 c7 45 d0 fe ff ff ff 48 89 9c 24 c0 00 00 00 4c 63 e2 48 8b f1 48 89 0d b5 12 58 01 44 89 25 0e 49 51 01 49 6b dc 64 48 03 99 2c 01 00 00"); + INIT_HOOK_PATTERN(CreateExport); + } + // FIX ADDR // OBJECT PRELOAD (called on every object in a package file, can be used for seekfree) //INIT_FIND_PATTERN_POSTHOOK(LinkerLoadPreload, /*"40 55 56 57 41*/ "54 41 55 41 56 41 57 48 8d 6c 24 d9 48 81 ec 90 00 00 00 48 c7 45 e7 fe ff ff ff"); diff --git a/LE1DebugLogger/HookPrototypes.h b/LE1DebugLogger/HookPrototypes.h index ff4b42a..f8ff0e0 100644 --- a/LE1DebugLogger/HookPrototypes.h +++ b/LE1DebugLogger/HookPrototypes.h @@ -302,6 +302,10 @@ typedef UPackage* (*tLoadPackage)(void* param1, wchar_t* packageName, ELoadFlags tLoadPackage LoadPackage = nullptr; tLoadPackage LoadPackage_orig = nullptr; +typedef UObject* (*tCreateExport)(ULinkerLoad* Context, int UIndex); +tCreateExport CreateExport = nullptr; +tCreateExport CreateExport_orig = nullptr; + typedef uint32(*tAsyncLoadMethod)(UnLinker* linker, int a2, float a3); tAsyncLoadMethod LoadPackageAsyncTick = nullptr; tAsyncLoadMethod LoadPackageAsyncTick_orig = nullptr;