青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

S.l.e!ep.¢%

像打了激速一樣,以四倍的速度運轉,開心的工作
簡單、開放、平等的公司文化;尊重個性、自由與個人價值;
posts - 1098, comments - 335, trackbacks - 0, articles - 1
  C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

How Windows Shuts Down

Posted on 2009-11-05 18:22 S.l.e!ep.¢% 閱讀(684) 評論(0)  編輯 收藏 引用 所屬分類: RootKit

How Windows Shuts Down

Blogger : MSDN Blogs
All posts : All posts by MSDN Blogs
Category : SAP SCM
Blogged date : 2007 Jun 09

Hi my name is Bryan,? I'm a escalation engineer on the Microsoft CPR platforms team.?? A common problem scenario involves shutting down Windows. When troubleshooting problems during shut down we have to look at the Winlogon.exe process which can be tricky and must be done correctly.

?

Troubleshooting Techniques

?

Common Settings

?

Settings that would affect how Windows shuts down are mostly in HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon, and are documented thoroughly at http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/regentry/12314.mspx . The setting to really pay attention is:

?

DisableCAD (REG_DWORD). When set to 1 the GINA will bypass the Ctrl-Alt-Del dialog and go straight to the logon prompt. The system cannot be shutdown when the logon prompt at the console is displayed.

?

Another common setting that is sometimes needed for security reasons is in HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management.

?

ClearPageFileAtShutdown (REG_DWORD). When set to 1 the memory manager will clear the paging file on shutdown. If the paging file is large this can significantly the time it takes for the system to shut down.

?

Winlogon Event Notification

?

Prior to Windows Vista/2008 Server, Winlogon Notification Packages can be used to reliably monitor the state of Winlogon. These are simple export DLLs that are registered with entry points for each event monitored by the package. Winlogon explicitly calls these entry points when a specific event occurs. Each package handles the notification within the context of the Winlogon process. Keep in mind that a bug in a notification package can cause problems in Winlogon and render the system inaccessible. You can find more information about Winlogon Notification Packages at http://msdn2.microsoft.com/en-us/library/aa380545.aspx .

?

Starting with Windows Vista support for Winlogon Notification Packages has been pulled. Most of this functionality is still provided through SCM event notifications. See the following link for more information about this.

?

http://technet2.microsoft.com/WindowsVista/en/library/6ec4ec6d-6b84-44c9-b3af-116589a42b861033.mspx?mfr=true

?

You can find information about how to write a service here.

?

http://msdn2.microsoft.com/en-us/library/ms685969.aspx

?

However these notifications are performed asynchronously so the exact moment of each state within Winlogon cannot be reliably known.

?

Winlogon Logging

?

Winlogon logging is obtained by applying the checked build of Winlogon and setting the following registry values under HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon.

?

DebugFlags (REG_SZ). This is a comma-separated list of debug flags to capture. The list of flags is Error, Warning, Trace, Init, Timeout, Sas, State, MPR, CoolSwitch, Profile, DebugLsa, DebugSpm, DebugMpr, DebugGo, Migrate, DebugServices, Setup, SC, Notify, and Job.

?

LogFile (REG_SZ). This is the path to the log file where the events should be written. If this value is missing then the events are written to the debug port.

?

These options can also be placed in the win.ini file. This option and other debug logging options for Winlogon can be found in these articles.

http://support.microsoft.com/default.aspx?scid=kb;EN-US;232575

http://support.microsoft.com/default.aspx?scid=kb;EN-US;221833

?

Checked builds of Windows binaries are available through MSDN subscriptions. The checked binary applied to the system must match the service pack level of the system.

?

When looking at the Winlogon logs there are three check points to identify. They are the three ExitWindowsEx calls made during shutdown. These log entries were made during a shutdown initiated with “shutdown –r –f –t 0”.

?

328.372> Winlogon-Trace: Doing remote-initiated (Administrator) Reboot=true, Force=true

328.372> Winlogon-Trace: Starting user thread for Logoff, flags = 3807

328.764> Winlogon-Trace: Doing immediate shutdown, LastGinaRet = b, Flags = 3804

328.764> Winlogon-Trace: Calling ExitWindowsEx(0x3804, 0)

.

.

.

328.1528> Winlogon-Trace: ExitWindowsEx called to shut down COM processes

.

.

.

328.332> Winlogon-Trace: Starting shutdown

328.332> Winlogon-Trace: Starting user thread for Logoff, flags = 7

.

.

.

328.284> Winlogon-Trace: Calling ExitWindowsEx(0x7, 0)

?

If shutdown stalls then based on the log entries you should be able to identify which part of shutdown it is stuck in.

?

Debugging

?

In order to debug Winlogon you will need to first install the debugging tools for Windows ( http://www.microsoft.com/whdc/devtools/debugging/default.mspx ). It contains information about how to set up the debugger for Winlogon debugging. If the debugger is not set up correctly on Winlogon the system can easily get in an unusable state and the system will need to be reinstalled.

?

You should debug Winlogon whenever a problem manifests itself on the Winlogon desktop where the SAS and logon prompt dialogs are displayed. When debugging Winlogon you should start by looking at the main process thread. If shutdown (or any other Winlogon activity) is hung that thread will show what happened to prevent shutdown from completing. Also look at these Winlogon flags which provide some indication of whether or not the main thread is even processing a shutdown.

?

0105fe8c winlogon!g_fReadyForShutdown

0105fdf8 winlogon!ShutdownHasBegun

01062b3c winlogon!ShutdownInProgress

01062b30 winlogon!ShutdownTime

?

I will point out how these variables are modified.

?

Shutdown Sequence of Events

?

If you are debugging a shutdown issue you first need to understand the sequence of events that take place during shutdown. This will help isolate what activity may be failing.

?

RPC Call

?

An application, local or remote, tells Windows to shut down by calling the Win32 API InitiateSystemShutdownEx ( http://msdn2.microsoft.com/en-us/library/aa376874.aspx ). This API creates an RPC call over the named pipe InitShutdown. The remote connect and RPC call looks like this in a network trace.

?

11:08:40.025???????????????? CLIENT???????? SERVER??????? SMB????????????? SMB: C; Nt Create Andx, FileName = \InitShutdown

11:08:40.027???????????????? CLIENT???????? SERVER??????? MSRPC??????? MSRPC: c/o Request: unknown Call=0x1 Opnum=0x2 Context=0x0 Hint=0x20

?

A local connect would not need to go over the network, but it uses the same mechanism to make this call.

?

The server side of this RPC call is handled by the function BaseInitiateShutdownEx in the Winlogon.exe process. This RPC worker performs the following actions.

?

1. ?????? Checks the privilege level of the client. If the client privilege test fails then the error status code is returned. This will typically be ERROR_ACCESS_DENIED (0x5).

2. ?????? Parses the shutdown command sent by the RPC client. If the command is malformed then the status error code of ERROR_INVALID_PARAMETER (0x57) is returned.

3. ?????? Checks the Winlogon flags ShutdownInProgress, ShutdownHasBegun, g_fReadyForShutdown, and the current state of the terminal desktop to see if we can shutdown. Winlogon cannot begin the shutdown if a shutdown is in progress or if it is not ready. Winlogon also will not start a shutdown if the force flag was not specified in the command and the desktop is locked. If the ShutdownInProgress or ShutdownHasBegun flag is set then the return value is ERROR_SHUTDOWN_IN_PROGRESS (0x45B). If the g_fReadyForShutdown is not set then the return value is ERROR_NOT_READY (0x15).

?

Debugger output:

dd winlogon!g_fReadyForShutdown l 1

0105fe8c? 00000001

?

dd winlogon!ShutdownInProgress l 1

01062b3c? 00000000

?

dd winlogon!ShutdownHasBegun l 1

0105fdf8? 00000000

?

4. ?????? Winlogon initializes the shutdown data including the global variable ShutdownTime. If this variable has been set then we know we’ve gotten this far.

?

Debugger Output:

dq winlogon!ShutdownTime l 1

01062b30? 01c7a859`baee0060

?

.formats 01c7a859`baee0060

Evaluate expression:

? Time:??? Wed Jun? 6 12:42:54.506 2007 (GMT-4)

?

5. ?????? If Winlogon has determined that it can proceed then the ShutdownInProgress flag is set. Subsequent shutdown requests from this point will fail in step 3 when it checks this flag.

6. ?????? Generates the shutdown audit event if auditing was enabled. Note that shutdown may fail at some point after this even though the audit log is generated.

7. ?????? Creates another thread to continue working on the shutdown. At this point the RPC worker thread returns to the caller.

?

To this point there has been no visible indication on the server being shutdown. If the RPC worker fails for some reason then the client application will get an indication of the failure. If the RPC worker successfully hands the shutdown request to the next thread then the client application will get ERROR_SUCCESS (0) as the return code. The client application will get no indication of a failure after that point.

?

Worker Thread

?

The RPC worker thread hands control to the LogoffThreadProc thread. If the delay specified in the shutdown command was 0 then the ShutdownInProgress flag is cleared and the ShutdownHasBegun is set. In the Winlogon log you will see a line that starts with “Doing immediate shutdown”. Otherwise you will not see any visible indication at this point that a shutdown is occurring.

?

If the delay specified in the shutdown command was greater than 0 then the countdown shutdown dialog is displayed.

?

?(See Attached shutdown.jpg to view this dialog.).

?

When that dialog completes the AbortShutdown flag is checked. This flag would get set as a result of a call to AbortSystemShutdown ( http://msdn2.microsoft.com/en-us/library/aa376630.aspx ). If it is set then the shutdown is aborted. Otherwise the ShutdownInProgress flag is cleared, the ShutdownHasBegun flag is set and if the shutdown was initiated by a system process then we shut the system down immediately at this point with no further clean up.

?

After these flags are updated the ExitWindowsInProgress flag is set and we call the Win32 API ExitWindowsEx ( http://msdn2.microsoft.com/en-us/library/ms893047.aspx ). In the Winlogon log you will see a line that starts with “Calling ExitWindowsEx”.

?

Debugger Output:

dd winlogon!ExitWindowsInProgress l 1

0105fd84 ?00000001

?

The Win32 API ExitWindowsEx makes an RPC call to CSRSS.EXE. CSRSS synchronously sends a WM_QUERYENDSESSION message to all Windows applications. When an application gets this message it indicates that shutdown can continue and CSRSS then sends the WM_ENDSESSION message. After that the process is terminated. If the application indicates that it cannot be terminated then CSRSS stops processing any further applications and waits for the interactive user to close the application. The ExitWindowsEx call will fail with error ERROR_OPERATION_ABORTED (0x3E3) and the Winlogon flags are reset so that a new shutdown request can be processed.

?

An application that prevents shutdown from proceeding in this manner can be seen visual since it will be the foreground window on the desktop. To confirm which application returned did this you will need to live debug CSRSS. A return code of 3 from either winsrv!ConsoleClientShutdown or winsrv!UserClientShutdown will indicate the application did this.

?

Debugger Output:

0:002> pc

eax=00000000 ebx=7c81a3ab ecx=7ffdb000 edx=75a58ca0 esi=75a58ca0 edi=00164600

eip=75a564de esp=0052fe40 ebp=0052fe68 iopl=0???????? nv up ei pl zr na po nc

cs=001b? ss=0023? ds=0023? es=0023? fs=003b? gs=0000???????????? efl=00000246

CSRSRV!CsrShutdownProcesses+7e:

75a564de ff5740 call dword ptr [edi+0x40]{winsrv!UserClientShutdown (75a9db1f)} ds:0023:00164640=75a9db1f

?

; Step past the call.

0:002> p

eax=00000003 ebx=7c81a3ab ecx=7ffdb000 edx=75a58ca0 esi=75a58ca0 edi=00164600

eip=75a564e1 esp=0052fe4c ebp=0052fe68 iopl=0???????? nv up ei pl zr na po nc

cs=001b? ss=0023? ds=0023? es=0023? fs=003b? gs=0000???????????? efl=00000246

CSRSRV!CsrShutdownProcesses+81:

75a564e1 8bf8???????????? mov???? edi,eax

?

; The first parameter is a structure that contains the process ID.

75a564d5 ff75f4?????????? push??? dword ptr [ebp-0xc]

75a564d8 ff750c?????????? push??? dword ptr [ebp+0xc]

75a564db ff75f8?????????? push??? dword ptr [ebp-0x8]

75a564de ff5740?????????? call??? dword ptr [edi+0x40]

?

; Get the pointer to this structure.

0:002> dd ebp-8 l 1

dd ebp-8 l 1

0052fe60? 0018a530

?

; The first DWORD is the process ID. The second DWORD is the thread ID.

0:002> dd 0018a530 l 1

dd 0018a530

0018a530? 0000066c

?

; Break into kernel mode so we can look at all the processes.

0:002> .breakin

.breakin

Break instruction exception - code 80000003 (first chance)

nt!RtlpBreakWithStatusInstruction:

8081db0e cc????????????? int???? 3

?

; Get the process object with that process ID.

kd> !process 0000066c 0

Searching for Process with Cid == 66c

PROCESS ff62a638? SessionId: 0? Cid: 066c??? Peb: 7ffdf000? ParentCid: 0108

??? DirBase: 0390d000? ObjectTable: e1658e38? HandleCount:? 51.

??? Image: test.exe

?

Console (text-based) applications are asynchronously sent a separate CTRL_SHUTDOWN_EVENT notification. This means that ExitWindowsEx will proceed no matter how the application chooses to handle this notification.

?

Services.exe (and all Windows services) is a console application which receives this notification from CSRSS. Services.exe registers a control handler ScShutdownNotificationRoutine which calls ScShutdownAllServices on shutdown. This function traverses through all Windows services that are not stopped or stopping and that accept the shutdown notification and sends them the SERVICE_CONTROL_SHUTDOWN notification. Each service has 20 seconds by default to shutdown. However a service may request more time by calling SetServiceStatus with a wait hint and updated check point. It can do this so long as it continues to respond within the current timeout period. However since Services.exe received this as an asynchronous message from CSRSS.EXE it will not prevent the system from shutting down.

?

After ExitWindowsEx returns control to Winlogon the ExitWindowsInProgress flag is cleared and LogoffThreadProc exits.

?

MainLoop

?

The state of Winlogon is controlled by the main process thread in a function called MainLoop. As LogoffThreadProc sets the ShutdownHasBegun flag and calls ExitWindowsEx the MainLoop function picks up on this change of state and begins executing its shutdown code. Since MainLoop is responsible for interaction with the user this is the first place where the user will get visible confirmation from Winlogon that the system is shutting down.

?

When MainLoop sees that the Winlogon state has changed to shutting down it takes the following actions.

?

1. ?????? Signal the shell that we are shutting down. This causes the Explorer shell to disappear.

2. ?????? Checks to see if there are any updates to the user’s profile.

3. ?????? Send out the logoff notification event.

4. ?????? Delete network connections.

5. ?????? Play the logoff sound.

6. ?????? Play the system exit sound.

7. ?????? Creates a KillComProcesses thread. This calls ExitWindowsEx and will wait up to 15 minutes for this to complete.

8. ?????? Save and unload the user’s profile.

9. ?????? Delete RAS connections.

10. ??? Send out the shutdown notification event.

11. ??? Stop Windows file protection.

12. ??? Creates another LogoffThreadProc thread which again calls ExitWindowsEx.

13. ??? Call the shutdown function in the GINA. This displays the Windows is shutting down dialog.

14. ??? Wait for any remaining system processes to complete. If we are stuck here then we would need to look at System, smss.exe, or csrss.exe. One of those will be stuck in some action.

15. ??? Shut down the system.

?

Winlogon uses the native API NtShutdownSystem in step 15. If there is a hang after this point then you will see the main thread in Winlogon stuck in this call and the real problem is likely the result of a device driver in the System process. This call will never return.

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            麻豆成人91精品二区三区| 欧美麻豆久久久久久中文| 久热精品在线| 尤妮丝一区二区裸体视频| 麻豆精品一区二区av白丝在线| 免播放器亚洲一区| 亚洲精品日本| 国产精品第一区| 欧美一级日韩一级| 欧美高清视频| 亚洲天堂第二页| 国产揄拍国内精品对白| 免费欧美在线| 一区二区三区四区五区精品视频 | 国产精品99久久久久久宅男| 午夜欧美不卡精品aaaaa| 国产一区二区三区的电影 | 久久久999精品| 亚洲国产精品久久久久久女王| 欧美日韩欧美一区二区| 亚欧成人精品| 欧美激情成人在线| 亚洲综合清纯丝袜自拍| 国产午夜精品全部视频播放| 久久亚洲风情| 一区二区电影免费观看| 六月婷婷久久| 亚洲免费在线视频| 尤物99国产成人精品视频| 欧美日韩国产成人| 欧美在线观看视频| 亚洲精品在线三区| 久久综合成人精品亚洲另类欧美| 夜夜嗨av一区二区三区免费区| 国产欧美一区二区三区另类精品 | 欧美区视频在线观看| 中文国产成人精品| 亚洲第一成人在线| 欧美一区二区在线看| 日韩视频在线观看| 在线不卡视频| 国产欧美日韩亚洲一区二区三区| 欧美精品一区二区三区视频| 久久狠狠亚洲综合| 亚洲欧美国产精品桃花| 亚洲免费观看在线视频| 欧美高清视频一区二区三区在线观看| 午夜宅男欧美| 亚洲一区二区三区四区五区黄| 亚洲福利视频一区| 国产一区二区中文字幕免费看| 欧美午夜大胆人体| 欧美激情综合色综合啪啪| 久久久精品久久久久| 亚洲欧美在线一区| 亚洲小少妇裸体bbw| 亚洲伦理在线免费看| 欧美高清不卡| 欧美激情免费观看| 免费成人高清视频| 久久人人97超碰精品888| 午夜日韩福利| 性久久久久久久久久久久| 亚洲一区二区免费在线| 亚洲视频一区二区在线观看| av不卡在线| 在线视频亚洲欧美| 日韩网站在线| 夜夜狂射影院欧美极品| 亚洲精品一区久久久久久| 91久久精品网| 亚洲精品一区在线观看香蕉| 亚洲看片免费| 艳妇臀荡乳欲伦亚洲一区| 一区二区三区精品视频| 一区二区三区不卡视频在线观看 | 欧美不卡视频一区发布| 久久综合久久综合这里只有精品| 久久久不卡网国产精品一区| 久久精品视频网| 久久久久综合一区二区三区| 久久久久九九九九| 麻豆成人av| 欧美精品福利视频| 欧美手机在线| 国产精品久久久久久久免费软件 | 欧美日韩精品在线播放| 欧美日韩专区| 国产精品丝袜xxxxxxx| 国产日韩欧美亚洲| 黄色av成人| 亚洲精品偷拍| 亚洲欧美日韩专区| 久久精品国产一区二区三区免费看 | 亚洲高清资源| 亚洲欧洲另类| 亚洲无限av看| 午夜久久久久久| 久久一区二区三区国产精品| 欧美顶级艳妇交换群宴| 日韩视频专区| 午夜亚洲一区| 美女国产精品| 欧美午夜不卡在线观看免费| 国产一区二区日韩精品| 亚洲激情国产精品| 亚洲免费在线精品一区| 麻豆精品在线播放| 亚洲精选视频在线| 欧美影片第一页| 欧美激情精品久久久久久免费印度| 国产精品都在这里| 亚洲第一色中文字幕| 亚洲香蕉伊综合在人在线视看| 久久av在线看| 亚洲国产精品专区久久| 午夜精品福利视频| 欧美二区在线播放| 国产欧美丝祙| 日韩视频在线免费| 久久三级福利| 一区二区不卡在线视频 午夜欧美不卡在| 欧美在线你懂的| 欧美日韩和欧美的一区二区| 国产综合久久久久久| 亚洲婷婷国产精品电影人久久| 美女日韩欧美| 亚洲欧美国产视频| 欧美日韩国产成人在线观看| 在线成人国产| 久久精品亚洲| 在线亚洲欧美| 欧美精品啪啪| 亚洲国产免费| 久久久久国产精品人| 亚洲视频综合在线| 欧美成人免费大片| 午夜精品久久久久久久99水蜜桃 | 亚洲国产精品成人精品| 欧美在线免费视屏| 亚洲高清免费视频| av成人天堂| 久久精品一区二区国产| 亚洲丰满少妇videoshd| 在线视频免费在线观看一区二区| 欧美一区二区在线免费观看| 乱码第一页成人| 欧美午夜精品久久久久久浪潮| 国语精品中文字幕| 日韩午夜视频在线观看| 久久精品国产清高在天天线| 亚洲国产精品99久久久久久久久| 亚洲视频久久| 男女激情视频一区| 国产精品主播| 一本一本久久a久久精品综合妖精| 久久成人国产| 亚洲精品中文字幕有码专区| 欧美中文在线观看| 国产精品国产自产拍高清av| 激情国产一区| 亚洲欧美日韩精品久久久久| 欧美国产日韩一区二区三区| 亚洲欧美在线网| 欧美日韩国产色站一区二区三区| 狠狠综合久久| 欧美亚洲一区二区在线| 亚洲国产日韩一区| 久久九九国产精品| 国产乱码精品一区二区三区五月婷| 亚洲人成人77777线观看| 久久精品国产一区二区三区免费看| 亚洲伦理中文字幕| 理论片一区二区在线| 国产日韩欧美一二三区| 亚洲欧美日韩国产综合精品二区 | 蜜桃视频一区| 午夜亚洲精品| 国产精品一卡| 亚洲伊人观看| 日韩视频在线一区二区三区| 男男成人高潮片免费网站| 在线观看日韩专区| 久久se精品一区二区| 一区二区三区国产精华| 欧美日韩大片| 在线亚洲高清视频| 亚洲黄页视频免费观看| 男女激情久久| 最新高清无码专区| 欧美华人在线视频| 免费不卡亚洲欧美| 91久久精品一区| 亚洲成色777777在线观看影院| 久久亚洲精选| 亚洲国产视频一区二区| 欧美成人国产va精品日本一级| 久久久久久久久久久久久9999| 国产综合久久| 欧美成人免费小视频|