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

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>
            日韩视频一区| 欧美精品国产一区二区| 亚洲午夜精品17c| 亚洲欧美日韩精品久久亚洲区| 亚洲在线播放电影| 免费欧美网站| 国产精品videossex久久发布| 国产精品色婷婷| 亚洲国产精品第一区二区三区| 夜夜夜精品看看| 久久尤物视频| 一本久道久久综合狠狠爱| aaa亚洲精品一二三区| 国产精品久久久久久亚洲毛片| 亚洲精品一区二区三区不| 久久丁香综合五月国产三级网站| 欧美91视频| 亚洲一区二区三区视频| 狠狠色伊人亚洲综合网站色| 在线视频精品一区| 欧美成人亚洲成人| 久久成人久久爱| 国产精品高潮呻吟久久| 日韩一区二区电影网| 欧美www在线| 欧美视频一区二区三区四区| 亚洲三级观看| 新狼窝色av性久久久久久| 国产精品视频福利| 欧美黄色aa电影| 免费看成人av| 欧美一区二区三区在线看 | 国产精品视频精品| 欧美77777| 国产视频自拍一区| 亚洲欧美国产精品va在线观看| 亚洲国产精品第一区二区| 一区二区三区日韩精品视频| 亚洲中字在线| 国产一区二区三区的电影| 欧美一区午夜精品| 欧美日韩一区二区免费在线观看| 亚洲免费观看视频| 一本大道久久精品懂色aⅴ| 影音先锋日韩有码| 欧美激情bt| 国内久久精品视频| 欧美1级日本1级| 国产精品羞羞答答| 一级成人国产| 日韩视频一区二区三区在线播放免费观看 | 99精品国产在热久久下载| 在线观看视频一区二区欧美日韩| 亚洲永久精品大片| 亚洲一区二区在线| 亚洲在线日韩| 亚洲小视频在线| 亚洲亚洲精品三区日韩精品在线视频| 91久久夜色精品国产网站| 亚洲人成在线观看网站高清| 欧美精品在线观看播放| 亚洲欧美国产高清| 国产精品第13页| 一区二区精品在线观看| 亚洲精品自在在线观看| 欧美国产专区| 性久久久久久久久| 久久综合五月天婷婷伊人| 亚洲欧洲日本在线| 欧美成年网站| 久久成人精品无人区| 国产精品欧美一区喷水| 亚洲一区二区三区免费观看| 亚洲在线一区二区| 国产精品久久一卡二卡| 亚洲免费在线精品一区| 久久狠狠一本精品综合网| 欧美国产在线视频| 亚洲精品欧美精品| 国产亚洲精品美女| 欧美专区日韩视频| 亚洲男女毛片无遮挡| 国产精品色午夜在线观看| 午夜欧美不卡精品aaaaa| 久久婷婷综合激情| 亚洲国产精品一区制服丝袜| 91久久精品美女高潮| 国产情人节一区| 亚洲精品在线视频观看| 亚洲一区二区免费看| 国产美女一区二区| 亚洲精品视频啊美女在线直播| 亚洲图片自拍偷拍| 欧美成人精品高清在线播放| 日韩视频一区二区| 欧美中文字幕在线视频| 在线免费不卡视频| 欧美一区二区三区成人| 亚洲一区日韩在线| 亚洲国产99| 国产精品专区第二| 久久一区二区三区国产精品| 午夜亚洲影视| 亚洲国产高清aⅴ视频| 欧美日韩成人在线| 欧美高清视频一区二区三区在线观看| 一区二区三区回区在观看免费视频| 国产精品腿扒开做爽爽爽挤奶网站| 久久露脸国产精品| 老巨人导航500精品| 国产一区二区三区日韩| 欧美激情一区二区三区成人| 亚洲自拍偷拍一区| 亚洲三级观看| 麻豆成人在线播放| 亚洲欧美激情精品一区二区| 亚洲高清自拍| 国产亚洲一区二区三区| 欧美三级网页| 欧美xart系列高清| 久久精品99国产精品日本| 夜色激情一区二区| 欧美成人激情在线| 久久久久久免费| 在线日韩日本国产亚洲| 国产酒店精品激情| 欧美四级伦理在线| 欧美精品一区二| 久久亚洲综合色| 午夜视黄欧洲亚洲| 亚洲手机成人高清视频| 亚洲人成77777在线观看网| 免费久久精品视频| 亚洲日本一区二区| 在线日韩一区二区| 尤物精品国产第一福利三区| 国产欧美一区二区三区久久| 国产精品video| 欧美视频二区36p| 欧美日韩八区| 欧美区亚洲区| 欧美日韩午夜在线| 欧美久久影院| 欧美日韩国内自拍| 欧美色图天堂网| 国产精品国产精品国产专区不蜜| 欧美日韩国产一级片| 欧美日韩免费在线| 欧美午夜精品理论片a级按摩| 欧美精品一区二区三区蜜臀| 欧美1区2区| 欧美91精品| 欧美人与禽猛交乱配视频| 欧美啪啪成人vr| 国产精品激情电影| 国产伦精品一区二区| 国产综合欧美| 亚洲第一免费播放区| 亚洲国产小视频在线观看| 亚洲美女在线看| 亚洲午夜一二三区视频| 欧美亚洲在线播放| 久久全球大尺度高清视频| 久久综合一区二区三区| 亚洲国产高清自拍| 99视频国产精品免费观看| 亚洲一区二区三区乱码aⅴ| 欧美亚洲一区二区三区| 裸体丰满少妇做受久久99精品| 亚洲一区中文字幕在线观看| 久久精品国产v日韩v亚洲 | 欧美激情无毛| 亚洲精品久久久久久久久久久久久| 99成人在线| 欧美在线三区| 欧美激情偷拍| 国产精品自拍小视频| 亚洲国内精品| 亚洲欧美电影院| 欧美粗暴jizz性欧美20| 中文精品视频| 99视频一区二区| 欧美一区二区三区男人的天堂| 久久综合999| 国产精品久久久久久亚洲调教| 黄色成人在线网站| 中文精品一区二区三区| 久久久精品国产一区二区三区| 亚洲欧美变态国产另类| 免费成人激情视频| 亚洲美女中出| 麻豆精品视频在线| 国产精品国产三级国产a| 亚洲国产另类精品专区| 性欧美xxxx视频在线观看| 亚洲国产精品综合| 欧美影院在线播放| 国产精品久久国产精品99gif| 亚洲第一区色| 久久亚洲私人国产精品va媚药 |