Windows 8 File redirection
-
10 April 2012 6:37
Hi,
I am trying to use the file system redirection in windows 8 64Bit (Server beta and also consumer preview) when using 32 Bit programs. Works ok in windows 7.
I used Borland delphi 7 to make the api calls but i assume c# or c++ or .net will fail in the same manner.
Here are the steps to reproduce (you will need to write a 32 bit program to make the api calls and run it with administrator privelige for UAC.
1. Make a call to "Wow64DisableWow64FsRedirection"
2. Make a call to "Wow64RevertWow64FsRedirection"
3. Make a call to "GetFileVersionInfoSize" passing a the name of a file in the first parameter that exists in the system32 directory. This is the crutial step which seems to break things. eg. c:\windows\system32\aepic.dll. The file path MUST point to system32.
4. Do a CopyFile (using copyFile api) from anywhere to the system32 directory. eg. CopyFile('c:\users\public\test.txt', 'c:\windows\system32\test.txt', false)
The result should be that the file is copied to c:\windows\syswow64\test.txt due to redirection, however in ends up in c:\windows\system32.
On windows 7 it is correctly copied to c:\windows\syswow64.
If i remove the GetFileVersionInfoSize call then it works correctly, so i suspect that this function is breaking the redirection.
As this behaviour is different to windows7 i assume it may be a bug rather than a feature?
Any suggestions?
Thanks.
Semua Balasan
-
11 April 2012 6:50Moderator
Hi Ryan,
Welcome to the MSDN Forum.
According to this documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365743(v=vs.85).aspx
Every successful call to theWow64DisableWow64FsRedirection function must have a matching call to the Wow64RevertWow64FsRedirection function. This will ensure redirection is re-enabled and frees associated system resources.
So the program structure should be:
1. Call Wow64DisableWow64FsRedirection
2. Your actions
3. Call Wow64RevertWow64FsRedirection
Am I right?
If I misunderstood anything, please feel free to follow up.
Best regards,
Mike Feng
MSDN Community Support | Feedback to us
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-
12 April 2012 6:09
Hi Mike,
You are correct in that i am making a call to Wow64Revert64FsRedirection after a call to Wow64DisableWow64FsRedirection (so associated resources are freed).
However, if a make a call to GetFileVersionInfoSize to a file in the SYSTEM32 directory AFTER Wow64Revert64FsRedirection it seems the redirection is broken or not working. Therefore i assume the GetFileVersionInfoSize function may have the fault?
Here is my program structure:
1. Call Wow64DisableWow64FSRedirection
2. Do some stuff. Doesn't really matter what.
3. Call Wow64RevertWow64FsRedirection
4. Call GetFileVersionInfoSize of a file in the windows\system32 directory
5. Copy a file from point A to c:\windows\system32.
As the file redirection has been reverted the file SHOULD end up in c:\windows\syswow64 however it goes to c:\windows\system32. If i remove step 4 (the call to GetFileVersionInfoSize) then it works as expected (eg. File goes to c:\windows\syswow64)
This works ok in windows 7 but fails in windows 8 (CP and Server Beta). So not sure if it is win8 bug or intended change in behaviour?
Thanks.
-
12 April 2012 6:16Moderator
Hi Ryan,
I think I understanding you very clear now. And I am performing research on this issue and will get back to you as soon as possible. I appreciate your patience.
Best regards,
Mike Feng
MSDN Community Support | Feedback to us
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-
16 April 2012 9:47
Does it occurs when calling GetFileVersionInfoSize with a file in windows\system32 directory only? Or just call GetFileVersionInfoSize of any file.
And could you please share a sample to reproduce this issue?
Thanks!
Best Regards,
Han Xia
-
17 April 2012 0:48
Hi,
Yes, it occurs when calling GetFileVersionInfoSize with a file in windows\system32 directory ONLY. If it is called with a file in a different directory then the problem does NOT occur.
Here is a url to download a simple sample which highlights the problem. I have included source (in unit1.pas file) but you will require Borland Delphi 7 if you need to recompile. I have also included a complied version with alert points to illustrate what is happening.
http://downloads.stamina.com.au/Project1.zip
Please let me know if you need any further clarification.
Thanks.
-
20 April 2012 4:50
Hi,
Just wondering it there are any updates to this problem that i reported?
Thanks.
-
29 Mei 2012 5:38
We don't support delphi code. However, the C++ code works well without any problem in my side:
BOOL bRet;
HANDLE hFile = INVALID_HANDLE_VALUE;
PVOID OldValue = NULL;
DWORD dwHandle=NULL;
// Disable redirection immediately prior to the native API
// function call.
bRet=Wow64DisableWow64FsRedirection(&OldValue);
bRet=Wow64RevertWow64FsRedirection(OldValue);
GetFileVersionInfoSize(L"c:\\windows\\system32\\aepic.dll",&dwHandle);bRet=CopyFile(L"D:\\test.txt",L"c:\\windows\\system32\\test1.txt",false);
Best Regards,
Han Xia