https://git.reactos.org/?p=reactos.git;a=commitdiff;h=334ab0f2a5f547118e7a8f63291a69ffaac88101

commit 334ab0f2a5f547118e7a8f63291a69ffaac88101
Author:     Oleg Dubinskiy <[email protected]>
AuthorDate: Wed Oct 20 01:22:29 2021 +0300
Commit:     George BiČ™oc <[email protected]>
CommitDate: Sat Oct 23 16:19:22 2021 +0200

    [KERNEL32] Implement SetFileCompletionNotificationModes
    Call native Nt* function to do the actual work, similarly to as it done in 
Wine: 
https://source.winehq.org/git/wine.git/blob/530c1839603bd3caa1b9d17fe458b5bd341ccfc9:/dlls/kernel32/file.c#l258.
    Also add/fix some declarations in internal kernel32/public ndk neaders, to 
fix compilation.
    CORE-17821
---
 dll/win32/kernel32/client/file/iocompl.c | 25 +++++++++++++++++++++----
 dll/win32/kernel32/k32.h                 |  1 +
 sdk/include/ndk/iotypes.h                |  7 ++++++-
 3 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/dll/win32/kernel32/client/file/iocompl.c 
b/dll/win32/kernel32/client/file/iocompl.c
index 656ffd93d6d..0d2546be50d 100644
--- a/dll/win32/kernel32/client/file/iocompl.c
+++ b/dll/win32/kernel32/client/file/iocompl.c
@@ -3,7 +3,8 @@
  * PROJECT:         ReactOS system libraries
  * FILE:            dll/win32/kernel32/client/file/iocompl.c
  * PURPOSE:         Io Completion functions
- * PROGRAMMER:      Ariadne ( [email protected])
+ * PROGRAMMERS:     Ariadne ([email protected])
+ *                  Oleg Dubinskiy ([email protected])
  * UPDATE HISTORY:
  *                  Created 01/11/98
  */
@@ -23,21 +24,37 @@
 #endif
 
 /*
- * @unimplemented
+ * @implemented
  */
 BOOL
 WINAPI
 SetFileCompletionNotificationModes(IN HANDLE FileHandle,
                                    IN UCHAR Flags)
 {
+    NTSTATUS Status;
+    FILE_IO_COMPLETION_NOTIFICATION_INFORMATION FileInformation;
+    IO_STATUS_BLOCK IoStatusBlock;
+
     if (Flags & ~(FILE_SKIP_COMPLETION_PORT_ON_SUCCESS | 
FILE_SKIP_SET_EVENT_ON_HANDLE))
     {
         SetLastError(ERROR_INVALID_PARAMETER);
         return FALSE;
     }
 
-    UNIMPLEMENTED;
-    return FALSE;
+    FileInformation.Flags = Flags;
+
+    Status = NtSetInformationFile(FileHandle,
+                                  &IoStatusBlock,
+                                  &FileInformation,
+                                  sizeof(FileInformation),
+                                  FileIoCompletionNotificationInformation);
+    if (!NT_SUCCESS(Status))
+    {
+        BaseSetLastNTError(Status);
+        return FALSE;
+    }
+
+    return TRUE;
 }
 
 /*
diff --git a/dll/win32/kernel32/k32.h b/dll/win32/kernel32/k32.h
index 604953680d7..ec2543a4f00 100644
--- a/dll/win32/kernel32/k32.h
+++ b/dll/win32/kernel32/k32.h
@@ -35,6 +35,7 @@
 #include <ndk/cmfuncs.h>
 #include <ndk/exfuncs.h>
 #include <ndk/iofuncs.h>
+#include <ndk/iotypes.h>
 #include <ndk/kdtypes.h>
 #include <ndk/kefuncs.h>
 #include <ndk/ldrfuncs.h>
diff --git a/sdk/include/ndk/iotypes.h b/sdk/include/ndk/iotypes.h
index ace4d6fc7a2..2faf128ee97 100644
--- a/sdk/include/ndk/iotypes.h
+++ b/sdk/include/ndk/iotypes.h
@@ -323,8 +323,8 @@ typedef enum _FILE_INFORMATION_CLASS
     FileIdFullDirectoryInformation,
     FileValidDataLengthInformation,
     FileShortNameInformation,
-#if (NTDDI_VERSION >= NTDDI_VISTA)
     FileIoCompletionNotificationInformation,
+#if (NTDDI_VERSION >= NTDDI_VISTA)
     FileIoStatusBlockRangeInformation,
     FileIoPriorityHintInformation,
     FileSfioReserveInformation,
@@ -604,6 +604,11 @@ typedef struct _FILE_COMPLETION_INFORMATION
     PVOID Key;
 } FILE_COMPLETION_INFORMATION, *PFILE_COMPLETION_INFORMATION;
 
+typedef struct _FILE_IO_COMPLETION_NOTIFICATION_INFORMATION
+{
+    ULONG Flags;
+} FILE_IO_COMPLETION_NOTIFICATION_INFORMATION, 
*PFILE_IO_COMPLETION_NOTIFICATION_INFORMATION;
+
 typedef struct _FILE_LINK_INFORMATION
 {
     BOOLEAN ReplaceIfExists;

Reply via email to