Skip to content

Instantly share code, notes, and snippets.

@ThirteenAG
Created October 8, 2021 13:03
Show Gist options
  • Save ThirteenAG/868a964b46b82ce5cebbd4a0823c69e4 to your computer and use it in GitHub Desktop.
Save ThirteenAG/868a964b46b82ce5cebbd4a0823c69e4 to your computer and use it in GitHub Desktop.
[GTA SA UWP] Radio For All Vehicles Plugin
#include "stdafx.h"
static inline DWORD WINAPI ThreadProc(LPVOID ptr)
{
HANDLE hTimer = NULL;
LARGE_INTEGER liDueTime;
liDueTime.QuadPart = -30 * 10000000LL;
hTimer = CreateWaitableTimer(NULL, TRUE, NULL);
SetWaitableTimer(hTimer, &liDueTime, 0, NULL, NULL, 0);
while (GetModuleHandle(L"GTASASCWin8Component") == NULL)
{
Sleep(0);
if (WaitForSingleObject(hTimer, 0) == WAIT_OBJECT_0)
{
CloseHandle(hTimer);
return 0;
}
};
auto m = (uint32_t)GetModuleHandle(L"GTASASCWin8Component");
auto pattern = hook::range_pattern(m, m + 0xB3DFF0, "00 00 63 00 62 00 00 00 14 AE 47 3F 00 00 80 3F");
while (pattern.clear().empty())
{
Sleep(0);
if (WaitForSingleObject(hTimer, 0) == WAIT_OBJECT_0)
{
CloseHandle(hTimer);
return 0;
}
};
auto offset = (uint32_t)pattern.count(2).get(0).get<void*>(0);
static constexpr auto LANDSTAL = 400;
static constexpr auto UTILTR1 = 611;
for (size_t i = LANDSTAL; i <= UTILTR1; i++)
{
injector::WriteMemory<uint8_t>(((offset - 0x3840 + 0x1B) + (i * 36)), 0, true);
}
return 0;
}
CEXP void InitializeASI()
{
std::call_once(CallbackHandler::flag, []()
{
CreateThreadAutoClose(0, 0, (LPTHREAD_START_ROUTINE)&ThreadProc, 0, 0, NULL);
});
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpReserved)
{
if (reason == DLL_PROCESS_ATTACH)
{
if (!IsUALPresent()) { InitializeASI(); }
}
return TRUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment