VirtualBox

Changeset 95834 in vbox for trunk/src/VBox/Runtime/r3


Ignore:
Timestamp:
Jul 26, 2022 2:46:59 PM (2 years ago)
Author:
vboxsync
Message:

IPRT/nocrt: Call C & C++ initializers and terminators. TLS directory (not used by VBoxControl). bugref:10261

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/win/nocrt-startup-exe-win.cpp

    r95818 r95834  
    4545# include <iprt/nocrt/stdlib.h>
    4646#endif
     47
     48#include "internal/compiler-vcc.h"
    4749
    4850
     
    158160            }
    159161        }
     162
     163        rtVccInitializersRunTerm();
    160164    }
    161165#else
     
    203207    initProcExecPath();
    204208
    205     /*
    206      * Get and convert the command line to argc/argv format.
    207      */
    208209    RTEXITCODE rcExit;
    209     UNICODE_STRING const *pCmdLine = pPeb->ProcessParameters ? &pPeb->ProcessParameters->CommandLine : NULL;
    210     if (pCmdLine)
    211     {
    212         char *pszCmdLine = NULL;
    213         int rc = RTUtf16ToUtf8Ex(pCmdLine->Buffer, pCmdLine->Length / sizeof(WCHAR), &pszCmdLine, 0, NULL);
    214         if (RT_SUCCESS(rc))
    215         {
    216             char **papszArgv;
    217             int    cArgs = 0;
    218             rc = RTGetOptArgvFromString(&papszArgv, &cArgs, pszCmdLine,
    219                                         RTGETOPTARGV_CNV_MODIFY_INPUT | RTGETOPTARGV_CNV_QUOTE_MS_CRT,  NULL);
     210#ifdef IPRT_NO_CRT
     211    AssertCompile(sizeof(rcExit) == sizeof(int));
     212    rcExit = (RTEXITCODE)rtVccInitializersRunInit();
     213    if (rcExit == RTEXITCODE_SUCCESS)
     214#endif
     215    {
     216        /*
     217         * Get and convert the command line to argc/argv format.
     218         */
     219        UNICODE_STRING const *pCmdLine = pPeb->ProcessParameters ? &pPeb->ProcessParameters->CommandLine : NULL;
     220        if (pCmdLine)
     221        {
     222            char *pszCmdLine = NULL;
     223            int rc = RTUtf16ToUtf8Ex(pCmdLine->Buffer, pCmdLine->Length / sizeof(WCHAR), &pszCmdLine, 0, NULL);
    220224            if (RT_SUCCESS(rc))
    221225            {
    222                 /*
    223                  * Call the main function.
    224                  */
    225                 AssertCompile(sizeof(rcExit) == sizeof(int));
    226                 rcExit = (RTEXITCODE)main(cArgs, papszArgv, NULL /*envp*/);
     226                char **papszArgv;
     227                int    cArgs = 0;
     228                rc = RTGetOptArgvFromString(&papszArgv, &cArgs, pszCmdLine,
     229                                            RTGETOPTARGV_CNV_MODIFY_INPUT | RTGETOPTARGV_CNV_QUOTE_MS_CRT,  NULL);
     230                if (RT_SUCCESS(rc))
     231                {
     232                    /*
     233                     * Call the main function.
     234                     */
     235                    AssertCompile(sizeof(rcExit) == sizeof(int));
     236                    rcExit = (RTEXITCODE)main(cArgs, papszArgv, NULL /*envp*/);
     237                }
     238                else
     239                    rcExit = RTMsgErrorExitFailure("Error parsing command line: %Rrc\n", rc);
    227240            }
    228241            else
    229                 rcExit = RTMsgErrorExitFailure("Error parsing command line: %Rrc\n", rc);
     242                rcExit = RTMsgErrorExitFailure("Failed to convert command line to UTF-8: %Rrc\n", rc);
    230243        }
    231244        else
    232             rcExit = RTMsgErrorExitFailure("Failed to convert command line to UTF-8: %Rrc\n", rc);
    233     }
     245            rcExit = RTMsgErrorExitFailure("No command line\n");
     246        rtTerminateProcess(rcExit, true /*fDoAtExit*/);
     247    }
     248#ifdef IPRT_NO_CRT
    234249    else
    235         rcExit = RTMsgErrorExitFailure("No command line\n");
    236 
    237     rtTerminateProcess(rcExit, true /*fDoAtExit*/);
    238 }
    239 
     250    {
     251        RTMsgError("A C static initializor failed (%d)\n", rcExit);
     252        rtTerminateProcess(rcExit, false /*fDoAtExit*/);
     253    }
     254#endif
     255}
     256
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