Commit graph

52 commits

Author SHA1 Message Date
Victor Perevertkin 34593d933b
[FORMATTING][NTOS][HAL][DRIVERS][SDK] Fix trailing spaces 2021-06-11 15:33:08 +03: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 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
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
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
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
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 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
George Bișoc a340ec1767
[NTOS:PS] Guard the quota in a spin lock (#3419)
Prior to acquiring a quota from the process and do whatever it's needed to do (charge it or return it back), we must guard ourselves with a spinlock so that we may not get into potential race conditions. In Windows Server 2003, PspGivebackQuota and PspExpandQuota do the same thing and they're the equivalent to PspReturnProcessQuotaSpecifiedPool and PspChargeProcessQuotaSpecifiedPool in our codebase.
2021-03-04 04:43:30 +03:00
George Bișoc 6170b574f0
[NTOS:PS] Implement PS_QUOTA_TYPE and let the quota code use it (#3389)
This will replace the PoolIndex variable and as such we'll only be using the PS_QUOTA_TYPE enumeration, as Windows does. Both QuotaEntry, QuotaUsage and QuotaPeak depend explicitly or implicitly on this enumeration. Further details about this enum can be found in the following articles.
https://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/ps/psquota/type.htm?tx=68,143
https://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/ps/psquota/block.htm?tx=68,142,143
https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/ps/eprocess/index.htm (see QuotaPeak and QuotaUsage)
2021-03-02 20:09:58 +01:00
Jérôme Gardou 073ec9b0d4 [NTOSKRNL][NDK] Get rid of SECTION_OBJECT typedef
We will use the more recent SECTION (already used in ARM3) and this will avoid confusions
2021-02-03 09:41:21 +01:00
Victor Perevertkin 5c7ce4475e
[REACTOS] Cleanup INIT and some PAGE section allocations
- Change INIT_FUNCTION and INIT_SECTION to CODE_SEG("INIT") and DATA_SEG("INIT") respectively
- Remove INIT_FUNCTION from function prototypes
- Remove alloc_text pragma calls as they are not needed anymore
2020-11-02 21:45:31 +03:00
Timo Kreuzer d74037b666 [NTOS:PS] Fix size handling in ProcessDeviceMap
If you want to know the details, browse history or use git blame.
2020-09-28 00:24:53 +02:00
Timo Kreuzer cb22d5f697 [NTOS:PS] On x64 don't fail in NtSetInformationProcess with ProcessUserModeIOPL information class, instead just don't do anything.
For NT6+ appcompat setting return STATUS_NOT_IMPLEMENTED
2020-09-20 23:08:17 +02:00
Nguyen Trung Khanh bc584bdf99
[NTOS:PS] Fix stack memory disclosure in PsGetContextThread #3024
Fix stack memory disclosure in PsGetContextThread.
2020-08-15 19:18:35 +09:00
Thomas Faber db180c29c7
[NTOS:SE] Implement job case in PsImpersonateClient. CORE-8787 2020-05-17 16:05:00 +02:00
Andrew Boyarshin b607e0119f [NTOSKRNL][PS] Implement NtQueueApcThreadEx and use it in NtQueueApcThread
Actually rename NtQueueApcThread to NtQueueApcThreadEx and ignore one additional parameter for now.
2019-08-15 12:32:09 +02:00
Bișoc George 42ce8519b6 [FASTFAT][FLTMGR][NTOS] Do not explicitly call ObfDereferenceObject() (#1636)
"Most code should not directly call the platform-specific ObfDereferenceObject() function but use the ObDereferenceObject() macro instead."

CORE-16081
2019-06-22 16:20:58 +02:00
Pierre Schweitzer ad80715b1a
[NTOSKRNL] Implement NtSetInformationProcess:ProcessDeviceMap 2019-06-10 10:35:24 +02:00
Pierre Schweitzer f8a4d31da4
[NTOSKRNL] On process primary token change, dereference device map 2019-06-02 10:00:17 +02:00
Pierre Schweitzer 445e895932
[NTOSKRNL] Simplify NtQueryInformationProcess:ProcessDeviceMap implementation 2019-06-01 17:40:23 +02:00
Pierre Schweitzer 1074a9aaff
[NTOSKRNL] Implement support for PROCESS_DEVICEMAP_INFORMATION_EX in NtQueryInformationProcess 2019-06-01 15:18:52 +02:00
Pierre Schweitzer b16a07fa69
[NTOSKRNL] Implement ObIsLUIDDeviceMapsEnabled and call it in NtQueryInformationProcess 2019-06-01 14:56:28 +02:00
Hervé Poussineau f7ec84eea0 [NTOS:KD] Remove some _WINDK_ usages
- Always include kd64.h
- Change KdpPrompt() prototype to be compatible between KDBG and _WINDK_
- Rename KdComponentTable to KdpComponentTable to prevent a conflict
- Add some functions stubs and global variables
2019-05-23 11:04:40 +02:00
Timo Kreuzer 8a4c5763da [NTOS:PS] Use NULL instead of 0 in ps/kill.c 2019-03-06 00:49:59 +01:00
Mark Jansen 5c05a29d3d
[APPHELP] Implement ShimDumpCache and ShimFlushCache
These functions simply call into the Base* functions,
having a prototype that is compatible with rundll32
CORE-11301
2019-02-25 20:00:34 +01:00
Thomas Faber e7de564bfc
[NTOS:MM] Implement big pool table expansion. CORE-15051 2019-01-09 08:18:38 +01:00
Pierre Schweitzer 47b48520b5
[NTOSKRNL] Reimplement !irpfind using !poolfind helpers
This allows avoiding one of the previous implementation limits:
leaked IRP not queued to a thread are now totally visible since
we look directly in the memory pool.
2019-01-06 12:49:57 +01:00
Pierre Schweitzer d6dc1fd231
[NTOSKRNL] Add a raw implementation of !irpfind in kdbg
This is far from perfect, and totally doesn't match the
WinDBG way of doing it. Instead of browsing pool to find
matching 'IRP' tags, we just browse all the processes
to find the queued IRP. This requires the IRPs to be queued,
obviously, and will make us miss the leaked IRPs, for instance.

Proper way to do it would be to implement !poolfind and then
rely on its implementation to find our IRPs.

Perhaps later ;-)
2019-01-01 22:00:56 +01:00
Pierre Schweitzer 1a93d83f92
[SDK] Add PsGetCurrentThreadTeb() to the DDK 2018-12-31 11:19:35 +01:00
Timo Kreuzer 71fefa32db
[NDK][NTOS] Add global definition of INIT_FUNCTION/INIT_SECTION (#779)
* Add an NDK header to define INIT_FUNCTION/INIT_SECTION globally
* Use _declspec(allocate(x)) and _declspec(code_seg(x)) on MSVC versions that support it
* Use INIT_FUNCTION on functions only and INIT_SECTION on data only (required by MSVC)
* Place INIT_FUNCTION before the return type (required by MSVC)
* Make sure declarations and implementations share the same modifiers (required by MSVC)
* Add a global linker option to suppress warnings about defined but unused INIT section
* Merge INIT section into .text in freeldr
2018-12-30 12:19:11 +01:00
Hermès Bélusca-Maïto 89c5191d3f
[NTOS:PS] In PspSetPrimaryToken(), check also for sibling token to determine whether it is required to have the SeAssignPrimaryTokenPrivilege.
In addition, it is the presence or absence of the 'Token' pointer that indicates whether or not we should use instead the provided token handle.
2018-09-28 00:45:03 +02:00
Timo Kreuzer 094a90ad4e [NTOS:PS] Fix an issue with PROCESS_DEVICEMAP_INFORMATION size on 64 bit builds
The PROCESS_DEVICEMAP_INFORMATION  union has 2 fields, one is a handle, the other one is a structure of 36 bytes (independent of architecture). The handle forces 64 bit alignment on 64 bit builds, making the structure 4 bytes bigger than on 32 bit builds. The site is checked in NtQueryInformationProcess (case ProcessDeviceMap). The expected size on x64 is the size of the Query structure without alignment. autocheck correctly passes the site of the Query union member, while smss passes the full size of PROCESS_DEVICEMAP_INFORMATION. Packing the structure is not an option, since it is defined in public headers without packing. Using the original headers sizeof(PROCESS_DEVICEMAP_INFORMATION) is 0x28, sizeof(PROCESS_DEVICEMAP_INFORMATION::Query) is 0x24.
2018-08-17 22:08:37 +02:00
Hermès Bélusca-Maïto 813879f02f
[NTOS:PS] Adjust the PsReferenceEffectiveToken() prototype in the header; add a comment about the fact that the ImpersonationLevel parameter can be left untouched on purpose in one special case. 2018-06-27 23:40:13 +02:00
Pierre Schweitzer f15afdbc43
[NTOSKRNL] Implement KeQueryValuesProcess().
And make use of it.
2018-05-25 21:40:39 +02:00
Pierre Schweitzer b0b7437882
[NTOSKRNL] Make NtSetInformationJobObject() success for JobObjectExtendedLimitInformation
This fixes pip from Python 2.7.9 starting in ReactOS.
Though it doesn't work due to TLS issues.
2018-05-25 08:48:51 +02:00
Pierre Schweitzer f300ca7245
[NTOSKRNL] Define required sizes with structures sizes 2018-05-25 08:48:51 +02:00
Pierre Schweitzer ffbd6995e6
[NTOSKRNL] Implement NtQueryInformationJobObject().
This is required by some Python2 applications
such as pip.exe
2018-05-25 08:48:51 +02:00
Hermès Bélusca-Maïto 3a0ecb3dc8
[NTOSKRNL] Don't hardcode flag values for DefaultHardErrorProcessing. 2018-04-01 22:50:16 +02:00
Pierre Schweitzer 62facb7a49
[NTOSKRNL] Implement ThreadHideFromDebugger in NtSetInformationThread() 2018-02-24 22:07:12 +01:00
Thomas Faber 5c52ded05f
[NTOS:PS] Check for rundown success in PsReferenceProcessFilePointer. CID 514553 2018-01-28 10:48:19 +01:00
Amine Khaldi 007131b5de [NTOS] Fix Shim AVL prototypes to exactly match the types expected by RtlInitializeGenericTableAvl. #179 2017-12-25 22:34:57 +01:00
Ivan Labutin 8723be733c [NTOS:PS] Skip backtrace on non-x86 2017-12-20 06:56:09 +01:00
Ivan Labutin d6792047f3 [NTOS][NDK][RTL] A bunch of 'wrong size' fixes 2017-12-20 06:56:09 +01:00