Skip to content

Commit

Permalink
Do not dynamically allocate global 'memory' object
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkrupinski committed Jun 23, 2022
1 parent ee4c757 commit 5fc8df3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Source/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ Hooks::Hooks(HMODULE moduleHandle) noexcept : moduleHandle{ moduleHandle }

// interfaces and memory shouldn't be initialized in wndProc because they show MessageBox on error which would cause deadlock
interfaces = std::make_unique<const Interfaces>();
memory = std::make_unique<const Memory>();
memory.emplace(Memory{});

window = FindWindowW(L"Valve001", nullptr);
originalWndProc = WNDPROC(SetWindowLongPtrW(window, GWLP_WNDPROC, LONG_PTR(&wndProc)));
Expand Down
4 changes: 2 additions & 2 deletions Source/Memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <array>
#include <cstdint>
#include <memory>
#include <optional>
#include <type_traits>

#include "SDK/Platform.h"
Expand Down Expand Up @@ -171,4 +171,4 @@ class Memory {
std::uintptr_t setDynamicAttributeValueFn;
};

inline std::unique_ptr<const Memory> memory;
inline std::optional<const Memory> memory;

0 comments on commit 5fc8df3

Please sign in to comment.