Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ── Patch backup/restore ──────────────────────────────────────────────────────
- struct PatchEntry {
- uintptr_t addr;
- uint8_t original[8];
- uint8_t patched[8];
- size_t size;
- bool applied;
- };
- static PatchEntry g_patches[] = {
- {
- /* CreateVehicle network branch */
- GTA_BASE + 0xAF3A2F,
- { 0x75, 0x0E }, // original: jnz short loc_AF3A3F
- { 0xEB, 0x0E }, // patched: jmp short loc_AF3A3F
- 2, false
- },
- };
- static constexpr int PATCH_COUNT = sizeof(g_patches) / sizeof(g_patches[0]);
- static void ApplyPatch(PatchEntry& p) {
- if (p.applied) return;
- sceKernelMprotect((void*)p.addr, p.size, VM_PROT_ALL);
- memcpy((void*)p.addr, p.patched, p.size);
- p.applied = true;
- final_printf("[PATCH] Applied @ 0x%lx (%zu bytes)\n", p.addr, p.size);
- }
- static void RestorePatch(PatchEntry& p) {
- if (!p.applied) return;
- sceKernelMprotect((void*)p.addr, p.size, VM_PROT_ALL);
- memcpy((void*)p.addr, p.original, p.size);
- p.applied = false;
- final_printf("[PATCH] Restored @ 0x%lx (%zu bytes)\n", p.addr, p.size);
- }
- void InstallAllPatches() {
- for (int i = 0; i < PATCH_COUNT; i++)
- ApplyPatch(g_patches[i]);
- final_printf("[PATCH] All patches installed.\n");
- }
- void RestoreAllPatches() {
- for (int i = 0; i < PATCH_COUNT; i++)
- RestorePatch(g_patches[i]);
- final_printf("[PATCH] All patches restored.\n");
- }
Advertisement