Commit graph

1251 commits

Author SHA1 Message Date
Hermès Bélusca-Maïto
c306a27941
[MOUNTMGR] Fix the buffer returned by IOCTL_MOUNTMGR_QUERY_DOS_VOLUME_PATH (#6990)
The buffer returned by MountMgrQueryDosVolumePath()
should be a multi-string containing one single string.
2025-01-21 19:16:01 +01:00
Hermès Bélusca-Maïto
8bb7cd286b
[MOUNTMGR] Fix three more bugs in MountMgrQueryDosVolumePath() (#6990)
- When trying to find a device, don't fail with STATUS_NOT_FOUND if no
  associated symbolic links are present. Instead, that test was wrong,
  and should go out of the search loop to do the drive-letter processing.

  Addendum to commit f9f5a78715.

- In addition, when using the associated-device method, fix the list
  used to retrieve the corresponding device.

- In the TryWithVolumeName: block, reset DeviceString to NULL after
  freeing, so that we can correctly fail with STATUS_NOT_FOUND if no
  suitable device was found, before initializing the output data.
2025-01-21 19:16:01 +01:00
Hermès Bélusca-Maïto
28c3533d11
[MOUNTMGR] Simplify a bit the code in MountMgrQueryDosVolumePath(s) (#6990) 2025-01-21 19:16:00 +01:00
Hermès Bélusca-Maïto
e72a9a78b0
[MOUNTMGR] Fix some other bugs (#6990)
- Use FIELD_OFFSET to correct structure and member instead of hardcoding
  sizeof-s of fields until the member of interest.

- Fix a bug in MountMgrQueryDosVolumePath() where the FIELD_OFFSET used
  in the entry structure size validation was incorrect.

  FIELD_OFFSET(MOUNTMGR_TARGET_NAME, DeviceNameLength) is == 0 since
  DeviceNameLength is the first member of the MOUNTMGR_TARGET_NAME
  structure. The intended member was DeviceName.

  Addendum to commit f9f5a78715.
2025-01-21 19:15:59 +01:00
Hermès Bélusca-Maïto
be97a36f25
[MOUNTMGR] Simplify MountMgrQueryDosVolumePath() code (#6990)
- Use a variable of correct type instead of casting every time.
- Remove one level of indentation by returning early.
2025-01-21 19:15:59 +01:00
Timo Kreuzer
96676ca251 [PSEH] Use native SEH on clang-cl x64 2025-01-14 13:34:24 +02:00
Timo Kreuzer
4ceb46a700 [CMIDriver] Disable a clang warning 2025-01-14 13:34:24 +02:00
Timo Kreuzer
45fc95b667 [UDFS] Remove unused file from compilation 2025-01-14 13:34:24 +02:00
George Bișoc
a97fcf19ec
[CMBATT] Minor improvements to estimated battery time code
- Declare CMBATT_DISCHARGE_TIME and CMBATT_CAPACITY_BOGUS constructs
- Determine if the battery was already discharging and if not, update the time when it's being discharged
- Fix the condition where it checks if the battery has been discharging for quite some time
- Default the time to BATTERY_UNKNOWN_TIME if querying the estimated battery time request fails or if the battery has just started discharging not over 15 seconds

CORE-18969
CORE-19452
2025-01-12 20:00:14 +01:00
George Bișoc
13b394c1a7
[COMPBATT] Document COMPBATT_BATTERY_DATA and COMPBATT_DEVICE_EXTENSION structures
CORE-18969
CORE-19452
CORE-19888
2025-01-08 23:20:09 +01:00
George Bișoc
f58f37e944
[COMPBATT] Document the newly added code 2025-01-08 23:20:09 +01:00
George Bișoc
65b29fe533
[COMPBATT] Update the top headers and relicense the driver as MIT 2025-01-08 23:20:09 +01:00
George Bișoc
c439c5849b
[COMPBATT] Implement CompBattGetEstimatedTime 2025-01-08 23:20:08 +01:00
George Bișoc
a6d4998c6c
[COMPBATT] Implement CompBattQueryStatus and CompBattSetStatusNotify 2025-01-08 23:20:08 +01:00
George Bișoc
ee9914c712
[COMPBATT] Implement the battery monitor IRP worker 2025-01-08 23:20:08 +01:00
George Bișoc
6a06db09ca
[COMPBATT] Use FALSE for BOOLEANs on BatteryIoctl, not integers 2025-01-08 23:20:08 +01:00
George Bișoc
c944116833
[COMPBATT] Use the allocated battery IRPs as tags when acquiring I/O remove lock 2025-01-08 23:20:07 +01:00
George Bișoc
95f062bf0d
[COMPBATT] Use the documented debug switches
Use the debug switches that are documented and have a name rather than some cryptic values with no meaning or some shit.
2025-01-08 23:20:07 +01:00
George Bișoc
c6bdbefdc4
[COMPBATT] Use the non-constant variant of UNICODE_STRING for the battery name 2025-01-08 23:20:07 +01:00
George Bișoc
28bb8c6ff7
[COMPBATT] Assign a memory allocation tag for the I/O remove lock
IoInitializeRemoveLock expects an allocation tag to be provided when it allocates debug data in the kernel.
Passing 0 leads to a bunch of ASSERTs in the kernel as such data is allocated by ExAllocatePoolWithTag of which a tag has to be supplied, it's not optional.
2025-01-08 23:20:07 +01:00
George Bișoc
3346301777
[COMPBATT] Pass NULL for the work item context, not 0
It expects an arbitrary pointer, do the right thing!
2025-01-08 23:20:06 +01:00
George Bișoc
8b5423aa60
[COMPBATT] Annotate all functions with SAL2 2025-01-08 23:20:06 +01:00
George Bișoc
f9ea9220d8
[COMPBATT] Remove the useless WaitFlag field in the code which is never used 2025-01-08 23:20:06 +01:00
George Bișoc
04cd478035
[COMPBATT] Prepare the base foundation for the header file
- Introduce some new constructs
- Annotate the function prototypes with SAL2
- Re-structure & remove some useless fields in COMPBATT_DEVICE_EXTENSION and COMPBATT_BATTERY_DATA
2025-01-08 23:19:56 +01:00
Hermès Bélusca-Maïto
dac991c056
[PARTMGR] Implement support for IOCTL_STORAGE_GET_DEVICE_NUMBER (#7591)
CORE-13525

Now, sending the IOCTL_STORAGE_GET_DEVICE_NUMBER to a disk partition
correctly returns a non-zero STORAGE_DEVICE_NUMBER::PartitionNumber
value. This is used by the BTRFS filesystem driver and other modules.

When the STORAGE_DEVICE_NUMBER DeviceType member equals FILE_DEVICE_DISK,
the DeviceNumber and PartitionNumber correspond respectively to the
X and Y values in the \Device\Harddisk<X>\Partition<Y> device name.

References:
https://learn.microsoft.com/en-us/windows/win32/api/winioctl/ni-winioctl-ioctl_storage_get_device_number
https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntddstor/ni-ntddstor-ioctl_storage_get_device_number
https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntddstor/ns-ntddstor-_storage_device_number
2025-01-06 21:26:43 +01:00
Eric Kohl
5c4fcd99d6 [CMBATT] Fix two comments 2025-01-05 21:43:06 +01:00
Hermès Bélusca-Maïto
8653bb1b32
[PARTMGR] Few code enhancements.
- PartMgrAddDevice(): If IoAttachDeviceToDeviceStack() fails, bail out
  immediately, instead of continuing initializing the device extension
  then deciding to fail.

- PartitionCreateDevice(): Initialize the fields pertaining to parent
  device linking in the partition device extension, before the other fields
  (following in a similar way what's done in PartMgrAddDevice).
2025-01-05 20:10:26 +01:00
Hermès Bélusca-Maïto
e1b835bdbf
[PARTMGR] Minor code formatting. 2025-01-05 20:07:53 +01:00
George Bișoc
faf6123150
[CMBATT] Implement support for the _BIX method
_BIX is basically _BIF but with more information added, such as cycle count, measurement capacity accuracy and whatnot.
Starting with ACPI 4.0 _BIF is rendered obsolete and as a matter of fact a lot of modern hardware fill their ACPI machine data to _BIX.

ReactOS must go forward and beyond, compatibility with _BIF is kept. NOTE that a machine can ONLY support one battery static information method!

CORE-18969
CORE-19452
2025-01-02 18:21:33 +01:00
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
f3dd15ad64
[CMBATT] Grab the design voltage after the BIF data gets copied
There was a risk of accessing invalid data as the design voltage was grabbed before the read BIF data was copied into the device extension.
2024-12-16 22:09:02 +01:00
George Bișoc
ea8315ba56
[CMBATT] Convert power statistics from mAh to mWh
ReactOS (like any other OSes) expects power data to be represented in milliwatts per hour, not in milliamps per hour.
Currently CMBATT defaults the stats to unknown values, if that's the case, and there are a bunch of machines that do report their data from _BIF ACPI method in ampere.

CORE-18969
CORE-19452
2024-12-16 17:33:51 +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
Hermès Bélusca-Maïto
4795177ced
[DRIVERS] Fix misusages of the RTL_REGISTRY_OPTIONAL flag.
See https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-rtlqueryregistryvalues

The RTL_REGISTRY_OPTIONAL applies to the first parameter of the
RtlQueryRegistryValues() function, not to the Flags member of the
table entries. However, a RTL_QUERY_REGISTRY_REQUIRED flag exists
to mark values whose existence is NOT optional.

Problematic usage was introduced in the following modules:
drivers/input/i8042prt: Commit e7e959fb0 (r30000)
drivers/input/kbdclass: Commit 5a77f871d (r18911)
drivers/input/mouclass: Commit aeeab7d1f (r18906)
drivers/input/sermouse: Commit 3f348259c (r19100)
rosapps/drivers/green : Commit c8a90f769 (r21165)
2024-12-14 19:12:11 +01:00
Hervé Poussineau
2d3f3a1613 [COMPBATT] Use BATTERY_TAG_INVALID instead 0 when applicable 2024-11-20 21:47:13 +01:00
Hervé Poussineau
05ae94092e [COMPBATT] Free device-related memory only if we failed
Otherwise, we just inserted in the BatteryList this device, and we will
probably crash later when accessing it.
2024-11-20 21:47:13 +01:00
Hervé Poussineau
2323dbcb4f [COMPBATT] Keep incoming Status on unknown IOCTL 2024-11-20 21:47:13 +01:00
Vincent Franchomme
1f2d67a841
[FS_REC] Rename Ext2 recognizer to Ext recognizer (#7497)
Rename the Ext2 recognizer to a more generic Ext to be more future-proof with a possible upcoming ext4 support.
Also, it already makes no sense to use the name ext2 as it already recognizes all the FS of the "Ext family".

In addition, add the Ext Recognizer for CDs.
2024-11-18 21:27:16 +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
81860b482a [CMBATT] Fix battery Tag
0 (ie BATTERY_TAG_INVALID) is not a valid battery tag.
First battery must have a tag of 1.
2024-11-12 21:26:42 +01:00
Timo Kreuzer
0d6316b008 [CMAKE][LWIP] Fix build with newer CMake versions 2024-11-10 11:46:47 +02:00
Hervé Poussineau
d6eebaa47a [TCPIP] Synchronize LWIP code to 2.2.0
- take code from STABLE-2_2_0_RELEASE commit on https://git.savannah.gnu.org/git/lwip.git
- remove lwip/contrib directory
- do required changes due to upgrade in
  * CMakeLists.txt
  * include/lwip/arch/cc.h
  * include/lwip/arch/sys_arch.h
  * include/lwip/lwipopts.h
  * include/tcpip.h
  * ip/CMakeLists.txt
  * ip/lwip_glue/lwip_glue.h
  * ip/lwip_glue/tcp.c
  * ip/transport/tcp/if.c
  * tcpip/icmp.c

CORE-13098
2024-11-03 22:49:45 +01:00
Hervé Poussineau
bc94df7288 [TCPIP] Add ip_addr_t typedef
ip_addr_t is used in later versions of LWIP.
2024-11-03 22:49:45 +01:00
Hervé Poussineau
5e5b31ecbd [TCPIP] Remove options in lwipopts.h having default values
If lwipopts.h doesn't provide a define, a default value is taken from lwip/src/include/lwip/opt.h
2024-11-03 22:49:45 +01:00
Timo Kreuzer
bf95874c2d [REACTOS] Improve handling of non-standard names
- Link oldnames instead of defining names
- Define _CRT_DECLARE_NONSTDC_NAMES to 1 where needed
- Remove header hacks
2024-10-20 14:12:25 +03:00
Timo Kreuzer
e4930be4ff [REACTOS] Use the ISO C and C++ conformant names: _wcsicmp, _stricmp
Stop using non-conforming wcsicmp, stricmp, strcasecmp
2024-10-20 14:12:25 +03:00
Dmitry Borisov
10b08aa2bb
[ISAPNP] Detect I/O ports at runtime (#7411)
Improve the driver's portability.
CORE-17977
2024-10-07 16:10:08 +02:00
Timo Kreuzer
0c2cdcae83 [REACTOS] Add missing line breaks at end of file 2024-10-06 10:47:11 +03:00
Justin Miller
a65b6ae946
[USBSTOR] Don't assert on clean up if initization didnt finish (#7412)
During investigation into some of the USB stack issues we've been running into I've found that when a USB storage device is already plugged in during boot and removed before it finishes initialization we run into this assert.

The logic in this function removes the pools made for the following entries in DeviceExtension indiscriminately this makes debugging a bit more difficult. Instead of depending on this behavior of ALWAYS being filled with valid data, let's free the following pools ONLY if they're initialized. This change prevents us from bugchecking when USB flash drives are removed early during boot. This makes the debugging experience a little more sane.
2024-10-02 23:21:50 +02:00
Timo Kreuzer
d9a287e9a5 [FASTFAT] Use debug bitmap
This is to figure out, whether the bitmap gets corrupted or if there is something else going on.
2024-09-14 20:15:07 +03:00