From 164580d090f7c0625b37fe71d7f52c819df7368a Mon Sep 17 00:00:00 2001 From: techiew Date: Tue, 29 Oct 2024 22:52:28 +0100 Subject: [PATCH] Chainload example --- dllmain.cpp | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/dllmain.cpp b/dllmain.cpp index c281202..08ac7dc 100644 --- a/dllmain.cpp +++ b/dllmain.cpp @@ -3,15 +3,37 @@ #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) { @@ -19,5 +41,5 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) return FALSE; } } - return TRUE; -} + return TRUE; +} \ No newline at end of file