71 CallAtPassiveLevel =
TRUE;
76 NextStack->Parameters.Power.State.DeviceState ==
PowerDeviceD0)
78 CallAtPassiveLevel =
FALSE;
83 CallAtPassiveLevel =
FALSE;
87 if (CallAtPassiveLevel)
151 Stack->Parameters.Others.Argument4,
307 if (TopDeviceObject == PowerStateContext->
PowerDevice)
343 DPRINT1(
"No system power driver available\n");
351 DPRINT(
"An FDO was not attached\n");
370 DPRINT1(
"Query system power state failed; changing state anyway\n");
410 (
PVOID)&GUID_DEVICE_SYS_BUTTON,
421 (
PVOID)&GUID_DEVICE_LID,
432 (
PVOID)&GUID_DEVICE_BATTERY,
451 if (
strstr(CommandLine,
"NOACPI")) ForceAcpiDisable =
TRUE;
453 if (ForceAcpiDisable)
514 Prcb->PowerState.Idle0KernelTimeLimit = 0xFFFFFFFF;
515 Prcb->PowerState.CurrentThrottle = 100;
516 Prcb->PowerState.CurrentThrottleIndex = 0;
517 Prcb->PowerState.IdleFunction =
PopIdle0;
566 DPRINT1(
"PoShutdownBugCheck called\n");
625 return PopPresentIrp(NextStack,
Irp);
687 Irp->IoStatus.Information = 0;
696 Stack->DeviceObject = TopDeviceObject;
716 PoCallDriver(TopDeviceObject,
Irp);
803 DPRINT(
"NtPowerInformation(PowerInformationLevel 0x%x, InputBuffer 0x%p, "
804 "InputBufferLength 0x%x, OutputBuffer 0x%p, OutputBufferLength 0x%x)\n",
805 PowerInformationLevel,
823 switch (PowerInformationLevel)
895 PowerInformation->
Number = 0;
896 PowerInformation->
MaxMhz = 1000;
915 DPRINT1(
"PowerInformationLevel 0x%x is UNIMPLEMENTED! Have a nice day.\n",
916 PowerInformationLevel);
1029 DPRINT1(
"NtSetSystemPowerState: Bad parameters!\n");
1030 DPRINT1(
" SystemAction: 0x%x\n", SystemAction);
1043 DPRINT1(
"ERROR: Privilege not held for shutdown\n");
1055 DPRINT(
"Stopping lazy flush\n");
1059 Action.Action = SystemAction;
1063 DPRINT(
"Notifying callbacks\n");
1067 DPRINT(
"Swapping worker threads\n");
1100 DPRINT(
"Flushing volumes\n");
1107 DPRINT(
"Cache flushed %lu pages\n", Dummy);
1116 DPRINT(
"Queueing shutdown thread\n");
1142 DPRINT1(
"System is still up and running, you may not have chosen a yet supported power option: %u\n",
PopAction.
Action);
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define STATUS_PRIVILEGE_NOT_HELD
PRTL_UNICODE_STRING_BUFFER PULONG PULONG Unknown4
char * strstr(char *String1, char *String2)
_In_ ULONG _In_ BOOLEAN LogError
VOID NTAPI CmSetLazyFlushState(IN BOOLEAN Enable)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES IN DWORD IN DWORD IN DWORD Unknown5
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES IN DWORD Unknown3
#define STATUS_NOT_SUPPORTED
#define STATUS_NOT_IMPLEMENTED
#define NT_SUCCESS(StatCode)
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
VOID NTAPI KeSetTargetProcessorDpc(IN PKDPC Dpc, IN CCHAR Number)
_In_ PIO_STACK_LOCATION IrpSp
#define _IRQL_requires_same_
#define _IRQL_requires_max_(irql)
#define KeRaiseIrql(irql, oldIrql)
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define KeInitializeEvent(pEvt, foo, foo2)
#define KeLowerIrql(oldIrql)
#define KeGetCurrentIrql()
#define InitializeListHead(ListHead)
#define KeInitializeSpinLock(sl)
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
VOID FASTCALL KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
VOID NTAPI HalProcessorIdle(VOID)
#define KeGetCurrentThread
LONG NTAPI ExSystemExceptionFilter(VOID)
#define EXCEPTION_EXECUTE_HANDLER
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
PLOADER_PARAMETER_BLOCK KeLoaderBlock
static OUT PIO_STATUS_BLOCK IoStatusBlock
#define _Use_decl_annotations_
#define _In_reads_opt_(size)
#define _Analysis_assume_(expr)
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
#define KeGetPreviousMode()
#define DNF_LEGACY_DRIVER
NTSYSCALLAPI NTSTATUS NTAPI ZwSetSystemPowerState(_In_ POWER_ACTION SystemAction, _In_ SYSTEM_POWER_STATE MinSystemState, _In_ ULONG Flags)
_In_ ULONG _In_ ULONG _In_ ULONG Length
#define IoSkipCurrentIrpStackLocation(Irp)
NTSTATUS CcRosFlushDirtyPages(ULONG Target, PULONG Count, BOOLEAN Wait, BOOLEAN CalledFromLazy)
PCALLBACK_OBJECT PowerStateCallback
VOID NTAPI ExNotifyCallback(IN PCALLBACK_OBJECT CallbackObject, IN PVOID Argument1, IN PVOID Argument2)
#define IopInitDeviceTreeTraverseContext( _DeviceTreeTraverseContext, _DeviceNode, _Action, _Context)
NTSTATUS IopGetSystemPowerDeviceObject(IN PDEVICE_OBJECT *DeviceObject)
NTSTATUS IopTraverseDeviceTree(PDEVICETREE_TRAVERSE_CONTEXT Context)
PDEVICE_NODE IopRootDeviceNode
ULONG NTAPI KeSuspendThread(PKTHREAD Thread)
const LUID SeShutdownPrivilege
PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject)
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
VOID NTAPI IoFreeIrp(IN PIRP Irp)
PVOID NTAPI PoRegisterSystemState(IN PVOID StateHandle, IN EXECUTION_STATE Flags)
VOID NTAPI PopPerfIdleDpc(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
NTSTATUS NTAPI PoCancelDeviceNotify(IN PVOID NotifyBlock)
NTSTATUS PopSetSystemPowerStateTraverse(PDEVICE_NODE DeviceNode, PVOID Context)
VOID NTAPI PoSetHiberRange(IN PVOID HiberContext, IN ULONG Flags, IN OUT PVOID StartPage, IN ULONG Length, IN ULONG PageTag)
POWER_STATE NTAPI PoSetPowerState(IN PDEVICE_OBJECT DeviceObject, IN POWER_STATE_TYPE Type, IN POWER_STATE State)
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
NTSTATUS PopSendQuerySystemPowerState(PDEVICE_OBJECT DeviceObject, SYSTEM_POWER_STATE SystemState, POWER_ACTION PowerAction)
NTSTATUS NTAPI NtInitiatePowerAction(IN POWER_ACTION SystemAction, IN SYSTEM_POWER_STATE MinSystemState, IN ULONG Flags, IN BOOLEAN Asynchronous)
VOID NTAPI PoShutdownBugCheck(IN BOOLEAN LogError, IN ULONG BugCheckCode, IN ULONG_PTR BugCheckParameter1, IN ULONG_PTR BugCheckParameter2, IN ULONG_PTR BugCheckParameter3, IN ULONG_PTR BugCheckParameter4)
PULONG NTAPI PoRegisterDeviceForIdleDetection(IN PDEVICE_OBJECT DeviceObject, IN ULONG ConservationIdleTime, IN ULONG PerformanceIdleTime, IN DEVICE_POWER_STATE State)
BOOLEAN NTAPI PoInitSystem(IN ULONG BootPhase)
struct _POWER_STATE_TRAVERSE_CONTEXT * PPOWER_STATE_TRAVERSE_CONTEXT
BOOLEAN NTAPI NtIsSystemResumeAutomatic(VOID)
VOID NTAPI PoUnregisterSystemState(IN PVOID StateHandle)
NTSTATUS NTAPI PoRegisterDeviceNotify(OUT PVOID Unknown0, IN ULONG Unknown1, IN ULONG Unknown2, IN ULONG Unknown3, IN PVOID Unknown4, IN PVOID Unknown5)
NTSTATUS NTAPI NtRequestWakeupLatency(IN LATENCY_TIME Latency)
NTSTATUS NTAPI NtSetThreadExecutionState(IN EXECUTION_STATE esFlags, OUT EXECUTION_STATE *PreviousFlags)
WORK_QUEUE_ITEM PopShutdownWorkItem
VOID NTAPI PopCleanupPowerState(IN PPOWER_STATE PowerState)
struct _POWER_STATE_TRAVERSE_CONTEXT POWER_STATE_TRAVERSE_CONTEXT
NTSTATUS PopSendSetSystemPowerState(PDEVICE_OBJECT DeviceObject, SYSTEM_POWER_STATE SystemState, POWER_ACTION PowerAction)
VOID NTAPI PopPerfIdle(PPROCESSOR_POWER_STATE PowerState)
NTSTATUS PopQuerySystemPowerStateTraverse(PDEVICE_NODE DeviceNode, PVOID Context)
SYSTEM_POWER_CAPABILITIES PopCapabilities
static IO_COMPLETION_ROUTINE PopRequestPowerIrpCompletion
NTSTATUS NTAPI NtSetSystemPowerState(IN POWER_ACTION SystemAction, IN SYSTEM_POWER_STATE MinSystemState, IN ULONG Flags)
NTSTATUS NTAPI PoRequestPowerIrp(_In_ PDEVICE_OBJECT DeviceObject, _In_ UCHAR MinorFunction, _In_ POWER_STATE PowerState, _In_opt_ PREQUEST_POWER_COMPLETE CompletionFunction, _In_opt_ __drv_aliasesMem PVOID Context, _Outptr_opt_ PIRP *pIrp)
NTSTATUS NTAPI PopSetSystemPowerState(SYSTEM_POWER_STATE PowerState, POWER_ACTION PowerAction)
static WORKER_THREAD_ROUTINE PopPassivePowerCall
NTSTATUS NTAPI NtPowerInformation(IN POWER_INFORMATION_LEVEL PowerInformationLevel, IN PVOID InputBuffer OPTIONAL, IN ULONG InputBufferLength, OUT PVOID OutputBuffer OPTIONAL, IN ULONG OutputBufferLength)
VOID NTAPI PoInitializePrcb(IN PKPRCB Prcb)
NTSTATUS NTAPI NtGetDevicePowerState(IN HANDLE Device, IN PDEVICE_POWER_STATE PowerState)
VOID NTAPI PoSetSystemState(IN EXECUTION_STATE Flags)
PDEVICE_NODE PopSystemPowerDeviceNode
POP_POWER_ACTION PopAction
VOID FASTCALL PopIdle0(IN PPROCESSOR_POWER_STATE PowerState)
BOOLEAN NTAPI SeSinglePrivilegeCheck(_In_ LUID PrivilegeValue, _In_ KPROCESSOR_MODE PreviousMode)
Checks if a single privilege is present in the context of the calling thread.
_In_ SYSTEM_POWER_STATE MinSystemState
#define POWER_ACTION_UI_ALLOWED
_In_ SYSTEM_POWER_STATE _In_ ULONG _In_ BOOLEAN Asynchronous
enum _POWER_STATE_TYPE POWER_STATE_TYPE
struct SYSTEM_BATTERY_STATE * PSYSTEM_BATTERY_STATE
struct SYSTEM_POWER_CAPABILITIES * PSYSTEM_POWER_CAPABILITIES
#define POWER_ACTION_LOCK_CONSOLE
#define POWER_ACTION_QUERY_ALLOWED
#define POWER_ACTION_OVERRIDE_APPS
_Out_ EXECUTION_STATE * PreviousFlags
@ PowerActionShutdownReset
enum _DEVICE_POWER_STATE * PDEVICE_POWER_STATE
enum _POWER_INFORMATION_LEVEL POWER_INFORMATION_LEVEL
enum _DEVICE_POWER_STATE DEVICE_POWER_STATE
enum _SYSTEM_POWER_STATE SYSTEM_POWER_STATE
#define POWER_ACTION_LIGHTEST_FIRST
#define POWER_ACTION_DISABLE_WAKES
@ SystemPowerCapabilities
#define POWER_ACTION_CRITICAL
struct _PROCESSOR_POWER_INFORMATION * PPROCESSOR_POWER_INFORMATION
#define STATUS_SYSTEM_SHUTDOWN
#define STATUS_INVALID_PARAMETER_2
NTSTATUS NTAPI IoRegisterPlugPlayNotification(_In_ IO_NOTIFICATION_EVENT_CATEGORY EventCategory, _In_ ULONG EventCategoryFlags, _In_opt_ PVOID EventCategoryData, _In_ PDRIVER_OBJECT DriverObject, _In_ PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine, _Inout_opt_ PVOID Context, _Out_ PVOID *NotificationEntry)
LIST_ENTRY PopVolumeDevices
VOID NTAPI PopInitShutdownList(VOID)
VOID NTAPI PopReadShutdownPolicy(VOID)
@ PolicyDeviceSystemButton
NTSTATUS NTAPI PopAddRemoveSysCapsCallback(IN PVOID NotificationStructure, IN PVOID Context)
KSPIN_LOCK PopDopeGlobalLock
VOID NTAPI PopFlushVolumes(IN BOOLEAN ShuttingDown)
KGUARDED_MUTEX PopVolumeLock
VOID NTAPI PopGracefulShutdown(IN PVOID Context)
#define _SEH2_GetExceptionCode()
#define _SEH2_EXCEPT(...)
#define _SEH2_YIELD(__stmt)
PEPROCESS PsInitialSystemProcess
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
#define ASSERT_IRQL_LESS_OR_EQUAL(x)
#define ProbeForWriteUlong(Ptr)
#define STATUS_MORE_PROCESSING_REQUIRED
#define STATUS_BUFFER_TOO_SMALL
PULONG MinorVersion OPTIONAL
BOOLEAN SystemBatteriesPresent
PDEVICE_OBJECT PhysicalDeviceObject
PDEVICE_OBJECT DeviceObject
struct _IO_STACK_LOCATION::@3974::@4010 Power
union _IO_STACK_LOCATION::@1575 Parameters
PLOADER_PARAMETER_EXTENSION Extension
SYSTEM_POWER_STATE SystemPowerState
PDEVICE_OBJECT PowerDevice
VOID NTAPI KeInitializeTimerEx(OUT PKTIMER Timer, IN TIMER_TYPE Type)
#define UNIMPLEMENTED_ONCE
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_INVALID_PARAMETER
#define STATUS_UNSUCCESSFUL
#define STATUS_INSUFFICIENT_RESOURCES
DEVICE_POWER_STATE DeviceState
SYSTEM_POWER_STATE SystemState
_Must_inspect_result_ _In_ WDFDEVICE Device
_In_ PDEVICE_OBJECT DeviceObject
_In_ WDF_POWER_DEVICE_STATE PreviousState
_In_ WDFDEVICE _In_ PWDF_DEVICE_POWER_CAPABILITIES PowerCapabilities
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_POWER_STATE PowerState
_In_ UCHAR _In_ UCHAR MinorFunction
_Must_inspect_result_ _In_ PWDF_DPC_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFDPC * Dpc
_Must_inspect_result_ _In_ WDFDEVICE Fdo
_In_ WDFREQUEST _In_ size_t OutputBufferLength
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionRoutine
int WINAPI StartPage(_In_ HDC)
VOID NTAPI ExQueueWorkItem(IN PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType)
VOID NTAPI ExSwapinWorkerThreads(IN BOOLEAN AllowSwap)
_Must_inspect_result_ _In_ ULONG Flags
#define ExInitializeWorkItem(Item, Routine, Context)
struct _WORK_QUEUE_ITEM * PWORK_QUEUE_ITEM
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
FORCEINLINE VOID IoSetNextIrpStackLocation(_Inout_ PIRP Irp)
_In_ ULONG _In_opt_ PVOID _In_ PDRIVER_OBJECT _In_ PDRIVER_NOTIFICATION_CALLBACK_ROUTINE _Inout_opt_ __drv_aliasesMem PVOID _Outptr_result_nullonfailure_ _At_ * NotificationEntry(return==0, __drv_allocatesMem(Mem))) PVOID *NotificationEntry
#define SL_PENDING_RETURNED
@ EventCategoryDeviceInterfaceChange
_In_ SYSTEM_POWER_STATE SystemPowerState
#define IRP_MN_QUERY_POWER
#define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
_In_opt_ PVOID DeferredContext
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
#define ObDereferenceObject
_In_ ULONG _In_ ULONG PerformanceIdleTime
_In_ UCHAR _In_ POWER_STATE _In_opt_ PREQUEST_POWER_COMPLETE CompletionFunction
_In_ ULONG ConservationIdleTime
REQUEST_POWER_COMPLETE * PREQUEST_POWER_COMPLETE
#define PsGetCurrentProcess
_Inout_opt_ PVOID Parameter
_In_ KPROCESSOR_MODE PreviousMode