简体   繁体   English

在64位环境中加载32位进程

[英]Loading a 32-bit process in a 64-bit environment

I have a couple of questions as below. 我有几个问题如下。 CHM is (Compiled HTML File) CHM是(编译的HTML文件)

My CHM file has a link to launch a 32-bit application. 我的CHM文件有一个启动32位应用程序的链接。 The CHM file is coded in Javascript.This works fine in a 32-bit OS environment. CHM文件用Javascript编码。这在32位操作系统环境中工作正常。

But this does not work in a 64 bit OS environment.The reason being: When I open the chm file,64-bit version of hh.exe(an operating system executable) executes and launches the chm. 但这在64位操作系统环境中不起作用。原因是:当我打开chm文件时,64位版本的hh.exe(操作系统可执行文件)执行并启动chm。 And the chm gets loaded in a 64-bit environment. 并且chm在64位环境中加载。
And now I cannot launch the 32 bit application from the CHM file, because a 64-bit process cannot load a 32-bit process. 现在我无法从CHM文件启动32位应用程序,因为64位进程无法加载32位进程。

Is there any way I can make it work for 64-bit OS as well ? 有什么方法可以让它适用于64位操作系统吗?

I thought of few solutions as below but I dont know how to implement them . 我想到了几个解决方案如下,但我不知道如何实现它们。

1)In Javascript code,if I could check whether the OS is a 32-bit or 64 bit.Then I could pop-up a well-defined error to user,if it is 64-bit OS. 1)在Javascript代码中,如果我可以检查操作系统是32位还是64位。然后我可以向用户弹出定义良好的错误,如果它是64位操作系统。

2)Or if I could force the OS to run the 32-bit version of hh.exe, so that the chm is loaded in a 32-bit environment and hence causing no problem. 2)或者,如果我可以强制操作系统运行32位版本的hh.exe,以便chm在32位环境中加载,因此没有问题。

And now I cannot launch the 32 bit application from the CHM file, because a 64-bit process cannot load a 32-bit process 现在我无法从CHM文件启动32位应用程序,因为64位进程无法加载32位进程

Not sure what you mean by 'load a 32-bit process', but a 32-bit process can most certainly create a 64-bit process. 不确定'加载32位进程'是什么意思,但32位进程肯定会创建一个64位进程。 For example, if I have MyApp32.exe, a 32-bit application, it can absolutely launch MyApp64.exe, a 64-bit application. 例如,如果我有一个32位应用程序MyApp32.exe,它绝对可以启动一个64位应用程序MyApp64.exe。

When you read about incompatibilities between 32- and 64-bit code, it refers to a 32-bit application loading a 64-bit DLL, or vice versa. 当您阅读32位和64位代码之间的不兼容性时,它指的是加载64位DLL的32位应用程序,反之亦然。

I suspect your problem is actually the path you are using to launch the application is running afoul of the WOW64 file system redirection. 我怀疑你的问题实际上是你用来启动应用程序的路径与WOW64文件系统重定向相冲突。 In this scheme, 32-bit applications that access C:\\Windows\\System32, are actually redirected to C:\\Windows\\SysWow64\\System32. 在此方案中,访问C:\\ Windows \\ System32的32位应用程序实际上被重定向到C:\\ Windows \\ SysWow64 \\ System32。 You can read about that more here 你可以在这里阅读更多内容

If that doesn't work, more information about how you are launching this 32-bit process and where it is located on the file system might add some clarity. 如果这不起作用,有关如何启动此32位进程以及它在文件系统中的位置的更多信息可能会增加一些清晰度。

或者3)分发由CHM发布的64位版本的应用程序?

You need to execute the 32 bits version of hh.exe . 您需要执行32位版本的hh.exe To do this launch the hh.exe with this path %WINDIR%\\System32\\hh.exe but before launching the application you must disable the Wow64 file system redirection . 要做到这一点推出这个路径%WINDIRHH.EXE%\\ SYSTEM32 \\ HH.EXE但启动必须在申请前禁用WOW64文件系统重定向

Here you have an example: 这里有一个例子:

#define _WIN32_WINNT 0x0501
#include <Windows.h>

void main()
{
    PVOID OldValue;
    HANDLE hFile = INVALID_HANDLE_VALUE;

    BOOL bRet = Wow64DisableWow64FsRedirection (&OldValue);

    if (bRet == TRUE) 
    {
        // Open a file

        hFile = CreateFile(TEXT("C:\\Windows\\System32\\Notepad.exe"),
            GENERIC_READ,
            FILE_SHARE_READ,
            NULL,
            OPEN_EXISTING,
            FILE_ATTRIBUTE_NORMAL,
            NULL);

        // Restore the previous WOW64 file system redirection value.

        Wow64RevertWow64FsRedirection (OldValue);
    }

    if( INVALID_HANDLE_VALUE != hFile )  
    {
        // Use the file handle
    }
}

NOTE: Remember to revert the redirection after you call the application 注意:请记住在调用应用程序后还原重定向

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 用JavaScript实现32位浮点数或64位long? - Implementation of 32-bit floats or 64-bit longs in JavaScript? 在JavaScript中使用64位结果的32位带符号乘法 - 32-bit signed multiplication with a 64-bit result in JavaScript 在32位和/或64位firefox(版本25.0.1)上具有js-ctypes的firefox扩展 - firefox extension with js-ctypes on 32-bit and/or 64-bit firefox (version 25.0.1) 通过Google Web Toolkit检测64位或32位Windows - Detect 64-bit or 32-bit Windows from Google Web Toolkit 从用户代理或Java代码检测64位或32位Windows? - Detect 64-bit or 32-bit Windows from User Agent or Javascript? 如何在JavaScript中从高位和低位32位部分创建64位整数时防止过大的值? - How to guard against too-large values when creating a 64-bit integer from high and low 32-bit parts in JavaScript? 具有64位整数的哈希表 - Hashtable with 64-bit integers Electron-builder 应用程序显示 32 位的空白屏幕,但适用于 64 位版本 - Electron-builder app show blank screen for 32 bit, but works for 64-bit version JavaScript中的32位有符号整数数学 - 32-bit signed integer math in JavaScript 如何在数组缓冲区中存储 32 位 integer? - How to store a 32-bit integer in an arraybuffer?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM