Commit 07f8b0c8 authored by Alexandre Julliard's avatar Alexandre Julliard

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

parent 76f94957
......@@ -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;
}
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment