Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgamerz committed Nov 1, 2023
2 parents 8934746 + 06ae108 commit bd7f285
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
26 changes: 24 additions & 2 deletions LE2DebugLogger/DebugLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

#include "HookPrototypes.h"

SPI_PLUGINSIDE_SUPPORT(L"DebugLogger", L"3.0.0", L"ME3Tweaks", SPI_GAME_LE2, SPI_VERSION_LATEST);
SPI_PLUGINSIDE_SUPPORT(L"DebugLogger", L"4.0.0", L"ME3Tweaks", SPI_GAME_LE2, SPI_VERSION_LATEST);
SPI_PLUGINSIDE_PRELOAD;
SPI_PLUGINSIDE_SEQATTACH;

ME3TweaksASILogger logger("DebugLogger v3", "LE2DebugLogger.log");
ME3TweaksASILogger logger("DebugLogger v4", "LE2DebugLogger.log");

// ===========================
// Debug output from game
Expand Down Expand Up @@ -119,6 +119,21 @@ 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();

return object;
}

// Logs a message from a source
void logMessage(const wchar_t* logSource, wchar_t* formatStr, void* param1, void* param2, void* param3, void* param4)
{
Expand Down Expand Up @@ -318,6 +333,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");
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");
Expand Down
4 changes: 4 additions & 0 deletions LE2DebugLogger/HookPrototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ typedef UObject* (*tCreateImport)(ULinkerLoad* Context, int UIndex);
tCreateImport CreateImport = nullptr;
tCreateImport CreateImport_orig = nullptr;

typedef UObject* (*tCreateExport)(ULinkerLoad* Context, int UIndex);
tCreateExport CreateExport = nullptr;
tCreateExport CreateExport_orig = nullptr;

// ProcessEvent
typedef void (*tProcessEvent)(UObject* Context, UFunction* Function, void* Parms, void* Result);
tProcessEvent ProcessEvent = nullptr;
Expand Down
2 changes: 2 additions & 0 deletions LE2HotReload/LE2HotReload.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define GAMELE2

#include "../../Shared-ASI/Interface.h"
#include "../../Shared-ASI/Common.h"

Expand Down
3 changes: 0 additions & 3 deletions LE2HotReload/LE2HotReload.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@
<ItemGroup>
<ClCompile Include="LE2HotReload.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="HookPrototypes.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down

0 comments on commit bd7f285

Please sign in to comment.