Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <TlHelp32.h>
- #include <string>
- #include <fstream>
- #include <vector>
- using namespace std;
- PBYTE GetModule(HANDLE Snapshot,string Module){
- PBYTE ModuleAddy;
- string Compare;
- MODULEENTRY32 ME32;
- if(Snapshot == INVALID_HANDLE_VALUE)return (PBYTE)ERROR_INVALID_HANDLE; else{ME32.dwSize = sizeof(MODULEENTRY32);
- if(!Module32First(Snapshot,&ME32))return (PBYTE)GetLastError();}
- while(Compare != Module){
- if(!Module32Next(Snapshot,&ME32)) return (PBYTE)GetLastError();
- else Compare = string(ME32.szModule);}
- //Almost the same thing as GetProcID, but for getting the module BASE
- ModuleAddy = ME32.modBaseAddr;
- return ModuleAddy;}
- int GetProcID(string ProcName){
- PROCESSENTRY32 PE32;
- //Get a memory snapshot of the processlist
- HANDLE ProcSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
- if(ProcSnapshot == INVALID_HANDLE_VALUE) return 0;
- //Create default space for PE32
- PE32.dwSize = sizeof(PROCESSENTRY32);
- //Get the first process, if it failes, close handle and return 0
- if(!Process32First(ProcSnapshot,&PE32)) {CloseHandle(ProcSnapshot);return 0;}
- //If it works okay and the szExeFile is target.exe, return the processid
- else if(PE32.szExeFile == ProcName){CloseHandle(ProcSnapshot);return PE32.th32ProcessID;}
- else{do{if(PE32.szExeFile == ProcName) {CloseHandle(ProcSnapshot); return PE32.th32ProcessID;}
- }while(Process32Next(ProcSnapshot,&PE32));
- //Otherwise keep walking the process list
- //Closehandle, as usual
- CloseHandle(ProcSnapshot);
- return 0;}}
- int main()
- {
- //Get the process Id for target.exe, Open the process, Get a memory snapshot of the module list and find 'client.dll'
- 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");
- //Close the handle to the snapshot because screw memory leaks
- CloseHandle(Snapshot);
- DWORD Base,EntityBase;
- int ID,Team,cTeam;
- while(true)
- {
- //Get local player
- ReadProcessMemory(process, LPCVOID(Client + 0x123456), &Base, sizeof(Base), NULL);
- //Get local teamid
- ReadProcessMemory(process, LPCVOID(Base + 0x12), &Team,sizeof(Team), NULL);
- //Get incross
- ReadProcessMemory(process, LPCVOID(Base + 0x1234), &ID, sizeof(ID), NULL);
- //Get entity list, 16 bytes between each entity (I assume) (0x10 == 16)
- ReadProcessMemory(process, LPCVOID(Client + 0x123456 + ((0x10 * ID) - 0x12)), &EntityBase, sizeof(EntityBase), NULL);
- //Get entity teamid
- ReadProcessMemory(process, LPCVOID(EntityBase + 0x12), &cTeam, sizeof(cTeam), NULL);
- //Is mouse4 pressed?
- if(GetAsyncKeyState(5) && ID && ID <= 32)
- {
- if(cTeam != Team)
- {
- //Press the left mouse button, wait 2 milliseconds, release left mouse button, wait two milliseconds
- mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); Sleep(2); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); Sleep(2);
- }
- }
- }
- //Close process handle, memory leaks have aids and we don't want aids
- CloseHandle(process);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement