Commit graph

1147 commits

Author SHA1 Message Date
Victor Perevertkin 34593d933b
[FORMATTING][NTOS][HAL][DRIVERS][SDK] Fix trailing spaces 2021-06-11 15:33:08 +03:00
Hermès Bélusca-Maïto 4b4ffa92f5
[NTOS:IO] Modify when 'PartitionBuffer' and how 'DriveLayout' are freed in IopCreateArcNamesDisk().
- Manage the lifetime of the temporary 'PartitionBuffer' buffer where
  it is locally used only, and free it as soon as possible, just after
  calculating the sector checksum. No need to then free it outside of
  the main for-loop.

- When the 'DriveLayout' buffer is freed, ensure the pointer is NULL-ed
  (and assert this at the top of the main for-loop), since it can also
  be freed at cleanup outside this for-loop, and in this case a NULL
  check is performed.
  This will avoid the scenario of possibly double-freeing a pointer,
  in the case the 'DriveLayout' was previously freed (when e.g. reading
  the sector for checksum calculation failed), then the for-loop goes to
  the next disk and stops early.
2021-06-11 02:21:48 +02:00
Hermès Bélusca-Maïto fdd74eb97e
[NTOS:IO/FSTUB] Fix the determination of 'SingleDisk' in IoGetBootDiskInformation().
The purpose of 'SingleDisk' is the same as in the IopCreateArcNames()
function. It is an optimization for that when looking up the
firmware-recognized ARC disks list, in order to match one of these with
the current NT disk being analysed (see e.g. also in IopCreateArcNamesDisk()),
we avoid a possible IopVerifyDiskSignature() call and directly build a
corresponding ARC name NT symbolic link for it.

'SingleDisk' will actually be TRUE, whether the DiskSignatureListHead
list is empty or contains only one element: Indeed in only both these
cases, 'DiskSignatureListHead.Flink->Flink' will refer to the list head.
(If the list is empty but 'SingleDisk' is TRUE, this does not matter,
because the DiskSignatureListHead looking-up loop never starts.)
2021-06-11 02:21:47 +02:00
Hermès Bélusca-Maïto 99078646c3
[NTOS:IO] Avoid hardcoding variable types in sizeofs when possible. 2021-06-11 02:21:47 +02:00
Hermès Bélusca-Maïto 6e65e6b28d
[NTOS:IO] Minor code style fixes (typos; improve comments/DPRINT; IN vs. OUT parameter). 2021-06-11 02:21:47 +02:00
Jérôme Gardou afc27ab1aa [NTOS:MM] Handle PT references for page table faults in MmAccessFault
Idea from Timo Kreuzer
2021-06-09 11:27:18 +02:00
Jérôme Gardou c7e09061ca [NTOS:MM] Get rid of MiQueryPageTableReferences 2021-06-09 11:27:18 +02:00
Timo Kreuzer 6a2eeaa5ae [NTOS] Implement MiIsPageTablePresent as a replacement for the abused MiQueryPageTableReferences 2021-06-09 11:27:18 +02:00
Jérôme Gardou 678923bf4b [NTOS:MM] In MiMakePdeExistAndValid, do not overly check PDE validity
It's "okay" to not #ifdef, but it's useless and confusing.
2021-06-09 11:27:18 +02:00
Jérôme Gardou c8fb3f7514 [NTOS:MM] Implement proper refcounting of page tables on amd64
CORE-17552
2021-06-09 11:27:18 +02:00
Jérôme Gardou 3aa346c21f [NTOS:MM] Make MiIsEntireRangeCommitted 64-bits aware 2021-06-09 11:27:18 +02:00
Jérôme Gardou 8bfba59b3e [NTOS:MM] Add some DPRINTs when incrementing or decrementing PFN share count 2021-06-09 11:27:18 +02:00
Jérôme Gardou a80ae8f2ea [NTOS:MM] Make MiCalculatePageCommitment 64-bits aware 2021-06-09 11:27:18 +02:00
Jérôme Gardou b48e27ada1 [NTOS:MM] Add a few MiP*eToP*e helpers
And turn some of the existing ones into inline functions for the sake of type checking
2021-06-09 11:27:18 +02:00
Jérôme Gardou ed1038ff9c [NTOS:MM] Properly initialize initial process address space on amd64
By applying the same kludge on the relevant MMPFNs than on x86
2021-06-09 11:27:18 +02:00
Jérôme Gardou f9ea58dc97 [NTOS:MM] Unconditionally delete the PFN in MiDeletePte when PTE is in transition
When we will have a modified page writer, it will have to know if the written
page is stale when being done, and act accordingly.

CORE-8552
2021-06-09 11:27:18 +02:00
Jérôme Gardou 82dd1afe33 [NTOS:MM] Remove some dead code from legacy Mm 2021-06-09 11:27:18 +02:00
George Bișoc 7ca6bfb994
[NTOS:SE] Use IQS_NONE for the first class which is not existent and barely used 2021-06-08 09:26:11 +02:00
George Bișoc 672c9068bb
[NTOS:PS] Use IQS_NONE for classes that do not exist 2021-06-08 09:26:11 +02:00
George Bișoc bbdb4d6340
[NTOSKRNL] Use CHAR for non existent classes
An alignment of 1 means no alignment required and the class doesn't exist. 0 shouldn't be used for alignment requirement in IQS_NONE!
2021-06-08 09:25:30 +02:00
Jérôme Gardou a5ea259b28 [NTOS:MM] Fix remnants of CORE-17587 2021-06-07 17:04:18 +02:00
Jérôme Gardou 4ddc66f224 [NTOS:MM] Make MI_MAKE_HARDWARE_PTE_KERNEL actually respect the protection it is given
This one would set a page as writable & dirty even if MM_READONLY was passed
CORE-17587
2021-06-07 17:04:18 +02:00
George Bișoc a330b56787
[NTOS:PS] Enable alignment probing for thread/process information classes
In addition to that, here are some stuff done in this commit whilst testing:

- ICIF_QUERY_SIZE_VARIABLE and friends were badly misused, they should be used only when an information class whose information length size is dyanmic and not fixed. By removing such flags from erroneous classes, this fixes the STATUS_INFO_LENGTH_MISMATCH testcases.

- Use CHAR instead of UCHAR for classes that do not need alignment probing, as every other class in the table do, for the sake of consistency.

- ProcessEnableAlignmentFaultFixup uses BOOLEAN as type size, not CHAR. This fixes a testcase failure on ROS.

- Check for information length size before proceeding further on querying the process' cookie information.

- ProcessHandleTracing wants an alignment of a ULONG, not CHAR.

- Move PROCESS_LDT_INFORMATION and PROCESS_LDT_SIZE outside of NTOS_MODE_USER macro case. This fixes a compilation issue when enabling the alignment probing. My mistake of having them inside NTOS_MODE_USER case, sorry.

- On functions like NtQueryInformationThread and the Process equivalent, complete probing is not done at the beginning of the function, complete probing including if the buffer is writable alongside with datatype misalignment check that is. Instead such check is done on each information class case basis. With that said, we have to explicitly tell DefaultQueryInfoBufferCheck if we want a complete probing or not initially.
2021-06-06 17:14:22 +02:00
Timo Kreuzer 20c1da7963 [RTL][KMTEST] RtlPcToFileHeader doesn't handle user mode images in kernel mode 2021-06-05 14:39:29 +02:00
Timo Kreuzer 7f2e0ece5a [NTOS:KE/x64] Handle shared interrupts 2021-06-04 09:19:13 +02:00
Timo Kreuzer e8496b4fbf [NTOS:PS/x64] Fix PspGetOrSetContextKernelRoutine
It now uses KiSetTrapContext to set the non-volatile context on the stack and the volatile context in the trap frame.
2021-06-02 18:25:36 +02:00
Timo Kreuzer f1ed97d6cc [NTOS:KE/x64] Implement KiSetTrapContext
KiSetTrapContext is an asm wrapper around RtlSetUnwindContext, which first stores an exception frame to assure that all non-volatile registers were put on the stack, then calls RtlSetUnwindContext to update their first saving positions on the stack and finally restore the exception frame to potentially load any updated registers, that haven't been saved elsewhere on the stack.
2021-06-02 18:25:36 +02:00
George Bișoc 06b0d2e380
[NTOS:SE] Implement logon session deletion
And declare a prototype for SepCleanupLUIDDeviceMapDirectory and annotate it with SAL.
2021-06-02 11:09:01 +02:00
George Bișoc 3140dac3fe
[NTOS:SE] Do some cleanup on ICIF flags in token information classes
A few of these classes have fixed size lengths, the rest are arbitrary. Also the TokenAuditPolicy class hasn't a size length type specified in the table, which is wrong (and move the corresponding TOKEN_AUDIT_POLICY_INFORMATION structure into the private header).
2021-05-29 12:44:03 +02:00
Timo Kreuzer 90a0e426ed [NTOS:KE] Add IRQL checks and fix KiInitiateUserApc 2021-05-28 11:52:42 +02:00
Timo Kreuzer 3d18831c19 [NTOS:KE] Improve KiSystemCallEntry64 2021-05-28 11:52:42 +02:00
Timo Kreuzer 69e8cb635a [NTOS:KE] Fix stack alignment issues 2021-05-28 11:52:42 +02:00
Timo Kreuzer 2a2d0903bf [NTOS:KE] Remove duplicated EFlag definitions 2021-05-28 11:52:42 +02:00
Jérôme Gardou b0ebf68d98 [NTOS:IO] Be more specific for chasing CORE-17587
Addendum to 42ec1388d7
2021-05-26 11:03:34 +02:00
Jérôme Gardou 42ec1388d7 [NTOS:IO] Break on IoRaiseInformationalHardError
This one will eventually be reverted. For now, this will help debugging CORE-17587
2021-05-26 10:48:29 +02:00
Hervé Poussineau 831cad3410 [NTOS:MM] Remove wrong cleaning of PDEs at session cleanup 2021-05-25 21:13:32 +02:00
Hervé Poussineau 98882fb089 [NTOS:MM] Finish implementation of MmSessionDelete 2021-05-25 18:48:16 +02:00
Hervé Poussineau eac0afc6fe [NTOS:MM] MiDereferenceSession: return as soon as session is destroyed
This leads to some simplifications in the following code.
2021-05-25 18:48:16 +02:00
Timo Kreuzer dd08ae2c0f [NTOS:CC] Fix use of unintialized variable (caught by RTC1) 2021-05-24 22:00:11 +02:00
Timo Kreuzer 184d3a6849 [NTOS:MM] MiIsPdeForAddressValid is NOT an INIT function! 2021-05-24 18:45:47 +02:00
Jérôme Gardou 0395049986 [NTOS:KE] Do not call MmSetPageProtect for the Pentium Lock Errata
CORE-17589
2021-05-21 10:52:55 +02:00
Jérôme Gardou 7eff8a36d5 Revert "[NTOS:MM] Add private pages to process working sets"
This is so full of bugs, I don't know what to say.
This reverts commit 374fef2d59.
2021-05-20 00:19:43 +02:00
Jérôme Gardou 969e60a06d [NTOS:MM] Move software PTE specific check after it's been tested for being one
Caught by The_DarkFire, only soul on earth actually *running* our SMP kernel
2021-05-19 23:56:21 +02:00
Jérôme Gardou 7d0d14965e [NTOS:MM] Do not map Process Working Set List in kernel space
This is not needed anymore and causes havoc on amd64
2021-05-19 23:17:27 +02:00
Dmitry Borisov 2193031133 [NTOS:PO] Check for optional parameter in the completion routine
The CompletionFunction parameter is really optional.
This fixes a bugcheck caused by shutdown with IDE driver stack.

CORE-17401
2021-05-19 20:14:29 +02:00
Jérôme Gardou 826aec48de [NTOS:MM] Fix build on whatever MSVC version triggered this
There is no real need to put static or extern "C" function in a special namespace anyway
2021-05-19 00:12:05 +02:00
Jérôme Gardou 374fef2d59 [NTOS:MM] Add private pages to process working sets 2021-05-18 23:42:19 +02:00
Jérôme Gardou 6a5fd8f487 [NTOS:MM] Relax requirements with regards to PFN lock when adding & removing entries in Working Sets
Once a page is used, holding the WS lock is enough until you want to free it.
2021-05-18 23:42:19 +02:00
Jérôme Gardou aeffd16b38 [NTOS] Introduce KiQueuedSpinLockGuard, similar to std::lock_guard for Queued Spin lock
And use it in Mm as MiPfnLockGuard
2021-05-18 23:42:19 +02:00
George Bișoc 99d776894a
[NTOS:SE] Capture the groups length when creating a token
The groups length is already returned by SeCaptureSidAndAttributesArray, it doesn't make sense to not use it.
2021-05-16 17:18:29 +02:00