Advertisement
Guest User

gunz2_animation

a guest
Sep 5th, 2015
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.38 KB | None | 0 0
  1. // ConsoleApplication2.cpp : Defines the entry point for the console application.
  2. //
  3. #include "stdafx.h"
  4. #include <iostream>
  5. #include <Windows.h>
  6. using namespace std;
  7. HWND hwnd;
  8. HANDLE phandle;
  9. DWORD pid;
  10. int displayValue;
  11.  
  12. void printMenu()
  13. {
  14.     cout << "Running:\n Current Value:\t" << displayValue <<"\t"; // "Running: (nextline) Current Value :   103"
  15. }
  16.  
  17. void WriteToMemory(UINT address, int value)
  18. {
  19.     if (WriteProcessMemory(phandle, (void*)address, &value, sizeof(value), 0))
  20.     {
  21.         cout << "Something went wrong in WriteToMemory\n" << endl;
  22.     }
  23.     else
  24.     {
  25.         cout << "Overwrite success";
  26.     }
  27. }
  28.  
  29.  
  30. int ReadIntFromAddress(UINT address)
  31. {
  32.     int val = 0;
  33.     //cout << hex << address << endl;
  34.     if (ReadProcessMemory(phandle, (void*)address, &val, sizeof(val), NULL) == 0)
  35.     {
  36.         cout << "Something went wrong in ReadIntFromAddress" << endl; // print error code if something goes wrong
  37.     }
  38.     return val;
  39. }
  40. // Purpose:
  41. // Set animation to anything :v
  42. // thru the uparrow and downarrow keys scrolling thru the list
  43. //
  44. // up - down increase/decrease values of 'value' from pointer 'attackState'
  45. // right - quits program
  46. // thanks Matte :3 for coming up with 90% of code
  47. int main()
  48. {
  49.     cout << "Animation Set-er\n";
  50.     int attackState = 0x019F9F5C;
  51.     hwnd = FindWindowA(NULL, "Gunz the Second Duel 1.0.0.55354");
  52.  
  53.     if (!hwnd) //If none, display an error
  54.     {
  55.         cout << "Window not found!\n";
  56.         system("pause");
  57.         return 0;
  58.     }
  59.  
  60.     GetWindowThreadProcessId(hwnd, &pid); //Get the process id and place it in pid
  61.  
  62.                                           //phandle = OpenProcess(PROCESS_VM_READ, 0, pid); //Get permission to read
  63.  
  64.     phandle = OpenProcess(PROCESS_VM_WRITE | PROCESS_VM_READ | PROCESS_VM_OPERATION, 0, pid);
  65.     cout << "Test breakpoint 5\n";
  66.  
  67.     if (!phandle) //Once again, if it fails, tell us
  68.     {
  69.         cout << "Could not get handle!\n";
  70.         system("pause");
  71.         return 0;
  72.     }
  73.  
  74.     int value = (ReadIntFromAddress(attackState));
  75.     int turnoff = 0;
  76.     while (turnoff==0)
  77.     {
  78.  
  79.         if (GetAsyncKeyState(VK_UP)) // uparrow increases value by 1
  80.             value = value + 0x1;
  81.  
  82.         if (GetAsyncKeyState(VK_DOWN))//downarrow decreases value by 1
  83.             value = value - 0x1;
  84.  
  85.         if (GetAsyncKeyState(VK_RIGHT))//right arrow exits
  86.             turnoff = 1;
  87.  
  88.         displayValue = value;
  89.         WriteToMemory(attackState, value);
  90.         value = ReadIntFromAddress(attackState);
  91.         printMenu();
  92.         Sleep(500);
  93.         system("cls");
  94.     }
  95.     system("pause");
  96.     return 0;
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement