Commit Graph

1217 Commits

Author SHA1 Message Date
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
Serge Gautherie
44662eaf62 [CMAKE] Use COMPILE_OPTIONS instead of superseded COMPILE_FLAGS
for set_source_files_properties().
2024-08-21 11:34:48 +03:00
Hervé Poussineau
30ac80f36b [CMBATT] Implement CmBattVerifyStaticInfo 2024-08-12 11:56:18 +02:00
Hervé Poussineau
2ff683fa33 [CMBATT] Remove useless fields in device extension
Information is already present in BifData, and those fields were never filled.
2024-08-12 11:56:18 +02:00
Hervé Poussineau
359e73d055 [CMBATT] Implement CmBattGetBifData/CmBattGetBstData 2024-08-12 11:56:18 +02: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
Dmitry Borisov
fdc1d96dc1 [ISAPNP] Make sure that APCs are disabled before acquiring a lock
Note: We could just use a fast mutex instead
2024-08-03 17:08:44 +06:00
Dmitry Borisov
6091dde0d3 [ISAPNP] Improvements around hardware access helpers
- Reimplement WriteWord using the WriteByte helper.
- Remove inline qualifiers from the bus read and write functions.
  This code path is considered "cold" and using an inline for it is overkill.
- Don't apply the IRQL restrictions to our PnP state transition helpers.
  They are only called at IRQL below dispatch level.
2024-08-03 17:08:43 +06:00
Dmitry Borisov
2981e63a31 [ISAPNP] Refactor the configuration code
- Remove useless checks
- Increase code readability
2024-08-03 17:08:43 +06:00
Dmitry Borisov
76ec8411a4 [ISAPNP] Fix parsing of complex resource data
- Properly handle the case when the dependent function is placed
  after fixed resources
- Initialize the version and revision fields of resource lists
- Improve validation of resource data
- Add more debug prints

CORE-18562
2024-08-03 17:08:43 +06:00
Dmitry Borisov
c1d7087352 [ISAPNP] Fix the reported length of the memory I/O ranges
CORE-18562
2024-08-03 17:08:43 +06:00
Dmitry Borisov
9b7f34601a [ISAPNP] Force clear the upper reserved bits on fixed I/O descriptors
CORE-18562
2024-08-03 17:08:43 +06:00
Dmitry Borisov
991dbeff53 [ISAPNP] Fix the truncation of 32-bit configuration I/O reads
CORE-18562
2024-08-03 17:08:43 +06:00
Dmitry Borisov
b36d9bd9c1 [ISAPNP_UNITTEST] Add unit tests exercising device discovery and device resources functionality
CORE-18562
2024-08-03 17:08:43 +06:00
Dmitry Borisov
016d01e5d1 [ISAPNP] Extract resource definitions
Prepare the driver for upcoming API tests
CORE-18562
2024-08-03 17:08:43 +06:00
Dmitry Borisov
4ba8a8b59b [ISAPNP] Allocate the Read Port resources on demand
This will simplify failure paths and reduce memory usage
2024-08-03 17:08:42 +06:00
Hermès Bélusca-Maïto
61b7fb99eb
[PARTMGR] Filter some currently-unimplemented MountMgr MOUNTDEV notifications.
CORE-17200

Helps reducing debug log noise like:
```
(drivers\storage\port\scsiport\ioctl.c:542) unknown ioctl code: 0x4D0018
```

The other notifications are already implemented there.
These are handled by the volume manager, which is currently
stubbed into ReactOS' partition manager.

See commit ed27d733f7 for what the deprecated versions
of IOCTL_MOUNTDEV_LINK_[CREATED|DELETED] are all about.
2024-07-17 17:24:26 +02:00
Hermès Bélusca-Maïto
9e07d0cc74
[PARTMGR] Trigger mount points removal when a partition/volume is deleted (#7034)
CORE-18139

When a partition is created, PartMgr notifies the volume manager
(FTDisk on Windows <= 2003, VolMgr on Vista+) of its presence.
(Note that currently in ReactOS, our partmgr does the job of both
PartMgr *AND* VolMgr.)
The VolMgr then sends a `GUID_DEVINTERFACE_VOLUME` PnP notification,
which is handled by the mount manager (MountMgr) as part of a
`GUID_DEVICE_INTERFACE_ARRIVAL` notification:
```
MountMgr!MountMgrMountedDeviceNotification -> MountMgrMountedDeviceArrival
followed by
MountMgr!MountMgrTargetDeviceNotification
```

When a partition is deleted, via e.g. Disk Management or DiskPart,
it can be observed, on Windows, that the PartMgr gets notified by
the PnP manager, as part of QueryDeviceRelations. Before actually
removing the partition, it notifies the VolMgr. The latter invalidates
any volume mounted on that partition (`*PartitionRemoved*` functions
for basic volumes), then requests (`*DeleteMountPoints` function)
the MountMgr to delete all the mount points associated to the volume:
```
VolMgr!*DeleteMountPoints
-> MountMgr!MountMgrDeviceControl -> MountMgrDeletePoints
```
**** THIS is the new functionality that is implemented for ReactOS ****
**** in the present commit.                                        ****

Following this, a subsequent PnP notification is sent, which calls
```
MountMgr!MountMgrTargetDeviceNotification
-> MountMgr!MountMgrMountedDeviceRemoval
```
(Note that this observation somewhat invalidates the modification
made in ReactOS commit 62a4f9d42b : our MountMgr placed in Windows
*WOULD* receive a `GUID_TARGET_DEVICE_REMOVE_COMPLETE` target-device
notification...)

Finally, a `GUID_DEVICE_INTERFACE_REMOVAL` PnP notification is sent
to the MountMgr:
```
MountMgr!MountMgrMountedDeviceNotification
-> MountMgr!MountMgrMountedDeviceRemoval
```
2024-07-11 13:46:52 +02:00
Hermès Bélusca-Maïto
7e89227a00
[MOUNTMGR] Fix initial sending of device online notification (#7030)
1. MountMgrMountedDeviceArrival():
   Fix the conditions under which the device's online notifications
   are skipped (SkipNotifications == TRUE) and fix the code comments.
   Now, things make much more sense:
   online notifications are skipped when the device is already offline
   or is a legacy (NT <= 4) fault-tolerant volume (see point 2 below),
   or is NOT mounted (doesn't have a drive letter).
   Previously, we were sending an online notification if the device
   was NOT mounted (why?!...) or if it was deemed as "valid" (wrongly
   determined, see point 2 below).

2. QueryDeviceInformation():
   * The usage of the "Valid" parameter didn't make much sense. Indeed,
     when a partition/volume device is reported to the Mount Manager,
     it's already valid. (Also, setting "Valid" to TRUE only in the case
     of an MBR partition while ignoring GPT ones, and resetting it to
     FALSE if IOCTL_STORAGE_GET_DEVICE_NUMBER returned success, pointed
     to something incorrect was going on.)
     Instead, what we are checking here is whether the device is a
     legacy fault-tolerant volume: such volume can only reside on an
     MBR disk, have the expected partition type, and does not really
     reside on a specific storage device (hence the check for
     IOCTL_STORAGE_GET_DEVICE_NUMBER returning failure).

   * Take also the opportunity to SAL2-ify the function.
2024-06-25 22:51:08 +02:00
Hermès Bélusca-Maïto
5f26356079
[MOUNTMGR] Rectify "NoAutoMount" usage (#7030)
This "NoAutoMount" member was not consistently used. Sometimes it was
used correctly, some other times it was used as "not NoAutoMount" i.e.
"AutoMount" enabled.
Fix this consistently throughout the source, and fix also some comments.
2024-06-25 22:51:07 +02:00
Joachim Henze
32d615fc10
[DD] Keep the network drivers infs 8.3 like on MS Windows (#7007)
Windows has all its network drivers inf files in 8.3.

This is an addendum to 0.4.15-dev-52-g 019f21ee1d
which moved us further away from our target.

The commit on its own was a good idea actually to get the inf into the drivers directory
and therefore simplifies adding and excluding drivers more locally (e.g. excluding works by
adding a single hashtag within the specific drivers CMakeLists.txt now).

But that cool feature doesn't require us to move away from our target.

For the record:
The historic netrtpnt.inf and netisa.inf (both 8.3) have been merged to
netne2000.inf (not 8.3) by 0.4.15-dev-2763-g 6924b8ff39
Unification of that was cool too,
but again: 8.3 is superior. Therefore netne.inf for that.

Worst of all: Since the .inf files did contain their filename within a comment also, that means
the historic renaming by the mentioned commit invalidated that comment.
netamd.inf fixed by restoring the ancient filename before 0.4.15-dev-52-g 019f21ee1d
netrtl.inf fixed by restoring the ancient filename before 0.4.15-dev-52-g 019f21ee1d
netne.inf I fixed the comment manually.
2024-06-17 22:41:31 +02:00
Joachim Henze
3e6f65ffcd
[DC21X4] Fix uninitialized variable read (#6984)
This is the network driver which is used for MSVPC 2007.

I spotted it during a WIP-backport-experiment of the driver, when compiling with GCC4.7.2, which warned about it.
GCC8.4.0 unfortunately is blind to that on master head, for unknown reasons. Not good.
MSVC github buildbot is also blind to that on master head, for unknown reasons. Not good.
We later found that at least Clang did also warn about it on master head.
2024-06-13 21:24:23 +02:00
Hermès Bélusca-Maïto
ab0e04c81d
[MOUNTMGR] Introduce MountMgrSendSyncDeviceIoCtl() to replace repeated code (#6960)
See https://www.osr.com/blog/2018/02/14/beware-iobuilddeviceiocontrolrequest/
for some details about IRQL requirements.
2024-06-13 20:01:16 +02:00
Hermès Bélusca-Maïto
ed27d733f7
[MOUNTMGR][DDK] Fix some IOCTLs definitions to Win2k3+ compatibility (#6959)
Fix IOCTL_MOUNTDEV_LINK_CREATED, IOCTL_MOUNTDEV_LINK_DELETED,
IOCTL_MOUNTDEV_UNIQUE_ID_CHANGE_NOTIFY, to Win2k3+ compatible definitions.
The previous versions of these IOCTLs (in Win2000 and XP) were defined without any access protection.

This was noticed here:
https://community.osr.com/t/ioctl-mountdev-link-created-definition-changed/29428
2024-06-12 12:31:32 +02:00
Hermès Bélusca-Maïto
7930bed0a1
[MPR][MOUNTMGR][DDK] Remove unused wine-specific code (#6958)
Usage of these in MPR was already inside #ifndef __REACTOS__ block,
so, "This Is Fine".
2024-06-12 12:29:22 +02:00
Hermès Bélusca-Maïto
0d36818422
[MOUNTMGR] Some cleanup 2024-06-12 12:29:06 +02:00
Hermès Bélusca-Maïto
e80cd6760c
[PARTMGR] Reimplement IOCTL_MOUNTDEV_QUERY_UNIQUE_ID for MBR and GPT partitions (#6926)
CORE-15575

In addition, fix a PartitionId assignment copy-paste error in PartitionCreateDevice().

The returned standard UniqueId has the following format:

- Basic volume on MBR disk: disk Mbr.Signature + partition StartingOffset (length: 0x0C)
- Basic volume on GPT disk: "DMIO:ID:" + Gpt.PartitionGuid (length: 0x18)
- Volume on Basic disk (NT <= 4): 8-byte FTDisk identifier (length: 0x08)
- Volume on Dynamic disk (NT 5+): "DMIO:ID:" + dmio VolumeGuid (length: 0x18)
- Super-floppy (single-partition with StartingOffset == 0),
  or Removable media: DiskInterfaceName.
- As fallback, we use the VolumeInterfaceName.

References:
- https://winreg-kb.readthedocs.io/en/latest/sources/system-keys/Mounted-devices.html
- https://stackoverflow.com/a/72787681/21852502
- Manual testing on Windows.
2024-06-12 12:15:31 +02:00
Hermès Bélusca-Maïto
3d26d76a4c
[PARTMGR] Detect and flag partitionless ("super-floppy") disks (#6926)
CORE-15575

Detect whether the disk is a "super-floppy", which is the name given
to partitionless disk having no MBR, with the unique partition volume
starting at sector offset zero and spanning the whole disk.
The name comes from the fact that at the partitioning level, the disk
"looks like" a large-capacity floppy disk.

This is typically how external removable (USB, ...) drives are
partitioned by default by Windows.

https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/windows-and-gpt-faq?view=windows-11#superfloppy

The kernel-mode functions IoReadPartitionTable() / IoWritePartitionTable()
report the drive layout of a "super-floppy" disk as follows:
an MBR-style disk containing only one single partition starting at the
beginning of the disk (StartingOffset == 0) without hidden sectors, and
its type being FAT16 non-bootable.
The disk NTFT signature is set to 0x00000001.

----

Additional bug fixes to make the feature work reliably:

- Make PartMgrGetDriveLayout() also update the FDO DiskData's
  PartitionStyle and Signature/GPT DiskId for consistency (code moved
  from PartMgrRefreshDiskData()).

- In FdoIoctlDiskSetDriveLayout[Ex](), if the disk is "super-floppy",
  but the user wants to create more than one partition, fail the call.
  (In the Ex call, fail also if the partition style changes.)
2024-06-12 12:15:22 +02:00
Hermès Bélusca-Maïto
33ac3578fd
[PARTMGR] Fix the way the "symlink -> target" DPRINT is displayed 2024-06-12 12:14:53 +02:00
Hermès Bélusca-Maïto
2d6bbdc6ed
[PARTMGR] Fix x64 build warning
warning C4267: 'function': conversion from 'size_t' to 'ULONG', possible loss of data'

The OutputBufferLength member that was temporarily stored in
outBufferLength is already a ULONG, and IssueSyncIoControlRequest()
takes the length as a ULONG. So there is no need to use 'size_t' here.
2024-06-12 12:14:45 +02:00
Hermès Bélusca-Maïto
b84f2a1cdc
[KDVM] Fix definition of RtlEqualMemory() (#6988)
Comply with the standard documented behaviour:

https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-rtlequalmemory#return-value
> RtlEqualMemory returns TRUE if Source1 and Source2 are equivalent; otherwise, it returns FALSE.

and
https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-rtlcomparememory#return-value
> [...] If all bytes match up to the specified Length value, the Length value is returned.
2024-06-10 22:29:22 +02:00
Hermès Bélusca-Maïto
0a8b421d53
[PARTMGR] Implement IOCTL_VOLUME_QUERY_VOLUME_NUMBER and IOCTL_VOLUME_IS_PARTITION (#6911)
- Implement IOCTL_VOLUME_QUERY_VOLUME_NUMBER:
  See usage example in:
  7241cebfa2/mayfield/branches/spr/src/umapps/ndassvc/service/drivematch.cpp (L627)

- Stubplement IOCTL_VOLUME_IS_PARTITION:
  The only type of volume we support right now is disk partition
  so we just return success. A more robust algorithm would be
  to check whether the volume has only one single extent, that
  covers the whole partition on which it lies upon. If this is
  not the case, return STATUS_UNSUCCESSFUL instead.
2024-06-10 21:32:47 +02:00
Oleg Dubinskiy
a55e9ce19c
[AC97] Use individual Decibel range for Master Volume control (#6950)
Add ReactOS change to use the same Decibel (dB) sound loudness range for Master Volume control as for WaveOut Volume Control.
This fixes incompatible volume level change scaling when changing the volume in Fox Audio Player 0.10.2 from Rapps and Winamp 2.95 with WaveOut output plugin.
Now it is identical to the one when using original AC97 driver from Windows XP/Server 2003.
CORE-14780
2024-06-01 12:31:53 +02:00
Serge Gautherie
3cc4361cca
[CMAKE] Clang*: Add '-Werror=unknown-warning-option' for C/CXX (#6383)
* [UDFS] Clang: Fix a #pragma

'warning: unknown warning group '-Wstringop-overflow', ignored [-Wunknown-warning-option]'

Follow-up to 612b1f2e6 (0.4.15-dev-1129).

* [CREATESPEC] Clang: Fix a target_compile_options()

'warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]'

Addendum to 00ed72d7e (0.4.15-dev-1169).

* [MSVCRT_WINETEST] Clang*: Fix a target_compile_options()

'warning: unknown warning option '-Wno-stringop-truncation'; did you mean '-Wno-string-concatenation'? [-Wunknown-warning-option]'

Addendum to commits 00ed72d7e (0.4.15-dev-1169) then f155b9377 (0.4.15-dev-4612).

* [TELNET] Clang*: Fix a target_compile_options()

'warning: unknown warning option '-Wno-restrict' [-Wunknown-warning-option]'

Addendum to 447ef2aa4 (0.4.15-dev-4613).
2024-05-31 16:26:11 +02:00
George Bișoc
f69e256376
[ACPI] Register a device interface class with ACPI fans
As the commit title says, the point of registering a device interface with ACPI fans is to receive incoming PnP notifications of incoming ACPI fan drivers so that the power manager can connect to them by creating a power device policies dedicated to them during power manager initialization.

CORE-18969
2024-05-22 20:23:06 +02:00