VirtualBox

Changeset 83991 in vbox


Ignore:
Timestamp:
Apr 27, 2020 10:08:37 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
137558
Message:

IPRT,VBoxAddInstallNt3x.cpp: Split out the IPRT bits from VBoxAddInstallNt3x.cpp and move template to /Config.kmk.

Location:
trunk
Files:
3 added
5 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Config.kmk

    r83969 r83991  
    56525652        $(VBOX_GCC_NON_PEDANTIC_CXX)
    56535653endif
     5654
     5655#
     5656# VBoxR3Static w/o any CRT (windows only atm, experimental).
     5657# Implies no fancy C++, no exceptions, no static constructors or destructors, ++.
     5658#
     5659TEMPLATE_VBoxR3StaticNoCrt               = Static
     5660TEMPLATE_VBoxR3StaticNoCrt_EXTENDS       = VBoxR3Static
     5661TEMPLATE_VBoxR3StaticNoCrt_SDKS          = $(subst WINSDK10-UCRT-STATIC,WINSDK10-UCRT-INCS, $(filter-out VBOX_OPENSSL,$(TEMPLATE_VBoxR3Static_SDKS)))
     5662TEMPLATE_VBoxR3StaticNoCrt_DEFS          = $(TEMPLATE_VBoxR3Static_DEFS) \
     5663        RT_NO_CRT \
     5664        IN_RT_STATIC
     5665TEMPLATE_VBoxR3StaticNoCrt_DEFS.win      = $(TEMPLATE_VBoxR3Static_DEFS.win) \
     5666        RT_WITHOUT_NOCRT_WRAPPERS
     5667TEMPLATE_VBoxR3StaticNoCrt_LIBS          = \
     5668        $(PATH_STAGE_LIB)/RuntimeR3NoCrt$(VBOX_SUFF_LIB)
     5669ifeq ($(KBUILD_TARGET),win)
     5670TEMPLATE_VBoxR3StaticNoCrt_LIBS.x86        = $(NO_SUCH_VARIABLE)
     5671TEMPLATE_VBoxR3StaticNoCrt_LIBS.amd64      = $(NO_SUCH_VARIABLE)
     5672TEMPLATE_VBoxR3StaticNoCrt_LIBS.win        = $(NO_SUCH_VARIABLE)
     5673TEMPLATE_VBoxR3StaticNoCrt_LIBS.win.x86    = \
     5674        $(PATH_SDK_$(VBOX_WINDDK)_LIB.x86)/int64.lib \
     5675        $(PATH_TOOL_$(TEMPLATE_VBoxR3StaticNoCrt_TOOL.win.x86)_LIB)/chkstk.obj
     5676TEMPLATE_VBoxR3StaticNoCrt_LDFLAGS.win.x86 = $(filter-out -Include%, $(TEMPLATE_VBoxR3Static_LDFLAGS.win.x86))
     5677TEMPLATE_VBoxR3StaticNoCrt_CFLAGS          = $(filter-out -EH%,$(TEMPLATE_VBoxR3Static_CFLAGS)) /GS- -EHs-
     5678TEMPLATE_VBoxR3StaticNoCrt_CXXFLAGS        = $(filter-out -EH%,$(TEMPLATE_VBoxR3Static_CXXFLAGS)) /GS- -EHs-
     5679TEMPLATE_VBoxR3StaticNoCrt_PCHFLAGS        = $(filter-out -EH%,$(TEMPLATE_VBoxR3Static_PCHFLAGS)) /GS- -EHs-
     5680TEMPLATE_VBoxR3StaticNoCrt_CXXFLAGS.debug  = $(filter-out /RTC% -RTC%, $(TEMPLATE_VBoxR3Static_CXXFLAGS.debug))
     5681else
     5682TEMPLATE_VBoxR3StaticNoCrt_CXXFLAGS        = $(TEMPLATE_VBoxR3Static_CXXFLAGS) -fno-exceptions
     5683TEMPLATE_VBoxR3StaticNoCrt_PCHFLAGS        = $(TEMPLATE_VBoxR3Static_PCHFLAGS) -fno-exceptions
     5684endif
     5685
     5686
     5687#
     5688# Executable w/o CRT (windows only atm, experimental).
     5689# Implies no fancy C++, no exceptions, no static constructors or destructors, ++.
     5690#
     5691TEMPLATE_VBoxR3StaticNoCrtExe            := VBoxR3StaticNoCrt with EXE startup code calling a main() function
     5692TEMPLATE_VBoxR3StaticNoCrtExe_EXTENDS    := VBoxR3StaticNoCrt
     5693TEMPLATE_VBoxR3StaticNoCrtExe_EXTENDS_BY := appending
     5694TEMPLATE_VBoxR3StaticNoCrtExe_LDFLAGS.win := /entry:CustomMainEntrypoint /subsystem:console
    56545695
    56555696
     
    75567597endif
    75577598
     7599
     7600#
     7601# Guest version of VBoxR3StaticNoCrtExe.
     7602#
     7603TEMPLATE_VBoxGuestR3NoCrtExe                := ...
     7604TEMPLATE_VBoxGuestR3NoCrtExe_EXTENDS        := VBoxGuestR3Exe
     7605TEMPLATE_VBoxGuestR3NoCrtExe_SDKS            = $(subst WINSDK10-UCRT-STATIC,WINSDK10-UCRT-INCS, $(filter-out VBOX_OPENSSL,$(TEMPLATE_VBoxGuestR3Exe_SDKS)))
     7606TEMPLATE_VBoxGuestR3NoCrtExe_DEFS            = $(TEMPLATE_VBoxGuestR3Exe_DEFS) \
     7607        RT_NO_CRT \
     7608        IN_RT_STATIC
     7609TEMPLATE_VBoxGuestR3NoCrtExe_DEFS.win        = $(TEMPLATE_VBoxGuestR3Exe_DEFS.win) \
     7610        RT_WITHOUT_NOCRT_WRAPPERS
     7611TEMPLATE_VBoxGuestR3NoCrtExe_LIBS            = \
     7612        $(PATH_STAGE_LIB)/RuntimeR3NoCrt$(VBOX_SUFF_LIB)
     7613ifeq ($(KBUILD_TARGET),win)
     7614TEMPLATE_VBoxGuestR3NoCrtExe_LIBS.x86        = $(NO_SUCH_VARIABLE)
     7615TEMPLATE_VBoxGuestR3NoCrtExe_LIBS.amd64      = $(NO_SUCH_VARIABLE)
     7616TEMPLATE_VBoxGuestR3NoCrtExe_LIBS.win        = $(NO_SUCH_VARIABLE)
     7617TEMPLATE_VBoxGuestR3NoCrtExe_LIBS.win.x86    = \
     7618        $(PATH_SDK_$(VBOX_WINDDK)_LIB.x86)/int64.lib \
     7619        $(PATH_TOOL_$(TEMPLATE_VBoxGuestR3NoCrtExe_TOOL.win.x86)_LIB)/chkstk.obj
     7620TEMPLATE_VBoxGuestR3NoCrtExe_LDFLAGS.win.x86 = $(filter-out -Include%, $(TEMPLATE_VBoxGuestR3Exe_LDFLAGS.win.x86))
     7621TEMPLATE_VBoxGuestR3NoCrtExe_LDFLAGS.win     = $(TEMPLATE_VBoxGuestR3Exe_LDFLAGS.win) /entry:CustomMainEntrypoint /subsystem:console
     7622TEMPLATE_VBoxGuestR3NoCrtExe_CFLAGS          = $(filter-out -EH%,$(TEMPLATE_VBoxGuestR3Exe_CFLAGS)) /GS- -EHs-
     7623TEMPLATE_VBoxGuestR3NoCrtExe_CXXFLAGS        = $(filter-out -EH%,$(TEMPLATE_VBoxGuestR3Exe_CXXFLAGS)) /GS- -EHs-
     7624TEMPLATE_VBoxGuestR3NoCrtExe_PCHFLAGS        = $(filter-out -EH%,$(TEMPLATE_VBoxGuestR3Exe_PCHFLAGS)) /GS- -EHs-
     7625TEMPLATE_VBoxGuestR3NoCrtExe_CXXFLAGS.debug  = $(filter-out /RTC% -RTC%, $(TEMPLATE_VBoxGuestR3Exe_CXXFLAGS.debug))
     7626else
     7627TEMPLATE_VBoxGuestR3NoCrtExe_CXXFLAGS        = $(TEMPLATE_VBoxGuestR3Exe_CXXFLAGS) -fno-exceptions
     7628TEMPLATE_VBoxGuestR3NoCrtExe_PCHFLAGS        = $(TEMPLATE_VBoxGuestR3Exe_PCHFLAGS) -fno-exceptions
     7629endif
     7630
     7631
    75587632#
    75597633# Template for building R3 programs for the guest additions (no -pedantic)
  • trunk/src/VBox/Additions/WINNT/Installer/Makefile.kmk

    r83979 r83991  
    322322# fun challenge.
    323323#
    324 TEMPLATE_VBoxGuestR3BareExe = No extra libs and tricks
    325 TEMPLATE_VBoxGuestR3BareExe_EXTENDS         = VBoxGuestR3Exe
    326 TEMPLATE_VBoxGuestR3BareExe_SDKS            = $(subst WINSDK10-UCRT-STATIC,WINSDK10-UCRT-INCS,$(filter-out ReorderCompilerIncs, $(TEMPLATE_VBoxGuestR3Exe_SDKS)))
    327 TEMPLATE_VBoxGuestR3BareExe_DEFS            = $(TEMPLATE_VBoxGuestR3Exe_DEFS) RT_NO_CRT
    328 TEMPLATE_VBoxGuestR3BareExe_LIBS            = $(NO_SUCH_VARIABLE)
    329 TEMPLATE_VBoxGuestR3BareExe_LIBS.x86        = \
    330         $(PATH_SDK_$(VBOX_WINDDK)_LIB.x86)/int64.lib \
    331        $(PATH_TOOL_$(TEMPLATE_VBoxGuestR3BareExe_TOOL.win.x86)_LIB)/chkstk.obj
    332 TEMPLATE_VBoxGuestR3BareExe_LIBS.win        = $(NO_SUCH_VARIABLE)
    333 TEMPLATE_VBoxGuestR3BareExe_LIBS.win.x86    = $(NO_SUCH_VARIABLE)
    334 TEMPLATE_VBoxGuestR3BareExe_LDFLAGS.win.x86 = $(filter-out -Include%, $(TEMPLATE_VBoxGuestR3Exe_LDFLAGS.win.x86))
    335 TEMPLATE_VBoxGuestR3BareExe_CXXFLAGS        = $(TEMPLATE_VBoxGuestR3Exe_CXXFLAGS) /GS-
    336 TEMPLATE_VBoxGuestR3BareExe_CXXFLAGS.debug  = $(filter-out /RTC% -RTC%, $(TEMPLATE_VBoxGuestR3Exe_CXXFLAGS.debug))
    337 
    338 
    339324PROGRAMS.win.x86 += VBoxAddInstallNt3x
    340 VBoxAddInstallNt3x_TEMPLATE := VBoxGuestR3BareExe
    341 VBoxAddInstallNt3x_SDKS     := VBOX_NTDLL
    342 VBoxAddInstallNt3x_DEFS     := \
    343         RT_NO_STRICT \
    344         RT_WITHOUT_NOCRT_WRAPPERS \
    345         IPRT_NO_ERROR_DATA \
    346         IPRT_NO_ALLOCA_TROUBLE IPRT_MINIMAL \
    347         IPRT_GETOPT_WITHOUT_NETWORK_ADDRESSES
    348 VBoxAddInstallNt3x_LDFLAGS  := /Entry:CustomMainEntrypoint /subsystem:console
    349 VBoxAddInstallNt3x_INCS     := \
    350         ../../../Runtime/include
     325VBoxAddInstallNt3x_TEMPLATE := VBoxGuestR3NoCrtExe
     326#VBoxAddInstallNt3x_TEMPLATE := VBoxGuestR3Exe
    351327VBoxAddInstallNt3x_SOURCES  := \
    352328        VBoxAddInstallNt3x.cpp \
    353        \
    354        ../../../Runtime/common/string/straprintf.cpp \
    355        ../../../Runtime/common/string/strformat.cpp \
    356        ../../../Runtime/common/string/strformatnum.cpp \
    357        ../../../Runtime/common/string/strformatrt.cpp \
    358        ../../../Runtime/common/string/strformattype.cpp \
    359        ../../../Runtime/common/string/strprintf.cpp \
    360        ../../../Runtime/common/string/strprintf2.cpp \
    361        ../../../Runtime/common/string/stringalloc.cpp \
    362        ../../../Runtime/common/string/strtonum.cpp \
    363        ../../../Runtime/common/string/RTStrNLen.cpp \
    364        ../../../Runtime/common/string/RTStrCmp.cpp \
    365        ../../../Runtime/common/string/RTStrNCmp.cpp \
    366        ../../../Runtime/common/string/RTStrICmpAscii.cpp \
    367        ../../../Runtime/common/string/RTStrNICmpAscii.cpp \
    368        ../../../Runtime/common/string/RTStrCopy.cpp \
    369        ../../../Runtime/common/string/RTStrEnd.asm \
    370        ../../../Runtime/common/string/RTUtf16Copy.cpp \
    371        ../../../Runtime/common/string/utf-16.cpp \
    372        ../../../Runtime/common/string/utf-8.cpp \
    373        ../../../Runtime/common/string/memcpy.asm \
    374        ../../../Runtime/common/string/memchr.asm \
    375        ../../../Runtime/common/string/memcmp.asm \
    376        ../../../Runtime/common/string/memmove.asm \
    377        ../../../Runtime/common/string/memset.asm \
    378        ../../../Runtime/common/string/strlen.asm \
    379        ../../../Runtime/common/string/strchr.asm \
    380        ../../../Runtime/common/string/strcmp.asm \
    381        ../../../Runtime/common/string/strncmp.asm \
    382        ../../../Runtime/common/path/RTPathFilename.cpp \
    383        ../../../Runtime/common/misc/getopt.cpp \
    384        ../../../Runtime/common/misc/getoptargv.cpp \
    385        ../../../Runtime/common/misc/message.cpp \
    386        ../../../Runtime/common/err/errmsg.cpp \
    387        ../../../Runtime/generic/uuid-generic.cpp \
    388        ../../../Runtime/win/errmsgwin.cpp \
    389         ../../../Runtime/generic/rtStrFormatKernelAddress-generic.cpp
    390329
    391330
  • trunk/src/VBox/Additions/WINNT/Installer/VBoxAddInstallNt3x.cpp

    r83979 r83991  
    11/* $Id$ */
    22/** @file
    3  * VBoxAddInstallNt3x = Install Guest Additions on NT3.51, 3.5 and 3.1.
     3 * VBoxAddInstallNt3x - Install Guest Additions on NT3.51, 3.5 and 3.1.
    44 */
    55
    66/*
    7  * Copyright (c) 2020 knut st. osmundsen <[email protected]>
     7 * Copyright (C) 2020 Oracle Corporation
    88 *
    9  * This program is free software; you can redistribute it and/or modify
    10  * it under the terms of the GNU General Public License as published by
    11  * the Free Software Foundation; either version 3 of the License, or
    12  * (at your option) any later version.
    13  *
    14  * This program is distributed in the hope that it will be useful,
    15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  * GNU General Public License for more details.
    18  *
    19  * You should have received a copy of the GNU General Public License
    20  * along with This program.  If not, see <http://www.gnu.org/licenses/>
    21  *
     9 * This file is part of VirtualBox Open Source Edition (OSE), as
     10 * available from http://www.virtualbox.org. This file is free software;
     11 * you can redistribute it and/or modify it under the terms of the GNU
     12 * General Public License (GPL) as published by the Free Software
     13 * Foundation, in version 2 as it comes in the "COPYING" file of the
     14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
     15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
    2216 */
    2317
     
    2923#include <iprt/ctype.h>
    3024#include <iprt/getopt.h>
    31 #include <iprt/mem.h>
    3225#include <iprt/message.h>
    3326#include <iprt/path.h>
     
    4033
    4134
     35
    4236/*********************************************************************************************************************************
    43 *   Minimal stream implementation (for message.cpp).                                                                             *
     37*   Structures and Typedefs                                                                                                      *
    4438*********************************************************************************************************************************/
    45 /** @todo might be an idea to make a more native version of this and use
    46  *        this as a base for it. */
    47 
    48 typedef struct PRINTFBUF
    49 {
    50     HANDLE  hHandle;
    51     size_t  offBuf;
    52     char    szBuf[128];
    53 } PRINTFBUF;
    54 
    55 struct RTSTREAM
    56 {
    57     int     iStream;
    58     HANDLE  hHandle;
    59 };
    60 
    61 
    62 RTSTREAM g_aStdStreams[3] =
    63 {
    64     { 0, NULL },
    65     { 1, NULL },
    66     { 2, NULL },
    67 };
    68 
    69 RTSTREAM *g_pStdIn  = &g_aStdStreams[0];
    70 RTSTREAM *g_pStdOut = &g_aStdStreams[1];
    71 RTSTREAM *g_pStdErr = &g_aStdStreams[2];
    72 
    73 
    74 static void InitStdHandles(PRTL_USER_PROCESS_PARAMETERS pParams)
    75 {
    76     if (pParams)
    77     {
    78         g_pStdIn->hHandle  = pParams->StandardInput;
    79         g_pStdOut->hHandle = pParams->StandardOutput;
    80         g_pStdErr->hHandle = pParams->StandardError;
    81     }
    82 }
    83 
    84 
    85 static void FlushPrintfBuffer(PRINTFBUF *pBuf)
    86 {
    87     if (pBuf->offBuf)
    88     {
    89         DWORD cbWritten = 0;
    90         WriteFile(pBuf->hHandle, pBuf->szBuf, pBuf->offBuf, &cbWritten, NULL);
    91         pBuf->offBuf   = 0;
    92         pBuf->szBuf[0] = '\0';
    93     }
    94 }
    95 
    96 
    97 /** @callback_method_impl{FNRTSTROUTPUT} */
    98 static DECLCALLBACK(size_t) MyPrintfOutputter(void *pvArg, const char *pachChars, size_t cbChars)
    99 {
    100     PRINTFBUF *pBuf = (PRINTFBUF *)pvArg;
    101     if (cbChars != 0)
    102     {
    103         size_t offSrc = 0;
    104         while  (offSrc < cbChars)
    105         {
    106             size_t cbLeft = sizeof(pBuf->szBuf) - pBuf->offBuf - 1;
    107             if (cbLeft > 0)
    108             {
    109                 size_t cbToCopy = RT_MIN(cbChars - offSrc, cbLeft);
    110                 memcpy(&pBuf->szBuf[pBuf->offBuf], &pachChars[offSrc], cbToCopy);
    111                 pBuf->offBuf += cbToCopy;
    112                 pBuf->szBuf[pBuf->offBuf] = '\0';
    113                 if (cbLeft > cbToCopy)
    114                     break;
    115                 offSrc += cbToCopy;
    116             }
    117             FlushPrintfBuffer(pBuf);
    118         }
    119     }
    120     else /* Special zero byte write at the end of the formatting. */
    121         FlushPrintfBuffer(pBuf);
    122     return cbChars;
    123 }
    124 
    125 
    126 RTR3DECL(int) RTStrmPrintfV(PRTSTREAM pStream, const char *pszFormat, va_list args)
    127 {
    128     PRINTFBUF Buf;
    129     Buf.hHandle  = pStream->hHandle;
    130     Buf.offBuf   = 0;
    131     Buf.szBuf[0] = '\0';
    132 
    133     return RTStrFormatV(MyPrintfOutputter, &Buf, NULL, NULL, pszFormat, args);
    134 }
    135 
    136 
    137 RTR3DECL(int) RTStrmPrintf(PRTSTREAM pStream, const char *pszFormat, ...)
    138 {
    139     va_list args;
    140     va_start(args, pszFormat);
    141     int rc = RTStrmPrintfV(pStream, pszFormat, args);
    142     va_end(args);
    143     return rc;
    144 }
    145 
    146 
    147 RTR3DECL(int) RTPrintfV(const char *pszFormat, va_list va)
    148 {
    149     PRINTFBUF Buf;
    150     Buf.hHandle  = g_pStdOut->hHandle;
    151     Buf.offBuf   = 0;
    152     Buf.szBuf[0] = '\0';
    153 
    154     return RTStrFormatV(MyPrintfOutputter, &Buf, NULL, NULL, pszFormat, va);
    155 }
    156 
    157 
    158 RTR3DECL(int) RTPrintf(const char *pszFormat, ...)
    159 {
    160     va_list va;
    161     va_start(va, pszFormat);
    162     int rc = RTPrintfV(pszFormat, va);
    163     va_end(va);
    164     return rc;
    165 }
    166 
    167 
    168 /*********************************************************************************************************************************
    169 *   Allocation using process heap                                                                                                *
    170 *********************************************************************************************************************************/
    171 /** @todo put this into a file in r3/win/ and r3/nt/ */
    172 RTDECL(void) RTMemTmpFree(void *pv)
    173 {
    174     HeapFree(GetProcessHeap(), 0, pv);
    175 }
    176 
    177 RTDECL(void) RTMemFree(void *pv)
    178 {
    179     HeapFree(GetProcessHeap(), 0, pv);
    180 }
    181 
    182 
    183 RTDECL(void *) RTMemTmpAllocTag(size_t cb, const char *pszTag)
    184 {
    185     RT_NOREF(pszTag);
    186     return HeapAlloc(GetProcessHeap(), 0, cb);
    187 }
    188 
    189 
    190 RTDECL(void *) RTMemTmpAllocZTag(size_t cb, const char *pszTag)
    191 {
    192     RT_NOREF(pszTag);
    193     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cb);
    194 }
    195 
    196 
    197 RTDECL(void *) RTMemAllocTag(size_t cb, const char *pszTag)
    198 {
    199     RT_NOREF(pszTag);
    200     return HeapAlloc(GetProcessHeap(), 0, cb);
    201 }
    202 
    203 
    204 RTDECL(void *) RTMemAllocZTag(size_t cb, const char *pszTag)
    205 {
    206     RT_NOREF(pszTag);
    207     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cb);
    208 }
    209 
    210 
    211 RTDECL(void *) RTMemReallocTag(void *pvOld, size_t cbNew, const char *pszTag)
    212 {
    213     RT_NOREF(pszTag);
    214     if (pvOld)
    215         return HeapReAlloc(GetProcessHeap(), 0, pvOld, cbNew);
    216     return HeapAlloc(GetProcessHeap(), 0, cbNew);
    217 }
    218 
    219 
    220 RTDECL(void *) RTMemReallocZTag(void *pvOld, size_t cbOld, size_t cbNew, const char *pszTag)
    221 {
    222     RT_NOREF(pszTag, cbOld);
    223     if (pvOld)
    224         return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, pvOld, cbNew);
    225     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cbNew);
    226 }
    227 
    228 
    229 /*********************************************************************************************************************************
    230 *   UTF-16                                                                                                                       *
    231 *********************************************************************************************************************************/
    232 
    233 RTDECL(PRTUTF16) RTUtf16ToLowerAscii(PRTUTF16 pwsz)
    234 {
    235     for (PRTUTF16 pwc = pwsz; *pwc; pwc++)
    236         if (*pwc < 0x7f)
    237             *pwc = RT_C_TO_LOWER(*pwc);
    238     return pwsz;
    239 }
    240 
    241 
    242 /*********************************************************************************************************************************
    243 *   Actual installer code.                                                                                                       *
    244 *********************************************************************************************************************************/
    245 
    24639/** Components (also indexes into g_aComponents). */
    24740typedef enum { kComp_VBoxGuest = 0, kComp_VBoxService = 1, kComp_VBoxMouse = 2} VBOXGACOMP;
     
    24942typedef enum { kFile_NotFound, kFile_LongName, kFile_8Dot3, kFile_Both, kFile_Mismatch } VBOXGAFILE;
    25043
     44
     45/*********************************************************************************************************************************
     46*   Defined Constants And Macros                                                                                                 *
     47*********************************************************************************************************************************/
    25148/** The components. */
    25249struct
     
    29996static uint32_t g_uSaneVersion = MAKE_SANE_VERSION(3,51);
    30097static DWORD    g_dwVersion    = 3 | (51 << 8);
     98
     99
     100RTDECL(PRTUTF16) RTUtf16ToLowerAscii(PRTUTF16 pwsz)
     101{
     102    for (PRTUTF16 pwc = pwsz; *pwc; pwc++)
     103        if (*pwc < 0x7f)
     104            *pwc = RT_C_TO_LOWER(*pwc);
     105    return pwsz;
     106}
    301107
    302108
     
    948754}
    949755
    950 
    951 #include <internal/process.h>
    952 
    953 RT_C_DECLS_BEGIN
    954 DECLHIDDEN(char)             g_szrtProcExePath[RTPATH_MAX] = "Unknown.exe";
    955 DECLHIDDEN(size_t)           g_cchrtProcExePath = 11;
    956 DECLHIDDEN(size_t)           g_cchrtProcExeDir = 0;
    957 DECLHIDDEN(size_t)           g_offrtProcName = 0;
    958 RT_C_DECLS_END
    959 
    960 
    961 DECL_NO_INLINE(static, void) initProcExecPath(void)
    962 {
    963     WCHAR wszPath[RTPATH_MAX];
    964     UINT cwcPath = GetModuleFileNameW(NULL, wszPath, RT_ELEMENTS(wszPath));
    965     if (cwcPath)
    966     {
    967         char *pszDst = g_szrtProcExePath;
    968         int rc = RTUtf16ToUtf8Ex(wszPath, cwcPath, &pszDst, sizeof(g_szrtProcExePath), &g_cchrtProcExePath);
    969         if (RT_SUCCESS(rc))
    970         {
    971             g_cchrtProcExeDir = g_offrtProcName = RTPathFilename(pszDst) - g_szrtProcExePath;
    972             while (   g_cchrtProcExeDir >= 2
    973                    && RTPATH_IS_SLASH(g_szrtProcExePath[g_cchrtProcExeDir - 1])
    974                    && g_szrtProcExePath[g_cchrtProcExeDir - 2] != ':')
    975                 g_cchrtProcExeDir--;
    976         }
    977     }
    978 }
    979 
    980 
    981 void CustomMainEntrypoint(PPEB pPeb)
    982 {
    983     /*
    984      * Initialize stuff.
    985      */
    986     InitStdHandles(pPeb->ProcessParameters);
    987     initProcExecPath();
    988 
    989     /*
    990      * Get and convert the command line to argc/argv format.
    991      */
    992     RTEXITCODE rcExit;
    993     UNICODE_STRING const *pCmdLine = pPeb->ProcessParameters ? &pPeb->ProcessParameters->CommandLine : NULL;
    994     if (pCmdLine)
    995     {
    996         char *pszCmdLine = NULL;
    997         int rc = RTUtf16ToUtf8Ex(pCmdLine->Buffer, pCmdLine->Length / sizeof(WCHAR), &pszCmdLine, 0, NULL);
    998         if (RT_SUCCESS(rc))
    999         {
    1000             char **papszArgv;
    1001             int    cArgs = 0;
    1002             rc = RTGetOptArgvFromString(&papszArgv, &cArgs, pszCmdLine,
    1003                                         RTGETOPTARGV_CNV_MODIFY_INPUT | RTGETOPTARGV_CNV_QUOTE_MS_CRT,  NULL);
    1004             if (RT_SUCCESS(rc))
    1005             {
    1006                 /*
    1007                  * Call the main function.
    1008                  */
    1009                 rcExit = (RTEXITCODE)main(cArgs, papszArgv);
    1010             }
    1011             else
    1012                 rcExit = RTMsgErrorExitFailure("Error parsing command line: %Rrc\n", rc);
    1013         }
    1014         else
    1015             rcExit = RTMsgErrorExitFailure("Failed to convert command line to UTF-8: %Rrc\n", rc);
    1016     }
    1017     else
    1018         rcExit = RTMsgErrorExitFailure("No command line\n");
    1019 
    1020     for (;;)
    1021         NtTerminateProcess(NtCurrentProcess(), rcExit);
    1022 }
    1023 
  • trunk/src/VBox/Runtime/Makefile.kmk

    r83967 r83991  
    3333 #
    3434 LIBRARIES += RuntimeGuestR3 RuntimeGuestR3Shared
     35 LIBRARIES.win += RuntimeR3NoCrt
    3536 LIBRARIES.win.amd64 += RuntimeGuestR3-x86 RuntimeGuestR3Shared-x86
    3637 ifdef VBOX_WITH_ADDITION_DRIVERS
     
    4950 LIBRARIES += RuntimeGuestR3 RuntimeGuestR3Shared RuntimeR3 RuntimeR0 RuntimeBldProg
    5051 LIBRARIES.solaris += RuntimeR0Stub
    51  LIBRARIES.win += RuntimeR0Stub
     52 LIBRARIES.win += RuntimeR0Stub #RuntimeR3NoCrt
    5253 LIBRARIES.win.x86 += RuntimeR3VccTricks
    5354 include $(PATH_SUB_CURRENT)/tools/Makefile.kmk
     
    8687 LIBRARIES += RuntimeR3 RuntimeBldProg RuntimeR0 RuntimeEFCPP RuntimeR3NoCRTGCC
    8788 LIBRARIES.solaris += RuntimeR0Stub
    88  LIBRARIES.win += RuntimeR0Stub
     89 LIBRARIES.win += RuntimeR0Stub RuntimeR3NoCrt
    8990 LIBRARIES.win.amd64 += RuntimeR3-x86
    9091 ifdef VBOX_WITH_RAW_MODE
     
    724725        r3/memsafer-r3.cpp \
    725726        r3/path.cpp \
     727        r3/RTPathTemp.cpp \
    726728        r3/poll.cpp \
    727729        r3/process.cpp \
     
    18971899        r3/memsafer-r3.cpp \
    18981900        r3/path.cpp \
     1901        r3/RTPathTemp.cpp \
    18991902        r3/process.cpp \
    19001903        r3/socket.cpp \
     
    25692572        common/math/gcc/xordi3.c
    25702573
     2574#
     2575# RuntimeR3NoCRT - For windows applications w/o any runtime library.
     2576# Experimental.
     2577#
     2578RuntimeR3NoCrt_TEMPLATE := VBoxR3StaticNoCrt
     2579RuntimeR3NoCrt_INCS     := include
     2580RuntimeR3NoCrt_DEFS     := \
     2581        RT_NO_STRICT \
     2582        IPRT_NO_ALLOCA_TROUBLE \
     2583        IPRT_GETOPT_WITHOUT_NETWORK_ADDRESSES
     2584RuntimeR3NoCrt_SOURCES  := \
     2585        common/string/straprintf.cpp \
     2586        common/string/strformat.cpp \
     2587        common/string/strformatnum.cpp \
     2588        common/string/strformatrt.cpp \
     2589        common/string/strformattype.cpp \
     2590        common/string/strprintf.cpp \
     2591        common/string/strprintf2.cpp \
     2592        common/string/stringalloc.cpp \
     2593        common/string/strtonum.cpp \
     2594        common/string/RTStrNLen.cpp \
     2595        common/string/RTStrCmp.cpp \
     2596        common/string/RTStrNCmp.cpp \
     2597        common/string/RTStrICmpAscii.cpp \
     2598        common/string/RTStrNICmpAscii.cpp \
     2599        common/string/RTStrCopy.cpp \
     2600        common/string/RTStrEnd.asm \
     2601        common/string/RTUtf16Copy.cpp \
     2602        common/string/utf-16.cpp \
     2603        common/string/utf-8.cpp \
     2604        common/path/RTPathFilename.cpp \
     2605        common/misc/getopt.cpp \
     2606        common/misc/getoptargv.cpp \
     2607        common/misc/message.cpp \
     2608        common/err/errmsg.cpp \
     2609        generic/uuid-generic.cpp \
     2610        generic/rtStrFormatKernelAddress-generic.cpp
     2611
     2612RuntimeR3NoCrt_SOURCES.x86 := \
     2613        common/string/memcpy.asm \
     2614        common/string/memchr.asm \
     2615        common/string/memcmp.asm \
     2616        common/string/memmove.asm \
     2617        common/string/memset.asm \
     2618        common/string/strlen.asm \
     2619        common/string/strchr.asm \
     2620        common/string/strcmp.asm \
     2621        common/string/strncmp.asm
     2622RuntimeR3NoCrt_SOURCES.amd64 := \
     2623        common/string/memcpy.asm \
     2624        common/string/memchr.asm \
     2625        common/string/memcmp.asm \
     2626        common/string/memmove.asm \
     2627        common/string/memset.asm \
     2628        common/string/strlen.asm \
     2629        common/string/strchr.asm \
     2630        common/string/strcmp.asm \
     2631        common/string/strncmp.asm \
     2632
     2633RuntimeR3NoCrt_SOURCES.win := \
     2634        r3/win/nocrt-startup-exe-win.cpp \
     2635        r3/win/nocrt-alloc-win.cpp \
     2636        r3/win/nocrt-streams-win.cpp \
     2637        \
     2638        win/errmsgwin.cpp
    25712639
    25722640#
     
    41124180x509-template.o x509-template.obj: x509-core.o x509-asn1-decoder.o x509-sanity.o x509-init.o
    41134181pkcs7-template.o pkcs7-template.obj: pkcs7-core.o pkcs7-asn1-decoder.o pkcs7-sanity.o pkcs7-init.o
     4182
  • trunk/src/VBox/Runtime/r3/RTPathTemp.cpp

    r83954 r83991  
    11/* $Id$ */
    22/** @file
    3  * IPRT - Path Manipulation.
     3 * IPRT - Path Manipulation, RTPathTemp.
    44 */
    55
     
    3030*********************************************************************************************************************************/
    3131#include "internal/iprt.h"
     32#include <iprt/path.h>
     33
    3234#include <iprt/assert.h>
    3335#include <iprt/env.h>
    3436#include <iprt/err.h>
    35 #include <iprt/path.h>
    3637#include <iprt/string.h>
    3738#include "internal/path.h"
    38 #include "internal/process.h"
    39 
    40 
    41 #ifdef RT_OS_SOLARIS
    42 /**
    43  * Hack to strip of the architecture subdirectory from the exec dir.
    44  *
    45  * @returns See RTPathExecDir.
    46  * @param   pszPath             See RTPathExecDir.
    47  * @param   cchPath             See RTPathExecDir.
    48  */
    49 DECLINLINE(int) rtPathSolarisArchHack(char *pszPath, size_t cchPath)
    50 {
    51     int rc = RTPathExecDir(pszPath, cchPath);
    52     if (RT_SUCCESS(rc))
    53     {
    54         const char *pszLast = RTPathFilename(pszPath);
    55         if (   !strcmp(pszLast, "amd64")
    56             || !strcmp(pszLast, "i386"))
    57             RTPathStripFilename(pszPath);
    58     }
    59     return rc;
    60 }
    61 #endif
    62 
    63 
    64 RTDECL(int) RTPathExecDir(char *pszPath, size_t cchPath)
    65 {
    66     AssertReturn(g_szrtProcExePath[0], VERR_WRONG_ORDER);
    67 
    68     /*
    69      * Calc the length and check if there is space before copying.
    70      */
    71     size_t cch = g_cchrtProcDir;
    72     if (cch < cchPath)
    73     {
    74         memcpy(pszPath, g_szrtProcExePath, cch);
    75         pszPath[cch] = '\0';
    76         return VINF_SUCCESS;
    77     }
    78 
    79     AssertMsgFailed(("Buffer too small (%zu <= %zu)\n", cchPath, cch));
    80     return VERR_BUFFER_OVERFLOW;
    81 }
    82 
    83 
    84 RTDECL(int) RTPathAppPrivateNoArch(char *pszPath, size_t cchPath)
    85 {
    86 #if !defined(RT_OS_WINDOWS) && defined(RTPATH_APP_PRIVATE)
    87     return RTStrCopy(pszPath, cchPath, RTPATH_APP_PRIVATE);
    88 #elif defined(RT_OS_SOLARIS)
    89     return rtPathSolarisArchHack(pszPath, cchPath);
    90 #else
    91     return RTPathExecDir(pszPath, cchPath);
    92 #endif
    93 }
    94 
    95 
    96 RTDECL(int) RTPathAppPrivateArch(char *pszPath, size_t cchPath)
    97 {
    98 #if !defined(RT_OS_WINDOWS) && defined(RTPATH_APP_PRIVATE_ARCH)
    99     return RTStrCopy(pszPath, cchPath, RTPATH_APP_PRIVATE_ARCH);
    100 #else
    101     return RTPathExecDir(pszPath, cchPath);
    102 #endif
    103 }
    104 
    105 
    106 RTDECL(int) RTPathAppPrivateArchTop(char *pszPath, size_t cchPath)
    107 {
    108 #if !defined(RT_OS_WINDOWS) && defined(RTPATH_APP_PRIVATE_ARCH_TOP)
    109     return RTStrCopy(pszPath, cchPath, RTPATH_APP_PRIVATE_ARCH_TOP);
    110 #elif !defined(RT_OS_WINDOWS) && defined(RTPATH_APP_PRIVATE_ARCH)
    111     return RTStrCopy(pszPath, cchPath, RTPATH_APP_PRIVATE_ARCH);
    112 #elif defined(RT_OS_SOLARIS)
    113     return rtPathSolarisArchHack(pszPath, cchPath);
    114 #else
    115     int rc = RTPathExecDir(pszPath, cchPath);
    116     return rc;
    117 #endif
    118 }
    119 
    120 
    121 RTDECL(int) RTPathSharedLibs(char *pszPath, size_t cchPath)
    122 {
    123 #if !defined(RT_OS_WINDOWS) && defined(RTPATH_SHARED_LIBS)
    124     return RTStrCopy(pszPath, cchPath, RTPATH_SHARED_LIBS);
    125 #else
    126     return RTPathExecDir(pszPath, cchPath);
    127 #endif
    128 }
    129 
    130 
    131 RTDECL(int) RTPathAppDocs(char *pszPath, size_t cchPath)
    132 {
    133 #if !defined(RT_OS_WINDOWS) && defined(RTPATH_APP_DOCS)
    134     return RTStrCopy(pszPath, cchPath, RTPATH_APP_DOCS);
    135 #elif defined(RT_OS_SOLARIS)
    136     return rtPathSolarisArchHack(pszPath, cchPath);
    137 #else
    138     return RTPathExecDir(pszPath, cchPath);
    139 #endif
    140 }
    14139
    14240
     
    17775}
    17876
    179 
    180 RTR3DECL(int) RTPathGetMode(const char *pszPath, PRTFMODE pfMode)
    181 {
    182     AssertPtrReturn(pfMode, VERR_INVALID_POINTER);
    183 
    184     RTFSOBJINFO ObjInfo;
    185     int rc = RTPathQueryInfoEx(pszPath, &ObjInfo, RTFSOBJATTRADD_NOTHING, RTPATH_F_FOLLOW_LINK);
    186     if (RT_SUCCESS(rc))
    187         *pfMode = ObjInfo.Attr.fMode;
    188 
    189     return rc;
    190 }
  • trunk/src/VBox/Runtime/r3/path.cpp

    r82968 r83991  
    3030*********************************************************************************************************************************/
    3131#include "internal/iprt.h"
     32#include <iprt/path.h>
     33
    3234#include <iprt/assert.h>
    33 #include <iprt/env.h>
    34 #include <iprt/err.h>
    35 #include <iprt/path.h>
     35#include <iprt/errcore.h>
    3636#include <iprt/string.h>
    3737#include "internal/path.h"
     
    141141
    142142
    143 RTDECL(int) RTPathTemp(char *pszPath, size_t cchPath)
    144 {
    145     /*
    146      * Try get it from the environment first.
    147      */
    148     static const char * const s_apszVars[] =
    149     {
    150         "IPRT_TMPDIR"
    151 #if defined(RT_OS_WINDOWS)
    152         , "TMP", "TEMP", "USERPROFILE"
    153 #elif defined(RT_OS_OS2)
    154         , "TMP", "TEMP", "TMPDIR"
    155 #else
    156         , "TMPDIR"
    157 #endif
    158     };
    159     for (size_t iVar = 0; iVar < RT_ELEMENTS(s_apszVars); iVar++)
    160     {
    161         int rc = RTEnvGetEx(RTENV_DEFAULT, s_apszVars[iVar], pszPath, cchPath, NULL);
    162         if (rc != VERR_ENV_VAR_NOT_FOUND)
    163             return rc;
    164     }
    165 
    166     /*
    167      * Here we should use some sane system default, instead we just use
    168      * the typical unix temp dir for now.
    169      */
    170     /** @todo Windows should default to the windows directory, see GetTempPath.
    171      * Some unixes has path.h and _PATH_TMP. There is also a question about
    172      * whether /var/tmp wouldn't be a better place...  */
    173     if (cchPath < sizeof("/tmp") )
    174         return VERR_BUFFER_OVERFLOW;
    175     memcpy(pszPath, "/tmp", sizeof("/tmp"));
    176     return VINF_SUCCESS;
    177 }
    178 
    179 
    180143RTR3DECL(int) RTPathGetMode(const char *pszPath, PRTFMODE pfMode)
    181144{
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