Commit 1a833442 authored by Alexandre Julliard's avatar Alexandre Julliard

Replaced create_file server requests by a call to NtCreateFile.

parent 24935297
......@@ -91,23 +91,41 @@ static CRITICAL_SECTION vxd_section = { &critsect_debug, -1, 0, 0, 0, 0 };
static HANDLE open_vxd_handle( LPCWSTR name )
{
const char *dir = wine_get_server_dir();
char *unix_name;
int len1, len2;
int len;
HANDLE ret;
len1 = strlen( dir );
len2 = WideCharToMultiByte( CP_UNIXCP, 0, name, -1, NULL, 0, NULL, NULL);
if (!(unix_name = HeapAlloc( GetProcessHeap(), 0, len1 + len2 + 1 )))
NTSTATUS status;
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW;
IO_STATUS_BLOCK io;
len = MultiByteToWideChar( CP_UNIXCP, 0, dir, -1, NULL, 0 );
nameW.Length = (len + 1 + strlenW( name )) * sizeof(WCHAR);
nameW.MaximumLength = nameW.Length + sizeof(WCHAR);
if (!(nameW.Buffer = HeapAlloc( GetProcessHeap(), 0, nameW.Length )))
{
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return 0;
}
strcpy( unix_name, dir );
unix_name[len1] = '/';
WideCharToMultiByte( CP_UNIXCP, 0, name, -1, unix_name + len1 + 1, len2, NULL, NULL);
ret = FILE_CreateFile( unix_name, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
OPEN_ALWAYS, 0, 0 );
HeapFree( GetProcessHeap(), 0, unix_name );
MultiByteToWideChar( CP_UNIXCP, 0, dir, -1, nameW.Buffer, len );
nameW.Buffer[len-1] = '/';
strcpyW( nameW.Buffer + len, name );
attr.Length = sizeof(attr);
attr.RootDirectory = 0;
attr.Attributes = 0;
attr.ObjectName = &nameW;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
status = NtCreateFile( &ret, 0, &attr, &io, NULL, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN_IF,
FILE_SYNCHRONOUS_IO_ALERT, NULL, 0 );
if (status)
{
ret = 0;
SetLastError( RtlNtStatusToDosError(status) );
}
RtlFreeUnicodeString( &nameW );
return ret;
}
......
......@@ -801,35 +801,41 @@ static BOOL INT21_SetCurrentDirectory( CONTEXT86 *context )
static HANDLE INT21_CreateMagicDeviceHandle( LPCWSTR name )
{
const char *dir = wine_get_server_dir();
char *unix_name;
int len1, len2;
HANDLE ret = 0;
len1 = strlen( dir );
len2 = WideCharToMultiByte( CP_UNIXCP, 0, name, -1, NULL, 0, NULL, NULL);
if (!(unix_name = HeapAlloc( GetProcessHeap(), 0, len1 + len2 + 1 )))
int len;
HANDLE ret;
NTSTATUS status;
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW;
IO_STATUS_BLOCK io;
len = MultiByteToWideChar( CP_UNIXCP, 0, dir, -1, NULL, 0 );
nameW.Length = (len + 1 + strlenW( name )) * sizeof(WCHAR);
nameW.MaximumLength = nameW.Length + sizeof(WCHAR);
if (!(nameW.Buffer = HeapAlloc( GetProcessHeap(), 0, nameW.Length )))
{
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return 0;
}
strcpy( unix_name, dir );
unix_name[len1] = '/';
WideCharToMultiByte( CP_UNIXCP, 0, name, -1, unix_name + len1 + 1, len2, NULL, NULL);
SERVER_START_REQ( create_file )
MultiByteToWideChar( CP_UNIXCP, 0, dir, -1, nameW.Buffer, len );
nameW.Buffer[len-1] = '/';
strcpyW( nameW.Buffer + len, name );
attr.Length = sizeof(attr);
attr.RootDirectory = 0;
attr.Attributes = 0;
attr.ObjectName = &nameW;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
status = NtCreateFile( &ret, GENERIC_READ|GENERIC_WRITE, &attr, &io, NULL, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN_IF,
FILE_SYNCHRONOUS_IO_ALERT, NULL, 0 );
if (status)
{
req->access = GENERIC_READ|GENERIC_WRITE;
req->inherit = 0;
req->sharing = FILE_SHARE_READ|FILE_SHARE_WRITE;
req->create = FILE_OPEN_IF;
req->options = FILE_SYNCHRONOUS_IO_ALERT;
req->attrs = 0;
wine_server_add_data( req, unix_name, strlen(unix_name) );
SetLastError(0);
if (!wine_server_call_err( req )) ret = reply->handle;
ret = 0;
SetLastError( RtlNtStatusToDosError(status) );
}
SERVER_END_REQ;
HeapFree( GetProcessHeap(), 0, unix_name );
RtlFreeUnicodeString( &nameW );
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