Alexandre Julliard : kernelbase: Implement GetSystemWow64Directory2().
Alexandre Julliard
julliard at winehq.org
Tue Nov 12 16:56:07 CST 2019
Module: wine
Branch: master
Commit: bf039539426aebaa352d17f04f7d21ac5fbc79de
URL: https://source.winehq.org/git/wine.git/?a=commit;h=bf039539426aebaa352d17f04f7d21ac5fbc79de
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Nov 12 21:51:23 2019 +0100
kernelbase: Implement GetSystemWow64Directory2().
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernelbase/file.c | 66 ++++++++++++++++++++++++++++++++---------
dlls/kernelbase/kernelbase.spec | 4 +--
include/winbase.h | 3 ++
include/winnt.h | 1 +
4 files changed, 58 insertions(+), 16 deletions(-)
diff --git a/dlls/kernelbase/file.c b/dlls/kernelbase/file.c
index af21687aa3..472f1ec964 100644
--- a/dlls/kernelbase/file.c
+++ b/dlls/kernelbase/file.c
@@ -57,6 +57,19 @@ static void WINAPI read_write_apc( void *apc_user, PIO_STATUS_BLOCK io, ULONG re
func( RtlNtStatusToDosError( io->u.Status ), io->Information, (LPOVERLAPPED)io );
}
+static const WCHAR *get_machine_wow64_dir( WORD machine )
+{
+ switch (machine)
+ {
+ case IMAGE_FILE_MACHINE_TARGET_HOST: return system_dir;
+ case IMAGE_FILE_MACHINE_I386: return L"C:\\windows\\syswow64";
+ case IMAGE_FILE_MACHINE_ARMNT: return L"C:\\windows\\sysarm32";
+ case IMAGE_FILE_MACHINE_AMD64: return L"C:\\windows\\sysx8664";
+ case IMAGE_FILE_MACHINE_ARM64: return L"C:\\windows\\sysarm64";
+ default: return NULL;
+ }
+}
+
/***********************************************************************
* Operations on file names
@@ -194,6 +207,21 @@ done:
}
+/***********************************************************************
+ * copy_filename
+ */
+static DWORD copy_filename( const WCHAR *name, WCHAR *buffer, DWORD len )
+{
+ UINT ret = lstrlenW( name ) + 1;
+ if (buffer && len >= ret)
+ {
+ lstrcpyW( buffer, name );
+ ret--;
+ }
+ return ret;
+}
+
+
/***********************************************************************
* copy_filename_WtoA
*
@@ -1211,13 +1239,7 @@ UINT WINAPI DECLSPEC_HOTPATCH GetSystemDirectoryA( LPSTR path, UINT count )
*/
UINT WINAPI DECLSPEC_HOTPATCH GetSystemDirectoryW( LPWSTR path, UINT count )
{
- UINT len = lstrlenW( system_dir ) + 1;
- if (path && count >= len)
- {
- lstrcpyW( path, system_dir );
- len--;
- }
- return len;
+ return copy_filename( system_dir, path, count );
}
@@ -1239,6 +1261,28 @@ UINT WINAPI DECLSPEC_HOTPATCH GetSystemWindowsDirectoryW( LPWSTR path, UINT coun
}
+/***********************************************************************
+ * GetSystemWow64Directory2A (kernelbase.@)
+ */
+UINT WINAPI DECLSPEC_HOTPATCH GetSystemWow64Directory2A( LPSTR path, UINT count, WORD machine )
+{
+ const WCHAR *dir = get_machine_wow64_dir( machine );
+
+ return dir ? copy_filename_WtoA( dir, path, count ) : 0;
+}
+
+
+/***********************************************************************
+ * GetSystemWow64Directory2W (kernelbase.@)
+ */
+UINT WINAPI DECLSPEC_HOTPATCH GetSystemWow64Directory2W( LPWSTR path, UINT count, WORD machine )
+{
+ const WCHAR *dir = get_machine_wow64_dir( machine );
+
+ return dir ? copy_filename( dir, path, count ) : 0;
+}
+
+
/***********************************************************************
* GetTempFileNameA (kernelbase.@)
*/
@@ -1413,13 +1457,7 @@ UINT WINAPI DECLSPEC_HOTPATCH GetWindowsDirectoryA( LPSTR path, UINT count )
*/
UINT WINAPI DECLSPEC_HOTPATCH GetWindowsDirectoryW( LPWSTR path, UINT count )
{
- UINT len = lstrlenW( windows_dir ) + 1;
- if (path && count >= len)
- {
- lstrcpyW( path, windows_dir );
- len--;
- }
- return len;
+ return copy_filename( windows_dir, path, count );
}
diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec
index 5b2c5ef2e0..40c82f464e 100644
--- a/dlls/kernelbase/kernelbase.spec
+++ b/dlls/kernelbase/kernelbase.spec
@@ -701,8 +701,8 @@
@ stdcall GetSystemTimes(ptr ptr ptr) kernel32.GetSystemTimes
@ stdcall GetSystemWindowsDirectoryA(ptr long)
@ stdcall GetSystemWindowsDirectoryW(ptr long)
-# @ stub GetSystemWow64Directory2A
-# @ stub GetSystemWow64Directory2W
+@ stdcall GetSystemWow64Directory2A(ptr long long)
+@ stdcall GetSystemWow64Directory2W(ptr long long)
@ stdcall GetSystemWow64DirectoryA(ptr long) kernel32.GetSystemWow64DirectoryA
@ stdcall GetSystemWow64DirectoryW(ptr long) kernel32.GetSystemWow64DirectoryW
# @ stub GetTargetPlatformContext
diff --git a/include/winbase.h b/include/winbase.h
index 2d9fafa52d..8b30c5a69a 100644
--- a/include/winbase.h
+++ b/include/winbase.h
@@ -2289,6 +2289,9 @@ WINBASEAPI VOID WINAPI GetSystemTimePreciseAsFileTime(LPFILETIME);
WINBASEAPI UINT WINAPI GetSystemWindowsDirectoryA(LPSTR,UINT);
WINBASEAPI UINT WINAPI GetSystemWindowsDirectoryW(LPWSTR,UINT);
#define GetSystemWindowsDirectory WINELIB_NAME_AW(GetSystemWindowsDirectory)
+WINBASEAPI UINT WINAPI GetSystemWow64Directory2A(LPSTR,UINT,WORD);
+WINBASEAPI UINT WINAPI GetSystemWow64Directory2W(LPWSTR,UINT,WORD);
+#define GetSystemWow64Directory2 WINELIB_NAME_AW(GetSystemWow64Directory2)
WINBASEAPI UINT WINAPI GetSystemWow64DirectoryA(LPSTR,UINT);
WINBASEAPI UINT WINAPI GetSystemWow64DirectoryW(LPWSTR,UINT);
#define GetSystemWow64Directory WINELIB_NAME_AW(GetSystemWow64Directory)
diff --git a/include/winnt.h b/include/winnt.h
index 9c39eb7e4d..d18b2e03b4 100644
--- a/include/winnt.h
+++ b/include/winnt.h
@@ -2874,6 +2874,7 @@ typedef struct _IMAGE_VXD_HEADER {
/* These are the settings of the Machine field. */
#define IMAGE_FILE_MACHINE_UNKNOWN 0
+#define IMAGE_FILE_MACHINE_TARGET_HOST 0x0001
#define IMAGE_FILE_MACHINE_I860 0x014d
#define IMAGE_FILE_MACHINE_I386 0x014c
#define IMAGE_FILE_MACHINE_R3000 0x0162
More information about the wine-cvs
mailing list