Silently redirecting 64-bit system files to 32-bit equivalents can be disabled and returned using Wow64DisableWow64FsRedirection and Wow64RevertWow64FsRedirection. We use this for certain checks of file identification in our application.
The problem is that when performing some of these tasks, we can call the framework or the Windows API, which subsequently calls another API in a DLL that is not yet loaded. If redirection is enabled at this time, the wrong version of the dll may be loaded, which will result in an error XXX is not a valid Win32 application .
I have identified some of the API calls in question and what I would like to do is redirect the redirect to the time of this call, and then bring it back - exactly the opposite of the provided Win32 APIs. Unfortunately, these calls do not provide any WOW64 compatibility flag, as some of the registry methods do.
The obvious alternative is to use Wow64EnableWow64FsRedirection, pass TRUE to Wow64FsEanbledRedirection. However, there are many warnings about using this method and a note that it is not compatible with the combined Disable / Revert methods that replaced it.
Is there a safe way to force redirection to call Win32?
The docs indicate that redirection is a thread, so I considered creating a new thread for a specific call with the appropriate locks and expectations, but I was hoping for a simpler solution.
source share