ReactOS  0.4.15-dev-2344-g8ddbfde
fxdeviceum.cpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxDeviceUm.cpp
8 
9 Abstract:
10 
11  This is the KM specific class implementation for the base Device class.
12 
13 Author:
14 
15 
16 
17 Environment:
18 
19  User mode only
20 
21 Revision History:
22 
23 --*/
24 
25 #include "coreprivshared.hpp"
26 
27 extern "C" {
28 #include "FxDeviceUm.tmh"
29 }
30 
31 VOID
34  _In_ MdIrp Irp,
36  )
37 {
39 
40 
41 
42 
43 
45 }
46 
47 VOID
50  _In_ MdIrp Irp,
52  )
53 {
55 
57 }
58 
59 FxDevice*
62  )
63 {
64  IWudfDevice2* device2;
65 
66 
67 
68 
69  device2 = static_cast<IWudfDevice2*> (DeviceObject);
70 
71  return (FxDevice *)device2->GetContext();
72 }
73 
78  )
79 {
82  FxPkgFdo * pkgFdo;
83  HRESULT hr;
84  BOOLEAN bAttached = FALSE;
85 
87 
88  if (DeviceInit->Fdo.EventCallbacks.EvtDeviceFilterAddResourceRequirements != NULL &&
89  DeviceInit->Fdo.EventCallbacks.EvtDeviceRemoveAddedResources == NULL) {
90  //
91  // Not allowed to add resources without filtering them out later
92  //
95  "Must set EvtDeviceRemoveAddedResources if "
96  "EvtDeviceFilterAddResourceRequirements (%p) is set",
97  DeviceInit->Fdo.EventCallbacks.EvtDeviceFilterAddResourceRequirements);
98 
100 
102  }
103 
104  //
105  // All FDOs cannot be deleted through the driver calling WdfObjectDelete
106  //
107  MarkNoDeleteDDI();
108 
109  m_PhysicalDevice.SetObject((MdDeviceObject)DeviceInit->Fdo.PhysicalDevice);
110 
111  //
112  // The PDO is known because it was used to bring up this FDO.
113  //
114  m_PdoKnown = TRUE;
115 
116  //
117  // Try to create and install the default packages that an FDO contains.
118  //
119 
120  // PnP
121  status = FxPkgFdo::_Create(pGlobals, (CfxDevice*)this, &pkgFdo);
122 
123  if (!NT_SUCCESS(status)) {
124  return status;
125  }
126  else {
127  m_PkgPnp = pkgFdo;
128  }
129 
131 
132  status = SetFilter(DeviceInit->Fdo.Filter);
133  if (!NT_SUCCESS(status)) {
134  return status;
135  }
136 
138  if (!NT_SUCCESS(status)) {
139  return status;
140  }
141 
142 
143  //
144  // Should be done after invoking Initialize so that FxPkgFdo::m_EnumInfo is
145  // already allocated.
146  //
147  if (DeviceInit->Fdo.ListConfig.Size > 0) {
149  &DeviceInit->Fdo.ListConfig,
150  DeviceInit->Fdo.ListConfigAttributes.Size > 0
151  ? &DeviceInit->Fdo.ListConfigAttributes
152  : NULL);
153 
154  if (!NT_SUCCESS(status)) {
155  return status;
156  }
157 
159  }
160 
161  //
162  // If the Size is zero then the driver writer never set any callbacks so we
163  // can skip this call.
164  //
165  if (DeviceInit->Fdo.EventCallbacks.Size != 0) {
166  status = GetFdoPkg()->RegisterCallbacks(&DeviceInit->Fdo.EventCallbacks);
167  if (!NT_SUCCESS(status)) {
168  return status;
169  }
170  }
171 
173  if (NT_SUCCESS(status)) {
174  MdDeviceObject attachedDevice = NULL;
175 
176  //
177  // If this is an FDO then the PhysicalDevice field will be initialized,
178  // and we need to attach to the device stack.
179  //
180  //
181  // Attach the newly created host device object to existing stack.
182  // Insert the host device in the device chain for this device stack.
183  //
184  hr = DeviceInit->DevStack->AttachDevice(
186  &attachedDevice
187  );
188  if (S_OK == hr) {
190  }
191  else {
192  //
193  // Catch if the host isn't obeying the COM contract that requires
194  // a NULL interface when FAILED(hr).
195  // Note that AttachDevice can return success with a NULL interface
196  // for the attached device when this device is the first in the
197  // stack.
198  //
199  FX_VERIFY(DRIVER(BadArgument, TODO), CHECK_NULL(attachedDevice));
201  goto exit;
202  }
203 
204  m_AttachedDevice.SetObject(attachedDevice);
205  bAttached = TRUE;
206 
207  if (m_AttachedDevice.GetObject() == NULL) {
208  //
209  // Note that AttachDevice can return success with a NULL interface
210  // for the attached device when this device is the first in the
211  // stack.
212  //
213 
214 
215 
216 
217  //
218  DO_NOTHING();
219  }
220 
221  if (NT_SUCCESS(status)) {
222  //
223  // If PPO, save newly created device as PPO in device stack
224  //
225  if (DeviceInit->IsPwrPolOwner()) {
227  }
228 
229  //
230  // If we are a filter device, inherit some state from the
231  // attached device.
232  //
233  if (m_Filter) {
234  //
235  // Set the IO type and power pageable status on our device based
236  // on the attached device's settings.
237  //
238  SetFilterIoType();
239 
240  if (m_AttachedDevice.GetObject() != NULL) {
243  }
244 
245  //
246  // For devices other then filters, m_PowerPageableCapable gets
247  // set in CreateDevice, but since this is determined for filters
248  // by the device they have attached to, we must set this value
249  // later as a special case only for filters.
250  //
253  }
254  }
255  else {
256  //
257  // We are not a filter, we dictate our own DO flags
258  //
259 
260  //
261  // Power pageable and inrush are mutually exclusive
262  //
263  if (DeviceInit->PowerPageable) {
265  }
266  else if (DeviceInit->Inrush) {
268  }
269  }
270  }
271  }
272 
273  //
274  // Set buffer retrieval and I/O type values
275  //
276  m_RetrievalMode = UMINT::WdfDeviceIoBufferRetrievalDeferred;
277  m_ReadWriteIoType = DeviceInit->ReadWriteIoType;
278  m_IoctlIoType = DeviceInit->DeviceControlIoType;;
279  m_DirectTransferThreshold = DeviceInit->DirectTransferThreshold;
280 
281  //
282  // Read HwAccess settings from registry
283  //
285 
286  if (!NT_SUCCESS(status)) {
287  return status;
288  }
289 
291  if (!NT_SUCCESS(status)) {
292  return status;
293  }
294 
296 
297  if (NT_SUCCESS(status)) {
298  //
299  // Do not clear the DO_DEVICE_INITIALIZING bit here. Instead, either
300  // let the caller do it in their AddDevice or do it after the AddDevice
301  // callback returns.
302  //
303  // FinishInitializing();
304  }
305 
306  exit:
307 
308  //
309  // Let the device stack object hold the only reference to
310  // the host devices. The infrastructure guarantees that the device
311  // stack's lifetime is greater than the this object's lifetime.
312  // If the Attach failed, the object will be destroyed.
313  //
314  if (NULL != m_DeviceObject.GetObject()) {
315  m_DeviceObject.GetObject()->Release();
316  }
317 
318  if (NULL != m_AttachedDevice.GetObject()) {
319  m_AttachedDevice.GetObject()->Release();
320  }
321 
322  if (!NT_SUCCESS(status)) {
323  if (bAttached) {
324  DetachDevice();
325  bAttached = FALSE;
326  }
327 
328  //
329  // NULL out m_pIWudfDevice so that d'tor doesn't try to detach again.
330  //
331  m_DeviceObject.SetObject(NULL); // weak ref.
332  m_AttachedDevice.SetObject(NULL); // weak ref.
333  }
334 
335  return status;
336 }
337 
339 NTSTATUS
342  )
343 {
344  MdDeviceObject pNewDeviceObject = NULL;
345  ULONG characteristics;
347  DEVICE_TYPE devType;
348  HRESULT hr;
349  IWudfDevice2* pNewDeviceObject2;
350  IWudfDeviceStack2* pDevStack2;
351 
353  if (!NT_SUCCESS(status)) {
354  return status;
355  }
356 
357 
358 
359 
360 
361 
362 
363 
364 
365 
366  UNREFERENCED_PARAMETER(devType);
367 
368  characteristics = DeviceInit->Characteristics;
369 
371  this,
372  &m_Dispatcher);
373  if (!NT_SUCCESS(status)) {
374  return status;
375  }
376 
377  hr = DeviceInit->DevStack->QueryInterface(IID_IWudfDeviceStack2,
378  (PVOID*)&pDevStack2);
379  FX_VERIFY(INTERNAL, CHECK_QI(hr, pDevStack2));
380  if (FAILED(hr)) {
382  return status;
383  }
384  pDevStack2->Release(); // weak ref. is sufficient.
385 
386  //
387  // Create IWudfDevice
388  //
389  hr = pDevStack2->CreateDevice2(DeviceInit->DriverID,
390  static_cast<IFxMessageDispatch*>(m_Dispatcher),
391  sizeof(FxWdmDeviceExtension),
392  &pNewDeviceObject2);
393  if (FAILED(hr)) {
395  return status;
396  }
397 
398  hr = pNewDeviceObject2->QueryInterface(IID_IWudfDevice,
399  (PVOID*)&pNewDeviceObject);
400  FX_VERIFY(INTERNAL, CHECK_QI(hr, pNewDeviceObject));
401  if (FAILED(hr)) {
403  return status;
404  }
405  pNewDeviceObject->Release(); // weak ref. is sufficient.
406 
407  if (NT_SUCCESS(status)) {
408 
409  //
410  // Initialize the remove lock and the event for use with the remove lock
411  // The event is initiatalized via IWudfDevice so the host can close the
412  // handle before destroying the allocated "WDM extension"
413  // In the KMDF implementation the "WDM device extension" is allocated by
414  // IoCreateDevice and destroyed when the WDM device object is deleted.
415  // In the kernel implementation the allocated extension only needs to be freed,
416  // where-as with UM the event handle needs to be closed as well.
417  //
418  FxWdmDeviceExtension* pWdmExt;
419  pWdmExt = _GetFxWdmExtension(pNewDeviceObject);
420 
423  0, // max min
424  0); // highwater mark
425 
426  status = pNewDeviceObject2->InitializeEventForRemoveLock(
427  &(pWdmExt->IoRemoveLock.RemoveEvent));
428  if (!NT_SUCCESS(status)) {
429  return status;
430  }
431  ASSERT(pWdmExt->IoRemoveLock.RemoveEvent);
432 
433  m_DeviceObject.SetObject(pNewDeviceObject);
434 
435  //
436  // Set the context
437  //
438  pNewDeviceObject2->SetContext(this);
439 
440  //
441  // capture input info
442  //
443  m_DevStack = DeviceInit->DevStack;
444 
445  //
446  // Hijack from deviceinit
447  //
448  m_PdoDevKey = DeviceInit->PdoKey;
449  DeviceInit->PdoKey = NULL;
450 
451  m_DeviceKeyPath = DeviceInit->ConfigRegistryPath;
452  DeviceInit->ConfigRegistryPath = NULL;
453 
454  m_KernelDeviceName = DeviceInit->KernelDeviceName;
455  DeviceInit->KernelDeviceName = NULL;
456 
457  m_DeviceInstanceId = DeviceInit->DevInstanceID;
458  DeviceInit->DevInstanceID = NULL;
459 
460  //
461  // Set some device object flags based on properties of DeviceInit.
462  //
463  // If we are a filter, we will set these flags later
464  // (in FxDevice::FdoInitialize) based on the device we are attached to.
465  //
466  if (m_Filter == FALSE) {
467  if (DeviceInit->ReadWriteIoType == WdfDeviceIoBuffered) {
469  }
470  else if (DeviceInit->ReadWriteIoType == WdfDeviceIoDirect) {
472  }
473 
474  m_ReadWriteIoType = DeviceInit->ReadWriteIoType;
475  m_PowerPageableCapable = DeviceInit->PowerPageable;
476  }
477 
478  //
479  // Note: In case of UMDF the StackSize of the MdDeviceObject must
480  // be incremented prior to calling AttachDevice. It is because at the
481  // time of attaching the device the CWudfDevStack caches the stack
482  // size of devnode.
483  // This is unlike KMDF where it must be done after AttachDevice.
484  // Though the UMDF design can be modified to match KMDF solution, it
485  // seems simpler to adjust the stack size of UMDF prior to AttachDevice
486  //
487  if (m_SelfIoTargetNeeded) {
489  }
490  }
491 
492  return status;
493 }
494 
495 VOID
497  VOID
498  )
499 {
500  //
501  // If there was a failure during create (AddDevice), we need to detach
502  // from stack so that we don't receive remove irp from host (since fx sm
503  // uses a simulated remove event to do remove related cleanup).
504  //
506  if (m_DeviceObject.GetObject() != NULL) {
508 
509  //
510  // The device object may not go away right away if there are pending
511  // references on it. But we can't look up our FxDevice anymore, so
512  // lets clear the DeviceExtension pointer.
513  //
515  }
516 
517  //
518  // Since this can be called in the context of the destructor when the ref
519  // count is zero, use GetObjectHandleUnchecked() to get the handle value.
520  //
523  "Deleting !devobj %p, WDFDEVICE %p, attached to !devobj %p",
526 
527  //
528  // This will detach the device from stack. Note that detach may cause
529  // the last ref on device object (IWudfDevice) to be released and
530  // therefore delete the device object.
531  //
532  DetachDevice();
533  }
534 }
535 
536 VOID
538  VOID
539  )
540 {
541  if (m_DeviceObject.GetObject() != NULL) {
542  //
543  // The device object may not go away right away if there are pending
544  // references on it. But we can't look up our FxDevice anymore, so
545  // lets clear the DeviceExtension pointer.
546  //
548  }
549 
550  //
551  // Since this can be called in the context of the destructor when the ref
552  // count is zero, use GetObjectHandleUnchecked() to get the handle value.
553  //
556  "Deleting !devobj %p, WDFDEVICE %p, attached to !devobj %p",
559 
560  //
561  // This will detach the device from stack. Note that detach may cause
562  // the last ref on device object (IWudfDevice) to be released and
563  // therefore delete the device object.
564  //
565  DetachDevice();
566 
567  if (m_InteruptThreadpool) {
568  delete m_InteruptThreadpool;
570  }
571 
572  delete [] m_KernelDeviceName;
574 
575  delete [] m_DeviceKeyPath;
577 
578  delete [] m_DeviceInstanceId;
580 
581  if (m_PdoDevKey) {
583  this->m_PdoDevKey = NULL;
584  }
585 
586  if (m_Dispatcher) {
587  delete m_Dispatcher;
588  m_Dispatcher = NULL;
589  }
590 }
591 
592 VOID
596  _Out_ WDF_DEVICE_IO_TYPE *RWPreference,
597  _Out_ WDF_DEVICE_IO_TYPE *IoctlPreference
598  )
599 /*++
600 
601  Routine Description:
602 
603  This method returns the i/o type information for the device to the
604  caller.
605 
606  Arguments:
607 
608  RetrievalMode - the retrival mode desired by this device
609 
610  RWPreference - the preferred r/w mode for the device
611 
612  IoctlPreference - the preferred ioctl mode for the device
613 
614  Return Value:
615 
616  None
617 
618 --*/
619 {
620  FxDevice* device;
621 
623 
624  *RetrievalMode = device->GetRetrievalMode();
625  *RWPreference = device->GetPreferredRWTransferMode();
626  *IoctlPreference = device->GetPreferredIoctlTransferMode();
627 }
628 
630 NTSTATUS
633  )
634 {
636  ASSERTMSG("Not implemented for UMDF\n", FALSE);
637  return STATUS_NOT_IMPLEMENTED;
638 }
639 
640 
642 NTSTATUS
645  )
646 {
648  ASSERTMSG("Not implemented for UMDF\n", FALSE);
649  return STATUS_NOT_IMPLEMENTED;
650 }
651 
652 VOID
655  )
656 {
658  ASSERTMSG("Not implemented for UMDF\n", FALSE);
659 }
660 
661 VOID
664  )
665 {
667  ASSERTMSG("Not implemented for UMDF\n", FALSE);
668 }
669 
671 NTSTATUS
673  VOID
674  )
675 {
676  ASSERTMSG("Not implemented for UMDF\n", FALSE);
677  return STATUS_NOT_IMPLEMENTED;
678 }
679 
680 VOID
682  __inout FxDmaEnabler* Enabler
683  )
684 {
685  UNREFERENCED_PARAMETER(Enabler);
686  ASSERTMSG("Not implemented for UMDF\n", FALSE);
687 }
688 
689 VOID
691  __inout FxDmaEnabler* Enabler
692  )
693 {
694  UNREFERENCED_PARAMETER(Enabler);
695  ASSERTMSG("Not implemented for UMDF\n", FALSE);
696 }
697 
698 NTSTATUS
700  _In_ RdWmiPowerAction Action,
701  _Out_ BOOLEAN * QueryResult
702  )
703 /*++
704 
705  Routine Description:
706 
707  This method is called to process WMI set/Query data received from
708  reflector. Reflector sends this message when it receives a WMI Query or
709  Set Irp for this device for power guids.
710 
711  Arguments:
712 
713  Action - Enumeration of Set and Query actions for S0Idle and SxWake
714 
715  *QueryResult - receives the query result.
716 
717  Return Value:
718 
719  STATUS_SUCCESS if successful
720 
721  STATUS_INVALID_PARAMETER if the parameter values are invalid
722 
723 --*/
724 {
725  if (Action == ActionInvalid) {
727  }
728 
729  if ((Action == QueryS0Idle || Action == QuerySxWake) && QueryResult == NULL) {
731  }
732 
733  switch(Action)
734  {
735  case SetS0IdleEnable:
737  break;
738  case SetS0IdleDisable:
740  break;
741  case SetSxWakeEnable:
743  break;
744  case SetSxWakeDisable:
746  break;
747  case QueryS0Idle:
749  break;
750  case QuerySxWake:
752  break;
753  default:
754  ASSERT(FALSE);
755  break;
756  }
757 
758  return STATUS_SUCCESS;
759 }
760 
763  _In_ IWudfDevice * DeviceObject,
764  _In_ LPCGUID DeviceInterfaceGuid,
766  )
767 {
769  UNREFERENCED_PARAMETER(DeviceInterfaceGuid);
771 
772  ASSERTMSG("Not implemented for UMDF\n", FALSE);
773 
774  return NULL;
775 }
776 
777 void
779  _In_ IWudfDevice * DeviceObject,
780  _In_ WUDF_INTERFACE_CONTEXT RemoteInterfaceID
781  )
782 {
784  UNREFERENCED_PARAMETER(RemoteInterfaceID);
785 
786  ASSERTMSG("Not implemented for UMDF\n", FALSE);
787 }
788 
789 BOOL
791  _In_ IWudfDevice * DeviceObject,
792  _In_ DWORD Id,
793  _In_ PVOID DataBuffer,
794  _In_ SIZE_T cbDataBufferSize
795  )
796 {
799  UNREFERENCED_PARAMETER(DataBuffer);
800  UNREFERENCED_PARAMETER(cbDataBufferSize);
801 
802  ASSERTMSG("Not implemented for UMDF\n", FALSE);
803 
804  return FALSE;
805 }
806 
807 void
810  )
811 {
813  m_PoxInterface.PowerRequiredCallbackInvoked();
814 }
815 
816 void
819  )
820 {
822  m_PoxInterface.PowerNotRequiredCallbackInvoked();
823 }
824 
825 NTSTATUS
827  _In_ IWudfDeviceStack * DevStack,
828  _In_ HRESULT Hr
829  )
830 {
831  PUMDF_VERSION_DATA driverVersion = DevStack->GetMinDriverVersion();
832  BOOL preserveCompat =
833  DevStack->ShouldPreserveIrpCompletionStatusCompatibility();
834 
835  return CHostFxUtil::NtStatusFromHr(Hr,
836  driverVersion->MajorNumber,
837  driverVersion->MinorNumber,
838  preserveCompat
839  );
840 }
841 
842 NTSTATUS
844  _In_ HRESULT Hr
845  )
846 {
848 }
849 
850 VOID
852  VOID
853  )
854 {
855  DWORD err;
856  HKEY wudfKey = NULL;
857  DWORD data;
858  DWORD dataSize;
859 
861  WUDF_SUB_KEY,
862  0,
863  KEY_READ,
864  &wudfKey);
865  if (ERROR_SUCCESS != err) {
867  "Failed to open hw registry key to read hw access settings");
868  goto clean0;
869  }
870 
871  //
872  // Read FX_DIRECT_HARDWARE_ACCESS value
873  //
874  dataSize = sizeof(data);
875  data = 0;
876  err = RegQueryValueEx(wudfKey,
878  NULL,
879  NULL,
880  (BYTE*) &data,
881  &dataSize);
882 
883  if (ERROR_SUCCESS == err) {
884  if (((WDF_DIRECT_HARDWARE_ACCESS_TYPE)data) < WdfDirectHardwareAccessMax) {
885  //
886  // save the setting only if it is valid
887  //
888  m_DirectHardwareAccess = (WDF_DIRECT_HARDWARE_ACCESS_TYPE)data;
889  }
890  else {
892  "invalid direct hardware access value in registry %u",
893  (WDF_DIRECT_HARDWARE_ACCESS_TYPE)data);
894  }
895  }
896  else if (ERROR_FILE_NOT_FOUND != err) {
898  "Failed to read direct hardware access value in registry");
899  }
900 
902  "DirectHardwareAccess = %u", m_DirectHardwareAccess);
903 
904 
905  //
906  // Read FX_REGISTER_ACCESS_MODE value
907  //
908  dataSize = sizeof(data);
909  data = 0;
910  err = RegQueryValueEx(wudfKey,
912  NULL,
913  NULL,
914  (BYTE*) &data,
915  &dataSize);
916  if (ERROR_SUCCESS == err) {
917  if (((WDF_REGISTER_ACCESS_MODE_TYPE)data) < WdfRegisterAccessMax) {
918  //
919  // save the setting only if it is valid
920  //
921  m_RegisterAccessMode = (WDF_REGISTER_ACCESS_MODE_TYPE)data;
922  }
923  else {
925  "Invalid Register Access mode value in registry %u",
926  (WDF_REGISTER_ACCESS_MODE_TYPE)data);
927  }
928  }
929  else if (ERROR_FILE_NOT_FOUND != err) {
931  "Failed to read Register Access mode value in registry");
932  }
933 
935  "RegisterAccessMode = %u", m_RegisterAccessMode);
936 
937  //
938  // Read FX_FILE_OBJECT_POLICY
939  //
940  dataSize = sizeof(data);
941  data = 0;
942  err = RegQueryValueEx(wudfKey,
944  NULL,
945  NULL,
946  (BYTE*) &data,
947  &dataSize);
948  if (ERROR_SUCCESS == err) {
949  if (((WDF_FILE_OBJECT_POLICY_TYPE)data) < WdfFileObjectPolicyMax) {
950  //
951  // save the setting only if it is valid
952  //
953  m_FileObjectPolicy = (WDF_FILE_OBJECT_POLICY_TYPE)data;
954  }
955  else {
957  "Invalid File object Policy value in registry %u",
958  (WDF_FILE_OBJECT_POLICY_TYPE)data);
959  }
960  }
961  else if (ERROR_FILE_NOT_FOUND != err) {
963  "Failed to read File Object Policy value in registry");
964  }
965 
967  "FileObjectPolicy = %u", m_FileObjectPolicy);
968 
969  //
970  // Read FX_FS_CONTEXT_USE_POLICY
971  //
972  dataSize = sizeof(data);
973  data = 0;
974  err = RegQueryValueEx(wudfKey,
976  NULL,
977  NULL,
978  (BYTE*) &data,
979  &dataSize);
980  if (ERROR_SUCCESS == err) {
981  if (((WDF_FS_CONTEXT_USE_POLICY_TYPE)data) < WdfFsContextUsePolicyMax) {
982  //
983  // save the setting only if it is valid
984  //
985  m_FsContextUsePolicy = (WDF_FS_CONTEXT_USE_POLICY_TYPE)data;
986  }
987  else {
989  "Invalid Fs Context Use Policy value in registry %u",
990  (WDF_FILE_OBJECT_POLICY_TYPE)data);
991  }
992  }
993  else if (ERROR_FILE_NOT_FOUND != err) {
995  "Failed to read Fs Context Use Policy value in registry");
996  }
997 
999  "FsContextUsePolicy = %u", m_FsContextUsePolicy);
1000 
1001 
1002 clean0:
1003 
1004  if (NULL != wudfKey) {
1005  RegCloseKey(wudfKey);
1006  }
1007 
1008  return;
1009 }
1010 
1011 NTSTATUS
1013  _In_ PFX_DRIVER_GLOBALS FxDriverGlobals,
1014  _In_ IWudfDeviceStack* DeviceStack,
1015  _In_ PWSTR DriverName,
1019  )
1020 {
1021  NTSTATUS status;
1022  HRESULT hr;
1023 
1024  UMINT::WDF_PROPERTY_STORE_ROOT root;
1025  UMINT::WDF_PROPERTY_STORE_RETRIEVE_FLAGS flags = UMINT::WdfPropertyStoreNormal;
1026  PWSTR subpath = NULL;
1027 
1028 
1029 
1030 
1031  #define WDF_REGKEY_DEVICE_SUBKEY 256
1032  #define WDF_REGKEY_DRIVER_SUBKEY 256
1033 
1034  root.LengthCb = sizeof(UMINT::WDF_PROPERTY_STORE_ROOT);
1035 
1037  {
1038  ASSERTMSG("Not available in UMDF\n", FALSE);
1039  }
1041  {
1042  root.RootClass = UMINT::WdfPropertyStoreRootClassHardwareKey;
1043 
1045  {
1046  root.Qualifier.HardwareKey.ServiceName = DriverName;
1047  flags = UMINT::WdfPropertyStoreCreateIfMissing;
1048  }
1049  else
1050  {
1051  root.Qualifier.HardwareKey.ServiceName = WDF_PROPERTY_STORE_HARDWARE_KEY_ROOT;
1052  }
1053  }
1055  {
1056  root.RootClass = UMINT::WdfPropertyStoreRootClassSoftwareKey;
1057 
1059  {
1060  subpath = DriverName;
1061  flags = UMINT::WdfPropertyStoreCreateIfMissing;
1062  }
1063  else
1064  {
1065  subpath = L"\\";
1066  }
1067  }
1069  {
1070  root.RootClass = UMINT::WdfPropertyStoreRootClassLegacyHardwareKey;
1071 
1072  //
1073  // Legacy keys must always be opened volatile for UMDF
1074  //
1075  flags = UMINT::WdfPropertyStoreCreateVolatile;
1076 
1077  subpath = NULL;
1078  root.Qualifier.LegacyHardwareKey.LegacyMapName = DriverName;
1079  }
1080 
1081  hr = ((IWudfDeviceStack*)DeviceStack)->CreateRegistryEntry(&root,
1082  flags,
1083  DesiredAccess,
1084  subpath,
1086  NULL);
1087  status = FxDevice::NtStatusFromHr(DeviceStack, hr);
1088 
1089  return status;
1090 }
1091 
1092 NTSTATUS
1094  _In_ PVOID DeviceStack,
1099  )
1100 {
1101  HRESULT hr;
1102  NTSTATUS status;
1103 
1104  DEVPROPTYPE propType;
1105  const DEVPROPKEY *propKey = NULL;
1106 
1107  //
1108  // {cccccccc-cccc-cccc-cccc-cccccccccccc}
1109  // 2 brackets + 4 dashes + 32 characters + UNICODE_NULL
1110  //
1111  GUID guidBuffer = {0};
1112  ULONG guidChLen = 2 + 4 + 32 + 1;
1113  ULONG guidCbLen = guidChLen * sizeof(WCHAR);
1114  BOOLEAN convertGuidToString = FALSE;
1115 
1117  ULONG bufferLen = BufferLength;
1118  ULONG resultLen = 0;
1119 
1120  UMINT::WDF_PROPERTY_STORE_ROOT rootSpecifier;
1121  rootSpecifier.LengthCb = sizeof(UMINT::WDF_PROPERTY_STORE_ROOT);
1122  rootSpecifier.RootClass = UMINT::WdfPropertyStoreRootClassHardwareKey;
1123  rootSpecifier.Qualifier.HardwareKey.ServiceName = NULL;
1124 
1125  //
1126  // Map DEVICE_REGISTRY_PROPERTY enums to DEVPROPKEYs
1127  //
1128  switch (DeviceProperty)
1129  {
1131  propKey = &DEVPKEY_Device_DeviceDesc;
1132  break;
1134  propKey = &DEVPKEY_Device_HardwareIds;
1135  break;
1137  propKey = &DEVPKEY_Device_CompatibleIds;
1138  break;
1140  ASSERTMSG("Not available in UMDF\n", FALSE);
1141  break;
1143  ASSERTMSG("Not available in UMDF\n", FALSE);
1144  break;
1146  propKey = &DEVPKEY_Device_Class;
1147  break;
1149  propKey = &DEVPKEY_Device_ClassGuid;
1150  convertGuidToString = TRUE;
1151  break;
1153  propKey = &DEVPKEY_NAME;
1154  break;
1156  propKey = &DEVPKEY_Device_Manufacturer;
1157  break;
1159  propKey = &DEVPKEY_Device_FriendlyName;
1160  break;
1162  propKey = &DEVPKEY_Device_LocationInfo;
1163  break;
1165  propKey = &DEVPKEY_Device_PDOName;
1166  break;
1168  propKey = &DEVPKEY_Device_BusTypeGuid;
1169  break;
1171  propKey = &DEVPKEY_Device_LegacyBusType;
1172  break;
1174  propKey = &DEVPKEY_Device_BusNumber;
1175  break;
1177  propKey = &DEVPKEY_Device_EnumeratorName;
1178  break;
1179  case DevicePropertyAddress:
1180  propKey = &DEVPKEY_Device_Address;
1181  break;
1183  propKey = &DEVPKEY_Device_UINumber;
1184  break;
1186  propKey = &DEVPKEY_Device_InstallState;
1187  break;
1189  propKey = &DEVPKEY_Device_RemovalPolicy;
1190  break;
1192  ASSERTMSG("Not available in UMDF\n", FALSE);
1193  break;
1195  ASSERTMSG("Not available in UMDF\n", FALSE);
1196  break;
1198  propKey = &DEVPKEY_Device_ContainerId;
1199  convertGuidToString = TRUE;
1200  break;
1201  }
1202 
1203  FX_VERIFY(DRIVER(BadArgument, TODO), CHECK_NOT_NULL(propKey));
1204 
1205  if (convertGuidToString)
1206  {
1207  buffer = &guidBuffer;
1208  bufferLen = sizeof(GUID);
1209  }
1210 
1211  hr = ((IWudfDeviceStack*)DeviceStack)->GetUnifiedPropertyData(&rootSpecifier,
1212  propKey,
1213  0,
1214  0,
1215  bufferLen,
1216  &propType,
1217  &resultLen,
1218  buffer);
1219  if (S_OK == hr)
1220  {
1222 
1223  //
1224  // Some DEVICE_REGISTRY_PROPERTY values are GUID strings,
1225  // while their DEVPROPKEY equivalents are GUID structs. To preserve
1226  // KMDF-UMDF DDI parity, we convert select GUID structs to wchar strings.
1227  //
1228  if (convertGuidToString)
1229  {
1230  if (PropertyBuffer == NULL || BufferLength < guidCbLen)
1231  {
1233  }
1234  else
1235  {
1237  guidChLen,
1238  L"{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
1239  guidBuffer.Data1, guidBuffer.Data2, guidBuffer.Data3,
1240  guidBuffer.Data4[0], guidBuffer.Data4[1],
1241  guidBuffer.Data4[2], guidBuffer.Data4[3],
1242  guidBuffer.Data4[4], guidBuffer.Data4[5],
1243  guidBuffer.Data4[6], guidBuffer.Data4[7]);
1244  if (hr != S_OK)
1245  {
1247  }
1248  }
1249  }
1250  }
1252  {
1254  }
1255  else
1256  {
1258  }
1259 
1260  if (ResultLength)
1261  {
1262  *ResultLength = convertGuidToString ? guidCbLen : resultLen;
1263  }
1264 
1265  return status;
1266 }
1267 
1268 VOID
1270  VOID
1271  )
1272 {
1273  //
1274  // Note that UMDF host's DetachDevice has a different interface than
1275  // IoDetachDevice. DetachDevice takes the current device object as parameter
1276  // instead of target device.
1277  //
1278  if (m_DevStack != NULL && m_DeviceObject.GetObject() != NULL) {
1281 
1282  //
1283  // This was a weak ref. Set it to NULL. m_DeviceObject (IWudfDevice)'s
1284  // lifetime is managed by host through a ref taken during Attach.
1285  //
1287  }
1288 }
1289 
1290 VOID
1292  VOID
1293  )
1294 {
1296 }
1297 
1298 NTSTATUS
1300  _In_ PFX_DRIVER_GLOBALS FxDriverGlobals,
1302  )
1303 {
1304  HRESULT hr;
1305  NTSTATUS status;
1306 
1307  status = FxDuplicateUnicodeString(FxDriverGlobals,
1310 
1311  if (!NT_SUCCESS(status)) {
1313  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
1314  "WDFDEVICE %p allocate buffer for symbolic name failed, %!STATUS!",
1315  GetHandle(), status);
1316 
1317  return status;
1318  }
1319 
1320  hr = GetDeviceStack()->CreateSymbolicLink(SymbolicLinkName->Buffer, NULL);
1321  if (SUCCEEDED(hr)) {
1323  }
1324  else {
1327 
1329 
1331  sizeof(m_SymbolicLinkName));
1332 
1334  "WDFDEVICE %p create symbolic link failed, %!STATUS!",
1335  GetHandle(), status);
1336  }
1337 
1338  return status;
1339 }
1340 
1341 VOID
1343  VOID
1344  )
1345 {
1346  if (m_SymbolicLinkName.Buffer != NULL) {
1347  //
1348  // There is no IoDeleteSymbolicLink equivalent exposed by UMDF host.
1349  // Reflector takes care of deleteing the symbolic link on removal.
1350  // So just free the string now.
1351  //
1354  }
1355 }
1356 
1357 NTSTATUS
1364  )
1365 {
1366  NTSTATUS status;
1367  HRESULT hr;
1368  const DEVPROPKEY * propertyKey;
1369  LCID lcid;
1370  ULONG flags;
1371 
1372  //
1373  // call into host to assign the property
1374  //
1375  UMINT::WDF_PROPERTY_STORE_ROOT rootSpecifier = {0};
1376 
1378  PWDF_DEVICE_INTERFACE_PROPERTY_DATA interfaceData =
1379  (PWDF_DEVICE_INTERFACE_PROPERTY_DATA) PropertyData;
1380 
1381  rootSpecifier.LengthCb = sizeof(UMINT::WDF_PROPERTY_STORE_ROOT);
1382  rootSpecifier.RootClass = UMINT::WdfPropertyStoreRootClassDeviceInterfaceKey;
1383  rootSpecifier.Qualifier.DeviceInterfaceKey.InterfaceGUID =
1384  interfaceData->InterfaceClassGUID;
1385  if (interfaceData->ReferenceString != NULL) {
1386  rootSpecifier.Qualifier.DeviceInterfaceKey.ReferenceString =
1387  interfaceData->ReferenceString->Buffer;
1388  }
1389  propertyKey = interfaceData->PropertyKey;
1390  lcid = interfaceData->Lcid;
1391  flags = interfaceData->Flags;
1392  }
1393  else {
1394  PWDF_DEVICE_PROPERTY_DATA deviceData =
1396 
1398 
1399  rootSpecifier.LengthCb = sizeof(UMINT::WDF_PROPERTY_STORE_ROOT);
1400  rootSpecifier.RootClass = UMINT::WdfPropertyStoreRootClassHardwareKey;
1401  propertyKey = deviceData->PropertyKey;
1402  lcid = deviceData->Lcid;
1403  flags = deviceData->Flags;
1404  }
1405 
1406  hr = GetDeviceStack()->SetUnifiedPropertyData(&rootSpecifier,
1407  propertyKey,
1408  lcid,
1409  flags,
1410  Type,
1411  BufferLength,
1412  PropertyBuffer);
1413  if (S_OK == hr) {
1415  }
1416  else {
1420  "WDFDEVICE %p failed to assign interface property, %!STATUS!",
1421  GetHandle(), status);
1422  }
1423 
1424  return status;
1425 }
1426 
1428 NTSTATUS
1430  _In_ PFX_DRIVER_GLOBALS FxDriverGlobals,
1436  _Out_ WDFKEY* Key
1437  )
1438 {
1439  FxRegKey* pKey;
1440  WDFKEY keyHandle;
1441  HANDLE hKey = NULL;
1442  NTSTATUS status;
1443  IWudfDeviceStack* deviceStack;
1444  PWSTR driverName;
1445 
1446  status = FxValidateObjectAttributes(FxDriverGlobals, KeyAttributes);
1447  if (!NT_SUCCESS(status)) {
1448  return status;
1449  }
1450 
1451  status = _ValidateOpenKeyParams(FxDriverGlobals, DeviceInit, Device);
1452  if (!NT_SUCCESS(status)) {
1453  return status;
1454  }
1455 
1457 
1458  if (DeviceInit != NULL) {
1459  deviceStack = DeviceInit->DevStack;
1460  driverName = DeviceInit->ConfigRegistryPath;
1461  }
1462  else {
1463  deviceStack = Device->m_DevStack;
1464  driverName = Device->m_DeviceKeyPath;
1465  }
1466 
1467  pKey = new(FxDriverGlobals, KeyAttributes) FxRegKey(FxDriverGlobals);
1468 
1469  if (pKey == NULL) {
1471  }
1472 
1473  if (Device != NULL) {
1475  }
1476 
1478 
1479  if (NT_SUCCESS(status)) {
1480  status = _OpenDeviceRegistryKey(FxDriverGlobals,
1481  deviceStack,
1482  driverName,
1484  DesiredAccess,
1485  &hKey);
1486  if (NT_SUCCESS(status)) {
1487  pKey->SetHandle(hKey);
1488  *Key = keyHandle;
1489  }
1490  }
1491 
1492  if (!NT_SUCCESS(status)) {
1493  //
1494  // No object is being returned, make sure the destroy callback will not
1495  // be called.
1496  //
1498  }
1499 
1500  return status;
1501 }
1502 
1504 NTSTATUS
1506  __out HANDLE* Key,
1508  )
1509 {
1510  NTSTATUS status;
1512  MdDeviceObject pdo;
1513 
1514  //
1515  // We need a PDO to open this reg key. in the case of failure to create
1516  // a static PDO, we will go down this path in the pnp state machine, so we
1517  // must check for validity always.
1518  //
1519  pdo = GetSafePhysicalDevice();
1520 
1521  if (pdo == NULL) {
1523  }
1524 
1526  m_DevStack,
1529  DesiredAccess,
1530  &parent.m_Key);
1531  if (NT_SUCCESS(status)) {
1532  DECLARE_CONST_UNICODE_STRING(wdf, L"WDF");
1533 
1534  //
1535  // Create the key if it does not already exist
1536  //
1537  status = FxRegKey::_Create(parent.m_Key,
1538  &wdf,
1539  Key,
1540  DesiredAccess);
1541  }
1542 
1543  return status;
1544 }
1545 
1547 NTSTATUS
1558  )
1559 {
1560  NTSTATUS status;
1561  HRESULT hr;
1562  DEVPROPTYPE propType;
1563  ULONG requiredLength = 0;
1564  const DEVPROPKEY * propertyKey;
1565  LCID lcid;
1566  ULONG flags;
1567  IWudfDeviceStack* devStack;
1568 
1569  *ResultLength = 0;
1570  *PropertyType = 0;
1571 
1573  DeviceInit,
1574  Device);
1575  if (!NT_SUCCESS(status)) {
1576  return status;
1577  }
1578 
1580 
1581  if (DeviceInit != NULL) {
1582  devStack = DeviceInit->DevStack;
1583  }
1584  else {
1585  devStack = Device->m_DevStack;
1586  }
1587 
1588  UMINT::WDF_PROPERTY_STORE_ROOT rootSpecifier = {0};
1589 
1591  PWDF_DEVICE_INTERFACE_PROPERTY_DATA interfaceData =
1592  (PWDF_DEVICE_INTERFACE_PROPERTY_DATA) PropertyData;
1593 
1594  rootSpecifier.LengthCb = sizeof(UMINT::WDF_PROPERTY_STORE_ROOT);
1595  rootSpecifier.RootClass = UMINT::WdfPropertyStoreRootClassDeviceInterfaceKey;
1596  rootSpecifier.Qualifier.DeviceInterfaceKey.InterfaceGUID =
1597  interfaceData->InterfaceClassGUID;
1598  if (interfaceData->ReferenceString != NULL) {
1599  rootSpecifier.Qualifier.DeviceInterfaceKey.ReferenceString =
1600  interfaceData->ReferenceString->Buffer;
1601  }
1602  propertyKey = interfaceData->PropertyKey;
1603  lcid = interfaceData->Lcid;
1604  flags = interfaceData->Flags;
1605  }
1606  else {
1607  PWDF_DEVICE_PROPERTY_DATA deviceData =
1609 
1611 
1612  rootSpecifier.LengthCb = sizeof(UMINT::WDF_PROPERTY_STORE_ROOT);
1613  rootSpecifier.RootClass = UMINT::WdfPropertyStoreRootClassHardwareKey;
1614  propertyKey = deviceData->PropertyKey;
1615  lcid = deviceData->Lcid;
1616  flags = deviceData->Flags;
1617  }
1618 
1619  hr = devStack->GetUnifiedPropertyData(&rootSpecifier,
1620  propertyKey,
1621  lcid,
1622  flags,
1623  BufferLength,
1624  &propType,
1625  &requiredLength,
1626  PropertyBuffer);
1627 
1630  *ResultLength = requiredLength;
1631  *PropertyType = propType;
1632  }
1633  else if (hr == S_OK) {
1635  *ResultLength = requiredLength;
1636  *PropertyType = propType;
1637  }
1638  else {
1639  status = NtStatusFromHr(devStack, hr);
1642  "Query for unified property buffer failed, %!STATUS!",
1643  status);
1644  }
1645 
1646  return status;
1647 }
1648 
1650 NTSTATUS
1652  _In_ PFX_DRIVER_GLOBALS FxDriverGlobals,
1655  _In_opt_ MdDeviceObject RemotePdo,
1660  )
1661 {
1662  NTSTATUS status;
1663  IWudfDeviceStack* deviceStack;
1664 
1665  UNREFERENCED_PARAMETER(RemotePdo);
1666 
1667  status = FxDevice::_ValidateOpenKeyParams(FxDriverGlobals,
1668  DeviceInit,
1669  Device);
1670  if (!NT_SUCCESS(status)) {
1671  return status;
1672  }
1673 
1675 
1676  if (DeviceInit != NULL) {
1677  deviceStack = DeviceInit->DevStack;
1678  }
1679  else {
1680  deviceStack = Device->m_DevStack;
1681  }
1682 
1685  BufferLength,
1687  ResultLength);
1688  return status;
1689 }
1690 
1692 NTSTATUS
1694  _In_ PWDF_DEVICE_INTERFACE_PROPERTY_DATA PropertyData
1695  )
1696 {
1697  NTSTATUS status;
1699 
1700  if (PropertyData->Size != sizeof(WDF_DEVICE_INTERFACE_PROPERTY_DATA)) {
1703  "PropertyData size (%d) incorrect, expected %d, %!STATUS!",
1704  PropertyData->Size,
1705  sizeof(WDF_DEVICE_INTERFACE_PROPERTY_DATA), status);
1706  return status;
1707  }
1708 
1709  FxPointerNotNull(pFxDriverGlobals, PropertyData->InterfaceClassGUID);
1710 
1712  if (!NT_SUCCESS(status)) {
1714  return status;
1715  }
1716 
1717  if (PropertyData->ReferenceString != NULL) {
1719  PropertyData->ReferenceString);
1720  if (!NT_SUCCESS(status)) {
1722  return status;
1723  }
1724  }
1725 
1726  //
1727  // check if the interface has been registered with WDF
1728  //
1729  if (IsInterfaceRegistered(PropertyData->InterfaceClassGUID,
1730  PropertyData->ReferenceString) == FALSE) {
1734  "WDFDEVICE %p cannot assign interface property for an interface not"
1735  " yet registered with WDF, %!STATUS!",
1736  GetHandle(), status);
1737  return status;
1738  }
1739 
1740  return status;
1741 }
1742 
1743 VOID
1747  )
1748 {
1750 
1751  GetDeviceStack()->GetDeviceStackPreferredTransferMode(
1752  &retrievalMode,
1755  );
1756 }
1757 
1758 VOID
1760  _Out_ PCWSTR* GroupId,
1761  _Out_ PUMDF_DRIVER_REGSITRY_INFO DeviceRegInfo
1762  )
1763 {
1764  DWORD Err;
1765  DWORD Data;
1766  HKEY wudfKey = NULL;
1767  DWORD DataSize;
1768  DWORD type;
1769  PWSTR buffer;
1770  DWORD bufferSize;
1771 
1772  ASSERT(GroupId != NULL);
1773  ASSERT(DeviceRegInfo != NULL);
1774 
1775  ZeroMemory(DeviceRegInfo, sizeof(UMDF_DRIVER_REGSITRY_INFO));
1776  type = REG_NONE;
1777 
1778  if (m_PdoDevKey == NULL) {
1780  "Handle to hardware key not yet available");
1781  return;
1782  }
1783 
1784  Err = RegOpenKeyEx(m_PdoDevKey,
1785  WUDF_SUB_KEY,
1786  0,
1787  KEY_READ,
1788  &wudfKey);
1789  if (ERROR_SUCCESS != Err) {
1791  "Failed to open hw registry key to read hw access settings");
1792  goto clean0;
1793  }
1794 
1795  //
1796  // Read WDF_KERNEL_MODE_CLIENT_POLICY value
1797  //
1798  DataSize = sizeof(Data);
1799  Data = 0;
1800  Err = RegQueryValueEx(wudfKey,
1802  NULL,
1803  NULL,
1804  (BYTE*) &Data,
1805  &DataSize);
1806 
1807  if (ERROR_SUCCESS == Err) {
1808  if (((WDF_KERNEL_MODE_CLIENT_POLICY_TYPE)Data) == WdfAllowKernelModeClients) {
1809  DeviceRegInfo->IsKernelModeClientAllowed = TRUE;
1810  }
1811  }
1812  else if (ERROR_FILE_NOT_FOUND != Err) {
1814  "Failed to read kernel mode client policy value in registry");
1815  }
1816 
1817  //
1818  // Read WDF_FILE_OBJECT_POLICY value
1819  //
1820  DataSize = sizeof(Data);
1821  Data = 0;
1822  Err = RegQueryValueEx(wudfKey,
1824  NULL,
1825  NULL,
1826  (BYTE*) &Data,
1827  &DataSize);
1828  if (ERROR_SUCCESS == Err) {
1829  if (((WDF_FILE_OBJECT_POLICY_TYPE)Data) == WdfAllowNullAndUnknownFileObjects) {
1830  DeviceRegInfo->IsNullFileObjectAllowed = TRUE;
1831  }
1832  }
1833  else if (ERROR_FILE_NOT_FOUND != Err) {
1835  "Failed to read file object policy value in registry");
1836  }
1837 
1838  //
1839  // Read WDF_METHOD_NEITHER_ACTION value
1840  //
1841  DataSize = sizeof(Data);
1842  Data = 0;
1843  Err = RegQueryValueEx(wudfKey,
1845  NULL,
1846  NULL,
1847  (BYTE*) &Data,
1848  &DataSize);
1849  if (ERROR_SUCCESS == Err) {
1850  if (((WDF_METHOD_NEITHER_ACTION_TYPE)Data) == WdfMethodNeitherAction_Copy) {
1851  DeviceRegInfo->IsMethodNeitherActionCopy = TRUE;
1852  }
1853  }
1854  else if (ERROR_FILE_NOT_FOUND != Err) {
1856  "Failed to read method neither action value in registry");
1857  }
1858 
1859  //
1860  // Read WDF_PROCESS_SHARING_ENABLED value
1861  //
1862  DataSize = sizeof(Data);
1863  Data = 0;
1864  Err = RegQueryValueEx(wudfKey,
1866  NULL,
1867  NULL,
1868  (BYTE*) &Data,
1869  &DataSize);
1870  if (ERROR_SUCCESS == Err) {
1871  if (((WDF_PROCESS_SHARING_TYPE)Data) == WdfProcessSharingDisabled) {
1872  DeviceRegInfo->IsHostProcessSharingDisabled = TRUE;
1873  }
1874  }
1875  else if (ERROR_FILE_NOT_FOUND != Err) {
1877  "Failed to read method neither action value in registry");
1878  }
1879 
1880  //
1881  // Read Group ID
1882  //
1883  buffer = NULL;
1884  bufferSize = 0;
1885  *GroupId = NULL;
1886 
1887  Err = RegQueryValueEx(wudfKey,
1889  0,
1890  &type,
1891  (LPBYTE) buffer,
1892  &bufferSize);
1893  if (ERROR_MORE_DATA == Err) {
1894 
1895  buffer = new WCHAR[bufferSize/sizeof(buffer[0])];
1896  if (buffer == NULL) {
1899  "Failed to allocate memory for string buffer");
1900  }
1901  else {
1902 
1903  buffer[0] = L'\0';
1904  Err = RegQueryValueEx(wudfKey,
1906  0,
1907  &type,
1908  (LPBYTE) buffer,
1909  &bufferSize);
1910  if (Err == ERROR_SUCCESS) {
1911  if (type != REG_SZ) {
1913  }
1914  else {
1915  //
1916  // according to the string data returned by RegQueryValueEx()
1917  // is not always null terminated.
1918  //
1919  buffer[bufferSize/sizeof(buffer[0]) - 1] = L'\0';
1920  }
1921  }
1922 
1923  if (Err == ERROR_SUCCESS) {
1924  *GroupId = buffer;
1925  }
1926  else {
1927  delete [] buffer;
1928  buffer = NULL;
1929  }
1930  }
1931  }
1932  else if (ERROR_FILE_NOT_FOUND != Err) {
1934  "Failed to read Group id value in registry");
1935  }
1936 
1937 
1938 clean0:
1939 
1940  if (NULL != wudfKey) {
1941  RegCloseKey(wudfKey);
1942  }
1943 
1944  return;
1945 }
1946 
1948 NTSTATUS
1953  _In_ FxRegKey* pKey
1954  )
1955 {
1956 
1957  NTSTATUS status;
1958  HANDLE hKey = NULL;
1959 
1961  m_DevStack,
1962  KeyName->Buffer,
1964  DesiredAccess,
1965  &hKey);
1966  if (NT_SUCCESS(status)) {
1967  pKey->SetHandle(hKey);
1968  }
1969 
1970  return status;
1971 }
1972 
#define RegQueryValueEx
Definition: winreg.h:524
VOID DestructorInternal(VOID)
Definition: fxdevicekm.cpp:390
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
DEVICE_REGISTRY_PROPERTY
Definition: iotypes.h:1194
static VOID DispatchUm(_In_ MdDeviceObject DeviceObject, _In_ MdIrp Irp, _In_opt_ IUnknown *Context)
Definition: fxdeviceum.cpp:32
#define DO_POWER_PAGABLE
VOID RetrieveDeviceInfoRegistrySettings(_Out_ PCWSTR *GroupId, _Out_ PUMDF_DRIVER_REGSITRY_INFO DeviceRegInfo)
const uint16_t * PCWSTR
Definition: typedefs.h:57
VOID InvalidateDeviceState(VOID)
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
MxDeviceObject m_AttachedDevice
Definition: fxdevice.hpp:472
UMINT::WDF_DEVICE_IO_BUFFER_RETRIEVAL m_RetrievalMode
Definition: fxdevice.hpp:770
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2654
#define _Must_inspect_result_
Definition: no_sal2.h:62
static _Must_inspect_result_ NTSTATUS _ValidateOpenKeyParams(_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device)
Definition: fxdevice.cpp:2149
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define WDF_REGKEY_DRIVER_SUBKEY
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define FX_PLUGPLAY_REGKEY_DEVICEMAP
Definition: mxum.h:48
#define ERROR_SUCCESS
Definition: deptool.c:10
MdDeviceObject __inline GetDeviceObject(VOID)
Definition: fxdevice.hpp:174
VOID SetFlags(ULONG Flags)
HRESULT hr
Definition: shlfolder.c:183
_Must_inspect_result_ NTSTATUS Commit(__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out_opt WDFOBJECT *ObjectHandle, __in_opt FxObject *Parent=NULL, __in BOOLEAN AssignDriverAsDefaultParent=TRUE)
Definition: fxobject.cpp:904
#define FX_FILE_OBJECT_POLICY
Definition: fxdeviceum.hpp:48
__inline MxDeviceObject * GetMxDeviceObject(VOID)
Definition: fxdevice.hpp:183
_Must_inspect_result_ NTSTATUS ControlDeviceInitialize(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxdevicekm.cpp:399
#define PLUGPLAY_REGKEY_DEVICE
Definition: iofuncs.h:2782
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
uint16_t * PWSTR
Definition: typedefs.h:56
#define DO_POWER_INRUSH
static __inline NTSTATUS _OpenDeviceRegistryKey(_In_ MdDeviceObject DeviceObject, _In_ ULONG DevInstKeyType, _In_ ACCESS_MASK DesiredAccess, _Out_ PHANDLE DevInstRegKey)
_In_ ULONG DevInstKeyType
Definition: iofuncs.h:1123
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty
Definition: wdfdevice.h:3767
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG _In_opt_ PVOID Data
Definition: wdfdevice.h:4527
struct _root root
LONG NTSTATUS
Definition: precomp.h:26
#define FX_DEVICE_GROUP_ID
Definition: fxdeviceum.hpp:47
enum _WDF_DEVICE_IO_TYPE WDF_DEVICE_IO_TYPE
VOID InstallPackage(__inout FxPackage *Package)
Definition: fxdevice.cpp:1609
static FxDevice * GetFxDevice(__in MdDeviceObject DeviceObject)
Definition: fxdeviceum.cpp:60
static void PoFxDevicePowerNotRequired(_In_ MdDeviceObject DeviceObject)
Definition: fxdeviceum.cpp:817
_Must_inspect_result_ NTSTATUS PostCreateDeviceInitialize(__in PWDFDEVICE_INIT Init)
_Must_inspect_result_ NTSTATUS Initialize(__in PWDFDEVICE_INIT DeviceInit)
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
IWudfDeviceStack * m_DevStack
Definition: fxdevice.hpp:743
_Must_inspect_result_ NTSTATUS PostCreateDeviceInitialize(VOID)
Definition: fxpkgfdo.cpp:1522
#define ZeroMemory
Definition: winbase.h:1664
GLuint buffer
Definition: glext.h:5915
WDF_DEVICE_IO_TYPE m_IoctlIoType
Definition: fxdevice.hpp:771
IWudfDeviceStack * deviceStack
VOID SetDeviceBase(__in CfxDeviceBase *DeviceBase)
Definition: fxobject.hpp:797
UNICODE_STRING m_SymbolicLinkName
Definition: fxdevice.hpp:580
FxPowerPolicyMachine m_PowerPolicyMachine
Definition: fxpkgpnp.hpp:4153
virtual VOID SetDeviceTelemetryInfoFlags(_In_ FxDeviceInfoFlags Flag)
Definition: fxdevice.hpp:1807
DWORD LCID
Definition: nls.h:13
static VOID DispatchWithLockUm(_In_ MdDeviceObject DeviceObject, _In_ MdIrp Irp, _In_opt_ IUnknown *Context)
Definition: fxdeviceum.cpp:48
DriverGlobals
#define FX_FS_CONTEXT_USE_POLICY
Definition: fxdeviceum.hpp:41
_In_ WDFDEVICE _In_ PWDF_DEVICE_INTERFACE_PROPERTY_DATA PropertyData
ULONG * PDEVPROPTYPE
Definition: devpropdef.h:24
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
ULONG DEVPROPTYPE
Definition: devpropdef.h:24
#define WUDF_SUB_KEY
Definition: fxdeviceum.hpp:29
#define _In_opt_
Definition: no_sal2.h:212
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
VOID InvalidateDeviceState(__in MdDeviceObject Fdo)
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
DWORD Id
BOOLEAN m_CleanupFromFailedCreate
Definition: fxdevice.hpp:732
_Must_inspect_result_ NTSTATUS FxValidateInterfacePropertyData(_In_ PWDF_DEVICE_INTERFACE_PROPERTY_DATA PropertyData)
VOID GetDeviceStackIoType(_Out_ WDF_DEVICE_IO_TYPE *ReadWriteIoType, _Out_ WDF_DEVICE_IO_TYPE *IoControlIoType)
FxDevice * device
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
static VOID MxDetachDevice(_Inout_ MdDeviceObject Device)
Definition: mxgeneralkm.h:502
PWSTR m_DeviceInstanceId
Definition: fxdevice.hpp:763
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
static _Must_inspect_result_ NTSTATUS _QueryPropertyEx(_In_ PFX_DRIVER_GLOBALS DriverGlobals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device, _In_ PVOID PropertyData, _In_ FxPropertyType FxPropertyType, _In_ ULONG BufferLength, _Out_ PVOID PropertyBuffer, _Out_ PULONG ResultLength, _Out_ PDEVPROPTYPE PropertyType)
Definition: fxdevicekm.cpp:859
return STATUS_NOT_IMPLEMENTED
VOID DetachDevice(VOID)
virtual VOID RemoveDmaEnabler(__inout FxDmaEnabler *Enabler)
Definition: fxdevicekm.cpp:475
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define StringCchPrintf
Definition: strsafe.h:517
#define TODO
Definition: SAX2.c:49
#define FALSE
Definition: types.h:117
_In_ const DEVPROPKEY * PropertyKey
Definition: wdfdevice.h:1912
_In_ PIRP Irp
Definition: csq.h:116
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
HKEY m_PdoDevKey
Definition: fxdevice.hpp:748
if SUCCEEDED(hr)
WDF_DEVICE_IO_TYPE m_ReadWriteIoType
Definition: fxdevice.hpp:514
static NTSTATUS _CreateAndInitialize(_In_ PFX_DRIVER_GLOBALS DriverGlobals, _In_ FxDevice *Device, _Out_ FxMessageDispatch **ppWudfDispatcher)
_Must_inspect_result_ NTSTATUS CreateDevice(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxdevice.cpp:964
#define __out
Definition: dbghelp.h:62
#define FX_REGISTER_ACCESS_MODE
Definition: fxdeviceum.hpp:35
BOOLEAN m_Filter
Definition: fxdevice.hpp:522
unsigned char BOOLEAN
static WUDF_INTERFACE_CONTEXT RemoteInterfaceArrival(_In_ IWudfDevice *DeviceObject, _In_ LPCGUID DeviceInterfaceGuid, _In_ PCWSTR SymbolicLink)
Definition: fxdeviceum.cpp:762
static _Must_inspect_result_ NTSTATUS _Create(__in PFX_DRIVER_GLOBALS pGlobals, __in CfxDevice *Device, __deref_out FxPkgFdo **PkgFdo)
Definition: fxpkgfdo.cpp:195
static NTSTATUS NtStatusFromHr(_In_ IWudfDeviceStack *DevStack, _In_ HRESULT Hr)
Definition: fxdeviceum.cpp:826
#define _Out_
Definition: no_sal2.h:160
VOID PowerPolicySetS0IdleState(__in BOOLEAN State)
Definition: fxpkgpnp.cpp:3710
_Must_inspect_result_ NTSTATUS OpenDevicemapKeyWorker(_In_ PFX_DRIVER_GLOBALS pFxDriverGlobals, _In_ PCUNICODE_STRING KeyName, _In_ ACCESS_MASK DesiredAccess, _In_ FxRegKey *pKey)
Definition: fxdevicekm.cpp:995
IWudfIrp * MdIrp
Definition: mxum.h:103
_Must_inspect_result_ NTSTATUS PdoInitialize(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxdevicekm.cpp:221
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK _In_opt_ PWDF_OBJECT_ATTRIBUTES KeyAttributes
Definition: wdfdevice.h:2654
BOOLEAN m_PdoKnown
Definition: fxdevice.hpp:599
VOID Destroy(VOID)
Definition: fxdevicekm.cpp:329
WDF_FILE_OBJECT_POLICY_TYPE m_FileObjectPolicy
Definition: fxdevice.hpp:788
#define _Out_opt_
Definition: no_sal2.h:214
_In_ WDFDEVICE _In_ PWDF_DEVICE_INTERFACE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG _Out_ PDEVPROPTYPE PropertyType
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158
IWudfDeviceStack * GetDeviceStack(VOID)
Definition: fxdeviceum.hpp:435
FxPowerPolicyOwnerSettings * m_Owner
#define TRACINGDEVICE
Definition: dbgtrace.h:58
FxPropertyType
Definition: fxdevice.hpp:85
PFX_DRIVER_GLOBALS pFxDriverGlobals
static void RemoteInterfaceRemoval(_In_ IWudfDevice *DeviceObject, _In_ WUDF_INTERFACE_CONTEXT RemoteInterfaceID)
Definition: fxdeviceum.cpp:778
WUDF_IO_REMOVE_LOCK IoRemoveLock
Definition: fxdevice.hpp:34
FX_VERIFY(INTERNAL, CHECK_NOT_NULL(LoaderInterface->pIWudfHost))
#define ASSERT(a)
Definition: mode.c:45
r parent
Definition: btrfs.c:2944
BOOLEAN IsInterfaceRegistered(_In_ const GUID *InterfaceClassGUID, _In_opt_ PCUNICODE_STRING RefString)
Definition: fxdevice.cpp:1924
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
LONG HRESULT
Definition: typedefs.h:79
enum _WDF_DEVICE_IO_BUFFER_RETRIEVAL WDF_DEVICE_IO_BUFFER_RETRIEVAL
Definition: mxum.h:117
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
#define DECLARE_CONST_UNICODE_STRING(_variablename, _string)
Definition: wdfcore.h:161
__inline CHAR GetStackSize(VOID)
Definition: fxdevice.hpp:1824
#define FX_METHOD_NEITHER_ACTION
Definition: fxdeviceum.hpp:45
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG DeviceInstanceKeyType
Definition: wdfdevice.h:2654
static BOOL TransportQueryId(_In_ IWudfDevice *DeviceObject, _In_ DWORD Id, _In_ PVOID DataBuffer, _In_ SIZE_T cbDataBufferSize)
Definition: fxdeviceum.cpp:790
Type
Definition: Type.h:6
nsrefcnt Release()
unsigned long DWORD
Definition: ntddk_ex.h:95
__inline FxPkgFdo * GetFdoPkg(VOID)
Definition: fxdevice.hpp:1236
struct _WDF_DEVICE_PROPERTY_DATA * PWDF_DEVICE_PROPERTY_DATA
_Must_inspect_result_ NTSTATUS FdoInitialize(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxdevicekm.cpp:33
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
_In_ WDFDEVICE _Out_ WDF_DEVICE_IO_TYPE _Out_ WDF_DEVICE_IO_TYPE * IoControlIoType
PWSTR m_KernelDeviceName
Definition: fxdevice.hpp:758
GLbitfield flags
Definition: glext.h:7161
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
PVOID __inline GetObjectHandleUnchecked(VOID)
Definition: fxobject.hpp:446
MxDeviceObject m_PhysicalDevice
Definition: fxdevice.hpp:473
_Must_inspect_result_ NTSTATUS FxDuplicateUnicodeString(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in const UNICODE_STRING *Source, __out PUNICODE_STRING Destination)
Definition: stringutil.cpp:180
static const WCHAR L[]
Definition: oid.c:1250
size_t bufferSize
_Must_inspect_result_ NTSTATUS FxValidateObjectAttributes(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
VOID SetDeviceExtension(PVOID Value)
static _Must_inspect_result_ NTSTATUS STDCALL DispatchWithLock(__in MdDeviceObject DeviceObject, __in MdIrp OriginalIrp)
Definition: fxdevice.cpp:1335
_Must_inspect_result_ NTSTATUS AssignProperty(_In_ PVOID PropertyData, _In_ FxPropertyType FxPropertyType, _In_ DEVPROPTYPE Type, _In_ ULONG BufferLength, _In_opt_ PVOID PropertyBuffer)
Definition: fxdevicekm.cpp:668
NTSTATUS CreateSymbolicLink(_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_ PCUNICODE_STRING SymbolicLinkName)
Definition: fxdevicekm.cpp:513
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:454
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define PLUGPLAY_REGKEY_DRIVER
Definition: usbd.c:42
_Must_inspect_result_ NTSTATUS OpenSettingsKey(__out HANDLE *Key, __in ACCESS_MASK DesiredAccess=STANDARD_RIGHTS_ALL)
Definition: fxdevicekm.cpp:818
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID PropertyBuffer
Definition: wdfdevice.h:4431
VOID MarkNoDeleteDDI(__in FxObjectLockState State=ObjectLock)
Definition: fxobject.hpp:1118
__inline VOID SetHandle(__in HANDLE Key)
Definition: fxregkey.hpp:94
BOOLEAN m_SelfIoTargetNeeded
Definition: fxdevice.hpp:611
_Must_inspect_result_ NTSTATUS __inline FxValidateUnicodeString(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PCUNICODE_STRING String)
#define __inout
Definition: dbghelp.h:50
#define err(...)
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4061
#define ERROR_MORE_DATA
Definition: dderror.h:13
PFX_DRIVER_GLOBALS pGlobals
unsigned char BYTE
Definition: xxhash.c:193
FxPkgGeneral * m_PkgGeneral
Definition: fxdevice.hpp:671
_In_ ULONG _In_ ACCESS_MASK _Out_ PHANDLE DevInstRegKey
Definition: iofuncs.h:1123
virtual _Must_inspect_result_ NTSTATUS Initialize(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxpkgfdokm.cpp:361
FxPkgPnp * m_PkgPnp
Definition: fxdevice.hpp:670
MdDeviceObject __inline GetSafePhysicalDevice(VOID)
Definition: fxdevice.hpp:1005
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
static VOID GetPreferredTransferMode(_In_ MdDeviceObject DeviceObject, _Out_ UMINT::WDF_DEVICE_IO_BUFFER_RETRIEVAL *RetrievalMode, _Out_ WDF_DEVICE_IO_TYPE *RWPreference, _Out_ WDF_DEVICE_IO_TYPE *IoctlPreference)
Definition: fxdeviceum.cpp:593
FxRegKey * pKey
_Must_inspect_result_ NTSTATUS SetFilter(__in BOOLEAN Value)
Definition: fxdevice.cpp:1849
#define _In_
Definition: no_sal2.h:158
static FxWdmDeviceExtension * _GetFxWdmExtension(__in MdDeviceObject DeviceObject)
Definition: fxdevicekm.hpp:30
VOID PowerPolicySetSxWakeState(__in BOOLEAN State)
Definition: fxpkgpnp.cpp:3720
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define TRACINGPNP
Definition: dbgtrace.h:67
__inline MdDeviceObject GetObject(VOID)
struct _GUID GUID
_Must_inspect_result_ NTSTATUS CreateDefaultDeviceList(__in PWDF_CHILD_LIST_CONFIG ListConfig, __in PWDF_OBJECT_ATTRIBUTES ListAttributes)
Definition: fxpkgfdo.cpp:816
#define S_OK
Definition: intsafe.h:51
#define RegOpenKeyEx
Definition: winreg.h:520
VOID DeleteSymbolicLink(VOID)
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
static __inline VOID MxInitializeRemoveLock(__in MdRemoveLock Lock, __in ULONG AllocateTag, __in ULONG MaxLockedMinutes, __in ULONG HighWatermark)
Definition: mxgeneralkm.h:256
ioTypeConfig ReadWriteIoType
BOOLEAN m_PowerPageableCapable
Definition: fxdevice.hpp:530
#define FX_DIRECT_HARDWARE_ACCESS
Definition: fxdeviceum.hpp:32
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:506
FxAutoRegKey hKey
PWSTR m_DeviceKeyPath
Definition: fxdevice.hpp:753
static void PoFxDevicePowerRequired(_In_ MdDeviceObject DeviceObject)
Definition: fxdeviceum.cpp:808
#define FX_PROCESS_SHARING_ENABLED
Definition: fxdeviceum.hpp:46
#define DEVICE_TYPE
Definition: guid.c:10
__inline VOID SetObject(__in_opt MdDeviceObject DeviceObject)
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
__inline VOID SetStackSize(_In_ CHAR Size)
Definition: fxdevice.hpp:1833
WDF_REGISTER_ACCESS_MODE_TYPE m_RegisterAccessMode
Definition: fxdevice.hpp:783
#define FX_KERNEL_MODE_CLIENT_POLICY
Definition: fxdeviceum.hpp:44
#define _Analysis_assume_
Definition: no_sal2.h:388
unsigned int * PULONG
Definition: retypes.h:1
#define NULL
Definition: types.h:112
virtual VOID AddDmaEnabler(__inout FxDmaEnabler *Enabler)
Definition: fxdevicekm.cpp:465
GLenum GLsizei dataSize
Definition: glext.h:11123
virtual VOID RemoveChildList(__inout FxChildList *List)
Definition: fxdevicekm.cpp:441
virtual VOID AddChildList(__inout FxChildList *List)
Definition: fxdevicekm.cpp:431
VOID DeleteFromFailedCreate(VOID)
Definition: fxobject.cpp:391
static _Must_inspect_result_ NTSTATUS _QueryProperty(_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device, _In_opt_ MdDeviceObject RemotePdo, _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty, _In_ ULONG BufferLength, _Out_opt_ PVOID PropertyBuffer, _Out_opt_ PULONG ResultLength)
Definition: fxdevicekm.cpp:939
FxInterruptThreadpool * m_InteruptThreadpool
Definition: fxdevice.hpp:798
static _Must_inspect_result_ NTSTATUS _OpenKey(_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device, _In_ ULONG DeviceInstanceKeyType, _In_ ACCESS_MASK DesiredAccess, _In_opt_ PWDF_OBJECT_ATTRIBUTES KeyAttributes, _Out_ WDFKEY *Key)
Definition: fxdevicekm.cpp:731
static __inline NTSTATUS _GetDeviceProperty(_In_ MdDeviceObject DeviceObject, _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty, _In_ ULONG BufferLength, _Out_opt_ PVOID PropertyBuffer, _Out_ PULONG ResultLength)
WDF_FS_CONTEXT_USE_POLICY_TYPE m_FsContextUsePolicy
Definition: fxdevice.hpp:793
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
ULONG m_DirectTransferThreshold
Definition: fxdevice.hpp:772
static _Must_inspect_result_ NTSTATUS STDCALL Dispatch(__in MdDeviceObject DeviceObject, __in MdIrp OriginalIrp)
Definition: fxdevice.cpp:1549
_In_ PWDFDEVICE_INIT DeviceInit
Definition: wdfcontrol.h:113
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG GetFlags(VOID)
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define REG_NONE
Definition: nt_native.h:1492
void exit(int exitcode)
Definition: _exit.c:33
#define WDF_REGKEY_DEVICE_SUBKEY
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
Definition: wdfpool.cpp:361
WDF_DIRECT_HARDWARE_ACCESS_TYPE m_DirectHardwareAccess
Definition: fxdevice.hpp:777
VOID RetrieveDeviceRegistrySettings(VOID)
Definition: fxdeviceum.cpp:851
#define __in
Definition: dbghelp.h:35
static SERVICE_STATUS status
Definition: service.c:31
WDFKEY keyHandle
UINT64 WUDF_INTERFACE_CONTEXT
Definition: mxum.h:111
virtual _Must_inspect_result_ NTSTATUS AllocateDmaEnablerList(VOID)
Definition: fxdevicekm.cpp:452
FxMessageDispatch * m_Dispatcher
Definition: fxdevice.hpp:738
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4751
NTSTATUS ProcessWmiPowerQueryOrSetData(_In_ RdWmiPowerAction Action, _Out_ BOOLEAN *QueryResult)
Definition: fxdeviceum.cpp:699
ULONG ACCESS_MASK
Definition: nt_native.h:40
MxDeviceObject m_DeviceObject
Definition: fxdevice.hpp:471
#define PLUGPLAY_REGKEY_CURRENT_HWPROFILE
Definition: iofuncs.h:2784
static const WCHAR SymbolicLink[]
Definition: interface.c:31
_Must_inspect_result_ NTSTATUS RegisterCallbacks(__in PWDF_FDO_EVENT_CALLBACKS DispatchTable)
Definition: fxpkgfdo.cpp:796
FxVerifierDbgBreakPoint(pFxDriverGlobals)
VOID SetFilterIoType(VOID)
Definition: fxdevice.cpp:1871
#define FxPointerNotNull(FxDriverGlobals, Ptr)
Definition: fxmacros.hpp:253
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING SymbolicLinkName
Definition: wdfdevice.h:3736
#define DO_NOTHING()
Definition: mxgeneral.h:32
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define REG_SZ
Definition: layer.c:22
Definition: ps.c:97