Author: tkreuzer
Date: Mon Feb 24 18:07:18 2014
New Revision: 62322
URL:
http://svn.reactos.org/svn/reactos?rev=62322&view=rev
Log:
[NTOSKRNL]
Zero out the guid object, remove debug breakpoints in WmipDeleteMethod and WmipCloseMethod
(for now there's nothing to do), factor out the code to capture the guid object
attributes into WmipCaptureGuidObjectAttributes, ignore ioctl 0x228168 for now and
stubplement IOCTL_WMI_OPEN_GUID_FOR_EVENTS
Modified:
branches/kernel-fun/reactos/ntoskrnl/wmi/guidobj.c
branches/kernel-fun/reactos/ntoskrnl/wmi/wmidrv.c
Modified: 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 [iso-8859-1] (original)
+++ branches/kernel-fun/reactos/ntoskrnl/wmi/guidobj.c [iso-8859-1] Mon Feb 24 18:07:18
2014
@@ -80,7 +80,14 @@
WmipDeleteMethod(
_In_ PVOID Object)
{
- UNIMPLEMENTED_DBGBREAK();
+ PWMIP_GUID_OBJECT GuidObject = Object;
+
+ /* Check if the object is attached to an IRP */
+ if (GuidObject->Irp != NULL)
+ {
+ /* This is not supported yet */
+ ASSERT(FALSE);
+ }
}
VOID
@@ -92,7 +99,7 @@
_In_ ULONG ProcessHandleCount,
_In_ ULONG SystemHandleCount)
{
- UNIMPLEMENTED_DBGBREAK();
+ /* For now nothing */
}
NTSTATUS
@@ -199,6 +206,7 @@
return Status;
}
+ RtlZeroMemory(GuidObject, sizeof(*GuidObject));
GuidObject->Guid = Guid;
*OutGuidObject = GuidObject;
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 18:07:18
2014
@@ -107,6 +107,59 @@
ULONG InputBufferLength)
{
UNIMPLEMENTED_DBGBREAK();
+ return STATUS_SUCCESS;
+}
+
+static
+NTSTATUS
+WmipCaptureGuidObjectAttributes(
+ _In_ POBJECT_ATTRIBUTES GuidObjectAttributes,
+ _Out_ POBJECT_ATTRIBUTES CapuredObjectAttributes,
+ _Out_ PUNICODE_STRING CapturedObjectName,
+ _Out_ PWSTR ObjectNameBuffer,
+ _In_ KPROCESSOR_MODE AccessMode)
+{
+ NT_ASSERT(AccessMode != KernelMode);
+
+ _SEH2_TRY
+ {
+ /* Probe and copy the object attributes structure */
+ ProbeForRead(GuidObjectAttributes,
+ sizeof(OBJECT_ATTRIBUTES),
+ sizeof(PVOID));
+ *CapuredObjectAttributes = *GuidObjectAttributes;
+
+ /* Probe and copy the object name UNICODE_STRING */
+ ProbeForRead(CapuredObjectAttributes->ObjectName,
+ sizeof(UNICODE_STRING),
+ sizeof(PVOID));
+ *CapturedObjectName = *CapuredObjectAttributes->ObjectName;
+
+ /* Check if the object name has the expected length */
+ if (CapturedObjectName->Length != 45 * sizeof(WCHAR))
+ {
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* Probe and copy the object name buffer */
+ ProbeForRead(CapturedObjectName->Buffer,
+ CapturedObjectName->Length,
+ sizeof(WCHAR));
+ RtlCopyMemory(ObjectNameBuffer,
+ CapturedObjectName->Buffer,
+ CapturedObjectName->Length);
+
+ /* Fix pointers */
+ CapturedObjectName->Buffer = ObjectNameBuffer;
+ GuidObjectAttributes->ObjectName = CapturedObjectName;
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ DPRINT1("Got exception!\n");
+ return _SEH2_GetExceptionCode();
+ }
+ _SEH2_END;
+
return STATUS_SUCCESS;
}
@@ -143,45 +196,20 @@
return STATUS_UNSUCCESSFUL;
}
- _SEH2_TRY
- {
- /* Probe and copy the object attributes structure */
- ProbeForRead(RegisterGuids->ObjectAttributes,
- sizeof(OBJECT_ATTRIBUTES),
- sizeof(PVOID));
- LocalObjectAttributes = *RegisterGuids->ObjectAttributes;
-
- /* Probe and copy the object name UNICODE_STRING */
- ProbeForRead(LocalObjectAttributes.ObjectName,
- sizeof(UNICODE_STRING),
- sizeof(PVOID));
- LocalObjectName = *LocalObjectAttributes.ObjectName;
-
- /* Check if the object name has the expected length */
- if (LocalObjectName.Length != 45 * sizeof(WCHAR))
- {
- return STATUS_INVALID_PARAMETER;
- }
-
- /* Probe and copy the object name buffer */
- ProbeForRead(LocalObjectName.Buffer, LocalObjectName.Length, sizeof(WCHAR));
- RtlCopyMemory(LocalObjectNameBuffer,
- LocalObjectName.Buffer,
- LocalObjectName.Length);
-
- /* Fix pointers */
- LocalObjectName.Buffer = LocalObjectNameBuffer;
- LocalObjectAttributes.ObjectName = &LocalObjectName;
- }
- _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
- {
- DPRINT1("Got exception!\n");
- return _SEH2_GetExceptionCode();
- }
- _SEH2_END;
+ /* Capture object attributes */
+ PreviousMode = ExGetPreviousMode();
+ Status = WmipCaptureGuidObjectAttributes(RegisterGuids->ObjectAttributes,
+ &LocalObjectAttributes,
+ &LocalObjectName,
+ LocalObjectNameBuffer,
+ PreviousMode);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("WmipCaptureGuidObjectAttributes failed: 0x%lx\n", Status);
+ return Status;
+ }
/* Open a new GUID object */
- PreviousMode = ExGetPreviousMode();
Status = WmipOpenGuidObject(&LocalObjectAttributes,
SPECIFIC_RIGHTS_ALL,
PreviousMode,
@@ -189,6 +217,7 @@
&GuidObject);
if (!NT_SUCCESS(Status))
{
+ DPRINT1("WmipOpenGuidObject failed: 0x%lx\n", Status);
return Status;
}
@@ -325,6 +354,77 @@
}
return Status;
+}
+
+typedef struct _WMI_OPEN_GUID_FOR_EVENTS
+{
+ POBJECT_ATTRIBUTES ObjectAttributes;
+ ACCESS_MASK DesiredAccess;
+ ULONG Unknown08;
+ ULONG Unknown0C;
+} WMI_OPEN_GUID_FOR_EVENTS, *PWMI_OPEN_GUID_FOR_EVENTS;
+
+typedef struct _WMIP_RESULT2
+{
+ ULONG Unknown00;
+ ULONG Unknown04;
+ HANDLE Handle;
+ ULONG Unknown0C;
+} WMIP_RESULT2, *PWMIP_RESULT2;
+
+static
+NTSTATUS
+WmipOpenGuidForEvents(
+ PVOID Buffer,
+ ULONG InputLength,
+ PULONG OutputLength)
+{
+ PWMI_OPEN_GUID_FOR_EVENTS OpenGuidForEvents = Buffer;
+ PWMIP_RESULT2 Result = (PWMIP_RESULT2)Buffer;
+ OBJECT_ATTRIBUTES LocalObjectAttributes;
+ UNICODE_STRING LocalObjectName;
+ WCHAR LocalObjectNameBuffer[45 + 1];
+ KPROCESSOR_MODE PreviousMode;
+ HANDLE GuidObjectHandle;
+ PVOID GuidObject;
+ NTSTATUS Status;
+
+ if ((InputLength != sizeof(WMI_OPEN_GUID_FOR_EVENTS)) ||
+ (*OutputLength != sizeof(WMIP_RESULT2)))
+ {
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ /* Capture object attributes */
+ PreviousMode = ExGetPreviousMode();
+ Status = WmipCaptureGuidObjectAttributes(OpenGuidForEvents->ObjectAttributes,
+ &LocalObjectAttributes,
+ &LocalObjectName,
+ LocalObjectNameBuffer,
+ PreviousMode);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("ProbeAndCaptureGuidObjectAttributes failed: 0x%lx\n",
Status);
+ return Status;
+ }
+
+ /* Open a new GUID object */
+ Status = WmipOpenGuidObject(&LocalObjectAttributes,
+ OpenGuidForEvents->DesiredAccess,
+ PreviousMode,
+ &GuidObjectHandle,
+ &GuidObject);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("WmipOpenGuidObject failed: 0x%lx\n", Status);
+ return Status;
+ }
+
+ Result->Handle = GuidObjectHandle;
+
+ ObDereferenceObject(GuidObject);
+
+ return STATUS_SUCCESS;
}
NTSTATUS
@@ -375,6 +475,19 @@
Buffer,
InputLength,
&OutputLength);
+ break;
+ }
+
+ case 0x228168:
+ {
+ DPRINT1("IOCTL 0x228168 is unimplemented, ignoring\n");
+ Status = STATUS_SUCCESS;
+ break;
+ }
+
+ case IOCTL_WMI_OPEN_GUID_FOR_EVENTS:
+ {
+ Status = WmipOpenGuidForEvents(Buffer, InputLength, &OutputLength);
break;
}