Commit graph

10 commits

Author SHA1 Message Date
George Bișoc
b0680d65fe
[BATTC] Signal the wait battery tag event when notifying Battery Class
BatteryClassStatusNotify is used by battery miniport drivers to notify the Battery Class of a status change. This can either be a battery status change or battery tag assignation, depending on what the device extension (namely the composite battery) waits for.

We do have implementation for EVENT_BATTERY_STATUS but not for EVENT_BATTERY_TAG. What happens is when BatteryClassIoctl fails to query the battery tag because it has not yet been assigned, the thread is stuck on waiting for the event object to be signaled, forever.
This tipically happens when a timeout of -1 (meaning the calling thread must wait indefinitely) is supplied. The composite battery driver (COMPBATT) is responsible to signal the Battery Class when a CM (Control Method) ACPI battery receives a tag, which then this function will signal the event.

CORE-18969
CORE-19452
2024-12-17 14:23:33 +01:00
George Bișoc
2416c31a30
[BATTC] Fix the wait timeout conversion
KeWaitForSingleObject takes 100ns unit for timeout. Both IOCTL_BATTERY_QUERY_TAG and IOCTL_BATTERY_QUERY_STATUS take a wait for the timeout in milliseconds.
Supposedly a miniport driver wants to supply a wait of 5000 ms (which is equivalent to 5 s), the miniport driver WON'T BE WAITING 5 seconds but 0.5!!!

CORE-18969
CORE-19452
2024-12-16 17:24:56 +01:00
Hervé Poussineau
997b1797f4 [BATTC] Fix comparisons when choosing to complete the status IRP
They were reversed, which meant to immediately complete the IRP
if conditions were NOT satisfied.

Remove a now useless/invalid call to QueryStatus, to return the
status which lead to IRP completion.
2024-11-16 23:33:41 +01:00
Hervé Poussineau
8612d6c0aa [BATTC] Copy BATTERY_WAIT_STATUS structure to prevent memory overwrite.
At first QueryStatus call, output is written to Irp->AssociatedIrp.SystemBuffer.
Unfortunately, this is also the BattWait buffer.

At return of QueryStatus call, BattWait buffer has been modified, so
following code can't use it anymore.

Fix memory overwrite by copying BattWait buffer on the stack.
2024-08-12 11:56:18 +02:00
Hervé Poussineau
6b5ee5ccc7 [BATTC] Make input buffer on IOCTL_BATTERY_QUERY_TAG optional
In that case, don't wait to get battery tag.
2024-02-01 10:08:51 +01:00
Jérôme Gardou
23373acbb9 [CMAKE] Use modules instead of shared libraries
There is no need to compile our DLLs as shared libraries since we are
managing symbols exports and imports through spec files.

On my system, this reduces the configure-time by a factor of two.
2019-04-06 17:43:38 +02:00
Eric Kohl
34b0516ec4 [BATTC] Fixed an oops! 2019-01-01 13:48:43 +01:00
Eric Kohl
397fa2844e [BATTC] Some tiny fixes
- Add missing parameter to a DPRINT.
- Print pointers using %p instead of %x.
- Move all executable code behind a functions initial DPRINT.
- Do not use non-trivial initializers.
- Check for NULL instead of using !.
- Add missing parentheses.
2019-01-01 13:20:41 +01:00
Eric Kohl
04524fef3b [BATTC] Fix indentation. No code changes! 2019-01-01 13:20:39 +01:00
Colin Finck
c2c66aff7d Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00