ntdll: Make NtCreateFile and NtOpenFile thin wrappers over internal function

Nikolay Sivov bunglehead at gmail.com
Thu Jun 4 07:36:53 CDT 2009


Calling NtCreateFile in response of NtOpenFile cause problems sometimes as
described here http://bugs.winehq.org/show_bug.cgi?id=11030#c9

Changelog:
    - Make NtCreateFile and NtOpenFile thin wrappers over internal function


>From 2a72a78963a7d9578877a072135a3268e20ca10a Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Thu, 4 Jun 2009 16:31:17 +0400
Subject: Make NtCreateFile and NtOpenFile thin wrappers over internal function

---
 dlls/ntdll/file.c |  118 ++++++++++++++++++++++++++++++-----------------------
 1 files changed, 67 insertions(+), 51 deletions(-)

diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index ecba665..d6532cc 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -90,60 +90,17 @@ mode_t FILE_umask = 0;
 #define SECSPERDAY         86400
 #define SECS_1601_TO_1970  ((369 * 365 + 89) * (ULONGLONG)SECSPERDAY)
 
-/**************************************************************************
- *                 NtOpenFile				[NTDLL.@]
- *                 ZwOpenFile				[NTDLL.@]
- *
- * Open a file.
- *
- * PARAMS
- *  handle    [O] Variable that receives the file handle on return
- *  access    [I] Access desired by the caller to the file
- *  attr      [I] Structure describing the file to be opened
- *  io        [O] Receives details about the result of the operation
- *  sharing   [I] Type of shared access the caller requires
- *  options   [I] Options for the file open
- *
- * RETURNS
- *  Success: 0. FileHandle and IoStatusBlock are updated.
- *  Failure: An NTSTATUS error code describing the error.
- */
-NTSTATUS WINAPI NtOpenFile( PHANDLE handle, ACCESS_MASK access,
-                            POBJECT_ATTRIBUTES attr, PIO_STATUS_BLOCK io,
-                            ULONG sharing, ULONG options )
-{
-    return NtCreateFile( handle, access, attr, io, NULL, 0,
-                         sharing, FILE_OPEN, options, NULL, 0 );
-}
 
 /**************************************************************************
- *		NtCreateFile				[NTDLL.@]
- *		ZwCreateFile				[NTDLL.@]
- *
- * Either create a new file or directory, or open an existing file, device,
- * directory or volume.
- *
- * PARAMS
- *	handle       [O] Points to a variable which receives the file handle on return
- *	access       [I] Desired access to the file
- *	attr         [I] Structure describing the file
- *	io           [O] Receives information about the operation on return
- *	alloc_size   [I] Initial size of the file in bytes
- *	attributes   [I] Attributes to create the file with
- *	sharing      [I] Type of shared access the caller would like to the file
- *	disposition  [I] Specifies what to do, depending on whether the file already exists
- *	options      [I] Options for creating a new file
- *	ea_buffer    [I] Pointer to an extended attributes buffer
- *	ea_length    [I] Length of ea_buffer
- *
- * RETURNS
- *  Success: 0. handle and io are updated.
- *  Failure: An NTSTATUS error code describing the error.
+ *                 FILE_NtCreateFile                    (internal)
+ * Open a file.
+ * 
+ * Parameter set fully identical with NtCreateFile
  */
-NTSTATUS WINAPI NtCreateFile( PHANDLE handle, ACCESS_MASK access, POBJECT_ATTRIBUTES attr,
-                              PIO_STATUS_BLOCK io, PLARGE_INTEGER alloc_size,
-                              ULONG attributes, ULONG sharing, ULONG disposition,
-                              ULONG options, PVOID ea_buffer, ULONG ea_length )
+static NTSTATUS FILE_NtCreateFile( PHANDLE handle, ACCESS_MASK access, POBJECT_ATTRIBUTES attr,
+                                   PIO_STATUS_BLOCK io, PLARGE_INTEGER alloc_size,
+                                   ULONG attributes, ULONG sharing, ULONG disposition,
+                                   ULONG options, PVOID ea_buffer, ULONG ea_length )
 {
     ANSI_STRING unix_name;
     int created = FALSE;
@@ -248,6 +205,65 @@ NTSTATUS WINAPI NtCreateFile( PHANDLE handle, ACCESS_MASK access, POBJECT_ATTRIB
     return io->u.Status;
 }
 
+/**************************************************************************
+ *                 NtOpenFile				[NTDLL.@]
+ *                 ZwOpenFile				[NTDLL.@]
+ *
+ * Open a file.
+ *
+ * PARAMS
+ *  handle    [O] Variable that receives the file handle on return
+ *  access    [I] Access desired by the caller to the file
+ *  attr      [I] Structure describing the file to be opened
+ *  io        [O] Receives details about the result of the operation
+ *  sharing   [I] Type of shared access the caller requires
+ *  options   [I] Options for the file open
+ *
+ * RETURNS
+ *  Success: 0. FileHandle and IoStatusBlock are updated.
+ *  Failure: An NTSTATUS error code describing the error.
+ */
+NTSTATUS WINAPI NtOpenFile( PHANDLE handle, ACCESS_MASK access,
+                            POBJECT_ATTRIBUTES attr, PIO_STATUS_BLOCK io,
+                            ULONG sharing, ULONG options )
+{
+    return FILE_NtCreateFile( handle, access, attr, io, NULL, 0,
+                              sharing, FILE_OPEN, options, NULL, 0 );
+}
+
+/**************************************************************************
+ *		NtCreateFile				[NTDLL.@]
+ *		ZwCreateFile				[NTDLL.@]
+ *
+ * Either create a new file or directory, or open an existing file, device,
+ * directory or volume.
+ *
+ * PARAMS
+ *	handle       [O] Points to a variable which receives the file handle on return
+ *	access       [I] Desired access to the file
+ *	attr         [I] Structure describing the file
+ *	io           [O] Receives information about the operation on return
+ *	alloc_size   [I] Initial size of the file in bytes
+ *	attributes   [I] Attributes to create the file with
+ *	sharing      [I] Type of shared access the caller would like to the file
+ *	disposition  [I] Specifies what to do, depending on whether the file already exists
+ *	options      [I] Options for creating a new file
+ *	ea_buffer    [I] Pointer to an extended attributes buffer
+ *	ea_length    [I] Length of ea_buffer
+ *
+ * RETURNS
+ *  Success: 0. handle and io are updated.
+ *  Failure: An NTSTATUS error code describing the error.
+ */
+NTSTATUS WINAPI NtCreateFile( PHANDLE handle, ACCESS_MASK access, POBJECT_ATTRIBUTES attr,
+                              PIO_STATUS_BLOCK io, PLARGE_INTEGER alloc_size,
+                              ULONG attributes, ULONG sharing, ULONG disposition,
+                              ULONG options, PVOID ea_buffer, ULONG ea_length )
+{
+    return FILE_NtCreateFile( handle, access, attr, io, alloc_size, attributes,
+                              sharing, disposition, options, ea_buffer, ea_length );
+}
+
 /***********************************************************************
  *                  Asynchronous file I/O                              *
  */
-- 
1.5.6.5





More information about the wine-patches mailing list