VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/hardenedmain.cpp@ 74942

Last change on this file since 74942 was 72247, checked in by vboxsync, 6 years ago

FE/Qt and HostDriver/Support: bugref:9049: Hardening support for split GUI functionality (at least Win host).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.5 KB
Line 
1/* $Id: hardenedmain.cpp 72247 2018-05-17 17:28:18Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - Hardened main().
4 */
5
6/*
7 * Copyright (C) 2008-2017 Oracle Corporation
8 *
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.
16 */
17
18#include <VBox/sup.h>
19
20
21/**
22 * No CRT on windows, so cook our own strcmp.
23 *
24 * @returns See man strcmp.
25 * @param psz1 The first string.
26 * @param psz2 The second string.
27 */
28static int MyStrCmp(const char *psz1, const char *psz2)
29{
30 for (;;)
31 {
32 char ch1 = *psz1++;
33 char ch2 = *psz2++;
34 if (ch1 != ch2)
35 return ch1 < ch2 ? -1 : 1;
36 if (!ch1)
37 return 0;
38 }
39}
40
41
42int main(int argc, char **argv, char **envp)
43{
44 /* First check whether we're about to start a VM: */
45 bool fStartVM = false;
46 /* In separate process: */
47 bool fSeparateProcess = false;
48 for (int i = 1; i < argc && !(fStartVM && fSeparateProcess); ++i)
49 {
50 /* NOTE: the check here must match the corresponding check for the
51 * options to start a VM in main.cpp and VBoxGlobal.cpp exactly,
52 * otherwise there will be weird error messages. */
53 if ( !MyStrCmp(argv[i], "--startvm")
54 || !MyStrCmp(argv[i], "-startvm"))
55 {
56 fStartVM = true;
57 }
58 else if ( !MyStrCmp(argv[i], "--separate")
59 || !MyStrCmp(argv[i], "-separate"))
60 {
61 fSeparateProcess = true;
62 }
63 }
64
65 uint32_t fFlags = (fStartVM && !fSeparateProcess) ? 0 : SUPSECMAIN_FLAGS_DONT_OPEN_DEV;
66
67#ifndef VBOX_GUI_WITH_SHARED_LIBRARY
68# ifdef VBOX_RUNTIME_UI
69 return SUPR3HardenedMain("VirtualBoxVM",
70 fFlags | SUPSECMAIN_FLAGS_TRUSTED_ERROR | SUPSECMAIN_FLAGS_OSX_VM_APP,
71 argc, argv, envp);
72# else
73 return SUPR3HardenedMain("VirtualBox",
74 fFlags | SUPSECMAIN_FLAGS_TRUSTED_ERROR,
75 argc, argv, envp);
76# endif
77#else
78 return SUPR3HardenedMain("VirtualBoxVM",
79 fFlags | SUPSECMAIN_FLAGS_TRUSTED_ERROR,
80 argc, argv, envp);
81#endif
82}
83
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use