Wow64DisableWow64FsRedirection function (wow64apiset.h)
Disables file system redirection for the calling thread. File system redirection is enabled by default.
Syntax
BOOL Wow64DisableWow64FsRedirection(
[out] PVOID *OldValue
);
Parameters
[out] OldValue
The WOW64 file system redirection value. The system uses this parameter to store information necessary to revert (re-enable) file system redirection.
Return value
If the function succeeds, the return value is a nonzero value.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
This function is useful for 32-bit applications that want to gain access to the native system32 directory. By default, WOW64 file system redirection is enabled.
The Wow64DisableWow64FsRedirection/Wow64RevertWow64FsRedirection function pairing is a replacement for the functionality of the Wow64EnableWow64FsRedirection function.
To restore file system redirection, call the Wow64RevertWow64FsRedirection function. Every successful call to the Wow64DisableWow64FsRedirection function must have a matching call to the Wow64RevertWow64FsRedirection function. This will ensure redirection is re-enabled and frees associated system resources.
In Windows 8 and Windows Server 2012, this function is supported by the following technologies.
Technology | Supported |
---|---|
Server Message Block (SMB) 3.0 protocol | No |
SMB 3.0 Transparent Failover (TFO) | No |
SMB 3.0 with Scale-out File Shares (SO) | No |
Cluster Shared Volume File System (CsvFS) | Yes |
Resilient File System (ReFS) | No |
Examples
The following example uses Wow64DisableWow64FsRedirection to disable file system redirection so that a 32-bit application that is running under WOW64 can open the 64-bit version of Notepad.exe in %SystemRoot%\System32 instead of being redirected to the 32-bit version in %SystemRoot%\SysWOW64.
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT 0x0501
#ifdef NTDDI_VERSION
#undef NTDDI_VERSION
#endif
#define NTDDI_VERSION 0x05010000
#include <Windows.h>
void main()
{
HANDLE hFile = INVALID_HANDLE_VALUE;
PVOID OldValue = NULL;
// Disable redirection immediately prior to the native API
// function call.
if( Wow64DisableWow64FsRedirection(&OldValue) )
{
// Any function calls in this block of code should be as concise
// and as simple as possible to avoid unintended results.
hFile = CreateFile(TEXT("C:\\Windows\\System32\\Notepad.exe"),
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
// Immediately re-enable redirection. Note that any resources
// associated with OldValue are cleaned up by this call.
if ( FALSE == Wow64RevertWow64FsRedirection(OldValue) )
{
// Failure to re-enable redirection should be considered
// a critical failure and execution aborted.
return;
}
}
// The handle, if valid, now can be used as usual, and without
// leaving redirection disabled.
if( INVALID_HANDLE_VALUE != hFile )
{
// Use the file handle
}
}
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows Vista, Windows XP Professional x64 Edition [desktop apps only] |
Minimum supported server | Windows Server 2008, Windows Server 2003 with SP1 [desktop apps only] |
Target Platform | Windows |
Header | wow64apiset.h (include Windows.h) |
Library | Kernel32.lib |
DLL | Kernel32.dll |