Migrate to KHook

This commit is contained in:
Vauff 2026-09-08 17:02:27 -04:00
parent 6148f39ad3
commit b418365b5b
2 changed files with 5 additions and 5 deletions

2
AMBuildScript generated
View file

@ -278,7 +278,7 @@ class MMSPluginConfig(object):
cxx.cxxincludes += [ cxx.cxxincludes += [
os.path.join(context.currentSourcePath), os.path.join(context.currentSourcePath),
os.path.join(mms_core_path), os.path.join(mms_core_path),
os.path.join(mms_core_path, 'sourcehook'), os.path.join(self.mms_root, 'third_party', 'khook', 'include'),
] ]
defines = [] defines = []

View file

@ -19,7 +19,7 @@
#include <stdio.h> #include <stdio.h>
#include "MovementUnlocker.h" #include "MovementUnlocker.h"
#include <sh_memory.h> #include "khook/memory.hpp"
#ifdef _WIN32 #ifdef _WIN32
#include <Windows.h> #include <Windows.h>
#elif __linux__ #elif __linux__
@ -110,7 +110,7 @@ bool MovementUnlocker::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxl
return false; return false;
} }
SourceHook::SetMemAccess((void*)pPatchAddress, PatchLen, SH_MEM_READ | SH_MEM_WRITE | SH_MEM_EXEC); KHook::Memory::SetAccess((void*)pPatchAddress, PatchLen, KHook::Memory::READ | KHook::Memory::WRITE | KHook::Memory::EXECUTE);
#ifdef _WIN32 #ifdef _WIN32
const char* patchBytes[] = {"\xE9", "\xB0", "\x00", "\x00", "\x00", "\x90"}; const char* patchBytes[] = {"\xE9", "\xB0", "\x00", "\x00", "\x00", "\x90"};
@ -122,7 +122,7 @@ bool MovementUnlocker::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxl
*(unsigned char*)(pPatchAddress + i) = ((unsigned char*)"\x90")[0]; *(unsigned char*)(pPatchAddress + i) = ((unsigned char*)"\x90")[0];
#endif #endif
SourceHook::SetMemAccess((void*)pPatchAddress, PatchLen, SH_MEM_READ | SH_MEM_EXEC); KHook::Memory::SetAccess((void*)pPatchAddress, PatchLen, KHook::Memory::READ | KHook::Memory::EXECUTE);
META_CONPRINTF( "[Movement Unlocker] Successfully patched Movement Unlocker!\n" ); META_CONPRINTF( "[Movement Unlocker] Successfully patched Movement Unlocker!\n" );
return true; return true;
@ -154,7 +154,7 @@ const char *MovementUnlocker::GetLicense()
const char *MovementUnlocker::GetVersion() const char *MovementUnlocker::GetVersion()
{ {
return "1.12"; return "2.0";
} }
const char *MovementUnlocker::GetDate() const char *MovementUnlocker::GetDate()