none
Managed c++ library looking for systemWOW64 folder instead system32 folder. RRS feed

  • Question

  • I have C# console application which uses two manged libraries one made  in C# and other in C++.The C++ library in turns calls unmanaged code inorder to call some other API's.
    I am facing some strange issues in x64 bit Vista platform. In c# dll  there is a function which checks for a exe at  %SystemRoot%\System32\xyz.exe . When I try to run my c# application using both c++ dll and c# dll then on x64 machines it reads path as %SysetmRoot%\SystemWOW64\  and fails to launch the exe.

    But the same goes well with  32 bit. If I am not using managed C++ dll then everything goes well. This also works fine when I manually copy exe in SystemWOW64 folder.
    Can any one help me way by which I can force managed library to check to system32 folder and not systemWOW64 so that I can run exe correctly.??
    Any Help is appreciated.
    Friday, June 19, 2009 10:48 AM

Answers

  • This sounds entirely normal, a side-effect of Vista x64's file system redirection designed to allow 64-bit and 32-bit programs to co-exist on the same machine.  When a 32-bit program asks for a file in c:\windows\system32, like it would on a 32-bit operating system, it gets redirected to c:\windows\syswow64.  The same thing happens for c:\program files (x86). 

    Technically, it is possible to disable this by P/Invoking Wow64DisableWow64FsRedirection().  Not a good idea.  Your xyz.exe belongs in c:\windows\syswow64 since it is a 32-bit program.  Well, assuming its a Microsoft program.  Once you created a 64-bit version of your C++ library, you can start using the 64-bit version of the framework and regular paths. 

    Hans Passant.
    Friday, June 19, 2009 11:14 AM
    Moderator

All replies

  • This sounds entirely normal, a side-effect of Vista x64's file system redirection designed to allow 64-bit and 32-bit programs to co-exist on the same machine.  When a 32-bit program asks for a file in c:\windows\system32, like it would on a 32-bit operating system, it gets redirected to c:\windows\syswow64.  The same thing happens for c:\program files (x86). 

    Technically, it is possible to disable this by P/Invoking Wow64DisableWow64FsRedirection().  Not a good idea.  Your xyz.exe belongs in c:\windows\syswow64 since it is a 32-bit program.  Well, assuming its a Microsoft program.  Once you created a 64-bit version of your C++ library, you can start using the 64-bit version of the framework and regular paths. 

    Hans Passant.
    Friday, June 19, 2009 11:14 AM
    Moderator
  • Thanks .
    I am using  Wow64DisableWow64FsRedirection() function in my C# dll to redirect to system32.

    Monday, June 22, 2009 12:04 PM