Module: wine Branch: master Commit: dfa48037ec462c279bf314670d07f04696a9a25c URL: https://source.winehq.org/git/wine.git/?a=commit;h=dfa48037ec462c279bf314670...
Author: Alexandre Julliard julliard@winehq.org Date: Tue Jul 7 10:47:02 2020 +0200
ntdll: Use syscalls for NtCreateFile() and NtOpenFile().
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ntdll/file.c | 59 ------------------------------------------ dlls/ntdll/ntdll.spec | 9 ++++--- dlls/ntdll/unix/loader.c | 17 ++++++------ dlls/ntdll/unix/unix_private.h | 1 + dlls/ntdll/unixlib.h | 8 +----- 5 files changed, 16 insertions(+), 78 deletions(-)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c index f02be661d6..f650ff0d3e 100644 --- a/dlls/ntdll/file.c +++ b/dlls/ntdll/file.c @@ -38,65 +38,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
-/************************************************************************** - * 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 unix_funcs->NtOpenFile( handle, access, attr, io, sharing, options ); -} - -/************************************************************************** - * 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 unix_funcs->NtCreateFile( handle, access, attr, io, alloc_size, attributes, - sharing, disposition, options, ea_buffer, ea_length ); -} - - /****************************************************************************** * NtReadFile [NTDLL.@] * ZwReadFile [NTDLL.@] diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 0b1e91ddc9..ef38613a4e 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -162,7 +162,7 @@ @ stdcall NtCreateDirectoryObject(ptr long ptr) @ stdcall NtCreateEvent(ptr long ptr long long) @ stub NtCreateEventPair -@ stdcall NtCreateFile(ptr long ptr ptr ptr long long long long ptr long) +@ stdcall -syscall NtCreateFile(ptr long ptr ptr ptr long long long long ptr long) @ stdcall NtCreateIoCompletion(ptr long ptr long) @ stdcall NtCreateJobObject(ptr long ptr) # @ stub NtCreateJobSet @@ -253,7 +253,7 @@ @ stdcall NtOpenDirectoryObject(ptr long ptr) @ stdcall NtOpenEvent(ptr long ptr) @ stub NtOpenEventPair -@ stdcall NtOpenFile(ptr long ptr ptr long long) +@ stdcall -syscall NtOpenFile(ptr long ptr ptr long long) @ stdcall NtOpenIoCompletion(ptr long ptr) @ stdcall NtOpenJobObject(ptr long ptr) @ stdcall NtOpenKey(ptr long ptr) @@ -1151,7 +1151,7 @@ @ stdcall -private ZwCreateDirectoryObject(ptr long ptr) NtCreateDirectoryObject @ stdcall -private ZwCreateEvent(ptr long ptr long long) NtCreateEvent @ stub ZwCreateEventPair -@ stdcall -private ZwCreateFile(ptr long ptr ptr ptr long long long long ptr long) NtCreateFile +@ stdcall -private -syscall ZwCreateFile(ptr long ptr ptr ptr long long long long ptr long) NtCreateFile @ stdcall -private ZwCreateIoCompletion(ptr long ptr long) NtCreateIoCompletion @ stdcall -private ZwCreateJobObject(ptr long ptr) NtCreateJobObject # @ stub ZwCreateJobSet @@ -1237,7 +1237,7 @@ @ stdcall -private ZwOpenDirectoryObject(ptr long ptr) NtOpenDirectoryObject @ stdcall -private ZwOpenEvent(ptr long ptr) NtOpenEvent @ stub ZwOpenEventPair -@ stdcall -private ZwOpenFile(ptr long ptr ptr long long) NtOpenFile +@ stdcall -private -syscall ZwOpenFile(ptr long ptr ptr long long) NtOpenFile @ stdcall -private ZwOpenIoCompletion(ptr long ptr) NtOpenIoCompletion @ stdcall -private ZwOpenJobObject(ptr long ptr) NtOpenJobObject @ stdcall -private ZwOpenKey(ptr long ptr) NtOpenKey @@ -1583,6 +1583,7 @@ @ cdecl wine_server_send_fd(long) @ cdecl __wine_make_process_system() @ cdecl __wine_set_unix_funcs(long ptr) +@ extern __wine_syscall_dispatcher @ extern -arch=i386 __wine_ldt_copy
# Debugging diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index e2074f9734..2b43b69be9 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -794,6 +794,7 @@ static void fixup_ntdll_imports( const IMAGE_NT_HEADERS *nt ) const IMAGE_IMPORT_DESCRIPTOR *descr; const IMAGE_THUNK_DATA *import_list; IMAGE_THUNK_DATA *thunk_list; + void **ptr;
assert( ntdll_exports );
@@ -836,14 +837,16 @@ static void fixup_ntdll_imports( const IMAGE_NT_HEADERS *nt ) GET_FUNC( LdrInitializeThunk ); GET_FUNC( RtlUserThreadStart ); GET_FUNC( __wine_set_unix_funcs ); +#undef GET_FUNC +#define SET_PTR(name,val) \ + if ((ptr = (void *)find_named_export( ntdll_module, ntdll_exports, #name ))) *ptr = val; \ + else ERR( "%s not found\n", #name ) + + SET_PTR( __wine_syscall_dispatcher, __wine_syscall_dispatcher ); #ifdef __i386__ - { - struct ldt_copy **p__wine_ldt_copy; - GET_FUNC( __wine_ldt_copy ); - *p__wine_ldt_copy = &__wine_ldt_copy; - } + SET_PTR( __wine_ldt_copy, &__wine_ldt_copy ); #endif -#undef GET_FUNC +#undef SET_PTR }
@@ -1376,7 +1379,6 @@ static struct unix_funcs unix_funcs = NtClose, NtContinue, NtCreateEvent, - NtCreateFile, NtCreateIoCompletion, NtCreateJobObject, NtCreateKeyedEvent, @@ -1407,7 +1409,6 @@ static struct unix_funcs unix_funcs = NtMapViewOfSection, NtNotifyChangeDirectoryFile, NtOpenEvent, - NtOpenFile, NtOpenIoCompletion, NtOpenJobObject, NtOpenKeyedEvent, diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index e14da3ff7e..b7838355ee 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -223,6 +223,7 @@ extern void signal_init_process(void) DECLSPEC_HIDDEN; extern void DECLSPEC_NORETURN signal_start_thread( PRTL_THREAD_START_ROUTINE entry, void *arg, BOOL suspend, void *relay, TEB *teb ) DECLSPEC_HIDDEN; extern void DECLSPEC_NORETURN signal_exit_thread( int status, void (*func)(int) ) DECLSPEC_HIDDEN; +extern void __wine_syscall_dispatcher(void) DECLSPEC_HIDDEN;
extern NTSTATUS cdrom_DeviceIoControl( HANDLE device, HANDLE event, PIO_APC_ROUTINE apc, void *apc_user, IO_STATUS_BLOCK *io, ULONG code, void *in_buffer, diff --git a/dlls/ntdll/unixlib.h b/dlls/ntdll/unixlib.h index 89ca0e960c..5f1ad1b5d9 100644 --- a/dlls/ntdll/unixlib.h +++ b/dlls/ntdll/unixlib.h @@ -28,7 +28,7 @@ struct msghdr; struct _DISPATCHER_CONTEXT;
/* increment this when you change the function table */ -#define NTDLL_UNIXLIB_VERSION 70 +#define NTDLL_UNIXLIB_VERSION 71
struct unix_funcs { @@ -45,10 +45,6 @@ struct unix_funcs NTSTATUS (WINAPI *NtContinue)( CONTEXT *context, BOOLEAN alertable ); NTSTATUS (WINAPI *NtCreateEvent)( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr, EVENT_TYPE type, BOOLEAN state ); - NTSTATUS (WINAPI *NtCreateFile)( HANDLE *handle, ACCESS_MASK access, OBJECT_ATTRIBUTES *attr, - IO_STATUS_BLOCK *io, LARGE_INTEGER *alloc_size, - ULONG attributes, ULONG sharing, ULONG disposition, - ULONG options, void *ea_buffer, ULONG ea_length ); NTSTATUS (WINAPI *NtCreateIoCompletion)( HANDLE *handle, ACCESS_MASK access, OBJECT_ATTRIBUTES *attr, ULONG threads ); NTSTATUS (WINAPI *NtCreateJobObject)( HANDLE *handle, ACCESS_MASK access, @@ -120,8 +116,6 @@ struct unix_funcs ULONG filter, BOOLEAN subtree ); NTSTATUS (WINAPI *NtOpenEvent)( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr ); - NTSTATUS (WINAPI *NtOpenFile)( HANDLE *handle, ACCESS_MASK access, OBJECT_ATTRIBUTES *attr, - IO_STATUS_BLOCK *io, ULONG sharing, ULONG options ); NTSTATUS (WINAPI *NtOpenIoCompletion)( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr ); NTSTATUS (WINAPI *NtOpenJobObject)( HANDLE *handle, ACCESS_MASK access,