ReactOS 0.4.16-dev-2633-g8dc9e50
wmi.c File Reference
#include "atapi.h"
Include dependency graph for wmi.c:

Go to the source code of this file.

Functions

static NTSTATUS NTAPI AtaQueryWmiRegInfo (_Inout_ PDEVICE_OBJECT DeviceObject, _Inout_ PULONG RegFlags, _Inout_ PUNICODE_STRING InstanceName, _Outptr_result_maybenull_ PUNICODE_STRING *RegistryPath, _Inout_ PUNICODE_STRING MofResourceName, _Outptr_result_maybenull_ PDEVICE_OBJECT *Pdo)
 
static NTSTATUS NTAPI AtaQueryWmiDataBlock (_Inout_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _In_ ULONG GuidIndex, _In_ ULONG InstanceIndex, _In_ ULONG InstanceCount, _Out_writes_opt_(InstanceCount) PULONG InstanceLengthArray, _In_ ULONG BufferAvail, _Out_writes_bytes_opt_(BufferAvail) PUCHAR Buffer)
 
static NTSTATUS AtaPdoWmi (_In_ PATAPORT_DEVICE_EXTENSION DevExt, _Inout_ PIRP Irp)
 
static NTSTATUS AtaFdoWmi (_In_ PATAPORT_CHANNEL_EXTENSION ChanExt, _Inout_ PIRP Irp)
 
NTSTATUS NTAPI AtaDispatchWmi (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
 
NTSTATUS AtaPdoWmiRegistration (_In_ PATAPORT_DEVICE_EXTENSION DevExt, _In_ BOOLEAN Register)
 

Variables

static WMIGUIDREGINFO AtapWmiGuidList []
 

Function Documentation

◆ AtaDispatchWmi()

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

Definition at line 175 of file wmi.c.

178{
179 PAGED_CODE();
180
181 if (IS_FDO(DeviceObject->DeviceExtension))
182 return AtaFdoWmi(DeviceObject->DeviceExtension, Irp);
183 else
184 return AtaPdoWmi(DeviceObject->DeviceExtension, Irp);
185}
#define PAGED_CODE()
#define IS_FDO(p)
Definition: atapi.h:173
_In_ PIRP Irp
Definition: csq.h:116
static NTSTATUS AtaFdoWmi(_In_ PATAPORT_CHANNEL_EXTENSION ChanExt, _Inout_ PIRP Irp)
Definition: wmi.c:162
static NTSTATUS AtaPdoWmi(_In_ PATAPORT_DEVICE_EXTENSION DevExt, _Inout_ PIRP Irp)
Definition: wmi.c:110
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061

Referenced by DriverEntry().

◆ AtaFdoWmi()

static NTSTATUS AtaFdoWmi ( _In_ PATAPORT_CHANNEL_EXTENSION  ChanExt,
_Inout_ PIRP  Irp 
)
static

Definition at line 162 of file wmi.c.

165{
166 PAGED_CODE();
167
169 return IoCallDriver(ChanExt->Common.LowerDeviceObject, Irp);
170}
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IoCallDriver
Definition: irp.c:1225

Referenced by AtaDispatchWmi().

◆ AtaPdoWmi()

static NTSTATUS AtaPdoWmi ( _In_ PATAPORT_DEVICE_EXTENSION  DevExt,
_Inout_ PIRP  Irp 
)
static

Definition at line 110 of file wmi.c.

113{
116
117 PAGED_CODE();
118
119 TRACE("%s(%p, %p)\n", __FUNCTION__, DevExt, Irp);
120
121 Status = IoAcquireRemoveLock(&DevExt->Common.RemoveLock, Irp);
122 if (!NT_SUCCESS(Status))
123 {
124 Irp->IoStatus.Status = Status;
126
127 return Status;
128 }
129
130 Status = WmiSystemControl(&DevExt->WmiLibInfo,
131 DevExt->Common.Self,
132 Irp,
133 &Disposition);
134 switch (Disposition)
135 {
136 case IrpProcessed:
137 break;
138
139 case IrpNotCompleted:
141 break;
142
143 default:
144 ASSERT(FALSE);
146 case IrpForward:
147 case IrpNotWmi:
149 Irp->IoStatus.Status = Status;
151 break;
152 }
153
154 IoReleaseRemoveLock(&DevExt->Common.RemoveLock, Irp);
155
156 return Status;
157}
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define __FUNCTION__
Definition: types.h:116
Status
Definition: gdiplustypes.h:25
#define ASSERT(a)
Definition: mode.c:44
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:56
#define IoCompleteRequest
Definition: irp.c:1240
#define __fallthrough
Definition: sal_old.h:314
#define TRACE(s)
Definition: solgame.cpp:4
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 IoAcquireRemoveLock(RemoveLock, Tag)
#define IoReleaseRemoveLock(_RemoveLock, _Tag)
Definition: iofuncs.h:2764
#define IO_NO_INCREMENT
Definition: iotypes.h:598

Referenced by AtaDispatchWmi().

◆ AtaPdoWmiRegistration()

NTSTATUS AtaPdoWmiRegistration ( _In_ PATAPORT_DEVICE_EXTENSION  DevExt,
_In_ BOOLEAN  Register 
)

Definition at line 189 of file wmi.c.

192{
194
195 PAGED_CODE();
196
197 if (Register)
198 {
199 DevExt->WmiLibInfo.GuidCount = RTL_NUMBER_OF(AtapWmiGuidList);
200 DevExt->WmiLibInfo.GuidList = AtapWmiGuidList;
201
202 DevExt->WmiLibInfo.QueryWmiRegInfo = AtaQueryWmiRegInfo;
203 DevExt->WmiLibInfo.QueryWmiDataBlock = AtaQueryWmiDataBlock;
204
206 }
207 else
208 {
210 }
211
212 return IoWMIRegistrationControl(DevExt->Common.Self, Action);
213}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
static WMIGUIDREGINFO AtapWmiGuidList[]
Definition: wmi.c:14
static NTSTATUS NTAPI AtaQueryWmiRegInfo(_Inout_ PDEVICE_OBJECT DeviceObject, _Inout_ PULONG RegFlags, _Inout_ PUNICODE_STRING InstanceName, _Outptr_result_maybenull_ PUNICODE_STRING *RegistryPath, _Inout_ PUNICODE_STRING MofResourceName, _Outptr_result_maybenull_ PDEVICE_OBJECT *Pdo)
Definition: wmi.c:25
static NTSTATUS NTAPI AtaQueryWmiDataBlock(_Inout_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _In_ ULONG GuidIndex, _In_ ULONG InstanceIndex, _In_ ULONG InstanceCount, _Out_writes_opt_(InstanceCount) PULONG InstanceLengthArray, _In_ ULONG BufferAvail, _Out_writes_bytes_opt_(BufferAvail) PUCHAR Buffer)
Definition: wmi.c:51
NTSTATUS NTAPI IoWMIRegistrationControl(IN PDEVICE_OBJECT DeviceObject, IN ULONG Action)
Definition: wmi.c:68
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510
#define WMIREG_ACTION_REGISTER
#define WMIREG_ACTION_DEREGISTER

Referenced by AtaPdoRemoveDevice(), and AtaPdoStartDevice().

◆ AtaQueryWmiDataBlock()

static NTSTATUS NTAPI AtaQueryWmiDataBlock ( _Inout_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp,
_In_ ULONG  GuidIndex,
_In_ ULONG  InstanceIndex,
_In_ ULONG  InstanceCount,
_Out_writes_opt_(InstanceCount) PULONG  InstanceLengthArray,
_In_ ULONG  BufferAvail,
_Out_writes_bytes_opt_(BufferAvail) PUCHAR  Buffer 
)
static

Definition at line 51 of file wmi.c.

60{
63 ATA_SCSI_ADDRESS AtaScsiAddress;
65
66 PAGED_CODE();
67
69 {
71 goto Complete;
72 }
73
74 /* Only ever register 1 instance per GUID */
75 if (InstanceIndex != 0 || InstanceCount != 1)
76 {
78 goto Complete;
79 }
80
81 if (!InstanceLengthArray || BufferAvail < sizeof(*DeviceInfo))
82 {
84 goto Complete;
85 }
86
87 DevExt = DeviceObject->DeviceExtension;
88 AtaScsiAddress = DevExt->Device.AtaScsiAddress;
89
91 DeviceInfo->Bus = AtaScsiAddress.PathId;
92 DeviceInfo->Target = AtaScsiAddress.TargetId;
93 DeviceInfo->Lun = AtaScsiAddress.Lun;
94
95 *InstanceLengthArray = sizeof(*DeviceInfo);
96
98
101 Irp,
102 Status,
103 sizeof(*DeviceInfo),
105}
Definition: bufpool.h:45
_In_ LPGUID _In_ ULONG InstanceIndex
Definition: classpnp.h:1251
_In_ PIRP _In_ ULONG GuidIndex
Definition: classpnp.h:419
_In_ PIRP _In_ ULONG _In_ ULONG BufferAvail
Definition: classpnp.h:420
pRequest Complete(RequestStatus)
#define STATUS_WMI_INSTANCE_NOT_FOUND
Definition: ntstatus.h:902
#define STATUS_WMI_GUID_NOT_FOUND
Definition: ntstatus.h:901
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
ATAPORT_IO_CONTEXT Device
Definition: atapi.h:457
ATA_SCSI_ADDRESS AtaScsiAddress
Definition: atapi.h:100
UCHAR PathId
Definition: atapi.h:65
UCHAR TargetId
Definition: atapi.h:60
struct _MSIde_PortDeviceInfo * PMSIde_PortDeviceInfo
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

Referenced by AtaPdoWmiRegistration().

◆ AtaQueryWmiRegInfo()

static NTSTATUS NTAPI AtaQueryWmiRegInfo ( _Inout_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PULONG  RegFlags,
_Inout_ PUNICODE_STRING  InstanceName,
_Outptr_result_maybenull_ PUNICODE_STRING RegistryPath,
_Inout_ PUNICODE_STRING  MofResourceName,
_Outptr_result_maybenull_ PDEVICE_OBJECT Pdo 
)
static

Definition at line 25 of file wmi.c.

32{
33 PATAPORT_DEVICE_EXTENSION DevExt = DeviceObject->DeviceExtension;
34
37
38 PAGED_CODE();
39
42 *Pdo = DevExt->Common.Self;
43
44 return STATUS_SUCCESS;
45}
UNICODE_STRING AtapDriverRegistryPath
Definition: atapi.c:14
_Out_ ULONG * RegFlags
Definition: classpnp.h:403
_Must_inspect_result_ _Inout_ PFLT_VOLUME _In_opt_ PCUNICODE_STRING InstanceName
Definition: fltkernel.h:1163
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
PDEVICE_OBJECT Self
Definition: atapi.h:432
ATAPORT_COMMON_EXTENSION Common
Definition: atapi.h:455
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING MofResourceName
Definition: wdfdevice.h:2470
_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 AtaPdoWmiRegistration().

Variable Documentation

◆ AtapWmiGuidList

WMIGUIDREGINFO AtapWmiGuidList[]
static
Initial value:
=
{
{&MSIde_PortDeviceInfo_GUID, 1, 0}
}

Definition at line 14 of file wmi.c.

Referenced by AtaPdoWmiRegistration(), and AtaQueryWmiDataBlock().