Skip to content

Instantly share code, notes, and snippets.

@TheRouletteBoi
TheRouletteBoi / Examples.cpp
Last active December 21, 2022 18:15 — forked from jordywastaken/HookManager.cpp
PlayStation 3 hooking class
uint32_t GetCurrentToc()
{
uint32_t* entry_point = *reinterpret_cast<uint32_t**>(0x1001C); // ElfHeader->e_entry
return entry_point[1];
}
template <typename R, typename... TArgs>
inline R GameCall(std::uint32_t addr, TArgs... args)
{
volatile opd_s opd = { addr, GetCurrentToc() };
@TheRouletteBoi
TheRouletteBoi / DetourHook.cpp
Last active September 26, 2024 23:13
Hooking any function including imports and exports. PowerPC, PPC, PS3, Playstation 3
#include "DetourHook.hpp"
#define POWERPC_REGISTERINDEX_R0 0
#define POWERPC_REGISTERINDEX_R1 1
#define POWERPC_REGISTERINDEX_R2 2
#define POWERPC_REGISTERINDEX_R3 3
#define POWERPC_REGISTERINDEX_R4 4
#define POWERPC_REGISTERINDEX_R5 5
#define POWERPC_REGISTERINDEX_R6 6
#define POWERPC_REGISTERINDEX_R7 7
@TheRouletteBoi
TheRouletteBoi / PS3HookHandler.h
Last active February 25, 2022 12:40
Hooking method by using a single branch. PowerPC, PPC, PS3, Playstation 3
/** Initial Commit by gopro2027 **/
/** Revision #2 by gopro2027 **/
/**
* Added "original" into function hook
* Fixed branch instruction
*/
/** Revision #3 by TheRouLetteBoi **/
/**
@TheRouletteBoi
TheRouletteBoi / DetourHook.h
Last active February 25, 2022 12:41
PS3 Detour class (LEGACY) and enstone hooking. PowerPC, PPC, PS3, Playstation 3
// https://pastebin.com/yezsesij
static uint32_t GetFunctionBranch(uint32_t address)
{
uint32_t dest, temp;
dest = *(uint32_t*)address;
temp = dest;
dest = temp & 0x03FFFFFC;
if (temp & 0x02000000) dest |= 0xFC000000;
dest = address + dest;