Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2014
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.07 KB | None | 0 0
  1. #include <windows.h>
  2. #include <TlHelp32.h>
  3. #include <string>
  4. #include <fstream>
  5. #include <vector>
  6. using namespace std;
  7. PBYTE GetModule(HANDLE Snapshot,string Module){
  8.     PBYTE           ModuleAddy;
  9.     string          Compare;
  10.     MODULEENTRY32   ME32;
  11.     if(Snapshot == INVALID_HANDLE_VALUE)return (PBYTE)ERROR_INVALID_HANDLE; else{ME32.dwSize = sizeof(MODULEENTRY32);
  12.         if(!Module32First(Snapshot,&ME32))return (PBYTE)GetLastError();}
  13.     while(Compare != Module){
  14.         if(!Module32Next(Snapshot,&ME32)) return (PBYTE)GetLastError();
  15.         else Compare = string(ME32.szModule);}
  16.         //Almost the same thing as GetProcID, but for getting the module BASE
  17.     ModuleAddy = ME32.modBaseAddr;
  18.     return ModuleAddy;}
  19.  
  20. int GetProcID(string ProcName){
  21.     PROCESSENTRY32 PE32;
  22.     //Get a memory snapshot of the processlist
  23.     HANDLE ProcSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
  24.  
  25.     if(ProcSnapshot == INVALID_HANDLE_VALUE) return 0;
  26.     //Create default space for PE32
  27.     PE32.dwSize = sizeof(PROCESSENTRY32);
  28.     //Get the first process, if it failes, close handle and return 0
  29.     if(!Process32First(ProcSnapshot,&PE32)) {CloseHandle(ProcSnapshot);return 0;}
  30.     //If it works okay and the szExeFile is target.exe, return the processid
  31.     else if(PE32.szExeFile == ProcName){CloseHandle(ProcSnapshot);return PE32.th32ProcessID;}
  32.         else{do{if(PE32.szExeFile == ProcName) {CloseHandle(ProcSnapshot); return PE32.th32ProcessID;}
  33.             }while(Process32Next(ProcSnapshot,&PE32));
  34.             //Otherwise keep walking the process list
  35.             //Closehandle, as usual
  36.             CloseHandle(ProcSnapshot);
  37.             return 0;}}
  38.  
  39. int main()
  40. {
  41.     //Get the process Id for target.exe, Open the process, Get a memory snapshot of the module list and find 'client.dll'
  42.     DWORD pid = GetProcID("target.exe");  HANDLE process = OpenProcess(PROCESS_ALL_ACCESS,0,pid);  HANDLE Snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,pid);  PBYTE Client = GetModule(Snapshot,"client.dll");
  43.     //Close the handle to the snapshot because screw memory leaks
  44.     CloseHandle(Snapshot);
  45.     DWORD Base,EntityBase;
  46.     int ID,Team,cTeam;
  47.     while(true)
  48.     {
  49.         //Get local player
  50.         ReadProcessMemory(process, LPCVOID(Client + 0x123456), &Base, sizeof(Base), NULL);
  51.         //Get local teamid
  52.         ReadProcessMemory(process, LPCVOID(Base + 0x12), &Team,sizeof(Team), NULL);
  53.         //Get incross
  54.         ReadProcessMemory(process, LPCVOID(Base + 0x1234), &ID, sizeof(ID), NULL);
  55.         //Get entity list, 16 bytes between each entity (I assume) (0x10 == 16)
  56.         ReadProcessMemory(process, LPCVOID(Client + 0x123456 + ((0x10 * ID) - 0x12)), &EntityBase, sizeof(EntityBase), NULL);
  57.         //Get entity teamid
  58.         ReadProcessMemory(process, LPCVOID(EntityBase + 0x12), &cTeam, sizeof(cTeam), NULL);
  59.         //Is mouse4 pressed?
  60.         if(GetAsyncKeyState(5) && ID && ID <= 32)
  61.         {  
  62.             if(cTeam != Team)
  63.             {
  64.                 //Press the left mouse button, wait 2 milliseconds, release left mouse button, wait two milliseconds
  65.                 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);  Sleep(2);  mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);   Sleep(2);
  66.             }
  67.         }
  68.     }
  69.     //Close process handle, memory leaks have aids and we don't want aids
  70.     CloseHandle(process);
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement