Skip to content

Commit

Permalink
Chainload example
Browse files Browse the repository at this point in the history
  • Loading branch information
techiew committed Oct 29, 2024
1 parent f4a0f57 commit 164580d
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,43 @@

#include "UniversalProxyDLL.h"

DWORD WINAPI NewThread(LPVOID lpParam)
{
std::ifstream chainloadFile;
chainloadFile.open("upd_chainload.txt");
if (chainloadFile.is_open())
{
std::string line;
while (getline(chainloadFile, line))
{
line.erase(line.find_last_not_of(' ') + 1);
line.erase(0, line.find_first_not_of(' '));
UPD::Log("Loading: ", line);
LoadLibraryA(line.c_str());
}
chainloadFile.close();
return 1;
}
UPD::Log("upd_chainload.txt not found.");
return 0;
}

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls(hinstDLL);
try
{
UPD::OpenDebugTerminal();
{
UPD::MuteLogging();
UPD::CreateProxy(hinstDLL);
CreateThread(0, 0, &NewThread, NULL, 0, NULL);
}
catch (std::runtime_error e)
{
std::cout << e.what() << std::endl;
return FALSE;
}
}
return TRUE;
}
return TRUE;
}

0 comments on commit 164580d

Please sign in to comment.