Alexandre Julliard : krnl386: Return a handle to the vxd file itself instead of creating a dummy file.

Alexandre Julliard julliard at winehq.org
Thu Mar 26 16:27:23 CDT 2020


Module: wine
Branch: master
Commit: 61ad36fdc94d9a46ed2530a3766204525e062491
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=61ad36fdc94d9a46ed2530a3766204525e062491

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Mar 26 16:49:11 2020 +0100

krnl386: Return a handle to the vxd file itself instead of creating a dummy file.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/krnl386.exe16/vxd.c | 51 ++++--------------------------------------------
 1 file changed, 4 insertions(+), 47 deletions(-)

diff --git a/dlls/krnl386.exe16/vxd.c b/dlls/krnl386.exe16/vxd.c
index 88d43c2d36..1b50b15027 100644
--- a/dlls/krnl386.exe16/vxd.c
+++ b/dlls/krnl386.exe16/vxd.c
@@ -108,51 +108,6 @@ static WORD VXD_WinVersion(void)
     return (version >> 8) | (version << 8);
 }
 
-/* create a file handle to represent a VxD, by opening a dummy file in the wineserver directory */
-static HANDLE open_vxd_handle( LPCWSTR name )
-{
-    static const WCHAR prefixW[] = {'\\','?','?','\\','u','n','i','x'};
-    const char *dir = wine_get_server_dir();
-    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 = sizeof(prefixW) + (len + strlenW( name )) * sizeof(WCHAR);
-    nameW.MaximumLength = nameW.Length + sizeof(WCHAR);
-    if (!(nameW.Buffer = HeapAlloc( GetProcessHeap(), 0, nameW.MaximumLength )))
-    {
-        SetLastError( ERROR_NOT_ENOUGH_MEMORY );
-        return 0;
-    }
-    memcpy( nameW.Buffer, prefixW, sizeof(prefixW) );
-    MultiByteToWideChar( CP_UNIXCP, 0, dir, -1, nameW.Buffer + ARRAY_SIZE(prefixW), len );
-    len += ARRAY_SIZE(prefixW);
-    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, SYNCHRONIZE, &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;
-}
-
 /* retrieve the DeviceIoControl function for a Vxd given a file handle */
 DeviceIoProc __wine_vxd_get_proc( HANDLE handle )
 {
@@ -240,11 +195,13 @@ HANDLE __wine_vxd_open( LPCWSTR filenameW, DWORD access, SECURITY_ATTRIBUTES *sa
         }
         if (!vxd_modules[i].module)  /* new one, register it */
         {
+            WCHAR path[MAX_PATH];
             IO_STATUS_BLOCK io;
             FILE_INTERNAL_INFORMATION info;
 
-            /* get a file handle to the dummy file */
-            if (!(handle = open_vxd_handle( name )))
+            GetModuleFileNameW( module, path, MAX_PATH );
+            handle = CreateFileW( path, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
+            if (handle == INVALID_HANDLE_VALUE)
             {
                 FreeLibrary( module );
                 goto done;




More information about the wine-cvs mailing list