Could not find system file when it actually exists

后端 未结 2 1758
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-30 09:15

System can\'t find alg.exe but it does exist - \"c:\\windows\\system32\\alg.exe\".

I\'ve moved from Win 7 x86 to x64 recently and when I wa

2条回答
  •  执念已碎
    2020-11-30 09:46

    You have a 32 bit process running on a 64 bit system. Your process runs inside the WOW64 emulator and is subject to the File System Redirector. This redirects references to the 64 bit system folder, %windir%\System32, to the 32 bit system folder, %windir%\SysWOW64.

    The recommended way to gain access to the 64 bit system folder, from within a 32 bit process running under the emulator is to use the %windir%\Sysnative alias:

    32-bit applications can access the native system directory by substituting %windir%\Sysnative for %windir%\System32. WOW64 recognizes Sysnative as a special alias used to indicate that the file system should not redirect the access. This mechanism is flexible and easy to use, therefore, it is the recommended mechanism to bypass file system redirection. Note that 64-bit applications cannot use the Sysnative alias as it is a virtual directory not a real one.

    Naturally, this alias only exists on 64 bit systems. The simplest way to check that is to test the value of TOSVersion.Architecture.

    Whilst it is possible to disable the redirector, it is not advisable to do so. The documentation says:

    Applications can control the WOW64 file system redirector using the Wow64DisableWow64FsRedirection, Wow64EnableWow64FsRedirection, and Wow64RevertWow64FsRedirection functions. Disabling file system redirection affects all file operations performed by the calling thread, so it should be disabled only when necessary for a single CreateFile call and re-enabled again immediately after the function returns. Disabling file system redirection for longer periods can prevent 32-bit applications from loading system DLLs, causing the applications to fail.

    I would strongly advise you against disabling the file system redirector.

提交回复
热议问题