#include <Windows.h>
#include <process.h>
#include <stdint.h>
enum SA_Mem
{
settingsFPSLimit = 0xBA6794,
FPSLimit = 0x9D9D0
};
void WriteMemory(void* address, void* bytes, int byteSize)
{
DWORD NewProtection;
VirtualProtect(address, byteSize, PAGE_EXECUTE_READWRITE, &NewProtection);
memcpy(address, bytes, byteSize);
VirtualProtect(address, byteSize, NewProtection, &NewProtection);
}
void __cdecl MainThread(void* pArg)
{
DWORD dwSamp = DWORD(GetModuleHandleA("samp.dll"));
uint8_t* old = 0;
unsigned char settingsFPSLimitStatus = 0, oldSettingsFPSLimitStatus = 120;
if (dwSamp)
{
old = reinterpret_cast<uint8_t*>(dwSamp + SA_Mem::FPSLimit);
while (true)
{
Sleep(500);
settingsFPSLimitStatus = *reinterpret_cast<unsigned char*>(SA_Mem::settingsFPSLimit);
if (settingsFPSLimitStatus != oldSettingsFPSLimitStatus)
{
if(settingsFPSLimitStatus == 1)
WriteMemory((void*)(dwSamp + SA_Mem::FPSLimit), old, 4);
else
WriteMemory((void*)(dwSamp + SA_Mem::FPSLimit), (uint8_t*)"0x5051FF15", 4);
oldSettingsFPSLimitStatus = settingsFPSLimitStatus;
}
}
}
}
BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ PVOID lpvReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH) _beginthread(MainThread, NULL, nullptr);
return TRUE;
}