Changeset 83991 in vbox for trunk/src/VBox/Additions/WINNT/Installer
- Timestamp:
- Apr 27, 2020 10:08:37 AM (5 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Installer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Installer/Makefile.kmk
r83979 r83991 322 322 # fun challenge. 323 323 # 324 TEMPLATE_VBoxGuestR3BareExe = No extra libs and tricks325 TEMPLATE_VBoxGuestR3BareExe_EXTENDS = VBoxGuestR3Exe326 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_CRT328 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.obj332 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 339 324 PROGRAMS.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 325 VBoxAddInstallNt3x_TEMPLATE := VBoxGuestR3NoCrtExe 326 #VBoxAddInstallNt3x_TEMPLATE := VBoxGuestR3Exe 351 327 VBoxAddInstallNt3x_SOURCES := \ 352 328 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.cpp390 329 391 330 -
trunk/src/VBox/Additions/WINNT/Installer/VBoxAddInstallNt3x.cpp
r83979 r83991 1 1 /* $Id$ */ 2 2 /** @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. 4 4 */ 5 5 6 6 /* 7 * Copyright ( c) 2020 knut st. osmundsen <[email protected]>7 * Copyright (C) 2020 Oracle Corporation 8 8 * 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. 22 16 */ 23 17 … … 29 23 #include <iprt/ctype.h> 30 24 #include <iprt/getopt.h> 31 #include <iprt/mem.h>32 25 #include <iprt/message.h> 33 26 #include <iprt/path.h> … … 40 33 41 34 35 42 36 /********************************************************************************************************************************* 43 * Minimal stream implementation (for message.cpp).*37 * Structures and Typedefs * 44 38 *********************************************************************************************************************************/ 45 /** @todo might be an idea to make a more native version of this and use46 * this as a base for it. */47 48 typedef struct PRINTFBUF49 {50 HANDLE hHandle;51 size_t offBuf;52 char szBuf[128];53 } PRINTFBUF;54 55 struct RTSTREAM56 {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 246 39 /** Components (also indexes into g_aComponents). */ 247 40 typedef enum { kComp_VBoxGuest = 0, kComp_VBoxService = 1, kComp_VBoxMouse = 2} VBOXGACOMP; … … 249 42 typedef enum { kFile_NotFound, kFile_LongName, kFile_8Dot3, kFile_Both, kFile_Mismatch } VBOXGAFILE; 250 43 44 45 /********************************************************************************************************************************* 46 * Defined Constants And Macros * 47 *********************************************************************************************************************************/ 251 48 /** The components. */ 252 49 struct … … 299 96 static uint32_t g_uSaneVersion = MAKE_SANE_VERSION(3,51); 300 97 static DWORD g_dwVersion = 3 | (51 << 8); 98 99 100 RTDECL(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 } 301 107 302 108 … … 948 754 } 949 755 950 951 #include <internal/process.h>952 953 RT_C_DECLS_BEGIN954 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_END959 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 >= 2973 && 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 else1012 rcExit = RTMsgErrorExitFailure("Error parsing command line: %Rrc\n", rc);1013 }1014 else1015 rcExit = RTMsgErrorExitFailure("Failed to convert command line to UTF-8: %Rrc\n", rc);1016 }1017 else1018 rcExit = RTMsgErrorExitFailure("No command line\n");1019 1020 for (;;)1021 NtTerminateProcess(NtCurrentProcess(), rcExit);1022 }1023
Note:
See TracChangeset
for help on using the changeset viewer.