https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a49732e5b650bef2c0512…
commit a49732e5b650bef2c051260e78228e0eefa62b67
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Mon Jan 9 20:42:11 2023 +0100
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Thu Mar 9 18:59:16 2023 +0100
[NTOS:KD] KdpDebugLogInit: Fix ZwCreateFile flags for appending to debug logging
file.
However, ReactOS currently doesn't handle FILE_APPEND_DATA correctly,
so temporarily add a hack for fixing its support.
CORE-18789
---
ntoskrnl/kd/kdio.c | 38 ++++++++++++++++++++++++++++++++++++--
1 file changed, 36 insertions(+), 2 deletions(-)
diff --git a/ntoskrnl/kd/kdio.c b/ntoskrnl/kd/kdio.c
index c186e60752d..742121e08fb 100644
--- a/ntoskrnl/kd/kdio.c
+++ b/ntoskrnl/kd/kdio.c
@@ -272,8 +272,9 @@ KdpDebugLogInit(
NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ,
- FILE_SUPERSEDE,
- FILE_WRITE_THROUGH | FILE_SYNCHRONOUS_IO_NONALERT,
+ FILE_OPEN_IF,
+ FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT |
+ FILE_SEQUENTIAL_ONLY | FILE_WRITE_THROUGH,
NULL,
0);
@@ -285,6 +286,39 @@ KdpDebugLogInit(
return;
}
+ /** HACK for FILE_APPEND_DATA **
+ ** Remove once CORE-18789 is fixed. **
+ ** Enforce to go to the end of file **/
+ {
+ FILE_STANDARD_INFORMATION FileInfo;
+ FILE_POSITION_INFORMATION FilePosInfo;
+
+ Status = ZwQueryInformationFile(KdpLogFileHandle,
+ &Iosb,
+ &FileInfo,
+ sizeof(FileInfo),
+ FileStandardInformation);
+ DPRINT("Status: 0x%08lx - EOF offset: %I64d\n",
+ Status, FileInfo.EndOfFile.QuadPart);
+
+ Status = ZwQueryInformationFile(KdpLogFileHandle,
+ &Iosb,
+ &FilePosInfo,
+ sizeof(FilePosInfo),
+ FilePositionInformation);
+ DPRINT("Status: 0x%08lx - Position: %I64d\n",
+ Status, FilePosInfo.CurrentByteOffset.QuadPart);
+
+ FilePosInfo.CurrentByteOffset.QuadPart = FileInfo.EndOfFile.QuadPart;
+ Status = ZwSetInformationFile(KdpLogFileHandle,
+ &Iosb,
+ &FilePosInfo,
+ sizeof(FilePosInfo),
+ FilePositionInformation);
+ DPRINT("ZwSetInformationFile(FilePositionInfo) returned:
0x%08lx\n", Status);
+ }
+ /** END OF HACK **/
+
KeInitializeEvent(&KdpLoggerThreadEvent, SynchronizationEvent, TRUE);
/* Create the logger thread */