Last active
September 14, 2023 20:30
-
-
Save 4el0ve4ik/3e742d0f85db3353b82da26698de9ed9 to your computer and use it in GitHub Desktop.
radarrect.ASI source
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Windows.h> | |
#include <cmath> | |
float flt = 0.000001f; | |
void InjectJmp(unsigned long _offset, void* target){ | |
void *pBlock = VirtualAlloc(0, 0x1000, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); | |
unsigned long Protection; | |
VirtualProtect((void*)_offset, 5, PAGE_EXECUTE_READWRITE, &Protection); | |
unsigned long offs = (unsigned long)pBlock - (_offset + 5); | |
*reinterpret_cast<unsigned char*>(_offset) = 0xE9; | |
memcpy((LPVOID)(_offset + 1), &offs, 4); | |
VirtualProtect((void*)_offset, 5, Protection, 0); | |
memcpy(pBlock, "\xE9", 1); | |
offs = (DWORD)target - ((DWORD)pBlock + 5); | |
memcpy((void*)((unsigned long)pBlock + 1), &offs, sizeof(void*)); | |
memcpy((void*)((unsigned long)pBlock + 5), "\xE9", 1); | |
unsigned long retAddr = ((DWORD)pBlock + 5 + 5) - 0x58334D; | |
memcpy((void*)((unsigned long)pBlock + 6), &retAddr, sizeof(retAddr)); | |
} | |
struct vec { float x, y; }; | |
float __cdecl LimitRadarPoint(vec *point) { | |
if (*reinterpret_cast<unsigned char*>(0xBA67A1)) { | |
return (float)sqrt(point->y * point->y + point->x * point->x); | |
} | |
float sr = sqrt(point->y * point->y + point->x * point->x); | |
float x; | |
if (sr > 1.0) | |
{ | |
if (point->x > -1.0 && point->x < 1.0 && point->y > -1.0 && point->y < 1.0) | |
return 0.99f; | |
float y = atan2(point->y, point->x); | |
float angle = y * 57.295779513f; | |
if (angle > 45.0 || angle <= -45.0) | |
{ | |
if (angle > 45.0 && angle <= 135.0) | |
{ | |
point->x = cos(angle / 57.295779513f) * 1.4142135623f; | |
point->y = 1.0; | |
return sr; | |
} | |
if (angle <= 135.0 && angle > -135.0) | |
{ | |
point->x = cos(angle / 57.295779513f) * 1.4142135623f; | |
point->y = -1.0; | |
return sr; | |
} | |
x = -1.0; | |
} | |
else | |
{ | |
x = 1.0; | |
} | |
point->x = x; | |
point->y = sin(angle / 57.295779513f) * 1.4142135623f; | |
} | |
return sr; | |
} | |
template<typename T> | |
void WriteMemory(void* addr, T value) { | |
DWORD oldProt = 0; | |
VirtualProtect(addr, sizeof(T), PAGE_EXECUTE_READWRITE, &oldProt); | |
*reinterpret_cast<T*>(addr) = value; | |
VirtualProtect(addr, sizeof(T), oldProt, NULL); | |
} | |
BOOL WINAPI DllMain(HINSTANCE, DWORD fdwReason, LPVOID) { | |
if (fdwReason == 1) { | |
//hook LimitRadarPoint | |
InjectJmp(0x5832F0, &LimitRadarPoint); | |
// box radar | |
WriteMemory<void*>(reinterpret_cast<void*>(0x58585C), &flt); | |
// disable radar border | |
WriteMemory<unsigned char>(reinterpret_cast<void*>(0x58A8D9),0); | |
WriteMemory<unsigned char>(reinterpret_cast<void*>(0x58A789), 0); | |
WriteMemory<unsigned char>(reinterpret_cast<void*>(0x58A88F), 0); | |
WriteMemory<unsigned char>(reinterpret_cast<void*>(0x58A98F), 0); | |
} | |
return TRUE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment