1038{
1041 ULONG QueryLength = 0;
1042 ULONG RemainingTime = 0;
1045 WCHAR InfoBuffer[256];
1046 WCHAR TempBuffer[256];
1048 ULONG RemainingCapacity;
1053 DbgPrint(
"CmBattQueryInformation - Tag (%d) Device %d, Informationlevel %d\n",
1056 InfoLevel);
1057
1058
1061
1062
1063 switch (InfoLevel)
1064 {
1066
1069 break;
1070
1072
1073
1078 QueryData = BatteryReportingScale;
1080 break;
1081
1083
1084
1086 {
1087
1089
1090
1093
1094
1096
1097
1099
1100
1103 {
1104
1107 DbgPrint(
"CmBattQueryInformation: Can't calculate EstimatedTime.\n");
1108
1109
1112 {
1113
1116 DbgPrint(
"---------------------- PresentRate = BATTERY_UNKNOWN_RATE\n");
1117 }
1118
1119
1121 {
1122
1125 DbgPrint(
"---------------------- RemainingCapacity = BATTERY_UNKNOWN_CAPACITY\n");
1126 }
1127 }
1128 else
1129 {
1130
1131 if (RemainingCapacity > 0x123456)
1132 {
1133
1135 DbgPrint(
"CmBattQueryInformation: Data Overflow in calculating Remaining Capacity.\n");
1136 }
1137 else
1138 {
1139
1140 RemainingTime = (RemainingCapacity * 3600) / -Rate;
1141 }
1142 }
1143 }
1144
1145
1146 QueryData = &RemainingTime;
1147 QueryLength =
sizeof(
ULONG);
1148 break;
1149
1151
1152
1154
1155
1156 InfoString.
Buffer = InfoBuffer;
1159
1160
1161 QueryData = InfoString.
Buffer;
1162 QueryLength = InfoString.
Length;
1163 break;
1164
1167
1168
1170 break;
1171
1173
1174
1176
1177
1178 InfoString.
Buffer = InfoBuffer;
1181
1182
1183 QueryData = InfoString.
Buffer;
1184 QueryLength = InfoString.
Length;
1185 break;
1186
1188
1189
1191
1192
1193 InfoString.
Buffer = InfoBuffer;
1196
1197
1198 TempString2.
Buffer = TempBuffer;
1200
1201
1203 {
1204
1206
1207
1210 }
1211
1212
1214
1215
1218
1219
1220 QueryData = InfoString.
Buffer;
1221 QueryLength = InfoString.
Length;
1222 break;
1223
1224 default:
1225
1226
1228 break;
1229 }
1230
1231
1234
1235
1237
1238
1240}
_In_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL _In_ LONG _In_ ULONG _Out_ PULONG ReturnedLength
_In_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL _In_ LONG AtRate
struct _BATTERY_INFORMATION BATTERY_INFORMATION
@ BatteryGranularityInformation
#define BATTERY_UNKNOWN_RATE
NTSTATUS NTAPI CmBattGetBatteryStatus(IN PCMBATT_DEVICE_EXTENSION DeviceExtension, IN ULONG Tag)
NTSTATUS NTAPI CmBattVerifyStaticInfo(PCMBATT_DEVICE_EXTENSION DeviceExtension, ULONG BatteryTag)
#define CMBATT_GENERIC_INFO
#define ACPI_BATT_STAT_DISCHARG
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
#define KeQueryInterruptTime()
#define STATUS_BUFFER_TOO_SMALL
#define RtlCopyMemory(Destination, Source, Length)
#define STATUS_INVALID_DEVICE_REQUEST
#define STATUS_INVALID_PARAMETER
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength