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
|
|
|
{
|
|
|
|
u8 * Addr = Address;
|
2010-09-19 01:16:05 +02:00
|
|
|
u8 * Addr_end = Address + Size;
|
2010-05-30 16:18:25 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
while (Addr <= Addr_end - SearchSize)
|
2010-05-30 16:18:25 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (memcmp(Addr, SearchPattern, SearchSize) == 0)
|
2010-05-30 16:18:25 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
memcpy(Addr, PatchData, PatchSize);
|
2010-05-30 16:18:25 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
Addr += 4;
|
|
|
|
}
|
2010-09-19 01:16:05 +02:00
|
|
|
return false;
|
2010-05-30 16:18:25 +02:00
|
|
|
}
|