Fix reinjection after unloading (#472) (#473)

This commit is contained in:
Forever Gone 2022-10-16 16:06:17 -04:00 committed by GitHub
parent 915b2e7b7f
commit 85a45ae6c9
3 changed files with 21 additions and 2 deletions

View File

@ -106,6 +106,24 @@ namespace memory
return true; return true;
} }
handle range::bruteforce_scan(pattern const& sig)
{
auto data = sig.m_bytes.data();
auto length = sig.m_bytes.size();
const auto scan_end = m_size - length;
for (std::uintptr_t i{}; i != scan_end; ++i)
{
if (pattern_matches(m_base.add(i).as<std::uint8_t*>(), data, length))
{
return m_base.add(i);
}
}
return nullptr;
}
std::vector<handle> range::scan_all(pattern const &sig) std::vector<handle> range::scan_all(pattern const &sig)
{ {
std::vector<handle> result{}; std::vector<handle> result{};

View File

@ -17,6 +17,7 @@ namespace memory
bool contains(handle h); bool contains(handle h);
handle scan(pattern const& sig); handle scan(pattern const& sig);
handle bruteforce_scan(pattern const& sig);
std::vector<handle> scan_all(pattern const& sig); std::vector<handle> scan_all(pattern const& sig);
protected: protected:
handle m_base; handle m_base;

View File

@ -345,13 +345,13 @@ namespace big
* Freemode thread restorer through VM patch * Freemode thread restorer through VM patch
*/ */
if (auto pat1 = mem_region.scan("3b 0a 0f 83 ? ? ? ? 48 ff c7")) if (auto pat1 = mem_region.bruteforce_scan("3b 0a 0f 83 ? ? ? ? 48 ff c7"))
{ {
*pat1.add(2).as<uint32_t*>() = 0xc9310272; *pat1.add(2).as<uint32_t*>() = 0xc9310272;
*pat1.add(6).as<uint16_t*>() = 0x9090; *pat1.add(6).as<uint16_t*>() = 0x9090;
} }
if (auto pat2 = mem_region.scan("3b 0a 0f 83 ? ? ? ? 49 03 fa")) if (auto pat2 = mem_region.bruteforce_scan("3b 0a 0f 83 ? ? ? ? 49 03 fa"))
{ {
*pat2.add(2).as<uint32_t*>() = 0xc9310272; *pat2.add(2).as<uint32_t*>() = 0xc9310272;
*pat2.add(6).as<uint16_t*>() = 0x9090; *pat2.add(6).as<uint16_t*>() = 0x9090;