Alexandre Julliard : kernel32: Add implementation of GetSystemWow64DirectoryA/W.

Alexandre Julliard julliard at winehq.org
Tue Jul 7 08:08:19 CDT 2009


Module: wine
Branch: master
Commit: 03d6da0894b3a3f9c3b37b36b2c70d7c2a4ce831
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=03d6da0894b3a3f9c3b37b36b2c70d7c2a4ce831

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Jul  7 11:42:03 2009 +0200

kernel32: Add implementation of GetSystemWow64DirectoryA/W.

---

 dlls/kernel32/kernel_private.h |    1 +
 dlls/kernel32/path.c           |   28 ++++++++++++++++++++++------
 dlls/kernel32/process.c        |   15 +++++++++++++++
 include/winbase.h              |    3 +++
 4 files changed, 41 insertions(+), 6 deletions(-)

diff --git a/dlls/kernel32/kernel_private.h b/dlls/kernel32/kernel_private.h
index b23aedf..39a5e23 100644
--- a/dlls/kernel32/kernel_private.h
+++ b/dlls/kernel32/kernel_private.h
@@ -71,6 +71,7 @@ extern HANDLE dos_handles[DOS_TABLE_SIZE];
 
 extern const WCHAR *DIR_Windows;
 extern const WCHAR *DIR_System;
+extern const WCHAR *DIR_SysWow64;
 
 extern VOID SYSLEVEL_CheckNotLevel( INT level );
 
diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c
index 0b3a87e..299db1c 100644
--- a/dlls/kernel32/path.c
+++ b/dlls/kernel32/path.c
@@ -1521,10 +1521,22 @@ UINT WINAPI GetSystemDirectoryA( LPSTR path, UINT count )
  * - On Win32 we should returns ERROR_CALL_NOT_IMPLEMENTED
  * - On Win64 we should returns the SysWow64 (system64) directory
  */
-UINT WINAPI GetSystemWow64DirectoryW( LPWSTR lpBuffer, UINT uSize )
+UINT WINAPI GetSystemWow64DirectoryW( LPWSTR path, UINT count )
 {
-    SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
-    return 0;
+    UINT len;
+
+    if (!DIR_SysWow64)
+    {
+        SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
+        return 0;
+    }
+    len = strlenW( DIR_SysWow64 ) + 1;
+    if (path && count >= len)
+    {
+        strcpyW( path, DIR_SysWow64 );
+        len--;
+    }
+    return len;
 }
 
 
@@ -1533,10 +1545,14 @@ UINT WINAPI GetSystemWow64DirectoryW( LPWSTR lpBuffer, UINT uSize )
  *
  * See comment for GetWindowsWow64DirectoryW.
  */
-UINT WINAPI GetSystemWow64DirectoryA( LPSTR lpBuffer, UINT uSize )
+UINT WINAPI GetSystemWow64DirectoryA( LPSTR path, UINT count )
 {
-    SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
-    return 0;
+    if (!DIR_SysWow64)
+    {
+        SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
+        return 0;
+    }
+    return copy_filename_WtoA( DIR_SysWow64, path, count );
 }
 
 
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
index 6fde35b..4e74782 100644
--- a/dlls/kernel32/process.c
+++ b/dlls/kernel32/process.c
@@ -76,11 +76,13 @@ static UINT process_error_mode;
 static DWORD shutdown_flags = 0;
 static DWORD shutdown_priority = 0x280;
 static DWORD process_dword;
+static BOOL is_wow64;
 
 HMODULE kernel32_handle = 0;
 
 const WCHAR *DIR_Windows = NULL;
 const WCHAR *DIR_System = NULL;
+const WCHAR *DIR_SysWow64 = NULL;
 
 /* Process flags */
 #define PDB32_DEBUGGED      0x0001  /* Process is being debugged */
@@ -822,6 +824,7 @@ static void init_windows_dirs(void)
     static const WCHAR winsysdirW[] = {'w','i','n','s','y','s','d','i','r',0};
     static const WCHAR default_windirW[] = {'C',':','\\','w','i','n','d','o','w','s',0};
     static const WCHAR default_sysdirW[] = {'\\','s','y','s','t','e','m','3','2',0};
+    static const WCHAR default_syswow64W[] = {'\\','s','y','s','w','o','w','6','4',0};
 
     DWORD len;
     WCHAR *buffer;
@@ -849,6 +852,17 @@ static void init_windows_dirs(void)
         DIR_System = buffer;
     }
 
+#ifndef _WIN64  /* SysWow64 is always defined on 64-bit */
+    if (is_wow64)
+#endif
+    {
+        len = strlenW( DIR_Windows );
+        buffer = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) + sizeof(default_syswow64W) );
+        memcpy( buffer, DIR_Windows, len * sizeof(WCHAR) );
+        memcpy( buffer + len, default_syswow64W, sizeof(default_syswow64W) );
+        DIR_SysWow64 = buffer;
+    }
+
     if (!CreateDirectoryW( DIR_Windows, NULL ) && GetLastError() != ERROR_ALREADY_EXISTS)
         ERR( "directory %s could not be created, error %u\n",
              debugstr_w(DIR_Windows), GetLastError() );
@@ -1010,6 +1024,7 @@ void CDECL __wine_kernel_init(void)
     setbuf(stdout,NULL);
     setbuf(stderr,NULL);
     kernel32_handle = GetModuleHandleW(kernel32W);
+    IsWow64Process( GetCurrentProcess(), &is_wow64 );
 
     LOCALE_Init();
 
diff --git a/include/winbase.h b/include/winbase.h
index a7eaf9d..d7d8773 100644
--- a/include/winbase.h
+++ b/include/winbase.h
@@ -1726,6 +1726,9 @@ WINBASEAPI VOID        WINAPI GetSystemTimeAsFileTime(LPFILETIME);
 WINBASEAPI UINT        WINAPI GetSystemWindowsDirectoryA(LPSTR,UINT);
 WINBASEAPI UINT        WINAPI GetSystemWindowsDirectoryW(LPWSTR,UINT);
 #define                       GetSystemWindowsDirectory WINELIB_NAME_AW(GetSystemWindowsDirectory)
+WINBASEAPI UINT        WINAPI GetSystemWow64DirectoryA(LPSTR,UINT);
+WINBASEAPI UINT        WINAPI GetSystemWow64DirectoryW(LPWSTR,UINT);
+#define                       GetSystemWow64Directory WINELIB_NAME_AW(GetSystemWow64Directory)
 WINBASEAPI DWORD       WINAPI GetTapeParameters(HANDLE,DWORD,LPDWORD,LPVOID);
 WINBASEAPI DWORD       WINAPI GetTapePosition(HANDLE,DWORD,LPDWORD,LPDWORD,LPDWORD);
 WINBASEAPI DWORD       WINAPI GetTapeStatus(HANDLE);




More information about the wine-cvs mailing list