ntdll: Use syscalls for NtCreateFile() and NtOpenFile().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-07-07 10:47:02 +02:00
parent b2d09cbb21
commit dfa48037ec
5 changed files with 17 additions and 79 deletions

View File

@ -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.@]

View File

@ -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

View File

@ -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 );
#ifdef __i386__
{
struct ldt_copy **p__wine_ldt_copy;
GET_FUNC( __wine_ldt_copy );
*p__wine_ldt_copy = &__wine_ldt_copy;
}
#endif
#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__
SET_PTR( __wine_ldt_copy, &__wine_ldt_copy );
#endif
#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,

View File

@ -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,

View File

@ -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,