Commit graph

84078 commits

Author SHA1 Message Date
George Bișoc dd54cd32cf
[NTDLL_WINETEST] Enable registry tests for KeyCachedInformation back 2023-10-01 20:06:03 +02:00
George Bișoc c0ea1f96ef
[NTOS:CM][DOCUMENTATION] Provide documentation for newly added functions 2023-10-01 20:06:03 +02:00
George Bișoc f4de5ceb9e
[NTOS:CM] Implement cache lookup and cleanup subkey information for cache consistency
During an open or create procedure of a registry key, the registry parser grabs
a key control block (KCB) from the parser object and uses its information to do the
necessary work in order to obtain a pointer to the newly created or opened registry key.

However, the registry parsers faces several issues. First, we don't do subkey cache cleaning
information against gathered KCBs so whenever we do a registry parse we end up with KCBs
that have cache inconsistencies. Moreover we don't do any locking of whatever KCB we
are grabing during a parse procedure.

=== PROPOSED CHANGES ===

* Implement CmpComputeHashValue and CmpLookInCache functions. With CmpComputeHashValue we can
compute the convkey hashes of each subkey in the path name of a key so we can lock them
with CmpBuildAndLockKcbArray. CmpLookInCache is a function that searches for the suitable
KCB in the cache. The factors that determine if a KCB is "suitable" are:

-- the currently found KCB in the hash list has the same levels as that of the
given KCB from the parse object;

-- The key names from the computed hash values match with the block name of
the KCB;

-- The currently found KCB is not deleted.

The KCB will be changed if the key path name points to a partial match name in
the cache. The KCB from the parse object will be used if we have a full match
of remaining levels.

* Add missing CMP_LOCK_HASHES_FOR_KCB flags on CmpCreateKeyControlBlock calls
that create KCBs during a parse procedure. Such lock has to be preserved until
we're done with the registry parsing.

* On CmpDoCreateChild, preserve the exclusive lock of the KCB when we are
enlisting the key body.

* On CmpDoCreate, make sure that the passed parent KCB is locked exclusively and
lock the hiver flusher as we don't want the flusher to kick in during a key
creation on the given hive. Cleanup the subkey info when we're creating a key
object. Also implement missing cleanup path codes. Furthermore, avoid key
object creation if the parent KCB is protected with a read-only switch.

* Soft rewrite the CmpDoOpen function, namely how we manage a direct open vs
create KCB on open scenario. When a KCB is found in cache avoid touching
the key node. If the symbolic link has been resolved (aka found) then lock
exclusively the symbolic KCB. Otherwise just give the cached KCB to the caller.

If it were for the caller to request a KCB creation, we must check the passed
KCB from the parser object is locked exclusively, unlike on the case above
the caller doesn't want to create a KCB because there's already one in the cache.
We don't want anybody to touch our KCB while we are still toying with it during
its birth. Furthermore, enlist the key body but mind the kind of lock it's been
used.

* On CmpCreateLinkNode, avoid creating a key object if the parent KCB is protected
with a read-only switch. In addition, add missing hive flusher locks for both
the target hive and its child. Cleanup the subkey information of the KCB when
creating a link node, this ensures our cached KCB data remains consistent.

* Do a direct open on CmpParseKey if no remaining subkey levels have been found
during hash computation and cache lookup, in this case the given KCB is the
block that points to the exact key. This happens when for example someone tried
to call RegOpenKeyExW but submitting NULL to the lpSubKey argument parameter.

CORE-10581
ROSTESTS-198
2023-10-01 20:06:02 +02:00
George Bișoc 8cb56e77a6
[NTOS:CM] Do not call CmpSecurityMethod when assigning a security descriptor
CmpSecurityMethod is a method used by the Object Manager and called by this
subsystem whenever a security operation has to be done against a key object.

As CmpSecurityMethod is a specific OB construct we should not make any direct
call attempts to CmpSecurityMethod, only OB is responsible for that. This fixes
a deadlock where CmpSecurityMethod acquires a push lock for exclusive access
even though such lock is already acquired by the same calling thread in
CmpDoCreateChild.
2023-10-01 20:06:02 +02:00
George Bișoc 7fd6f86803
[NTOS:CM] Do not acquire a KCB lock twice when deleting a key object
This prevents a deadlock in DelistKeyBodyFromKCB when we delete a key
object because of an access check failure during a open procedure of a
registry key, as we are already holding a lock against the target KCB of
the key body.
2023-10-01 20:06:02 +02:00
George Bișoc 697a52aa33
[NTOS:CM] Do not acquire the lock twice when the Object Manager calls CmpSecurityMethod
Whenever a security request is invoked into a key object, such as when requesting
information from its security descriptor, the Object Manager will execute
the CmpSecurityMethod method to do the job.

The problem is that CmpSecurityMethod is not aware if the key control block
of the key body already has a lock acquired which means the function will attempt
to acquire a lock again, leading to a deadlock. This happens if the same
calling thread locks the KCB but it also wants to acquire security information
with ObCheckObjectAccess in CmpDoOpen.

Windows has a hack in CmpSecurityMethod where the passed KCB pointer is ORed
with a bitfield mask to avoid locking in all cases. This is ugly because it negates
every thread to acquire a lock if at least one has it.
2023-10-01 20:06:02 +02:00
George Bișoc 08fcf0c58b
[NTOS:CM] Implement locking/unlocking of KCBs in an array
The CmpUnLockKcbArray, CmpLockKcbArray and CmpBuildAndLockKcbArray routines
help us to lock KCBs within array so that information remains consistent when
we are doing a cache lookup during a parse procedure of the registry database.
2023-10-01 20:06:01 +02:00
George Bișoc c6230ba255
[NTOS:CM] Add KCB array lock function prototypes & Other Stuff
Implement CmpBuildAndLockKcbArray and CmpUnLockKcbArray prototypes, we'll gonna need these
to do the locking/unlocking of KCBs stacked up in an array. In addition implement some CM
constructs specifically for cache lookup implementation (more at documentation remarks).

=== DOCUMENTATION REMARKS ===

CMP_SUBKEY_LEVELS_DEPTH_LIMIT -- This is the limit of up to 32 subkey levels
that the registry can permit. This is used in CmpComputeHashValue to ensure
that we don't compute more than the limit of subkeys we're allowed to.

CMP_KCBS_IN_ARRAY_LIMIT -- This is equal to CMP_SUBKEY_LEVELS_DEPTH_LIMIT
plus the addition by 2. This construct is used as a limit of KCB elements
the array can hold. 2 serves as an additional space for the array (one for
the root object and another one as extra space so we don't blow up the stack
array).

CMP_LOCK_KCB_ARRAY_EXCLUSIVE & CMP_LOCK_KCB_ARRAY_SHARED -- These flags are used exclusively
for CmpBuildAndLockKcbArray and CmpLockKcbArray. Their meaning are obvious.

CM_HASH_CACHE_STACK -- A structure used to store the hashes of KCBs for locking. It is named
"stack" because the way we store the hashes of KCBs is within an auxilliary "outer stack array".
2023-10-01 20:06:01 +02:00
George Bișoc 8a335a3141
[NTOS:CM] Implement the shared lock macro for use
CmpAcquireKcbLockSharedByKey can come in handy for use to lock KCBs by their convkey with a shared lock, specifically we would need this for cache lookup stuff.
2023-10-01 20:06:00 +02:00
George Bișoc 26fe3616fe
[NTOS:CM] Implement COMPUTE_HASH_CHAR macro definition
Wrap the hash computation formula in a macro so that we don't have to copy
the logic over the places again and again.
2023-10-01 20:06:00 +02:00
George Bișoc a4213d491d
[NTOS:CM] Add surrounding parentheses to GET_HASH_INDEX definition 2023-10-01 20:05:57 +02:00
Timo Kreuzer 0e68e27ff6 [WINSPOOL] Add a number of missing NULL checks. 2023-10-01 13:05:51 +03:00
Timo Kreuzer 02df49ebd8 [WINSPOOL] Properly copy the DEVMODE in IntFixUpDevModeNames
Otherwise the size isn't set up correctly, leading to a crash.
Fixes crash in comdl32_winetest printdlg.
2023-10-01 13:05:51 +03:00
Joachim Henze 8c76870639 [NTOS:MM] Fix missing \n in unimplemented codepath DPRINT
We can hit that unimplemented code-path-line in NtQuerySection()
when browsing youtube.com with Chromium 49.
2023-09-30 19:06:30 +02:00
Katayama Hirofumi MZ 945ee4b2a4
[MSPAINT] Larger/smaller Rubber/AirBrush on Ctrl+Plus/Minus (#5740)
- Enable changing rubber/airbrush thickness by Ctrl+Plus / Ctrl+Minus
  key combination in TOOL_AIRBRUSH and TOOL_RUBBER.
CORE-19094
2023-09-28 21:54:32 +09:00
Katayama Hirofumi MZ 8a4787b384
[MSPAINT] Larger/smaller brush nib on Ctrl+Plus/Minus (#5739)
- Introduce the concept of "brush width" to the
  tools model.
- Enable changing the brush width by Ctrl+Plus/Minus
  key combination in TOOL_BRUSH.
- Re-define brush styles.
CORE-19094
2023-09-28 21:30:34 +09:00
Serge Gautherie c84b5007d0
[NTOS:CM] Simplify CmpDelayAllocBucketLock code a bit (#5729)
- Remove duplicate CmpDelayAllocBucketLock definition.
- Remove an else.
2023-09-28 11:39:13 +02:00
Katayama Hirofumi MZ f2a012240f
[MSPAINT] Larger/smaller pen nib on Ctrl+Plus/Minus (#5738)
- Introduce the concept of pen width (not line width) to the tools model.
- Enable changing pen/line width by Ctrl+Plus/Minus key combination in TOOL_PEN,
  TOOL_LINE, TOOL_BEZIER, TOOL_RECT, TOOL_SHAPE, TOO_ELLIPSE, and
  TOOL_RRECT tools.
CORE-19094
2023-09-28 16:32:36 +09:00
Katayama Hirofumi MZ cbc63d876c
[MSPAINT] "Selection Clone" and "Selection Brush" (#5734)
- Stamp the image of the selection when the user clicks on
  the selection while holding down the Ctrl key.
- Draw the image of the selection continuously when the user
  starts dragging the selection while holding down the Shift key.
CORE-19094
2023-09-28 07:34:25 +09:00
Timo Kreuzer 03283371c1 [NTOS/Mm] Fix SWAPENTRY bit-check in MmCreatePageFileMapping
Test for the highest bit, not for bit 3 / 7.
2023-09-28 01:19:47 +03:00
Joachim Henze 058b746bbe [SHELL32] *.rc: AGAIN! Use 1996 as birth year in IDD_ABOUT for consistency
We do use the birth year 1996 instead of 1998
within our msgina pictures already,
and also within the [SDK] for autogenerated file-info.

Since SHELL32 IDD_ABOUT is used by many applications it makes sense to harmonize with that.

Was done already during 0.4.15-dev for SHELL32, but we have to do it again,
since some recent translation PRs to match the en-US.rc again.
2023-09-27 22:23:31 +02:00
Joachim Henze 29c0e23fd4
[MAZESCR] Avoid (DLGPROC) cast, fix a typo (#5694)
May help a bit with x64.

Co-authored-by: Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
2023-09-27 17:37:44 +00:00
Joachim Henze e69d2e8b89
[CMICONTROL] Fix MSVC 14.2 dbg x64 warning C4267 (#5696)
Can be observed on the buildbots:
2023-09-17T14:19:34.2051345Z [10663/14808] Building CXX object drivers\wdm\audio\drivers\CMIDriver\cmicontrol\CMakeFiles\cmicontrol.dir\main.cpp.obj
2023-09-17T14:19:34.2052611Z D:\a\reactos\reactos\src\drivers\wdm\audio\drivers\CMIDriver\cmicontrol\main.cpp(818): warning C4267: '=': conversion from 'size_t' to 'unsigned int', possible loss of data
2023-09-27 17:34:32 +00:00
Serge Gautherie 9ca88bef80
[NTOS:MM] Fix 'eanbled' typo in a comment (#5728) 2023-09-27 17:31:42 +00:00
Timo Kreuzer 8227c5d380 [NTOS] Implement support for opting out of NX policy
Fixes crash in ntdll_winetest info on x64.
2023-09-26 18:04:19 +03:00
Timo Kreuzer 6133cc016d [CRT/x64] Fix a bug in __C_specific_handler
Fixes crash of compiler_apitest pseh
2023-09-26 18:02:21 +03:00
Timo Kreuzer cf4aa7ea9d [LSASRV] Fix usage of self-relative security descriptor in LsarQuerySecurityObject 2023-09-26 18:01:45 +03:00
Timo Kreuzer 5127433416 [SAMSRV] Fix usage of self-relative security descriptor in SamrQuerySecurityObject
Fixes crash of netapi32_winetest access
2023-09-26 18:01:45 +03:00
Timo Kreuzer df053d4e43 [RTL] Improve usage of absolte vs self-relative security descriptors
- RtlpQuerySecurityDescriptor: Change argument type of first parameter from PISECURITY_DESCRIPTOR to PSECURITY_DESCRIPTOR, since it handles both absolute and self-relative SDs.
- RtlMakeSelfRelativeSD: rename first parameter from AbsoluteSD to SecurityDescriptor, since it handles both absolute and self-relative SDs.
- SepGetGroupFromDescriptor/SepGetOwnerFromDescriptor/SepGetDaclFromDescriptor/SepGetSaclFromDescriptor: Change parameter type from PVOID to PSECURITY_DESCRIPTOR for clarity.
2023-09-26 18:01:45 +03:00
Katayama Hirofumi MZ 389d04650f
[MSPAINT] Restrict drawing direction on Shift key (#5726)
- While holding down the Shift key, drawing lines with the
  pen/brush is limited to either of 8 directions (horizontal/vertical/diagonal).
- s/abs/labs/
CORE-19094
2023-09-26 22:47:23 +09:00
Katayama Hirofumi MZ d1e9fe13de
[SHELL32][SDK] Implement SHTestTokenPrivilegeW (#5725)
and modify shell32.spec.
2023-09-26 07:36:07 +09:00
Doug Lyons 1b3eed58ca
[SHELL32] Fix for shlexec.cpp regressions (#5282)
fixes CORE-18967 'Taskbar toolbar - Right click > Open folder fails'
by restoring the code-path we removed with the guilty 
0.4.15-dev-3847-g /9b716539182864bc077e362febcda74da50287ed 

and add test_sei_lpIDList to shell32:ShellExecuteEx apitest test to protect
that functionality on future attempts to simplify.
2023-09-24 20:35:28 +00:00
Katayama Hirofumi MZ cc6e444ceb
[SHELL32][SDK] Implement SHInvokePrivilegedFunctionW (#5718)
Add it to <undocshell.h>. Modify shell32.spec.
2023-09-24 07:11:38 +09:00
Timo Kreuzer ed06c06dcb [NTOS:CM] Fix lock leak
Triggered by low available pool memory during kmtest ExPools.
2023-09-23 18:34:00 +03:00
Andrew Dent aa84645bcc [THEMES] Optimize png for Lautus style (#5712)
Lossless optimization of new png Start button in Lautus style, original by @Splitwirez (ed134bf2, #5540).
Slimmed 464 bytes, ~20% saving. This png is encoded as a grayscale+alpha, so should be tested.
2023-09-23 15:54:39 +03:00
Timo Kreuzer 88808bad8a [RPCRT4] Fix x64 assembly code
movaps is a 128 bit aligned move, we need a 64 bit unaligned move, so use movsd.
Fixes a crash in oleaut32_winetest tmarshal.
Also add a comment about the use of movd instead of movq.
2023-09-23 11:06:24 +03:00
Katayama Hirofumi MZ ed9973f876
[MSPAINT] Introduce Ctrl+Plus / Ctrl+Minus (#5717)
- Add Ctrl+Plus and Ctrl+Minus accelerators.
- Add IDM_CTRL_PLUS and IDM_CTRL_MINUS
  commands.
- Stretch the selection area on IDM_CTRL_PLUS
  and IDM_CTRL_MINUS actions.
CORE-19094
2023-09-23 09:26:11 +09:00
Katayama Hirofumi MZ bbb33a6ed5
[MSPAINT] Don't show error message twice (#5715)
- Reduce display of error message on IDM_EDITCOPYTO and IDM_EDITPASTEFROM.
- Introduce LockBitmap/UnlockBitmap mechanism for ImageModel and SelectionModel.
CORE-19181, CORE-19182
2023-09-22 10:48:13 +09:00
Katayama Hirofumi MZ 98050f9139
[MSPAINT] Don't copy bits on resizing (#5716)
- Fix the graphical glitches on resizing and moving toolbars.
- Add SWP_NOCOPYBITS flag on positioning controls on resizing of main window.
CORE-19137
2023-09-22 07:35:03 +09:00
Timo Kreuzer 4661bc006d [WIN32K] Prevent dereferencing NULL pointer
Initialize a window's ThreadListEntry as an empty list on creation and only remove the window from the list on destruction, when the entry is not an empty list. Previously the window creation could fail before the list entry was initialized and the window would get destroyed after that, resulting in a NULL pointer dereference.
2023-09-21 23:45:31 +03:00
Timo Kreuzer 41c99aa60a [KERNEL32] Fix RaiseException to correctly copy the passed in parameters as ULONG_PTR
Fixes C++ exception handling on x64.
2023-09-21 21:33:47 +03:00
Katayama Hirofumi MZ 4407e0aefa
[SHELL32][SDK] Implement SHOpenEffectiveToken and SHGetUserSessionId (#5713)
- Implement SHOpenEffectiveToken and
  SHGetUserSessionId functions.
- Add them to <undocshell.h>.
2023-09-21 22:44:20 +09:00
Hermès Bélusca-Maïto 4bdfee8e8b
[NTOS:EX] Initialize ExpResourceTimeoutCount also via the "Session Manager/ResourceTimeoutCount" registry value (#4089)
For more details, see
http://systemmanager.ru/win2k_regestry.en/29859.htm
https://www.betaarchive.com/wiki/index.php/Microsoft_KB_Archive/102985#ResourceTimeoutCount_REG_DWORD
2023-09-21 13:33:28 +02:00
Hermès Bélusca-Maïto 56417bfb93
[RTL] Satisfy the RtlpTimeoutDisable condition when waiting for critical sections (#4089) 2023-09-21 13:33:28 +02:00
Hermès Bélusca-Maïto dff55c9d33
[NTDLL][RTL] Move RtlpTimeoutDisable definition to the RTL (#4089) 2023-09-21 13:33:27 +02:00
Hermès Bélusca-Maïto 6f89a48349
[NTDLL:LDR] Fix process LoadConfig CS timeout conversion from ms to 100ns units (#4089)
For more details, see
https://forums.codeguru.com/showthread.php?370731-EnterCriticalSection-locking&p=1302399#post1302399
2023-09-21 13:33:26 +02:00
Hermès Bélusca-Maïto b5c75ce506
[NTOS:EX] Minor header formatting. 2023-09-21 13:33:25 +02:00
Hermès Bélusca-Maïto 903a3dc622
[NTDLL][RTL] Fix english typo in (internal) function name. 2023-09-21 13:33:18 +02:00
Oleg Dubinskiy f4d7cccd3c
[DXGTHK] Export DriverEntry (#5607)
Export driver entry point function DriverEntry from our dxgthk.sys,
following Windows behaviur. It is exported on XP SP3 and Server 2003.
2023-09-21 14:25:21 +03:00
Katayama Hirofumi MZ 539123c62f [SHELL32] SHChangeRegistrationReceive just returns FALSE 2023-09-21 12:09:28 +09:00