Switch to AMBuild & WIP port to Counter-Strike 2

This commit is contained in:
Vauff 2023-10-02 16:57:02 -04:00 • committed by Alex
parent b03db8ad19
commit 100636cd10
13 changed files with 671 additions and 1520 deletions

View file

@ -1,19 +1,20 @@
#include <stdio.h>
#include "MovementUnlocker.h"
#include <cstdint>
#include <sh_memory.h>
#ifdef _WIN32
#include <Windows.h>
#elif __linux__
#include <dlfcn.h>
#endif
MovementUnlocker g_MovementUnlocker;
#ifdef _WIN32
const unsigned char *pPatchSignature = (unsigned char *)"\x76\x58\xF3\x0F\x10\x40\x44\xF3\x0F\x10\x50\x40";
const char *pPatchPattern = "x?xxxxxxxxxx";
const unsigned char *pPatchSignature = (unsigned char *)"\x76\x2A\xF2\x0F\x10\x57\x3C\xF3\x0F\x10\x47\x44\x0F\x28\xCA\xF3\x0F\x59\xC0";
const char *pPatchPattern = "x?xxxxxxxxxxxxxxxxx";
#elif __linux__
unsigned char * pPatchSignature = (unsigned char *)"\x76\x45\xF3\x0F\x11\x9D\x4C\xFF\xFF\xFF";
const char* pPatchPattern = "x?xxxxxxxx";
const unsigned char * pPatchSignature = (unsigned char *)"\x0F\x87\x2A\x2A\x2A\x2A\x49\x8B\x7C\x24\x30\xE8\x2A\x2A\x2A\x2A\x66\x0F\xEF\xED";
const char* pPatchPattern = "xx????xxxxxx????xxxx";
#endif
// From https://git.botox.bz/CSSZombieEscape/sm-ext-PhysHooks
@ -54,12 +55,13 @@ PLUGIN_EXPOSE(MovementUnlocker, g_MovementUnlocker);
bool MovementUnlocker::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
PLUGIN_SAVEVARS();
int PatchLen = strlen(pPatchPattern);
#ifdef _WIN32
char *pBinPath = "csgo/bin/server.dll";
char const *pBinPath = "csgo/bin/win64/server.dll";
auto *pBin = LoadLibrary(pBinPath);
#elif __linux__
char *pBinPath = "csgo/bin/server.so";
char const *pBinPath = "csgo/bin/linuxsteamrt64/libserver.so";
auto *pBin = dlopen(pBinPath, RTLD_NOW);
#endif
@ -83,9 +85,22 @@ bool MovementUnlocker::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxl
return false;
}
#ifdef _WIN32
SourceHook::SetMemAccess((void*)pPatchAddress, PatchLen, SH_MEM_READ | SH_MEM_WRITE | SH_MEM_EXEC);
*(unsigned char*)(pPatchAddress) = ((unsigned char*)"\xEB")[0];
SourceHook::SetMemAccess((void*)pPatchAddress, PatchLen, SH_MEM_READ | SH_MEM_EXEC);
#elif __linux__
for (int i = 0; i < 5; i++)
{
SourceHook::SetMemAccess((void*)pPatchAddress, PatchLen, SH_MEM_READ | SH_MEM_WRITE | SH_MEM_EXEC);
*(unsigned char*)(pPatchAddress) = ((unsigned char*)"\x90")[i];
SourceHook::SetMemAccess((void*)pPatchAddress, PatchLen, SH_MEM_READ | SH_MEM_EXEC);
pPatchAddress++;
}
#endif
META_CONPRINTF( "[Movement Unlocker] Successfully patched Movement Unlocker!\n" );
return true;
}
@ -136,7 +151,7 @@ const char *MovementUnlocker::GetAuthor()
const char *MovementUnlocker::GetDescription()
{
return "CS2 MM:S port of Movement Unlocker, removes max speed limitation from players on the ground.";
return "CS2 MM:S port of Movement Unlocker, removes max speed limitation from players on the ground";
}
const char *MovementUnlocker::GetName()