Advertisement
CHEAT_THE_GAME

Untitled

Aug 13th, 2017
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 11.38 KB | None | 0 0
  1. #include "AVA.hpp"
  2.  
  3. struct BoundingBox
  4. {
  5.     FVector vec1;
  6.     FVector vec2;
  7.     FVector vec3;
  8.     FVector vec4;
  9.     FVector vec5;
  10.     FVector vec6;
  11.     FVector vec7;
  12.     FVector vec8;
  13. };
  14.  
  15. BOOL CarregaFonte = false;
  16. INT  MenuSelection = 1;
  17. INT  Current = true;
  18.  
  19. INT PosX = 30;
  20. INT PosY = 70;
  21. INT Posy = 60;
  22.  
  23. CHAR* Opt_Opções[] = { "0", "1" };
  24. CHAR* Opt_Menu[] = { "+", "-" };
  25.  
  26. int iCount;
  27. BoundingBox boundingBox[20];
  28.  
  29. int a;
  30. int b;
  31. template <typename T>
  32.  
  33. T GetInstanceOf(UClass* pClass)
  34. {
  35.     UObject* pObjectInstance = nullptr;
  36.  
  37.     //Check if GObjObjects does not equal zero
  38.     if (UObject::GObjObjects())
  39.     {
  40.         //Loop through all objects
  41.         for (int i = 0; i < UObject::GObjObjects()->Count; ++i)
  42.         {
  43.             //IsReadableMemory check to avoid crashes
  44.             if (UObject::GObjObjects()->Data[i])
  45.             {
  46.                 //Get the current object
  47.                 UObject* pCheckObject = (*UObject::GObjObjects())(i);
  48.  
  49.                 //Validate the current object
  50.                 if (pCheckObject && pCheckObject->IsA(pClass))
  51.                 {
  52.                     //Check if the current object is the default object for its class
  53.                     if (!strstr(pCheckObject->GetFullName(), "Default"))
  54.                         pObjectInstance = pCheckObject;
  55.                 }
  56.             }
  57.         }
  58.     }
  59.  
  60.     return (T)pObjectInstance;
  61. };
  62.  
  63.  
  64. bool inline IsValidTarget(APawn *pTarget)
  65. {
  66.     return pTarget
  67.         && !pTarget->bDeleteMe
  68.         && pTarget->Mesh
  69.         && pTarget->Health > 0
  70.         && pTarget->PlayerReplicationInfo;
  71. }
  72.  
  73.  
  74. FVector WorldToScreen(UCanvas *pCanvas, AavaPlayerController *pPlayerController, const FVector& vector)
  75. // you will have to understand 3d math before understand this
  76. {
  77.     FVector delta = pPlayerController->Subtract_VectorVector(vector, pPlayerController->CalcViewLocation);
  78.  
  79.     FVector axisX;
  80.     FVector axisY;
  81.     FVector axisZ;
  82.     pCanvas->GetAxes(pPlayerController->CalcViewRotation, &axisX, &axisY, &axisZ);
  83.  
  84.     FVector transformed;
  85.     transformed.X = pPlayerController->Dot_VectorVector(delta, axisY);
  86.     transformed.Y = pPlayerController->Dot_VectorVector(delta, axisZ);
  87.     transformed.Z = pPlayerController->Dot_VectorVector(delta, axisX);
  88.  
  89.     if (transformed.Z < 1.00f)
  90.         transformed.Z = 1.00f;
  91.  
  92.     float FOVAngle = pPlayerController->GetFOVAngle();
  93.  
  94.     FVector result;
  95.     result.X = (pCanvas->ClipX / 2.0f) + transformed.X * ((pCanvas->ClipX / 2.0f) / pPlayerController->Tan(FOVAngle * CONST_Pi / 360.0f)) / transformed.Z;
  96.     result.Y = (pCanvas->ClipY / 2.0f) + -transformed.Y * ((pCanvas->ClipX / 2.0f) / pPlayerController->Tan(FOVAngle * CONST_Pi / 360.0f)) / transformed.Z;
  97.     result.Z = 0;
  98.  
  99.     return result;
  100. }
  101.  
  102. void BoundingBox3D(UCanvas *pCanvas, AavaPlayerController *pPlayerController, APawn *pPawn, BoundingBox& boundingBox)
  103. {
  104.     FBox box;
  105.     pPawn->GetComponentsBoundingBox(&box);
  106.  
  107.     if (box.IsValid)
  108.          
  109.     {
  110.         boundingBox.vec1 = WorldToScreen(pCanvas, pPlayerController, box.Min);
  111.         boundingBox.vec2 = WorldToScreen(pCanvas, pPlayerController, box.Max);
  112.         boundingBox.vec3 = box.Min;
  113.         boundingBox.vec3.X = box.Max.X;
  114.         boundingBox.vec3 = WorldToScreen(pCanvas, pPlayerController, boundingBox.vec3);
  115.         boundingBox.vec4 = box.Min;
  116.         boundingBox.vec4.Y = box.Max.Y;
  117.         boundingBox.vec4 = WorldToScreen(pCanvas, pPlayerController, boundingBox.vec4);
  118.         boundingBox.vec5 = box.Min;
  119.         boundingBox.vec5.Z = box.Max.Z;
  120.         boundingBox.vec5 = WorldToScreen(pCanvas, pPlayerController, boundingBox.vec5);
  121.         boundingBox.vec6 = box.Max;
  122.         boundingBox.vec6.X = box.Min.X;
  123.         boundingBox.vec6 = WorldToScreen(pCanvas, pPlayerController, boundingBox.vec6);
  124.         boundingBox.vec7 = box.Max;
  125.         boundingBox.vec7.Y = box.Min.Y;
  126.         boundingBox.vec7 = WorldToScreen(pCanvas, pPlayerController, boundingBox.vec7);
  127.         boundingBox.vec8 = box.Max;
  128.         boundingBox.vec8.Z = box.Min.Z;
  129.         boundingBox.vec8 = WorldToScreen(pCanvas, pPlayerController, boundingBox.vec8);
  130.     }
  131. }
  132.  
  133. //void DrawString(LPCSTR pString, int X, int Y, D3DCOLOR Color)
  134. //{
  135. //  RECT rect = { X, Y, 0, 0 };
  136. //  pD3DFont->DrawText(NULL, pString, -1, &rect, DT_NOCLIP, Color);
  137. //}
  138.  
  139. void Draw2DLine(const FVector& f, const FVector& t, D3DCOLOR Color)
  140. {
  141.     D3DXVECTOR2 vLine[2];
  142.     vLine[0].x = f.X;
  143.     vLine[0].y = f.Y;
  144.     vLine[1].x = t.X;
  145.     vLine[1].y = t.Y;
  146.     pLine->Draw(vLine, 2, Color);
  147. }
  148.  
  149. HRESULT WINAPI hkEndScene(LPDIRECT3DDEVICE9 pDevice) // try it xD
  150. {
  151.     //if (!pD3DFont) // inizialize font
  152.     //  D3DXCreateFont(pDevice, 21, 0, FW_THIN, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Courier New", &pD3DFont);
  153.     if (GetAsyncKeyState(VK_HOME) & 1)
  154.     {
  155.         BaseJanela.Mostrar = !BaseJanela.Mostrar;
  156.     }
  157.  
  158.     if (BaseJanela.Mostrar)
  159.     {
  160.  
  161.  
  162.         Current = 1;
  163.  
  164.         if (GetAsyncKeyState(VK_UP) & 1)
  165.             MenuSelection--;
  166.  
  167.         if (GetAsyncKeyState(VK_DOWN) & 1)
  168.             MenuSelection++;
  169.  
  170.  
  171.         DrawRect(pDevice, PosX - 10, PosY - 22, 180, 20, Red);
  172.         GravaTexto(PosX + 38, PosY - 20, Orange, Fonte[13], "Elite Cheats");
  173.         Base(pDevice, PosX - 10, Posy + 2 + (MenuSelection * 15), 180, 13, Green, Green, Green);
  174.  
  175.  
  176.         Additem("UAV", 1, Item[1], 0, Opt_Opções, pDevice);
  177.         Additem("ESP", 1, Item[2], 0, Opt_Opções, pDevice);
  178.         /*  Additem("Unlimited Ammo", 1, Item[3], 0, Opt_Opções, pDevice);
  179.         Additem("Super Weapons", 1, Item[4], 0, Opt_Opções, pDevice);
  180.         Additem("Fast Reload", 1, Item[5], 0, Opt_Opções, pDevice);
  181.         Additem("Nospread", 1, Item[6], 0, Opt_Opções, pDevice);
  182.         Additem("Colors Red/Green", 1, Item[7], 0, Opt_Opções, pDevice);
  183.         Additem("Anti AFK Kick", 1, Item[9], 0, Opt_Opções, pDevice);
  184.         Additem("Anti Kick", 1, Item[10], 0, Opt_Opções, pDevice);
  185.         Additem("Night Vision", 1, Item[11], 0, Opt_Opções, pDevice);
  186.         Additem("No Recoil", 1, Item[12], 0, Opt_Opções, pDevice);
  187.         Additem("No Flash", 1, Item[13], 0, Opt_Opções, pDevice);
  188.         Additem("Rapid Fire", 1, Item[14], 0, Opt_Opções, pDevice);
  189.         Additem("Player Bob", 1, Item[15], 0, Opt_Opções, pDevice);
  190.         Additem("CrossHair D3D", 1, Item[8], 0, Opt_Opções, pDevice);
  191.         Additem("CrossHair Custom_1", 1, Item[16], 0, Opt_Opções, pDevice);
  192.         Additem("CrossHair Custom_2", 1, Item[17], 0, Opt_Opções, pDevice);
  193.         Additem("CrossHair Custom_3", 1, Item[18], 0, Opt_Opções, pDevice);
  194.         Additem("CrossHair Custom_4", 1, Item[20], 0, Opt_Opções, pDevice);
  195.         Additem("CrossHair Custom_5", 1, Item[22], 0, Opt_Opções, pDevice);
  196.         Additem("CrossHair Custom_6", 1, Item[23], 0, Opt_Opções, pDevice);
  197.         Additem("Hide CrossHair", 1, Item[24], 0, Opt_Opções, pDevice);
  198.         Additem("Restore CrossHair", 1, Item[21], 0, Opt_Opções, pDevice);
  199.         Additem("Names and Healthbars", 1, Item[19], 0, Opt_Opções, pDevice);*/
  200.  
  201.  
  202.         if (MenuSelection >= Current)
  203.             MenuSelection = 1;
  204.  
  205.         if (MenuSelection < 1)
  206.             MenuSelection = Current - 1;
  207.  
  208.  
  209.  
  210.  
  211.     }
  212.  
  213.  
  214.  
  215.     if (!pLine)
  216.         D3DXCreateLine(pDevice, &pLine); // inizialize lines
  217.  
  218.     //DrawString("AVA Hack", 10, 10, D3DCOLOR_RED);  // draw what i actually am
  219.      
  220.     for (int i = 0; i < iCount; i++)
  221.     {
  222.         auto& _boundingBox = boundingBox[i];
  223.  
  224.         // do it urself xD
  225.         Draw2DLine(_boundingBox.vec1, _boundingBox.vec5, D3DCOLOR_ARGB(255, 255, 0, 0));
  226.         Draw2DLine(_boundingBox.vec2, _boundingBox.vec8, D3DCOLOR_ARGB(255, 255, 0, 0));
  227.         Draw2DLine(_boundingBox.vec3, _boundingBox.vec7, D3DCOLOR_ARGB(255, 255, 0, 0));
  228.         Draw2DLine(_boundingBox.vec4, _boundingBox.vec6, D3DCOLOR_ARGB(255, 255, 0, 0));
  229.         Draw2DLine(_boundingBox.vec1, _boundingBox.vec3, D3DCOLOR_ARGB(255, 255, 0, 0));
  230.         Draw2DLine(_boundingBox.vec1, _boundingBox.vec4, D3DCOLOR_ARGB(255, 255, 0, 0));
  231.         Draw2DLine(_boundingBox.vec8, _boundingBox.vec3, D3DCOLOR_ARGB(255, 255, 0, 0));
  232.         Draw2DLine(_boundingBox.vec8, _boundingBox.vec4, D3DCOLOR_ARGB(255, 255, 0, 0));
  233.         Draw2DLine(_boundingBox.vec2, _boundingBox.vec6, D3DCOLOR_ARGB(255, 255, 0, 0));
  234.         Draw2DLine(_boundingBox.vec2, _boundingBox.vec7, D3DCOLOR_ARGB(255, 255, 0, 0));
  235.         Draw2DLine(_boundingBox.vec5, _boundingBox.vec6, D3DCOLOR_ARGB(255, 255, 0, 0));
  236.         Draw2DLine(_boundingBox.vec5, _boundingBox.vec7, D3DCOLOR_ARGB(255, 255, 0, 0));
  237.     }
  238.  
  239.    
  240.     return oEndScene(pDevice); // call original EndScene so that i can do whatever game does
  241. }
  242.  
  243.  
  244.  
  245. void Patch_D3DVMT()//are you getting EndScene Hook message in console? ok try now
  246. {
  247.     while (true) // try now
  248.     {
  249.         Sleep(1); // anti-CPU overload
  250.         static DWORD ES_addr = NULL;
  251.         if (!ES_addr)
  252.  
  253.             ES_addr = *(DWORD*)(FindPattern("AVA.exe", ES_Pattern, ES_Mask) + ES_Offset);
  254.  
  255.         DWORD dwDevice = *(DWORD*)(ES_addr); // pDevice
  256.  
  257.         //DWORD dwDevice = *(DWORD*)(0x1B5CC84); // pDevice
  258.  
  259.         if (!dwDevice) continue; // wait for pDevice initialized
  260.  
  261.         DWORD dwVMT = *(DWORD*)(dwDevice);// VMT
  262.  
  263.         if (!dwVMT) continue; // wait for VMT initialized
  264.  
  265.         DWORD dwEndScene = *(DWORD*)(dwVMT + dwOff); // EndScene
  266.  
  267.         if (!dwEndScene) continue; // wait for EndScene initialized
  268.  
  269.         if (!oEndScene) // get original EndScene function pointer
  270.             oEndScene = (tEndScene)dwEndScene;
  271.  
  272.         if (dwEndScene != (DWORD)&hkEndScene)                   // if EndScene called by game is not your EndScene function
  273.         {
  274.             DWORD dwOldProtect;
  275.             VirtualProtect((LPVOID)(dwVMT + dwOff), 4, PAGE_EXECUTE_READWRITE, &dwOldProtect); // unprotect memory giving write access
  276.             *(DWORD*)(dwVMT + dwOff) = (DWORD)&hkEndScene;      // replace game EndScene with your EndScene
  277.             VirtualProtect((LPVOID)(dwVMT + dwOff), 4, dwOldProtect, NULL); // restore previous protection
  278.         }
  279.  
  280.     } // simple until here?
  281. }
  282.  
  283.  
  284. void OnAttach()
  285. {
  286.     CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Patch_D3DVMT, NULL, NULL, NULL);
  287.  
  288.     unsigned long address;
  289.    
  290.     Beep(750, 300);  
  291.     AllocConsole();
  292.  
  293.     //SetConsoleTitle("AVA PUBLIC VERSION 1.3");
  294.  
  295.     //FILE *file = nullptr;
  296.     //freopen_s(&file, "CONOUT$", "w", stdout);
  297.     //freopen_s(&file, "CONIN$", "r", stdin);
  298.  
  299.    
  300.  
  301.  
  302.     while (!UObject::GObjObjects()
  303.         || UObject::GObjObjects()->Count < 100001)
  304.         Sleep(100);
  305.  
  306.     UGameEngine *pGameEngine = nullptr;
  307.  
  308.     while (!pGameEngine
  309.         || !pGameEngine->IsA(UGameEngine::StaticClass()))
  310.     {
  311.         pGameEngine = GetInstanceOf<UGameEngine*>(UGameEngine::StaticClass());
  312.         Sleep(100);
  313.     }
  314.  
  315.     AavaPlayerController *pPlayerController = nullptr;
  316.     UCanvas *pCanvas = nullptr;
  317.  
  318.     while (true)
  319.     {
  320.         if (!pGameEngine
  321.             || !pGameEngine->GamePlayers.Data)
  322.             continue;
  323.  
  324.         while (!pCanvas
  325.             || !pCanvas->IsA(UCanvas::StaticClass()))
  326.         {
  327.             pCanvas = GetInstanceOf<UCanvas*>(UCanvas::StaticClass());
  328.             Sleep(100);
  329.         }
  330.  
  331.         pPlayerController = (AavaPlayerController*)pGameEngine->GamePlayers.Data[0]->Actor;
  332.  
  333.         if (!pPlayerController
  334.             || !pPlayerController->IsA(AavaPlayerController::StaticClass()))
  335.             continue;
  336.  
  337.         AavaPawn *pPawn = (AavaPawn*)pPlayerController->Pawn;
  338.  
  339.         if (!pPawn
  340.             || !pPawn->IsA(AavaPawn::StaticClass())
  341.             || !pPawn->WorldInfo)
  342.             continue;
  343.  
  344.         iCount = 0;
  345.  
  346.  
  347.         // Loop through the pawns
  348.         for (APawn *pTarget = pPawn->WorldInfo->PawnList; pTarget; pTarget = pTarget->NextPawn)
  349.         {
  350.             if (pTarget == pPawn
  351.                 || !pTarget->IsA(AavaPawn::StaticClass())
  352.                 || !IsValidTarget(pTarget)
  353.                 || pPlayerController->IsSameTeam(pTarget))
  354.                 continue;
  355.  
  356.             if (Item[1] == 1)
  357.             {
  358.                 ((AavaPawn*)pTarget)->bTargetted = true;
  359.             }
  360.             if (Item[1] == 0)
  361.             {
  362.                 ((AavaPawn*)pTarget)->bTargetted = false;
  363.             }
  364.             if (Item[2] == 1)
  365.             {
  366.                 BoundingBox3D(pCanvas, pPlayerController, pTarget, boundingBox[iCount++]);
  367.             }
  368.             if (Item[2] == 0)
  369.             {
  370.                
  371.             }
  372.                  
  373.         }
  374.  
  375.         Sleep(100);
  376.     }
  377. }
  378.  
  379.  
  380. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  381. {
  382.     switch (dwReason)
  383.     {
  384.     case DLL_PROCESS_ATTACH:
  385.         DisableThreadLibraryCalls(hInstance);
  386.         CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)OnAttach, NULL, NULL, NULL);
  387.     }
  388.  
  389.     return TRUE;
  390. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement