Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // dllmain.cpp : Definiert den Einstiegspunkt fr die DLL-Anwendung.
- #include "stdafx.h"
- #include "arma.h"
- #include <stdio.h>
- #include <Subauth.h>
- #include <time.h> /* time */
- #include "detours.h"
- #pragma comment (lib, "detours.lib")
- #include <iostream>
- #include <string>
- #include <cstdio>
- HRESULT __stdcall EndScene(LPDIRECT3DDEVICE9 pDevice);
- typedef HRESULT(__stdcall* EndScene_t)(LPDIRECT3DDEVICE9);
- typedef HRESULT (WINAPI* oEndScene) (LPDIRECT3DDEVICE9 pDev);
- typedef int (WINAPI *Present_t)(LPDIRECT3DDEVICE9 pDevice, const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride, const RGNDATA *pDirtyRegion);
- Present_t oPresent;
- EndScene_t pEndScene;
- LPD3DXFONT m_pFont;
- ID3DXLine* m_rectLine;
- DWORD dwModBase;
- char hurennigger[5012];
- D3DXVECTOR3 localPlayer; // pos
- DWORD* dwpVTableStart = NULL; // d3d9.dll device vtable
- bool Init = 0;
- // W 2 S stuff
- D3DXVECTOR3 InvViewRight;
- D3DXVECTOR3 InvViewUp;
- D3DXVECTOR3 InvViewForward;
- D3DXVECTOR3 InvViewTranslation;
- D3DXVECTOR3 ViewPortMatrix;
- D3DXVECTOR3 ProjD1;
- D3DXVECTOR3 ProjD2;
- // end
- // colors
- const D3DCOLOR txtPink = D3DCOLOR_ARGB(255, 255, 0, 255); // Alpha, Rot, Grn, Blau
- const D3DCOLOR txtGreen = D3DCOLOR_ARGB(255, 20, 222, 20);
- const D3DCOLOR txtBlue = D3DCOLOR_ARGB(255, 20, 22, 222);
- const D3DCOLOR txtRed = D3DCOLOR_ARGB(255, 255, 0, 0);
- const D3DCOLOR txtGrey = D3DCOLOR_ARGB(255, 222, 222, 222);
- const D3DCOLOR txtDarkGrey = D3DCOLOR_ARGB(255, 142, 142, 182);
- // colors end
- /* Menu options */
- float *distLimit = new float(1000);
- float *distLimit2 = new float(1000);
- float *noFatigue = new float(0);
- float *emptyVeh = new float(0);
- float *objects = new float(0);
- float *allObjects = new float(0);
- float *unlockVehicles = new float(0);
- float *listItems = new float(0);
- float *bulletDamage = NULL;
- struct itemEntry
- {
- char name[64];
- BYTE type;
- void* item;
- itemEntry* last;
- itemEntry* next;
- bool show;
- itemEntry(char * n, BYTE t,void *i)
- {
- strcpy_s(name,n);
- type = t;
- item = i;
- show = 1;
- next = NULL;
- }
- };
- struct itemPicker
- {
- itemEntry* first;
- itemEntry* last;
- itemEntry* selected;
- itemPicker()
- {
- itemEntry *f = new itemEntry("...",0,0);
- selected = last = first = f;
- f->last = NULL;
- }
- void add(itemEntry* nm)
- {
- last->next = nm;
- nm->last = last;
- last = nm;
- }
- void update(char* t)
- {
- }
- };
- bool drawMenu;
- struct playerEntry
- {
- char name[32];
- int ID;
- playerEntry* last;
- playerEntry* next;
- playerEntry(char * n, int i)
- {
- strcpy_s(name,n);
- next = NULL;
- ID = i;
- }
- };
- struct playerPicker
- {
- playerEntry* first;
- playerEntry* last;
- playerEntry* selected;
- playerPicker(playerEntry* f)
- {
- selected = last = first = f;
- f->last = NULL;
- }
- void add(playerEntry* nm)
- {
- last->next = nm;
- nm->last = last;
- last = nm;
- }
- };
- struct menuentry
- {
- menuentry* next;
- menuentry* last;
- float *value;
- float step;
- float max;
- char name[32];
- menuentry(char * n,float* &d,float s, float m)
- {
- strcpy_s(name,n);
- next = NULL;
- value = d; step = s; max = m;
- }
- void right()
- {
- if(!((*value + step)>max))
- {
- *value = *value + step;
- }
- }
- void left()
- {
- if(!((*value - step)<0))
- {
- *value = *value - step;
- }
- }
- };
- menuentry* bd = NULL;
- struct menu
- {
- menuentry* first;
- menuentry* last;
- menuentry* selected;
- playerPicker* picker;
- itemPicker* iPicker;
- menu(menuentry* f)
- {
- selected = last = first = f;
- f->last = NULL;
- picker = NULL;
- iPicker = NULL;
- }
- void add(menuentry* nm)
- {
- last->next = nm;
- nm->last = last;
- last = nm;
- }
- };
- menu *mainMenu;
- //
- typedef struct _PEB_LDR_DATA
- {
- ULONG Length;
- BOOLEAN Initialized;
- PVOID SsHandle;
- LIST_ENTRY InLoadOrderModuleList;
- LIST_ENTRY InMemoryOrderModuleList;
- LIST_ENTRY InInitializationOrderModuleList;
- } PEB_LDR_DATA, *PPEB_LDR_DATA;
- typedef struct _LDR_MODULE {
- LIST_ENTRY InLoadOrderModuleList;
- LIST_ENTRY InMemoryOrderModuleList;
- LIST_ENTRY InInitializationOrderModuleList;
- PVOID BaseAddress;
- PVOID EntryPoint;
- ULONG SizeOfImage;
- UNICODE_STRING FullDllName;
- UNICODE_STRING BaseDllName;
- ULONG Flags;
- SHORT LoadCount;
- SHORT TlsIndex;
- LIST_ENTRY HashTableEntry;
- ULONG TimeDateStamp;
- } LDR_MODULE, *PLDR_MODULE;
- inline float Vectorl3(D3DVECTOR v) {
- return (sqrt(v.x * v.x + v.y * v.y + v.z * v.z));
- }
- inline float Vectorl2(D3DXVECTOR2 v) {
- return (sqrt(v.x * v.x + v.y * v.y));
- }
- VOID* DetourCreate(BYTE *src, const BYTE *dst, const int len)
- {
- BYTE *jmp = (BYTE*)malloc(len+5);
- DWORD dwBack;
- VirtualProtect(src, len, PAGE_EXECUTE_READWRITE, &dwBack);
- memcpy(jmp, src, len);
- jmp += len;
- jmp[0] = 0xE9;
- *(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
- src[0] = 0xE9;
- *(DWORD*)(src+1) = (DWORD)(dst - src) - 5;
- for (int i=5; i<len; i++) src[i]=0x90;
- VirtualProtect(src, len, dwBack, &dwBack);
- return (jmp-len);
- }
- bool bDataCompare(const BYTE* pData, const BYTE* bMask, const char* szMask)
- {
- for(;*szMask;++szMask,++pData,++bMask)
- if(*szMask=='x' && *pData!=*bMask )
- return false;
- return (*szMask) == NULL;
- }
- DWORD dwFindPattern(DWORD dwAddress,DWORD dwLen,BYTE *bMask,char * szMask)
- {
- for(DWORD i=0; i < dwLen; i++)
- if( bDataCompare( (BYTE*)( dwAddress+i ),bMask,szMask) )
- return (DWORD)(dwAddress+i);
- return 0;
- }
- DWORD D3D9VTable()
- {
- DWORD dwObjBase = (DWORD)LoadLibraryA("D3D9.DLL");
- while ( dwObjBase++ < dwObjBase + 0x127850 )
- {
- if ( (*(WORD*)(dwObjBase + 0x00)) == 0x06C7 && (*(WORD*)(dwObjBase + 0x06)) == 0x8689 && (*(WORD*)(dwObjBase + 0x0C)) == 0x8689 )
- {
- dwObjBase += 2;
- break;
- }
- }
- return ( dwObjBase );
- }
- void DrawRect (LPDIRECT3DDEVICE9 Device_t, int X, int Y, int L, int H, D3DCOLOR color)
- {
- D3DRECT rect = {X, Y, X+L, Y+H};
- Device_t->Clear(1, &rect, D3DCLEAR_TARGET, color, 0, 0); // bei Google gibt’s nהheres
- }
- void DrawLine(ID3DXLine* pLine,float x1, float y1,float x2, float y2, D3DCOLOR color)
- {
- D3DXVECTOR2 Vector2[2];
- Vector2[0].x = x1;
- Vector2[0].y = y1;
- Vector2[1].x = x2;
- Vector2[1].y = y2;
- pLine->Draw(Vector2,2,color);
- }
- void DrawFont (int X, int Y, D3DCOLOR Color, char *format, ...)
- {
- char buffer[256];
- va_list args; // deswegen: #include <cstdio>
- va_start (args, format);
- vsprintf (buffer,format, args);
- RECT FontRect = { X, Y, X + 120, Y + 16 };
- m_pFont->DrawText( NULL, buffer, -1, &FontRect, DT_NOCLIP , Color ); // Zeichnen
- va_end (args);
- }
- void UpdateView()
- {
- const D3DCOLOR txtPink = D3DCOLOR_ARGB(255, 255, 0, 255); // Alpha, Rot, Grn, Blau
- DWORD *dwTransformations = (DWORD*)0xDD32F4;
- DWORD *dwTransData = (DWORD*)(*dwTransformations + 0x90);
- InvViewRight = *(D3DXVECTOR3*)(*dwTransData+0x4);
- InvViewUp = *(D3DXVECTOR3*)(*dwTransData+0x10);
- InvViewForward = *(D3DXVECTOR3*)(*dwTransData+0x1C);
- InvViewTranslation = *(D3DXVECTOR3*)(*dwTransData+0x28);
- ViewPortMatrix = *(D3DXVECTOR3*)(*dwTransData+0x54);
- ProjD1 = *(D3DXVECTOR3*)(*dwTransData+0xCC);
- ProjD2 = *(D3DXVECTOR3*)(*dwTransData+0xD8);
- }
- D3DXVECTOR3 WorldToScreen(D3DXVECTOR3 in)
- {
- D3DXVECTOR3 out, temp;
- D3DXVec3Subtract(&temp, &in, &InvViewTranslation);
- float x = D3DXVec3Dot(&temp, &InvViewRight);
- float y = D3DXVec3Dot(&temp, &InvViewUp);
- float z = D3DXVec3Dot(&temp, &InvViewForward);
- out.x = ViewPortMatrix.x * (1 + (x / ProjD1.x / z));
- out.y = ViewPortMatrix.y * (1 - (y / ProjD2.y / z));
- out.z = z;
- return out;
- }
- /*
- HRESULT __stdcall hkEndScene(LPDIRECT3DDEVICE9 pDevice)
- {
- if(m_pFont==NULL)
- {
- D3DXCreateFont(pDevice, 14, 0, 400, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Verdana"), &m_pFont);
- }
- DrawFont(3,3,txtPink,"DistFilter: (%d)",DistLimit);
- WorldPointer pWorld = *(WorldPointer*)0xDA8208;
- if(pWorld.world->cameraOn->unit)
- {
- if(pWorld.world->cameraOn->unit->entityVisualState)
- localPlayer = pWorld.world->cameraOn->unit->entityVisualState->coordinates;
- EntityTablePointer* ObjectPtr = (pWorld.world->entityTablePointer);
- if(!IsBadReadPtr(ObjectPtr,0x8))
- {
- DWORD* entTable = *(DWORD**)ObjectPtr;
- if(!IsBadReadPtr(entTable,4))
- {
- for(int i = 0; i<pWorld.world->entityTablePointer->objectTableSize; i++)
- {
- EntityTable *eTable = *(EntityTable**)((entTable+(13*i)));
- if(eTable)
- {
- Entity *e = eTable->e;
- if(e)
- {
- if(strcmp(e->cfgVehicle->objectType->string,"soldier")==0)
- {
- bool human = 0;
- if(!IsBadReadPtr(eTable->unitInfo,0x34))
- {
- if(!IsBadReadPtr(eTable->unitInfo->unit,0x1178))
- if(eTable->unitInfo->unit->playerID > 1)human = 1;
- }
- EntityVisualState *vis = e->entityVisualState;
- if(vis)
- {
- UpdateView();
- D3DXVECTOR3 pos = WorldToScreen(vis->coordinates);
- if(pos.z > 0.01)
- DrawFont(pos.x,pos.y,human ? txtPink : txtRed,"%s (%s) %f m",e->cfgVehicle->entityName->string, e->cfgVehicle->objectType->string, (int)(Vectorl(localPlayer - vis->coordinates)));
- }
- }
- }
- }
- }
- }
- }
- }
- /*
- if(pWorld.world->cameraOn->unit)
- {
- if(pWorld.world->cameraOn->unit->entityVisualState)
- {
- D3DVECTOR pos = pWorld.world->cameraOn->unit->entityVisualState->coordinates;
- DrawFont(3,3,txtPink,"local pos: %f %f %f",pos.x,pos.y,pos.z);
- }
- }
- return pEndScene(pDevice);
- }
- */
- void UnlinkModule (char *szModule)
- {
- DWORD dwPEB = 0, dwOffset = 0;
- PLIST_ENTRY pUserModuleHead, pUserModule;
- PPEB_LDR_DATA pLdrData;
- PLDR_MODULE pLdrModule;
- PUNICODE_STRING lpModule;
- char szModuleName[512];
- int i = 0, n = 0;
- _asm
- {
- pushad
- mov eax, fs: [48]
- mov dwPEB, eax
- popad
- }
- pLdrData= ( PPEB_LDR_DATA )(PDWORD)(*(PDWORD)(dwPEB + 12));
- for (; i < 3; i++)
- {
- switch (i)
- {
- case 0:
- pUserModuleHead = pUserModule = ( PLIST_ENTRY ) ( &( pLdrData->InLoadOrderModuleList ) );
- dwOffset = 0;
- break;
- case 1:
- pUserModuleHead = pUserModule = ( PLIST_ENTRY ) ( &( pLdrData->InMemoryOrderModuleList ) );
- dwOffset = 8;
- break;
- case 2:
- pUserModuleHead = pUserModule = (PLIST_ENTRY) (&(pLdrData->InInitializationOrderModuleList));
- dwOffset = 16;
- break;
- }
- while (pUserModule->Flink != pUserModuleHead)
- {
- pUserModule = pUserModule->Flink;
- lpModule = (PUNICODE_STRING)(((DWORD)(pUserModule)) + (36-dwOffset));
- for (n = 0; n < (lpModule->Length)/2 && n < 512; n++)
- szModuleName[n] = (CHAR)(* ((lpModule->Buffer)+(n)));
- szModuleName[n] = '\0';
- if (strstr (szModuleName, szModule))
- {
- pUserModule->Blink->Flink = pUserModule->Flink;
- pUserModule->Flink->Blink = pUserModule->Blink;
- }
- }
- }
- }
- void HideModule( HINSTANCE hModule )
- {
- DWORD dwPEB_LDR_DATA = 0;
- _asm
- {
- pushad;
- pushfd;
- mov eax, fs:[30h] // PEB
- mov eax, [eax+0Ch] // PEB->ProcessModuleInfo
- mov dwPEB_LDR_DATA, eax // Save ProcessModuleInfo
- InLoadOrderModuleList:
- mov esi, [eax+0Ch] // ProcessModuleInfo->InLoadOrderModuleList[FORWARD]
- mov edx, [eax+10h] // ProcessModuleInfo->InLoadOrderModuleList[BACKWARD]
- LoopInLoadOrderModuleList:
- lodsd // Load First Module
- mov esi, eax // ESI points to Next Module
- mov ecx, [eax+18h] // LDR_MODULE->BaseAddress
- cmp ecx, hModule // Is it Our Module ?
- jne SkipA // If Not, Next Please (@f jumps to nearest Unamed Lable @@:)
- mov ebx, [eax] // [FORWARD] Module
- mov ecx, [eax+4] // [BACKWARD] Module
- mov [ecx], ebx // Previous Module's [FORWARD] Notation, Points to us, Replace it with, Module++
- mov [ebx+4], ecx // Next Modules, [BACKWARD] Notation, Points to us, Replace it with, Module--
- jmp InMemoryOrderModuleList // Hidden, so Move onto Next Set
- SkipA:
- cmp edx, esi // Reached End of Modules ?
- jne LoopInLoadOrderModuleList // If Not, Re Loop
- InMemoryOrderModuleList:
- mov eax, dwPEB_LDR_DATA // PEB->ProcessModuleInfo
- mov esi, [eax+14h] // ProcessModuleInfo->InMemoryOrderModuleList[START]
- mov edx, [eax+18h] // ProcessModuleInfo->InMemoryOrderModuleList[FINISH]
- LoopInMemoryOrderModuleList:
- lodsd
- mov esi, eax
- mov ecx, [eax+10h]
- cmp ecx, hModule
- jne SkipB
- mov ebx, [eax]
- mov ecx, [eax+4]
- mov [ecx], ebx
- mov [ebx+4], ecx
- jmp InInitializationOrderModuleList
- SkipB:
- cmp edx, esi
- jne LoopInMemoryOrderModuleList
- InInitializationOrderModuleList:
- mov eax, dwPEB_LDR_DATA // PEB->ProcessModuleInfo
- mov esi, [eax+1Ch] // ProcessModuleInfo->InInitializationOrderModuleList[START]
- mov edx, [eax+20h] // ProcessModuleInfo->InInitializationOrderModuleList[FINISH]
- LoopInInitializationOrderModuleList:
- lodsd
- mov esi, eax
- mov ecx, [eax+08h]
- cmp ecx, hModule
- jne SkipC
- mov ebx, [eax]
- mov ecx, [eax+4]
- mov [ecx], ebx
- mov [ebx+4], ecx
- jmp Finished
- SkipC:
- cmp edx, esi
- jne LoopInInitializationOrderModuleList
- Finished:
- popfd;
- popad;
- }
- }
- void DrawMenu(LPDIRECT3DDEVICE9 pDevice)
- {
- if(mainMenu)
- {
- if(mainMenu->first)
- {
- menuentry* looper = mainMenu->first;
- int i = 0;
- do
- {
- if(i)
- looper = looper->next;
- if(looper->value)
- DrawFont(3,(i*13)+3,(looper == mainMenu->selected) ? txtPink : txtBlue,"%s: (%d)",looper->name,(int)*looper->value);
- i++;
- }
- while(looper->next);
- }
- if(mainMenu->picker)
- {
- if(mainMenu->picker->first)
- {
- playerEntry* looper = mainMenu->picker->first;
- int i = 0;
- do
- {
- looper = looper->next;
- if(looper->ID>1)
- {
- DrawFont(153,(i*13)+3,(looper == mainMenu->picker->selected) ? txtPink : txtBlue,looper->name);
- i++;
- }
- }
- while(looper->next);
- }
- }
- else if(mainMenu->iPicker)
- {
- if(mainMenu->iPicker->first)
- {
- itemEntry* looper = mainMenu->iPicker->first;
- int i = 0;
- while(looper)
- {
- if(looper->show)
- {
- DrawFont(153,(i*13)+3,(looper == mainMenu->iPicker->selected) ? txtPink : txtBlue,"%s %x",looper->name,looper->item);
- i++;
- }
- looper = looper->next;
- }
- }
- }
- }
- }
- char* getCombi(EntryArray *entry)
- {
- while(true)
- {
- if((DWORD)entry>1)
- {
- if(!IsBadReadPtr(entry->firstEntry,4))
- {
- varEntry* en = entry->firstEntry;
- if(en->vTable == 12644640)
- {
- if(strcmp(en->name->string,"characterid")==0)
- return(en->value->value->string);//DrawFont(250,3+(i*13),txtGreen,"variable: %s n: %f",en->name->string,);
- }
- else
- {
- return 0;
- }
- }
- }
- entry += 1;
- }
- }
- void SlaveLoop(EntityList* table, int size)
- {
- for(int i = 0; i<size; i++)
- {
- if((DWORD*)(table+i))
- {
- Entity *e = *(Entity**)(table+i);
- if(e->entityVisualState)
- {
- if(e->cfgVehicle)
- {
- if(!IsBadReadPtr(e->cfgVehicle,0x220))
- {
- float dist = (Vectorl3(localPlayer - e->entityVisualState->coordinates));
- if(dist<*distLimit)
- {
- D3DXVECTOR3 pos = WorldToScreen(e->entityVisualState->coordinates);
- if(pos.z > 0.01)
- {
- if(*allObjects==0)
- {
- if(strcmp(e->cfgVehicle->entityName->string,"VaultStorageLocked")==0)
- {
- char *combi = NULL;
- DWORD vTable = *(DWORD*)(e);
- DWORD func = *(DWORD*)(vTable+0x104);
- VarTable* table;
- __asm
- {
- mov ECX, e
- call func
- mov table, EAX
- }
- EntryArray *entry = table->eArray;
- combi = getCombi(entry);
- DrawFont(pos.x,pos.y,txtGreen,"Safe (%s) %dm",combi,(int)dist);
- }
- else if(strcmp(e->cfgVehicle->entityName->string,"CinderWallDoorLocked_DZ")==0 || strcmp(e->cfgVehicle->entityName->string,"CinderWallDoorSmallLocked_DZ")==0 || strcmp(e->cfgVehicle->entityName->string,"Land_DZE_GarageWoodDoorLocked")==0 || strcmp(e->cfgVehicle->entityName->string,"Land_DZE_LargeWoodDoorLocked")==0 || strcmp(e->cfgVehicle->entityName->string,"Land_DZE_WoodDoorLocked")==0)
- {
- char *combi = NULL;
- DWORD vTable = *(DWORD*)(e);
- DWORD func = *(DWORD*)(vTable+0x104);
- VarTable* table;
- __asm
- {
- mov ECX, e
- call func
- mov table, EAX
- }
- EntryArray *entry = table->eArray;
- combi = getCombi(entry);
- DrawFont(pos.x,pos.y,txtGreen,"door (%s) %dm",combi,(int)dist);
- }
- if(strcmp(e->cfgVehicle->entityName->string,"LockboxStorageLocked")==0)
- {
- char *combi = NULL;
- DWORD vTable = *(DWORD*)(e);
- DWORD func = *(DWORD*)(vTable+0x104);
- VarTable* table;
- __asm
- {
- mov ECX, e
- call func
- mov table, EAX
- }
- EntryArray *entry = table->eArray;
- combi = getCombi(entry);
- DrawFont(pos.x,pos.y,txtGreen,"Lockbox (%s) %dm",combi,(int)dist);
- }
- else if(strcmp(e->cfgVehicle->entityName->string,"VaultStorage")==0)
- DrawFont(pos.x,pos.y,txtGreen,"Safe(open) %dm",(int)dist);
- else if(strcmp(e->cfgVehicle->entityName->string,"LockboxStorage")==0)
- DrawFont(pos.x,pos.y,txtGreen,"Lockbox(open) %dm",(int)dist);
- else if(strstr(e->cfgVehicle->entityName->string,"TentStorage"))
- DrawFont(pos.x,pos.y,txtGreen,"Tent %dm",(int)dist);
- else if(strstr(e->cfgVehicle->entityName->string,"StorageShed") || strstr(e->cfgVehicle->entityName->string,"WoodShack"))
- DrawFont(pos.x,pos.y,txtGreen,"Shed %dm",(int)dist);
- else if(strcmp(e->cfgVehicle->entityName->string,"WoodCrate_DZ")==0)
- DrawFont(pos.x,pos.y,txtGreen,"Crate %dm",(int)dist);
- else if(strstr(e->cfgVehicle->entityName->string,"Grave"))
- DrawFont(pos.x,pos.y,txtGrey,"Grave %dm",(int)dist);
- else if(strcmp(e->cfgVehicle->entityName->string,"GunRack_DZ")==0)
- DrawFont(pos.x,pos.y,txtGreen,"Gunrack %dm",(int)dist);
- else if(strcmp(e->cfgVehicle->entityName->string,"Plastic_Pole_EP1_DZ")==0)
- DrawFont(pos.x,pos.y,txtGreen,"Pole %dm",(int)dist);
- }
- else
- {
- DrawFont(pos.x,pos.y,txtGreen,e->cfgVehicle->entityName->string);
- }
- }
- }
- }
- }
- }
- }
- }
- }
- void MasterLoop(EntitiesDistributed* table)
- {
- __try
- {
- if(table->table1)SlaveLoop(table->table1,table->table1Size);
- if(table->table2)SlaveLoop(table->table2,table->table2Size);
- if(table->table3)SlaveLoop(table->table3,table->table3Size);
- if(table->table4)SlaveLoop(table->table4,table->table4Size);
- }
- __except(EXCEPTION_EXECUTE_HANDLER)
- {
- }
- }
- int WINAPI HookedPresent(LPDIRECT3DDEVICE9 pDevice, const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride, const RGNDATA *pDirtyRegion)
- {
- if(m_pFont==NULL)
- {
- D3DXCreateFont(pDevice, 14, 0, 400, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Verdana"), &m_pFont);
- }
- if(!Init)
- {
- mainMenu = new menu(new menuentry("Distance",distLimit,1000,15000));
- mainMenu->add(new menuentry("Show vehicle distance", distLimit2, 1000, 15000));
- mainMenu->add(new menuentry("No Fatigue",noFatigue,1,1));
- mainMenu->add(new menuentry("Show empty Vehicles",emptyVeh,1,1));
- mainMenu->add(new menuentry("Show Storages",objects,1,1));
- mainMenu->add(new menuentry("Show all objects",allObjects,1,1));
- mainMenu->add(new menuentry("Item List",listItems,1,1));
- mainMenu->add(new menuentry("Unlock Vehicles",unlockVehicles,1,1));
- //mainMenu->add(new menuentry("Vehicle locked",vehicleLocked,1,3));
- bd = new menuentry("Bulletdamage",bulletDamage,10,50000);
- mainMenu->add(bd);
- Init = 1;//menuvalue* v1 = selected->current = selected->first = new menuvalue();
- if(!m_rectLine)D3DXCreateLine(pDevice,&m_rectLine);
- }
- if (GetAsyncKeyState(VK_END))
- drawMenu = !drawMenu;
- if (drawMenu)
- DrawMenu(pDevice);
- WorldPointer pWorld = *(WorldPointer*)0xDA8208;
- NetworkManager pNetworkmanager = *(NetworkManager*)0xD99F08;
- if(pWorld.world->cameraOn->unit)
- {
- if(*listItems&&mainMenu->iPicker==NULL)
- {
- mainMenu->iPicker = new itemPicker();
- MagTable *mt = (MagTable*)0xDA81F0;
- for(int i = 0;i<mt->count;i++)
- {
- MagazineType *m = *(MagazineType**)((DWORD)mt->mag+i*4);
- //char nigger[64];
- //sprintf_s(nigger,"%x",m);
- if(m->magazineName)
- mainMenu->iPicker->add(new itemEntry(m->magazineName->string,0,m));
- }
- }
- else if(mainMenu->iPicker&&*listItems==0)
- {
- mainMenu->iPicker = NULL;
- }
- /*
- Entity* e = (Entity*)pWorld.world->cameraOn->unit;
- DWORD vTable = *(DWORD*)(e);
- DWORD func = *(DWORD*)(vTable+0x104);
- VarTable* table;
- __asm
- {
- mov ECX, e
- call func
- mov table, EAX
- }
- EntryArray *entry = table->eArray;
- int i = 0;
- DrawFont(250,500,txtGreen,"varTable: %x",table);
- while(true)
- {
- i++;
- if((DWORD)entry>1)
- {
- if(!IsBadReadPtr(entry->firstEntry,4))
- {
- varEntry* en = entry->firstEntry;
- if(en->vTable == 12644640)
- {
- DrawFont(250,3+(i*13),txtGreen,"variable: %s n: %x",en->name->string,en);
- }
- else
- {
- break;
- }
- }
- }
- entry += 1;
- }
- */
- //DrawFont(250,250,txtGreen,"%s",entry->name->string);
- if(pWorld.world->cameraOn->unit->playerID>0)
- {
- if(!pWorld.world->cameraOn->unit->isDead)
- {
- /*
- if(pNetworkmanager.scoreboard)
- if(pNetworkmanager.scoreboard->scoreboardTable)
- {
- for(int i = 0;i < pNetworkmanager.scoreboard->scoreboardTableCount; i++)
- {
- DrawFont(200,3+(i*13),txtPink,"%s %d",(wchar_t*)(*(DWORD**)((DWORD*)pNetworkmanager.scoreboard->scoreboardTable+(i * 0x46)+0x2A)+0x2),*(DWORD**)((DWORD*)pNetworkmanager.scoreboard->scoreboardTable+(i * 0x46) + 0x1)); // (wchar_t*)(*(DWORD**)((DWORD*)pNetworkmanager.scoreboard->scoreboardTable+0x2A)+0x2)
- }
- }
- */
- if(*noFatigue&&pWorld.world->cameraOn->unit->fatigue)
- pWorld.world->cameraOn->unit->fatigue = 0;
- }
- //float* bulletdmg = (float*)(*(DWORD**)(*(DWORD**)(*(DWORD**)((DWORD*)pWorld.world->cameraOn->unit->weaponTable+(pWorld.world->cameraOn->unit->weaponID * 0x9) + 0x1)+0x2)+0x80)+0x50);
- //pWorld.world->cameraOn->unit->customRecoilCoef = 0;
- //pWorld.world->cameraOn->unit->fatigue = 0;
- /*
- Weapon *w = (Weapon*)(pWorld.world->cameraOn->unit->weaponTable+(pWorld.world->cameraOn->unit->weaponID * 0x9)+0x1);
- if(w)
- {
- DrawFont(3,42,txtPink,"weapon %x", w);
- //w->weaponModeType->dispersion = 0;
- if(w->magazine)
- {
- //w->magazine->magazineType->ammunition->directDamage = 12;
- DrawFont(3,29,txtPink,"damage %f speed %f",w->magazine->magazineType->ammunition->directDamage,w->magazine->magazineType->ammunition->typicalSpeed);
- }
- else
- {
- DrawFont(3,29,txtPink,"Magazine is null");
- }
- }
- else
- {
- DrawFont(3,42,txtPink,"no weapon");
- }
- */
- }
- if(pWorld.world->cameraOn->unit->entityVisualState)
- localPlayer = pWorld.world->cameraOn->unit->entityVisualState->coordinates;
- EntityTablePointer* ObjectPtr = (pWorld.world->entityTablePointer);
- if(!IsBadReadPtr(ObjectPtr,0x8))
- {
- DWORD* entTable = *(DWORD**)ObjectPtr;
- if(!IsBadReadPtr(entTable,4))
- {
- UpdateView();
- for(int i = 0; i<pWorld.world->entityTablePointer->objectTableSize; i++)
- {
- EntityTable *eTable = *(EntityTable**)((entTable+(13*i)));
- if(eTable)
- {
- Entity *e = eTable->e;
- if(e)
- {
- if(strcmp(e->cfgVehicle->objectType->string,"soldier")==0)
- {
- if(e != (Entity*)pWorld.world->cameraOn->unit)
- {
- bool human = 0;
- Unit* u = (Unit*)e;
- if(u->playerID>1)
- human = 1;
- EntityVisualState *vis = e->entityVisualState;
- if(vis)
- {
- int dist = (int)(Vectorl3(localPlayer - vis->coordinates));
- if(dist<*distLimit)
- {
- if(!u->isDead)
- {
- if(human)
- {
- char* name = "null";
- D3DXVECTOR3 pos = WorldToScreen(vis->coordinates);
- if(pos.z > 0.01)
- {
- if(pNetworkmanager.scoreboard)
- {
- if(pNetworkmanager.scoreboard->scoreboardTable)
- {
- for(int i = 0;i < pNetworkmanager.scoreboard->scoreboardTableCount; i++)
- {
- if(*(DWORD*)((DWORD*)pNetworkmanager.scoreboard->scoreboardTable+(i * 0x46) + 0x1) == u->playerID)
- {
- //DrawFont(200,3+(i*13),txtPink,"%s %d",(char*)(*(DWORD**)((DWORD*)pNetworkmanager.scoreboard->scoreboardTable+(i * 0x46)+0x2A)+0x2),*(DWORD**)((DWORD*)pNetworkmanager.scoreboard->scoreboardTable+(i * 0x46) + 0x1)); // (wchar_t*)(*(DWORD**)((DWORD*)pNetworkmanager.scoreboard->scoreboardTable+0x2A)+0x2)
- name = (char*)(*(DWORD**)((DWORD*)pNetworkmanager.scoreboard->scoreboardTable+(i * 0x46)+0x2A)+0x2);
- break;//DrawFont(200,3+(i*13),txtPink,"%s %d",(wchar_t*)(*(DWORD**)((DWORD*)pNetworkmanager.scoreboard->scoreboardTable+(i * 0x46)+0x2A)+0x2),*(DWORD**)((DWORD*)pNetworkmanager.scoreboard->scoreboardTable+(i * 0x46) + 0x1)); // (wchar_t*)(*(DWORD**)((DWORD*)pNetworkmanager.scoreboard->scoreboardTable+0x2A)+0x2)
- }
- }
- }
- }
- if(dist<500)
- {
- D3DXVECTOR3 headpos = WorldToScreen(vis->headCoordinates);
- D3DXVECTOR3 bodypos = WorldToScreen(vis->torsoCoordinates);
- //D3DXVECTOR2 headpos2D(headpos.x,headpos.y);
- //D3DXVECTOR2 boxdir = (headpos - pos);
- //float blength = Vectorl2(boxdir);
- //D3DXVECTOR2 box90(-boxdir.y, boxdir.x);
- //D3DXVECTOR2 norm90;
- //D3DXVec2Normalize(&norm90,&box90);
- //D3DXVECTOR3 lefttop = headpos2D + (norm90 * 0,2);
- //D3DXVECTOR3 righttop = headpos2D - (norm90 * 0,2);
- DrawLine(m_rectLine,headpos.x,headpos.y,bodypos.x,bodypos.y,txtRed);
- DrawLine(m_rectLine,bodypos.x,bodypos.y,pos.x,pos.y,txtRed);
- //DrawLine(m_rectLine,lefttop.x,lefttop.y,righttop.x,righttop.y,txtRed);
- }
- D3DCOLOR txtCustom = D3DCOLOR_ARGB(255, 255, 0, 0);
- wchar_t dispName[256];
- //swprintf(dispName,L"%s %dm %d",name, dist,u->playerID);
- DrawFont(pos.x,pos.y,txtCustom,"%s %dm",name, dist);
- }
- }
- else
- {
- D3DXVECTOR3 pos = WorldToScreen(vis->coordinates);
- if (pos.z > 0.01)
- {
- D3DCOLOR txtCow = D3DCOLOR_ARGB(255 - (int)((float)((float)dist / (float)*distLimit) * 255), 255, 255, 0);
- DrawFont(pos.x, pos.y, txtCow, "%s (AI) %dm", e->cfgVehicle->entityName->string, dist);
- }
- }
- }
- else
- {
- D3DXVECTOR3 pos = WorldToScreen(vis->coordinates);
- if(pos.z > 0.01)
- {
- DrawFont(pos.x,pos.y,txtDarkGrey,"%s (dead) %dm",e->cfgVehicle->entityName->string, dist);
- }
- }
- }
- }
- }
- }
- else if(strcmp(e->cfgVehicle->objectType->string,"helicopter")==0 || strcmp(e->cfgVehicle->objectType->string,"car")==0 || strcmp(e->cfgVehicle->objectType->string,"airplane")==0 || strcmp(e->cfgVehicle->objectType->string,"motorcycle")==0 || strcmp(e->cfgVehicle->objectType->string,"parachute")==0)
- {
- Vehicle* v = (Vehicle*)e;
- /*
- DWORD desob = NULL;
- DWORD delVeh = 0x450430;
- if(*destruction)
- {
- __asm
- {
- push v
- call delVeh
- mov desob, EAX
- }
- if(desob)
- {
- DWORD vTable = *(DWORD*)desob;
- DWORD Adress = *(DWORD*)(vTable + 0x28);
- __asm
- {
- mov ECX, desob
- call Adress
- }
- }
- }
- */
- if(*unlockVehicles)
- {
- Unit *u = (Unit*)v;
- u->vehicleLocked = 1;
- }
- if((Unit*)v != pWorld.world->cameraOn->unit)
- {
- if(v->driver)
- {
- if(v->driver->playerID)
- {
- EntityVisualState *vis = e->entityVisualState;
- if(vis)
- {
- int dist = (int)(Vectorl3(localPlayer - vis->coordinates));
- if(dist<*distLimit)
- {
- Unit* e = (Unit*)v;
- char* name = "null";
- if(pNetworkmanager.scoreboard)
- {
- if(pNetworkmanager.scoreboard->scoreboardTable)
- {
- for(int i = 0;i < pNetworkmanager.scoreboard->scoreboardTableCount; i++)
- {
- if(*(DWORD*)((DWORD*)pNetworkmanager.scoreboard->scoreboardTable+(i * 0x46) + 0x1) == v->driver->playerID)
- {
- //DrawFont(200,3+(i*13),txtPink,"%s %d",(char*)(*(DWORD**)((DWORD*)pNetworkmanager.scoreboard->scoreboardTable+(i * 0x46)+0x2A)+0x2),*(DWORD**)((DWORD*)pNetworkmanager.scoreboard->scoreboardTable+(i * 0x46) + 0x1)); // (wchar_t*)(*(DWORD**)((DWORD*)pNetworkmanager.scoreboard->scoreboardTable+0x2A)+0x2)
- name = (char*)(*(DWORD**)((DWORD*)pNetworkmanager.scoreboard->scoreboardTable+(i * 0x46)+0x2A)+0x2);
- break;//DrawFont(200,3+(i*13),txtPink,"%s %d",(wchar_t*)(*(DWORD**)((DWORD*)pNetworkmanager.scoreboard->scoreboardTable+(i * 0x46)+0x2A)+0x2),*(DWORD**)((DWORD*)pNetworkmanager.scoreboard->scoreboardTable+(i * 0x46) + 0x1)); // (wchar_t*)(*(DWORD**)((DWORD*)pNetworkmanager.scoreboard->scoreboardTable+0x2A)+0x2)
- }
- }
- }
- }
- D3DXVECTOR3 pos = WorldToScreen(vis->coordinates);
- if(pos.z > 0.01)
- {
- DrawFont(pos.x,pos.y,txtPink,"%s %dm (%d) [%s]",e->cfgVehicle->entityName->string, dist,e->vehicleLocked, name);
- }
- }
- }
- }
- }
- else if(*emptyVeh)
- {
- EntityVisualState *vis = e->entityVisualState;
- if(vis)
- {
- int dist = (int)(Vectorl3(localPlayer - vis->coordinates));
- if(dist<*distLimit2)
- {
- Unit* e = (Unit*)v;
- D3DXVECTOR3 pos = WorldToScreen(vis->coordinates);
- if(pos.z > 0.01)
- {
- DrawFont(pos.x,pos.y,txtGrey,"%s %dm (%x)",e->cfgVehicle->entityName->string, dist,e->vehicleLocked);
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- if(*objects)
- {
- MasterLoop(pWorld.world->table1);
- MasterLoop(pWorld.world->table2);
- MasterLoop(pWorld.world->table3);
- }
- }
- /*
- if(pWorld.world->cameraOn->unit)
- {
- if(pWorld.world->cameraOn->unit->entityVisualState)
- {
- D3DVECTOR pos = pWorld.world->cameraOn->unit->entityVisualState->coordinates;
- DrawFont(3,3,txtPink,"local pos: %f %f %f",pos.x,pos.y,pos.z);
- }
- }
- */
- oPresent(pDevice, pSourceRect,pDestRect,hDestWindowOverride,pDirtyRegion);
- return 0;
- }
- template <typename T> T HookVTableFunction(DWORD* dwpTable, int index, DWORD dwNewFunc)
- {
- DWORD dwProt = 0;
- VirtualProtect(&dwpTable[index],4,PAGE_EXECUTE_READWRITE,&dwProt);
- T oFunc = (T)dwpTable[index];
- dwpTable[index] = dwNewFunc;
- VirtualProtect(&dwpTable[index],4,dwProt,0);
- return oFunc;
- }
- DWORD WINAPI HookThread(LPVOID lpParameter)
- {
- HMODULE hModule = GetModuleHandleA("d3d9.dll");
- DWORD dwDeviceVMTPtr(0), *dwpDeviceVMT = NULL;
- dwDeviceVMTPtr = *(DWORD*)(*(DWORD*)(*(DWORD*)0xDA8208+0x4)+0x188c);
- memcpy(&dwpDeviceVMT, (LPVOID)dwDeviceVMTPtr, 4);
- oPresent = HookVTableFunction<Present_t>(dwpDeviceVMT, 17, (DWORD)&HookedPresent);
- while (true)
- {
- HookVTableFunction<Present_t>(dwpDeviceVMT, 17, (DWORD)&HookedPresent);
- Sleep(1000);
- }
- }
- DWORD WINAPI KeyThread(LPVOID lpParameter)
- {
- while(true)
- {
- if(GetAsyncKeyState(VK_DOWN))
- {
- if(!mainMenu->picker&&!mainMenu->iPicker)
- {
- if(mainMenu->selected->next)
- mainMenu->selected = mainMenu->selected->next;
- else
- mainMenu->selected = mainMenu->first;
- }
- else if(!mainMenu->iPicker)
- {
- if(mainMenu->picker->selected->next)
- mainMenu->picker->selected = mainMenu->picker->selected->next;
- else
- mainMenu->picker->selected = mainMenu->picker->first;
- }
- else
- {
- if(mainMenu->iPicker->selected->next)
- mainMenu->iPicker->selected = mainMenu->iPicker->selected->next;
- else
- mainMenu->iPicker->selected = mainMenu->iPicker->first;
- }
- }
- if(GetAsyncKeyState(VK_UP))
- {
- if(!mainMenu->picker&&!mainMenu->iPicker)
- {
- if(mainMenu->selected->last)
- mainMenu->selected = mainMenu->selected->last;
- else
- mainMenu->selected = mainMenu->last;
- }
- else if(!mainMenu->iPicker)
- {
- if(mainMenu->picker->selected->last)
- mainMenu->picker->selected = mainMenu->picker->selected->last;
- else
- mainMenu->picker->selected = mainMenu->picker->last;
- }
- else
- {
- if(mainMenu->iPicker->selected->last)
- mainMenu->iPicker->selected = mainMenu->iPicker->selected->last;
- else
- mainMenu->iPicker->selected = mainMenu->iPicker->last;
- }
- }
- if(GetAsyncKeyState(VK_RIGHT))
- {
- mainMenu->selected->right();
- }
- if(GetAsyncKeyState(VK_LEFT))
- {
- mainMenu->selected->left();
- }
- if(GetAsyncKeyState(VK_PRIOR))
- {
- WorldPointer pWorld = *(WorldPointer*)0xDA8208;
- //Weapon *w = (Weapon*)pWorld.world->cameraOn->unit->weaponTable+(pWorld.world->cameraOn->unit->weaponID * 0x9);
- //pWorld.world->cameraOn->unit->weaponTable->weaponModeType->dispersion
- DWORD* dispersion = (DWORD*)(*(DWORD**)((DWORD*)pWorld.world->cameraOn->unit->weaponTable+(pWorld.world->cameraOn->unit->weaponID * 0x9) + 0x4)+0xB);
- DWORD* garbage1 = (DWORD*)(*(DWORD**)((DWORD*)pWorld.world->cameraOn->unit->weaponTable+(pWorld.world->cameraOn->unit->weaponID * 0x9) + 0x1)+0x3);
- DWORD* garbage2 = (DWORD*)(*(DWORD**)((DWORD*)pWorld.world->cameraOn->unit->weaponTable+(pWorld.world->cameraOn->unit->weaponID * 0x9) + 0x1)+0x9);
- //pWorld.world->cameraOn->unit->weaponTable->magazine->magazineType->ammunition->directDamage
- *garbage1 = (30^0xBABAC8B6) << 1;
- *garbage2 = (30^0xBABAC8B6) - *garbage1;
- *dispersion = 0;
- //w->magazine->ammo1 = 0xDD5D6454;
- //w->magazine->ammo2 = 0xDD5D6454;
- //w->weaponModeType->dispersion = 0;
- //w->magazine->magazineType->ammunition->directDamage = 22;
- }
- if(GetAsyncKeyState(VK_INSERT))
- {
- WorldPointer pWorld = *(WorldPointer*)0xDA8208;
- if(strcmp(pWorld.world->cameraOn->unit->cfgVehicle->objectType->string,"soldier")!=0)
- {
- srand (time(NULL));
- Vehicle* v = (Vehicle*)pWorld.world->cameraOn->unit;
- for(int i=0;i<v->damagePartsCount;i++)
- {
- float* part = (float*)(v->damageParts + i);
- *part = (float)((float)(rand()%100)/1000);
- }
- v->coordinates->fuelLevel = v->cfgVehicle->fuelTankCap;
- }
- }
- if(GetAsyncKeyState(VK_RETURN))
- {
- std::cout << "Enter";
- WorldPointer pWorld = *(WorldPointer*)0xDA8208;
- if(mainMenu->iPicker)
- {
- if(*listItems)
- {
- if(pWorld.world->cameraOn->unit)
- {
- if(mainMenu->iPicker)
- {
- if(mainMenu->iPicker->selected->item)
- {
- if(pWorld.world->cameraOn->unit->inventoryMagTableSize<pWorld.world->cameraOn->unit->inventoryMagTableMaxSize)
- {
- DWORD off_D83398 = 0xD83398;
- DWORD initMag = 0x71E326;
- MagazineType *item = (MagazineType*)mainMenu->iPicker->selected->item;
- Magazine *mag = NULL;
- DWORD test = 0;
- __asm
- {
- mov ecx, [off_D83398]
- mov eax, [ecx]
- mov eax, [eax]
- mov test, eax
- push 30h
- call dword ptr [eax+4]
- push item
- mov ecx, eax
- call initMag
- mov mag, eax
- }
- //pWorld.world->cameraOn->unit->inventoryMagTableMaxSize++;
- mag->ammo1 = (item->magazineCapacity ^ 0xBABAC8B6) << 1;
- mag->ammo2 = (item->magazineCapacity ^ 0xBABAC8B6) - mag->ammo1;
- mag->references = 2;
- DWORD *newmag = (DWORD*)((DWORD)pWorld.world->cameraOn->unit->inventoryMagTable+pWorld.world->cameraOn->unit->inventoryMagTableSize*4);
- pWorld.world->cameraOn->unit->inventoryMagTableSize++;
- *newmag = (DWORD)mag;
- }
- }
- }
- }
- }
- }
- }
- Sleep(200);
- }
- }
- BOOL APIENTRY DllMain( HMODULE hModule,
- DWORD ul_reason_for_call,
- LPVOID lpReserved
- )
- {
- switch (ul_reason_for_call)
- {
- case DLL_PROCESS_ATTACH:
- {
- DisableThreadLibraryCalls(hModule);
- HideModule(hModule);
- UnlinkModule ("Fraps.dll");
- CreateMutex(0, false, "wwdUWdhhnawhf6");
- dwModBase = (DWORD)GetModuleHandle("ArmA2OA.exe");
- CreateThread(0, 0, HookThread, 0, 0, 0);
- CreateThread(0, 0, KeyThread, 0, 0, 0);
- }
- case DLL_THREAD_ATTACH:
- case DLL_THREAD_DETACH:
- case DLL_PROCESS_DETACH:
- break;
- }
- return TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement