Commit graph

876 commits

Author SHA1 Message Date
Victor Perevertkin e5254974d2
[NTOS:IO] Start loading drivers from the disk only after SystemRoot is initialized
Add another PnPBootDriversInitialized variable to indicate a point where
both disk subsystem and SystemRoot symlink are initialized, and use it
in a PiCallDriverAddDevice call.
2021-01-04 16:50:33 +03:00
Victor Perevertkin c4c0585f96
[NTOS:IO][NTOS:PNP] Implement PiCallDriverAddDevice
- Move the driver's name obtaining logic into the IopGetDriverNames
  function
- Create a new PiCallDriverAddDevice instead of PipCallDriverAddDevice
  and move it to pnpmgr/devaction.c file. Move around all its internal
  helpers too
- Support a proper Windows-compatible driver loading order for a PDO
  (lower filters, main service, upper filters, etc.)
- Set a correct Problem for the DeviceNode, in case of an error during
  driver loading
- Check the Start Type for all drivers before loading
- Do not try to load drivers during the early boot stage when there is
  no disk subsystem initialized
2021-01-04 16:50:33 +03:00
Victor Perevertkin 4c95339da0
[NTOS:IO] Refactoring of the driver initialization code (2)
- Do not hold the IopDriverLoadResource while trying to reference a
  driver object (but still acquire it when we actually need to load a
  driver)
- Change IopLoadDriver and IopInitializeDriverModule to use registry
  handle instead of a service name string and/or full registry path
- Do not try to reference a driver object inside IopLoadDriver. It's
  supposed to be done before the function call
2021-01-04 16:50:33 +03:00
Victor Perevertkin a6a3aa0f0d
[NTOS:IO] Refactor IopLoadUnloadDriver
- Split IopLoadUnloadDriver into IopLoadDriver and calling DriverUnload
- Schedule the worker for (un)loading driver in a separate routine
  (IopDoLoadUnloadDriver) this allows IopLoadDriver to be called
  separately (if we are sure that we're in the system process)
2021-01-04 16:50:32 +03:00
Victor Perevertkin e18a32df3a
[NTOS:IO] Refactoring of the driver initialization code
- Remove IopCreateDriver and put its code into IoCreateDriver and
  IopInitializeDriverModule. It's hard to extract a meaningful common
  part from it
- Refactor IopInitializeDriverModule. Extend and put the DriverName
  generation logic into it. Now this function frees the ModuleObject in
  case of failure and returns STATUS_FAILED_DRIVER_ENTRY in case of
  DriverInit failure (will be used later)
2021-01-04 16:50:32 +03:00
Victor Perevertkin 6f0e37b042
[NTOS:PNP][NTOS:IO] Do not create a device object + node on every driver load
- Remove the usage of IopCreateDeviceNode and change it to
  PipAllocateDeviceNode where required
2021-01-04 16:50:32 +03:00
Hermès Bélusca-Maïto b570fac18b
Happy New Year 2021 to the ReactOS Community!!
⚛️ 🍾 🥳 🎆 ☢️
2021-01-01 00:00:00 +01:00
Stanislav Motylkov f234cb6e59
[NTOS:CM] Do not create ProcessorNameString value if there is no Brand String
If the CPU does support CPUID instruction but does not have the Brand String,
the legacy name detection should be performed either in CIM_Processor (WMI),
in the Processor device driver, or in the application itself.

The deleted Intel CPU name detection code can go to the WMI at some point.
In fact Windows XP and 2003 kernels do not have any strings of that kind.

This effectively reverts the hack committed 6 years ago in 7a985425 (r63798)
that was intended to workaround CORE-7952.

CORE-17413
2020-12-30 19:38:41 +03:00
Victor Perevertkin 8ee88d3bd5
[NTOS:PNP] Send removal IRPs to a file system device object for mounted devices
If a DeviceObject has VPB attached, it should be treated in a special way

CORE-16106
2020-12-27 18:40:33 +03:00
Hermès Bélusca-Maïto a748350fc9
[NTOS:IO] Fail if the driver name passed to NtLoadDriver() is an empty string.
Otherwise an assertion on the driver name is hit later on.
Can be reproduced by calling NtLoadDriver with a valid UNICODE_STRING
of Length == 0.
2020-12-27 00:52:00 +01:00
Hermès Bélusca-Maïto 44511f0809
[NTOS:IO] Minor formatting only.
Making IopLoadUnloadDriver() looking similar to IopUnloadDriver().
2020-12-27 00:51:59 +01:00
Jérôme Gardou bd0445dbf2 [NTOS/FSRTL] Implement FsRtlAcquireToCreateMappedSection using filter callbacks 2020-12-22 11:37:53 +01:00
Jérôme Gardou ef4c7ae978 [NTOS:IO] Validate input parameters in NtQueryDirectoryFile
It turns out this is not the job of the FS driver
2020-12-22 11:06:38 +01:00
Jérôme Gardou 1d1dba51db [NTOS:IO] Do not set Shared property of the file if we are failing in IoCheckShareAccess 2020-12-22 11:05:00 +01:00
Jérôme Gardou a6c0af2e21 [NTOS:IO] Do not pass bogus file offset to the FS in NtReadFile & NtWriteFile 2020-12-22 11:02:33 +01:00
Jérôme Gardou 96ae15ac4b [NTOS:MM] Fix more 64 bit arithmetics 2020-12-15 10:08:25 +01:00
Jérôme Gardou abcbd44641 [NTOS:MM] Fix passing section size to MiCreatePagingFileMap & fix maximum size check
Also return the right status instead of stupidly asserting when failing to allocate memory.
2020-12-14 18:22:18 +01:00
Jérôme Gardou 8631e75837 [NTOS:CC] Acquire the master lock after freeing the VACB in CcRosFlushDirtyPages
Fixes a random ASSERT
2020-12-09 18:06:42 +01:00
Jérôme Gardou 3d4cf8d2d8 [NTOS/FSRTL] Fix MCB tests
- Fix behaviour when adding or removing entries in the middle of an existing run
 - Do not touch output parameters when failing, caller might rely on this.
2020-12-08 11:48:00 +01:00
Victor Perevertkin 016dc28793
[NTOS:CONFIG] Release the lock in a failure case in CmLoadKey
This is a workaround, the real issue is still not resolved
CORE-17263
2020-12-08 13:44:27 +03:00
Hermès Bélusca-Maïto 3d980c4a2c
[NTOS:FSTUB] Addendum to 29615fee and 8d2fe541: Further remove useless casts.
Also, fix the MBR checksum calculation (missing ~CheckSum + 1), to fix
the calculation in accordance with how MS calculates the MBR checksums
(and what we do as well in
https://github.com/reactos/reactos/blob/master/base/setup/lib/utils/partlist.c#L1581
https://github.com/reactos/reactos/blob/master/boot/freeldr/freeldr/arch/i386/hwdisk.c#L291
).
2020-12-07 22:52:42 +01:00
Hermès Bélusca-Maïto fd053237cb
[NTOS:FSTUB] Minor formatting; put the PAGED_CODE() macros in evidence (instead of being lost in the declarations). 2020-12-07 22:51:15 +01:00
Victor Perevertkin 29615feeb6
[FSTUB] Fix bugs from 8d2fe54188
The buffer is now PUCHAR or PVOID everywhere
2020-12-07 19:50:51 +03:00
Victor Perevertkin 8d2fe54188
[FSTUB] Fix out of bounds access in IoReadDiskSignature
- Convert PARTITION_TABLE_OFFSET to the number of bytes instead of
  (number of bytes) / 2. This avoids many confusing casts
- Use a cache aligned buffer for MBR
2020-12-07 14:43:34 +03:00
Victor Perevertkin 582ca68696
[NTOS:PNP] Improve and refactor PnP notifications
- BUGFIX: do not call IoGetRelatedTargetDevice while guarded mutex is acquired
  (the function issues an APC, but they are disabled inside a critical section)
- BUGFIX: only the beginning of a structure for GUID_PNP_CUSTOM_NOTIFICATION was copied and queued.
  Just pass it as-is to a subscriber, without copying
- Don't convert event GUID to string, store and compare GUID struct itself
- Split IopNotifyPlugPlayNotification into 3 functions for each type of notification
  (less stack usage and for future changes)
- Move initialization code for notifications into a separate routine
- Use separate lists and locks for every type of notification
- Put "TargetDeviceChange" notifications into their place inside DEVICE_NODE
2020-12-05 22:25:40 +03:00
Victor Perevertkin e3198fb644
[NTOS:PNP] Check if APCs are enabled before waiting inside IopSynchronousCall 2020-12-05 22:25:39 +03:00
Victor Perevertkin 9eafb2971f
[NTOS:CONFIG] Comment out the assertion until fixed
CORE-17263
2020-12-05 22:17:08 +03:00
Jérôme Gardou 0db79d4aa9 [NTOSKRNL:FSRTL] Fix memory corruption when pruning tunnel cache 2020-12-04 16:08:14 +01:00
Thomas Faber 828d5fa93e
[NTOS:IO] Reduce stack usage in IopLoadServiceModule. CORE-17215 2020-11-27 12:44:35 +01:00
Thomas Faber 2858ff53ce
[NTOS:KD] Avoid large stack buffer in KdpPrint. CORE-17215 2020-11-27 10:31:45 +01:00
Thomas Faber ae1d272add
[NTOS:PNP] Avoid recursion in IopTraverseDeviceTree(Node). CORE-17215 2020-11-27 10:31:41 +01:00
Hervé Poussineau 1a3c607f53 [NTOS:KD] Change the way we detect if exception if from KernelMode/UserMode
CORE-17381
2020-11-22 18:17:59 +01:00
Hervé Poussineau 44c6df4b27 [NTOS:KD] Correctly define previous mode when entering KDBG (addendum to 0c76bbfe98) 2020-11-17 14:23:36 +01:00
Jérôme Gardou 9e7071e8fb [NTOSKRNL] DO not disable optimisations when compiling with CLang 2020-11-16 16:58:10 +01:00
Jérôme Gardou e00922a0fe [NTOSKRNL] Link memcmp to the import lib when using CLang
CLang performs some optimisations on e.g. strcmp, but memcmp is not exported by ntoskrnl
2020-11-16 16:58:10 +01:00
Hervé Poussineau d6d5caec7c [NTOS:KD] Move some KDBG-specific variables to KDBG-specific file 2020-11-16 08:55:04 +01:00
Hervé Poussineau 0c76bbfe98 [NTOS:KD] Merge KdpReportExceptionStateChange() with kd64 version 2020-11-16 08:55:04 +01:00
Hervé Poussineau baa47fa5e0 [NTOS:KD] Use a PCONTEXT instead of a PKTRAP_FRAME in KDBG 2020-11-16 08:55:03 +01:00
Hervé Poussineau ba37323a62 [NTOS:KD] Move some declarations where they belong 2020-11-16 08:55:03 +01:00
Hervé Poussineau 67e9cc00b2 [NTOS:KD] Remove useless define
KdbEnterDebuggerException() is only called when KDBG is defined.
2020-11-16 08:55:03 +01:00
Hervé Poussineau 95faf65ebf [NTOS:KD] Remove useless variables/members
Those where only set and never read.
2020-11-16 08:55:03 +01:00
Hervé Poussineau 8d3a395101 [NTOS:KD] Remove Bochs port debugging
You can use serial port debugging instead.
2020-11-16 08:55:03 +01:00
Hervé Poussineau 8a62f277d8 [NTOS:KD] Remove useless implementation of BREAKPOINT_PRINT in KdSystemDebugControl
This is (as expected) handled in KdpTrap(), which also calls KdpPrint().
2020-11-16 08:55:03 +01:00
Hervé Poussineau 1eda7d7e99 [NTOS:KD] Merge KdpReportCommandStringStateChange() with kd64 version 2020-11-16 08:55:03 +01:00
Hervé Poussineau 6f7835d30c [NTOS:KD] Merge KdpReportLoadSymbolsStateChange() with kd64 version 2020-11-16 08:55:03 +01:00
Hervé Poussineau e31be4ec25 [NTOS:KD] Merge KdEnableDebuggerWithLock()/KdDisableDebuggerWithLock() with kd64 version 2020-11-16 08:55:03 +01:00
Hervé Poussineau ebb6f29e69 [NTOS:KD] Merge KdEnterDebugger()/KdExitDebugger() with kd64 version 2020-11-16 08:55:03 +01:00
Hervé Poussineau 81b184741d [NTOS:KD] Remove useless uses of _WINKD_ 2020-11-16 08:55:03 +01:00
Hervé Poussineau 329b9fa2fb [NTOS:KD] Merge KdpReport() with kd64 version 2020-11-16 08:55:03 +01:00
Hervé Poussineau a8662c73a5 [NTOS:KD] Merge KdpTrap() with kd64 version 2020-11-16 08:55:03 +01:00