From 820cb4ca470f03200a85389ce965b8ec91dfdc15 Mon Sep 17 00:00:00 2001 From: xhz8s Date: Tue, 3 Aug 2021 13:17:11 +0200 Subject: [PATCH] made loopFly() more "understandable"? --- pHake/main.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/pHake/main.cpp b/pHake/main.cpp index 769fb16..6340040 100644 --- a/pHake/main.cpp +++ b/pHake/main.cpp @@ -189,7 +189,7 @@ void loopNeverWanted() { if (settings.neverwanted) { - if (world.localplayer.playerinfo.wanted_level() > 0) + if (world.localplayer.playerinfo.wanted_level() != 0) world.localplayer.playerinfo.wanted_level(0); } } @@ -257,20 +257,25 @@ void loopWeaponMax() void loopFly() // code explained in "SDK/_info_.txt" { static uint64_t position_base = 0; - if (position_base != world.localplayer.position.base()) // setup + if (position_base != world.localplayer.position.base()) { position_base = world.localplayer.position.base(); uint8_t position_base_patch[8]; - Uint64ToArray(position_base, position_base_patch); + Uint64ToArray(position_base, position_base_patch); // convert the position base to int array - std::vector mov_rcx_localplayer{ 0x48, 0xB9 }; - mov_rcx_localplayer.insert(std::end(mov_rcx_localplayer), std::begin(position_base_patch), std::end(position_base_patch)); + std::vector patch_beginning{ 0x48, 0xB9 }; // mov player location base to rcx + patch_beginning.insert(std::end(patch_beginning), std::begin(position_base_patch), std::end(position_base_patch)); - std::vector cmp_rax_rcx_je_movaps_add_pop_ret{ 0x48, 0x39, 0xC1, 0x74, 0x4, 0x0F, 0x29, 0x48, 0x50, 0x48, 0x83, 0xC4, 0x60, 0x5B, 0xC3 }; - mov_rcx_localplayer.insert(std::end(mov_rcx_localplayer), std::begin(cmp_rax_rcx_je_movaps_add_pop_ret), std::end(cmp_rax_rcx_je_movaps_add_pop_ret)); + std::vector patch_ending{ + 0x48, 0x39, 0xC1, // compare rcx rax registers + 0x74, 0x04, // if it's the same skip to GTA5.exe + 0x2D + 0x0F, 0x29, 0x48, 0x50, // update location of entity from rax register + 0x48, 0x83, 0xC4, 0x60, // vanilla code + 0x5B, 0xC3 }; // vabilla code - proc.write_bytes((uint64_t)proc.base_ + 0x1A, mov_rcx_localplayer); + patch_beginning.insert(std::end(patch_beginning), std::begin(patch_ending), std::end(patch_ending)); + proc.write_bytes((uint64_t)proc.base_ + 0x1A, patch_beginning); } if (settings.fly)