Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //blip is already defined in types.h
- //redefine that blip to blip2
- extern MODULEINFO g_MainModuleInfo;//goes in header
- MODULEINFO g_MainModuleInfo = { 0 };//goes in main.cpp
- if (!GetModuleInformation(GetCurrentProcess(), GetModuleHandle(0), &g_MainModuleInfo, sizeof(g_MainModuleInfo))) {
- write_text_to_log_file("Unable to bypass model request block");
- }
- //goes in dll_process_attach in main
- DWORD64 g_dwThreadCollectionPtr = 0;
- BlipList* g_blipList;
- rage::pgPtrCollection<GtaThread>* GetGtaThreadCollection() {
- DWORD64 blipCollectionSignature = Pattern::Scan(g_MainModuleInfo, "4C 8D 05 ? ? ? ? 0F B7 C1");
- g_blipList = (BlipList*)(blipCollectionSignature + *(DWORD*)(blipCollectionSignature + 3) + 7);
- return (rage::pgPtrCollection<GtaThread>*) g_dwThreadCollectionPtr;
- }
- GtaThread_VTable gGtaThreadOriginal;
- GtaThread_VTable gGtaThreadNew;
- bool ThreadCollection() {
- rage::pgPtrCollection<GtaThread>* threadCollection = GetGtaThreadCollection();
- if (!threadCollection) {
- return false;
- }
- for (UINT16 i = 0; i < threadCollection->count(); i++) {
- GtaThread* pThread = threadCollection->at(i);
- if (!pThread)
- continue;
- //s0biet originally had some junk thread that was called for like 2 seconds then died. This thread is better.
- if (pThread->GetContext()->ScriptHash != 0x5700179C) {
- continue;
- }
- // Now what? We need to find a target thread and hook it's "Tick" function
- if (gGtaThreadOriginal.Deconstructor == NULL) {
- memcpy(&gGtaThreadOriginal, (DWORD64*)((DWORD64*)pThread)[0], sizeof(gGtaThreadOriginal)); //Create a backup of the original table so we can call the original functions from our hook.
- memcpy(&gGtaThreadNew, &gGtaThreadOriginal, sizeof(GtaThread_VTable)); //Construct our VMT replacement table.
- }
- if (((DWORD64*)pThread)[0] != (DWORD64)&gGtaThreadNew) { //If the table is not VMT Hooked.
- write_text_to_log_file("Hooking thread: " + pThread->GetContext()->ThreadId);
- write_text_to_log_file("Hash: " + pThread->GetContext()->ScriptHash);
- ((DWORD64*)pThread)[0] = (DWORD64)&gGtaThreadNew; //Replace the VMT pointer with a pointer to our new VMT.
- write_text_to_log_file("Hooked thread: " + pThread->GetContext()->ThreadId);
- write_text_to_log_file("Hash: " + pThread->GetContext()->ScriptHash);
- return true;
- }
- }
- return false;
- }
- //Below code goes into the case label
- ThreadCollection();
- for (int i = 0; i <= 1000; i++)
- {
- Blip* blip = g_blipList->m_Blips[i].m_pBlip;
- if (blip)
- {
- if ((blip->dwColor == BLIPCOLOR_MISSION && blip->iIcon == BLIP_CIRCLE) ||
- (blip->dwColor == BLIPCOLOR_YELLOWMISSION && blip->iIcon == BLIP_CIRCLE) ||
- (blip->dwColor == BLIPCOLOR_NONE && blip->iIcon == BLIP_RACEFLAG) ||
- (blip->dwColor == BLIPCOLOR_GREEN && blip->iIcon == BLIP_CIRCLE) ||
- (blip->iIcon == BLIP_SPECIALCRATE))
- {
- Entity e = PLAYER::PLAYER_PED_ID();
- if (PED::IS_PED_IN_ANY_VEHICLE(e, 0))
- e = PED::GET_VEHICLE_PED_IS_USING(e);
- NETWORK::NETWORK_REQUEST_CONTROL_OF_ENTITY(e);
- ENTITY::SET_ENTITY_COORDS_NO_OFFSET(e, blip->x, blip->y, blip->z, FALSE, FALSE, TRUE);
- break; //During a race there's sometimes 2 yellow markers. We want the first one.
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement