Adding a WPP trace logging support to storport miniport driver is not working

I am working on adding a WPP trace logging support to a virtual storport miniport driver, but it is not working in my case only for this type of driver. For other kernel mode drivers (WDF, WDM), WPP trace logging support is working fine, and I can see the traces coming in TraceView.

Links referred:
https://social.msdn.microsoft.com/Forums/azure/en-US/c42ba85c-37cd-46f7-9bfa-ff5829909544/physical-storport-miniport-and-wppcleanup?forum=wdk
https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/wpp-preprocessor
https://lists.openfabrics.org/pipermail/nvmewin/2014-October/001013.html

I referred to the above links and done the following implementation:

  1. Added trace.h header file which includes=>
    • WPP_CONTROL_GUIDS macro is defined
    • Flags and levels macros are defined
    • TraceEvents macro is defined

  2. -scan:“.\header\Trace.h” is added

  3. For storage miniport driver:
    • “stortrce.h” is included
    • -gen:{km-StorDefault.tpl}*.tmh is added

  4. Trace.h and the generated .tmh files are included in the source code files.

My case is, the support is working fine for other type of drivers when added, but it is not working for my virtual storport miniport driver. I am not getting any traces in the TraceView. Can you please tell me, am I missing anything for the virtual storport miniport drivers; Or, provide any links that I can refer, to correct my implementation.

I’ve done this successfully in physical StorPort miniports but not a virtual one (yet…will be soon though for a project).

Are you calling WPP_INIT_TRACING with an initialized STORAGE_TRACE_INIT_INFO?

Global Variable:
PVOID TraceContext = NULL;

Yes, I am calling WPP_INIT_TRACING with an initialized STORAGE_TRACE_INIT_INFO as given below in the DriverEntry() function:

STORAGE_TRACE_INIT_INFO initInfo;
memset(&initInfo, 0, sizeof(STORAGE_TRACE_INIT_INFO));
initInfo.Size = sizeof(STORAGE_TRACE_INIT_INFO);
initInfo.NumErrorLogRecords = 5;
initInfo.TraceCleanupRoutine = WppCleanupRoutine;
initInfo.DriverObject = DriverObject;
initInfo.TraceContext = NULL;

WPP_INIT_TRACING(DriverObject, Argument2, &initInfo);

if (initInfo.TraceContext != NULL)
{
    TraceContext = initInfo.TraceContext;
}

Also, have the cleanup routine as given below:

VOID WppCleanupRoutine(PVOID arg1)
{
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, " WppCleanupRoutine\n");

if (TraceContext)
{
    WPP_CLEANUP(NULL, TraceContext);
}

}