Improve logging

This commit is contained in:
Maschell 2023-01-06 14:15:59 +01:00
parent fa815f17c0
commit b1320f0c8d
4 changed files with 14 additions and 15 deletions

View File

@ -11,7 +11,7 @@ uint32_t FunctionAddressProvider::getEffectiveAddressOfFunction(function_replace
for (auto &rplHandle : rpl_handles) {
if (rplHandle.library == library) {
if (rplHandle.handle == nullptr) {
DEBUG_FUNCTION_LINE_VERBOSE("Lets acquire handle for rpl: %s", rplHandle.rplname);
DEBUG_FUNCTION_LINE_VERBOSE("Lets check if rpl is loaded: %s", rplHandle.rplname);
err = OSDynLoad_IsModuleLoaded((char *) rplHandle.rplname, &rplHandle.handle);
}
if (err != OS_DYNLOAD_OK || !rplHandle.handle) {

View File

@ -54,7 +54,7 @@ bool PatchedFunctionData::updateFunctionAddresses() {
if (!this->functionName) {
DEBUG_FUNCTION_LINE_ERR("Function name was empty. This should never happen.");
OSFatal("function name was empty");
OSFatal("FunctionPatcherModule: function name was empty");
return false;
}
@ -77,7 +77,7 @@ bool PatchedFunctionData::updateFunctionAddresses() {
void PatchedFunctionData::generateJumpToOriginal() {
if (!this->jumpToOriginal) {
DEBUG_FUNCTION_LINE_ERR("this->jumpToOriginal is not allocated");
OSFatal("this->jumpToOriginal is not allocated");
OSFatal("FunctionPatcherModule: this->jumpToOriginal is not allocated");
}
uint32_t jumpToAddress = this->realEffectiveFunctionAddress + 4;
@ -109,7 +109,7 @@ void PatchedFunctionData::generateReplacementJump() {
if (this->replacementFunctionAddress > 0x01FFFFFC || this->targetProcess != FP_TARGET_PROCESS_ALL) {
if (!this->jumpData) {
DEBUG_FUNCTION_LINE_ERR("jumpData was not allocated");
OSFatal("jumpData was not allocated");
OSFatal("FunctionPatcherModule: jumpData was not allocated");
}
uint32_t offset = 0;
if (this->targetProcess != FP_TARGET_PROCESS_ALL) {
@ -150,13 +150,13 @@ void PatchedFunctionData::generateReplacementJump() {
if (offset >= this->jumpDataSize) {
DEBUG_FUNCTION_LINE_ERR("Tried to overflow buffer. offset: %08X vs array size: %08X", offset, this->jumpDataSize);
OSFatal("Wrote too much data");
OSFatal("FunctionPatcherModule: Wrote too much data");
}
// Make sure the trampoline itself is usable.
if (((uint32_t) this->jumpData & 0x01FFFFFC) != (uint32_t) this->jumpData) {
DEBUG_FUNCTION_LINE_ERR("Jump is impossible");
OSFatal("Jump is impossible");
OSFatal("FunctionPatcherModule: Jump is impossible");
}
this->replaceWithInstruction = 0x48000002 | ((uint32_t) this->jumpData & 0x01FFFFFC);

View File

@ -49,7 +49,7 @@ bool PatchFunction(std::shared_ptr<PatchedFunctionData> &patchedFunction) {
if (!ReadFromPhysicalAddress(patchedFunction->realPhysicalFunctionAddress, &patchedFunction->replacedInstruction)) {
DEBUG_FUNCTION_LINE_ERR("Failed to read instruction.");
OSFatal("Failed to read instruction.");
OSFatal("FunctionPatcherModule: Failed to read instruction.");
return false;
}
@ -108,7 +108,7 @@ bool RestoreFunction(std::shared_ptr<PatchedFunctionData> &patchedFunction) {
}
if (sourceAddrPhys == 0) {
OSFatal("Failed to get physical address");
OSFatal("FunctionPatcherModule: Failed to get physical address");
}
KernelCopyData(targetAddrPhys, sourceAddrPhys, 4);

View File

@ -19,18 +19,17 @@ void UpdateFunctionPointer() {
OSDynLoad_Module coreinitModule;
if (OSDynLoad_Acquire("coreinit", &coreinitModule) != OS_DYNLOAD_OK) {
DEBUG_FUNCTION_LINE_ERR("Failed to acquire coreinit.rpl");
OSFatal("Failed to acquire coreinit.rpl");
OSFatal("FunctionPatcherModule: Failed to acquire coreinit.rpl");
}
/* Memory allocation functions */
uint32_t *allocPtr, *freePtr;
/* Memory allocation functions */
if (OSDynLoad_FindExport(coreinitModule, true, "MEMAllocFromDefaultHeapEx", reinterpret_cast<void **>(&allocPtr)) != OS_DYNLOAD_OK) {
DEBUG_FUNCTION_LINE_ERR("OSDynLoad_FindExport for MEMAllocFromDefaultHeapEx");
OSFatal("OSDynLoad_FindExport for MEMAllocFromDefaultHeapEx");
OSFatal("FunctionPatcherModule: OSDynLoad_FindExport for MEMAllocFromDefaultHeapEx");
}
if (OSDynLoad_FindExport(coreinitModule, true, "MEMFreeToDefaultHeap", reinterpret_cast<void **>(&freePtr)) != OS_DYNLOAD_OK) {
DEBUG_FUNCTION_LINE_ERR("OSDynLoad_FindExport for MEMFreeToDefaultHeap");
OSFatal("OSDynLoad_FindExport for MEMFreeToDefaultHeap");
OSFatal("FunctionPatcherModule: OSDynLoad_FindExport for MEMFreeToDefaultHeap");
}
gMEMAllocFromDefaultHeapExForThreads = (void *(*) (uint32_t, int) ) * allocPtr;
@ -77,13 +76,13 @@ WUMS_INITIALIZE() {
gJumpHeapHandle = MEMCreateExpHeapEx((void *) (gJumpHeapData), JUMP_HEAP_DATA_SIZE, 1);
if (gJumpHeapHandle == nullptr) {
DEBUG_FUNCTION_LINE_ERR("Failed to create heap for jump data");
OSFatal("Failed to create heap for jump data");
OSFatal("FunctionPatcherModule: Failed to create heap for jump data");
}
gFunctionAddressProvider = make_shared_nothrow<FunctionAddressProvider>();
if (!gFunctionAddressProvider) {
DEBUG_FUNCTION_LINE_ERR("Failed to create gFunctionAddressProvider");
OSFatal("Failed to create gFunctionAddressProvider");
OSFatal("FunctionPatcherModule: Failed to create gFunctionAddressProvider");
}
}
@ -146,4 +145,4 @@ WUMS_APPLICATION_ENDS() {
}
WUMS_EXPORT_FUNCTION(FunctionPatcherPatchFunction);
WUMS_EXPORT_FUNCTION(FunctionPatcherRestoreFunction);
WUMS_EXPORT_FUNCTION(FunctionPatcherRestoreFunction);