Module: wine Branch: master Commit: 7929b21ede210634e989ad32d479085053ca0059 URL: https://source.winehq.org/git/wine.git/?a=commit;h=7929b21ede210634e989ad32d...
Author: Alexandre Julliard julliard@winehq.org Date: Thu Apr 1 12:25:21 2021 +0200
ntdll: Define NtCurrentTeb64() on 64-bit to avoid some #ifdefs.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ntdll/directory.c | 8 -------- dlls/ntdll/env.c | 11 ++++------- dlls/ntdll/loader.c | 7 +------ dlls/ntdll/ntdll_misc.h | 7 +++---- dlls/ntdll/unix/env.c | 8 +++----- dlls/ntdll/unix/file.c | 4 ---- dlls/ntdll/unix/loader.c | 2 -- dlls/ntdll/unix/unix_private.h | 4 +++- 8 files changed, 14 insertions(+), 37 deletions(-)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c index 4125170b509..3c601fe016a 100644 --- a/dlls/ntdll/directory.c +++ b/dlls/ntdll/directory.c @@ -46,13 +46,9 @@ */ NTSTATUS WINAPI RtlWow64EnableFsRedirection( BOOLEAN enable ) { -#ifdef _WIN64 - return STATUS_NOT_IMPLEMENTED; -#else if (!NtCurrentTeb64()) return STATUS_NOT_IMPLEMENTED; NtCurrentTeb64()->TlsSlots[WOW64_TLS_FILESYSREDIR] = !enable; return STATUS_SUCCESS; -#endif }
@@ -61,9 +57,6 @@ NTSTATUS WINAPI RtlWow64EnableFsRedirection( BOOLEAN enable ) */ NTSTATUS WINAPI RtlWow64EnableFsRedirectionEx( ULONG disable, ULONG *old_value ) { -#ifdef _WIN64 - return STATUS_NOT_IMPLEMENTED; -#else if (!NtCurrentTeb64()) return STATUS_NOT_IMPLEMENTED;
__TRY @@ -78,7 +71,6 @@ NTSTATUS WINAPI RtlWow64EnableFsRedirectionEx( ULONG disable, ULONG *old_value )
NtCurrentTeb64()->TlsSlots[WOW64_TLS_FILESYSREDIR] = disable; return STATUS_SUCCESS; -#endif }
diff --git a/dlls/ntdll/env.c b/dlls/ntdll/env.c index 62f93603d55..1ed52b9728f 100644 --- a/dlls/ntdll/env.c +++ b/dlls/ntdll/env.c @@ -73,14 +73,11 @@ static void set_wow64_environment( WCHAR **env ) RtlSetEnvironmentVariable( env, &arch6432_strW, NULL ); } } - else if (!RtlQueryEnvironmentVariable_U( *env, &arch_strW, &valW )) + else if (NtCurrentTeb64() && !RtlQueryEnvironmentVariable_U( *env, &arch_strW, &valW )) { - if (is_wow64) - { - RtlSetEnvironmentVariable( env, &arch6432_strW, &valW ); - RtlInitUnicodeString( &nameW, L"x86" ); - RtlSetEnvironmentVariable( env, &arch_strW, &nameW ); - } + RtlSetEnvironmentVariable( env, &arch6432_strW, &valW ); + RtlInitUnicodeString( &nameW, L"x86" ); + RtlSetEnvironmentVariable( env, &arch_strW, &nameW ); }
/* set the ProgramFiles variables */ diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 39e87e5d752..daee7675196 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -69,7 +69,6 @@ const WCHAR system_dir[] = L"C:\windows\system32\"; const WCHAR syswow64_dir[] = L"C:\windows\syswow64\";
HMODULE kernel32_handle = 0; -BOOL is_wow64 = FALSE;
/* system search path */ static const WCHAR system_path[] = L"C:\windows\system32;C:\windows\system;C:\windows"; @@ -2704,7 +2703,7 @@ static NTSTATUS find_dll_file( const WCHAR *load_path, const WCHAR *libname, con }
/* Win 7/2008R2 and up seem to re-enable WoW64 FS redirection when loading libraries */ - if (is_wow64) RtlWow64EnableFsRedirectionEx( 0, &wow64_old_value ); + RtlWow64EnableFsRedirectionEx( 0, &wow64_old_value );
nt_name->Buffer = NULL;
@@ -4048,10 +4047,6 @@ static NTSTATUS process_init(void) InitializeListHead( &ldr.InMemoryOrderModuleList ); InitializeListHead( &ldr.InInitializationOrderModuleList );
-#ifndef _WIN64 - is_wow64 = !!NtCurrentTeb64(); -#endif - init_user_process_params(); load_global_options(); version_init(); diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h index 400ac9398a5..e50d48dc3cc 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h @@ -64,9 +64,6 @@ extern void heap_set_debug_flags( HANDLE handle ) DECLSPEC_HIDDEN; extern void init_user_process_params(void) DECLSPEC_HIDDEN; extern void CDECL DECLSPEC_NORETURN signal_start_thread( CONTEXT *ctx ) DECLSPEC_HIDDEN;
-/* server support */ -extern BOOL is_wow64 DECLSPEC_HIDDEN; - /* module handling */ extern LIST_ENTRY tls_links DECLSPEC_HIDDEN; extern FARPROC RELAY_GetProcAddress( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports, @@ -90,7 +87,9 @@ extern int CDECL NTDLL__vsnwprintf( WCHAR *str, SIZE_T len, const WCHAR *format,
/* load order */
-#ifndef _WIN64 +#ifdef _WIN64 +static inline TEB64 *NtCurrentTeb64(void) { return NULL; } +#else static inline TEB64 *NtCurrentTeb64(void) { return (TEB64 *)NtCurrentTeb()->GdiBatchCount; } #endif
diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index 2101f463287..ab2e828dacd 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -1827,7 +1827,6 @@ static void run_wineboot( WCHAR *env, SIZE_T size )
wine_server_fd_to_handle( 2, GENERIC_WRITE | SYNCHRONIZE, OBJ_INHERIT, ¶ms.hStdError );
-#ifndef _WIN64 if (NtCurrentTeb64() && !NtCurrentTeb64()->TlsSlots[WOW64_TLS_FILESYSREDIR]) { NtCurrentTeb64()->TlsSlots[WOW64_TLS_FILESYSREDIR] = TRUE; @@ -1837,10 +1836,9 @@ static void run_wineboot( WCHAR *env, SIZE_T size ) NtCurrentTeb64()->TlsSlots[WOW64_TLS_FILESYSREDIR] = FALSE; } else -#endif - status = NtCreateUserProcess( &process, &thread, PROCESS_ALL_ACCESS, THREAD_ALL_ACCESS, - NULL, NULL, 0, THREAD_CREATE_FLAGS_CREATE_SUSPENDED, ¶ms, - &create_info, &ps_attr ); + status = NtCreateUserProcess( &process, &thread, PROCESS_ALL_ACCESS, THREAD_ALL_ACCESS, + NULL, NULL, 0, THREAD_CREATE_FLAGS_CREATE_SUSPENDED, ¶ms, + &create_info, &ps_attr ); NtClose( params.hStdError );
if (status) diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c index 35ff3c7dea7..9ee5e84ee43 100644 --- a/dlls/ntdll/unix/file.c +++ b/dlls/ntdll/unix/file.c @@ -3118,11 +3118,7 @@ static NTSTATUS lookup_unix_name( const WCHAR *name, int name_len, char **buffer int ret, len; struct stat st; char *unix_name = *buffer; -#ifdef _WIN64 - const BOOL redirect = FALSE; -#else const BOOL redirect = NtCurrentTeb64() && !NtCurrentTeb64()->TlsSlots[WOW64_TLS_FILESYSREDIR]; -#endif
/* try a shortcut first */
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 1d3a940aab8..9c6d58d94ee 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -1439,10 +1439,8 @@ BOOL is_builtin_path( const UNICODE_STRING *path, WORD *machine ) if (path->Length > wcslen(system_dir) * sizeof(WCHAR) && !wcsnicmp( path->Buffer, system_dir, wcslen(system_dir) )) { -#ifndef _WIN64 if (NtCurrentTeb64() && NtCurrentTeb64()->TlsSlots[WOW64_TLS_FILESYSREDIR]) *machine = IMAGE_FILE_MACHINE_AMD64; -#endif goto found; } if ((is_win64 || is_wow64) && path->Length > sizeof(wow64W) && diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index b49789b641e..c02a8f50b24 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -315,7 +315,9 @@ static inline void mutex_unlock( pthread_mutex_t *mutex ) if (!process_exiting) pthread_mutex_unlock( mutex ); }
-#ifndef _WIN64 +#ifdef _WIN64 +static inline TEB64 *NtCurrentTeb64(void) { return NULL; } +#else static inline TEB64 *NtCurrentTeb64(void) { return (TEB64 *)NtCurrentTeb()->GdiBatchCount; } #endif