1 /* 2 * scsiwmi.h 3 * 4 * SCSI WMILIB interface. 5 * 6 * This file is part of the w32api package. 7 * 8 * Contributors: 9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net> 10 * 11 * THIS SOFTWARE IS NOT COPYRIGHTED 12 * 13 * This source code is offered for use in the public domain. You may 14 * use, modify or distribute it freely. 15 * 16 * This code is distributed in the hope that it will be useful but 17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 * DISCLAIMED. This includes but is not limited to warranties of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 * 21 */ 22 23 #pragma once 24 25 #ifndef _SCSIWMI_ 26 #define _SCSIWMI_ 27 28 #include "srb.h" 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 #pragma pack(push,4) 35 36 typedef struct _SCSIWMI_REQUEST_CONTEXT { 37 PVOID UserContext; 38 ULONG BufferSize; 39 PUCHAR Buffer; 40 UCHAR MinorFunction; 41 UCHAR ReturnStatus; 42 ULONG ReturnSize; 43 } SCSIWMI_REQUEST_CONTEXT, *PSCSIWMI_REQUEST_CONTEXT; 44 45 #ifdef _GUID_DEFINED 46 # warning _GUID_DEFINED is deprecated, use GUID_DEFINED instead 47 #endif 48 49 #if ! (defined _GUID_DEFINED || defined GUID_DEFINED) 50 #define GUID_DEFINED 51 typedef struct _GUID { 52 unsigned long Data1; 53 unsigned short Data2; 54 unsigned short Data3; 55 unsigned char Data4[8]; 56 } GUID; 57 #endif 58 59 typedef struct _SCSIWMIGUIDREGINFO { 60 LPCGUID Guid; 61 ULONG InstanceCount; 62 ULONG Flags; 63 } SCSIWMIGUIDREGINFO, *PSCSIWMIGUIDREGINFO; 64 65 typedef 66 _Must_inspect_result_ 67 UCHAR 68 (NTAPI *PSCSIWMI_QUERY_REGINFO)( 69 _In_ PVOID DeviceContext, 70 _In_ PSCSIWMI_REQUEST_CONTEXT RequestContext, 71 _Out_ PWCHAR *MofResourceName); 72 73 typedef 74 _Must_inspect_result_ 75 BOOLEAN 76 (NTAPI *PSCSIWMI_QUERY_DATABLOCK)( 77 _In_ PVOID Context, 78 _In_ PSCSIWMI_REQUEST_CONTEXT DispatchContext, 79 _In_ ULONG GuidIndex, 80 _In_ ULONG InstanceIndex, 81 _In_ ULONG InstanceCount, 82 _Inout_ PULONG InstanceLengthArray, 83 _In_ ULONG BufferAvail, 84 _Out_writes_bytes_(BufferAvail) PUCHAR Buffer); 85 86 typedef 87 _Must_inspect_result_ 88 BOOLEAN 89 (NTAPI *PSCSIWMI_SET_DATABLOCK)( 90 _In_ PVOID DeviceContext, 91 _In_ PSCSIWMI_REQUEST_CONTEXT RequestContext, 92 _In_ ULONG GuidIndex, 93 _In_ ULONG InstanceIndex, 94 _In_ ULONG BufferSize, 95 _In_reads_bytes_(BufferSize) PUCHAR Buffer); 96 97 typedef 98 _Must_inspect_result_ 99 BOOLEAN 100 (NTAPI *PSCSIWMI_SET_DATAITEM)( 101 _In_ PVOID DeviceContext, 102 _In_ PSCSIWMI_REQUEST_CONTEXT RequestContext, 103 _In_ ULONG GuidIndex, 104 _In_ ULONG InstanceIndex, 105 _In_ ULONG DataItemId, 106 _In_ ULONG BufferSize, 107 _In_reads_bytes_(BufferSize) PUCHAR Buffer); 108 109 typedef 110 _Must_inspect_result_ 111 BOOLEAN 112 (NTAPI *PSCSIWMI_EXECUTE_METHOD)( 113 _In_ PVOID DeviceContext, 114 _In_ PSCSIWMI_REQUEST_CONTEXT RequestContext, 115 _In_ ULONG GuidIndex, 116 _In_ ULONG InstanceIndex, 117 _In_ ULONG MethodId, 118 _In_ ULONG InBufferSize, 119 _In_ ULONG OutBufferSize, 120 _Inout_updates_bytes_to_(InBufferSize, OutBufferSize) PUCHAR Buffer); 121 122 typedef enum _SCSIWMI_ENABLE_DISABLE_CONTROL { 123 ScsiWmiEventControl, 124 ScsiWmiDataBlockControl 125 } SCSIWMI_ENABLE_DISABLE_CONTROL; 126 127 typedef 128 _Must_inspect_result_ 129 BOOLEAN 130 (NTAPI *PSCSIWMI_FUNCTION_CONTROL)( 131 _In_ PVOID DeviceContext, 132 _In_ PSCSIWMI_REQUEST_CONTEXT RequestContext, 133 _In_ ULONG GuidIndex, 134 _In_ SCSIWMI_ENABLE_DISABLE_CONTROL Function, 135 _In_ BOOLEAN Enable); 136 137 typedef struct _SCSIWMILIB_CONTEXT { 138 ULONG GuidCount; 139 PSCSIWMIGUIDREGINFO GuidList; 140 PSCSIWMI_QUERY_REGINFO QueryWmiRegInfo; 141 PSCSIWMI_QUERY_DATABLOCK QueryWmiDataBlock; 142 PSCSIWMI_SET_DATABLOCK SetWmiDataBlock; 143 PSCSIWMI_SET_DATAITEM SetWmiDataItem; 144 PSCSIWMI_EXECUTE_METHOD ExecuteWmiMethod; 145 PSCSIWMI_FUNCTION_CONTROL WmiFunctionControl; 146 } SCSI_WMILIB_CONTEXT, *PSCSI_WMILIB_CONTEXT; 147 148 _Must_inspect_result_ 149 SCSIPORT_API 150 BOOLEAN 151 NTAPI 152 ScsiPortWmiDispatchFunction( 153 _In_ PSCSI_WMILIB_CONTEXT WmiLibInfo, 154 _In_ UCHAR MinorFunction, 155 _In_ PVOID DeviceContext, 156 _In_ PSCSIWMI_REQUEST_CONTEXT RequestContext, 157 _In_ PVOID DataPath, 158 _In_ ULONG BufferSize, 159 _In_ PVOID Buffer); 160 161 #define ScsiPortWmiFireAdapterEvent( \ 162 HwDeviceExtension, \ 163 Guid, \ 164 InstanceIndex, \ 165 EventDataSize, \ 166 EventData) \ 167 ScsiPortWmiFireLogicalUnitEvent( \ 168 HwDeviceExtension, \ 169 0xff, \ 170 0, \ 171 0, \ 172 Guid, \ 173 InstanceIndex, \ 174 EventDataSize, \ 175 EventData) 176 177 /* 178 * ULONG 179 * ScsiPortWmiGetReturnSize( 180 * PSCSIWMI_REQUEST_CONTEXT RequestContext); 181 */ 182 #define ScsiPortWmiGetReturnSize(RequestContext) \ 183 ((RequestContext)->ReturnSize) 184 185 /* UCHAR 186 * ScsiPortWmiGetReturnStatus( 187 * PSCSIWMI_REQUEST_CONTEXT RequestContext); 188 */ 189 #define ScsiPortWmiGetReturnStatus(RequestContext) \ 190 ((RequestContext)->ReturnStatus) 191 192 SCSIPORT_API 193 VOID 194 NTAPI 195 ScsiPortWmiPostProcess( 196 _Inout_ PSCSIWMI_REQUEST_CONTEXT RequestContext, 197 _In_ UCHAR SrbStatus, 198 _In_ ULONG BufferUsed); 199 200 SCSIPORT_API 201 VOID 202 NTAPI 203 ScsiPortWmiFireLogicalUnitEvent( 204 _In_ PVOID HwDeviceExtension, 205 _In_ UCHAR PathId, 206 _In_ UCHAR TargetId, 207 _In_ UCHAR Lun, 208 _In_ LPGUID Guid, 209 _In_ ULONG InstanceIndex, 210 _In_ ULONG EventDataSize, 211 _In_ PVOID EventData); 212 213 #pragma pack(pop) 214 215 #ifdef __cplusplus 216 } 217 #endif 218 219 #endif /* _SCSIWMI_ */ 220