mirror of
https://github.com/AxioDL/PrimeAPI.git
synced 2026-03-30 11:38:46 -07:00
32 lines
1.0 KiB
C++
32 lines
1.0 KiB
C++
|
|
/******************************************************
|
||
|
|
*** ApplyCodePatches_Template.cpp ***
|
||
|
|
*** This is a template file used by BuildModule.py ***
|
||
|
|
*** to generate DOL patching code. ***
|
||
|
|
******************************************************/
|
||
|
|
#include <PrimeAPI.h>
|
||
|
|
|
||
|
|
// Generated Forward Decls
|
||
|
|
%s
|
||
|
|
// Function Prototypes
|
||
|
|
void Relocate_Addr32(void *pRelocAddress, void *pSymbolAddress);
|
||
|
|
void Relocate_Rel24(void *pRelocAddress, void *pSymbolAddress);
|
||
|
|
void ApplyCodePatches();
|
||
|
|
|
||
|
|
// Function Implementations
|
||
|
|
void Relocate_Addr32(void *pRelocAddress, void *pSymbolAddress)
|
||
|
|
{
|
||
|
|
uint32 *pReloc = (uint32*) pRelocAddress;
|
||
|
|
*pReloc = (uint32) pSymbolAddress;
|
||
|
|
}
|
||
|
|
|
||
|
|
void Relocate_Rel24(void *pRelocAddress, void *pSymbolAddress)
|
||
|
|
{
|
||
|
|
uint32 *pReloc = (uint32*) pRelocAddress;
|
||
|
|
uint32 instruction = *pReloc;
|
||
|
|
uint32 AA = (instruction >> 1) & 0x1;
|
||
|
|
*pReloc = (instruction & ~0x3FFFFFC) | (AA == 0 ? ((uint32) pSymbolAddress - (uint32) pRelocAddress) : (uint32) pSymbolAddress);
|
||
|
|
}
|
||
|
|
|
||
|
|
void ApplyCodePatches()
|
||
|
|
{%s
|
||
|
|
}
|