Archive: WinXP x64 redirects system32 files to WOW64 directory


WinXP x64 redirects system32 files to WOW64 directory
I have tried these three different commands to write a file to the C:/Windows/System32/ directory under WinXP x64.

InstallDir "C:\windows\system32" ; Won't work with 9x
InstallDir "$WINDIR\system32" ; Won't work with 9x
InstallDir "$SYSDIR"

Every single time it will write the file to the C:\Windows\WOW64\ directory (only on x64 machines, not XP/2003/9x).

I figure it is a self protection measure by Windows x64 to keep 32-bit software from mingling with the 64-bit software.

I'm trying to make a program that installs the system OEM info, in the system properties box. This costists of two files, "oeminfo.ini" and "oemlogo.bmp", and they must be placed in the system directory (C:\Windows\System\ on 9x, and C:\Windows\System32\ on XP\2000\2003\x64).

Any help or ideas how to circumvent this?


Some more info from Microsoft's site:
http://www.microsoft.com/windowsxp/u...el_x64faq.mspx

Q.
What is the SysWOW64 directory?
A.
The \Windows\SysWOW64 directory is where 32-bit system files are installed. 64-bit system files are in the \Windows\system32 directory for compatibility reasons.

Q.
Why do some of my programs install into the Program Files Directory, and others into the Program Files (X86) directory?
A.
Windows XP Professional x64 Edition redirects the \Program Files directory for all programs that are 32-bit during the installation to the \Program Files(x86) directory. Programs that 64-bit are installed into the \Program Files directory.

More here too:
http://www.sysinternals.com/blog/200...t-windows.html

Windows 2003 SDK API to turn redirect off:
http://msdn.microsoft.com/library/de...edirection.asp


You can call Wow64DisableWow64FsRedirection using the System plug-in:

System::Call "kernel32::Wow64DisableWow64FsRedirection(*i)"

Cool, so do I just call that, then call the enable function again to put it back?


Yes, that should work. Just make sure you call it before $SYSDIR is actually parsed. In InstallDir's case, that's impossible. InstallDir is parsed before any of your code is executed. You'd have to call this in .onInit, copy $SYSDIR into $INSTDIR (using StrCpy) and then call the enable function.


Originally posted by guido666
Cool, so do I just call that, then call the enable function again to put it back?
Actually, unless you want your installer to redirect again there is no need to enable redirection again.

From MSDN documentation:

The Wow64DisableWow64FsRedirection function disables file system redirection for the calling thread.
So, disabling redirection in your installer doesn't disable redirection system wide.

This is not working for me, using System::Call "kernel32::Wow64DisableWow64FsRedirection(*i)"
Is there any way to get a return value from this instruction? documentation says the function returns a bool. Is there a way to tell if there is an error in the syntax?


I got it working, i don't know what stupid thing I must have been doing before. It also works with simply:

System::call "kernel32::Wow64DisableWow64FsRedirection()"


You can also use the macros in x64.nsh, which is included with the current NSIS releases.