如何允许 64 位 Windows 上的 32 位应用程序执行 WindowsSystem32 中提供的 64 位应用程序 [英] How to allow 32 bit apps on 64 bit windows to execute 64 bit apps provided in WindowsSystem32

查看:38
本文介绍了如何允许 64 位 Windows 上的 32 位应用程序执行 WindowsSystem32 中提供的 64 位应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设您有一个应用,您希望让用户能够浏览 system32 目录并在其中执行程序(如 telnet).

Say you have an app, that you want to provide users ability to browse the system32 directory and execute programs in (like telnet).

当您需要支持 XP 以上的客户端和 2k 以上的服务器时,支持此功能的最佳方法是什么?

What is the best method for supporting this when you need to support XP onwards as a client and 2k onwards for server?

写完所有这些后,我想知道提供浏览来执行此操作是否需要太多时间/精力,他们可以从资源管理器中复制它.仍然需要启动能力.

我发现了一些关于 Nynaeve 的讨论.

I have found some discussion on Nynaeve.

到目前为止似乎有以下选项

So far it seems there are the following options

  1. 在 Windows 中创建一个 sysnative 文件夹,它允许您浏览/执行 64 位.问题是:
    • 仅在 Vista/Longhorn 中可用,因此不支持 XP 64
    • 导致不同的路径命名,不能在多个版本上使用相同的路径.
    • 对整个窗口都有效,而不仅仅是我们的应用
    • 在安装应用程序时可能不适合(可能不适合)
    • 如果有 32 位和 64 位版本,则允许通过路径明确指定要启动的应用程序版本
  • 仅适用于 64 位 - 必须使用 GetProcAddress
  • 仅在某些服务包下可用
  • 必须单独确定应该实施的所有位置
  • 用户需要提供有关这是 64 位应用还是 32 位应用的单独信息.

如果有人有一些示例代码来显示 Windows OpenFile 对话框(比如使用 MFC CFileDialog),该对话框在 XP/Vista 中显示原生并允许查看 64 位 system32 目录,那就太棒了.

If anybody had some example code which displayed a Windows OpenFile dialog (say using MFC CFileDialog) showing nativly for XP/Vista and allowing the viewing of 64 bit system32 directory, that would be awesome.

如果有人有启动命名应用程序的示例,那就太好了!

If anybody had an example of launching the named app, that would also be great!


目前我们使用 CreateProcess 来启动应用程序(失败).


Currently we use CreateProcess for launching the app (which is failing).

err = CreateProcess((wchar_t*)exeName.c_str(), (wchar_t*)cmdLine.c_str(), NULL, NULL, FALSE, CREATE_SEPARATE_WOW_VDM, NULL, workingDir.c_str(), &startupInfo, &processInfo);

推荐答案

我选择了选项 2,对于那些可能感兴趣的人;这是我根据 MS 的注释管理禁用 Wow64 重定向的范围版本的快速破解.如果 API 可用,将重定向,预计 kernel32.dll 已经可用.

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; 
};

因此用法是

Wow64RedirectOff scopedRedirect;
//CFileOpen
//CreateProcess

这篇关于如何允许 64 位 Windows 上的 32 位应用程序执行 WindowsSystem32 中提供的 64 位应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆