2010-05-30 16:18:25 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include <gctypes.h>
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
bool PatchDOL(u8 * Address, int Size, const u8 * SearchPattern, int SearchSize, const u8 * PatchData, int PatchSize)
|
2010-05-30 16:18:25 +02:00
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
u8 * Addr = Address;
|
|
|
|
u8 * Addr_end = Address + Size;
|
2010-05-30 16:18:25 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
while (Addr <= Addr_end - SearchSize)
|
|
|
|
{
|
|
|
|
if (memcmp(Addr, SearchPattern, SearchSize) == 0)
|
|
|
|
{
|
|
|
|
memcpy(Addr, PatchData, PatchSize);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
Addr += 4;
|
|
|
|
}
|
|
|
|
return false;
|
2010-05-30 16:18:25 +02:00
|
|
|
}
|