/* * HaloHook :: VoiDAPI Test Project * ----------------------------------- * Coded by: VoiDeD * * Uses: - VoiDAPI * - WinAPI * * Time Spent: 10 mins of converting C# code to * C++ code, and then 40 mins * figuring how to cast pointer types */ #include "voidapi.h" #include using namespace std; #define Menu 0x00718EBC //0x0 = in game #define MapName 0x400001E8 #define MouseX 0x402AD4B8 #define MouseY 0x402AD4BC #define Vehicle 0x006AC4F0//0x0 = not in vehicle #define HostLocationX 0x6AC4E4 #define HostLocationY 0x6AC4E8 #define HostLocationZ 0x6AC4EC #define HostScore 0x006B1340 v_window* wnd; v_window* haloHwnd; v_control* hookBtn; v_thread* hookThread; v_thread* graphicsThread; v_process* haloProc; bool hooked = false; byte inMenu; v_vector3* curPlayer; v_vector2* mouse; char* mapName = (char*)malloc(13); byte inVehicle; int score = 0; int mode = 0; void exit(v_window* wind) { if (hooked) { hookThread->kill(); graphicsThread->kill(); } wind->destroy(); } void hook_Tick(v_thread* thr, void* data) { while (hooked) { //check halo HWND halo = FindWindow(NULL, "Halo"); if (!halo) { hooked = false; graphicsThread->kill(); thr->kill(); wnd->destroy(); return; } //get values inMenu = haloProc->read_byte(Menu); mapName = haloProc->read_string(MapName, 13); curPlayer->set_x(*(float*)haloProc->read(HostLocationX, 4)); curPlayer->set_y(*(float*)haloProc->read(HostLocationY, 4)); curPlayer->set_z(*(float*)haloProc->read(HostLocationZ, 4)); mouse->set_x(*(float*)haloProc->read(MouseX, 4)); mouse->set_y(*(float*)haloProc->read(MouseY, 4)); inVehicle = haloProc->read_byte(Vehicle); score = *(int*)haloProc->read(HostScore, 4); if (inMenu == 0x0) { //check key presses byte key = HIBYTE(GetKeyState(VK_F1)); // score mode if (key) mode = 0; key = HIBYTE(GetKeyState(VK_ADD)); // + if (key) { switch (mode) { case 0: int temp = score + 1; haloProc->write(&temp, HostScore, 4); break; } thr->sleep(100); } key = HIBYTE(GetKeyState(VK_SUBTRACT)); // - if (key) { switch (mode) { case 0: int temp = score - 1; haloProc->write(&temp, HostScore, 4); break; } thr->sleep(100); } key = HIBYTE(GetKeyState(VK_MULTIPLY)); // * if (key) { switch (mode) { case 0: int temp = score * 2; haloProc->write(&temp, HostScore, 4); break; } thr->sleep(100); } key = HIBYTE(GetKeyState(VK_DIVIDE)); if (key) { switch (mode) { case 0: int temp = score / 2; haloProc->write(&temp, HostScore, 4); break; } thr->sleep(100); } } thr->sleep(1); } } void DrawStringInt(v_graphics* gfx, int x, int y, char* text, int value) { string str = text; str += v_convert::to_string(value); gfx->draw_string((char*)str.c_str(), new v_point(x, y)); } void DrawStringVector3(v_graphics* gfx, int x, int y, char* text, v_vector3* vect) { string str = text; str += v_convert::to_string(vect->get_x()); str += ", "; str += v_convert::to_string(vect->get_y()); str += ", "; str += v_convert::to_string(vect->get_z()); gfx->draw_string((char*)str.c_str(), new v_point(x, y)); } void DrawStringVector2(v_graphics* gfx, int x, int y, char* text, v_vector2* vect) { string str = text; str += v_convert::to_string(mouse->get_x()); str += ", "; str += v_convert::to_string(mouse->get_y()); gfx->draw_string((char*)str.c_str(), new v_point(x, y)); } void graphics_Tick(v_thread* thr, void* data) { v_graphics* gfx = new v_graphics(haloHwnd); gfx->set_textcolor(new v_color(255, 255, 0)); gfx->set_background(TRANSPARENT, new v_color(255, 255, 0)); while (hooked) { if (inMenu != 0x0) { gfx->draw_string("HaloHook v0.1C", new v_point(5, 5)); DrawStringInt(gfx, 5, 20, "Menu: ", inMenu); } else { gfx->draw_string("HaloHook v0.1C", new v_point(150, 5)); string str = "Map: "; str += mapName; gfx->draw_string((char*)str.c_str(), new v_point(150, 20)); DrawStringVector3(gfx, 150, 35, "Your Coords: ", curPlayer); DrawStringVector2(gfx, 150, 50, "Mouse Coords: ", mouse); DrawStringInt(gfx, 150, 65, "Vehicle: ", inVehicle); DrawStringInt(gfx, 150, 80, "Score: ", score); switch (mode) { case 0: gfx->draw_string("Mode: Score (F-Keys To Change)", new v_point(150, 110)); break; } } thr->sleep(1); } } void starthook(v_control* ctrl, void* wind) { if (hooked) return; haloHwnd = v_window::find_window("Halo", NULL); if (!haloHwnd) return; haloProc = new v_process(haloHwnd); if (haloProc == NULL) return; hooked = true; curPlayer = new v_vector3(0, 0, 0); mouse = new v_vector2(0, 0); hookThread = new v_thread(&hook_Tick, NULL); graphicsThread = new v_thread(&graphics_Tick, NULL); hookThread->start(); graphicsThread->start(); hookBtn->set_text("Hooked"); hookBtn->disable(); } int main() { wnd = new v_window("HaloHook", new v_size(300, 225)); wnd->register_event(WM_CLOSE, &exit); hookBtn = new v_button("Hook", new v_size(89, 23), new v_point(103, 163), wnd->get_hwnd()); hookBtn->register_event(BN_CLICKED, &starthook); wnd->add_control(hookBtn); wnd->show(); }