Does anyone know why nt!KD_DEFAULT_Mask is 0x3fffffff by default? I need to figure out how to configure dbgPrintEx() calls to be disabled by default.
I am working on a kernel level driver, specifically a DSM driver. I want to use DbgPrintEx to provide tracing ability. Specifically I want to be able to enable it on a production release. I want to be able to dynamically turn on traces to help debug on support calls or during problems are test group sees, without having to load a special build. By default I want the traces should to be disabled.
From the Googling and MS documentation I have read, my problem appears to be the opposite of most folks. My trace seems to be enabled and outputting messages in dbgview by default.
I have reproduced my problem on two different 2008R2 systems. The same certified DSM image/build runs on 2008, 2012, and 2012R2, so the final solution needs to work for all of those OS.
My code looks like:
#define DPFLTR_DSM_DRIVER_LEVEL DPFLTR_MASK | 0x10
DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_DSM_DRIVER_LEVEL, “[DSM_KM] BestAdminPath: returning READY device\n”);
I have also tried changing the level values in my source code to use DPFLTR_MASK|0x10, DPFLTR_TRACE_LEVEL, DPFLTR_INFO_LEVEL, and the value 7. In all cases, my trace statements appear in dbgview.
My registry does not even have a HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Debug Print Filter key. I also tried creating the key and creating DEFAULT, IHVAUDIO, IHVDRIVER, and SR entries using the OSR SetDbgPrintFiltering.exe tool. I tried those entries with values of both 0x0, and 0x1. I did remember to reboot, to allow the values to take and again, the messages always came out in dbgview.
I tried using the kernel debug to look at the masks, for example, I did a “dd nt!Kd_WIN2000_Mask”. Here is what I got for all of them:
lkd> dd nt!Kd_WIN2000_Mask
fffff80001c55fb0 00000001 lkd\> dd nt!Kd_DEFAULT_Mask fffff800
01c6deb0 3fffffff
lkd> dd nt!Kd_IHVDRIVER_Mask
fffff80001c6de50 3fffffff lkd\> dd nt!Kd_IHVAUDIO_Mask fffff800
01c6de58 3fffffff
lkd> dd nt!Kd_SR_Mask
fffff800`01c6de48 3fffffff
The following appears to toggle my dbg print statements, when using DPFLTR_MASK | 0x10 for the level, off then on again:
lkd> ed nt!Kd_IHVDRIVER_Mask 0x1
lkd> ed nt!Kd_IHVDRIVER_Mask 0x3fffffff
So, when I change the default value of nt!Kd_IHVDRIVER_Mask from 0x3fffffff to 0x1, my statements stop. Therefore, I think the default value of the nt!Kd_IHVDRIVER_Mask is the issue. Does anyone know why the Mask coming up as 0x3fffffff and how can I code my dbgPrintEx() calls so they are disabled by default, but able to be turned on in a released version of my driver.
Thanks,
Curtis