From 1eaca8dff8c7a4683f9479241d284d210fb7e413 Mon Sep 17 00:00:00 2001 From: Simon Garrelou Date: Mon, 3 Oct 2022 16:03:12 +0200 Subject: [PATCH] Allow passing DLL paths (fix #1) --- TTD/TTD.cpp | 9 +++++++-- TTD/TTD.hpp | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/TTD/TTD.cpp b/TTD/TTD.cpp index fbe5c72..634eeb0 100644 --- a/TTD/TTD.cpp +++ b/TTD/TTD.cpp @@ -100,7 +100,7 @@ namespace TTD { return this->cursor->ICursor->GetModuleList(cursor); } - ReplayEngine::ReplayEngine() { + ReplayEngine::ReplayEngine(const wchar_t* ttdReplayPath, const wchar_t* ttdReplayCpuPath) { HINSTANCE hinstLib; PROC_Initiate InitiateReplayEngineHandshake; PROC_Create CreateReplayEngineWithHandshake; @@ -109,7 +109,12 @@ namespace TTD { SHA256_CTX ctx; BYTE sha[32]; - hinstLib = LoadLibrary(TEXT("TTDReplay.dll")); + hinstLib = LoadLibraryW(ttdReplayCpuPath); + if (hinstLib == NULL) { + throw std::exception("Unable to find TTDReplayCPU.dll"); + } + + hinstLib = LoadLibraryW(ttdReplayPath); if (hinstLib == NULL) { throw std::exception("Unable to find TTDReplay.dll"); } diff --git a/TTD/TTD.hpp b/TTD/TTD.hpp index 82e29a7..c77365f 100644 --- a/TTD/TTD.hpp +++ b/TTD/TTD.hpp @@ -494,7 +494,7 @@ namespace TTD { TTD_Replay_ReplayEngine* engine; public: - ReplayEngine(); + ReplayEngine(const wchar_t* ttdReplayPath=L"TTDReplay.dll", const wchar_t* ttdReplayCpuPath=L"TTDReplayCPU.dll"); /**** Wrapping around the vftable ****/ bool Initialize(const wchar_t* trace_filename);