841{
847 ULONG instanceCount, dataBlockOffset, lengthArraySize,
i, sizeRemaining,
848 lastAdjustment, bufferUsed, tempOffset;
851
853
855
858
859 lastAdjustment = 0;
861 dataBlockOffset = 0;
862
863
864
865
866
867 bufferUsed = 0;
868
870
873 goto Done;
874 }
875
876
877
878
879
880
881
882
883
884
886 instanceCount =
Provider->m_NumInstances;
888
889
890
891
892
893
894
895
896
897
898
899 if (instanceCount == 0) {
903 "Failing QueryAllData since no instances found for "
904 "WDFWMIPROVIDER %p, %!STATUS!",
906 bufferUsed = 0;
907 goto Done;
908 }
909
912 "WDFWMIPROVIDER %p QueryAllData, num instances %d",
913 Provider->GetHandle(), instanceCount);
914
916
917
918
919
920
921
922 pNodeData->
WnodeHeader.Flags &= ~WNODE_FLAG_FIXED_INSTANCE_SIZE;
923
924
925
926
927
928
929 status = RtlULongMult(instanceCount,
931 &lengthArraySize);
932
934
935
938 lengthArraySize,
939 &tempOffset);
940
944
945 if (dataBlockOffset < tempOffset) {
947 }
948 }
949 }
950
954 "Failing QueryAllData since integer overflow occured using"
955 " provider instance count %d for WDFWMIPROVIDER %p, %!STATUS!",
957 bufferUsed = 0;
958 goto Done;
959 }
960
962
963 if (dataBlockOffset <= stack->
Parameters.WMI.BufferSize) {
965 sizeRemaining =
stack->Parameters.WMI.BufferSize - dataBlockOffset;
967 }
968 else {
969
970
971
972
973
976 sizeRemaining = 0;
977
978
979
980
983 }
984
985 if (instanceCount > 0 &&
Provider->GetMinInstanceBufferSize() != 0) {
987
989
991 Provider->GetMinInstanceBufferSize(),
993 );
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013 status = RtlULongMult(minSizeAdjusted, instanceCount - 1, &
size);
1015 goto Done;
1016 }
1017
1020 goto Done;
1021 }
1022
1023
1024
1025
1026
1027
1028
1029
1030 if (sizeRemaining <
size) {
1031
1032
1033
1034
1037 goto Done;
1038 }
1039 }
1040
1041 for (
i = 0;
i < instanceCount;
i++) {
1043
1044
1045
1046
1047
1049
1051
1053 break;
1054 }
1055
1058
1059 tmpSize = 0;
1060
1062
1065
1066
1067
1068
1069
1070
1073 );
1074
1075 if (adjustedSize < tmpSize) {
1076
1077
1078
1079
1083 "WDFWMIINSTNACE %p queried, returned a buffer size of %d,"
1084 "but it could not be rounded up, %!STATUS!",
1086 goto QueryError;
1087 }
1088
1089
1090
1091
1092
1093
1094 lastAdjustment = adjustedSize - tmpSize;
1095
1096
1097
1098
1099
1101
1102
1103
1106
1107 pData += adjustedSize;
1108 }
1109 else {
1111 }
1112
1113
1114
1115
1116 if (adjustedSize <= sizeRemaining) {
1117 sizeRemaining -= adjustedSize;
1118
1119
1120
1121
1122 addStatus = RtlULongAdd(dataBlockOffset,
1123 adjustedSize,
1124 &dataBlockOffset);
1125 }
1126 else {
1127
1128
1129
1130 addStatus = RtlULongAdd(dataBlockOffset,
1131 sizeRemaining,
1132 &dataBlockOffset);
1133 sizeRemaining = 0;
1134 }
1135
1140 "WDFWMIPROVIDER %p, arithmetic overflow in computing "
1141 "block offset, %!STATUS!",
Provider->GetHandle(),
1143 goto QueryError;
1144 }
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154 addStatus = RtlULongAdd(bufferUsed, adjustedSize, &bufferUsed);
1155
1160 "WDFWMIPROVIDER %p, arithmetic overflow in computing "
1161 "buffer consumed(%d+%d), %!STATUS!",
1163 goto QueryError;
1164 }
1165 }
1166 }
1167 else if (pOffsets !=
NULL) {
1168
1169
1170
1171
1172
1175 }
1176
1177QueryError:
1179
1180
1181
1182
1183
1185 break;
1186 }
1187 }
1188
1189
1190
1191
1192
1193
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205 bufferUsed -=lastAdjustment;
1206
1208
1211 "WDFWMIPROVIDER %p QueryAllData returning %!STATUS!, requesting "
1212 "buffer size of 0x%x",
Provider->GetHandle(),
status, bufferUsed);
1213 }
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1227 bufferUsed = dataBlockOffset - pNodeData->
DataBlockOffset - lastAdjustment;
1228 }
1229 else {
1232 "WDFWMIPROVIDER %p QueryAllData returning %!STATUS!",
1234
1235 bufferUsed = 0;
1236 }
1237
1240 "WDFWMIPROVIDER %p QueryAllData returning %!STATUS!, buffer used 0x%x",
1242
1243Done:
1245
1247}
virtual BOOLEAN IsQueryInstanceSupported(VOID)
WDFWMIINSTANCE GetHandle(VOID)
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
FxWmiInstanceExternal * pInstance
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define MEMORY_ALLOCATION_ALIGNMENT
#define STATUS_WMI_INSTANCE_NOT_FOUND
#define STATUS_INTEGER_OVERFLOW
#define TRACE_LEVEL_VERBOSE
#define TRACE_LEVEL_ERROR
#define TRACE_LEVEL_INFORMATION
OFFSETINSTANCEDATAANDLENGTH OffsetInstanceDataAndLength[0]
struct _WNODE_HEADER WnodeHeader
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
#define FIELD_OFFSET(t, f)
FORCEINLINE size_t WDF_ALIGN_SIZE_UP(_In_ size_t Length, _In_ size_t AlignTo)
struct tagWNODE_ALL_DATA * PWNODE_ALL_DATA