Sunday, 16 April 2023

Help with Hooking Functions (MSHookFunction)

So i've been working on a mod menu for a couple days and I've tried working with instance variables but it just won't work, im trying to mod Pixel Gun 3D which is a Unity game and i've tested this on a jailbroken device here is the HOOK function uint64_t getOffset(uint64_t offset){ return (long)_dyld_get_image_header(0) + offset; } #define HOOK(offset, ptr, orig) MSHookFunction((void *)getOffset(offset), (void *)ptr, (void **)&orig) i also made sure i defined all the variables int selectedBullet = 0; bool shootBullet = false; and here is the code for the hook void(*oldWeaponSounds)(void* obj); void WeaponSounds(void* obj){ if(obj != nullptr){ if (silentaim) { *(bool*)((uint64_t) obj + 0x191) = true; // isRoundMelee *(float*)((uint64_t) obj + 0x184) = 9999.0f; // radiusRoundMelee } if (shootBullet) { if (selectedBullet == 0) { *(bool*)((uint64_t) obj + 0x12B) = true; // bazooka } else if (selectedBullet == 1) { // laser *(bool*)((uint64_t) obj + 0x1BC) = true; // railgun } else if (selectedBullet == 2) { // shotgun *(bool*)((uint64_t) obj + 0x1A6) = true; // isShotgun } else if (selectedBullet == 3) { // harpoon *(bool*)((uint64_t) obj + 0x2A4) = true; // harpoon } else if (selectedBullet == 4) { // dash *(bool*)((uint64_t) obj + 0x294) = true; // isDash } else if (selectedBullet == 5) { // exploding bullets *(bool*)((uint64_t) obj + 0x1A5) = true; // bulletExplode } } oldWeaponSounds(obj); } } void Hooks() { HOOK(0x2DC1EB0, WeaponSounds, oldWeaponSounds); } the first parameter of the HOOK function is the Update function for the WeaponSounds class [FieldOffset(Offset = "0x191")] public bool isRoundMelee; [FieldOffset(Offset = "0x184")] public float radiusRoundMelee; [丌丈专三丌丞丈东丏("Bazooka")] public bool bazooka; and so on [Address(RVA = "0x2DC1EB0", Offset = "0x2DC1EB0", VA = "0x2DC1EB0")] private void Update() { } then I call the Hooks function at where the ImGui menu is drawn - (void)draw { [self drawMenu]; Hooks(); [self nono]; [self nosee]; } and heres the code for the switch: if (ImGui::BeginTabItem(ENCRYPT("Gameplay"))) { const char* bulletTypes[] = { "Rocket", "Laser", "Shotgun", "Harpoon", "Dash", "Exploding Bullets"}; ImGui::Text(ENCRYPT("Gameplay Mods")); ImGui::Checkbox("Silent Aim", &silentaim); ImGui::Checkbox("Shoot bullet: ", &shootBullet); ImGui::SameLine(); if (ImGui::Combo(" ", &selectedBullet, bulletTypes, IM_ARRAYSIZE(bulletTypes))) { char buffer[512]; snprintf(buffer, 512, "Index: %d\nSelected item: %s", selectedBullet, bulletTypes[selectedBullet]); showAlert("Info", buffer); } if (shootBullet && !shootBulletAlertShown) { char buffer[512]; snprintf(buffer, 512, "Index: %d\nSelected item: %s", selectedBullet, bulletTypes[selectedBullet]); showAlert("Info", buffer); shootBulletAlertShown = true; } if (!shootBullet && shootBulletAlertShown) { shootBulletAlertShown = false; } ImGui::EndTabItem(); } Im 101% sure the offset to the update function is correct as i double checked multiple times and when the checkbox is ticked, nothing happens i also made sure the instance variables are correct and double checked multiple times, im not sure what i did wrong and would appreciate it if anyone knows whats going on with the code and please let me know in the replies if you need any more details the mod im working on is in objective c++ and uses the dear imgui from ocornut

from iOSGods RSS Feed https://ift.tt/0VCH3cb

No comments:

Post a Comment