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

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

View File

@ -3919,12 +3919,20 @@ NTSTATUS WINAPI NtDeleteFile( OBJECT_ATTRIBUTES *attr )
{
HANDLE handle;
NTSTATUS status;
IO_STATUS_BLOCK io;
char *unix_name;
UNICODE_STRING nt_name;
OBJECT_ATTRIBUTES new_attr = *attr;
status = NtCreateFile( &handle, GENERIC_READ | GENERIC_WRITE | DELETE, attr, &io, NULL, 0,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_OPEN,
FILE_DELETE_ON_CLOSE, NULL, 0 );
if (status == STATUS_SUCCESS) NtClose( handle );
get_redirect( &new_attr, &nt_name );
if (!(status = nt_to_unix_file_name( &new_attr, &unix_name, FILE_OPEN )))
{
if (!(status = open_unix_file( &handle, unix_name, GENERIC_READ | GENERIC_WRITE | DELETE, &new_attr,
0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_OPEN,
FILE_DELETE_ON_CLOSE, NULL, 0 )))
NtClose( handle );
free( unix_name );
}
free( nt_name.Buffer );
return status;
}

View File

@ -661,14 +661,23 @@ NTSTATUS WINAPI NtLoadKey( const OBJECT_ATTRIBUTES *attr, OBJECT_ATTRIBUTES *fil
{
NTSTATUS ret;
HANDLE key;
IO_STATUS_BLOCK io;
data_size_t len;
struct object_attributes *objattr;
char *unix_name;
UNICODE_STRING nt_name;
OBJECT_ATTRIBUTES new_attr = *file;
TRACE("(%p,%p)\n", attr, file);
ret = NtCreateFile( &key, GENERIC_READ | SYNCHRONIZE, file, &io, NULL, FILE_ATTRIBUTE_NORMAL, 0,
FILE_OPEN, 0, NULL, 0);
get_redirect( &new_attr, &nt_name );
if (!(ret = nt_to_unix_file_name( &new_attr, &unix_name, FILE_OPEN )))
{
ret = open_unix_file( &key, unix_name, GENERIC_READ | SYNCHRONIZE,
&new_attr, 0, 0, FILE_OPEN, 0, NULL, 0 );
free( unix_name );
}
free( nt_name.Buffer );
if (ret) return ret;
if ((ret = alloc_object_attributes( attr, &objattr, &len ))) return ret;