mirror of
https://github.com/wiiu-env/FunctionPatcherModule.git
synced 2026-04-22 18:17:12 -05:00
Compare commits
No commits in common. "main" and "v0.2" have entirely different histories.
10
.github/dependabot.yml
vendored
10
.github/dependabot.yml
vendored
|
|
@ -1,10 +0,0 @@
|
|||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "docker"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
10
.github/workflows/ci.yml
vendored
10
.github/workflows/ci.yml
vendored
|
|
@ -3,21 +3,21 @@ name: CI-Release
|
|||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
|
||||
jobs:
|
||||
clang-format:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v3
|
||||
- name: clang-format
|
||||
run: |
|
||||
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./source
|
||||
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source
|
||||
build-binary:
|
||||
runs-on: ubuntu-22.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v3
|
||||
- name: create version.h
|
||||
run: |
|
||||
git_hash=$(git rev-parse --short "$GITHUB_SHA")
|
||||
|
|
@ -48,7 +48,7 @@ jobs:
|
|||
- name: zip artifact
|
||||
run: zip -r ${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip *.wms
|
||||
- name: Create Release
|
||||
uses: "softprops/action-gh-release@v2"
|
||||
uses: "softprops/action-gh-release@v1"
|
||||
with:
|
||||
tag_name: ${{ env.REPOSITORY_NAME }}-${{ env.DATETIME }}
|
||||
draft: false
|
||||
|
|
|
|||
8
.github/workflows/pr.yml
vendored
8
.github/workflows/pr.yml
vendored
|
|
@ -6,15 +6,15 @@ jobs:
|
|||
clang-format:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v3
|
||||
- name: clang-format
|
||||
run: |
|
||||
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./source
|
||||
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source
|
||||
check-build-with-logging:
|
||||
runs-on: ubuntu-22.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v3
|
||||
- name: build binary with logging
|
||||
run: |
|
||||
docker build . -t builder
|
||||
|
|
@ -25,7 +25,7 @@ jobs:
|
|||
runs-on: ubuntu-22.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v3
|
||||
- name: create version.h
|
||||
run: |
|
||||
git_hash=$(git rev-parse --short "${{ github.event.pull_request.head.sha }}")
|
||||
|
|
|
|||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -8,4 +8,3 @@ build/
|
|||
cmake-build-debug/
|
||||
CMakeLists.txt
|
||||
*.wms
|
||||
*.zip
|
||||
|
|
|
|||
10
Dockerfile
10
Dockerfile
|
|
@ -1,7 +1,7 @@
|
|||
FROM ghcr.io/wiiu-env/devkitppc:20260225
|
||||
FROM wiiuenv/devkitppc:20221228
|
||||
|
||||
COPY --from=ghcr.io/wiiu-env/libkernel:20260331 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/libfunctionpatcher:20260331 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/wiiumodulesystem:20260418 /artifacts $DEVKITPRO
|
||||
COPY --from=wiiuenv/libkernel:20220904 /artifacts $DEVKITPRO
|
||||
COPY --from=wiiuenv/libfunctionpatcher:20230107 /artifacts $DEVKITPRO
|
||||
COPY --from=wiiuenv/wiiumodulesystem:20230106 /artifacts $DEVKITPRO
|
||||
|
||||
WORKDIR /project
|
||||
WORKDIR project
|
||||
|
|
|
|||
2
Makefile
2
Makefile
|
|
@ -28,7 +28,7 @@ INCLUDES := source
|
|||
#-------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#-------------------------------------------------------------------------------
|
||||
CFLAGS := -Wall -Wextra -Werror -Os -ffunction-sections\
|
||||
CFLAGS := -Wall -Os -ffunction-sections\
|
||||
$(MACHDEP)
|
||||
|
||||
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__
|
||||
|
|
|
|||
|
|
@ -34,4 +34,4 @@ docker run -it --rm -v ${PWD}:/project functionpatchermodule-builder make clean
|
|||
|
||||
## Format the code via docker
|
||||
|
||||
`docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./source -i`
|
||||
`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source -i`
|
||||
|
|
@ -15,7 +15,7 @@ uint32_t FunctionAddressProvider::getEffectiveAddressOfFunction(function_replace
|
|||
err = OSDynLoad_IsModuleLoaded((char *) rplHandle.rplname, &rplHandle.handle);
|
||||
}
|
||||
if (err != OS_DYNLOAD_OK || !rplHandle.handle) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("%s is not loaded yet. Err %d for handle %p", rplHandle.rplname, err, rplHandle.handle);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("%s is not loaded yet", rplHandle.rplname, err, rplHandle.handle);
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = rplHandle.handle;
|
||||
|
|
@ -28,7 +28,7 @@ uint32_t FunctionAddressProvider::getEffectiveAddressOfFunction(function_replace
|
|||
return 0;
|
||||
}
|
||||
|
||||
OSDynLoad_FindExport(rpl_handle, OS_DYNLOAD_EXPORT_FUNC, functionName, reinterpret_cast<void **>(&real_addr));
|
||||
OSDynLoad_FindExport(rpl_handle, 0, functionName, reinterpret_cast<void **>(&real_addr));
|
||||
|
||||
if (!real_addr) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("OSDynLoad_FindExport failed for %s", functionName);
|
||||
|
|
|
|||
|
|
@ -232,15 +232,15 @@ void PatchedFunctionData::generateJumpToOriginal() {
|
|||
|
||||
uint32_t jumpToAddress = this->realEffectiveFunctionAddress + 4;
|
||||
|
||||
this->jumpToOriginal[0] = this->replacedInstruction;
|
||||
|
||||
if (((uint32_t) jumpToAddress & 0x01FFFFFC) != (uint32_t) jumpToAddress) {
|
||||
// We need to do a long jump
|
||||
this->jumpToOriginal[0] = 0x3d600000 | ((jumpToAddress >> 16) & 0x0000FFFF); // lis r11 ,0x1234
|
||||
this->jumpToOriginal[1] = 0x616b0000 | (jumpToAddress & 0x0000ffff); // ori r11 ,r11 ,0x5678
|
||||
this->jumpToOriginal[2] = 0x7d6903a6; // mtspr CTR ,r11
|
||||
this->jumpToOriginal[3] = this->replacedInstruction;
|
||||
this->jumpToOriginal[1] = 0x3d600000 | ((jumpToAddress >> 16) & 0x0000FFFF); // lis r11 ,0x1234
|
||||
this->jumpToOriginal[2] = 0x616b0000 | (jumpToAddress & 0x0000ffff); // ori r11 ,r11 ,0x5678
|
||||
this->jumpToOriginal[3] = 0x7d6903a6; // mtspr CTR ,r11
|
||||
this->jumpToOriginal[4] = 0x4e800420; // bctr
|
||||
} else {
|
||||
this->jumpToOriginal[0] = this->replacedInstruction;
|
||||
this->jumpToOriginal[1] = 0x48000002 | (jumpToAddress & 0x01FFFFFC);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include "FunctionAddressProvider.h"
|
||||
#include "PatchedFunctionData.h"
|
||||
#include "fpatching_defines_legacy.h"
|
||||
#include "utils/logger.h"
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/debug.h>
|
||||
|
|
|
|||
|
|
@ -2,11 +2,8 @@
|
|||
#include "PatchedFunctionData.h"
|
||||
#include "function_patcher.h"
|
||||
#include "utils/globals.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <ranges>
|
||||
#include <vector>
|
||||
|
||||
#include <wums/exports.h>
|
||||
|
||||
WUT_CHECK_OFFSET(function_replacement_data_v2_t, 0x00, VERSION);
|
||||
|
|
@ -53,7 +50,7 @@ FunctionPatcherStatus FPAddFunctionPatch(function_replacement_data_t *function_d
|
|||
}
|
||||
|
||||
{
|
||||
std::lock_guard lock(gPatchedFunctionsMutex);
|
||||
std::lock_guard<std::mutex> lock(gPatchedFunctionsMutex);
|
||||
gPatchedFunctions.push_back(std::move(functionData));
|
||||
|
||||
OSMemoryBarrier();
|
||||
|
|
@ -67,7 +64,7 @@ bool FunctionPatcherPatchFunction(function_replacement_data_t *function_data, Pa
|
|||
}
|
||||
|
||||
FunctionPatcherStatus FPRemoveFunctionPatch(PatchedFunctionHandle handle) {
|
||||
std::lock_guard lock(gPatchedFunctionsMutex);
|
||||
std::lock_guard<std::mutex> lock(gPatchedFunctionsMutex);
|
||||
std::vector<std::shared_ptr<PatchedFunctionData>> toBeTempRestored;
|
||||
bool found = false;
|
||||
int32_t erasePosition = 0;
|
||||
|
|
@ -135,7 +132,7 @@ FunctionPatcherStatus FPIsFunctionPatched(PatchedFunctionHandle handle, bool *ou
|
|||
if (outIsFunctionPatched == nullptr) {
|
||||
return FUNCTION_PATCHER_RESULT_INVALID_ARGUMENT;
|
||||
}
|
||||
std::lock_guard lock(gPatchedFunctionsMutex);
|
||||
std::lock_guard<std::mutex> lock(gPatchedFunctionsMutex);
|
||||
for (auto &cur : gPatchedFunctions) {
|
||||
if (cur->getHandle() == handle) {
|
||||
*outIsFunctionPatched = cur->isPatched;
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
/* Types that are kept only for ABI compatibility. */
|
||||
|
||||
#include <function_patcher/fpatching_defines.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct function_replacement_data_v2_t {
|
||||
uint32_t VERSION;
|
||||
uint32_t physicalAddr; /* [needs to be filled] */
|
||||
uint32_t virtualAddr; /* [needs to be filled] */
|
||||
uint32_t replaceAddr; /* [needs to be filled] Address of our replacement function */
|
||||
uint32_t *replaceCall; /* [needs to be filled] Address to access the real_function */
|
||||
function_replacement_library_type_t library; /* [needs to be filled] rpl where the function we want to replace is. */
|
||||
const char *function_name; /* [needs to be filled] name of the function we want to replace */
|
||||
FunctionPatcherTargetProcess targetProcess; /* [will be filled] */
|
||||
} function_replacement_data_v2_t;
|
||||
|
|
@ -4,18 +4,13 @@
|
|||
#include "utils/CThread.h"
|
||||
#include "utils/logger.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/debug.h>
|
||||
#include <coreinit/memorymap.h>
|
||||
|
||||
#include <kernel/kernel.h>
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
static void writeDataAndFlushIC(CThread *thread, void *arg) {
|
||||
(void) thread;
|
||||
auto *data = (PatchedFunctionData *) arg;
|
||||
|
||||
uint32_t replace_instruction = data->replaceWithInstruction;
|
||||
|
|
@ -26,19 +21,6 @@ static void writeDataAndFlushIC(CThread *thread, void *arg) {
|
|||
|
||||
auto replace_instruction_physical = (uint32_t) &replace_instruction;
|
||||
|
||||
if (data->jumpData) {
|
||||
DCFlushRange(data->jumpData, data->jumpDataSize * sizeof(uint32_t));
|
||||
ICInvalidateRange(data->jumpData, data->jumpDataSize * sizeof(uint32_t));
|
||||
}
|
||||
if (data->jumpToOriginal) {
|
||||
DCFlushRange(data->jumpToOriginal, 5 * sizeof(uint32_t));
|
||||
ICInvalidateRange(data->jumpToOriginal, 5 * sizeof(uint32_t));
|
||||
}
|
||||
if (data->realCallFunctionAddressPtr) {
|
||||
DCFlushRange(data->realCallFunctionAddressPtr, sizeof(uint32_t));
|
||||
ICInvalidateRange(data->realCallFunctionAddressPtr, sizeof(uint32_t));
|
||||
}
|
||||
|
||||
if (replace_instruction_physical < 0x00800000 || replace_instruction_physical >= 0x01000000) {
|
||||
replace_instruction_physical = OSEffectiveToPhysical(replace_instruction_physical);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -4,11 +4,9 @@
|
|||
#include "utils/globals.h"
|
||||
#include "utils/logger.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
#include <coreinit/memdefaultheap.h>
|
||||
#include <coreinit/memexpheap.h>
|
||||
#include <kernel/kernel.h>
|
||||
#include <mutex>
|
||||
#include <ranges>
|
||||
#include <set>
|
||||
#include <wums.h>
|
||||
|
|
@ -27,11 +25,11 @@ void UpdateFunctionPointer() {
|
|||
}
|
||||
/* Memory allocation functions */
|
||||
uint32_t *allocPtr, *freePtr;
|
||||
if (OSDynLoad_FindExport(coreinitModule, OS_DYNLOAD_EXPORT_DATA, "MEMAllocFromDefaultHeapEx", reinterpret_cast<void **>(&allocPtr)) != OS_DYNLOAD_OK) {
|
||||
if (OSDynLoad_FindExport(coreinitModule, true, "MEMAllocFromDefaultHeapEx", reinterpret_cast<void **>(&allocPtr)) != OS_DYNLOAD_OK) {
|
||||
DEBUG_FUNCTION_LINE_ERR("OSDynLoad_FindExport for MEMAllocFromDefaultHeapEx");
|
||||
OSFatal("FunctionPatcherModule: OSDynLoad_FindExport for MEMAllocFromDefaultHeapEx");
|
||||
}
|
||||
if (OSDynLoad_FindExport(coreinitModule, OS_DYNLOAD_EXPORT_DATA, "MEMFreeToDefaultHeap", reinterpret_cast<void **>(&freePtr)) != OS_DYNLOAD_OK) {
|
||||
if (OSDynLoad_FindExport(coreinitModule, true, "MEMFreeToDefaultHeap", reinterpret_cast<void **>(&freePtr)) != OS_DYNLOAD_OK) {
|
||||
DEBUG_FUNCTION_LINE_ERR("OSDynLoad_FindExport for MEMFreeToDefaultHeap");
|
||||
OSFatal("FunctionPatcherModule: OSDynLoad_FindExport for MEMFreeToDefaultHeap");
|
||||
}
|
||||
|
|
@ -43,7 +41,7 @@ void UpdateFunctionPointer() {
|
|||
}
|
||||
|
||||
void CheckIfPatchedFunctionsAreStillInMemory() {
|
||||
std::lock_guard lock(gPatchedFunctionsMutex);
|
||||
std::lock_guard<std::mutex> lock(gPatchedFunctionsMutex);
|
||||
// Check if rpl has been unloaded by comparing the instruction.
|
||||
std::set<uint32_t> physicalAddressesUnchanged;
|
||||
std::set<uint32_t> physicalAddressesChanged;
|
||||
|
|
@ -130,15 +128,13 @@ void notify_callback(OSDynLoad_Module module,
|
|||
void *userContext,
|
||||
OSDynLoad_NotifyReason reason,
|
||||
OSDynLoad_NotifyData *infos) {
|
||||
(void) userContext;
|
||||
(void) infos;
|
||||
if (reason == OS_DYNLOAD_NOTIFY_LOADED) {
|
||||
std::lock_guard lock(gPatchedFunctionsMutex);
|
||||
std::lock_guard<std::mutex> lock(gPatchedFunctionsMutex);
|
||||
for (auto &cur : gPatchedFunctions) {
|
||||
PatchFunction(cur);
|
||||
}
|
||||
} else if (reason == OS_DYNLOAD_NOTIFY_UNLOADED) {
|
||||
std::lock_guard lock(gPatchedFunctionsMutex);
|
||||
std::lock_guard<std::mutex> lock(gPatchedFunctionsMutex);
|
||||
auto library = gFunctionAddressProvider->getTypeForHandle(module);
|
||||
if (library != LIBRARY_OTHER) {
|
||||
for (auto &cur : gPatchedFunctions) {
|
||||
|
|
@ -166,7 +162,7 @@ WUMS_APPLICATION_STARTS() {
|
|||
|
||||
initLogging();
|
||||
{
|
||||
std::lock_guard lock(gPatchedFunctionsMutex);
|
||||
std::lock_guard<std::mutex> lock(gPatchedFunctionsMutex);
|
||||
// reset function patch status if the rpl they were patching has been unloaded from memory.
|
||||
CheckIfPatchedFunctionsAreStillInMemory();
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Patch all functions");
|
||||
|
|
|
|||
|
|
@ -28,11 +28,10 @@ public:
|
|||
typedef void (*Callback)(CThread *thread, void *arg);
|
||||
|
||||
//! constructor
|
||||
explicit CThread(int32_t iAttr, int32_t iPriority = 16, int32_t stacksize = 0x8000, CThread::Callback callback = nullptr, void *callbackArg = nullptr)
|
||||
explicit CThread(int32_t iAttr, int32_t iPriority = 16, int32_t iStackSize = 0x8000, CThread::Callback callback = nullptr, void *callbackArg = nullptr)
|
||||
: pThread(nullptr), pThreadStack(nullptr), pCallback(callback), pCallbackArg(callbackArg) {
|
||||
//! save attribute assignment
|
||||
iAttributes = iAttr;
|
||||
iStackSize = stacksize;
|
||||
//! allocate the thread on the default Cafe OS heap
|
||||
pThread = (OSThread *) gMEMAllocFromDefaultHeapExForThreads(sizeof(OSThread), 0x10);
|
||||
//! allocate the stack on the default Cafe OS heap
|
||||
|
|
@ -124,15 +123,11 @@ public:
|
|||
}
|
||||
OSJoinThread(pThread, nullptr);
|
||||
}
|
||||
// Some games (e.g. Minecraft) expect the default heap to be empty.
|
||||
// Make sure to clean up the memory after using it
|
||||
//! free the thread stack buffer
|
||||
if (pThreadStack) {
|
||||
memset(pThreadStack, 0, iStackSize);
|
||||
gMEMFreeToDefaultHeapForThreads(pThreadStack);
|
||||
}
|
||||
if (pThread) {
|
||||
memset(pThread, 0, sizeof(OSThread));
|
||||
gMEMFreeToDefaultHeapForThreads(pThread);
|
||||
}
|
||||
pThread = nullptr;
|
||||
|
|
@ -151,13 +146,11 @@ public:
|
|||
|
||||
private:
|
||||
static int32_t threadCallback(int32_t argc, void *arg) {
|
||||
(void) argc;
|
||||
//! After call to start() continue with the internal function
|
||||
((CThread *) arg)->executeThread();
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t iStackSize;
|
||||
int32_t iAttributes;
|
||||
OSThread *pThread;
|
||||
uint8_t *pThreadStack;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ char gJumpHeapData[JUMP_HEAP_DATA_SIZE] __attribute__((section(".data")));
|
|||
MEMHeapHandle gJumpHeapHandle __attribute__((section(".data")));
|
||||
|
||||
std::shared_ptr<FunctionAddressProvider> gFunctionAddressProvider;
|
||||
std::recursive_mutex gPatchedFunctionsMutex;
|
||||
std::mutex gPatchedFunctionsMutex;
|
||||
std::vector<std::shared_ptr<PatchedFunctionData>> gPatchedFunctions;
|
||||
|
||||
void *(*gMEMAllocFromDefaultHeapExForThreads)(uint32_t size, int align);
|
||||
|
|
|
|||
|
|
@ -3,10 +3,9 @@
|
|||
#include "version.h"
|
||||
#include <coreinit/memheap.h>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
#define MODULE_VERSION "v0.2.4"
|
||||
#define MODULE_VERSION "v0.2"
|
||||
#define MODULE_VERSION_FULL MODULE_VERSION MODULE_VERSION_EXTRA
|
||||
|
||||
#define JUMP_HEAP_DATA_SIZE (32 * 1024)
|
||||
|
|
@ -14,7 +13,7 @@ extern char gJumpHeapData[];
|
|||
extern MEMHeapHandle gJumpHeapHandle;
|
||||
|
||||
extern std::shared_ptr<FunctionAddressProvider> gFunctionAddressProvider;
|
||||
extern std::recursive_mutex gPatchedFunctionsMutex;
|
||||
extern std::mutex gPatchedFunctionsMutex;
|
||||
extern std::vector<std::shared_ptr<PatchedFunctionData>> gPatchedFunctions;
|
||||
|
||||
extern void *(*gMEMAllocFromDefaultHeapExForThreads)(uint32_t size, int align);
|
||||
|
|
|
|||
|
|
@ -14,18 +14,13 @@ extern "C" {
|
|||
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
|
||||
|
||||
#define LOG(LOG_FUNC, FMT, ARGS...) LOG_EX_DEFAULT(LOG_FUNC, "", "", "", FMT, ##ARGS)
|
||||
#define LOG(LOG_FUNC, FMT, ARGS...) LOG_EX_DEFAULT(LOG_FUNC, "", "", FMT, ##ARGS)
|
||||
|
||||
#define CONSOLE_COLOR_RED "\033[31m"
|
||||
#define CONSOLE_COLOR_YELLOW "\033[33m"
|
||||
#define CONSOLE_COLOR_CYAN "\033[36m"
|
||||
#define CONSOLE_COLOR_RESET "\033[0m"
|
||||
#define LOG_EX_DEFAULT(LOG_FUNC, LOG_LEVEL, LINE_END, FMT, ARGS...) LOG_EX(__FILENAME__, __FUNCTION__, __LINE__, LOG_FUNC, LOG_LEVEL, LINE_END, FMT, ##ARGS)
|
||||
|
||||
#define LOG_EX_DEFAULT(LOG_FUNC, LOG_COLOR, LOG_LEVEL, LINE_END, FMT, ARGS...) LOG_EX(__FILENAME__, __FUNCTION__, __LINE__, LOG_FUNC, LOG_COLOR, LOG_LEVEL, LINE_END, FMT, ##ARGS)
|
||||
|
||||
#define LOG_EX(FILENAME, FUNCTION, LINE, LOG_FUNC, LOG_COLOR, LOG_LEVEL, LINE_END, FMT, ARGS...) \
|
||||
#define LOG_EX(FILENAME, FUNCTION, LINE, LOG_FUNC, LOG_LEVEL, LINE_END, FMT, ARGS...) \
|
||||
do { \
|
||||
LOG_FUNC(LOG_COLOR "[(%s)%18s][%23s]%30s@L%04d: " LOG_LEVEL "" FMT "" LINE_END, LOG_APP_TYPE, LOG_APP_NAME, FILENAME, FUNCTION, LINE, ##ARGS); \
|
||||
LOG_FUNC("[(%s)%18s][%23s]%30s@L%04d: " LOG_LEVEL "" FMT "" LINE_END, LOG_APP_TYPE, LOG_APP_NAME, FILENAME, FUNCTION, LINE, ##ARGS); \
|
||||
} while (0)
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
@ -42,11 +37,10 @@ extern "C" {
|
|||
|
||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) LOG(WHBLogWritef, FMT, ##ARGS)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX_DEFAULT(WHBLogPrintf, CONSOLE_COLOR_RED, "## ERROR## ", CONSOLE_COLOR_RESET, FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_WARN(FMT, ARGS...) LOG_EX_DEFAULT(WHBLogPrintf, CONSOLE_COLOR_YELLOW, "##WARN ## ", CONSOLE_COLOR_RESET, FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_INFO(FMT, ARGS...) LOG_EX_DEFAULT(WHBLogPrintf, CONSOLE_COLOR_CYAN, "##INFO ## ", CONSOLE_COLOR_RESET, FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX_DEFAULT(WHBLogPrintf, "##ERROR## ", "", FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_WARN(FMT, ARGS...) LOG_EX_DEFAULT(WHBLogPrintf, "## WARN## ", "", FMT, ##ARGS)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_ERR_LAMBDA(FILENAME, FUNCTION, LINE, FMT, ARGS...) LOG_EX(FILENAME, FUNCTION, LINE, WHBLogPrintf, CONSOLE_COLOR_RED, "##ERROR## ", CONSOLE_COLOR_RESET, FMT, ##ARGS);
|
||||
#define DEBUG_FUNCTION_LINE_ERR_LAMBDA(FILENAME, FUNCTION, LINE, FMT, ARGS...) LOG_EX(FILENAME, FUNCTION, LINE, WHBLogPrintf, "##ERROR## ", "", FMT, ##ARGS);
|
||||
|
||||
#else
|
||||
|
||||
|
|
@ -58,11 +52,10 @@ extern "C" {
|
|||
|
||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) while (0)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX_DEFAULT(OSReport, CONSOLE_COLOR_RED, "##ERROR## ", CONSOLE_COLOR_RESET "\n", FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_WARN(FMT, ARGS...) LOG_EX_DEFAULT(OSReport, CONSOLE_COLOR_YELLOW, "##WARN ## ", CONSOLE_COLOR_RESET "\n", FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_INFO(FMT, ARGS...) LOG_EX_DEFAULT(OSReport, CONSOLE_COLOR_CYAN, "##INFO ## ", CONSOLE_COLOR_RESET "\n", FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX_DEFAULT(OSReport, "##ERROR## ", "\n", FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_WARN(FMT, ARGS...) LOG_EX_DEFAULT(OSReport, "## WARN## ", "\n", FMT, ##ARGS)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_ERR_LAMBDA(FILENAME, FUNCTION, LINE, FMT, ARGS...) LOG_EX(FILENAME, FUNCTION, LINE, OSReport, CONSOLE_COLOR_RED, "##ERROR## ", CONSOLE_COLOR_RESET "\n", FMT, ##ARGS);
|
||||
#define DEBUG_FUNCTION_LINE_ERR_LAMBDA(FILENAME, FUNCTION, LINE, FMT, ARGS...) LOG_EX(FILENAME, FUNCTION, LINE, OSReport, "##ERROR## ", "\n", FMT, ##ARGS);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user