VirtualBox

source: vbox/trunk/src/VBox/Runtime/r3/win/nocrt-startup-common-win.cpp@ 96442

Last change on this file since 96442 was 96442, checked in by vboxsync, 2 years ago

IPRT: Split out the public init data into separate files and made it possible to check if IPRT is initialized w/o dragging in the init code. Added tweak to stream.cpp so it'll work w/o IPRT init in debug builds. bugref:10261

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1/* $Id: nocrt-startup-common-win.cpp 96442 2022-08-23 14:12:35Z vboxsync $ */
2/** @file
3 * IPRT - No-CRT - Common Windows startup code.
4 */
5
6/*
7 * Copyright (C) 2006-2022 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 "internal/nocrt.h"
42#include "internal/process.h"
43
44#include <iprt/nt/nt-and-windows.h>
45#ifndef IPRT_NOCRT_WITHOUT_FATAL_WRITE
46# include <iprt/assert.h>
47#endif
48#include <iprt/getopt.h>
49#include <iprt/message.h>
50#include <iprt/path.h>
51#include <iprt/string.h>
52#include <iprt/utf16.h>
53
54#include "internal/compiler-vcc.h"
55#include "internal/process.h"
56
57
58
59void rtVccWinInitProcExecPath(void)
60{
61 WCHAR wszPath[RTPATH_MAX];
62 UINT cwcPath = GetModuleFileNameW(NULL, wszPath, RT_ELEMENTS(wszPath));
63 if (cwcPath)
64 {
65 char *pszDst = g_szrtProcExePath;
66 int rc = RTUtf16ToUtf8Ex(wszPath, cwcPath, &pszDst, sizeof(g_szrtProcExePath), &g_cchrtProcExePath);
67 if (RT_SUCCESS(rc))
68 {
69 g_cchrtProcExeDir = g_offrtProcName = RTPathFilename(pszDst) - g_szrtProcExePath;
70 while ( g_cchrtProcExeDir >= 2
71 && RTPATH_IS_SLASH(g_szrtProcExePath[g_cchrtProcExeDir - 1])
72 && g_szrtProcExePath[g_cchrtProcExeDir - 2] != ':')
73 g_cchrtProcExeDir--;
74 }
75 else
76 {
77#ifdef IPRT_NOCRT_WITHOUT_FATAL_WRITE
78 RTMsgError("initProcExecPath: RTUtf16ToUtf8Ex failed: %Rrc\n", rc);
79#else
80 rtNoCrtFatalMsgWithRc(RT_STR_TUPLE("initProcExecPath: RTUtf16ToUtf8Ex failed: "), rc);
81#endif
82 }
83 }
84 else
85 {
86#ifdef IPRT_NOCRT_WITHOUT_FATAL_WRITE
87 RTMsgError("initProcExecPath: GetModuleFileNameW failed: %Rhrc\n", GetLastError());
88#else
89 rtNoCrtFatalWriteBegin(RT_STR_TUPLE("initProcExecPath: GetModuleFileNameW failed: "));
90 rtNoCrtFatalWriteWinRc(GetLastError());
91 rtNoCrtFatalWrite(RT_STR_TUPLE("\r\n"));
92#endif
93 }
94}
95
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette