Commit 7929b21e authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Define NtCurrentTeb64() on 64-bit to avoid some #ifdefs.

parent e6ed9430
......@@ -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
}
......
......@@ -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 */
......
......@@ -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();
......
......@@ -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
......
......@@ -1827,7 +1827,6 @@ static void run_wineboot( WCHAR *env, SIZE_T size )
wine_server_fd_to_handle( 2, GENERIC_WRITE | SYNCHRONIZE, OBJ_INHERIT, &params.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, &params,
&create_info, &ps_attr );
status = NtCreateUserProcess( &process, &thread, PROCESS_ALL_ACCESS, THREAD_ALL_ACCESS,
NULL, NULL, 0, THREAD_CREATE_FLAGS_CREATE_SUSPENDED, &params,
&create_info, &ps_attr );
NtClose( params.hStdError );
if (status)
......
......@@ -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 */
......
......@@ -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) &&
......
......@@ -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
......
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