Hi,
i was developing a helper application in .NET that is using the System.Diagnostic-Namespaces Process-Class for terminating a specific process if it had to be terminated forcibly and no other “soft” way did work. The Process-Class does have a member named Kill() that internally expects a process id and internally forwards this to the Kernel32::TerminateProcess by using the processes handle and a “-1” as second parameter. I accidentally managed to include the SYSTEM process into the list of processes (thats what i found out later by analysing my code) to be terminated but the termination of the SYSTEM process failed for sure, but lead to a unexpected BSOD on systems hibernation request. At first it wasnt clear from where i got the BSOD since all worked fine yet and i never got the RESOURCE_NOT_OWNED before on that system. As said i found out that this was in direct relation to a failing TerminateProcess() request on the SYSTEM process on my Vista 32bit system. While the system is working nothing happens and all runs fine, but if you request the session written to disk with hibernation, the BSOD appears right after the display turns dark for hibernation attempt. Thats what the Bugcheck in detail shows, The terminator application is a win32 app that is elevated and has debug privilege (for other tasks it can carry out on demand).
Microsoft (R) Windows Debugger Version 6.12.0002.633 X86
Copyright (c) Microsoft Corporation. All rights reserved.
Loading Dump File [C:\Windows\MEMORY.DMP]
Kernel Summary Dump File: Only kernel address space is available
Symbol search path is: srv*c:\Symbols*http://msdl.microsoft.com/download/symbols
Executable search path is:
Windows Server 2008/Windows Vista Kernel Version 6002 (Service Pack 2) MP (2 procs) Free x86 compatible
Product: WinNt, suite: TerminalServer SingleUserTS
Built by: 6002.18533.x86fre.vistasp2_gdr.111025-0338
Machine Name:
Kernel base = 0x82202000 PsLoadedModuleList = 0x82319c70
Debug session time: Thu Mar 15 07:06:36.670 2012 (UTC + 1:00)
System Uptime: 0 days 0:15:40.700
Loading Kernel Symbols
…
…
…
Loading User Symbols
Loading unloaded module list
…
*******************************************************************************
* *
* Bugcheck Analysis *
* *
*******************************************************************************
Use !analyze -v to get detailed debugging information.
BugCheck E3, {823043a0, 84fb4ad0, 0, 2}
Probably caused by : ntkrpamp.exe ( nt!ExpReleaseResourceForThreadLite+d8 )
Followup: MachineOwner
0: kd> !analyze -v
*******************************************************************************
* *
* Bugcheck Analysis *
* *
*******************************************************************************
RESOURCE_NOT_OWNED (e3)
A thread tried to release a resource it did not own.
Arguments:
Arg1: 823043a0, Address of resource
Arg2: 84fb4ad0, Address of thread
Arg3: 00000000, Address of owner table if there is one
Arg4: 00000002
Debugging Details:
DEFAULT_BUCKET_ID: VISTA_DRIVER_FAULT
BUGCHECK_STR: 0xE3
PROCESS_NAME: System
CURRENT_IRQL: 2
LAST_CONTROL_TRANSFER: from 822ad792 to 822cfb3f
STACK_TEXT:
8b957a04 822ad792 000000e3 823043a0 84fb4ad0 nt!KeBugCheckEx+0x1e
8b957a34 822ad6b3 00000001 8b957ab8 823b34c8 nt!ExpReleaseResourceForThreadLite+0xd8
8b957a40 823b34c8 00000000 824db7bc 8b957ad8 nt!ExReleaseResourceLite+0xf
8b957a48 824db7bc 8b957ad8 00000001 00000000 nt!ExReleaseTimeRefreshLock+0xd
8b957aa4 824db413 8b957ab8 00000003 00000001 nt!PoBroadcastSystemState+0x398
8b957ad8 824dc771 3f958e03 8b957c10 8b957c94 nt!PopSetDevicesSystemState+0x7b
8b957bfc 8224cc7a 00000002 c000010a 01000000 nt!NtSetSystemPowerState+0x6c5
8b957bfc 8224bb9d 00000002 c000010a 01000000 nt!KiFastCallEntry+0x12a
8b957c80 824903eb 00000002 00000005 80000000 nt!ZwSetSystemPowerState+0x11
8b957ccc 8248fd7e 00000000 00000002 00000005 nt!PopIssueActionRequest+0x352
8b957d08 822328ce 3f9588bb 8230413c 84fb4ad0 nt!PopPolicyWorkerAction+0x45
8b957d44 822a7e22 00000004 00000000 84fb4ad0 nt!PopPolicyWorkerThread+0x6e
8b957d7c 823d7fe2 80000000 3f95883f 00000000 nt!ExpWorkerThread+0xfd
8b957dc0 82240efe 822a7d25 00000001 00000000 nt!PspSystemThreadStartup+0x9d
00000000 00000000 00000000 00000000 00000000 nt!KiThreadStartup+0x16
STACK_COMMAND: kb
FOLLOWUP_IP:
nt!ExpReleaseResourceForThreadLite+d8
822ad792 cc int 3
SYMBOL_STACK_INDEX: 1
SYMBOL_NAME: nt!ExpReleaseResourceForThreadLite+d8
FOLLOWUP_NAME: MachineOwner
MODULE_NAME: nt
IMAGE_NAME: ntkrpamp.exe
DEBUG_FLR_IMAGE_TIMESTAMP: 4ea6b87e
FAILURE_BUCKET_ID: 0xE3_nt!ExpReleaseResourceForThreadLite+d8
BUCKET_ID: 0xE3_nt!ExpReleaseResourceForThreadLite+d8
Followup: MachineOwner
So my question here is: If i dont have termination access to the system process, why does the TerminateProcess() “affect” the SYSTEM process in some way or why does the TerminateProcess() lead to some kind of change in either the SYSTEM process or some Kernel data structures?
K.