Commit graph

1128 commits

Author SHA1 Message Date
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
Jérôme Gardou 3adf450867 [REACTOS] Addendum to 5c7ce4475e - Fix MSVC 2015 build
Put data into PAGEDATA or INITDATA sections
Keep section declaration for prototypes

CORE-17540
2021-05-12 11:04:29 +02:00
Jérôme Gardou 04e9251612 [NTOS:PS] Use KD routine to safely read memory from thread stack
Should fix a crash when hitting TAB+(Whatever I typed that triggerred this)
2021-05-10 19:11:21 +02:00
George Bișoc f5dc1c77b5
[NDK][NTOS:SE] Add the missing "LogonSession" member to TOKEN structure
And also fix the wrong member offsets in comments. The said offset values are based upon the ones retrieved with WinDBG.
2021-05-09 17:34:02 +02:00
George Bișoc 11f239373d
[NTOS:SE] Add further remarks in SeQueryInformationToken
Explicitly mention under remarks that some classes are not implemented for that function, for documentation purposes. No code changes.
2021-05-08 18:11:42 +02:00
Stanislav Motylkov 83dbb6b27e
[NTOS:PS] Do not leak the Thread. Addendum to 0c8f0785 2021-05-08 00:32:14 +03:00
Stanislav Motylkov 0c8f07854b
[NTOS:PS] Fix misplaced Thread variable reference caught by RTC
Addendum to 2e88e2b9.
2021-05-07 21:54:10 +03:00
Jérôme Gardou f421bccbcc [NTOS:MM] First shot for Working Set list support
- Initialize
- Add private page (no shared page support yet)
- Remove pages
- Trim

Yes, this is C++ in the kernel.
2021-05-04 12:02:41 +02:00
Jérôme Gardou 31afbf1054 [NTOS] Make some internal headers C++ aware 2021-05-04 12:02:41 +02:00
Jérôme Gardou 8df48f9876 [NTOS:MM] Introduce MI_IS_PROCESS_WORKING_SET helper function 2021-05-04 12:02:41 +02:00
Jérôme Gardou 6b2f05f9dd [NTOS:MM] Implement turning working set shared lock to exclusive 2021-05-04 12:02:41 +02:00
Jérôme Gardou cd085ac12f [NTOS/MM] Implement Mi(Un)lockWorkingSetShared
Also fix checks when exclusively locking
2021-05-04 12:02:41 +02:00
George Bișoc 5dd93a8a5b
[NTOS:SE] Get the session ID and assign it to the new token
SeExchangePrimaryToken doesn't assign the session ID to the new token, which could lead to incorrect behaviour in the long run. Let's fix that.
2021-05-04 10:08:26 +02:00
George Bișoc 207543429b
[NTOSKRNL] Use IQS_SAME instead of ICI_SQ_SAME
And remove the redundant ICI_SQ_SAME macro as it's no longer needed in the codebase.
2021-05-02 21:00:51 +02:00
George Bișoc 74e527b452
[NTOS:PS] Bring the threads/processes information classes table back
These were removed in bf493b9, for whatever apparent reason. It's time to import them back.
2021-05-02 20:52:18 +02:00
George Bișoc 39b266b728
[NTOSKRNL] Move the ICIF related code and stuff into a separate header file
For easier accessibility for the APITESTs and whatnot.
2021-05-02 20:49:06 +02:00
George Bișoc 242efae9a2
[NTOS:PS] Make sure we can impersonate the given token first
PsImpersonateClient blindly impersonates the requested client even though it doesn't know if the actual token given to the call can be impersonated for the thread of the client which we are going to begin impersonation. In the case where impersonation is not possible, make a copy of the given token and assign the newly one for impersonation instead.
CORE-17539
2021-05-02 16:55:20 +02:00
George Bișoc 18ddb6ba92
[NTOS:SE] Implement SeTokenCanImpersonate routine
SeTokenCanImpersonate ensures whether the client impersonation can occur, and if not, the call signals this to the caller.
2021-05-02 16:55:19 +02:00
Eric Kohl a7d6483e65 [NTOS:PS] Revert 4d7062abb6 on request 2021-05-02 16:26:11 +02:00
Eric Kohl 9fa31e0f9b [NTOS:PS] Add the missing privilege check to NtSetInformationThread:ThreadPriority
This fixes the remaining failure in the NtSetInformationThread test.
2021-05-02 15:28:26 +02:00