Alexandre Julliard : kernel32: Move GetSystemWow64Directory() functions to kernelbase.

Alexandre Julliard julliard at winehq.org
Tue Nov 12 16:56:07 CST 2019


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Nov 12 22:01:27 2019 +0100

kernel32: Move GetSystemWow64Directory() functions to kernelbase.

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

---

 dlls/kernel32/kernel32.spec     |  4 ++--
 dlls/kernel32/path.c            | 42 -----------------------------------------
 dlls/kernelbase/file.c          | 28 +++++++++++++++++++++++++++
 dlls/kernelbase/kernelbase.h    |  3 +++
 dlls/kernelbase/kernelbase.spec |  4 ++--
 dlls/kernelbase/main.c          |  2 ++
 dlls/kernelbase/registry.c      |  2 --
 7 files changed, 37 insertions(+), 48 deletions(-)

diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec
index 88708845df..5769a8b6ce 100644
--- a/dlls/kernel32/kernel32.spec
+++ b/dlls/kernel32/kernel32.spec
@@ -837,8 +837,8 @@
 @ stdcall GetSystemTimes(ptr ptr ptr)
 @ stdcall -import GetSystemWindowsDirectoryA(ptr long)
 @ stdcall -import GetSystemWindowsDirectoryW(ptr long)
-@ stdcall GetSystemWow64DirectoryA(ptr long)
-@ stdcall GetSystemWow64DirectoryW(ptr long)
+@ stdcall -import GetSystemWow64DirectoryA(ptr long)
+@ stdcall -import GetSystemWow64DirectoryW(ptr long)
 @ stdcall GetTapeParameters(ptr long ptr ptr)
 @ stdcall GetTapePosition(ptr long ptr ptr ptr)
 @ stdcall GetTapeStatus(ptr)
diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c
index bbe0fe268f..4f05118739 100644
--- a/dlls/kernel32/path.c
+++ b/dlls/kernel32/path.c
@@ -849,48 +849,6 @@ UINT WINAPI GetSystemDirectoryA( LPSTR path, UINT count )
 }
 
 
-/***********************************************************************
- *           GetSystemWow64DirectoryW   (KERNEL32.@)
- *
- * As seen on MSDN
- * - On Win32 we should return ERROR_CALL_NOT_IMPLEMENTED
- * - On Win64 we should return the SysWow64 (system64) directory
- */
-UINT WINAPI GetSystemWow64DirectoryW( LPWSTR path, UINT count )
-{
-    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;
-}
-
-
-/***********************************************************************
- *           GetSystemWow64DirectoryA   (KERNEL32.@)
- *
- * See comment for GetWindowsWow64DirectoryW.
- */
-UINT WINAPI GetSystemWow64DirectoryA( LPSTR path, UINT count )
-{
-    if (!DIR_SysWow64)
-    {
-        SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
-        return 0;
-    }
-    return copy_filename_WtoA( DIR_SysWow64, path, count );
-}
-
-
 /***********************************************************************
  *           Wow64EnableWow64FsRedirection   (KERNEL32.@)
  */
diff --git a/dlls/kernelbase/file.c b/dlls/kernelbase/file.c
index 472f1ec964..aa2ebfcc69 100644
--- a/dlls/kernelbase/file.c
+++ b/dlls/kernelbase/file.c
@@ -1261,6 +1261,34 @@ UINT WINAPI DECLSPEC_HOTPATCH GetSystemWindowsDirectoryW( LPWSTR path, UINT coun
 }
 
 
+/***********************************************************************
+ *	GetSystemWow64DirectoryA   (kernelbase.@)
+ */
+UINT WINAPI /* DECLSPEC_HOTPATCH */ GetSystemWow64DirectoryA( LPSTR path, UINT count )
+{
+    if (!is_win64 && !is_wow64)
+    {
+        SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
+        return 0;
+    }
+    return copy_filename_WtoA( get_machine_wow64_dir( IMAGE_FILE_MACHINE_I386 ), path, count );
+}
+
+
+/***********************************************************************
+ *	GetSystemWow64DirectoryW   (kernelbase.@)
+ */
+UINT WINAPI /* DECLSPEC_HOTPATCH */ GetSystemWow64DirectoryW( LPWSTR path, UINT count )
+{
+    if (!is_win64 && !is_wow64)
+    {
+        SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
+        return 0;
+    }
+    return copy_filename( get_machine_wow64_dir( IMAGE_FILE_MACHINE_I386 ), path, count );
+}
+
+
 /***********************************************************************
  *	GetSystemWow64Directory2A   (kernelbase.@)
  */
diff --git a/dlls/kernelbase/kernelbase.h b/dlls/kernelbase/kernelbase.h
index 6203877aeb..63d4b21d76 100644
--- a/dlls/kernelbase/kernelbase.h
+++ b/dlls/kernelbase/kernelbase.h
@@ -30,6 +30,9 @@ extern void init_startup_info( RTL_USER_PROCESS_PARAMETERS *params ) DECLSPEC_HI
 
 extern const WCHAR windows_dir[] DECLSPEC_HIDDEN;
 extern const WCHAR system_dir[] DECLSPEC_HIDDEN;
+
+static const BOOL is_win64 = (sizeof(void *) > sizeof(int));
+extern BOOL is_wow64 DECLSPEC_HIDDEN;
 extern HANDLE kernel32_handle DECLSPEC_HIDDEN;
 
 static inline BOOL is_console_handle(HANDLE h)
diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec
index 40c82f464e..a0e90f706b 100644
--- a/dlls/kernelbase/kernelbase.spec
+++ b/dlls/kernelbase/kernelbase.spec
@@ -703,8 +703,8 @@
 @ stdcall GetSystemWindowsDirectoryW(ptr long)
 @ stdcall GetSystemWow64Directory2A(ptr long long)
 @ stdcall GetSystemWow64Directory2W(ptr long long)
-@ stdcall GetSystemWow64DirectoryA(ptr long) kernel32.GetSystemWow64DirectoryA
-@ stdcall GetSystemWow64DirectoryW(ptr long) kernel32.GetSystemWow64DirectoryW
+@ stdcall GetSystemWow64DirectoryA(ptr long)
+@ stdcall GetSystemWow64DirectoryW(ptr long)
 # @ stub GetTargetPlatformContext
 @ stdcall GetTempFileNameA(str str long ptr)
 @ stdcall GetTempFileNameW(wstr wstr long ptr)
diff --git a/dlls/kernelbase/main.c b/dlls/kernelbase/main.c
index e54222a5d6..3015078d91 100644
--- a/dlls/kernelbase/main.c
+++ b/dlls/kernelbase/main.c
@@ -35,6 +35,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(kernelbase);
 
 
 HANDLE kernel32_handle = 0;
+BOOL is_wow64 = FALSE;
 
 /***********************************************************************
  *           DllMain
@@ -44,6 +45,7 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
     if (reason == DLL_PROCESS_ATTACH)
     {
         DisableThreadLibraryCalls( hinst );
+        IsWow64Process( GetCurrentProcess(), &is_wow64 );
         kernel32_handle = GetModuleHandleA( "kernel32.dll" );
         init_startup_info( NtCurrentTeb()->Peb->ProcessParameters );
     }
diff --git a/dlls/kernelbase/registry.c b/dlls/kernelbase/registry.c
index 30c5e9f6f3..d3364dbcee 100644
--- a/dlls/kernelbase/registry.c
+++ b/dlls/kernelbase/registry.c
@@ -108,8 +108,6 @@ static struct list reg_mui_cache = LIST_INIT(reg_mui_cache); /* MRU */
 static unsigned int reg_mui_cache_count;
 #define REG_MUI_CACHE_SIZE 8
 
-static const BOOL is_win64 = (sizeof(void *) > sizeof(int));
-
 /* check if value type needs string conversion (Ansi<->Unicode) */
 static inline BOOL is_string( DWORD type )
 {




More information about the wine-cvs mailing list