VirtualBox

Changeset 107860 in vbox for trunk/src/VBox/Additions/WINNT


Ignore:
Timestamp:
Jan 20, 2025 5:53:12 PM (4 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167062
Message:

Add/Nt/Installer: Pick right NSIS installer from the loader stub.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Installer/Loader/VBoxWindowsAdditions.cpp

    r107083 r107860  
    5151#endif
    5252
    53 
    5453#ifdef VBOX_SIGNING_MODE
    5554# if 1 /* Whether to use IPRT or Windows to verify the executable signatures. */
     
    6362#  include <iprt/crypto/pkcs7.h>
    6463#  include <iprt/crypto/store.h>
     64#endif
     65
     66
     67/*********************************************************************************************************************************
     68*   Structures and Typedefs                                                                                                      *
     69*********************************************************************************************************************************/
     70typedef BOOL (WINAPI *PFNISWOW64PROCESS)(HANDLE, PBOOL);
     71typedef BOOL (WINAPI *PFNISWOW64PROCESS2)(HANDLE, USHORT *, USHORT *);
     72
     73
     74#ifdef VBOX_SIGNING_MODE
    6575
    6676class CryptoStore
     
    897907}
    898908
     909/**
     910 * Detects the native host platform and returns the appropriate installer
     911 * executable suffix for it.
     912 *
     913 * @returns Architecture stuff string.
     914 */
     915static const wchar_t *GetNativeArchInstallerSuffix(void)
     916{
     917    HMODULE const      hModKernel32 = GetModuleHandleW(L"kernel32.dll");
     918    PFNISWOW64PROCESS2 pfnIsWow64Process2 = (PFNISWOW64PROCESS2)GetProcAddress(hModKernel32, "IsWow64Process2");
     919    if (pfnIsWow64Process2)
     920    {
     921        USHORT usWowMachine  = IMAGE_FILE_MACHINE_UNKNOWN;
     922        USHORT usHostMachine = IMAGE_FILE_MACHINE_UNKNOWN;
     923        if (pfnIsWow64Process2(GetCurrentProcess(), &usWowMachine, &usHostMachine))
     924        {
     925            if (usHostMachine == IMAGE_FILE_MACHINE_AMD64)
     926                return L"-amd64.exe";
     927            if (usHostMachine == IMAGE_FILE_MACHINE_ARM64)
     928                return L"-arm64.exe";
     929            if (usHostMachine == IMAGE_FILE_MACHINE_I386)
     930                return L"-x86.exe";
     931            ErrorMsgSU("IsWow64Process2 return unknown host machine value: ", usHostMachine);
     932        }
     933        else
     934            ErrorMsgLastErr("Unable to determine the process type! (#2)");
     935    }
     936    else
     937    {
     938        PFNISWOW64PROCESS pfnIsWow64Process = (PFNISWOW64PROCESS)GetProcAddress(hModKernel32, "IsWow64Process");
     939        if (pfnIsWow64Process)
     940        {
     941            BOOL fIsWow64 = TRUE;
     942            if (pfnIsWow64Process(GetCurrentProcess(), &fIsWow64))
     943            {
     944                if (fIsWow64)
     945                    return L"-amd64.exe";
     946            }
     947            else
     948                ErrorMsgLastErr("Unable to determine the process type!");
     949        }
     950    }
     951
     952#ifdef RT_ARCH_X86
     953    return L"-x86.exe";
     954#elif defined(RT_ARCH_AMD64)
     955    return L"-amd64.exe";
     956#elif defined(RT_ARCH_ARM64)
     957    return L"-arm64.exe";
     958#else
     959# error "port me"
     960#endif
     961}
     962
    899963static int WaitForProcess2(HANDLE hProcess)
    900964{
     
    9951059    }
    9961060
    997 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
    998     WCHAR const  *pwszSuff = IsWow64() ? L"-amd64.exe" : L"-x86.exe";
    999 #elif defined(RT_ARCH_ARM64)
    1000     WCHAR const  *pwszSuff = L"-arm64.exe";
    1001 #else
    1002 # error "Port me!"
    1003 #endif
    1004 
     1061    WCHAR const * const pwszSuff = GetNativeArchInstallerSuffix();
    10051062    int rc = RTUtf16Copy(&wszExePath[cwcExePath], RT_ELEMENTS(wszExePath) - cwcExePath, pwszSuff);
    10061063    if (RT_FAILURE(rc))
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette