VirtualBox

Ignore:
Timestamp:
Sep 1, 2022 8:34:00 PM (2 years ago)
Author:
vboxsync
Message:

Installer/win/Stub*: Built in no-CRT mode. Documented and reworked the resource structures a bit. bugref:10261

Location:
trunk/src/VBox/Installer/win/Stub
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Installer/win/Stub/Makefile.kmk

    r96407 r96571  
    5757endif
    5858
    59 VBoxStub_LDFLAGS = \
    60         -DelayLoad:comctl32.dll
     59VBoxStub_LDFLAGS = -SubSystem:Windows -DelayLoad:comctl32.dll
    6160VBoxStub_POST_CMDS = $(VBOX_CHECK_IMPORTS) --image $(out) ntdll.dll kernel32.dll
    6261ifeq ($(KBUILD_TYPE),asan)
     
    8180 endif
    8281
    83  $$(VBoxStub_0_OUTDIR)/VBoxStubPublicCert.h:  | $$(dir $$@) $(VBOX_RTSIGNTOOL) $(PATH_STAGE_SYS)/VBoxSup.sys
     82 $$(VBoxStub_0_OUTDIR)/VBoxStubPublicCert.h:  | $$(dir $$@) $(VBOX_RTSIGNTOOL) $(VBOX_BIN2C) $(PATH_STAGE_SYS)/VBoxSup.sys
    8483        $(RM) -f -- "$@" "[email protected]" "[email protected]" "[email protected]" "[email protected]"
    8584
  • trunk/src/VBox/Installer/win/Stub/VBoxStub.cpp

    r96407 r96571  
    3232#include <iprt/win/windows.h>
    3333#include <iprt/win/commctrl.h>
    34 #include <fcntl.h>
    35 #include <io.h>
    3634#include <lmerr.h>
    3735#include <msiquery.h>
    3836#include <iprt/win/objbase.h>
    39 
    4037#include <iprt/win/shlobj.h>
    41 #include <stdlib.h>
    42 #include <stdio.h>
    43 #include <string.h>
    44 #include <strsafe.h>
    4538
    4639#include <VBox/version.h>
     
    6356#include <iprt/utf16.h>
    6457
     58#ifndef IPRT_NO_CRT
     59# include <stdio.h>
     60# include <stdlib.h>
     61#endif
     62
    6563#include "VBoxStub.h"
    6664#include "../StubBld/VBoxStubBld.h"
     
    501499static bool PackageIsNeeded(VBOXSTUBPKG const *pPackage)
    502500{
    503     if (pPackage->byArch == VBOXSTUBPKGARCH_ALL)
     501    if (pPackage->enmArch == VBOXSTUBPKGARCH_ALL)
    504502        return true;
    505503    VBOXSTUBPKGARCH enmArch = IsWow64() ? VBOXSTUBPKGARCH_AMD64 : VBOXSTUBPKGARCH_X86;
    506     return pPackage->byArch == enmArch;
     504    return pPackage->enmArch == enmArch;
    507505}
    508506
     
    811809        rcExit = RTEXITCODE_SUCCESS; /* Ignore .cab files, they're generally referenced by other files. */
    812810    else
    813         rcExit = ShowError("Internal error: Do not know how to handle file '%s' (%s).", pPackage->szFileName, pRec->szPath);
     811        rcExit = ShowError("Internal error: Do not know how to handle file '%s' (%s).", pPackage->szFilename, pRec->szPath);
    814812    return rcExit;
    815813}
     
    10231021            RTFILE hFile = NIL_RTFILE;
    10241022            char   szDstFile[RTPATH_MAX];
    1025             if (fExtractOnly || pPackage->byArch == VBOXSTUBPKGARCH_ALL)
    1026                 rc = RTPathJoin(szDstFile, sizeof(szDstFile), pszDstDir, pPackage->szFileName);
     1023            if (fExtractOnly || pPackage->enmArch == VBOXSTUBPKGARCH_ALL)
     1024                rc = RTPathJoin(szDstFile, sizeof(szDstFile), pszDstDir, pPackage->szFilename);
    10271025            else
    10281026            {
     
    10301028                if (RT_SUCCESS(rc))
    10311029                {
    1032                     const char *pszSuffix = RTPathSuffix(pPackage->szFileName);
     1030                    const char *pszSuffix = RTPathSuffix(pPackage->szFilename);
    10331031                    if (pszSuffix)
    10341032                        rc = RTStrCat(szDstFile, sizeof(szDstFile), pszSuffix);
     
    10401038                        if (RT_FAILURE(rc))
    10411039                            return ShowError("Failed to create unique filename for '%s' in '%s': %Rrc",
    1042                                              pPackage->szFileName, pszDstDir, rc);
     1040                                             pPackage->szFilename, pszDstDir, rc);
    10431041                    }
    10441042                }
     
    10491047            rc = Extract(pPackage, szDstFile, hFile, k);
    10501048            if (RT_FAILURE(rc))
    1051                 return ShowError("Error extracting package #%u (%s): %Rrc", k, pPackage->szFileName, rc);
     1049                return ShowError("Error extracting package #%u (%s): %Rrc", k, pPackage->szFilename, rc);
    10521050        }
    10531051    }
     
    10561054}
    10571055
    1058 
    1059 int WINAPI WinMain(HINSTANCE  hInstance,
    1060                    HINSTANCE  hPrevInstance,
    1061                    char      *lpCmdLine,
    1062                    int        nCmdShow)
    1063 {
    1064     RT_NOREF(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
    1065     char **argv = __argv;
    1066     int argc    = __argc;
    1067 
     1056int main(int argc, char **argv)
     1057{
    10681058    /*
    10691059     * Init IPRT. This is _always_ the very first thing we do.
     
    10881078    char szExtractPath[RTPATH_MAX] = {0};
    10891079    char szMSIArgs[_4K]            = {0};
    1090     char szMSILogFile[RTPATH_MAX]     = {0};
     1080    char szMSILogFile[RTPATH_MAX]  = {0};
    10911081
    10921082    /* Argument enumeration IDs. */
     
    13351325     */
    13361326    SetLastError(0);
    1337     HANDLE hMutexAppRunning = CreateMutex(NULL, FALSE, "VBoxStubInstaller");
     1327    HANDLE hMutexAppRunning = CreateMutexW(NULL, FALSE, L"VBoxStubInstaller");
    13381328    if (   hMutexAppRunning != NULL
    13391329        && GetLastError() == ERROR_ALREADY_EXISTS)
     
    13891379            return ShowError("Unable to allocate console: LastError=%u\n", GetLastError());
    13901380
     1381# ifdef IPRT_NO_CRT
     1382        PRTSTREAM pNewStdOutErr = NULL;
     1383        vrc = RTStrmOpen("CONOUT$", "a", &pNewStdOutErr);
     1384        if (RT_SUCCESS(vrc))
     1385        {
     1386            RTStrmSetBufferingMode(pNewStdOutErr, RTSTRMBUFMODE_UNBUFFERED);
     1387            g_pStdErr  = pNewStdOutErr;
     1388            g_pStdOut  = pNewStdOutErr;
     1389        }
     1390# else
    13911391        freopen("CONOUT$", "w", stdout);
    13921392        setvbuf(stdout, NULL, _IONBF, 0);
    1393 
    13941393        freopen("CONOUT$", "w", stderr);
     1394# endif
    13951395    }
    13961396#endif /* VBOX_STUB_WITH_OWN_CONSOLE */
     
    14451445             * From here on, we do everything in functions so we can counter clean up.
    14461446             */
    1447             rcExit = ExtractFiles(pHeader->byCntPkgs, szExtractPath, fExtractOnly, &pExtractDirRec);
     1447            rcExit = ExtractFiles(pHeader->cPackages, szExtractPath, fExtractOnly, &pExtractDirRec);
    14481448            if (rcExit == RTEXITCODE_SUCCESS)
    14491449            {
     
    14621462#endif
    14631463                    unsigned iPackage = 0;
    1464                     while (   iPackage < pHeader->byCntPkgs
     1464                    while (   iPackage < pHeader->cPackages
    14651465                           && (rcExit == RTEXITCODE_SUCCESS || rcExit == (RTEXITCODE)ERROR_SUCCESS_REBOOT_REQUIRED))
    14661466                    {
     
    15091509    return rcExit != (RTEXITCODE)ERROR_SUCCESS_REBOOT_REQUIRED || !fIgnoreReboot ? rcExit : RTEXITCODE_SUCCESS;
    15101510}
     1511
     1512#ifndef IPRT_NO_CRT
     1513int WINAPI WinMain(HINSTANCE  hInstance,
     1514                   HINSTANCE  hPrevInstance,
     1515                   char      *lpCmdLine,
     1516                   int        nCmdShow)
     1517{
     1518    RT_NOREF(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
     1519    return main(__argc, __argv);
     1520}
     1521#endif
     1522
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