A forum for reverse engineering, OS internals and malware analysis 

Forum for discussion about kernel-mode development.
 #30015  by guidono
 Wed Feb 22, 2017 1:59 pm
Hello !

I'm trying to create a simple windows driver, but the KdPrintEx function doesn't print anything on the debug view on the host... Or it prints some '\n' but nothing else (it happens when I use the 0xf flag I think).

I tried to understand how does this function work using this link : https://msdn.microsoft.com/windows/hard ... g-messages

I also tried this solution : KdPrintEx in 'Debugger Immediate Window' into VS 2012 is not printing any msg

But it seems not working... Here is my code :
Code: Select all
FLT_PREOP_CALLBACK_STATUS MfPreOperationCallback(
_Inout_ PFLT_CALLBACK_DATA Data,
_In_ PCFLT_RELATED_OBJECTS FltObjects,
_Flt_CompletionContext_Outptr_ PVOID *CompletionContext
)
{
    UNREFERENCED_PARAMETER(Data);
    UNREFERENCED_PARAMETER(FltObjects);
    UNREFERENCED_PARAMETER(CompletionContext);

    //DbgSetDebugFilterState(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, TRUE);
    KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "MINIFILTER  PreOperationCallback !\n"));

    return FLT_PREOP_SUCCESS_NO_CALLBACK;
}
So here I use the INFO_LEVEL flag for a IHVDRIVER_ID component, so I created a new register key called IHVDRIVER and with the decimal value 3 (I restarted the machine). I also tried to set the default mask : ed nt!kd_default_mask f (I tried f, 3, 8), I also used !dbgprint : nothing or just '\n' !

Do I miss something ?
 #30016  by Vrtule
 Wed Feb 22, 2017 7:51 pm
Hello,

are you compiling your driver in debug or relelease mode? KdPrint(Ex) is, by preprocessor, translated to DbgPrint(Ex) is compiled in debug mode (more precisely, if the DBG preprocessor "macro" is defined). So, check whether the DBG symbol is defined.

If you want to check how debug prints work, just use DbgPrint(Ex) instead of KdPrint(Ex). They are function, not macros (that may translate to nothing).