@@ -112,9 +112,9 @@ BatteryClassStatusNotify(PVOID ClassData)
112112
113113 ExAcquireFastMutex (& BattClass -> Mutex );
114114
115- if (!( BattWait -> PowerState & BattStatus .PowerState ) ||
116- ( BattWait -> HighCapacity > BattStatus .Capacity ) ||
117- ( BattWait -> LowCapacity < BattStatus .Capacity ) )
115+ if (BattWait -> PowerState != BattStatus .PowerState ||
116+ BattWait -> HighCapacity < BattStatus .Capacity ||
117+ BattWait -> LowCapacity > BattStatus .Capacity )
118118 {
119119 KeSetEvent (& BattClass -> WaitEvent , IO_NO_INCREMENT , FALSE);
120120 }
@@ -274,16 +274,15 @@ BatteryClassIoctl(PVOID ClassData,
274274
275275 Timeout .QuadPart = Int32x32To64 (BattWait .Timeout , -1000 );
276276
277+ BattStatus = Irp -> AssociatedIrp .SystemBuffer ;
277278 Status = BattClass -> MiniportInfo .QueryStatus (BattClass -> MiniportInfo .Context ,
278279 BattWait .BatteryTag ,
279- (PBATTERY_STATUS )Irp -> AssociatedIrp .SystemBuffer );
280-
281- BattStatus = Irp -> AssociatedIrp .SystemBuffer ;
280+ BattStatus );
282281
283282 if (!NT_SUCCESS (Status ) ||
284- (( BattWait .PowerState & BattStatus -> PowerState ) &&
285- ( BattWait .HighCapacity < = BattStatus -> Capacity ) &&
286- ( BattWait .LowCapacity > = BattStatus -> Capacity ) ))
283+ (BattWait .PowerState == BattStatus -> PowerState &&
284+ BattWait .HighCapacity > = BattStatus -> Capacity &&
285+ BattWait .LowCapacity < = BattStatus -> Capacity ))
287286 {
288287 BattNotify .PowerState = BattWait .PowerState ;
289288 BattNotify .HighCapacity = BattWait .HighCapacity ;
@@ -304,25 +303,14 @@ BatteryClassIoctl(PVOID ClassData,
304303 KernelMode ,
305304 FALSE,
306305 BattWait .Timeout != -1 ? & Timeout : NULL );
306+ if (Status == STATUS_TIMEOUT )
307+ Status = STATUS_SUCCESS ;
307308
308309 ExAcquireFastMutex (& BattClass -> Mutex );
309310 BattClass -> Waiting = FALSE;
310311 ExReleaseFastMutex (& BattClass -> Mutex );
311312
312313 BattClass -> MiniportInfo .DisableStatusNotify (BattClass -> MiniportInfo .Context );
313-
314- if (Status == STATUS_SUCCESS )
315- {
316- Status = BattClass -> MiniportInfo .QueryStatus (BattClass -> MiniportInfo .Context ,
317- BattWait .BatteryTag ,
318- (PBATTERY_STATUS )Irp -> AssociatedIrp .SystemBuffer );
319- if (NT_SUCCESS (Status ))
320- Irp -> IoStatus .Information = sizeof (ULONG );
321- }
322- else
323- {
324- Status = STATUS_NO_SUCH_DEVICE ;
325- }
326314 }
327315 else
328316 {
0 commit comments