1 | /* $Id: vcc-fakes-msvcrt.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - Tricks to make the Visual C++ 2010 CRT work on NT4, W2K and XP.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * The contents of this file may alternatively be used under the terms
|
---|
26 | * of the Common Development and Distribution License Version 1.0
|
---|
27 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
28 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
29 | * CDDL are applicable instead of those of the GPL.
|
---|
30 | *
|
---|
31 | * You may elect to license modified versions of this file under the
|
---|
32 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
33 | *
|
---|
34 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
35 | */
|
---|
36 |
|
---|
37 |
|
---|
38 | /*********************************************************************************************************************************
|
---|
39 | * Header Files *
|
---|
40 | *********************************************************************************************************************************/
|
---|
41 | #include <iprt/assert.h>
|
---|
42 | #include <stdlib.h>
|
---|
43 |
|
---|
44 |
|
---|
45 | #ifndef RT_ARCH_X86
|
---|
46 | # error "This code is X86 only"
|
---|
47 | #endif
|
---|
48 |
|
---|
49 |
|
---|
50 |
|
---|
51 | /* This one is static in libcmt, fortunately no rocket science. */
|
---|
52 | extern "C" void __cdecl my_initterm(PFNRT *papfnStart, PFNRT *papfnEnd)
|
---|
53 | {
|
---|
54 | for (; (uintptr_t)papfnStart < (uintptr_t)papfnEnd; papfnStart++)
|
---|
55 | if (*papfnStart)
|
---|
56 | (*papfnStart)();
|
---|
57 | }
|
---|
58 |
|
---|
59 | extern "C" PFNRT __cdecl my_dllonexit(PFNRT pfnToAdd, PFNRT **ppapfnStart, PFNRT **ppapfnEnd)
|
---|
60 | {
|
---|
61 | /* This is _very_ crude, but it'll probably do for our purposes... */
|
---|
62 | size_t cItems = *ppapfnEnd - *ppapfnStart;
|
---|
63 | *ppapfnStart = (PFNRT *)realloc(*ppapfnStart, (cItems + 1) * sizeof(**ppapfnStart));
|
---|
64 | (*ppapfnStart)[cItems] = pfnToAdd;
|
---|
65 | *ppapfnEnd = &(*ppapfnStart)[cItems + 1];
|
---|
66 | return pfnToAdd;
|
---|
67 | }
|
---|
68 |
|
---|
69 | extern "C" int _newmode;
|
---|
70 | extern "C" int __cdecl __setargv(void);
|
---|
71 | extern "C" int __cdecl _setargv(void);
|
---|
72 |
|
---|
73 | extern "C" int __cdecl my_getmainargs(int *pcArgs, char ***ppapszArgs, char ***ppapszEnv, int fDoWildcardExp, int *pfNewMode)
|
---|
74 | {
|
---|
75 | _newmode = *pfNewMode;
|
---|
76 |
|
---|
77 | Assert(!fDoWildcardExp);
|
---|
78 | int rc = _setargv();
|
---|
79 | if (rc >= 0)
|
---|
80 | {
|
---|
81 | *pcArgs = __argc;
|
---|
82 | *ppapszArgs = __argv;
|
---|
83 | *ppapszEnv = _environ;
|
---|
84 | }
|
---|
85 | return rc;
|
---|
86 | }
|
---|
87 |
|
---|
88 | extern "C" void __cdecl my_setusermatherr(PFNRT pfnIgnore)
|
---|
89 | {
|
---|
90 | RT_NOREF(pfnIgnore);
|
---|
91 | /* pure stub. */
|
---|
92 | }
|
---|
93 |
|
---|