Rewritten Core dll loading
This commit is contained in:
@@ -20,6 +20,7 @@ typedef float (*GetFloatFn)();
|
|||||||
typedef bool (*GetBoolFn)();
|
typedef bool (*GetBoolFn)();
|
||||||
|
|
||||||
static HMODULE fixLib = nullptr;
|
static HMODULE fixLib = nullptr;
|
||||||
|
static LONG g_coreInitialized = 0;
|
||||||
static SetBoolFn SetFixEnabled = nullptr;
|
static SetBoolFn SetFixEnabled = nullptr;
|
||||||
static SetBoolFn SetFOVFixEnabled = nullptr;
|
static SetBoolFn SetFOVFixEnabled = nullptr;
|
||||||
static SetBoolFn SetAspectRatioFixEnabled = nullptr;
|
static SetBoolFn SetAspectRatioFixEnabled = nullptr;
|
||||||
@@ -72,33 +73,11 @@ const char* DONATION_URL = "https://buymeacoffee.com/k4sh44";
|
|||||||
// Scaling factor based on screen resolution
|
// Scaling factor based on screen resolution
|
||||||
float scale = 1.f;
|
float scale = 1.f;
|
||||||
|
|
||||||
bool IsAlreadyInitialized()
|
|
||||||
{
|
|
||||||
// Declare a lock
|
|
||||||
HANDLE hMap = OpenFileMappingA(FILE_MAP_ALL_ACCESS, FALSE, "Local\\HellisUsFixSharedSection");
|
|
||||||
|
|
||||||
// If lock is not yet initialized
|
|
||||||
if (hMap == nullptr)
|
|
||||||
{
|
|
||||||
// We create the lock only once
|
|
||||||
hMap = CreateFileMappingA(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, 1, "Local\\HellisUsFixSharedSection");
|
|
||||||
|
|
||||||
if (hMap == nullptr) // We ensure the lock is valid
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false; // First time created we return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise we return true
|
|
||||||
CloseHandle(hMap);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load and unload game core dll functions /!\ necessary
|
// Load and unload game core dll functions /!\ necessary
|
||||||
static void LoadFixDLL()
|
static void LoadFixDLL()
|
||||||
{
|
{
|
||||||
if (IsAlreadyInitialized())
|
if (InterlockedCompareExchange(&g_coreInitialized, 1, 0) != 0)
|
||||||
return; // déjà lancé dans un autre chargement
|
return;
|
||||||
|
|
||||||
if (GetModuleHandleA("HellIsUsCore.dll") == nullptr) {
|
if (GetModuleHandleA("HellIsUsCore.dll") == nullptr) {
|
||||||
fixLib = LoadLibraryA("HellIsUsCore.dll");
|
fixLib = LoadLibraryA("HellIsUsCore.dll");
|
||||||
|
|||||||
Reference in New Issue
Block a user