mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Add logic for preventing recursive SDK initialization
This allows for loading the game with the client.dll without loading the main worker/sdk dll. gamesdk.dll is imported by the game executable, so we cannot circumvent its loading without some hacks, so instead, we just check if -noworkerdll is passed and not perform any init if its present.
This commit is contained in:
parent
1e23ddbf35
commit
bc3b580525
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
void SDK_Init()
|
void SDK_Init()
|
||||||
{
|
{
|
||||||
CheckCPU(); // Check CPU as early as possible, SpdLog also uses SIMD intrinsics.
|
CheckCPU(); // Check CPU as early as possible, SpdLog also uses SSE intrinsics.
|
||||||
|
|
||||||
MathLib_Init(); // Initialize Mathlib.
|
MathLib_Init(); // Initialize Mathlib.
|
||||||
WinSock_Init(); // Initialize Winsock.
|
WinSock_Init(); // Initialize Winsock.
|
||||||
@ -90,17 +90,31 @@ void SDK_Shutdown()
|
|||||||
|
|
||||||
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
|
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
|
||||||
{
|
{
|
||||||
|
#if !defined (DEDICATED) && !defined (CLIENT_DLL)
|
||||||
|
// This dll is imported by the game executable, we cannot circumvent it.
|
||||||
|
// To solve the recursive init problem, we check if -noworkerdll is passed.
|
||||||
|
// If this is passed, the worker dll will not be initialized, which allows
|
||||||
|
// us to load the client dll (or any other dll) instead, or load the game
|
||||||
|
// without the SDK.
|
||||||
|
s_bNoWorkerDll = !!strstr(GetCommandLineA(), "-noworkerdll");
|
||||||
|
#endif // !DEDICATED && CLIENT_DLL
|
||||||
switch (dwReason)
|
switch (dwReason)
|
||||||
{
|
{
|
||||||
case DLL_PROCESS_ATTACH:
|
case DLL_PROCESS_ATTACH:
|
||||||
{
|
{
|
||||||
SDK_Init();
|
if (!s_bNoWorkerDll)
|
||||||
|
{
|
||||||
|
SDK_Init();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case DLL_PROCESS_DETACH:
|
case DLL_PROCESS_DETACH:
|
||||||
{
|
{
|
||||||
SDK_Shutdown();
|
if (!s_bNoWorkerDll)
|
||||||
|
{
|
||||||
|
SDK_Shutdown();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ __declspec(dllexport) void DummyExport()
|
|||||||
// Required for detours.
|
// Required for detours.
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string R5R_EMBLEM[] =
|
const static std::string R5R_EMBLEM[] =
|
||||||
{
|
{
|
||||||
R"(+-------------------------------------------------------------+)",
|
R"(+-------------------------------------------------------------+)",
|
||||||
R"(| ___ ___ ___ _ _ _ ___ ___ |)",
|
R"(| ___ ___ ___ _ _ _ ___ ___ |)",
|
||||||
@ -19,3 +19,5 @@ const std::string R5R_EMBLEM[] =
|
|||||||
R"(| |)",
|
R"(| |)",
|
||||||
R"(+-------------------------------------------------------------+)"
|
R"(+-------------------------------------------------------------+)"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool s_bNoWorkerDll = false;
|
@ -949,6 +949,9 @@ eLaunchMode CUIBaseSurface::BuildParameter(string& svParameters)
|
|||||||
}
|
}
|
||||||
case eMode::CLIENT:
|
case eMode::CLIENT:
|
||||||
{
|
{
|
||||||
|
svParameters.append("-noworkerdll\n"); // This prevents init of worker dll
|
||||||
|
//(this dll is always imported, but we want client.dll to do the work instead).
|
||||||
|
|
||||||
// GAME ###############################################################
|
// GAME ###############################################################
|
||||||
if (this->m_DeveloperToggle->Checked())
|
if (this->m_DeveloperToggle->Checked())
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user