Jump to content
Sign in to follow this  
RvdH

X64 - Wow64DisableWow64FsRedirection

Recommended Posts

RvdH

Hi, quick question

I got a script that should work identical on X86 as on X64, now i have read in the manual i need to use "Wow64DisableWow64FsRedirection" to succesfully copy files on both X86 as X64 systems,

if @ProcessorArch = "X64" then DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)
oÝ÷ Ù(hºWbzvè­j¢§íz»azÇ+^Ö§u·¢·­êk¢
ÚÉh±ë(®È­+¢wºÚ&'m~)Ýv*Þrدzȧëh"Ø^®¶­s`¦b&ö6W76÷$&6ÒgV÷CµcBgV÷C²FVâFÆÄ6ÆÂgV÷C¶¶W&æVÃ3"æFÆÂgV÷C²ÂgV÷C¶çBgV÷C²ÂgV÷Cµv÷scDF6&ÆUv÷scDg5&VF&V7FöâgV÷C²ÂgV÷C¶çBgV÷C²Â¤W@

Thx,

RvdH

Share this post


Link to post
Share on other sites
martin

Hi, quick question

I got a script that should work identical on X86 as on X64, now i have read in the manual i need to use "Wow64DisableWow64FsRedirection" to succesfully copy files on both X86 as X64 systems,

if @ProcessorArch = "X64" then DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)
oÝ÷ Ù(hºWbzvè­j¢§íz»azÇ+^Ö§u·¢·­êk¢
ÚÉh±ë(®È­+¢wºÚ&'m~)Ýv*Þrدzȧëh"Ø^®¶­s`¦b&ö6W76÷$&6ÒgV÷CµcBgV÷C²FVâFÆÄ6ÆÂgV÷C¶¶W&æVÃ3"æFÆÂgV÷C²ÂgV÷C¶çBgV÷C²ÂgV÷Cµv÷scDF6&ÆUv÷scDg5&VF&V7FöâgV÷C²ÂgV÷C¶çBgV÷C²Â¤W@

Thx,

RvdH

The file redirectioon is only disabled for the calling thread, ie for your script, so you don't need to call Wow64RevertWow64FsRedirection on exit, but if you do it won't hurt.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
RvdH

thx for the quick reply

Ok, so if i would make sure it is back on i should use something similair to the line below?

if @ProcessorArch = "X64" then DllCall("kernel32.dll", "int", "Wow64RevertWow64FsRedirection", "int", 1)

Share this post


Link to post
Share on other sites
martin

thx for the quick reply

Ok, so if i would make sure it is back on i should use something similair to the line below?

if @ProcessorArch = "X64" then DllCall("kernel32.dll", "int", "Wow64RevertWow64FsRedirection", "int",    1)
That is not quite right.

It really needs someone a bit more expert to advise you on this, but anyway I think you are calling the function the wrong way. It may work, but you should be using a pointer to a variable as a parameter not the value 1. Maybe you are using 1 because you think 1 turns the feature on, but the function

Wow64DisableWow64FsRedirection disbales redirection, and puts the value of the current state of redirection into the variable pointed to by the parameter passed to it.

I think it should go something like this

Global $a,$redirstatep

$a  = DllStructCreate("uint");don't know if uint is correct here because I don't know what a void pointer   
                                        ;should point to
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif

$redirstatep= DllStructGetPtr($a,1)

if @ProcessorArch = "X64" then 
   DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "ptr", $redirstatep)
;now there is a record of the previous state of redirection in the $a structure.
endif



.
.
.
.
if @ProcessorArch = "X64" then;put back the state which existed before we changed it
DllCall("kernel32.dll", "int", "Wow64RevertWow64FsRedirection", "uint", DllStructGetData($a,1))

$a = 0;release the memory for the variable

I'm not good at this aspect so it would be better if someone could confirm or correct what I've said.

However, I think I am fairly close.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
The Kandie Man

I am curious as to why you would want to disable the 32bit redirection. The only reason one would disable the 32bit redirection is if they had a 32bit installer that was installing a 64bit application. Other than that, the 32bit redirection should be used. The program will still perform all tasks identically, just in different folders and in a different set of registry subkeys for the HKEY_Local_Machine. For one, I would be quite irritated if a 32bit program installed itself in my 64bit Program Files folder.

In addition, you will not be able to load system libraries correctly since the 32bit application will be redirected to the 64bit system folder. If a 32bit program attempts to load a 64bit DLL, for example user32.dll or kernel32.dll, the program will probably end up critically failing. A 32bit program cannot load a 64bit dll and a 64bit program cannot load a 32bit dll.

Also, when a 32bit program writes to HKEY_LOCAL_MACHINE\SOFTWARE, it will be redirected to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node. The redirection only applies to the Local Machine key. The Current User branch does not have a redirection node.

I just wanted to let you know in case you were unaware of any of this.

The Kandie Man


"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Share this post


Link to post
Share on other sites
RvdH

Hi Kandie Man ,

My script is not like that. I do not use dll's call whatsoever, just coping files and adding regsitry entries

I just wan't the program to copy OEM specific files to

"C:\Windows\System32\oobe\" both on X86 and the X64 platform

Without Wow64DisableWow64FsRedirection on X64 the autoit program would copy these files to:

C:\Windows\Syswow64\oobe\

instead of:

C:\Windows\System32\oobe\

These files need to be in: C:\Windows\System32\oobe\ to be displayed properly

post-317-1176380414_thumb.gif

Share this post


Link to post
Share on other sites
RvdH

That is not quite right.

It really needs someone a bit more expert to advise you on this, but anyway I think you are calling the function the wrong way. It may work, but you should be using a pointer to a variable as a parameter not the value 1. Maybe you are using 1 because you think 1 turns the feature on, but the function

Wow64DisableWow64FsRedirection disbales redirection, and puts the value of the current state of redirection into the variable pointed to by the parameter passed to it.

I think it should go something like this

Global $a,$redirstatep

$a  = DllStructCreate("uint");don't know if uint is correct here because I don't know what a void pointer   
                                    ;should point to
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif

$redirstatep= DllStructGetPtr($a,1)

if @ProcessorArch = "X64" then 
   DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "ptr", $redirstatep)
;now there is a record of the previous state of redirection in the $a structure.
endif
.
.
.
.
if @ProcessorArch = "X64" then;put back the state which existed before we changed it
DllCall("kernel32.dll", "int", "Wow64RevertWow64FsRedirection", "uint", DllStructGetData($a,1))

$a = 0;release the memory for the variable

I'm not good at this aspect so it would be better if someone could confirm or correct what I've said.

However, I think I am fairly close.

Can anyone confirm and check what martin wrote?

Thx,

RvdH

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×