Author: tkreuzer
Date: Sat Feb 22 20:07:10 2014
New Revision: 62294
URL:
http://svn.reactos.org/svn/reactos?rev=62294&view=rev
Log:
[NTOSKRNL]
Add basic code for the WMI GUID object
Added:
branches/kernel-fun/reactos/ntoskrnl/wmi/guidobj.c (with props)
Modified:
branches/kernel-fun/reactos/ntoskrnl/ntos.cmake
branches/kernel-fun/reactos/ntoskrnl/wmi/wmi.c
branches/kernel-fun/reactos/ntoskrnl/wmi/wmip.h
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 20:07:10 2014
@@ -270,6 +270,7 @@
${REACTOS_SOURCE_DIR}/ntoskrnl/se/srm.c
${REACTOS_SOURCE_DIR}/ntoskrnl/se/token.c
${REACTOS_SOURCE_DIR}/ntoskrnl/vf/driver.c
+ ${REACTOS_SOURCE_DIR}/ntoskrnl/wmi/guidobj.c
${REACTOS_SOURCE_DIR}/ntoskrnl/wmi/wmi.c
${REACTOS_SOURCE_DIR}/ntoskrnl/wmi/wmidrv.c)
Added: branches/kernel-fun/reactos/ntoskrnl/wmi/guidobj.c
URL:
http://svn.reactos.org/svn/reactos/branches/kernel-fun/reactos/ntoskrnl/wmi…
==============================================================================
--- branches/kernel-fun/reactos/ntoskrnl/wmi/guidobj.c (added)
+++ branches/kernel-fun/reactos/ntoskrnl/wmi/guidobj.c [iso-8859-1] Sat Feb 22 20:07:10
2014
@@ -0,0 +1,207 @@
+/*
+ * 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>
+#include "wmip.h"
+
+#define NDEBUG
+#include <debug.h>
+
+
+/* GLOBALS ******************************************************************/
+
+POBJECT_TYPE WmipGuidObjectType;
+GENERIC_MAPPING WmipGenericMapping;
+
+
+/* FUNCTIONS *****************************************************************/
+
+NTSTATUS
+NTAPI
+WmipSecurityMethod(
+ _In_ PVOID Object,
+ _In_ SECURITY_OPERATION_CODE OperationType,
+ _In_ PSECURITY_INFORMATION SecurityInformation,
+ _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
+ _Inout_ PULONG CapturedLength,
+ _Inout_ PSECURITY_DESCRIPTOR *ObjectSecurityDescriptor,
+ _In_ POOL_TYPE PoolType,
+ _In_ PGENERIC_MAPPING GenericMapping)
+{
+ UNIMPLEMENTED_DBGBREAK();
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+VOID
+NTAPI
+WmipDeleteMethod(
+ _In_ PVOID Object)
+{
+ UNIMPLEMENTED_DBGBREAK();
+}
+
+VOID
+NTAPI
+WmipCloseMethod(
+ _In_opt_ PEPROCESS Process,
+ _In_ PVOID Object,
+ _In_ ACCESS_MASK GrantedAccess,
+ _In_ ULONG ProcessHandleCount,
+ _In_ ULONG SystemHandleCount)
+{
+ UNIMPLEMENTED_DBGBREAK();
+}
+
+NTSTATUS
+NTAPI
+WmipInitializeGuidObjectType(
+ VOID)
+{
+ static UNICODE_STRING GuidObjectName = RTL_CONSTANT_STRING(L"WmiGuid");
+ OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
+ NTSTATUS Status;
+
+ /* Setup the object type initializer */
+ RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
+ ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
+ ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK;
+ ObjectTypeInitializer.GenericMapping = WmipGenericMapping;
+ ObjectTypeInitializer.PoolType = NonPagedPool;
+ ObjectTypeInitializer.MaintainHandleCount = FALSE;
+ ObjectTypeInitializer.ValidAccessMask = STANDARD_RIGHTS_ALL | 0xFFF;
+ ObjectTypeInitializer.SecurityRequired = TRUE;
+ ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(WMIP_GUID_OBJECT);;
+ ObjectTypeInitializer.SecurityProcedure = WmipSecurityMethod;
+ ObjectTypeInitializer.DeleteProcedure = WmipDeleteMethod;
+ ObjectTypeInitializer.CloseProcedure = WmipCloseMethod;
+
+ /* Create the object type */
+ Status = ObCreateObjectType(&GuidObjectName,
+ &ObjectTypeInitializer,
+ 0,
+ &WmipGuidObjectType);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("ObCreateObjectType failed: 0x%lx\n", Status);
+ }
+
+ return Status;
+}
+
+static
+NTSTATUS
+WmipCreateGuidObject(
+ _In_ PUNICODE_STRING GuidString,
+ _Out_ PWMIP_GUID_OBJECT *OutGuidObject)
+{
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ GUID Guid;
+ PWMIP_GUID_OBJECT GuidObject;
+ NTSTATUS Status;
+
+ /* Convert the string into a GUID structure */
+ Status = RtlGUIDFromString(GuidString, &Guid);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("WMI: Invalid uuid format for guid '%wZ'\n",
GuidString);
+ return Status;
+ }
+
+ /* Initialize object attributes for an unnamed object */
+ InitializeObjectAttributes(&ObjectAttributes,
+ NULL,
+ 0,
+ NULL,
+ NULL); // FIXME: security descriptor!
+
+ /* Create the GUID object */
+ Status = ObCreateObject(KernelMode,
+ WmipGuidObjectType,
+ &ObjectAttributes,
+ KernelMode,
+ NULL,
+ sizeof(WMIP_GUID_OBJECT),
+ 0,
+ 0,
+ (PVOID*)&GuidObject);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("WMI: failed to create GUID object: 0x%lx\n", Status);
+ return Status;
+ }
+
+ GuidObject->Guid = Guid;
+
+ *OutGuidObject = GuidObject;
+
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+NTAPI
+WmipOpenGuidObject(
+ POBJECT_ATTRIBUTES ObjectAttributes,
+ ACCESS_MASK DesiredAccess,
+ KPROCESSOR_MODE AccessMode,
+ PHANDLE OutGuidObjectHandle,
+ PVOID *OutGuidObject)
+{
+ static UNICODE_STRING Prefix = RTL_CONSTANT_STRING(L"\\WmiGuid\\");
+ UNICODE_STRING GuidString;
+ ULONG HandleAttributes;
+ PWMIP_GUID_OBJECT GuidObject;
+ NTSTATUS Status;
+ PAGED_CODE();
+
+ /* Check if we have the expected prefix */
+ if (!RtlPrefixUnicodeString(ObjectAttributes->ObjectName, &Prefix, FALSE))
+ {
+ DPRINT1("WMI: Invalid prefix for guid object '%wZ'\n",
+ ObjectAttributes->ObjectName);
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* Extract the GUID string */
+ GuidString = *ObjectAttributes->ObjectName;
+ GuidString.Buffer += Prefix.Length / sizeof(WCHAR);
+ GuidString.Length -= Prefix.Length;
+
+ /* Create the GUID object */
+ Status = WmipCreateGuidObject(&GuidString, &GuidObject);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to create GUID object: 0x%lx\n", Status);
+ return Status;
+ }
+
+ /* Set handle attributes */
+ HandleAttributes = (AccessMode == KernelMode) ? OBJ_KERNEL_HANDLE : 0;
+
+ /* Get a handle for the object */
+ Status = ObOpenObjectByPointer(GuidObject,
+ HandleAttributes,
+ 0,
+ DesiredAccess,
+ WmipGuidObjectType,
+ AccessMode,
+ OutGuidObjectHandle);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("ObOpenObjectByPointer failed: 0x%lx\n", Status);
+ ObfDereferenceObject(GuidObject);
+ }
+
+ *OutGuidObject = GuidObject;
+
+ return Status;
+}
+
Propchange: branches/kernel-fun/reactos/ntoskrnl/wmi/guidobj.c
------------------------------------------------------------------------------
svn:eol-style = native
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 20:07:10 2014
@@ -23,6 +23,14 @@
{
UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L"\\Driver\\WMIxWDM");
NTSTATUS Status;
+
+ /* Initialize the GUID object type */
+ Status = WmipInitializeGuidObjectType();
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("WmipInitializeGuidObjectType() failed: 0x%lx\n", Status);
+ return FALSE;
+ }
/* Create the WMI driver */
Status = IoCreateDriver(&DriverName, WmipDriverEntry);
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] Sat Feb 22 20:07:10 2014
@@ -1,5 +1,10 @@
#pragma once
+
+typedef struct _WMIP_GUID_OBJECT
+{
+ GUID Guid;
+} WMIP_GUID_OBJECT, *PWMIP_GUID_OBJECT;
_Function_class_(DRIVER_INITIALIZE)
@@ -10,3 +15,16 @@
_In_ PDRIVER_OBJECT DriverObject,
_In_ PUNICODE_STRING RegistryPath);
+NTSTATUS
+NTAPI
+WmipInitializeGuidObjectType(
+ VOID);
+
+NTSTATUS
+NTAPI
+WmipOpenGuidObject(
+ POBJECT_ATTRIBUTES ObjectAttributes,
+ ACCESS_MASK DesiredAccess,
+ KPROCESSOR_MODE AccessMode,
+ PHANDLE OutGuidObjectHandle,
+ PVOID *OutGuidObject);