Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h> // Needed to use windows api calls
- using namespace std;
- // need to be global so our keyboard hook can clean up
- HANDLE hProc = NULL;
- HWND Window = NULL;
- HHOOK hHook = NULL;
- HANDLE hThread = NULL;
- // haxx0r thread
- void haxxor (LPVOID Value)
- {
- while (TRUE)
- {
- WriteProcessMemory(hProc,(BYTE*)0x28ff1c,(LPDWORD)Value,sizeof(DWORD),NULL);
- Sleep (1000);
- }
- }
- // callback function for keyboard hook
- LRESULT CALLBACK KeyboardProc (int nCode, WPARAM wParam, LPARAM lParam)
- {
- if (nCode >= 0)
- {
- // struct to get virtual key codes
- KBDLLHOOKSTRUCT kbdStruct = *((KBDLLHOOKSTRUCT*)lParam);
- // if F1 pressed
- if (nCode == HC_ACTION && wParam == WM_KEYDOWN && kbdStruct.vkCode == VK_F1)
- {
- // kill haxx0r thread
- TerminateThread (hThread, 0);
- cout << "Terminating haxxor thread" << endl;
- // clean up
- CloseHandle (hThread);
- UnhookWindowsHookEx (hHook);
- CloseHandle(Window);
- CloseHandle(hProc);
- // exit
- ExitProcess (0);
- }
- }
- // if the message does not get processed
- return CallNextHookEx (0, nCode, wParam, lParam);
- }
- int main()
- {
- int Value = 999; //New intended health Value
- DWORD procID;
- Window = FindWindow(NULL,"Lose Health");
- if(!Window)
- {
- cout << "Window not found" << endl;
- return 1;
- }
- else
- {
- if (!GetWindowThreadProcessId(Window,&procID))
- {
- cerr << "Get window process ID error: " << GetLastError() << endl;
- return 1;
- }
- }
- if(procID != 0)
- hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, procID);
- if(!hProc)
- {
- cerr << "Can not open process: " << GetLastError() << endl;
- return 2;
- }
- else
- {
- cout << "Process Found Ready to write" << endl;
- cout << "Press F1 to terminate" << endl;
- }
- // set global keyboard hook to capture F1 key press
- hHook = SetWindowsHookEx (WH_KEYBOARD_LL, (HOOKPROC)KeyboardProc, GetModuleHandle (NULL), 0);
- // create threading function to haxx0r program
- hThread = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)haxxor, &Value, 0, NULL);
- if (hThread == NULL)
- {
- cerr << "Create thread error: " << GetLastError() << endl;
- // clean up
- UnhookWindowsHookEx (hHook);
- CloseHandle(Window);
- CloseHandle(hProc);
- // exit
- ExitProcess (1);
- }
- // this is for the message queue to be able to capture key presses
- MSG msg;
- while (GetMessage (&msg, NULL, 0, 0 ) > 0)
- {
- TranslateMessage (&msg);
- DispatchMessage (&msg);
- }
- UnhookWindowsHookEx (hHook);
- CloseHandle(Window);
- CloseHandle(hProc);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement