ReactOS  0.4.15-dev-1636-gf634010
wmi.c File Reference
#include "inport.h"
#include <debug.h>
Include dependency graph for wmi.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI InPortQueryWmiRegInfo (_Inout_ PDEVICE_OBJECT DeviceObject, _Inout_ PULONG RegFlags, _Inout_ PUNICODE_STRING InstanceName, _Out_opt_ PUNICODE_STRING *RegistryPath, _Inout_ PUNICODE_STRING MofResourceName, _Out_opt_ PDEVICE_OBJECT *Pdo)
 
NTSTATUS NTAPI InPortQueryWmiDataBlock (_Inout_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _In_ ULONG GuidIndex, _In_ ULONG InstanceIndex, _In_ ULONG InstanceCount, _Out_opt_ PULONG InstanceLengthArray, _In_ ULONG BufferAvail, _Out_opt_ PUCHAR Buffer)
 
NTSTATUS NTAPI InPortWmiRegistration (_Inout_ PINPORT_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI InPortWmiDeRegistration (_Inout_ PINPORT_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI InPortWmi (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
 

Variables

GUID GuidWmiPortData = POINTER_PORT_WMI_STD_DATA_GUID
 
WMIGUIDREGINFO InPortWmiGuidList []
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file wmi.c.

Function Documentation

◆ InPortQueryWmiDataBlock()

NTSTATUS NTAPI InPortQueryWmiDataBlock ( _Inout_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp,
_In_ ULONG  GuidIndex,
_In_ ULONG  InstanceIndex,
_In_ ULONG  InstanceCount,
_Out_opt_ PULONG  InstanceLengthArray,
_In_ ULONG  BufferAvail,
_Out_opt_ PUCHAR  Buffer 
)

Definition at line 62 of file wmi.c.

71 {
73  PPOINTER_PORT_WMI_STD_DATA InPortData;
74  PINPORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
75 
76  PAGED_CODE();
77 
78  DPRINT("%s()\n", __FUNCTION__);
79 
81  {
83  goto Complete;
84  }
85 
86  /* Only register 1 instance per GUID */
87  if (InstanceIndex != 0 || InstanceCount != 1)
88  {
90  goto Complete;
91  }
92 
93  if (!InstanceLengthArray || BufferAvail < sizeof(POINTER_PORT_WMI_STD_DATA))
94  {
96  goto Complete;
97  }
98 
99  InPortData = (PPOINTER_PORT_WMI_STD_DATA)Buffer;
100 
101  /* Bus mouse connector isn't defined in the DDK, so set type to something generic */
103  /* 1 packet */
104  InPortData->DataQueueSize = 1;
105  /* Not supported by device */
106  InPortData->ErrorCount = 0;
107 
108  InPortData->Buttons = DeviceExtension->MouseAttributes.NumberOfButtons;
110  *InstanceLengthArray = sizeof(POINTER_PORT_WMI_STD_DATA);
111 
113 
114 Complete:
116  Irp,
117  Status,
120 }
#define STATUS_WMI_GUID_NOT_FOUND
Definition: ntstatus.h:776
WMIGUIDREGINFO InPortWmiGuidList[]
Definition: wmi.c:27
LONG NTSTATUS
Definition: precomp.h:26
_In_ LPGUID _In_ ULONG InstanceIndex
Definition: classpnp.h:1250
NTSTATUS NTAPI WmiCompleteRequest(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN NTSTATUS Status, IN ULONG BufferUsed, IN CCHAR PriorityBoost)
Definition: wmilib.c:24
#define STATUS_WMI_INSTANCE_NOT_FOUND
Definition: ntstatus.h:777
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
struct _POINTER_PORT_WMI_STD_DATA * PPOINTER_PORT_WMI_STD_DATA
_In_ PIRP Irp
Definition: csq.h:116
pRequest Complete(RequestStatus)
_In_ PIRP _In_ ULONG GuidIndex
Definition: classpnp.h:418
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
struct _POINTER_PORT_WMI_STD_DATA POINTER_PORT_WMI_STD_DATA
Status
Definition: gdiplustypes.h:24
_In_ PIRP _In_ ULONG _In_ ULONG BufferAvail
Definition: classpnp.h:418
#define POINTER_PORT_WMI_STD_MOUSE
Definition: wmidata.h:3180
MOUSE_ATTRIBUTES MouseAttributes
Definition: inport.h:74
#define POINTER_PORT_WMI_STD_I8042
Definition: wmidata.h:3169
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define IO_NO_INCREMENT
Definition: iotypes.h:598
_In_ ULONG InstanceCount
Definition: iofuncs.h:1319
#define STATUS_SUCCESS
Definition: shellext.h:65
#define __FUNCTION__
Definition: types.h:112
USHORT NumberOfButtons
Definition: ntddmou.h:110
#define PAGED_CODE()

Referenced by InPortWmiRegistration().

◆ InPortQueryWmiRegInfo()

NTSTATUS NTAPI InPortQueryWmiRegInfo ( _Inout_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PULONG  RegFlags,
_Inout_ PUNICODE_STRING  InstanceName,
_Out_opt_ PUNICODE_STRING RegistryPath,
_Inout_ PUNICODE_STRING  MofResourceName,
_Out_opt_ PDEVICE_OBJECT Pdo 
)

Definition at line 36 of file wmi.c.

43 {
44  PINPORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
45 
48 
49  PAGED_CODE();
50 
51  DPRINT("%s()\n", __FUNCTION__);
52 
55  *Pdo = DeviceExtension->Pdo;
56 
57  return STATUS_SUCCESS;
58 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:213
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_ WDFDRIVER _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT Pdo
Definition: wdfminiport.h:64
_Out_ ULONG * RegFlags
Definition: classpnp.h:403
void DPRINT(...)
Definition: polytest.cpp:61
#define WMIREG_FLAG_INSTANCE_PDO
Definition: wmistr.h:69
PDEVICE_OBJECT Pdo
Definition: inport.h:43
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING MofResourceName
Definition: wdfdevice.h:2461
UNICODE_STRING DriverRegistryPath
Definition: inport.c:24
_Must_inspect_result_ _Inout_ PFLT_VOLUME _In_opt_ PCUNICODE_STRING InstanceName
Definition: fltkernel.h:1162
#define STATUS_SUCCESS
Definition: shellext.h:65
#define __FUNCTION__
Definition: types.h:112
#define PAGED_CODE()

Referenced by InPortWmiRegistration().

◆ InPortWmi()

NTSTATUS NTAPI InPortWmi ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp 
)

Definition at line 156 of file wmi.c.

159 {
162  PINPORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
163 
164  PAGED_CODE();
165 
166  DPRINT("%s(%p, %p) %X\n", __FUNCTION__, DeviceObject, Irp,
168 
169  Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, Irp);
170  if (!NT_SUCCESS(Status))
171  {
172  Irp->IoStatus.Information = 0;
173  Irp->IoStatus.Status = Status;
175 
176  return Status;
177  }
178 
179  Status = WmiSystemControl(&DeviceExtension->WmiLibInfo,
180  DeviceObject,
181  Irp,
182  &Disposition);
183  switch (Disposition)
184  {
185  case IrpProcessed:
186  break;
187 
188  case IrpNotCompleted:
190  break;
191 
192  case IrpForward:
193  case IrpNotWmi:
195  Status = IoCallDriver(DeviceExtension->Ldo, Irp);
196  break;
197  }
198 
199  IoReleaseRemoveLock(&DeviceExtension->RemoveLock, Irp);
200 
201  return Status;
202 }
PDEVICE_OBJECT Ldo
Definition: inport.h:44
WMILIB_CONTEXT WmiLibInfo
Definition: inport.h:47
NTSTATUS NTAPI WmiSystemControl(IN PWMILIB_CONTEXT WmiLibInfo, IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, OUT PSYSCTL_IRP_DISPOSITION IrpDisposition)
Definition: wmilib.c:48
LONG NTSTATUS
Definition: precomp.h:26
#define IoReleaseRemoveLock(_RemoveLock, _Tag)
Definition: iofuncs.h:2760
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:50
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
_In_ UCHAR _In_ UCHAR MinorFunction
Definition: wdfdevice.h:1697
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
Status
Definition: gdiplustypes.h:24
enum _SYSCTL_IRP_DISPOSITION SYSCTL_IRP_DISPOSITION
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
IO_REMOVE_LOCK RemoveLock
Definition: inport.h:46
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define __FUNCTION__
Definition: types.h:112
#define IoAcquireRemoveLock(RemoveLock, Tag)
#define PAGED_CODE()

Referenced by DriverEntry().

◆ InPortWmiDeRegistration()

NTSTATUS NTAPI InPortWmiDeRegistration ( _Inout_ PINPORT_DEVICE_EXTENSION  DeviceExtension)

Definition at line 145 of file wmi.c.

147 {
148  PAGED_CODE();
149 
150  return IoWMIRegistrationControl(DeviceExtension->Self,
152 }
#define WMIREG_ACTION_DEREGISTER
NTSTATUS NTAPI IoWMIRegistrationControl(IN PDEVICE_OBJECT DeviceObject, IN ULONG Action)
Definition: wmi.c:68
#define PAGED_CODE()

Referenced by InPortRemoveDevice().

◆ InPortWmiRegistration()

NTSTATUS NTAPI InPortWmiRegistration ( _Inout_ PINPORT_DEVICE_EXTENSION  DeviceExtension)

Definition at line 124 of file wmi.c.

126 {
127  PAGED_CODE();
128 
129  DeviceExtension->WmiLibInfo.GuidCount = RTL_NUMBER_OF(InPortWmiGuidList);
130  DeviceExtension->WmiLibInfo.GuidList = InPortWmiGuidList;
131 
132  DeviceExtension->WmiLibInfo.QueryWmiRegInfo = InPortQueryWmiRegInfo;
133  DeviceExtension->WmiLibInfo.QueryWmiDataBlock = InPortQueryWmiDataBlock;
134  DeviceExtension->WmiLibInfo.SetWmiDataBlock = NULL;
135  DeviceExtension->WmiLibInfo.SetWmiDataItem = NULL;
136  DeviceExtension->WmiLibInfo.ExecuteWmiMethod = NULL;
137  DeviceExtension->WmiLibInfo.WmiFunctionControl = NULL;
138 
139  return IoWMIRegistrationControl(DeviceExtension->Self,
141 }
WMIGUIDREGINFO InPortWmiGuidList[]
Definition: wmi.c:27
NTSTATUS NTAPI InPortQueryWmiDataBlock(_Inout_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _In_ ULONG GuidIndex, _In_ ULONG InstanceIndex, _In_ ULONG InstanceCount, _Out_opt_ PULONG InstanceLengthArray, _In_ ULONG BufferAvail, _Out_opt_ PUCHAR Buffer)
Definition: wmi.c:62
NTSTATUS NTAPI InPortQueryWmiRegInfo(_Inout_ PDEVICE_OBJECT DeviceObject, _Inout_ PULONG RegFlags, _Inout_ PUNICODE_STRING InstanceName, _Out_opt_ PUNICODE_STRING *RegistryPath, _Inout_ PUNICODE_STRING MofResourceName, _Out_opt_ PDEVICE_OBJECT *Pdo)
Definition: wmi.c:36
NTSTATUS NTAPI IoWMIRegistrationControl(IN PDEVICE_OBJECT DeviceObject, IN ULONG Action)
Definition: wmi.c:68
#define WMIREG_ACTION_REGISTER
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define NULL
Definition: types.h:112
#define PAGED_CODE()

Referenced by InPortStartDevice().

Variable Documentation

◆ GuidWmiPortData

Definition at line 25 of file wmi.c.

◆ InPortWmiGuidList

WMIGUIDREGINFO InPortWmiGuidList[]
Initial value:
=
{
{&GuidWmiPortData, 1, 0}
}
GUID GuidWmiPortData
Definition: wmi.c:25

Definition at line 27 of file wmi.c.

Referenced by InPortQueryWmiDataBlock(), and InPortWmiRegistration().