mirror of
https://github.com/R2Northstar/NorthstarLauncher
synced 2024-09-29 09:19:41 +02:00
Clean up
This commit is contained in:
parent
ae2f240d4f
commit
07fbef7382
@ -20,7 +20,7 @@ ConVar* RegisterConVar(const char* name, const char* defaultValue, int flags, co
|
||||
ConVar* newVar = new ConVar;
|
||||
conVarConstructor(newVar, name, defaultValue, flags, helpString);
|
||||
|
||||
g_CustomConvars.insert(std::make_pair(name, newVar));
|
||||
g_CustomConvars.emplace(name, newVar);
|
||||
|
||||
return newVar;
|
||||
}
|
||||
|
@ -45,12 +45,12 @@ void InstallInitialHooks()
|
||||
ENABLER_CREATEHOOK(hook, &LoadLibraryW, &LoadLibraryWHook, reinterpret_cast<LPVOID*>(&LoadLibraryWOriginal));
|
||||
}
|
||||
|
||||
char* cmdlineResult;
|
||||
LPSTR GetCommandLineAHook()
|
||||
{
|
||||
static char* cmdlineModified;
|
||||
static char* cmdlineOrg;
|
||||
|
||||
if (cmdlineOrg == nullptr || cmdlineResult == nullptr)
|
||||
if (cmdlineOrg == nullptr || cmdlineModified == nullptr)
|
||||
{
|
||||
cmdlineOrg = GetCommandLineAOriginal();
|
||||
bool isDedi = strstr(cmdlineOrg, "-dedicated"); // well, this one has to be a real argument
|
||||
@ -77,18 +77,18 @@ LPSTR GetCommandLineAHook()
|
||||
}
|
||||
|
||||
auto len = args.length();
|
||||
cmdlineResult = reinterpret_cast<char*>(_malloc_base(len + 1));
|
||||
if (!cmdlineResult)
|
||||
cmdlineModified = new char[len + 1];
|
||||
if (!cmdlineModified)
|
||||
{
|
||||
spdlog::error("malloc failed for command line");
|
||||
return cmdlineOrg;
|
||||
}
|
||||
memcpy(cmdlineResult, args.c_str(), len + 1);
|
||||
memcpy(cmdlineModified, args.c_str(), len + 1);
|
||||
|
||||
spdlog::info("Command line: {}", cmdlineResult);
|
||||
spdlog::info("Command line: {}", cmdlineModified);
|
||||
}
|
||||
|
||||
return cmdlineResult;
|
||||
return cmdlineModified;
|
||||
}
|
||||
|
||||
// dll load callback stuff
|
||||
@ -116,7 +116,7 @@ void CallLoadLibraryACallbacks(LPCSTR lpLibFileName, HMODULE moduleAddress)
|
||||
{
|
||||
for (auto& callbackStruct : dllLoadCallbacks)
|
||||
{
|
||||
if (!callbackStruct->called && strstr(lpLibFileName + (strlen(lpLibFileName) - strlen(callbackStruct->dll.c_str())), callbackStruct->dll.c_str()) != nullptr)
|
||||
if (!callbackStruct->called && strstr(lpLibFileName + (strlen(lpLibFileName) - callbackStruct->dll.length()), callbackStruct->dll.c_str()) != nullptr)
|
||||
{
|
||||
callbackStruct->callback(moduleAddress);
|
||||
callbackStruct->called = true;
|
||||
@ -130,7 +130,7 @@ void CallLoadLibraryWCallbacks(LPCWSTR lpLibFileName, HMODULE moduleAddress)
|
||||
{
|
||||
std::wstring wcharStrDll = std::wstring(callbackStruct->dll.begin(), callbackStruct->dll.end());
|
||||
const wchar_t* callbackDll = wcharStrDll.c_str();
|
||||
if (!callbackStruct->called && wcsstr(lpLibFileName + (wcslen(lpLibFileName) - wcslen(callbackDll)), callbackDll) != nullptr)
|
||||
if (!callbackStruct->called && wcsstr(lpLibFileName + (wcslen(lpLibFileName) - wcharStrDll.length()), callbackDll) != nullptr)
|
||||
{
|
||||
callbackStruct->callback(moduleAddress);
|
||||
callbackStruct->called = true;
|
||||
|
@ -38,7 +38,7 @@ void HookEnabler::CreateHook(LPVOID ppTarget, LPVOID ppDetour, LPVOID* ppOrigina
|
||||
else
|
||||
{
|
||||
if (targetName != nullptr)
|
||||
spdlog::error("MH_CreateHook failed for function %s", targetName);
|
||||
spdlog::error("MH_CreateHook failed for function {}", targetName);
|
||||
else
|
||||
spdlog::error("MH_CreateHook failed for unknown function");
|
||||
}
|
||||
@ -51,7 +51,7 @@ HookEnabler::~HookEnabler()
|
||||
if (MH_EnableHook(hook->targetAddress) != MH_OK)
|
||||
{
|
||||
if (hook->targetName != nullptr)
|
||||
spdlog::error("MH_EnableHook failed for function %s", hook->targetName);
|
||||
spdlog::error("MH_EnableHook failed for function {}", hook->targetName);
|
||||
else
|
||||
spdlog::error("MH_EnableHook failed for unknown function");
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ void ModManager::LoadMods()
|
||||
if (fs::is_regular_file(file))
|
||||
{
|
||||
std::string kvStr = file.path().lexically_relative(mod.ModDirectory / "keyvalues").lexically_normal().string();
|
||||
mod.KeyValues.insert(std::make_pair(std::hash<std::string>{}(kvStr), kvStr));
|
||||
mod.KeyValues.emplace(std::hash<std::string>{}(kvStr), kvStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user