ReactOS  0.4.14-dev-342-gdc047f9
poshtdwn.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for poshtdwn.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID NTAPI PopInitShutdownList (VOID)
 
NTSTATUS NTAPI PoRequestShutdownWait (_In_ PETHREAD Thread)
 
VOID NTAPI PopProcessShutDownLists (VOID)
 
VOID NTAPI PopShutdownHandler (VOID)
 
VOID NTAPI PopShutdownSystem (IN POWER_ACTION SystemAction)
 
VOID NTAPI PopGracefulShutdown (IN PVOID Context)
 
VOID NTAPI PopReadShutdownPolicy (VOID)
 
NTSTATUS NTAPI PoQueueShutdownWorkItem (_In_ PWORK_QUEUE_ITEM WorkItem)
 
NTSTATUS NTAPI PoRequestShutdownEvent (OUT PVOID *Event)
 

Variables

ULONG PopShutdownPowerOffPolicy
 
KEVENT PopShutdownEvent
 
PPOP_SHUTDOWN_WAIT_ENTRY PopShutdownThreadList
 
LIST_ENTRY PopShutdownQueue
 
KGUARDED_MUTEX PopShutdownListMutex
 
BOOLEAN PopShutdownListAvailable
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file poshtdwn.c.

Function Documentation

◆ PopGracefulShutdown()

VOID NTAPI PopGracefulShutdown ( IN PVOID  Context)

Definition at line 244 of file poshtdwn.c.

245 {
247 
248  /* Process the registered waits and work items */
250 
251  /* Loop every process */
253  while (Process)
254  {
255  /* Make sure this isn't the idle or initial process */
257  {
258  /* Print it */
259  DPRINT1("%15s is still RUNNING (%p)\n", Process->ImageFileName, Process->UniqueProcessId);
260  }
261 
262  /* Get the next process */
264  }
265 
266  /* First, the HAL handles any "end of boot" special functionality */
267  DPRINT("HAL shutting down\n");
268  HalEndOfBoot();
269 
270  /* Shut down the Shim cache if enabled */
272 
273  /* In this step, the I/O manager does first-chance shutdown notification */
274  DPRINT("I/O manager shutting down in phase 0\n");
275  IoShutdownSystem(0);
276 
277  /* In this step, all workers are killed and hives are flushed */
278  DPRINT("Configuration Manager shutting down\n");
280 
281  /* Shut down the Executive */
282  DPRINT("Executive shutting down\n");
284 
285  /* Note that modified pages should be written here (MiShutdownSystem) */
286  MmShutdownSystem(0);
287 
288  /* Flush all user files before we start shutting down IO */
289  /* This is where modified pages are written back by the IO manager */
291 
292  /* In this step, the I/O manager does last-chance shutdown notification */
293  DPRINT("I/O manager shutting down in phase 1\n");
294  IoShutdownSystem(1);
296 
297  /* FIXME: Calling Mm shutdown phase 1 here to get page file dereference
298  * but it shouldn't be called here. Only phase 2 should be called.
299  */
300  MmShutdownSystem(1);
301 
302  /* Note that here, we should broadcast the power IRP to devices */
303 
304  /* In this step, the HAL disables any wake timers */
305  DPRINT("Disabling wake timers\n");
307 
308  /* And finally the power request is sent */
309  DPRINT("Taking the system down\n");
311 }
VOID NTAPI IoShutdownSystem(IN ULONG Phase)
Definition: device.c:133
POWER_ACTION Action
Definition: po.h:216
VOID MmShutdownSystem(IN ULONG Phase)
Definition: shutdown.c:41
#define HalSetWakeEnable
Definition: halfuncs.h:39
PEPROCESS PsIdleProcess
Definition: psmgr.c:51
PEPROCESS PsInitialSystemProcess
Definition: psmgr.c:50
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
VOID NTAPI PopShutdownSystem(IN POWER_ACTION SystemAction)
Definition: poshtdwn.c:189
#define HalEndOfBoot
Definition: haltypes.h:296
NTSTATUS NTAPI CcWaitForCurrentLazyWriterActivity(VOID)
Definition: lazyrite.c:30
VOID NTAPI CcShutdownSystem(VOID)
Definition: cachesub.c:299
VOID NTAPI CmShutdownSystem(VOID)
Definition: cmsysini.c:2088
POP_POWER_ACTION PopAction
Definition: power.c:27
PEPROCESS NTAPI PsGetNextProcess(IN PEPROCESS OldProcess OPTIONAL)
Definition: process.c:128
VOID NTAPI PopProcessShutDownLists(VOID)
Definition: poshtdwn.c:100
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
VOID NTAPI ExShutdownSystem(VOID)
Definition: shutdown.c:21
VOID NTAPI ApphelpCacheShutdown(VOID)
Definition: apphelp.c:466

Referenced by NtSetSystemPowerState().

◆ PopInitShutdownList()

VOID NTAPI PopInitShutdownList ( VOID  )

Definition at line 32 of file poshtdwn.c.

33 {
34  PAGED_CODE();
35 
36  /* Initialize the global shutdown event */
38 
39  /* Initialize the shutdown lists */
42 
43  /* Initialize the shutdown list lock */
45 
46  /* The list is available now */
48 }
#define TRUE
Definition: types.h:120
LIST_ENTRY PopShutdownQueue
Definition: poshtdwn.c:23
#define PAGED_CODE()
Definition: video.h:57
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN PopShutdownListAvailable
Definition: poshtdwn.c:25
KEVENT PopShutdownEvent
Definition: poshtdwn.c:21
PPOP_SHUTDOWN_WAIT_ENTRY PopShutdownThreadList
Definition: poshtdwn.c:22
VOID FASTCALL KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:31
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
KGUARDED_MUTEX PopShutdownListMutex
Definition: poshtdwn.c:24

Referenced by PoInitSystem().

◆ PopProcessShutDownLists()

VOID NTAPI PopProcessShutDownLists ( VOID  )

Definition at line 100 of file poshtdwn.c.

101 {
102  PPOP_SHUTDOWN_WAIT_ENTRY ShutDownWaitEntry;
103  PWORK_QUEUE_ITEM WorkItem;
104  PLIST_ENTRY ListEntry;
105 
106  /* First signal the shutdown event */
108 
109  /* Acquire the shutdown list lock */
111 
112  /* Block any further attempts to register a shutdown event */
114 
115  /* Release the list lock, since we are exclusively using the lists now */
117 
118  /* Process the shutdown queue */
119  while (!IsListEmpty(&PopShutdownQueue))
120  {
121  /* Get the head entry */
122  ListEntry = RemoveHeadList(&PopShutdownQueue);
123  WorkItem = CONTAINING_RECORD(ListEntry, WORK_QUEUE_ITEM, List);
124 
125  /* Call the shutdown worker routine */
126  WorkItem->WorkerRoutine(WorkItem->Parameter);
127  }
128 
129  /* Now process the shutdown thread list */
130  while (PopShutdownThreadList != NULL)
131  {
132  /* Get the top entry and remove it from the list */
133  ShutDownWaitEntry = PopShutdownThreadList;
135 
136  /* Wait for the thread to finish and dereference it */
137  KeWaitForSingleObject(ShutDownWaitEntry->Thread, 0, 0, 0, 0);
138  ObDereferenceObject(ShutDownWaitEntry->Thread);
139 
140  /* Finally free the entry */
141  ExFreePoolWithTag(ShutDownWaitEntry, 'LSoP');
142  }
143 }
struct _POP_SHUTDOWN_WAIT_ENTRY * NextEntry
Definition: po.h:260
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
LIST_ENTRY PopShutdownQueue
Definition: poshtdwn.c:23
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
volatile PVOID Parameter
Definition: extypes.h:205
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
LIST_ENTRY List
Definition: psmgr.c:57
BOOLEAN PopShutdownListAvailable
Definition: poshtdwn.c:25
PWORKER_THREAD_ROUTINE WorkerRoutine
Definition: extypes.h:204
KEVENT PopShutdownEvent
Definition: poshtdwn.c:21
Definition: typedefs.h:117
PPOP_SHUTDOWN_WAIT_ENTRY PopShutdownThreadList
Definition: poshtdwn.c:22
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
Definition: po.h:258
PETHREAD Thread
Definition: po.h:261
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
KGUARDED_MUTEX PopShutdownListMutex
Definition: poshtdwn.c:24

Referenced by PopGracefulShutdown().

◆ PopReadShutdownPolicy()

VOID NTAPI PopReadShutdownPolicy ( VOID  )

Definition at line 315 of file poshtdwn.c.

316 {
317  UNICODE_STRING KeyString;
321  ULONG Length;
322  UCHAR Buffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(ULONG)];
324 
325  /* Setup object attributes */
326  RtlInitUnicodeString(&KeyString,
327  L"\\Registry\\Machine\\Software\\Policies\\Microsoft\\Windows NT");
329  &KeyString,
331  NULL,
332  NULL);
333 
334  /* Open the key */
335  Status = ZwOpenKey(&KeyHandle, KEY_READ, &ObjectAttributes);
336  if (NT_SUCCESS(Status))
337  {
338  /* Open the policy value and query it */
339  RtlInitUnicodeString(&KeyString, L"DontPowerOffAfterShutdown");
340  Status = ZwQueryValueKey(KeyHandle,
341  &KeyString,
343  &Info,
344  sizeof(Info),
345  &Length);
346  if ((NT_SUCCESS(Status)) && (Info->Type == REG_DWORD))
347  {
348  /* Read the policy */
349  PopShutdownPowerOffPolicy = *Info->Data == 1;
350  }
351 
352  /* Close the key */
354  }
355 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
ULONG PopShutdownPowerOffPolicy
Definition: poshtdwn.c:20
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define KEY_READ
Definition: nt_native.h:1023
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
struct TraceInfo Info
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
unsigned char UCHAR
Definition: xmlstorage.h:181
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define REG_DWORD
Definition: sdbapi.c:596
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231

Referenced by NtSetSystemPowerState().

◆ PopShutdownHandler()

VOID NTAPI PopShutdownHandler ( VOID  )

Definition at line 147 of file poshtdwn.c.

148 {
149  PUCHAR Logo1, Logo2;
150  ULONG i;
151 
152  /* Stop all interrupts */
154  _disable();
155 
156  /* Do we have boot video */
158  {
159  /* Yes we do, cleanup for shutdown screen */
162  InbvSolidColorFill(0, 0, 639, 479, 0);
164  InbvSetScrollRegion(0, 0, 639, 479);
165 
166  /* Display shutdown logo and message */
169  if ((Logo1) && (Logo2))
170  {
171  InbvBitBlt(Logo1, 220, 352);
172  InbvBitBlt(Logo2, 222, 111);
173  }
174  }
175  else
176  {
177  /* Do it in text-mode */
178  for (i = 0; i < 25; i++) InbvDisplayString("\r\n");
179  InbvDisplayString(" ");
180  InbvDisplayString("The system may be powered off now.\r\n");
181  }
182 
183  /* Hang the system */
184  for (;;) HalHaltSystem();
185 }
#define TRUE
Definition: types.h:120
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG IN OUT PLONG IN LONG Increment KeRaiseIrqlToDpcLevel
Definition: CrNtStubs.h:67
BOOLEAN NTAPI InbvDisplayString(IN PCHAR String)
Definition: inbv.c:573
unsigned char * PUCHAR
Definition: retypes.h:3
VOID NTAPI InbvSolidColorFill(IN ULONG Left, IN ULONG Top, IN ULONG Right, IN ULONG Bottom, IN ULONG Color)
Definition: inbv.c:720
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define IDB_LOGO_DEFAULT
Definition: resource.h:15
#define HalHaltSystem
Definition: halfuncs.h:43
#define IDB_SHUTDOWN_MSG
Definition: resource.h:13
VOID NTAPI InbvAcquireDisplayOwnership(VOID)
Definition: inbv.c:532
BOOLEAN NTAPI InbvEnableDisplayString(IN BOOLEAN Enable)
Definition: inbv.c:610
BOOLEAN NTAPI InbvIsBootDriverInstalled(VOID)
Definition: inbv.c:634
BOOLEAN NTAPI InbvResetDisplay(VOID)
Definition: inbv.c:668
VOID NTAPI InbvBitBlt(IN PUCHAR Buffer, IN ULONG X, IN ULONG Y)
Definition: inbv.c:814
void __cdecl _disable(void)
Definition: intrin_arm.h:365
unsigned int ULONG
Definition: retypes.h:1
PUCHAR NTAPI InbvGetResourceAddress(IN ULONG ResourceNumber)
Definition: inbv.c:903
VOID NTAPI InbvSetScrollRegion(IN ULONG Left, IN ULONG Top, IN ULONG Right, IN ULONG Bottom)
Definition: inbv.c:685
BOOLEAN NTAPI InbvCheckDisplayOwnership(VOID)
Definition: inbv.c:557

Referenced by PopShutdownSystem().

◆ PopShutdownSystem()

VOID NTAPI PopShutdownSystem ( IN POWER_ACTION  SystemAction)

Definition at line 189 of file poshtdwn.c.

190 {
191  /* Note should notify caller of NtPowerInformation(PowerShutdownNotification) */
192 
193  /* Unload symbols */
194  DPRINT("It's the final countdown...%lx\n", SystemAction);
196 
197  /* Run the thread on the boot processor */
199 
200  /* Now check what the caller wants */
201  switch (SystemAction)
202  {
203  /* Reset */
205 
206  /* Try platform driver first, then legacy */
207  //PopInvokeSystemStateHandler(PowerStateShutdownReset, NULL);
210  break;
211 
212  case PowerActionShutdown:
213 
214  /* Check for group policy that says to use "it is now safe" screen */
216  {
217  /* FIXFIX: Switch to legacy shutdown handler */
218  //PopPowerStateHandlers[PowerStateShutdownOff].Handler = PopShutdownHandler;
219  }
220 
222 
223  /* Call shutdown handler */
224  //PopInvokeSystemStateHandler(PowerStateShutdownOff, NULL);
225 
226  /* ReactOS Hack */
229 
230  /* If that didn't work, call the HAL */
232  break;
233 
234  default:
235  break;
236  }
237 
238  /* Anything else should not happen */
239  KeBugCheckEx(INTERNAL_POWER_ERROR, 5, 0, 0, 0);
240 }
ULONG PopShutdownPowerOffPolicy
Definition: poshtdwn.c:20
VOID NTAPI KeSetSystemAffinityThread(IN KAFFINITY Affinity)
Definition: thrdobj.c:1116
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
VOID NTAPI DbgUnLoadImageSymbols(_In_ PSTRING Name, _In_ PVOID Base, _In_ ULONG_PTR ProcessId)
VOID NTAPI PopShutdownHandler(VOID)
Definition: poshtdwn.c:147
VOID NTAPI HalReturnToFirmware(IN FIRMWARE_REENTRY Action)
Definition: reboot.c:22
NTSTATUS NTAPI PopSetSystemPowerState(SYSTEM_POWER_STATE PowerState, POWER_ACTION PowerAction)
Definition: power.c:231
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:107

Referenced by PopGracefulShutdown().

◆ PoQueueShutdownWorkItem()

NTSTATUS NTAPI PoQueueShutdownWorkItem ( _In_ PWORK_QUEUE_ITEM  WorkItem)

Definition at line 364 of file poshtdwn.c.

366 {
368 
369  /* Acquire the shutdown list lock */
371 
372  /* Check if the list is (already/still) available */
374  {
375  /* Insert the item into the list */
376  InsertTailList(&PopShutdownQueue, &WorkItem->List);
378  }
379  else
380  {
381  /* We are already in shutdown */
383  }
384 
385  /* Release the list lock */
387 
388  return Status;
389 }
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
LIST_ENTRY PopShutdownQueue
Definition: poshtdwn.c:23
LONG NTSTATUS
Definition: precomp.h:26
#define InsertTailList(ListHead, Entry)
BOOLEAN PopShutdownListAvailable
Definition: poshtdwn.c:25
Status
Definition: gdiplustypes.h:24
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
return STATUS_SUCCESS
Definition: btrfs.c:2938
KGUARDED_MUTEX PopShutdownListMutex
Definition: poshtdwn.c:24
#define STATUS_SYSTEM_SHUTDOWN
Definition: ntstatus.h:841

◆ PoRequestShutdownEvent()

NTSTATUS NTAPI PoRequestShutdownEvent ( OUT PVOID Event)

Definition at line 396 of file poshtdwn.c.

397 {
399  PAGED_CODE();
400 
401  /* Initialize to NULL */
402  if (Event) *Event = NULL;
403 
404  /* Request a shutdown wait */
406  if (!NT_SUCCESS(Status))
407  {
408  return Status;
409  }
410 
411  /* Return the global shutdown event */
412  if (Event) *Event = &PopShutdownEvent;
413  return STATUS_SUCCESS;
414 }
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI PoRequestShutdownWait(_In_ PETHREAD Thread)
Definition: poshtdwn.c:52
#define PAGED_CODE()
Definition: video.h:57
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
KEVENT PopShutdownEvent
Definition: poshtdwn.c:21
Status
Definition: gdiplustypes.h:24
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by RawInputThreadMain().

◆ PoRequestShutdownWait()

NTSTATUS NTAPI PoRequestShutdownWait ( _In_ PETHREAD  Thread)

Definition at line 52 of file poshtdwn.c.

54 {
55  PPOP_SHUTDOWN_WAIT_ENTRY ShutDownWaitEntry;
57  PAGED_CODE();
58 
59  /* Allocate a new shutdown wait entry */
60  ShutDownWaitEntry = ExAllocatePoolWithTag(PagedPool, sizeof(*ShutDownWaitEntry), 'LSoP');
61  if (ShutDownWaitEntry == NULL)
62  {
63  return STATUS_NO_MEMORY;
64  }
65 
66  /* Reference the thread and save it in the wait entry */
68  ShutDownWaitEntry->Thread = Thread;
69 
70  /* Acquire the shutdown list lock */
72 
73  /* Check if the list is still available */
75  {
76  /* Insert the item in the list */
77  ShutDownWaitEntry->NextEntry = PopShutdownThreadList;
78  PopShutdownThreadList = ShutDownWaitEntry;
79 
80  /* We are successful */
82  }
83  else
84  {
85  /* We cannot proceed, cleanup and return failure */
87  ExFreePoolWithTag(ShutDownWaitEntry, 'LSoP');
89  }
90 
91  /* Release the list lock */
93 
94  /* Return the status */
95  return Status;
96 }
struct _POP_SHUTDOWN_WAIT_ENTRY * NextEntry
Definition: po.h:260
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define PAGED_CODE()
Definition: video.h:57
smooth NULL
Definition: ftsmooth.c:416
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
BOOLEAN PopShutdownListAvailable
Definition: poshtdwn.c:25
Status
Definition: gdiplustypes.h:24
PPOP_SHUTDOWN_WAIT_ENTRY PopShutdownThreadList
Definition: poshtdwn.c:22
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
Definition: po.h:258
#define ObReferenceObject
Definition: obfuncs.h:204
PETHREAD Thread
Definition: po.h:261
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
return STATUS_SUCCESS
Definition: btrfs.c:2938
KGUARDED_MUTEX PopShutdownListMutex
Definition: poshtdwn.c:24

Referenced by PoRequestShutdownEvent().

Variable Documentation

◆ PopShutdownEvent

KEVENT PopShutdownEvent

Definition at line 21 of file poshtdwn.c.

Referenced by PopInitShutdownList(), PopProcessShutDownLists(), and PoRequestShutdownEvent().

◆ PopShutdownListAvailable

BOOLEAN PopShutdownListAvailable

◆ PopShutdownListMutex

◆ PopShutdownPowerOffPolicy

ULONG PopShutdownPowerOffPolicy

Definition at line 20 of file poshtdwn.c.

Referenced by PopReadShutdownPolicy(), and PopShutdownSystem().

◆ PopShutdownQueue

LIST_ENTRY PopShutdownQueue

◆ PopShutdownThreadList

PPOP_SHUTDOWN_WAIT_ENTRY PopShutdownThreadList

Definition at line 22 of file poshtdwn.c.

Referenced by PopInitShutdownList(), PopProcessShutDownLists(), and PoRequestShutdownWait().