Advertisement
Guest User

Untitled

a guest
Dec 31st, 2013
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.97 KB | None | 0 0
  1. #include <Windows.h>
  2. #include <iostream>
  3. #include <string>
  4. #include <ctime>
  5.  
  6.  
  7. #define F6_KEY 0x75
  8.  
  9. using namespace std;
  10.  
  11. string GameName = "Cube";
  12. LPCSTR LGameWindow = "Cube";
  13. string GameStatus = "";
  14.  
  15. HWND hGameWindow = NULL;
  16. HANDLE hProcHandle = NULL;
  17. DWORD dwPRocID = NULL;
  18.  
  19. bool GameFound = false;
  20. bool Running = false;
  21. bool UpdateConsole;
  22.  
  23. //Ammo Variables
  24. DWORD BaseAddr = 0x0036B1C8;
  25.  
  26.  
  27. int XPNum = 0;
  28. bool XPPressed;
  29. DWORD XPOffs[] = {0x39C,0x194};
  30. BYTE ONEHUNDERED[] = {0x4,0x6,0x0,0x0};
  31.  
  32. int LVLSAdded;
  33. bool LVLPressed;
  34. DWORD LVLOffs[] = {0x39C,0x190};
  35. BYTE ONE[] = {0x1,0x0,0x0,0x0};
  36.  
  37. bool Godmode;
  38. DWORD HPOffs[] = {0x16C, 0x39C};
  39. BYTE LEET[] = {0x39,0x5,0x0,0x0};
  40.  
  41. DWORD FindDMAAddr(int PtrLvl, HANDLE hProcHandle, DWORD Offsets[], DWORD BaseAddress) //could be (int PtrLvl, HANDLE hProcHandle, DWORD Offsets[], DWORD BaseAddress) but baseaddr is same for all and global
  42. {
  43.     DWORD ptr = BaseAddress;
  44.     DWORD pTemp;
  45.    
  46.     DWORD ptrAddr;
  47.     for(int i = 0; i < PtrLvl; i++)
  48.     {
  49.         if(i==0)
  50.         {                                                          //v 4
  51.             ReadProcessMemory(hProcHandle,(LPCVOID)ptr,&pTemp,sizeof(DWORD),NULL);
  52.         }
  53.  
  54.         ptrAddr = pTemp + Offsets[i];
  55.  
  56.         ReadProcessMemory(hProcHandle,(LPCVOID)ptrAddr,&pTemp,sizeof(DWORD),NULL);
  57.     }
  58.     return ptrAddr;
  59. }
  60.  
  61. void WriteToMemory(HANDLE hProcHandle)
  62. {
  63.     if(XPPressed)
  64.     {  
  65.         DWORD AddrToWrite = FindDMAAddr(2, hProcHandle, XPOffs, BaseAddr);
  66.  
  67.         int curXP=0;                   
  68.  
  69.         ReadProcessMemory(hProcHandle,(BYTE*)AddrToWrite,&curXP,sizeof(int),0);
  70.  
  71.         curXP += 100;
  72.  
  73.         WriteProcessMemory(hProcHandle,(BYTE*)AddrToWrite, &ONEHUNDERED, sizeof(ONEHUNDERED),0);
  74.  
  75.         XPNum++;
  76.  
  77.         XPPressed = false;
  78.     }
  79.     if(LVLSAdded)
  80.     {
  81.     }
  82.     if(Godmode)
  83.     {
  84.     }
  85. }
  86.  
  87. int main()
  88. {
  89.     SetConsoleTitle("Foxxy's Cubeworld Trainer");
  90.  
  91.     int timesinceupdate = clock();
  92.     int GameAvailTMR = clock();
  93.     int PressTMR = clock();
  94.    
  95.     UpdateConsole = true;
  96.  
  97.     while(!GetAsyncKeyState(F6_KEY))
  98.     {
  99.         if(clock() - GameAvailTMR > 100)
  100.         {
  101.             GameAvailTMR = clock();
  102.             GameFound = false;
  103.             HWND hGameWindow = FindWindow(NULL, LGameWindow);
  104.             if(hGameWindow)
  105.             {
  106.                 GetWindowThreadProcessId(hGameWindow, &dwPRocID);
  107.                 if(dwPRocID != 0)
  108.                 {
  109.                     hProcHandle = OpenProcess(PROCESS_ALL_ACCESS, false, dwPRocID);
  110.  
  111.                     if(hProcHandle == INVALID_HANDLE_VALUE || hProcHandle == NULL)
  112.                     {
  113.                         GameStatus = "Failed to open process for valid handle";
  114.                     }
  115.                     else
  116.                     {
  117.                         GameStatus = "Found CubeWorld";
  118.                         GameFound = true;
  119.                     }
  120.                 }
  121.                 else
  122.                 {
  123.                     GameStatus = "Failed to get process ID";
  124.                 }
  125.             }
  126.             else
  127.             {
  128.                 GameStatus = "Cubeworld not found";
  129.             }
  130.  
  131.             if(UpdateConsole || clock() - timesinceupdate > 5000)
  132.             {
  133.                 system("cls");         
  134.                 cout << "Foxxy's Cubeworld Trainer, some credit to Fleep's Hacking Tutorials"<<endl;
  135.                 std::cout << "Status: " << GameStatus <<endl<<endl;
  136.  
  137.                 cout << "[Numpad 1] Godmode: "<<endl;
  138.  
  139.                 cout << "[Numpad 2] Infinite MP: NYI" <<endl;
  140.  
  141.                 cout << "[Numpad 3] +1 Level: "<<LVLSAdded<<endl;
  142.  
  143.                 cout << "[Numpad +] +100 XP: "<< XPNum*100<<endl;
  144.  
  145.                 cout << "[F6] Exit"<<endl;;
  146.  
  147.                 UpdateConsole = false;
  148.                 timesinceupdate = clock();
  149.  
  150.             }
  151.             if(GameFound)
  152.             {
  153.                 WriteToMemory(hProcHandle);
  154.             }
  155.         }
  156.  
  157.         if(clock() - PressTMR > 250)
  158.         {
  159.             if(GameFound)
  160.             {
  161.                 if(GetAsyncKeyState(VK_NUMPAD1))
  162.                 {
  163.                     PressTMR = clock();
  164.                     UpdateConsole = true;
  165.                     Godmode = !Godmode;
  166.                 }
  167.  
  168.                 if(GetAsyncKeyState(VK_NUMPAD2))
  169.                 {
  170.                     PressTMR = clock();
  171.                     UpdateConsole = true;
  172.                     cout << "NYI"<<endl;
  173.                 }
  174.  
  175.                 if(GetAsyncKeyState(VK_NUMPAD3))
  176.                 {
  177.                     PressTMR = clock();
  178.                     UpdateConsole = true;
  179.                     LVLPressed = true;
  180.                 }
  181.                 if(GetAsyncKeyState(VK_NUMPAD4))
  182.                 {
  183.                     PressTMR = clock();
  184.                     UpdateConsole = true;
  185.                     XPPressed = true;
  186.                 }
  187.  
  188.             }
  189.         }
  190.     }
  191.  
  192.     CloseHandle(hProcHandle);
  193.     CloseHandle(hGameWindow);
  194. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement