hello.
i have the following macro, which i use to log function failures (both API and in-project functions):
#define WPP_LEVEL_FLAGS_FUNCTION_STATUS_LOGGER(lvl, flags, FUNCTION_NAME, STATUS) WPP_LEVEL_LOGGER(flags)
#define WPP_LEVEL_FLAGS_FUNCTION_STATUS_ENABLED(lvl, flags, FUNCTION_NAME, STATUS) (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= lvl)
// USEPREFIX (LogFuncFailNtStatus, "%!STDPREFIX!");
// FUNC LogFuncFailNtStatus{LEVEL=TRACE_LEVEL_ERROR, FLAGS=TRACE_GENERIC}(FUNCTION_NAME, STATUS);
// USESUFFIX (LogFuncFailNtStatus, "%s failed with %!STATUS!", FUNCTION_NAME, STATUS);
So i can do things like:
NTSTATUS status=ZwProtectVirtualMemory(...);
if(!NT_SUCCESS(status))
{
LogFuncFailNtStatus("ZwProtectVirtualMemory", status);
return status;
}
The macro works, the result is as expected.
My only problem is, that all the function names, that are passed as argument to the LogFuncFailNtStatus macro appear in the binary, taking up space, while i believe they could be compiled into the string literal from which the GUID is generated, so i can avoid clogging up the binary with a lot of strings.
I searched around the (rather vague) WPP documentation and also other examples and tutorials, but could not find any way to do that, since as it seems, the wpp pre-processor does not know to automatically concatenate string literals?
What i tried:
// USESUFFIX (LogFuncFailNtStatus, "" FUNCTION_NAME " failed with %!STATUS!", STATUS);
I was hoping, that i can concatenate constant string literals just like in C.
thank you