Author: tkreuzer
Date: Mon Feb 24 15:14:31 2014
New Revision: 62321
URL:
http://svn.reactos.org/svn/reactos?rev=62321&view=rev
Log:
[NTOSKRNL]
Stubplement IOCTL_WMI_UNREGISTER_GUIDS and IOCTL_WMI_RECEIVE_NOTIFICATIONS, just enough
that the callers don't error out.
Modified:
branches/kernel-fun/reactos/include/reactos/wmiioctl.h
branches/kernel-fun/reactos/ntoskrnl/wmi/wmidrv.c
branches/kernel-fun/reactos/ntoskrnl/wmi/wmip.h
Modified: branches/kernel-fun/reactos/include/reactos/wmiioctl.h
URL:
http://svn.reactos.org/svn/reactos/branches/kernel-fun/reactos/include/reac…
==============================================================================
--- branches/kernel-fun/reactos/include/reactos/wmiioctl.h [iso-8859-1] (original)
+++ branches/kernel-fun/reactos/include/reactos/wmiioctl.h [iso-8859-1] Mon Feb 24
15:14:31 2014
@@ -25,13 +25,13 @@
#define IOCTL_WMI_4e CTL_CODE(FILE_DEVICE_UNKNOWN, 0x4e, METHOD_BUFFERED,
FILE_READ_ACCESS) // 0x224138
#define IOCTL_WMI_4f CTL_CODE(FILE_DEVICE_UNKNOWN, 0x4f, METHOD_BUFFERED,
FILE_READ_ACCESS) // 0x22413C
#define IOCTL_WMI_OPEN_GUID_FOR_EVENTS CTL_CODE(FILE_DEVICE_UNKNOWN, 0x50,
METHOD_BUFFERED, FILE_READ_ACCESS) // 0x224140
-#define IOCTL_WMI_51 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x51, METHOD_BUFFERED,
FILE_WRITE_ACCESS) // 0x228144
+#define IOCTL_WMI_RECEIVE_NOTIFICATIONS CTL_CODE(FILE_DEVICE_UNKNOWN, 0x51,
METHOD_BUFFERED, FILE_WRITE_ACCESS) // 0x228144
#define IOCTL_WMI_52 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x52, METHOD_BUFFERED,
FILE_READ_ACCESS) // 0x224148
#define IOCTL_WMI_REGISTER_GUIDS CTL_CODE(FILE_DEVICE_UNKNOWN, 0x53, METHOD_BUFFERED,
FILE_READ_ACCESS) // 0x22414C, called from ntdll!EtwpRegisterGuids
#define IOCTL_WMI_54 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x54, METHOD_BUFFERED,
FILE_READ_ACCESS) // 0x224150
#define IOCTL_WMI_55 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x55, METHOD_BUFFERED,
FILE_READ_ACCESS) // 0x224154
#define IOCTL_WMI_56 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x56, METHOD_BUFFERED,
FILE_READ_ACCESS) // 0x224158
-#define IOCTL_WMI_57 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x57, METHOD_BUFFERED,
FILE_READ_ACCESS) // 0x22415C
+#define IOCTL_WMI_UNREGISTER_GUIDS CTL_CODE(FILE_DEVICE_UNKNOWN, 0x57, METHOD_BUFFERED,
FILE_READ_ACCESS) // 0x22415C, called from ntdll!WmiUnregisterGuids
#define IOCTL_WMI_58 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x58, METHOD_BUFFERED,
FILE_READ_ACCESS) // 0x224160
#define IOCTL_WMI_59 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x59, METHOD_BUFFERED,
FILE_READ_ACCESS) // 0x224164
#define IOCTL_WMI_5a CTL_CODE(FILE_DEVICE_UNKNOWN, 0x5a, METHOD_BUFFERED,
FILE_WRITE_ACCESS) // 0x228168
Modified: branches/kernel-fun/reactos/ntoskrnl/wmi/wmidrv.c
URL:
http://svn.reactos.org/svn/reactos/branches/kernel-fun/reactos/ntoskrnl/wmi…
==============================================================================
--- branches/kernel-fun/reactos/ntoskrnl/wmi/wmidrv.c [iso-8859-1] (original)
+++ branches/kernel-fun/reactos/ntoskrnl/wmi/wmidrv.c [iso-8859-1] Mon Feb 24 15:14:31
2014
@@ -33,11 +33,35 @@
{
HANDLE Handle;
ULONG Unknown04;
+ TRACEHANDLE TraceHandle;
+ BOOLEAN Unknown10;
+} WMIP_RESULT, *PWMIP_RESULT;
+
+typedef struct _WMI_UNREGISTER_GUID
+{
+ GUID Guid;
+ ULONG Unknown10;
+ ULONG Unknown14;
+ ULONG Unknown18;
+ ULONG Unknown1C;
+} WMI_UNREGISTER_GUID, *PWMI_UNREGISTER_GUID;
+
+typedef struct _WMI_GUID_OBJECT_ENTRY
+{
+ HANDLE Handle;
+ ULONG Unknown04;
+} WMI_GUID_OBJECT_ENTRY, *PWMI_GUID_OBJECT_ENTRY;
+
+typedef struct _WMI_NOTIFICATION
+{
+ ULONG NumberOfGuidObjects;
+ ULONG Unknown04;
ULONG Unknown08;
ULONG Unknown0C;
- BOOLEAN Unknown10;
-} WMIP_RESULT, *PWMIP_RESULT;
-
+ ULONG Unknown10;
+ ULONG Unknown14;
+ WMI_GUID_OBJECT_ENTRY GuidObjects[0];
+} WMI_NOTIFICATION, *PWMI_NOTIFICATION;
PDEVICE_OBJECT WmipServiceDeviceObject;
PDEVICE_OBJECT WmipAdminDeviceObject;
@@ -106,7 +130,7 @@
/* Make sure the input buffer is large enough */
if ((InputLength < sizeof(WMIP_REGISTER_GUIDS)) ||
- (RegisterGuids->RegInfo.BufferSize >
+ (RegisterGuids->RegInfo.BufferSize >
(InputLength - FIELD_OFFSET(WMIP_REGISTER_GUIDS, RegInfo))))
{
return STATUS_UNSUCCESSFUL;
@@ -168,14 +192,139 @@
return Status;
}
- /* Derefernce the GUID object */
+ /* Dereference the GUID object */
ObDereferenceObject(GuidObject);
- /* Return the handle */
+ /* Return the handle (user mode will close it) */
Result->Handle = GuidObjectHandle;
+ Result->TraceHandle = 0;
*OutputLength = 24;
return STATUS_SUCCESS;
+}
+
+
+static
+NTSTATUS
+WmipUnregisterGuids(
+ _In_ PVOID Buffer,
+ _In_ ULONG InputLength,
+ _Inout_ PULONG OutputLength)
+{
+ /* For now we have nothing to do */
+ return STATUS_SUCCESS;
+}
+
+VOID
+NTAPI
+WmipClearIrpObjectList(
+ _In_ PIRP Irp)
+{
+ PWMIP_IRP_CONTEXT IrpContext;
+ PLIST_ENTRY ListEntry;
+ PWMIP_GUID_OBJECT GuidObject;
+
+ /* Get the IRP context */
+ IrpContext = (PWMIP_IRP_CONTEXT)Irp->Tail.Overlay.DriverContext;
+
+ /* Loop all GUID objects attached to this IRP */
+ for (ListEntry = IrpContext->GuidObjectListHead.Flink;
+ ListEntry != &IrpContext->GuidObjectListHead;
+ ListEntry = ListEntry->Flink)
+ {
+ /* Get the GUID object */
+ GuidObject = CONTAINING_RECORD(ListEntry, WMIP_GUID_OBJECT, IrpLink);
+
+ /* Make sure the IRP matches and clear it */
+ ASSERT(GuidObject->Irp == Irp);
+ GuidObject->Irp = NULL;
+
+ /* Remove the entry */
+ RemoveEntryList(ListEntry);
+ }
+}
+
+VOID
+NTAPI
+WmipNotificationIrpCancel(
+ _In_ PDEVICE_OBJECT DeviceObject,
+ _Inout_ PIRP Irp)
+{
+ /* Clear the list */
+ WmipClearIrpObjectList(Irp);
+
+ /* Release the cancel spin lock */
+ IoReleaseCancelSpinLock(Irp->CancelIrql);
+
+ /* Set the status to cancelled and complete the IRP */
+ Irp->IoStatus.Status = STATUS_CANCELLED;
+ Irp->IoStatus.Information = 0;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+}
+
+static
+VOID
+WmipInitializeIrpContext(
+ PWMIP_IRP_CONTEXT IrpContext)
+{
+ /* Initialize the list head for GUID objects */
+ InitializeListHead(&IrpContext->GuidObjectListHead);
+}
+
+static
+NTSTATUS
+WmipReceiveNotifications(
+ _Inout_ PIRP Irp,
+ _In_ PVOID Buffer,
+ _In_ ULONG InputLength,
+ _Inout_ PULONG OutputLength)
+{
+ PWMI_NOTIFICATION Notification;
+ PWMIP_IRP_CONTEXT IrpContext;
+ NTSTATUS Status;
+
+ //__debugbreak();
+ if ((InputLength < sizeof(WMI_NOTIFICATION)) || (*OutputLength < 0x38))
+ {
+ return STATUS_INVALID_DEVICE_REQUEST;
+ }
+
+ /// FIXME: For now we don't do any actual work, but simply pretend we are
+ /// waiting for notifications. We won't ever deliver any though.
+ Notification = (PWMI_NOTIFICATION)Buffer;
+ DBG_UNREFERENCED_LOCAL_VARIABLE(Notification);
+
+ // loop all objects
+ // reference the object
+ // on failure, fail the whole request
+
+ // loop all objects
+ // update the irp (synchronization!)
+ // if we had one before complete the old irp with an error
+
+ /* Get the IRP context and initialize it */
+ IrpContext = (PWMIP_IRP_CONTEXT)Irp->Tail.Overlay.DriverContext;
+ WmipInitializeIrpContext(IrpContext);
+
+ // loop all objects
+ // insert the objects into the IRP list
+
+ /* Set our cancel routine for cleanup */
+ IoSetCancelRoutine(Irp, WmipNotificationIrpCancel);
+
+ /* Check if the IRP is already being cancelled */
+ if (Irp->Cancel && IoSetCancelRoutine(Irp, NULL))
+ {
+ Status = STATUS_CANCELLED;
+ }
+ else
+ {
+ /* Mark the IRP as pending */
+ IoMarkIrpPending(Irp);
+ Status = STATUS_PENDING;
+ }
+
+ return Status;
}
NTSTATUS
@@ -209,6 +358,23 @@
Buffer,
InputLength,
&OutputLength);
+ break;
+ }
+
+ case IOCTL_WMI_UNREGISTER_GUIDS:
+ {
+ Status = WmipUnregisterGuids(Buffer,
+ InputLength,
+ &OutputLength);
+ break;
+ }
+
+ case IOCTL_WMI_RECEIVE_NOTIFICATIONS:
+ {
+ Status = WmipReceiveNotifications(Irp,
+ Buffer,
+ InputLength,
+ &OutputLength);
break;
}
Modified: branches/kernel-fun/reactos/ntoskrnl/wmi/wmip.h
URL:
http://svn.reactos.org/svn/reactos/branches/kernel-fun/reactos/ntoskrnl/wmi…
==============================================================================
--- branches/kernel-fun/reactos/ntoskrnl/wmi/wmip.h [iso-8859-1] (original)
+++ branches/kernel-fun/reactos/ntoskrnl/wmi/wmip.h [iso-8859-1] Mon Feb 24 15:14:31 2014
@@ -3,9 +3,16 @@
#define GUID_STRING_LENGTH 36
+typedef struct _WMIP_IRP_CONTEXT
+{
+ LIST_ENTRY GuidObjectListHead;
+} WMIP_IRP_CONTEXT, *PWMIP_IRP_CONTEXT;
+
typedef struct _WMIP_GUID_OBJECT
{
GUID Guid;
+ PIRP Irp;
+ LIST_ENTRY IrpLink;
} WMIP_GUID_OBJECT, *PWMIP_GUID_OBJECT;