mirror of
https://github.com/reactos/reactos.git
synced 2025-06-10 20:34:59 +00:00
[NTOS:PO]: Whitespace fixes only!
svn path=/trunk/; revision=70535
This commit is contained in:
parent
d5691eba70
commit
63025d14ef
2 changed files with 199 additions and 207 deletions
|
@ -16,18 +16,18 @@
|
||||||
|
|
||||||
typedef struct _SYS_BUTTON_CONTEXT
|
typedef struct _SYS_BUTTON_CONTEXT
|
||||||
{
|
{
|
||||||
PDEVICE_OBJECT DeviceObject;
|
PDEVICE_OBJECT DeviceObject;
|
||||||
PIO_WORKITEM WorkItem;
|
PIO_WORKITEM WorkItem;
|
||||||
KEVENT Event;
|
KEVENT Event;
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
ULONG SysButton;
|
ULONG SysButton;
|
||||||
} SYS_BUTTON_CONTEXT, *PSYS_BUTTON_CONTEXT;
|
} SYS_BUTTON_CONTEXT, *PSYS_BUTTON_CONTEXT;
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
PopGetSysButton(
|
PopGetSysButton(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PVOID Context);
|
IN PVOID Context);
|
||||||
|
|
||||||
PKWIN32_POWEREVENT_CALLOUT PopEventCallout;
|
PKWIN32_POWEREVENT_CALLOUT PopEventCallout;
|
||||||
extern PCALLBACK_OBJECT SetSystemTimeCallback;
|
extern PCALLBACK_OBJECT SetSystemTimeCallback;
|
||||||
|
@ -57,25 +57,25 @@ PoNotifySystemTimeSet(VOID)
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
PopGetSysButtonCompletion(
|
PopGetSysButtonCompletion(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp,
|
IN PIRP Irp,
|
||||||
IN PVOID Context)
|
IN PVOID Context)
|
||||||
{
|
{
|
||||||
PSYS_BUTTON_CONTEXT SysButtonContext = Context;
|
PSYS_BUTTON_CONTEXT SysButtonContext = Context;
|
||||||
ULONG SysButton;
|
ULONG SysButton;
|
||||||
|
|
||||||
/* The DeviceObject can be NULL, so use the one we stored */
|
/* The DeviceObject can be NULL, so use the one we stored */
|
||||||
DeviceObject = SysButtonContext->DeviceObject;
|
DeviceObject = SysButtonContext->DeviceObject;
|
||||||
|
|
||||||
/* FIXME: What do do with the sys button event? */
|
/* FIXME: What do do with the sys button event? */
|
||||||
SysButton = *(PULONG)Irp->AssociatedIrp.SystemBuffer;
|
SysButton = *(PULONG)Irp->AssociatedIrp.SystemBuffer;
|
||||||
{
|
{
|
||||||
DPRINT1("A device reported the event 0x%x (", SysButton);
|
DPRINT1("A device reported the event 0x%x (", SysButton);
|
||||||
if (SysButton & SYS_BUTTON_POWER) DbgPrint(" POWER");
|
if (SysButton & SYS_BUTTON_POWER) DbgPrint(" POWER");
|
||||||
if (SysButton & SYS_BUTTON_SLEEP) DbgPrint(" SLEEP");
|
if (SysButton & SYS_BUTTON_SLEEP) DbgPrint(" SLEEP");
|
||||||
if (SysButton & SYS_BUTTON_LID) DbgPrint(" LID");
|
if (SysButton & SYS_BUTTON_LID) DbgPrint(" LID");
|
||||||
if (SysButton == 0) DbgPrint(" WAKE");
|
if (SysButton == 0) DbgPrint(" WAKE");
|
||||||
DbgPrint(" )\n");
|
DbgPrint(" )\n");
|
||||||
|
|
||||||
if (SysButton & SYS_BUTTON_POWER)
|
if (SysButton & SYS_BUTTON_POWER)
|
||||||
{
|
{
|
||||||
|
@ -84,65 +84,62 @@ PopGetSysButtonCompletion(
|
||||||
|
|
||||||
ZwShutdownSystem(ShutdownNoReboot);
|
ZwShutdownSystem(ShutdownNoReboot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate a new workitem to send the next IOCTL_GET_SYS_BUTTON_EVENT */
|
/* Allocate a new workitem to send the next IOCTL_GET_SYS_BUTTON_EVENT */
|
||||||
SysButtonContext->WorkItem = IoAllocateWorkItem(DeviceObject);
|
SysButtonContext->WorkItem = IoAllocateWorkItem(DeviceObject);
|
||||||
if (!SysButtonContext->WorkItem)
|
if (!SysButtonContext->WorkItem)
|
||||||
{
|
{
|
||||||
DPRINT("IoAllocateWorkItem() failed\n");
|
DPRINT("IoAllocateWorkItem() failed\n");
|
||||||
ExFreePoolWithTag(SysButtonContext, 'IWOP');
|
ExFreePoolWithTag(SysButtonContext, 'IWOP');
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
IoQueueWorkItem(
|
IoQueueWorkItem(SysButtonContext->WorkItem,
|
||||||
SysButtonContext->WorkItem,
|
PopGetSysButton,
|
||||||
PopGetSysButton,
|
DelayedWorkQueue,
|
||||||
DelayedWorkQueue,
|
SysButtonContext);
|
||||||
SysButtonContext);
|
|
||||||
|
|
||||||
return STATUS_SUCCESS /* STATUS_CONTINUE_COMPLETION */;
|
return STATUS_SUCCESS /* STATUS_CONTINUE_COMPLETION */;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
PopGetSysButton(
|
PopGetSysButton(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PVOID Context)
|
IN PVOID Context)
|
||||||
{
|
{
|
||||||
PSYS_BUTTON_CONTEXT SysButtonContext = Context;
|
PSYS_BUTTON_CONTEXT SysButtonContext = Context;
|
||||||
PIO_WORKITEM CurrentWorkItem = SysButtonContext->WorkItem;
|
PIO_WORKITEM CurrentWorkItem = SysButtonContext->WorkItem;
|
||||||
PIRP Irp;
|
PIRP Irp;
|
||||||
|
|
||||||
/* Get button pressed (IOCTL_GET_SYS_BUTTON_EVENT) */
|
/* Get button pressed (IOCTL_GET_SYS_BUTTON_EVENT) */
|
||||||
KeInitializeEvent(&SysButtonContext->Event, NotificationEvent, FALSE);
|
KeInitializeEvent(&SysButtonContext->Event, NotificationEvent, FALSE);
|
||||||
Irp = IoBuildDeviceIoControlRequest(
|
Irp = IoBuildDeviceIoControlRequest(IOCTL_GET_SYS_BUTTON_EVENT,
|
||||||
IOCTL_GET_SYS_BUTTON_EVENT,
|
DeviceObject,
|
||||||
DeviceObject,
|
NULL,
|
||||||
NULL,
|
0,
|
||||||
0,
|
&SysButtonContext->SysButton,
|
||||||
&SysButtonContext->SysButton,
|
sizeof(SysButtonContext->SysButton),
|
||||||
sizeof(SysButtonContext->SysButton),
|
FALSE,
|
||||||
FALSE,
|
&SysButtonContext->Event,
|
||||||
&SysButtonContext->Event,
|
&SysButtonContext->IoStatusBlock);
|
||||||
&SysButtonContext->IoStatusBlock);
|
if (Irp)
|
||||||
if (Irp)
|
{
|
||||||
{
|
IoSetCompletionRoutine(Irp,
|
||||||
IoSetCompletionRoutine(
|
PopGetSysButtonCompletion,
|
||||||
Irp,
|
SysButtonContext,
|
||||||
PopGetSysButtonCompletion,
|
TRUE,
|
||||||
SysButtonContext,
|
FALSE,
|
||||||
TRUE,
|
FALSE);
|
||||||
FALSE,
|
IoCallDriver(DeviceObject, Irp);
|
||||||
FALSE);
|
}
|
||||||
IoCallDriver(DeviceObject, Irp);
|
else
|
||||||
}
|
{
|
||||||
else
|
DPRINT1("IoBuildDeviceIoControlRequest() failed\n");
|
||||||
{
|
ExFreePoolWithTag(SysButtonContext, 'IWOP');
|
||||||
DPRINT1("IoBuildDeviceIoControlRequest() failed\n");
|
}
|
||||||
ExFreePoolWithTag(SysButtonContext, 'IWOP');
|
|
||||||
}
|
|
||||||
|
|
||||||
IoFreeWorkItem(CurrentWorkItem);
|
IoFreeWorkItem(CurrentWorkItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -150,146 +147,141 @@ NTAPI
|
||||||
PopAddRemoveSysCapsCallback(IN PVOID NotificationStructure,
|
PopAddRemoveSysCapsCallback(IN PVOID NotificationStructure,
|
||||||
IN PVOID Context)
|
IN PVOID Context)
|
||||||
{
|
{
|
||||||
PDEVICE_INTERFACE_CHANGE_NOTIFICATION Notification;
|
PDEVICE_INTERFACE_CHANGE_NOTIFICATION Notification;
|
||||||
PSYS_BUTTON_CONTEXT SysButtonContext;
|
PSYS_BUTTON_CONTEXT SysButtonContext;
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
HANDLE FileHandle;
|
HANDLE FileHandle;
|
||||||
PDEVICE_OBJECT DeviceObject;
|
PDEVICE_OBJECT DeviceObject;
|
||||||
PFILE_OBJECT FileObject;
|
PFILE_OBJECT FileObject;
|
||||||
PIRP Irp;
|
PIRP Irp;
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
KEVENT Event;
|
KEVENT Event;
|
||||||
BOOLEAN Arrival;
|
BOOLEAN Arrival;
|
||||||
ULONG Caps;
|
ULONG Caps;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT("PopAddRemoveSysCapsCallback(%p %p)\n",
|
DPRINT("PopAddRemoveSysCapsCallback(%p %p)\n",
|
||||||
NotificationStructure, Context);
|
NotificationStructure, Context);
|
||||||
|
|
||||||
Notification = (PDEVICE_INTERFACE_CHANGE_NOTIFICATION)NotificationStructure;
|
Notification = (PDEVICE_INTERFACE_CHANGE_NOTIFICATION)NotificationStructure;
|
||||||
if (Notification->Version != 1)
|
if (Notification->Version != 1)
|
||||||
return STATUS_REVISION_MISMATCH;
|
return STATUS_REVISION_MISMATCH;
|
||||||
if (Notification->Size != sizeof(DEVICE_INTERFACE_CHANGE_NOTIFICATION))
|
if (Notification->Size != sizeof(DEVICE_INTERFACE_CHANGE_NOTIFICATION))
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
if (RtlCompareMemory(&Notification->Event, &GUID_DEVICE_INTERFACE_ARRIVAL, sizeof(GUID)) == sizeof(GUID))
|
if (RtlCompareMemory(&Notification->Event, &GUID_DEVICE_INTERFACE_ARRIVAL, sizeof(GUID)) == sizeof(GUID))
|
||||||
Arrival = TRUE;
|
Arrival = TRUE;
|
||||||
else if (RtlCompareMemory(&Notification->Event, &GUID_DEVICE_INTERFACE_REMOVAL, sizeof(GUID)) == sizeof(GUID))
|
else if (RtlCompareMemory(&Notification->Event, &GUID_DEVICE_INTERFACE_REMOVAL, sizeof(GUID)) == sizeof(GUID))
|
||||||
Arrival = FALSE;
|
Arrival = FALSE;
|
||||||
else
|
else
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
|
||||||
if (Arrival)
|
if (Arrival)
|
||||||
{
|
{
|
||||||
DPRINT("Arrival of %wZ\n", Notification->SymbolicLinkName);
|
DPRINT("Arrival of %wZ\n", Notification->SymbolicLinkName);
|
||||||
|
|
||||||
/* Open the device */
|
/* Open the device */
|
||||||
InitializeObjectAttributes(
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
&ObjectAttributes,
|
Notification->SymbolicLinkName,
|
||||||
Notification->SymbolicLinkName,
|
OBJ_KERNEL_HANDLE,
|
||||||
OBJ_KERNEL_HANDLE,
|
NULL,
|
||||||
NULL,
|
NULL);
|
||||||
NULL);
|
Status = ZwOpenFile(&FileHandle,
|
||||||
Status = ZwOpenFile(
|
FILE_READ_DATA,
|
||||||
&FileHandle,
|
&ObjectAttributes,
|
||||||
FILE_READ_DATA,
|
&IoStatusBlock,
|
||||||
&ObjectAttributes,
|
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
&IoStatusBlock,
|
0);
|
||||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
if (!NT_SUCCESS(Status))
|
||||||
0);
|
{
|
||||||
if (!NT_SUCCESS(Status))
|
DPRINT1("ZwOpenFile() failed with status 0x%08lx\n", Status);
|
||||||
{
|
return Status;
|
||||||
DPRINT1("ZwOpenFile() failed with status 0x%08lx\n", Status);
|
}
|
||||||
return Status;
|
Status = ObReferenceObjectByHandle(FileHandle,
|
||||||
}
|
FILE_READ_DATA,
|
||||||
Status = ObReferenceObjectByHandle(
|
IoFileObjectType,
|
||||||
FileHandle,
|
KernelMode,
|
||||||
FILE_READ_DATA,
|
(PVOID*)&FileObject,
|
||||||
IoFileObjectType,
|
NULL);
|
||||||
KernelMode,
|
if (!NT_SUCCESS(Status))
|
||||||
(PVOID*)&FileObject,
|
{
|
||||||
NULL);
|
DPRINT1("ObReferenceObjectByHandle() failed with status 0x%08lx\n", Status);
|
||||||
if (!NT_SUCCESS(Status))
|
ZwClose(FileHandle);
|
||||||
{
|
return Status;
|
||||||
DPRINT1("ObReferenceObjectByHandle() failed with status 0x%08lx\n", Status);
|
}
|
||||||
ZwClose(FileHandle);
|
DeviceObject = IoGetRelatedDeviceObject(FileObject);
|
||||||
return Status;
|
ObDereferenceObject(FileObject);
|
||||||
}
|
|
||||||
DeviceObject = IoGetRelatedDeviceObject(FileObject);
|
|
||||||
ObDereferenceObject(FileObject);
|
|
||||||
|
|
||||||
/* Get capabilities (IOCTL_GET_SYS_BUTTON_CAPS) */
|
/* Get capabilities (IOCTL_GET_SYS_BUTTON_CAPS) */
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||||
Irp = IoBuildDeviceIoControlRequest(
|
Irp = IoBuildDeviceIoControlRequest(IOCTL_GET_SYS_BUTTON_CAPS,
|
||||||
IOCTL_GET_SYS_BUTTON_CAPS,
|
DeviceObject,
|
||||||
DeviceObject,
|
NULL,
|
||||||
NULL,
|
0,
|
||||||
0,
|
&Caps,
|
||||||
&Caps,
|
sizeof(Caps),
|
||||||
sizeof(Caps),
|
FALSE,
|
||||||
FALSE,
|
&Event,
|
||||||
&Event,
|
&IoStatusBlock);
|
||||||
&IoStatusBlock);
|
if (!Irp)
|
||||||
if (!Irp)
|
{
|
||||||
{
|
DPRINT1("IoBuildDeviceIoControlRequest() failed\n");
|
||||||
DPRINT1("IoBuildDeviceIoControlRequest() failed\n");
|
ZwClose(FileHandle);
|
||||||
ZwClose(FileHandle);
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
}
|
||||||
}
|
Status = IoCallDriver(DeviceObject, Irp);
|
||||||
Status = IoCallDriver(DeviceObject, Irp);
|
if (Status == STATUS_PENDING)
|
||||||
if (Status == STATUS_PENDING)
|
{
|
||||||
{
|
DPRINT("IOCTL_GET_SYS_BUTTON_CAPS pending\n");
|
||||||
DPRINT("IOCTL_GET_SYS_BUTTON_CAPS pending\n");
|
KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
|
||||||
KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
|
Status = IoStatusBlock.Status;
|
||||||
Status = IoStatusBlock.Status;
|
}
|
||||||
}
|
if (!NT_SUCCESS(Status))
|
||||||
if (!NT_SUCCESS(Status))
|
{
|
||||||
{
|
DPRINT1("Sending IOCTL_GET_SYS_BUTTON_CAPS failed with status 0x%08x\n", Status);
|
||||||
DPRINT1("Sending IOCTL_GET_SYS_BUTTON_CAPS failed with status 0x%08x\n", Status);
|
ZwClose(FileHandle);
|
||||||
ZwClose(FileHandle);
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* FIXME: What do do with the capabilities? */
|
/* FIXME: What do do with the capabilities? */
|
||||||
{
|
{
|
||||||
DPRINT("Device capabilities: 0x%x (", Caps);
|
DPRINT("Device capabilities: 0x%x (", Caps);
|
||||||
if (Caps & SYS_BUTTON_POWER) DPRINT(" POWER");
|
if (Caps & SYS_BUTTON_POWER) DPRINT(" POWER");
|
||||||
if (Caps & SYS_BUTTON_SLEEP) DPRINT(" SLEEP");
|
if (Caps & SYS_BUTTON_SLEEP) DPRINT(" SLEEP");
|
||||||
if (Caps & SYS_BUTTON_LID) DPRINT(" LID");
|
if (Caps & SYS_BUTTON_LID) DPRINT(" LID");
|
||||||
DPRINT(" )\n");
|
DPRINT(" )\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
SysButtonContext = ExAllocatePoolWithTag(NonPagedPool,
|
SysButtonContext = ExAllocatePoolWithTag(NonPagedPool,
|
||||||
sizeof(SYS_BUTTON_CONTEXT),
|
sizeof(SYS_BUTTON_CONTEXT),
|
||||||
'IWOP');
|
'IWOP');
|
||||||
if (!SysButtonContext)
|
if (!SysButtonContext)
|
||||||
{
|
{
|
||||||
DPRINT1("ExAllocatePoolWithTag() failed\n");
|
DPRINT1("ExAllocatePoolWithTag() failed\n");
|
||||||
ZwClose(FileHandle);
|
ZwClose(FileHandle);
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Queue a work item to get sys button event */
|
/* Queue a work item to get sys button event */
|
||||||
SysButtonContext->WorkItem = IoAllocateWorkItem(DeviceObject);
|
SysButtonContext->WorkItem = IoAllocateWorkItem(DeviceObject);
|
||||||
SysButtonContext->DeviceObject = DeviceObject;
|
SysButtonContext->DeviceObject = DeviceObject;
|
||||||
if (!SysButtonContext->WorkItem)
|
if (!SysButtonContext->WorkItem)
|
||||||
{
|
{
|
||||||
DPRINT1("IoAllocateWorkItem() failed\n");
|
DPRINT1("IoAllocateWorkItem() failed\n");
|
||||||
ZwClose(FileHandle);
|
ZwClose(FileHandle);
|
||||||
ExFreePoolWithTag(SysButtonContext, 'IWOP');
|
ExFreePoolWithTag(SysButtonContext, 'IWOP');
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
}
|
}
|
||||||
IoQueueWorkItem(
|
IoQueueWorkItem(SysButtonContext->WorkItem,
|
||||||
SysButtonContext->WorkItem,
|
PopGetSysButton,
|
||||||
PopGetSysButton,
|
DelayedWorkQueue,
|
||||||
DelayedWorkQueue,
|
SysButtonContext);
|
||||||
SysButtonContext);
|
|
||||||
|
|
||||||
ZwClose(FileHandle);
|
ZwClose(FileHandle);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DPRINT1("Removal of a power capable device not implemented\n");
|
DPRINT1("Removal of a power capable device not implemented\n");
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -622,10 +622,10 @@ PoUnregisterSystemState(IN PVOID StateHandle)
|
||||||
*/
|
*/
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
NtInitiatePowerAction (IN POWER_ACTION SystemAction,
|
NtInitiatePowerAction(IN POWER_ACTION SystemAction,
|
||||||
IN SYSTEM_POWER_STATE MinSystemState,
|
IN SYSTEM_POWER_STATE MinSystemState,
|
||||||
IN ULONG Flags,
|
IN ULONG Flags,
|
||||||
IN BOOLEAN Asynchronous)
|
IN BOOLEAN Asynchronous)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue