[*] this is going to be a problem

This commit is contained in:
Reece Wilson 2023-10-12 18:58:11 +01:00
parent 23ddcf9ba1
commit f5f79bb184

View File

@ -145,6 +145,24 @@ namespace Aurora::Process
return dllSuffixString;
}
static AuString GetModuleNameFromFileName(const AuString &filename)
{
static const auto &kStringSuffixA = ConstructAuDllSuffix();
static const auto kStringSuffixB = GetPlatformExt(Build::kCurrentPlatform);
if (filename.ends_with(kStringSuffixA))
{
return filename.substr(0, filename.size() - kStringSuffixA.size());
}
if (filename.ends_with(kStringSuffixB))
{
return filename.substr(0, filename.size() - strlen(kStringSuffixB));
}
return filename;
}
#if defined(AURORA_PLATFORM_WIN32)
bool VerifyEmbeddedSignature(const wchar_t *path, HANDLE handle)
{
@ -276,6 +294,12 @@ namespace Aurora::Process
static void *LoadModule(const AuString &name, const AuString &path)
{
auto itr = gModuleHandles.find(path);
if (itr != gModuleHandles.end())
{
return itr->second;
}
#if defined(AURORA_IS_MODERNNT_DERIVED)
if (!pLoadLibraryW)
{
@ -299,6 +323,7 @@ namespace Aurora::Process
auto pRet = (void *)handle;
gModuleHandles.insert(AuMakePair(name, pRet));
gModuleHandles.insert(AuMakePair(path, pRet));
return pRet;
}
@ -706,16 +731,27 @@ namespace Aurora::Process
{
auto &sharedDLL = *itr;
AuLogDbg("[attempt] Loading shared object: {}", sharedDLL);
AuString a = dir + "/" + sharedDLL;
#if defined(AURORA_IS_MODERNNT_DERIVED)
AuString aAbs = dir + "/" + sharedDLL + ".";
#endif
#if defined(AURORA_IS_MODERNNT_DERIVED)
if (GetProcHandle(aAbs))
#else
if (GetProcHandle(a))
#endif
{
itr++;
continue;
}
auto modName = GetModuleNameFromFileName(sharedDLL);
AuLogDbg("[attempt] Loading shared object: {} (path: {})", modName, sharedDLL);
bool fail {};
ModuleLoadRequest request { AuList<AuString>{ dir }, sharedDLL };
ModuleLoadRequest request { AuList<AuString>{ dir }, modName };
if (TryLoadModule(a,
#if defined(AURORA_IS_MODERNNT_DERIVED)
@ -727,7 +763,7 @@ namespace Aurora::Process
{
if (!fail)
{
AuLogDbg("[attempt] Loaded shared object: {}!", sharedDLL);
AuLogDbg("[attempt] Loaded shared object: {} (path: {})", modName, sharedDLL);
uSuccess++;
itr = sharedObjects.erase(itr);
}