Author: tkreuzer
Date: Sat Feb 22 18:02:10 2014
New Revision: 62291
URL:
http://svn.reactos.org/svn/reactos?rev=62291&view=rev
Log:
[NTOSKRNL]
Start implementing the built-in WMI driver
Added:
branches/kernel-fun/reactos/include/reactos/wmiguid.h (with props)
branches/kernel-fun/reactos/ntoskrnl/wmi/wmidrv.c (with props)
branches/kernel-fun/reactos/ntoskrnl/wmi/wmip.h (with props)
Modified:
branches/kernel-fun/reactos/ntoskrnl/io/iomgr/iomgr.c
branches/kernel-fun/reactos/ntoskrnl/ntos.cmake
branches/kernel-fun/reactos/ntoskrnl/wmi/wmi.c
Added: branches/kernel-fun/reactos/include/reactos/wmiguid.h
URL:
http://svn.reactos.org/svn/reactos/branches/kernel-fun/reactos/include/reac…
==============================================================================
--- branches/kernel-fun/reactos/include/reactos/wmiguid.h (added)
+++ branches/kernel-fun/reactos/include/reactos/wmiguid.h [iso-8859-1] Sat Feb 22 18:02:10
2014
@@ -0,0 +1,37 @@
+
+#pragma once
+
+#define IOCTL_WMI_QUERY_ALL_DATA CTL_CODE(FILE_DEVICE_UNKNOWN, 0x00, METHOD_BUFFERED,
FILE_READ_ACCESS) // 0x224000
+#define IOCTL_WMI_SINGLE_INSTANCE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x01, METHOD_BUFFERED,
FILE_READ_ACCESS) // 0x224004
+#define IOCTL_WMI_SET_SINGLE_INSTANCE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x02,
METHOD_BUFFERED, FILE_WRITE_ACCESS) // 0x228008
+#define IOCTL_WMI_SET_SINGLE_ITEM CTL_CODE(FILE_DEVICE_UNKNOWN, 0x03, METHOD_BUFFERED,
FILE_WRITE_ACCESS) // 0x22800C
+#define IOCTL_WMI_09 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x09, METHOD_BUFFERED,
FILE_WRITE_ACCESS) // 0x228024
+#define IOCTL_WMI_20 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x20, METHOD_BUFFERED,
FILE_ANY_ACCESS) // 0x220080
+#define IOCTL_WMI_21 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x21, METHOD_BUFFERED,
FILE_ANY_ACCESS) // 0x220084
+#define IOCTL_WMI_22 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x22, METHOD_BUFFERED,
FILE_ANY_ACCESS) // 0x220088
+#define IOCTL_WMI_TRACE_EVENT CTL_CODE(FILE_DEVICE_UNKNOWN, 0x23, METHOD_NEITHER,
FILE_WRITE_ACCESS) // 0x22808F
+#define IOCTL_WMI_24 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x24, METHOD_BUFFERED,
FILE_ANY_ACCESS) // 0x220090
+#define IOCTL_WMI_25 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x25, METHOD_BUFFERED,
FILE_ANY_ACCESS) // 0x220094
+#define IOCTL_WMI_TRACE_USER_MESSAGE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x28, METHOD_NEITHER,
FILE_WRITE_ACCESS) // 0x2280A3
+#define IOCTL_WMI_29 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x29, METHOD_BUFFERED,
FILE_ANY_ACCESS) // 0x2200A4
+#define IOCTL_WMI_2a CTL_CODE(FILE_DEVICE_UNKNOWN, 0x2a, METHOD_BUFFERED,
FILE_ANY_ACCESS) // 0x2200A8
+#define IOCTL_WMI_2b CTL_CODE(FILE_DEVICE_UNKNOWN, 0x2b, METHOD_BUFFERED,
FILE_ANY_ACCESS) // 0x2200AC
+#define IOCTL_WMI_42 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x42, METHOD_BUFFERED,
FILE_READ_ACCESS) // 0x224108
+#define IOCTL_WMI_47 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x47, METHOD_BUFFERED,
FILE_WRITE_ACCESS) // 0x22811C
+#define IOCTL_WMI_49 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x49, METHOD_BUFFERED,
FILE_READ_ACCESS) // 0x224124
+#define IOCTL_WMI_4b CTL_CODE(FILE_DEVICE_UNKNOWN, 0x4b, METHOD_BUFFERED,
FILE_WRITE_ACCESS) // 0x22812C
+#define IOCTL_WMI_4c CTL_CODE(FILE_DEVICE_UNKNOWN, 0x4c, METHOD_BUFFERED,
FILE_WRITE_ACCESS) // 0x228130
+#define IOCTL_WMI_4d CTL_CODE(FILE_DEVICE_UNKNOWN, 0x4d, METHOD_BUFFERED,
FILE_READ_ACCESS) // 0x224134
+#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_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_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
Propchange: branches/kernel-fun/reactos/include/reactos/wmiguid.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: branches/kernel-fun/reactos/ntoskrnl/io/iomgr/iomgr.c
URL:
http://svn.reactos.org/svn/reactos/branches/kernel-fun/reactos/ntoskrnl/io/…
==============================================================================
--- branches/kernel-fun/reactos/ntoskrnl/io/iomgr/iomgr.c [iso-8859-1] (original)
+++ branches/kernel-fun/reactos/ntoskrnl/io/iomgr/iomgr.c [iso-8859-1] Sat Feb 22 18:02:10
2014
@@ -24,6 +24,11 @@
IN PVOID SystemArgument1,
IN PVOID SystemArgument2
);
+
+BOOLEAN
+NTAPI
+WmiInitialize(
+ VOID);
/* DATA ********************************************************************/
@@ -525,6 +530,9 @@
/* Initialize PnP manager */
IopInitializePlugPlayServices();
+ /* Initialize WMI */
+ WmiInitialize();
+
/* Initialize HAL Root Bus Driver */
HalInitPnpDriver();
Modified: branches/kernel-fun/reactos/ntoskrnl/ntos.cmake
URL:
http://svn.reactos.org/svn/reactos/branches/kernel-fun/reactos/ntoskrnl/nto…
==============================================================================
--- branches/kernel-fun/reactos/ntoskrnl/ntos.cmake [iso-8859-1] (original)
+++ branches/kernel-fun/reactos/ntoskrnl/ntos.cmake [iso-8859-1] Sat Feb 22 18:02:10 2014
@@ -269,7 +269,8 @@
${REACTOS_SOURCE_DIR}/ntoskrnl/se/sid.c
${REACTOS_SOURCE_DIR}/ntoskrnl/se/token.c
${REACTOS_SOURCE_DIR}/ntoskrnl/vf/driver.c
- ${REACTOS_SOURCE_DIR}/ntoskrnl/wmi/wmi.c)
+ ${REACTOS_SOURCE_DIR}/ntoskrnl/wmi/wmi.c
+ ${REACTOS_SOURCE_DIR}/ntoskrnl/wmi/wmidrv.c)
list(APPEND ASM_SOURCE ${REACTOS_SOURCE_DIR}/ntoskrnl/ex/zw.S)
Modified: branches/kernel-fun/reactos/ntoskrnl/wmi/wmi.c
URL:
http://svn.reactos.org/svn/reactos/branches/kernel-fun/reactos/ntoskrnl/wmi…
==============================================================================
--- branches/kernel-fun/reactos/ntoskrnl/wmi/wmi.c [iso-8859-1] (original)
+++ branches/kernel-fun/reactos/ntoskrnl/wmi/wmi.c [iso-8859-1] Sat Feb 22 18:02:10 2014
@@ -9,10 +9,31 @@
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
+#include "wmip.h"
+
#define NDEBUG
#include <debug.h>
/* FUNCTIONS *****************************************************************/
+
+BOOLEAN
+NTAPI
+WmiInitialize(
+ VOID)
+{
+ UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L"\\Driver\\WMIxWDM");
+ NTSTATUS Status;
+
+ /* Create the WMI driver */
+ Status = IoCreateDriver(&DriverName, WmipDriverEntry);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to create WMI driver: 0x%lx\n", Status);
+ return FALSE;
+ }
+
+ return TRUE;
+}
/*
* @unimplemented
Added: 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 (added)
+++ branches/kernel-fun/reactos/ntoskrnl/wmi/wmidrv.c [iso-8859-1] Sat Feb 22 18:02:10
2014
@@ -0,0 +1,196 @@
+/*
+ * PROJECT: ReactOS Kernel
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: ntoskrnl/io/wmidrv.c
+ * PURPOSE: I/O Windows Management Instrumentation (WMI) Support
+ * PROGRAMMERS: Timo Kreuzer (timo.kreuzer(a)reactos.org)
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include <ntoskrnl.h>
+#include <wmistr.h>
+#include <wmiguid.h>
+
+#define NDEBUG
+#include <debug.h>
+
+PDEVICE_OBJECT WmipServiceDeviceObject;
+PDEVICE_OBJECT WmipAdminDeviceObject;
+FAST_IO_DISPATCH WmipFastIoDispatch;
+
+
+/* FUNCTIONS *****************************************************************/
+
+DRIVER_DISPATCH WmipOpenCloseCleanup;
+DRIVER_DISPATCH WmipIoControl;
+DRIVER_DISPATCH WmipSystemControl;
+DRIVER_DISPATCH WmipShutdown;
+
+NTSTATUS
+NTAPI
+WmipOpenCloseCleanup(
+ _In_ PDEVICE_OBJECT DeviceObject,
+ _Inout_ PIRP Irp)
+{
+ PAGED_CODE();
+
+ /* No work to do, just return success */
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ Irp->IoStatus.Information = 0;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+NTAPI
+WmipIoControl(
+ _Inout_ PDEVICE_OBJECT DeviceObject,
+ _Inout_ PIRP Irp)
+{
+ UNIMPLEMENTED_DBGBREAK();
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+WmipSystemControl(
+ _Inout_ PDEVICE_OBJECT DeviceObject,
+ _Inout_ PIRP Irp)
+{
+ UNIMPLEMENTED_DBGBREAK();
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+WmipShutdown(
+ _Inout_ PDEVICE_OBJECT DeviceObject,
+ _Inout_ PIRP Irp)
+{
+ UNIMPLEMENTED_DBGBREAK();
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+_Function_class_(FAST_IO_DEVICE_CONTROL)
+_IRQL_requires_same_
+BOOLEAN
+NTAPI
+WmipFastIoDeviceControl(
+ _In_ PFILE_OBJECT FileObject,
+ _In_ BOOLEAN Wait,
+ _In_opt_ PVOID InputBuffer,
+ _In_ ULONG InputBufferLength,
+ _Out_opt_ PVOID OutputBuffer,
+ _In_ ULONG OutputBufferLength,
+ _In_ ULONG IoControlCode,
+ _Out_ PIO_STATUS_BLOCK IoStatus,
+ _In_ PDEVICE_OBJECT DeviceObject)
+{
+ UNIMPLEMENTED_DBGBREAK();
+ return FALSE;
+}
+
+NTSTATUS
+NTAPI
+WmipDockUndockEventCallback(
+ _In_ PVOID NotificationStructure,
+ _Inout_opt_ PVOID Context)
+{
+ UNIMPLEMENTED_DBGBREAK();
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+_Function_class_(DRIVER_INITIALIZE)
+_IRQL_requires_same_
+NTSTATUS
+NTAPI
+WmipDriverEntry(
+ _In_ PDRIVER_OBJECT DriverObject,
+ _In_ PUNICODE_STRING RegistryPath)
+{
+ static UNICODE_STRING ServiceDeviceName =
RTL_CONSTANT_STRING(L"\\Device\\WMIDataDevice");
+ static UNICODE_STRING ServiceDosDeviceName =
RTL_CONSTANT_STRING(L"\\DosDevices\\WMIDataDevice");
+ static UNICODE_STRING AdminDeviceName =
RTL_CONSTANT_STRING(L"\\Device\\WMIAdminDevice");
+ static UNICODE_STRING AdminDosDeviceName =
RTL_CONSTANT_STRING(L"\\DosDevices\\WMIAdminDevice");
+ NTSTATUS Status;
+ PAGED_CODE();
+
+ /* Create the service device object */
+ Status = IoCreateDevice(DriverObject,
+ 0,
+ &ServiceDeviceName,
+ FILE_DEVICE_UNKNOWN,
+ FILE_DEVICE_SECURE_OPEN,
+ 0,
+ &WmipServiceDeviceObject);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to create service device: 0x%lx\n", Status);
+ return Status;
+ }
+
+ /* Create a symbolic link for the service device */
+ Status = IoCreateSymbolicLink(&ServiceDosDeviceName, &ServiceDeviceName);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("IoCreateSymbolicLink() failed: 0x%lx\n", Status);
+ IoDeleteDevice(WmipServiceDeviceObject);
+ return Status;
+ }
+
+ /* Create the admin device object */
+ Status = IoCreateDevice(DriverObject,
+ 0,
+ &AdminDeviceName,
+ FILE_DEVICE_UNKNOWN,
+ FILE_DEVICE_SECURE_OPEN,
+ 0,
+ &WmipAdminDeviceObject);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to create admin device: 0x%lx\n", Status);
+ IoDeleteDevice(WmipServiceDeviceObject);
+ IoDeleteSymbolicLink(&ServiceDosDeviceName);
+ return Status;
+ }
+
+ /* Create a symbolic link for the admin device */
+ Status = IoCreateSymbolicLink(&AdminDosDeviceName, &AdminDeviceName);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("IoCreateSymbolicLink() failed: 0x%lx\n", Status);
+ IoDeleteSymbolicLink(&ServiceDosDeviceName);
+ IoDeleteDevice(WmipServiceDeviceObject);
+ IoDeleteDevice(WmipAdminDeviceObject);
+ return Status;
+ }
+
+ /* Initialize dispatch routines */
+ DriverObject->MajorFunction[IRP_MJ_CREATE] = WmipOpenCloseCleanup;
+ DriverObject->MajorFunction[IRP_MJ_CLOSE] = WmipOpenCloseCleanup;
+ DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = WmipIoControl;
+ DriverObject->MajorFunction[IRP_MJ_CLEANUP] = WmipOpenCloseCleanup;
+ DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = WmipSystemControl;
+ DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = WmipShutdown;
+
+ /* Initialize fast dispatch */
+ RtlZeroMemory(&WmipFastIoDispatch, sizeof(WmipFastIoDispatch));
+ WmipFastIoDispatch.SizeOfFastIoDispatch = sizeof(WmipFastIoDispatch);
+ WmipFastIoDispatch.FastIoDeviceControl = WmipFastIoDeviceControl;
+ DriverObject->FastIoDispatch = &WmipFastIoDispatch;
+
+ /* Register the WMI service device */
+ IoWMIRegistrationControl(WmipServiceDeviceObject, WMIREG_ACTION_REGISTER);
+
+ /* Register a shutdown notification */
+ IoRegisterShutdownNotification(WmipServiceDeviceObject);
+
+ /* Initialization is done */
+ WmipServiceDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
+ WmipAdminDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
+
+ return STATUS_SUCCESS;
+}
+
+
Propchange: branches/kernel-fun/reactos/ntoskrnl/wmi/wmidrv.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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 (added)
+++ branches/kernel-fun/reactos/ntoskrnl/wmi/wmip.h [iso-8859-1] Sat Feb 22 18:02:10 2014
@@ -0,0 +1,12 @@
+
+#pragma once
+
+
+_Function_class_(DRIVER_INITIALIZE)
+_IRQL_requires_same_
+NTSTATUS
+NTAPI
+WmipDriverEntry(
+ _In_ PDRIVER_OBJECT DriverObject,
+ _In_ PUNICODE_STRING RegistryPath);
+
Propchange: branches/kernel-fun/reactos/ntoskrnl/wmi/wmip.h
------------------------------------------------------------------------------
svn:eol-style = native