Commit graph

1106 commits

Author SHA1 Message Date
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
Eric Kohl 4d7062abb6 [NTOS:PS] Add ThreadInformation probing to NtSetInformationThread
Also get rid of unused buffer check code.
This fixes two test failures.
2021-05-02 13:55:29 +02:00
Eric Kohl 2e88e2b904 [NTOS:PS] Rewrite NtSetInformationThread to match NtQueryInformationThread
The Information length must always be checked before referencing the thread object. This fixes a test failure.
2021-05-02 13:46:22 +02:00
Eric Kohl 5585767460 [NTOS:PS] Rewrite NtQueryInformationThread to match NtQueryInformationProcess
The information length must always be checked before referencing the thread object. This fixes the remaining test failure.
2021-05-02 12:46:55 +02:00
Serge Gautherie 249f2388bd
[REACTOS] Fix parameter types on some exports (#3217)
Fix some wrong parameter types on some exports in NTDLL, KERNEL32, WTSAPI32, and NTOSKRNL.
2021-05-01 21:11:34 +02:00
Serge Gautherie 5d89643311 [NTOS:OB] ObQueryDeviceMapInformation(): Fix annotations 2021-05-01 11:26:07 +02:00
Serge Gautherie 8a61e4f08c [NTOS:PS] NtQueryInformationProcess(): Fix ProcessDeviceMap case
Fix Clang-Cl
'...\ntoskrnl\ps\query.c(583,33): warning: variable 'Status' is uninitialized when used here [-Wuninitialized]'

Addendum to 1074a9a.
2021-04-29 21:40:58 +02:00
Serge Gautherie c0961cac10 [NTOS:PS] NtQueryInformationProcess(): Sync' annotations 2021-04-29 21:40:58 +02:00
Jérôme Gardou b97d5fd2f7 [NTOS:KDBG] Fix invalid DBG print 2021-04-28 15:58:01 +02:00
Jérôme Gardou 3726b992ed [NTOS:KDBG] Begin port for amd64.
Not really functional, but it prints debug output.
Take this as an opportunity to add consistancy between some i386 & amd64 intrinsics
2021-04-28 13:10:23 +02:00
Jérôme Gardou 5e29e98f91 [NTOS:KE] Explicitly use sysretq instruction 2021-04-28 13:10:23 +02:00
Jérôme Gardou 662774bca3 [NTOS] Do not force-align an integer value 2021-04-28 13:10:23 +02:00
George Bișoc 44fb528fcc
[NTOS:SE] Implement the NtImpersonateAnonymousToken system call
Implement SepImpersonateAnonymousToken private helpers, which is necessary for the complete implementation of NtImpersonateAnonymousToken function and thus finally we're able to impersonate the anonymous logon token.
2021-04-27 12:25:03 +02:00
George Bișoc 12c69e6d63
[NTOS:SE] Add the declaration prototype of SepRegQueryHelper in the internal header 2021-04-27 12:25:03 +02:00
George Bișoc b68216e503
[NTOS:SE] Annotate the function parameters of SepRegQueryHelper with SAL
And add a documentation comment header
2021-04-27 12:25:03 +02:00
George Bișoc f9c603db6e
[NTOS:OB] Do not close the handle if it's granted access to ObpAccessProtectCloseBit
As of now the Object Manager private service, ObpCloseHandleTableEntry, looks for OBJ_PROTECT_CLOSE attribute if a handle should not be closed. However, in ObDuplicateObject if an attribute of OBJ_PROTECT_CLOSE is found as it's been filled to the caller (see L2466) this attribute is removed from the attributes list of the new handle and ObpAccessProtectCloseBit access is granted to the newly duplicated object handle.

With that being said ObpCloseHandleTableEntry indiscriminately closes the object handle albeit it shouldn't do so. As a matter of fact in Windows Server 2003 SP2 this service indeed checks for ObpAccessProtectCloseBit flag bit and if the condition is met then it returns STATUS_HANDLE_NOT_CLOSABLE as it should. Therefore we should do the same.

Now NtClose can properly warn the calling thread the object handle can't be closed which fixes a testcase failure within NtDuplicateObject NTDLL APITEST where this function gives handle close protection bit as requested by the caller.
2021-04-26 19:36:38 +02:00
Serge Gautherie 710acab83d [NTOS:MM] MiSetPagingOfDriver(): Add an explicit #if around unreachable code 2021-04-26 10:27:20 +02:00
George Bișoc 3d8dd932b1
[NTOS:SE] Lock the token in SeQueryInformationToken and do some cleanup
* Guard the token in a lock whilst querying stuff
* Remove the piece of code that checks if the information class provided is above the maximum information class threshold. That code literally duplicates the inner functionality of the default case in the switch block, where the code falls in that case if an invalid information class is provided anyway.
* Remove the redundant information classes. Internally, this function in Windows has 12 switch case blocks (11 token info classes + the default case) and the other classes are supported in NtQueryInformationToken only so it doesn't make any logical sense to keep them in the codebase.
* Annotate the argument parameters with SAL and add documentation header
2021-04-18 13:56:37 +02:00
Hermès Bélusca-Maïto 3ad573f92f
[NTOS:KE] Both KeFindConfigurationEntry() and KeFindConfigurationNextEntry() functions are exported by NTOSKRNL, so they definitively must NOT be in the discardable INIT section!!
Noticed while reviewing c7d1ff4a.
2021-04-10 00:43:52 +02:00
Victor Perevertkin f3e1697c2b
[NDK] DATA_SEG requires an extra #pragma on MSVC 2021-04-09 04:38:35 +03:00
Jérôme Gardou c48580135d [NTOS:MM] Fix a bit page fault handler with regard to COW sections 2021-04-08 15:40:37 +02:00
Jérôme Gardou a34d9bcfb6 [NTOS:MM] Share "page.c" between i386 & amd64 builds 2021-04-08 15:40:37 +02:00
Jérôme Gardou 7ea8312617 [NTOS:MM] Split MmCreateProcessAddressSpace in two parts
Generic one and arch-specific one.
Properly fail if we are out of resources.
Restore a lost assert.
2021-04-08 15:40:37 +02:00