Driver opens
L"\REGISTRY\MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Perflib\009"
This works and the returned handle is always
0x80000050 (aka HKEY_PERFORMANCE_TEXT).
The driver closes the key which results in a
INVALID_KERNEL_HANDLE bugcheck.
Other registry keys open and close fine.
I have tried with and without OBJ_KERNEL_HANDLE.
This has been tested on XP SP2 and 2K3.
Here is the snippet that blows up:
RtlInitUnicodeString(&us,
L"\REGISTRY\MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Perflib\009");
InitializeObjectAttributes(&oa, &us,
OBJ_CASE_INSENSITIVE /*| OBJ_KERNEL_HANDLE*/, NULL,
NULL);
status = ZwOpenKey(&handle, KEY_ALL_ACCESS, &oa);
if (NT_SUCCESS(status))
{
status = ZwClose(handle);
}
Note that Arg2 in the bugcheck is sometimes 0 which
means that a protected handle was closed (don't know
what "protected" means in this context)
Here is a copy of !analyze -v:
*******************************************************************************
*
*
* Bugcheck Analysis
*
*
*
*******************************************************************************
INVALID_KERNEL_HANDLE (93)
This message occurs if kernel code (server,
redirector, other driver, etc.)
attempts to close a handle that is not a valid handle.
Arguments:
Arg1: 00000050, The handle that NtClose was called
with.
Arg2: 00000001, means an invalid handle was closed.
Arg3: 00000000
Arg4: 00000000
Debugging Details:
DEFAULT_BUCKET_ID: DRIVER_FAULT
BUGCHECK_STR: 0x93
CURRENT_IRQL: 0
LAST_CONTROL_TRANSFER: from 80542289 to 804df1c0
STACK_TEXT:
f336075c 80542289 00000003 00000050 00000000
nt!RtlpBreakWithStatusInstruction
f33607a8 80543108 00000003 824072f8 81d9f9e8
nt!KiBugCheckDebugBreak+0x19
f3360b10 805435b9 00000093 00000050 00000001
nt!KeBugCheck2+0x4a8
f3360b30 805fa4ca 00000093 00000050 00000001
nt!KeBugCheckEx+0x19
f3360b78 80586d17 00000050 00000000 804dfd24
nt!ObpCloseHandle+0x164
f3360b84 804dfd24 80000050 80587fa4 e11e9378
nt!NtClose+0x17
f3360b84 804ea881 80000050 80587fa4 e11e9378
nt!KiSystemService+0xd0
f3360c00 f899fbed 80000050 95000004 80000050
nt!ZwClose+0x11
WARNING: Stack unwind information not available.
Following frames may be wrong.
f3360c3c 804f04f3 826492b0 81e3fce8 823e51f8
SampleDriver+0xbed
f3360c4c 80585208 81e3fd58 823e51f8 81e3fce8
nt!IofCallDriver+0x3f
f3360c60 80585fe6 826492b0 81e3fce8 823e51f8
nt!IopSynchronousServiceTail+0x6f
f3360d00 80586028 000007e8 00000000 00000000
nt!IopXxxControlFile+0x607
f3360d34 804dfd24 000007e8 00000000 00000000
nt!NtDeviceIoControlFile+0x28
f3360d34 7ffe0304 000007e8 00000000 00000000
nt!KiSystemService+0xd0
0006fea4 77f426cb 77e4b2eb 000007e8 00000000
SharedUserData!SystemCallStub+0x4
0006fea8 77e4b2eb 000007e8 00000000 00000000
ntdll!NtDeviceIoControlFile+0xc
0006ff0c 01001304 000007e8 95000004 00000000
kernel32!DeviceIoControl+0x137
0006ff44 01001478 00000002 00263810 002629c0
SampleDriverProgram+0x1304
0006ffc0 77e4f38c 00000000 00000000 7ffdf000
SampleDriverProgram+0x1478
0006fff0 00000000 01001349 00000000 78746341
kernel32!BaseProcessStart+0x23
FOLLOWUP_IP:
SampleDriver+bed
f899fbed 8945f8 mov [ebp-0x8],eax
SYMBOL_STACK_INDEX: 8
FOLLOWUP_NAME: MachineOwner
SYMBOL_NAME: SampleDriver+bed
MODULE_NAME: SampleDriver
IMAGE_NAME: SampleDriver.sys
DEBUG_FLR_IMAGE_TIMESTAMP: 416ae0c4
STACK_COMMAND: kb
BUCKET_ID: 0x93_SampleDriver+bed
Followup: MachineOwner
Any ideas?
Thanks,
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo