diff options
author | Davide Beatrici <git@davidebeatrici.dev> | 2020-11-06 23:37:06 +0300 |
---|---|---|
committer | Davide Beatrici <git@davidebeatrici.dev> | 2020-11-06 23:37:06 +0300 |
commit | 988b8417acfc4ca4b19283afe7e1973d05a39be8 (patch) | |
tree | 160e79e9d7dc57ac27e02279775ea29418a537ae /plugins/se | |
parent | a3480a2a6b432b247821add175f725714692ef1e (diff) |
REFAC(positional-audio): Proper functions/classes for module-related operations
Previously, only module() was present: it retrieved the base address of the specified module.
It worked fine, but it iterated through the process' modules every time it was called.
This commit replaces it with modules(), which returns an std::unordered_map containing all modules.
The map uses the module name as key and Module as value.
Aside from the performance improvement, the new code also provides info for each module region:
- Start address.
- Size.
- Whether it's readable, writable and/or executable.
Diffstat (limited to 'plugins/se')
-rw-r--r-- | plugins/se/CMakeLists.txt | 1 | ||||
-rw-r--r-- | plugins/se/se.cpp | 16 |
2 files changed, 15 insertions, 2 deletions
diff --git a/plugins/se/CMakeLists.txt b/plugins/se/CMakeLists.txt index aaf63ac7d..e6f56857e 100644 --- a/plugins/se/CMakeLists.txt +++ b/plugins/se/CMakeLists.txt @@ -6,6 +6,7 @@ add_library(se SHARED "se.cpp" + "../Module.cpp" "../Process.cpp" "../ProcessWindows.cpp" ) diff --git a/plugins/se/se.cpp b/plugins/se/se.cpp index 4560046e5..dd256afbc 100644 --- a/plugins/se/se.cpp +++ b/plugins/se/se.cpp @@ -215,12 +215,24 @@ static int tryLock(const std::multimap< std::wstring, unsigned long long int > & return false; } - const auto engine = proc->module(isWin32 ? "engine.dll" : "engine.so"); + const auto modules = proc->modules(); + + auto iter = modules.find(isWin32 ? "engine.dll" : "engine.so"); + if (iter == modules.cend()) { + return false; + } + + const auto engine = iter->second.baseAddress(); if (!engine) { return false; } - const auto client = proc->module(isWin32 ? "client.dll" : "client.so"); + iter = modules.find(isWin32 ? "client.dll" : "client.so"); + if (iter == modules.cend()) { + return false; + } + + const auto client = iter->second.baseAddress(); if (!client) { return false; } |