How to allow 32 bit apps on 64 bit windows to execute 64 bit apps provided in Windows\\System32

£可爱£侵袭症+ 提交于 2019-12-01 06:40:45

I've gone with option 2, For those who might be interested; here is my quick hack at a scoped version of managing the disabling of Wow64 redirection based on notes from MS. Will redirect if the API is available, expects that kernel32.dll is already available.

class Wow64RedirectOff {
    typedef BOOL (WINAPI *FN_Wow64DisableWow64FsRedirection) ( __out PVOID *OldValue );
    typedef BOOL (WINAPI *FN_Wow64RevertWow64FsRedirection) ( __in  PVOID OldValue );

public:
    Wow64RedirectOff() {
        LPFN_Disable = (FN_Wow64DisableWow64FsRedirection)GetProcAddress(
            GetModuleHandle(TEXT("kernel32")),"Wow64DisableWow64FsRedirection");
        if( LPFN_Disable ) {
            LPFN_Disable(&OldValue);
        }
    }

    ~Wow64RedirectOff() {
        if( LPFN_Disable ) {
            FN_Wow64RevertWow64FsRedirection LPFN_Revert = (FN_Wow64RevertWow64FsRedirection)GetProcAddress(
                GetModuleHandle(TEXT("kernel32")),"Wow64RevertWow64FsRedirection");
            if( LPFN_Revert ) {
                LPFN_Revert(OldValue);
            }
        }
    }

private:
    FN_Wow64DisableWow64FsRedirection LPFN_Disable;
    PVOID OldValue; 
};

And thus usage would be

Wow64RedirectOff scopedRedirect;
//CFileOpen
//CreateProcess

Are you getting redirected to Windows/SysWoW64? I can launch 64-bit apps from Windows/System32 from an OpenFile in a 32-bit managed executable.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!