VirtualBox

Changeset 106984 in vbox for trunk


Ignore:
Timestamp:
Nov 13, 2024 12:54:01 PM (2 weeks ago)
Author:
vboxsync
Message:

Installer/win/Stub*: ARM64 changes. Kicked out unnecessary VBoxStub.h header file. jiraref:VBP-1442

Location:
trunk/src/VBox/Installer/win
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Installer/win/Stub/VBoxStub.cpp

    r106798 r106984  
    6161#endif
    6262
    63 #include "VBoxStub.h"
    6463#include "../StubBld/VBoxStubBld.h"
    6564#include "resource.h"
     
    7473*   Defined Constants And Macros                                                                                                 *
    7574*********************************************************************************************************************************/
     75#define VBOX_STUB_TITLE "VirtualBox Installer"
     76
    7677#define MY_UNICODE_SUB(str) L ##str
    7778#define MY_UNICODE(str)     MY_UNICODE_SUB(str)
     
    110111/** Pointer to a cleanup record. */
    111112typedef STUBCLEANUPREC *PSTUBCLEANUPREC;
     113
     114typedef BOOL (WINAPI *PFNISWOW64PROCESS)(HANDLE, PBOOL);
     115typedef BOOL (WINAPI *PFNISWOW64PROCESS2)(HANDLE, USHORT *, USHORT *);
    112116
    113117
     
    472476 * Detects whether we're running on a 32- or 64-bit platform and returns the result.
    473477 *
    474  * @returns TRUE if we're running on a 64-bit OS, FALSE if not.
    475  */
    476 static BOOL IsWow64(void)
    477 {
    478     BOOL fIsWow64 = TRUE;
    479     fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "IsWow64Process");
    480     if (NULL != fnIsWow64Process)
    481     {
    482         if (!fnIsWow64Process(GetCurrentProcess(), &fIsWow64))
     478 * @returns Returns the native package architecture.
     479 */
     480static VBOXSTUBPKGARCH GetNativePackageArch(void)
     481{
     482    HMODULE const      hModKernel32 = GetModuleHandleW(L"kernel32.dll");
     483    PFNISWOW64PROCESS2 pfnIsWow64Process2 = (PFNISWOW64PROCESS2)GetProcAddress(hModKernel32, "IsWow64Process2");
     484    if (pfnIsWow64Process2)
     485    {
     486        USHORT usWowMachine  = IMAGE_FILE_MACHINE_UNKNOWN;
     487        USHORT usHostMachine = IMAGE_FILE_MACHINE_UNKNOWN;
     488        if (pfnIsWow64Process2(GetCurrentProcess(), &usWowMachine, &usHostMachine))
    483489        {
    484             /* Error in retrieving process type - assume that we're running on 32bit. */
    485             return FALSE;
     490            if (usHostMachine == IMAGE_FILE_MACHINE_AMD64)
     491                return VBOXSTUBPKGARCH_AMD64;
     492            if (usHostMachine == IMAGE_FILE_MACHINE_ARM64)
     493                return VBOXSTUBPKGARCH_ARM64;
     494            if (usHostMachine == IMAGE_FILE_MACHINE_I386)
     495                return VBOXSTUBPKGARCH_X86;
     496            LogError("IsWow64Process2 return unknown host machine value: %#x (wow machine %#x)", usHostMachine, usWowMachine);
    486497        }
    487     }
    488     return fIsWow64;
     498        else
     499            LogError("IsWow64Process2 failed: %u", GetLastError());
     500    }
     501    else
     502    {
     503        PFNISWOW64PROCESS pfnIsWow64Process = (PFNISWOW64PROCESS)GetProcAddress(hModKernel32, "IsWow64Process");
     504        if (pfnIsWow64Process)
     505        {
     506            BOOL fIsWow64 = TRUE;
     507            if (pfnIsWow64Process(GetCurrentProcess(), &fIsWow64))
     508            {
     509                if (fIsWow64)
     510                    return VBOXSTUBPKGARCH_AMD64;
     511            }
     512            else
     513                LogError("IsWow64Process failed: %u\n", GetLastError());
     514        }
     515        else
     516            LogError("Neither IsWow64Process nor IsWow64Process2 was found!");
     517    }
     518
     519#ifdef RT_ARCH_X86
     520    return VBOXSTUBPKGARCH_X86;
     521#elif defined(RT_ARCH_AMD64)
     522    return VBOXSTUBPKGARCH_AMD64;
     523#elif defined(RT_ARCH_ARM64)
     524    return VBOXSTUBPKGARCH_ARM64;
     525#else
     526# error "port me"
     527#endif
    489528}
    490529
     
    501540    if (pPackage->enmArch == VBOXSTUBPKGARCH_ALL)
    502541        return true;
    503     VBOXSTUBPKGARCH enmArch = IsWow64() ? VBOXSTUBPKGARCH_AMD64 : VBOXSTUBPKGARCH_X86;
     542    VBOXSTUBPKGARCH enmArch = GetNativePackageArch();
    504543    return pPackage->enmArch == enmArch;
    505544}
     
    14271466    if (   !fExtractOnly
    14281467        && !g_fSilent
    1429         && !IsWow64())
     1468        && GetNativePackageArch() == VBOXSTUBPKGARCH_X86)
    14301469        rcExit = ShowError("32-bit Windows hosts are not supported by this VirtualBox release.");
    14311470    else
  • trunk/src/VBox/Installer/win/StubBld/VBoxStubBld.cpp

    r106061 r106984  
    181181            && strcmp(pszArg, "-target-all")
    182182            && strcmp(pszArg, "-target-x86")
    183             && strcmp(pszArg, "-target-amd64"))
     183            && strcmp(pszArg, "-target-amd64")
     184            && strcmp(pszArg, "-target-arm64"))
    184185        {
    185186            fprintf(stderr, "syntax error: Invalid parameter: %s\n", argv[i]);
     
    212213            else if (strcmp(pszArg, "-target-amd64") == 0)
    213214                aBuildPkgs[StubHdr.cPackages].enmArch = VBOXSTUBPKGARCH_AMD64;
     215            else if (strcmp(pszArg, "-target-arm64") == 0)
     216                aBuildPkgs[StubHdr.cPackages].enmArch = VBOXSTUBPKGARCH_ARM64;
    214217            else if (strcmp(pszArg, "-target-x86") == 0)
    215218                aBuildPkgs[StubHdr.cPackages].enmArch = VBOXSTUBPKGARCH_X86;
  • trunk/src/VBox/Installer/win/StubBld/VBoxStubBld.h

    r106061 r106984  
    6363    VBOXSTUBPKGARCH_X86,
    6464    /** Extract on AMD64 hosts. */
    65     VBOXSTUBPKGARCH_AMD64
     65    VBOXSTUBPKGARCH_AMD64,
     66    /** Extract on ARM64 hosts. */
     67    VBOXSTUBPKGARCH_ARM64
    6668} VBOXSTUBPKGARCH;
    6769
Note: See TracChangeset for help on using the changeset viewer.

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