[英]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 . 要做到这一点推出这个路径%WINDIR的HH.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.