ReactOS 0.4.15-dev-8413-gc1c91f2
fbtwmi.c File Reference
#include "fbtusb.h"
#include "fbtpwr.h"
#include "fbtpnp.h"
#include "fbtdev.h"
#include "fbtrwr.h"
#include "fbtwmi.h"
#include "fbtusr.h"
Include dependency graph for fbtwmi.c:

Go to the source code of this file.

Macros

#define MOFRESOURCENAME   L"MofResourceName"
 
#define WMI_FREEBT_DRIVER_INFORMATION   0
 

Functions

 DEFINE_GUID (FREEBT_WMI_STD_DATA_GUID, 0x871B1A60, 0xD3EA, 0x4f2f, 0x81, 0x7b, 0x46, 0x5e, 0x44, 0x86, 0x7b, 0xf5)
 
NTSTATUS NTAPI FreeBT_WmiRegistration (IN OUT PDEVICE_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI FreeBT_WmiDeRegistration (IN OUT PDEVICE_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI FreeBT_DispatchSysCtrl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI FreeBT_QueryWmiRegInfo (IN PDEVICE_OBJECT DeviceObject, OUT ULONG *RegFlags, OUT PUNICODE_STRING InstanceName, OUT PUNICODE_STRING *RegistryPath, OUT PUNICODE_STRING MofResourceName, OUT PDEVICE_OBJECT *Pdo)
 
NTSTATUS NTAPI FreeBT_QueryWmiDataBlock (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN ULONG GuidIndex, IN ULONG InstanceIndex, IN ULONG InstanceCount, IN OUT PULONG InstanceLengthArray, IN ULONG OutBufferSize, OUT PUCHAR Buffer)
 
NTSTATUS NTAPI FreeBT_SetWmiDataItem (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN ULONG GuidIndex, IN ULONG InstanceIndex, IN ULONG DataItemId, IN ULONG BufferSize, IN PUCHAR Buffer)
 
NTSTATUS NTAPI FreeBT_SetWmiDataBlock (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN ULONG GuidIndex, IN ULONG InstanceIndex, IN ULONG BufferSize, IN PUCHAR Buffer)
 
PCHAR NTAPI WMIMinorFunctionString (UCHAR MinorFunction)
 

Variables

WMIGUIDREGINFO FreeBTWmiGuidList [1]
 

Macro Definition Documentation

◆ MOFRESOURCENAME

#define MOFRESOURCENAME   L"MofResourceName"

Definition at line 22 of file fbtwmi.c.

◆ WMI_FREEBT_DRIVER_INFORMATION

#define WMI_FREEBT_DRIVER_INFORMATION   0

Definition at line 24 of file fbtwmi.c.

Function Documentation

◆ DEFINE_GUID()

DEFINE_GUID ( FREEBT_WMI_STD_DATA_GUID  ,
0x871B1A60  ,
0xD3EA  ,
0x4f2f  ,
0x81  ,
0x7b  ,
0x46  ,
0x5e  ,
0x44  ,
0x86  ,
0x7b  ,
0xf5   
)

◆ FreeBT_DispatchSysCtrl()

NTSTATUS NTAPI FreeBT_DispatchSysCtrl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 66 of file fbtwmi.c.

67{
68 PDEVICE_EXTENSION deviceExtension;
69 SYSCTL_IRP_DISPOSITION disposition;
70 NTSTATUS ntStatus;
71 PIO_STACK_LOCATION irpStack;
72
73 PAGED_CODE();
74
76 deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
77
78 FreeBT_DbgPrint(3, ("FBTUSB: "));
80 if (Removed == deviceExtension->DeviceState)
81 {
82 ntStatus = STATUS_DELETE_PENDING;
83
84 Irp->IoStatus.Status = ntStatus;
85 Irp->IoStatus.Information = 0;
87
88 return ntStatus;
89
90 }
91
92 FreeBT_DbgPrint(3, ("FBTUSB: FreeBT_DispatchSysCtrl::"));
93 FreeBT_IoIncrement(deviceExtension);
94
95 ntStatus = WmiSystemControl(&deviceExtension->WmiLibInfo,
97 Irp,
98 &disposition);
99
100 switch(disposition)
101 {
102 case IrpProcessed:
103 {
104 // This irp has been processed and may be completed or pending.
105 break;
106
107 }
108
109 case IrpNotCompleted:
110 {
111 // This irp has not been completed, but has been fully processed.
112 // we will complete it now
114 break;
115
116 }
117
118 case IrpForward:
119 case IrpNotWmi:
120 {
121 // This irp is either not a WMI irp or is a WMI irp targeted
122 // at a device lower in the stack.
124 ntStatus = IoCallDriver(deviceExtension->TopOfStackDeviceObject, Irp);
125 break;
126 }
127
128 default:
129 {
130 // We really should never get here, but if we do just forward....
131 ASSERT(FALSE);
133 ntStatus = IoCallDriver(deviceExtension->TopOfStackDeviceObject, Irp);
134 break;
135
136 }
137
138 }
139
140 FreeBT_DbgPrint(3, ("FBTUSB: FreeBT_DispatchSysCtrl::"));
141 FreeBT_IoDecrement(deviceExtension);
142
143 return ntStatus;
144
145}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define PAGED_CODE()
LONG NTSTATUS
Definition: precomp.h:26
_In_ PIRP Irp
Definition: csq.h:116
#define FALSE
Definition: types.h:117
struct _BEEP_DEVICE_EXTENSION * PDEVICE_EXTENSION
LONG NTAPI FreeBT_IoDecrement(IN OUT PDEVICE_EXTENSION DeviceExtension)
Definition: fbtpnp.c:1742
LONG NTAPI FreeBT_IoIncrement(IN OUT PDEVICE_EXTENSION DeviceExtension)
Definition: fbtpnp.c:1722
#define FreeBT_DbgPrint(level, _x_)
Definition: fbtusb.h:55
@ Removed
Definition: fbtusb.h:86
PCHAR NTAPI WMIMinorFunctionString(UCHAR MinorFunction)
Definition: fbtwmi.c:509
#define ASSERT(a)
Definition: mode.c:44
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IoCompleteRequest
Definition: irp.c:1240
#define IoCallDriver
Definition: irp.c:1225
#define STATUS_DELETE_PENDING
Definition: ntstatus.h:322
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
NTSTATUS NTAPI WmiSystemControl(IN PWMILIB_CONTEXT WmiLibInfo, IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, OUT PSYSCTL_IRP_DISPOSITION IrpDisposition)
Definition: wmilib.c:48
@ IrpNotWmi
Definition: wmilib.h:15
@ IrpForward
Definition: wmilib.h:16
@ IrpNotCompleted
Definition: wmilib.h:14
@ IrpProcessed
Definition: wmilib.h:13
enum _SYSCTL_IRP_DISPOSITION SYSCTL_IRP_DISPOSITION
#define IO_NO_INCREMENT
Definition: iotypes.h:598

Referenced by DriverEntry().

◆ FreeBT_QueryWmiDataBlock()

NTSTATUS NTAPI FreeBT_QueryWmiDataBlock ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN ULONG  GuidIndex,
IN ULONG  InstanceIndex,
IN ULONG  InstanceCount,
IN OUT PULONG  InstanceLengthArray,
IN ULONG  OutBufferSize,
OUT PUCHAR  Buffer 
)

Definition at line 217 of file fbtwmi.c.

267{
268 PDEVICE_EXTENSION deviceExtension;
269 NTSTATUS ntStatus;
270 ULONG size;
271 WCHAR modelName[] = L"Aishverya\0\0";
272 USHORT modelNameLen;
273
274 PAGED_CODE();
275
276 FreeBT_DbgPrint(3, ("FBTUSB: FreeBT_QueryWmiDataBlock: Entered\n"));
277
278 size = 0;
279 modelNameLen = (wcslen(modelName) + 1) * sizeof(WCHAR);
280
281 // Only ever registers 1 instance per guid
282 ASSERT((InstanceIndex == 0) && (InstanceCount == 1));
283
284 deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
286 {
288 size = sizeof(ULONG) + modelNameLen + sizeof(USHORT);
289 if (OutBufferSize < size )
290 {
291 FreeBT_DbgPrint(3, ("FBTUSB: OutBuffer too small\n"));
292 ntStatus = STATUS_BUFFER_TOO_SMALL;
293 break;
294
295 }
296
298 Buffer += sizeof(ULONG);
299
300 // put length of string ahead of string
301 *((PUSHORT)Buffer) = modelNameLen;
302 Buffer = (PUCHAR)Buffer + sizeof(USHORT);
303 RtlCopyBytes((PVOID)Buffer, (PVOID)modelName, modelNameLen);
304 *InstanceLengthArray = size ;
305
306 ntStatus = STATUS_SUCCESS;
307 break;
308
309 default:
310 ntStatus = STATUS_WMI_GUID_NOT_FOUND;
311
312 }
313
315 Irp,
316 ntStatus,
317 size,
319
320 FreeBT_DbgPrint(3, ("FBTUSB: FreeBT_QueryWmiDataBlock: Leaving\n"));
321
322 return ntStatus;
323
324}
Definition: bufpool.h:45
_In_ LPGUID _In_ ULONG InstanceIndex
Definition: classpnp.h:1251
_In_ PIRP _In_ ULONG GuidIndex
Definition: classpnp.h:419
switch(r->id)
Definition: btrfs.c:3046
ULONG DebugLevel
Definition: fbtusb.c:26
#define WMI_FREEBT_DRIVER_INFORMATION
Definition: fbtwmi.c:24
GLsizeiptr size
Definition: glext.h:5919
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define STATUS_WMI_GUID_NOT_FOUND
Definition: ntstatus.h:776
#define L(x)
Definition: ntvdm.h:50
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
uint32_t * PULONG
Definition: typedefs.h:59
uint16_t * PUSHORT
Definition: typedefs.h:56
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
_In_ ULONG OutBufferSize
Definition: wdfwmi.h:87
NTSTATUS NTAPI WmiCompleteRequest(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN NTSTATUS Status, IN ULONG BufferUsed, IN CCHAR PriorityBoost)
Definition: wmilib.c:24
_In_ ULONG InstanceCount
Definition: iofuncs.h:1323
#define RtlCopyBytes
Definition: rtlfuncs.h:282
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by FreeBT_WmiRegistration().

◆ FreeBT_QueryWmiRegInfo()

NTSTATUS NTAPI FreeBT_QueryWmiRegInfo ( IN PDEVICE_OBJECT  DeviceObject,
OUT ULONG RegFlags,
OUT PUNICODE_STRING  InstanceName,
OUT PUNICODE_STRING RegistryPath,
OUT PUNICODE_STRING  MofResourceName,
OUT PDEVICE_OBJECT Pdo 
)

Definition at line 147 of file fbtwmi.c.

197{
198 PDEVICE_EXTENSION deviceExtension;
199
200 PAGED_CODE();
201
202 FreeBT_DbgPrint(3, ("FBTUSB: FreeBT_QueryWmiRegInfo: Entered\n"));
203
204 deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
205
207 *RegistryPath = &Globals.FreeBT_RegistryPath;
208 *Pdo = deviceExtension->PhysicalDeviceObject;
210
211 FreeBT_DbgPrint(3, ("FBTUSB: FreeBT_QueryWmiRegInfo: Leaving\n"));
212
213 return STATUS_SUCCESS;
214
215}
_Out_ ULONG * RegFlags
Definition: classpnp.h:403
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define MOFRESOURCENAME
Definition: fbtwmi.c:22
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING MofResourceName
Definition: wdfdevice.h:2464
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
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:72
#define WMIREG_FLAG_INSTANCE_PDO
Definition: wmistr.h:69

Referenced by FreeBT_WmiRegistration().

◆ FreeBT_SetWmiDataBlock()

NTSTATUS NTAPI FreeBT_SetWmiDataBlock ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN ULONG  GuidIndex,
IN ULONG  InstanceIndex,
IN ULONG  BufferSize,
IN PUCHAR  Buffer 
)

Definition at line 427 of file fbtwmi.c.

461{
462 PDEVICE_EXTENSION deviceExtension;
463 NTSTATUS ntStatus;
464 ULONG info;
465
466 PAGED_CODE();
467
468 FreeBT_DbgPrint(3, ("FBTUSB: FreeBT_SetWmiDataBlock: Entered\n"));
469
470 deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
471 info = 0;
472
473 switch(GuidIndex)
474 {
476 if(BufferSize == sizeof(ULONG))
477 {
479 ntStatus = STATUS_SUCCESS;
480 info = sizeof(ULONG);
481
482 }
483
484 else
485 {
487
488 }
489
490 break;
491
492 default:
493 ntStatus = STATUS_WMI_GUID_NOT_FOUND;
494
495 }
496
498 Irp,
499 ntStatus,
500 info,
502
503 FreeBT_DbgPrint(3, ("FBTUSB: FreeBT_SetWmiDataBlock: Leaving\n"));
504
505 return ntStatus;
506
507}
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

Referenced by FreeBT_WmiRegistration().

◆ FreeBT_SetWmiDataItem()

NTSTATUS NTAPI FreeBT_SetWmiDataItem ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN ULONG  GuidIndex,
IN ULONG  InstanceIndex,
IN ULONG  DataItemId,
IN ULONG  BufferSize,
IN PUCHAR  Buffer 
)

Definition at line 327 of file fbtwmi.c.

369{
370 PDEVICE_EXTENSION deviceExtension;
371 NTSTATUS ntStatus;
372 ULONG info;
373
374 PAGED_CODE();
375
376 FreeBT_DbgPrint(3, ("FBTUSB: FreeBT_SetWmiDataItem: Entered\n"));
377
378 deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
379 info = 0;
380
381 switch(GuidIndex)
382 {
384 if(DataItemId == 1)
385 {
386 if(BufferSize == sizeof(ULONG))
387 {
389 ntStatus = STATUS_SUCCESS;
390 info = sizeof(ULONG);
391
392 }
393
394 else
395 {
397
398 }
399
400 }
401
402 else
403 {
404 ntStatus = STATUS_WMI_READ_ONLY;
405
406 }
407
408 break;
409
410 default:
411 ntStatus = STATUS_WMI_GUID_NOT_FOUND;
412
413 }
414
416 Irp,
417 ntStatus,
418 info,
420
421 FreeBT_DbgPrint(3, ("FBTUSB: FreeBT_SetWmiDataItem: Leaving\n"));
422
423 return ntStatus;
424
425}
#define STATUS_WMI_READ_ONLY
Definition: ntstatus.h:818
_In_ ULONG DataItemId
Definition: wdfwmi.h:123

Referenced by FreeBT_WmiRegistration().

◆ FreeBT_WmiDeRegistration()

NTSTATUS NTAPI FreeBT_WmiDeRegistration ( IN OUT PDEVICE_EXTENSION  DeviceExtension)

Definition at line 59 of file fbtwmi.c.

60{
61 PAGED_CODE();
62 return IoWMIRegistrationControl(DeviceExtension->FunctionalDeviceObject, WMIREG_ACTION_DEREGISTER);
63
64}
NTSTATUS NTAPI IoWMIRegistrationControl(IN PDEVICE_OBJECT DeviceObject, IN ULONG Action)
Definition: wmi.c:68
#define WMIREG_ACTION_DEREGISTER

Referenced by FreeBT_AddDevice(), and HandleRemoveDevice().

◆ FreeBT_WmiRegistration()

NTSTATUS NTAPI FreeBT_WmiRegistration ( IN OUT PDEVICE_EXTENSION  DeviceExtension)

Definition at line 37 of file fbtwmi.c.

38{
39 NTSTATUS ntStatus;
40
41 PAGED_CODE();
42
43 DeviceExtension->WmiLibInfo.GuidCount = sizeof (FreeBTWmiGuidList) / sizeof (WMIGUIDREGINFO);
44 DeviceExtension->WmiLibInfo.GuidList = FreeBTWmiGuidList;
45 DeviceExtension->WmiLibInfo.QueryWmiRegInfo = FreeBT_QueryWmiRegInfo;
46 DeviceExtension->WmiLibInfo.QueryWmiDataBlock = FreeBT_QueryWmiDataBlock;
47 DeviceExtension->WmiLibInfo.SetWmiDataBlock = FreeBT_SetWmiDataBlock;
48 DeviceExtension->WmiLibInfo.SetWmiDataItem = FreeBT_SetWmiDataItem;
49 DeviceExtension->WmiLibInfo.ExecuteWmiMethod = NULL;
50 DeviceExtension->WmiLibInfo.WmiFunctionControl = NULL;
51
52 // Register with WMI
53 ntStatus = IoWMIRegistrationControl(DeviceExtension->FunctionalDeviceObject, WMIREG_ACTION_REGISTER);
54
55 return ntStatus;
56
57}
#define NULL
Definition: types.h:112
NTSTATUS NTAPI FreeBT_SetWmiDataItem(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN ULONG GuidIndex, IN ULONG InstanceIndex, IN ULONG DataItemId, IN ULONG BufferSize, IN PUCHAR Buffer)
Definition: fbtwmi.c:327
NTSTATUS NTAPI FreeBT_QueryWmiRegInfo(IN PDEVICE_OBJECT DeviceObject, OUT ULONG *RegFlags, OUT PUNICODE_STRING InstanceName, OUT PUNICODE_STRING *RegistryPath, OUT PUNICODE_STRING MofResourceName, OUT PDEVICE_OBJECT *Pdo)
Definition: fbtwmi.c:147
NTSTATUS NTAPI FreeBT_QueryWmiDataBlock(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN ULONG GuidIndex, IN ULONG InstanceIndex, IN ULONG InstanceCount, IN OUT PULONG InstanceLengthArray, IN ULONG OutBufferSize, OUT PUCHAR Buffer)
Definition: fbtwmi.c:217
WMIGUIDREGINFO FreeBTWmiGuidList[1]
Definition: fbtwmi.c:28
NTSTATUS NTAPI FreeBT_SetWmiDataBlock(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN ULONG GuidIndex, IN ULONG InstanceIndex, IN ULONG BufferSize, IN PUCHAR Buffer)
Definition: fbtwmi.c:427
#define WMIREG_ACTION_REGISTER

Referenced by FreeBT_AddDevice().

◆ WMIMinorFunctionString()

PCHAR NTAPI WMIMinorFunctionString ( UCHAR  MinorFunction)

Definition at line 509 of file fbtwmi.c.

510{
511 switch (MinorFunction)
512 {
514 return "IRP_MN_CHANGE_SINGLE_INSTANCE\n";
515
517 return "IRP_MN_CHANGE_SINGLE_ITEM\n";
518
520 return "IRP_MN_DISABLE_COLLECTION\n";
521
523 return "IRP_MN_DISABLE_EVENTS\n";
524
526 return "IRP_MN_ENABLE_COLLECTION\n";
527
529 return "IRP_MN_ENABLE_EVENTS\n";
530
532 return "IRP_MN_EXECUTE_METHOD\n";
533
535 return "IRP_MN_QUERY_ALL_DATA\n";
536
538 return "IRP_MN_QUERY_SINGLE_INSTANCE\n";
539
540 case IRP_MN_REGINFO:
541 return "IRP_MN_REGINFO\n";
542
543 default:
544 return "IRP_MN_?????\n";
545
546 }
547
548}
_In_ UCHAR _In_ UCHAR MinorFunction
Definition: wdfdevice.h:1699
#define IRP_MN_EXECUTE_METHOD
#define IRP_MN_DISABLE_COLLECTION
#define IRP_MN_CHANGE_SINGLE_ITEM
#define IRP_MN_QUERY_ALL_DATA
#define IRP_MN_DISABLE_EVENTS
#define IRP_MN_ENABLE_EVENTS
#define IRP_MN_ENABLE_COLLECTION
#define IRP_MN_REGINFO
#define IRP_MN_CHANGE_SINGLE_INSTANCE
#define IRP_MN_QUERY_SINGLE_INSTANCE

Referenced by FreeBT_DispatchSysCtrl().

Variable Documentation

◆ FreeBTWmiGuidList

WMIGUIDREGINFO FreeBTWmiGuidList[1]
Initial value:
=
{
{
&FREEBT_WMI_STD_DATA_GUID, 1, 0
}
}

Definition at line 28 of file fbtwmi.c.

Referenced by FreeBT_WmiRegistration().