Archive: Extending the x64.nsh


Extending the x64.nsh
I'm starting to dig heavily in creating my own header/includes and I identified a shortcoming in the x64.nsh include.

I looked for an API to detect if the file redirection has been disabled but I was unable to locate anything that didn't feel like a hack.

So, I added a new macro to the x64.nsh include named "RestoreX64FSRedirection". It uses the precompiler directives to track the redirection state. It's not perfect as any calls outside of the x64.nsh that changes the redirection state will break it but it's better than nothing. :D

Why go through the trouble? Headers! A header library author never knows what the state of the systems is in prior to the include or macro / function execution. I added this to allow my header code to support 64bit without inadvertently mucking up the developer's code. When he/she installs with redirection enabled they expect it to return to the way they left it after they run one of my macros or functions. It's all about maintaining state. :cool:

x64.nsh v2 on PasteBin.com

What do you guys think?


well if you're going through that trouble, you might as well update it to use the proper Wow64DisableWow64FsRedirection and Wow64RevertWow64FsRedirection API calls ;)


You also have the (major) issue that the order that code fragments appear in a script isn't the order that they will be executed at run time. Therefore you really need to use a run time check for this. If you must, just add a define to make x64.nsh use its own state variable.

Stu


hmmm...... TO THE LAB!!


yep.. what's what we ended up doing. We actually adjusted it a slight bit further to ignore the redirection bits with ${Unless} ${AtLeastWinVista}, and new $SYS32 and $SYS64 variables which are initialized (in .onInit). On Vista+, $SYS64 simply contains the $WINDIR\SysNative folder (avoiding the need for the FS redirector calls), while on XP it's left to $SYSDIR with the FS redirection disable/revert calls taking care of files going to the correct one. It also makes it easier for us to work with because we don't see a bunch of $SYSDIR references having to puzzle from context or comments as to whether the code should be dealing with the 32bit or the 64bit one.