From 4f275184d360ba258d220c0ef711e91f26de0d0a Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Sat, 28 Oct 2023 21:13:19 +0100 Subject: [PATCH] [+] Win32Config::bProcessCheckWinLdrForModNameFirst --- Include/Aurora/Runtime.hpp | 6 ++++++ Source/Process/AuProcess.cpp | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/Include/Aurora/Runtime.hpp b/Include/Aurora/Runtime.hpp index 46c003ef..a65ac2cc 100644 --- a/Include/Aurora/Runtime.hpp +++ b/Include/Aurora/Runtime.hpp @@ -427,6 +427,11 @@ namespace Aurora AuUInt32 uProtocolStackDefaultBufferSize { 64 * 1024 }; }; + struct Win32Config + { + bool bProcessCheckWinLdrForModNameFirst { true }; + }; + struct RuntimeStartInfo { ConsoleConfig console; @@ -437,6 +442,7 @@ namespace Aurora AuAlignTo<64, DebugConfig> debug; AuAlignTo<32, ThreadingConfig> threadingConfig; AuAlignTo<32, LinuxConfig> linuxConfig; + AuAlignTo<32, Win32Config> win32Config; AuAlignTo<32, ProcessConfig> processConfig; AuAlignTo<32, IOConfig> ioConfig; AuAlignTo<32, DummyConfig> padding; diff --git a/Source/Process/AuProcess.cpp b/Source/Process/AuProcess.cpp index 21b47c6c..0c14e781 100644 --- a/Source/Process/AuProcess.cpp +++ b/Source/Process/AuProcess.cpp @@ -410,6 +410,26 @@ namespace Aurora::Process AuString b = path + AuString({ AuFS::kPathSplitter }) + genericDll; #if defined(AURORA_IS_MODERNNT_DERIVED) + #if defined(AURORA_PLATFORM_WIN32) + if (gRuntimeConfig.win32Config.bProcessCheckWinLdrForModNameFirst) + { + auto aW = AuLocale::ConvertFromUTF8(genericDll); + auto bW = AuLocale::ConvertFromUTF8(auDll); + + auto pDLL = ::GetModuleHandleW(aW.c_str()); + if (!pDLL) + { + pDLL = ::GetModuleHandleW(bW.c_str()); + } + + if (pDLL) + { + gModuleHandles.insert(AuMakePair(request.mod, (void *)pDLL)); + return pDLL; + } + } + #endif + AuString aAbs = path + AuString({ AuFS::kPathSplitter }) + auDll + "."; AuString bAbs = path + AuString({ AuFS::kPathSplitter }) + genericDll + "."; #endif