https://git.reactos.org/?p=reactos.git;a=commitdiff;h=79b0fce5dcfd11d1ecb68…
commit 79b0fce5dcfd11d1ecb6880929d3660a17b34b45
Author: Thomas Faber <thomas.faber(a)reactos.org>
AuthorDate: Tue Nov 1 20:10:04 2022 -0400
Commit: Thomas Faber <thomas.faber(a)reactos.org>
CommitDate: Sun Nov 20 16:02:39 2022 -0500
[NTOS:CM] Consistently use synchronous I/O for registry hives.
Our current CmpFileRead/CmpFileWrite do not wait for completion,
so will cause stack corruption if used on files opened in async
mode.
---
ntoskrnl/config/cminit.c | 14 ++++++++++----
ntoskrnl/config/cmwraprs.c | 12 ++++++++++++
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/ntoskrnl/config/cminit.c b/ntoskrnl/config/cminit.c
index 5d8ea072761..dd3a051e959 100644
--- a/ntoskrnl/config/cminit.c
+++ b/ntoskrnl/config/cminit.c
@@ -366,7 +366,10 @@ CmpOpenHiveFiles(IN PCUNICODE_STRING BaseName,
/* Default attributes */
AttributeFlags = FILE_ATTRIBUTE_NORMAL;
- /* Now create the file */
+ /* Now create the file.
+ * Note: We use FILE_SYNCHRONOUS_IO_NONALERT here to simplify CmpFileRead/CmpFileWrite.
+ * Windows does async I/O and therefore does not use this flag (or SYNCHRONIZE).
+ */
Status = ZwCreateFile(Primary,
DesiredAccess | SYNCHRONIZE,
&ObjectAttributes,
@@ -543,16 +546,19 @@ CmpOpenHiveFiles(IN PCUNICODE_STRING BaseName,
AttributeFlags |= FILE_ATTRIBUTE_HIDDEN;
}
- /* Now create the file */
+ /* Now create the file.
+ * Note: We use FILE_SYNCHRONOUS_IO_NONALERT here to simplify CmpFileRead/CmpFileWrite.
+ * Windows does async I/O and therefore does not use this flag (or SYNCHRONIZE).
+ */
Status = ZwCreateFile(Log,
- DesiredAccess,
+ DesiredAccess | SYNCHRONIZE,
&ObjectAttributes,
&IoStatusBlock,
NULL,
AttributeFlags,
ShareMode,
CreateDisposition,
- IoFlags,
+ FILE_SYNCHRONOUS_IO_NONALERT | IoFlags,
NULL,
0);
if ((NT_SUCCESS(Status)) && (MarkAsSystemHive))
diff --git a/ntoskrnl/config/cmwraprs.c b/ntoskrnl/config/cmwraprs.c
index 0f5e47da922..b23092e0cd9 100644
--- a/ntoskrnl/config/cmwraprs.c
+++ b/ntoskrnl/config/cmwraprs.c
@@ -89,6 +89,8 @@ CmpFileRead(IN PHHIVE RegistryHive,
_FileOffset.QuadPart = *FileOffset;
Status = ZwReadFile(HiveHandle, NULL, NULL, NULL, &IoStatusBlock,
Buffer, (ULONG)BufferLength, &_FileOffset, NULL);
+ /* We do synchronous I/O for simplicity - see CmpOpenHiveFiles. */
+ ASSERT(Status != STATUS_PENDING);
return NT_SUCCESS(Status) ? TRUE : FALSE;
}
@@ -117,6 +119,11 @@ CmpFileWrite(IN PHHIVE RegistryHive,
_FileOffset.QuadPart = *FileOffset;
Status = ZwWriteFile(HiveHandle, NULL, NULL, NULL, &IoStatusBlock,
Buffer, (ULONG)BufferLength, &_FileOffset, NULL);
+ /* We do synchronous I/O for simplicity - see CmpOpenHiveFiles.
+ * Windows optimizes here by starting an async write for each 64k chunk,
+ * then waiting for all writes to complete at once.
+ */
+ ASSERT(Status != STATUS_PENDING);
return NT_SUCCESS(Status) ? TRUE : FALSE;
}
@@ -178,5 +185,10 @@ CmpFileFlush(IN PHHIVE RegistryHive,
return TRUE;
Status = ZwFlushBuffersFile(HiveHandle, &IoStatusBlock);
+
+ /* This operation is always synchronous */
+ ASSERT(Status != STATUS_PENDING);
+ ASSERT(Status == IoStatusBlock.Status);
+
return NT_SUCCESS(Status) ? TRUE : FALSE;
}
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=685728bc248a3922644c0…
commit 685728bc248a3922644c0b7938fa86a236526077
Author: Jose Carlos Jesus <zecarlos1957(a)hotmail.com>
AuthorDate: Sun Nov 20 18:10:11 2022 +0000
Commit: GitHub <noreply(a)github.com>
CommitDate: Sun Nov 20 21:10:11 2022 +0300
[SHELL32] Prevent a second call to Drive Properties dialog (#4888)
CDefaultContextMenu::DoProperties provides a fallback call
to the property sheet testing the return value of the _DoCallback method,
which is ultimately the return value of SH_ShowDriveProperties().
SH_ShowDriveProperties() sometimes returns an HRESULT, however it is marked
as returning a BOOL. Then, DrivesContextMenuCallback() always handles this
result as an HRESULT.
Fix SH_ShowDriveProperties() to always return a BOOL as it is intended,
and in DrivesContextMenuCallback() handle the result accordingly.
CORE-18537
---
dll/win32/shell32/dialogs/drive.cpp | 2 +-
dll/win32/shell32/folders/CDrivesFolder.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dll/win32/shell32/dialogs/drive.cpp b/dll/win32/shell32/dialogs/drive.cpp
index 1a09a6ed712..ed57ccc9793 100644
--- a/dll/win32/shell32/dialogs/drive.cpp
+++ b/dll/win32/shell32/dialogs/drive.cpp
@@ -175,7 +175,7 @@ SH_ShowDriveProperties(WCHAR *pwszDrive, IDataObject *pDataObj)
CDataObjectHIDA cida(pDataObj);
if (FAILED_UNEXPECTEDLY(cida.hr()))
- return cida.hr();
+ return FAILED(cida.hr());
RECT rcPosition = {CW_USEDEFAULT, CW_USEDEFAULT, 0, 0};
POINT pt;
diff --git a/dll/win32/shell32/folders/CDrivesFolder.cpp b/dll/win32/shell32/folders/CDrivesFolder.cpp
index bf0dde7c9d6..565c1dc6052 100644
--- a/dll/win32/shell32/folders/CDrivesFolder.cpp
+++ b/dll/win32/shell32/folders/CDrivesFolder.cpp
@@ -345,7 +345,7 @@ HRESULT CALLBACK DrivesContextMenuCallback(IShellFolder *psf,
{
// pdtobj should be valid at this point!
ATLASSERT(pdtobj);
- hr = SH_ShowDriveProperties(wszBuf, pdtobj);
+ hr = SH_ShowDriveProperties(wszBuf, pdtobj) ? S_OK : E_UNEXPECTED;
if (FAILED(hr))
{
dwError = ERROR_CAN_NOT_COMPLETE;
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c093d4f8038e7ddec1ca1…
commit c093d4f8038e7ddec1ca193edc573c48e12f12ff
Author: Jose Carlos Jesus <zecarlos1957(a)hotmail.com>
AuthorDate: Sun Nov 20 17:22:30 2022 +0000
Commit: GitHub <noreply(a)github.com>
CommitDate: Sun Nov 20 20:22:30 2022 +0300
[TASKMGR] Prevent context menu on idle process (#4889)
In Win2K3, there is no context menu on the System Idle Process.
CORE-18640
---
base/applications/taskmgr/procpage.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/base/applications/taskmgr/procpage.c b/base/applications/taskmgr/procpage.c
index e916cae8ee0..dd2825d2c91 100644
--- a/base/applications/taskmgr/procpage.c
+++ b/base/applications/taskmgr/procpage.c
@@ -400,6 +400,9 @@ void ProcessPageShowContextMenu(DWORD dwProcessId)
DWORD dwDebuggerSize;
HKEY hKey;
+ if (dwProcessId == 0)
+ return;
+
memset(&si, 0, sizeof(SYSTEM_INFO));
GetCursorPos(&pt);