ntdll: Avoid calling NtOpenFile() from the Unix side.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-07-08 16:49:23 +02:00
parent f690266c11
commit 76f949577a
2 changed files with 15 additions and 9 deletions

View File

@ -162,7 +162,6 @@ static NTSTATUS open_nls_data_file( ULONG type, ULONG id, HANDLE *file )
's','o','r','t','i','n','g','\\',0};
NTSTATUS status = STATUS_OBJECT_NAME_NOT_FOUND;
IO_STATUS_BLOCK io;
OBJECT_ATTRIBUTES attr;
UNICODE_STRING valueW;
WCHAR buffer[ARRAY_SIZE(sortdirW) + 16];
@ -179,10 +178,12 @@ static NTSTATUS open_nls_data_file( ULONG type, ULONG id, HANDLE *file )
status = open_unix_file( file, path, GENERIC_READ, &attr, 0, FILE_SHARE_READ,
FILE_OPEN, FILE_SYNCHRONOUS_IO_ALERT, NULL, 0 );
if (status == STATUS_NO_SUCH_FILE)
/* try to open file in system dir */
status = NtOpenFile( file, GENERIC_READ, &attr, &io, FILE_SHARE_READ, FILE_SYNCHRONOUS_IO_ALERT );
free( path );
if (status != STATUS_NO_SUCH_FILE) return status;
if ((status = nt_to_unix_file_name( &attr, &path, FILE_OPEN ))) return status;
status = open_unix_file( file, path, GENERIC_READ, &attr, 0, FILE_SHARE_READ,
FILE_OPEN, FILE_SYNCHRONOUS_IO_ALERT, NULL, 0 );
free( path );
return status;
}

View File

@ -353,21 +353,26 @@ static WCHAR *get_nt_pathname( const UNICODE_STRING *str )
*/
static int get_unix_curdir( const RTL_USER_PROCESS_PARAMETERS *params )
{
UNICODE_STRING nt_name;
UNICODE_STRING nt_name, redir;
OBJECT_ATTRIBUTES attr;
IO_STATUS_BLOCK io;
NTSTATUS status;
HANDLE handle;
int fd = -1;
char *unix_name;
if (!(nt_name.Buffer = get_nt_pathname( &params->CurrentDirectory.DosPath ))) return -1;
nt_name.Length = wcslen( nt_name.Buffer ) * sizeof(WCHAR);
InitializeObjectAttributes( &attr, &nt_name, OBJ_CASE_INSENSITIVE, 0, NULL );
status = NtOpenFile( &handle, FILE_TRAVERSE | SYNCHRONIZE, &attr, &io,
FILE_SHARE_READ | FILE_SHARE_WRITE,
FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT );
get_redirect( &attr, &redir );
status = nt_to_unix_file_name( &attr, &unix_name, FILE_OPEN );
free( nt_name.Buffer );
free( redir.Buffer );
if (status) return -1;
status = open_unix_file( &handle, unix_name, FILE_TRAVERSE | SYNCHRONIZE, &attr, 0,
FILE_SHARE_READ | FILE_SHARE_DELETE,
FILE_OPEN, FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0 );
free( unix_name );
if (status) return -1;
wine_server_handle_to_fd( handle, FILE_TRAVERSE, &fd, NULL );
NtClose( handle );