diff --git a/Lilu/Headers/kern_util.hpp b/Lilu/Headers/kern_util.hpp index af7af302..17e627ff 100644 --- a/Lilu/Headers/kern_util.hpp +++ b/Lilu/Headers/kern_util.hpp @@ -72,10 +72,10 @@ extern proc_t kernproc; * @param cond precondition * @param str printf-like string */ -#define SYSLOG_COND(cond, module, str, ...) \ - do { \ - if (cond) \ - LLLog( "%s%10s" str "\n", xStringify(PRODUCT_NAME) ": ", module " @ ", ## __VA_ARGS__); \ +#define SYSLOG_COND(cond, module, str, ...) \ + do { \ + if (cond) \ + lilu_os_log( "%s%10s" str "\n", xStringify(PRODUCT_NAME) ": ", module " @ ", ## __VA_ARGS__); \ } while (0) /** @@ -240,7 +240,7 @@ extern proc_t kernproc; * * @param format formatted string */ -EXPORT void LLLog(const char *format, ...); +EXPORT extern "C" void lilu_os_log(const char *format, ...); /** * Two-way substring search diff --git a/Lilu/PrivateHeaders/kern_ubsan.h b/Lilu/PrivateHeaders/kern_ubsan.h index ef64b7ba..6423b496 100644 --- a/Lilu/PrivateHeaders/kern_ubsan.h +++ b/Lilu/PrivateHeaders/kern_ubsan.h @@ -53,13 +53,14 @@ #ifdef vprintf #undef vprintf #endif +void lilu_os_log(const char *format, ...); #define vprintf(fmt, va) do { \ char buf[1024]; \ vsnprintf(buf, sizeof(buf), (fmt), (va)); \ if (buf[0] == 'U' && buf[1] == 'B' && buf[2] == 'S' && buf[3] == 'a' && buf[4] == 'n' && buf[5] == ':') \ - IOLog("Lilu: ubsan @%s", &buf[6]); \ + lilu_os_log("Lilu: ubsan @%s", &buf[6]); \ else \ - IOLog("Lilu: ubsan @ %s", buf); \ + lilu_os_log("Lilu: ubsan @ %s", buf); \ } while (0) // Bit manipulation is not present (aside an ugly BIT macro in IOFireWire header) diff --git a/Lilu/Sources/kern_user.cpp b/Lilu/Sources/kern_user.cpp index 9f3cac53..6b24b808 100644 --- a/Lilu/Sources/kern_user.cpp +++ b/Lilu/Sources/kern_user.cpp @@ -104,17 +104,17 @@ void UserPatcher::performPagePatch(const void *data_ptr, size_t data_size) { for (maybe = 0; maybe < sz; maybe++) { if (lookup.c[i][maybe] == value) { // We have a possible match - DBGLOG_COND(ml_get_interrupts_enabled(), "user", "found a possible match for %lu of %llX\n", i, value); + DBGLOG("user", "found a possible match for %lu of %llX\n", i, value); break; } } } else { if (lookup.c[i][maybe] != value) { // We failed - DBGLOG_COND(ml_get_interrupts_enabled(), "user", "failure not matching %lu of %llX to expected %llX\n", i, value, lookup.c[i][maybe]); + DBGLOG("user", "failure not matching %lu of %llX to expected %llX\n", i, value, lookup.c[i][maybe]); maybe = sz; } else { - DBGLOG_COND(ml_get_interrupts_enabled(), "user", "found a possible match for %lu of %llX\n", i, value); + DBGLOG("user", "found a possible match for %lu of %llX\n", i, value); } } @@ -132,7 +132,7 @@ void UserPatcher::performPagePatch(const void *data_ptr, size_t data_size) { sz = ref->pageOffs.size(); - DBGLOG_COND(ml_get_interrupts_enabled(), "user", "found what we are looking for %X %X %X %X %X %X %X %X\n", rpatch.find[0], + DBGLOG("user", "found what we are looking for %X %X %X %X %X %X %X %X\n", rpatch.find[0], rpatch.size > 1 ? rpatch.find[1] : 0xff, rpatch.size > 2 ? rpatch.find[2] : 0xff, rpatch.size > 3 ? rpatch.find[3] : 0xff, @@ -143,7 +143,7 @@ void UserPatcher::performPagePatch(const void *data_ptr, size_t data_size) { ); if (sz > 0 && MachInfo::setKernelWriting(true, KernelPatcher::kernelWriteLock) == KERN_SUCCESS) { - DBGLOG_COND(ml_get_interrupts_enabled(), "user", "obtained write permssions\n"); + DBGLOG("user", "obtained write permssions\n"); for (size_t i = 0; i < sz; i++) { uint8_t *patch = const_cast(ptr + ref->pageOffs[i]); @@ -167,14 +167,14 @@ void UserPatcher::performPagePatch(const void *data_ptr, size_t data_size) { } if (MachInfo::setKernelWriting(false, KernelPatcher::kernelWriteLock) == KERN_SUCCESS) { - DBGLOG_COND(ml_get_interrupts_enabled(), "user", "restored write permssions\n"); + DBGLOG("user", "restored write permssions\n"); } } else { - SYSLOG_COND(ml_get_interrupts_enabled(), "user", "failed to obtain write permssions for %lu\n", sz); + SYSLOG("user", "failed to obtain write permssions for %lu\n", sz); } } } else { - DBGLOG_COND(ml_get_interrupts_enabled(), "user", "failed to match a complete page with %lu\n", maybe); + DBGLOG("user", "failed to match a complete page with %lu\n", maybe); } } } diff --git a/Lilu/Sources/kern_util.cpp b/Lilu/Sources/kern_util.cpp index a8787a68..1f558aef 100644 --- a/Lilu/Sources/kern_util.cpp +++ b/Lilu/Sources/kern_util.cpp @@ -16,14 +16,16 @@ bool ADDPR(debugEnabled) = false; uint32_t ADDPR(debugPrintDelay) = 0; -void LLLog(const char *format, ...) { - char tmp[2048]; +void lilu_os_log(const char *format, ...) { + char tmp[1024]; + tmp[0] = '\0'; va_list va; va_start(va, format); vsnprintf(tmp, sizeof(tmp), format, va); va_end(va); - IOLog("%s", tmp); + if (ml_get_interrupts_enabled()) + IOLog("%s", tmp); #ifdef DEBUG if (ADDPR(config).debugLock && ADDPR(config).debugBuffer) { @@ -42,7 +44,7 @@ void LLLog(const char *format, ...) { } #endif - if (ADDPR(debugPrintDelay) > 0) + if (ml_get_interrupts_enabled() && ADDPR(debugPrintDelay) > 0) IOSleep(ADDPR(debugPrintDelay)); }