From 747d58d211e76a7c06b2cd412dd43f4d71bbd82e Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 6 Jul 2009 15:08:39 +0200 Subject: [PATCH] ntdll: Add management of the Wow64 filesystem redirection flag. --- dlls/ntdll/directory.c | 23 +++++++++++++++++++++++ dlls/ntdll/ntdll.spec | 2 ++ dlls/ntdll/ntdll_misc.h | 7 ++++--- dlls/ntdll/process.c | 6 +----- dlls/ntdll/server.c | 8 +++++++- include/winternl.h | 2 ++ 6 files changed, 39 insertions(+), 9 deletions(-) diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c index 41880f4a12..bccfba6aa2 100644 --- a/dlls/ntdll/directory.c +++ b/dlls/ntdll/directory.c @@ -2129,6 +2129,29 @@ done: } +/****************************************************************** + * RtlWow64EnableFsRedirection (NTDLL.@) + */ +NTSTATUS WINAPI RtlWow64EnableFsRedirection( BOOLEAN enable ) +{ + if (!is_wow64) return STATUS_NOT_IMPLEMENTED; + ntdll_get_thread_data()->wow64_redir = enable; + return STATUS_SUCCESS; +} + + +/****************************************************************** + * RtlWow64EnableFsRedirectionEx (NTDLL.@) + */ +NTSTATUS WINAPI RtlWow64EnableFsRedirectionEx( ULONG enable, ULONG *old_value ) +{ + if (!is_wow64) return STATUS_NOT_IMPLEMENTED; + *old_value = ntdll_get_thread_data()->wow64_redir; + ntdll_get_thread_data()->wow64_redir = enable; + return STATUS_SUCCESS; +} + + /****************************************************************** * RtlDoesFileExists_U (NTDLL.@) */ diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index acc69db53d..03686b2820 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -913,6 +913,8 @@ @ stdcall -arch=x86_64 RtlVirtualUnwind(long long long ptr ptr ptr ptr ptr) @ stub RtlWalkFrameChain @ stdcall RtlWalkHeap(long ptr) +@ stdcall RtlWow64EnableFsRedirection(long) +@ stdcall RtlWow64EnableFsRedirectionEx(long ptr) @ stub RtlWriteMemoryStream @ stdcall RtlWriteRegistryValue(long ptr ptr long ptr long) @ stub RtlZeroHeap diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h index 8da7148b30..3032553e9c 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h @@ -71,7 +71,7 @@ extern void virtual_init_threading(void); /* server support */ extern timeout_t server_start_time; -extern unsigned int server_cpus; +extern int is_wow64; extern void server_init_process(void); extern NTSTATUS server_init_process_done(void); extern size_t server_init_thread( void *entry_point ); @@ -198,8 +198,9 @@ struct ntdll_thread_data int request_fd; /* 1e0/310 fd for sending server requests */ int reply_fd; /* 1e4/314 fd for receiving server replies */ int wait_fd[2]; /* 1e8/318 fd for sleeping server requests */ - void *vm86_ptr; /* 1f0/320 data for vm86 mode */ - pthread_t pthread_id; /* 1f4/328 pthread thread id */ + BOOL wow64_redir; /* 1f0/320 Wow64 filesystem redirection flag */ + void *vm86_ptr; /* 1f4/328 data for vm86 mode */ + pthread_t pthread_id; /* 1f8/330 pthread thread id */ }; static inline struct ntdll_thread_data *ntdll_get_thread_data(void) diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c index c129e0a64b..9ec5513a88 100644 --- a/dlls/ntdll/process.c +++ b/dlls/ntdll/process.c @@ -307,11 +307,7 @@ NTSTATUS WINAPI NtQueryInformationProcess( case ProcessWow64Information: if (ProcessInformationLength == sizeof(DWORD)) { -#ifdef __i386__ - *(DWORD *)ProcessInformation = (server_cpus & (1 << CPU_x86_64)) != 0; -#else - *(DWORD *)ProcessInformation = FALSE; -#endif + *(DWORD *)ProcessInformation = is_wow64; len = sizeof(DWORD); } else ret = STATUS_INFO_LENGTH_MISMATCH; diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c index e90ea72f4e..a4f29539a4 100644 --- a/dlls/ntdll/server.c +++ b/dlls/ntdll/server.c @@ -94,7 +94,8 @@ static const enum cpu_type client_cpu = CPU_SPARC; #error Unsupported CPU #endif -unsigned int server_cpus = 0; +static unsigned int server_cpus; +int is_wow64 = FALSE; #ifndef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS /* data structure used to pass an fd with sendmsg/recvmsg */ @@ -1081,6 +1082,11 @@ size_t server_init_thread( void *entry_point ) } SERVER_END_REQ; +#ifndef _WIN64 + is_wow64 = (server_cpus & (1 << CPU_x86_64)) != 0; +#endif + ntdll_get_thread_data()->wow64_redir = is_wow64; + if (ret) { if (ret == STATUS_NOT_SUPPORTED) diff --git a/include/winternl.h b/include/winternl.h index b386787218..6d0b4805d9 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -2512,6 +2512,8 @@ NTSYSAPI BOOLEAN WINAPI RtlValidSid(PSID); NTSYSAPI BOOLEAN WINAPI RtlValidateHeap(HANDLE,ULONG,LPCVOID); NTSYSAPI NTSTATUS WINAPI RtlVerifyVersionInfo(const RTL_OSVERSIONINFOEXW*,DWORD,DWORDLONG); NTSYSAPI NTSTATUS WINAPI RtlWalkHeap(HANDLE,PVOID); +NTSYSAPI NTSTATUS WINAPI RtlWow64EnableFsRedirection(BOOLEAN); +NTSYSAPI NTSTATUS WINAPI RtlWow64EnableFsRedirectionEx(ULONG,ULONG*); NTSYSAPI NTSTATUS WINAPI RtlWriteRegistryValue(ULONG,PCWSTR,PCWSTR,ULONG,PVOID,ULONG); NTSYSAPI NTSTATUS WINAPI RtlpNtCreateKey(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*,ULONG,const UNICODE_STRING*,ULONG,PULONG); NTSYSAPI NTSTATUS WINAPI RtlpNtEnumerateSubKey(HANDLE,UNICODE_STRING *, ULONG);