Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <Windows.h>
- #include <iostream>
- #include <TlHelp32.h>
- using namespace std;
- bool GetGameAccess();
- void PressKey(unsigned short KeyCode);
- ULONG GetModuleAddress(const char *szModuleName, const ULONG dwProcessId);
- int IsAlive();
- int GetMyTeam();
- int GetTargetTeam(int AimTarget);
- HANDLE phandle;
- ULONG ClientDLL;
- ULONG EngineDLL;
- int main()
- {
- bool Continue = GetGameAccess();
- if(Continue)
- {
- cout << "Triggerbot loaded!" << endl;
- int i = 0, AimTarget = 0; ULONG AimOffset=0;
- while(1)
- {
- ReadProcessMemory(phandle, LPCVOID(ClientDLL+0x780CD0), &i, sizeof(i), 0); AimOffset = i + 0x14A8;
- ReadProcessMemory(phandle, LPCVOID(AimOffset), &AimTarget, sizeof(AimTarget), NULL);
- if(AimTarget != 0)
- {
- int TargetTeam = GetTargetTeam(AimTarget);
- int MyTeam = GetMyTeam();
- int IsDead = IsAlive();
- if (TargetTeam != MyTeam &&
- (TargetTeam == 2 || TargetTeam == 3) &&
- (MyTeam == 2 || MyTeam == 3) &&
- IsDead == 0)
- PressKey(0x1A);
- }
- else
- Sleep(1);
- }
- }
- cin.get();
- }
- int IsAlive()
- {
- int Alive = 0;
- ReadProcessMemory(phandle, LPCVOID(ClientDLL + 0x77C5F0), &Alive, sizeof(Alive), NULL);
- return Alive;
- }
- int GetMyTeam()
- {
- int Value = 0, PlayerID = 0;
- ReadProcessMemory(phandle, LPCVOID(EngineDLL + 0x42CAD8), &PlayerID, sizeof(PlayerID), NULL);
- PlayerID = 0x6E4+(4*PlayerID);
- ReadProcessMemory(phandle, LPCVOID(ClientDLL + 0x74B430), &Value, sizeof(Value), NULL);
- ReadProcessMemory(phandle, LPCVOID(Value+0x26C), &Value, sizeof(Value), NULL);
- ReadProcessMemory(phandle, LPCVOID(Value+PlayerID), &Value, sizeof(Value), NULL);
- return Value;
- }
- int GetTargetTeam(int AimTarget)
- {
- int Value1 = 0, Value2 = 0;
- ReadProcessMemory(phandle, LPCVOID(ClientDLL + 0x74B430), &Value1, sizeof(Value1), NULL);
- ReadProcessMemory(phandle, LPCVOID(Value1 + 0x26C), &Value1, sizeof(Value1), NULL);
- Value2 = 0x6E4+(4*AimTarget);
- ReadProcessMemory(phandle, LPCVOID(Value1 + Value2), &Value1, sizeof(Value1), NULL);
- return Value1;
- }
- bool GetGameAccess()
- {
- ULONG pid;
- HWND hWnd;
- hWnd = FindWindow(NULL, "Counter-Strike Source");
- if(!hWnd)
- {
- cout <<"Game not found. Press enter to retry.\n";
- cin.get();
- main();
- return false;
- }
- else
- {
- GetWindowThreadProcessId(hWnd, &pid);
- phandle = OpenProcess(PROCESS_VM_READ, 0, pid);
- if(!phandle)
- {
- cout << "Could not get handle to window. Press enter to retry.\n";
- cin.get();
- main();
- return false;
- }
- else
- {
- ClientDLL = GetModuleAddress("client.dll", pid);
- EngineDLL = GetModuleAddress("engine.dll", pid);
- return true;
- }
- }
- }
- ULONG GetModuleAddress(const char *szModuleName, const ULONG dwProcessId)
- {
- if (!szModuleName || !dwProcessId)
- return 0;
- HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessId);
- if (hSnap == INVALID_HANDLE_VALUE)
- return 0;
- MODULEENTRY32 me;
- me.dwSize = sizeof(MODULEENTRY32);
- if (Module32First(hSnap, &me))
- {
- while (Module32Next(hSnap, &me))
- {
- if (strcmp(reinterpret_cast<const char*>(me.szModule), szModuleName) == 0)
- {
- CloseHandle(hSnap);
- return (ULONG)me.modBaseAddr;
- }
- }
- }
- CloseHandle(hSnap);
- return 0;
- }
- void PressKey(unsigned short KeyCode)
- {
- INPUT InputData;
- InputData.type = INPUT_KEYBOARD;
- InputData.ki.wScan = KeyCode;
- InputData.ki.time = (0);
- InputData.ki.dwExtraInfo = 0;
- InputData.ki.dwFlags = 0;
- SendInput(1, &InputData, sizeof(InputData));
- Sleep(10);
- InputData.ki.dwFlags = KEYEVENTF_KEYUP;
- SendInput(1, &InputData, sizeof(InputData));
- Sleep(10);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement