Loading a 32-bit process in a 64-bit environment

I have a couple of questions as shown below. CHM (compiled HTML file)

There is a link in my CHM file to launch a 32-bit application. CHM file encoded in Javascript. This works great in a 32-bit OS environment.

But this does not work in a 64-bit environment. The reason is that when you open the chm file, the 64-bit version of hh.exe (the executable file of the operating system) runs and starts chm. And chm loads into a 64-bit environment.
And now I can not start a 32-bit application from a CHM file, because a 64-bit process cannot load a 32-bit process.

Is there a way to make it work for a 64-bit OS?

I was thinking of several solutions as shown below, but I do not know how to implement them.

1) In Javascript code, if I could check if the OS is 32-bit or 64-bit. Then I could pop up a well-defined error for the user if it is a 64-bit OS.

2) Or if I can get the OS to run the 32-bit version of hh.exe, so that chm loads into a 32-bit environment and therefore does not cause any problems.

+3
source share
3 answers

And now I can not start a 32-bit application from a CHM file, because a 64-bit process cannot load a 32-bit process

, " 32- ", 32- , , 64- . , MyApp32.exe, 32- , MyApp64.exe, 64- .

32- 64- , 32- , 64- DLL, .

, - , , WOW64. 32- , C:\Windows\System32, C:\Windows\SysWow64\System32.

, , 32- , .

+1

3) 64- , CHM?

0

32- hh.exe. hh.exe % WINDIR%\System32\hh.exe, Wow64.

:

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

.

0

Source: https://habr.com/ru/post/1709183/


All Articles