Simple2012

Untitled

Oct 17th, 2013
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.22 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "memoryReading.h"
  3. #include "stdafx.h"
  4. #include <tchar.h>
  5. #include <Windows.h>
  6. #include <stdio.h>
  7. #include <psapi.h>
  8. #include <TlHelp32.h>
  9. #include <iostream>
  10. #include <cstring>
  11. #include <tchar.h>
  12. #include <vector>
  13.  
  14. DWORD get_start_address(DWORD TibianicPID)
  15. {
  16.     // Handle for the snapshot
  17.     HANDLE hProcessSnap = NULL;
  18.  
  19.     // TH32CS_SNAPMODULE Includes all modules of the process specified in th32ProcessID in the snapshot.
  20.     hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, TibianicPID);
  21.  
  22.     if (hProcessSnap == INVALID_HANDLE_VALUE)
  23.         return 0;
  24.  
  25.     MODULEENTRY32 the;
  26.     the.dwSize = sizeof(MODULEENTRY32);
  27.     const char *dllName = "Tibianic.dll";
  28.  
  29.     BOOL bret = Module32First( hProcessSnap, &the); // Initiate bret with module
  30.     while(bret)
  31.     {
  32.         if(wcscmp(the.szModule, _T("Tibianic.dll"))==0) // Compare with current value
  33.             return (DWORD)the.modBaseAddr;
  34.                
  35.         // Fetch next dll loaded address
  36.         bret = Module32Next(hProcessSnap, &the);
  37.     }
  38.     return 0;
  39. }
  40.  
  41.  
  42.  
  43. int readMemory( void )
  44. {
  45.     DWORD pAddress3 = 0x00400000; // This will store our value we read.
  46.     DWORD pAddressHpBase;
  47.     DWORD pBattleList;
  48.    
  49.     //vector<DWORD> v = {};
  50.     DWORD offset5 = 0x378;
  51.     DWORD offset4 = 0x218;
  52.     DWORD offset3 = 0x10C;
  53.     DWORD offset2 = 0x1C0;
  54.     DWORD offset1 = 0x78;
  55.     DWORD offset0 = 0xF3090;
  56.     //TCHAR Modname[MAX_PATH];
  57.  
  58.     HWND hWnd = FindWindow( NULL , _T("Tibianic Client") );
  59.     DWORD TibianicPID; //This will store our Process ID, used to read/write into the memory
  60.     GetWindowThreadProcessId(hWnd, &TibianicPID); //Get the process id and place it in pid
  61.  
  62.     DWORD aProcesses[1024];
  63.     DWORD cbNeeded;
  64.  
  65.     // Get the list of process identifiers.
  66.     if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
  67.         return 1;
  68.  
  69.  
  70.  
  71.    
  72.     pAddress3 = get_start_address(TibianicPID);
  73.     pAddressHpBase = pAddress3;
  74.     pBattleList = pAddress3;
  75.  
  76.         /* Reading Memory & Opening process */
  77.         HANDLE phandle = OpenProcess(PROCESS_VM_READ,0, TibianicPID); // Get permission to read
  78.     if(!phandle){ // Once again, if it fails, tell us
  79.             std::cout <<"Error message: " << GetLastError() << " Dvs Access denied" << std::endl;
  80.             std::cin.get();
  81.             return 0;
  82.     }
  83.     //std::cout << "Base address is: " << pAddress3 << std::endl;
  84.     ReadProcessMemory(phandle,(void*)(pAddressHpBase+0xF40F0),&pAddressHpBase,sizeof(pAddressHpBase),0);
  85.     pAddressHpBase += 4;
  86.     ReadProcessMemory(phandle,(void*)(pAddressHpBase),&pAddressHpBase,sizeof(pAddressHpBase),0);
  87.     std::cout << "Your HP is: " << pAddressHpBase << std::endl;
  88.  
  89.     //std::cout << "Base address is: " << pAddress3 << std::endl;
  90.     ReadProcessMemory(phandle,(void*)(pBattleList+0x319D68),&pBattleList,sizeof(pBattleList),0);
  91.     pAddressHpBase += 0x12A;
  92.     ReadProcessMemory(phandle,(void*)(pBattleList),&pBattleList,sizeof(pBattleList),0);
  93.     std::cout << "Battle list: " << (char)pBattleList << std::endl;
  94.  
  95.  
  96.     SIZE_T size;
  97.     ReadProcessMemory(phandle,(void*)(pAddress3+0xF40F0),&pAddress3,sizeof(pAddress3),&size);
  98.     ReadProcessMemory(phandle,(void*)(pAddress3),&pAddress3,sizeof(pAddress3),&size);
  99.     std::cout << "You mana is: " << pAddress3 << std::endl;
  100.  
  101.     std::cin.get();
  102.     return 0;
  103. }
Advertisement
Add Comment
Please, Sign In to add comment