Hey guys,
I have a file system driver that has implemented a RegistryCallback via CmRegisterCallbackEx.
When I get the callback, I attempt to get the name of the registry object using
ObQueryNameString. It returns STATUS_SUCCESS, I check for null on the returned string (and it isn’t), and then I attempt to do a string compare on it, at which time I get a bugcheck 135.
I assume I’m accessing unpaged memory by running past the end of the string, but I’m doing everything I can to guard against that. What’s even stranger is when I analyze the crash dump (full crash dump, not just kernel) in WinDBG, the string’s value is
“0xfffff8800a4f6b60 "--- memory read error at address 0x000007fef98f9178 —” struct _UNICODE_STRING *". I am unsure whether that is WinDBG, or what I was actually given at runtime.
Below is the code:
pRegDeleteValueKeyInfo = (REG_DELETE_VALUE_KEY_INFORMATION *)Argument2;
OBJECT_NAME_INFORMATION *pObjectNameInfo = (OBJECT_NAME_INFORMATION *)pExtension->deviceHeap;
if ( ObQueryNameString( pRegDeleteValueKeyInfo->Object, pObjectNameInfo, DEVICE_HEAP_SIZE, &returnLength ) != STATUS_SUCCESS ) break;
if ( !pObjectNameInfo->Name.Buffer ) break;
if ( !_wcsnicmp( pObjectNameInfo->Name.Buffer, L"\REGISTRY\", pObjectNameInfo->Name.Length / sizeof( WHCAR ) ) )
pExtension->deviceHeap is basically a scratch buffer 2kb in size that I use in place of memory allocation. When I evaluate that in WinDBG, as a WCHAR *, it looks fine.
One thing to note, however, is that if I cast it to a UNICODE_STRING *, I do get another ‘memory read error’ value. Not sure if this is related.
I’m at a loss as to why this would crash, since I’m testing for a valid return and using the provided length of the buffer (not assuming null terminated).
Any help would be GREATLY appreciated.
Thank you!