Commit bf039539 authored by Alexandre Julliard's avatar Alexandre Julliard

kernelbase: Implement GetSystemWow64Directory2().

parent eee3a4e8
......@@ -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
......@@ -195,6 +208,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
*
* copy a file name back to OEM/Ansi, but only if the buffer is large enough
......@@ -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 );
}
......@@ -1240,6 +1262,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.@)
*/
UINT WINAPI DECLSPEC_HOTPATCH GetTempFileNameA( LPCSTR path, LPCSTR prefix, UINT unique, LPSTR buffer )
......@@ -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 );
}
......
......@@ -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
......
......@@ -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)
......
......@@ -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
......
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