Add framework for in-game patches
This commit is contained in:
parent
e76aec4a67
commit
e86bb6cf15
13 changed files with 268 additions and 74 deletions
20
src/patcher/patcher.cpp
Normal file
20
src/patcher/patcher.cpp
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#include "patcher.h"
|
||||
|
||||
#include "utils/logger.h"
|
||||
|
||||
#include <kernel/kernel.h>
|
||||
#include <coreinit/memorymap.h>
|
||||
|
||||
bool replace_string(uint32_t start, uint32_t size, const char* original_val, size_t original_val_sz, const char* new_val, size_t new_val_sz) {
|
||||
for (uint32_t addr = start; addr < start + size - original_val_sz; addr++) {
|
||||
int ret = memcmp(original_val, (void*)addr, original_val_sz);
|
||||
if (ret == 0) {
|
||||
DEBUG_FUNCTION_LINE("found str @%08x: %s", addr, (const char*)addr);
|
||||
KernelCopyData(OSEffectiveToPhysical(addr), OSEffectiveToPhysical((uint32_t)new_val), new_val_sz);
|
||||
DEBUG_FUNCTION_LINE("new str @%08x: %s", addr, (const char*)addr);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
Loading…
Reference in a new issue