Commit Graph
35 Commits
Author SHA1 Message Date
Ahmed Arif ed367320c2 [DHCPCSVC] Fix DHCP option stack overflow (#9056)
Reject malformed DHCP subnet mask and router option lengths
before setup_adapter() consumes them.

This prevents attacker-controlled option lengths from expanding DHCP
option bytes into a fixed stack buffer while preserving valid
router address lists.

Validate the option lengths before use, keep router lists limited to
complete IPv4 addresses, and format registry IPv4 strings with
RtlIpv4AddressToStringA().

Booted amd64 QEMU image: no DHCP/client networking regression observed.
2026-07-30 18:20:50 +03:00
Ahmed Arif c606fd79b1 [NTOS:FSRTL] Respect byte-range lock ownership (#9342)
FsRtlCheckLockForReadAccess() accepts access through an exclusive
byte-range lock when the IRP key matches, even if another process
owns the lock. FsRtlFastUnlockAll() likewise removes exclusive locks
without checking the Process argument.

Require both the key and requestor process for exclusive-read access,
and skip exclusive locks owned by other processes in FsRtlFastUnlockAll().
This matches the ownership checks already used by
FsRtlFastCheckLockForRead() and FsRtlFastUnlockAllByKey().

Reference:
- https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/nf-ntifs-_fsrtl_advanced_fcb_header-fsrtlfastchecklockforread
2026-07-29 21:54:44 +03:00
Ahmed Arif 4c3d15abe6 [CLANG][SDK] Add the llvm-compat runtime shim library (#9094)
llvm-mingw's static runtime (libc++, libmingwex, libc++abi, libunwind)
references symbols the NT 5.2 export surface does not provide. Add a
static library, linked into the Clang runtime chain below
DLL_EXPORT_VERSION 0x601, providing:

- C99 vsnprintf/snprintf on top of _vsnprintf/_vscprintf.
- __imp_* aliases binding dllimport references to the static CRT
  definitions instead of ucrtbase import thunks, which collide with
  them (lld: "<sym> was replaced").
- K32EnumProcessModules, forwarded to psapi's EnumProcessModules.
- The Win7 SRW lock and Vista condition variable surface, bound to the
  RTL implementation linked statically from rtl_vista. Modules get one
  self-contained, consistent synchronization implementation (ReactOS'
  lock layout is not Windows-compatible), no kernel32_vista.dll
  dependency, and stay runnable on any Windows version. Static SRW
  linking suggested by Timo Kreuzer.

Address review feedback on the llvm-compat shims:

sync_static.c now uses the proper SDK/NDK headers with WINAPI/NTAPI, imp_alias.h
moved to sdk/include/reactos and fixes the msvcrtex slot decorations too, and a
new InitOnceExecuteOnce shim lets us drop libkernel32_vista from the interface.
2026-07-29 11:27:59 +00:00
Ahmed Arif 98256a4f5d [NTOS:MM] Allow contiguous-memory frees at DISPATCH_LEVEL (#9349)
MmFreeContiguousMemory() is callable at up to DISPATCH_LEVEL,
but MiFreeContiguousMemory() used PAGED_CODE(), which incorrectly asserted
above APC_LEVEL in checked builds.

Replace it with an assertion that enforces the exported IRQL contract.
2026-07-27 17:44:40 +03:00
Ahmed Arif 28373a9f84 [NTOS:IO] Do not free the active VPB (#9343)
IopDereferenceVpbAndFree frees a zero-reference VPB only while it is still
installed in RealDevice->Vpb. This can leave the device with a dangling
VPB pointer while detached VPBs are retained.

Reverse the identity test so only a detached, nonpersistent VPB is released
after its reference count reaches zero.

Reference:
- https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/ns-wdm-_vpb
2026-07-27 15:48:33 +03:00
Ahmed Arif 6c515f5aa6 [NTOS:MM] Release system image PTEs on unload (#9078)
MmUnloadSystemImage() had an explicit leak placeholder for driver images.

Implement the MmUnloadSystemImage() that performs matching teardown
for the image mappings, releasing the reserved system PTE range.

Also fix similar leak in MiLoadImageSection() by releasing image mappings
after load failures.

CORE-8294

Note that the driver images loaded at boot, which were not reloaded by
MiReloadBootLoadedDrivers(), remain at their loader-assigned addresses
and do not own system PTEs.
2026-07-27 15:20:39 +03:00
Ahmed ARIF 6799d7e96e [ARM64][SDK] Address intrinsic review feedback 2026-07-25 17:46:38 +00:00
Ahmed ARIF 658328ca24 [ARM64][SDK] Fix MinGW intrinsic declarations 2026-07-25 17:46:38 +00:00
Ahmed ARIF f6efc98b37 [ARM64][SDK] Add MinGW intrinsics support
Add the ARM64 MinGW intrinsics and SDK constants validated by the ARM64 bring-up work.
2026-07-25 17:46:38 +00:00
Ahmed ARIF 174b9d64fe [NTOS] Export the UTF-8 conversion routines
RtlUTF8ToUnicodeN and RtlUnicodeToUTF8N are documented kernel APIs since Windows 7, but they are missing from the ntoskrnl export table.
2026-07-24 14:49:13 +02:00
Ahmed Arif 63deca5a96 [ACPI][UEFI] Use bootloader-provided ACPI root pointer in OSL (#8980)
Fix ACPI table discovery on the UEFI boot path by teaching the ACPI OSL
to use the loader-provided ACPI root table information instead of relying
only on legacy BIOS RSDP scanning:

- Build a synthetic RSDP from the ACPI BIOS configuration node
  populated by the bootloader
- Fallback to the old scan only if that data is unavailable
- Keep full 64-bit physical addresses when mapping ACPI tables
- Improve failure diagnostics if initialization still fails

This lets ACPICA initialize from the UEFI-provided RSDT/XSDT path.
CORE-11954

So QEMU Q35 on UEFI is now able to discover ACPI tables through the loader-
provided root table path, which fixes 0x7B INACCESSIBLE_BOOT_DEVICE bugcheck:

https://github.com/user-attachments/assets/25d4d9c9-4197-496b-84f9-e5642c65809d
2026-07-09 01:40:17 +03:00
Ahmed Arif cf47094103 [NTUSER] Preserve WM_QUIT in move/size modal loop (#9087)
Dragging the first-boot install/status window could make setup stall,
and the shell never started after that.

The problem is that the move/size modal loop can remove a posted `WM_QUIT`
while setup is tearing the thread down. That quit message then does not
reach the outer `GetMessage()` loop, so the setup thread keeps waiting
instead of exiting.

This fix keeps the `WM_QUIT` message alive by re-posting it and leaving
the move/size loop.

See also: https://devblogs.microsoft.com/oldnewthing/20050222-00/?p=36393

## How to test

Boot to first-boot setup, drag the install/status window while it is finishing,
and check that setup continues and Explorer starts instead of hanging.
2026-06-29 21:20:26 +02:00
Ahmed Arif b82e2884fc [NTUSER] Report fresh scrollbar state in co_IntGetScrollBarInfo (#9137)
`co_IntGetScrollBarInfo()` computed the `rgstate` bits into the output buffer
and then immediately overwrote them with the cached copy, so callers always
got stale state.

Fix this by copying the cached info before computing `rgstate`.

This also exposed an inverted `WS_DISABLED` test (per wine, disabled `SB_CTL`
should report `UNAVAILABLE`, not enabled ones), which is now fixed as well.
2026-06-29 21:10:41 +02:00
Ahmed Arif b38db9dd23 [NTUSER] Clip the non-client update region to the dirty region (#9126)
Remove the excessive repainting of the non-client window area (title caption/buttons and borders) whenever other windows are being dragged over.

CORE-5877, CORE-16672
2026-06-28 20:24:50 +02:00
Ahmed Arif 24e904e095 [EVTLIB] Do not preallocate event logs to MaxSize (#9071)
Keep the configured event log `MaxSize` as a capacity limit and track the
physical file size separately.

New logs now start at the Windows 64 KiB file-size granularity, instead of
growing immediately to the full configured maximum. They are then grown in
64 KiB chunks as records are written, while preserving the logical used area
in the header offsets and EOF record.
2026-06-28 20:14:56 +02:00
Ahmed Arif 1b91127bbe [FLOPPY] Fix double-free of the interrupt object on init failure (#9225)
AddControllers already disconnects the controller interrupt on its error paths but left InterruptObject pointing at the freed object.

Now that DriverEntry runs Cleanup on failure (and Unload() routes through it too), that stale pointer is handed to IoDisconnectInterrupt a second time, bugchecking with BAD_POOL_HEADER.

Clear InterruptObject right after disconnecting so Cleanup() skips it.

CORE-20669
2026-06-28 10:23:39 -05:00
Ahmed Arif c0f18d059a [WIN32SS:GDI] Fix an off-by-one error in the StretchBlt mask bounds check (#9136)
The mask bounds check in `DIB_XXBPP_StretchBlt` allowed `sx == cx` (and similar for `sy`),
reading one pixel past the end of the mask bitmap.
On the contrary, the source-surface check a few lines below already does it right.
2026-06-27 17:03:48 +02:00
Ahmed Arif aaab5f0198 [WIN32SS:NTGDI] IntGdiCreateDisplayDC: Directly invoke GreCreateCompatibleDC (#9164)
Call the internal GreCreateCompatibleDC instead of the NtGdi syscall stub.
2026-06-26 14:28:42 +02:00
Ahmed Arif 6e95a132bd [WIN32SS:ENG/NTUSER] Use shared locks for display list lookups (#9090)
- Use shared locks for the display device and PDEV lookup paths.
  These functions only walk existing lists and take references, while list updates
  and mode-switch paths still use exclusive locking.
  This avoids serializing read-only display queries unnecessarily.

- Use shared locks for other read-only NtUser calls.
2026-06-26 14:07:15 +02:00
Ahmed Arif a45e91cb3d [WIN32SS:NTUSER] Use shared locks for read-only queries (#9088)
Some win32k syscalls were still taking the exclusive user lock even though they only read existing state.

This switches a few simple query paths to the shared user lock instead: foreground window lookup, IME hotkey/context queries, layered window attributes, and title bar info.

The goal is to avoid taking the writer lock for read-only work while keeping the same behavior.
2026-06-26 13:51:48 +02:00
Ahmed Arif f17d904d2d [WIN32SS:NTUSER] Return NO_SELECTED_ITEM from NtUserMenuItemFromPoint() when no item is hit (#9121)
Fix the bug, where `NtUserMenuItemFromPoint()` returned `cItems` instead of `NO_SELECTED_ITEM`
when no item is under the point (`mi` is never NULL on a miss), so `MenuItemFromPoint()` callers
could have indexed one past the menu array.
2026-06-25 18:22:15 +02:00
Ahmed Arif ae0e4ee305 [WIN32K:DIB] Fix some bugs in DIB_8BPP_BitBltSrcCopy (#9119)
- Fix destination row stride;
- Fix source stride and double translation in the flip path.

Related to CORE-2965
2026-06-25 18:03:00 +02:00
Ahmed ARIF 9dce9a82e9 [FLOPPY] fix driver unloading 2026-06-25 12:07:57 +00:00
Ahmed Arif 69474b3190 [NTOS:OB] Replace the joke debug print in NtWaitForMultipleObjects with a proper diagnostic (#9163)
Addendum to commit f543c860f7 (r69399).
2026-06-16 18:06:18 +03:00
Ahmed Arif 7f79e1c948 [NTUSER] IntNotifyWinEvent(): Fix 4th argument copypasta (#9138)
The caret EVENT_OBJECT_SHOW notification passed OBJID_CARET as idChild,
while the other four caret events in the file correctly pass CHILDID_SELF.
2026-06-11 16:24:26 +03:00
Ahmed Arif 529f3c618d [NTUSER] Return the correct value for SPI_GETLOWPOWERACTIVE (#9135) 2026-06-11 00:32:35 +02:00
Ahmed Arif d3ed29ef06 [NTGDI][POLYTEST] Use newx1 as the lower bound in polyfill line-touch test (#9118)
Bug/typo was introduced in https://github.com/reactos/reactos/commit/5b6d43ab50b88d2ab8fd3d7ebf434173c5768065 (r5619).
2026-06-08 16:42:33 +03:00
Ahmed Arif a94352ba48 [WIN32SS:ENG] Fix copy direction in overlapping EngTransparentBlt (#9117)
The brackets were around the wrong part, so the < checked the left edge against the picked direction instead of against the other left edge.

Bug was introduced in https://github.com/reactos/reactos/commit/5424a511074933c1b7874cdfce28fd1e06125b12 (r8988), then improved in https://github.com/reactos/reactos/commit/07a533fe02d9f3affaa33d004159ae846cbf1eb5 (r40380), however the obvious braces issue was not noticed.
2026-06-08 14:20:41 +03:00
Ahmed Arif 984657bdf0 [WIN32SS:ENG] Fix Y coordinate of the software pointer exclude rectangle (#9116)
Crazy that this typo survived two decades, but here we are, that might fix some GDI test.

Bug was introduced in https://github.com/reactos/reactos/commit/50b193239bd9554a4e7cf671a001dc12ec726454 (r12035).
2026-06-08 13:48:12 +03:00
Ahmed Arif b1f04786e1 [NTOS:FSTUB] Clear the whole partition table in FstubCreateDiskRaw (#9124)
FstubCreateDiskRaw is supposed to wipe the MBR when it makes a RAW disk.
Before this fix, that function only cleared the first of the 4 partition entries, so one entry (16 bytes) instead of the whole table (64).
As a consequence, the wiped MBR written back to disk still had entries 2, 3 and 4 sitting there with old data, and those came back as ghost/garbage partitions.
2026-06-08 00:14:11 +02:00
Ahmed ARIF 99ec6cbf07 [CMLIB] Fix hive validation loop for missing bins 2026-05-14 11:37:59 +02:00
Ahmed ARIF 7509b428bf [DBGHELP][AMD64] Return the last valid frame at end of stack in StackWalk64 2026-04-02 12:06:19 +02:00
Ahmed Arif 1c2b5a1a8e [SEH][GCC] Prevent inlining of functions using REACTOS seh pragma 2026-03-20 14:57:40 +02:00
Ahmed ARIF 094d06eb26 [ASMPP] Fix .text exporting for MASM .code blocks 2026-03-20 13:50:03 +02:00
Ahmed Arif 08e57f6bc2 [CRT/GCC] Fix infinite recursion in memset/memcpy/memmove at -O2 2026-03-02 20:14:06 +02:00