aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/hooks.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-05-09 02:46:04 +0100
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-05-09 02:46:04 +0100
commit9ab7c43c34183915273cc8b5ccedd72568249b27 (patch)
tree6662f6f8d5a64bb86ec725faf48fe4c8cbe3eb70 /NorthstarDedicatedTest/hooks.cpp
parent503d336e9e695a0518f90f727f4a2fe4569615e6 (diff)
downloadNorthstarLauncher-9ab7c43c34183915273cc8b5ccedd72568249b27.tar.gz
NorthstarLauncher-9ab7c43c34183915273cc8b5ccedd72568249b27.zip
fix debug crashes
Diffstat (limited to 'NorthstarDedicatedTest/hooks.cpp')
-rw-r--r--NorthstarDedicatedTest/hooks.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/NorthstarDedicatedTest/hooks.cpp b/NorthstarDedicatedTest/hooks.cpp
index c566ca8d..7e697701 100644
--- a/NorthstarDedicatedTest/hooks.cpp
+++ b/NorthstarDedicatedTest/hooks.cpp
@@ -149,18 +149,17 @@ struct DllLoadCallback
bool called;
};
-bool how = false;
-std::vector<DllLoadCallback> dllLoadCallbacks = std::vector<DllLoadCallback>();
+// for whatever reason, just declaring and initialising the vector at file scope crashes on debug builds
+// but this works, idk sucks but just how it is
+std::vector<DllLoadCallback>& GetDllLoadCallbacks()
+{
+ static std::vector<DllLoadCallback> vec = std::vector<DllLoadCallback>();
+ return vec;
+}
void AddDllLoadCallback(std::string dll, DllLoadCallbackFuncType callback, std::string tag, std::string reliesOn)
{
- if (!how) // WHY IS THIS A THING WE NEED ON DEBUG?????
- {
- dllLoadCallbacks = std::vector<DllLoadCallback>();
- how = true;
- }
-
- DllLoadCallback& callbackStruct = dllLoadCallbacks.emplace_back();
+ DllLoadCallback& callbackStruct = GetDllLoadCallbacks().emplace_back(); // <-- crashes here
callbackStruct.dll = dll;
callbackStruct.callback = callback;
@@ -194,7 +193,7 @@ void CallLoadLibraryACallbacks(LPCSTR lpLibFileName, HMODULE moduleAddress)
{
bool doneCalling = true;
- for (auto& callbackStruct : dllLoadCallbacks)
+ for (auto& callbackStruct : GetDllLoadCallbacks())
{
if (!callbackStruct.called && fs::path(lpLibFileName).filename() == fs::path(callbackStruct.dll).filename())
{
@@ -222,7 +221,7 @@ void CallLoadLibraryWCallbacks(LPCWSTR lpLibFileName, HMODULE moduleAddress)
{
bool doneCalling = true;
- for (auto& callbackStruct : dllLoadCallbacks)
+ for (auto& callbackStruct : GetDllLoadCallbacks())
{
if (!callbackStruct.called && fs::path(lpLibFileName).filename() == fs::path(callbackStruct.dll).filename())
{