Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  SafeMode.h

  Sprache: C
 

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */


#ifndef mozilla_SafeMode_h
#define mozilla_SafeMode_h

// NB: This code must be able to run apart from XPCOM

#include "mozilla/CmdLineAndEnvUtils.h"
#include "mozilla/Maybe.h"

#if defined(XP_WIN)
#  include "mozilla/PolicyChecks.h"
#  include <windows.h>
#endif  // defined(XP_WIN)

// Undo X11/X.h's definition of None
#undef None

namespace mozilla {

enum class SafeModeFlag : uint32_t {
  None = 0,
  Unset = (1 << 0),
  NoKeyPressCheck = (1 << 1),
};

MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(SafeModeFlag)

template <typename CharT>
inline Maybe<bool> IsSafeModeRequested(
    int& aArgc, CharT* aArgv[],
    const SafeModeFlag aFlags = SafeModeFlag::Unset) {
  CheckArgFlag checkArgFlags = CheckArgFlag::None;
  if (aFlags & SafeModeFlag::Unset) {
    checkArgFlags |= CheckArgFlag::RemoveArg;
  }

  ArgResult ar = CheckArg(aArgc, aArgv, "safe-mode", nullptr, checkArgFlags);
  if (ar == ARG_BAD) {
    return Nothing();
  }

  bool result = ar == ARG_FOUND;

#if defined(XP_WIN)
  // If the shift key is pressed and the ctrl and / or alt keys are not pressed
  // during startup, start in safe mode. GetKeyState returns a short and the
  // high order bit will be 1 if the key is pressed. By masking the returned
  // short with 0x8000 the result will be 0 if the key is not pressed and
  // non-zero otherwise.
  if (!(aFlags & SafeModeFlag::NoKeyPressCheck) &&
      (GetKeyState(VK_SHIFT) & 0x8000) && !(GetKeyState(VK_CONTROL) & 0x8000) &&
      !(GetKeyState(VK_MENU) & 0x8000) &&
      !EnvHasValue("MOZ_DISABLE_SAFE_MODE_KEY")) {
    result = true;
  }

  if (result && PolicyCheckBoolean(L"DisableSafeMode")) {
    result = false;
  }
#endif  // defined(XP_WIN)

#if defined(XP_MACOSX)
  if (!(aFlags & SafeModeFlag::NoKeyPressCheck) &&
      (GetCurrentEventKeyModifiers() & optionKey) &&
      !EnvHasValue("MOZ_DISABLE_SAFE_MODE_KEY")) {
    result = true;
  }
#endif  // defined(XP_MACOSX)

  // The Safe Mode Policy should not be enforced for the env var case
  // (used by updater and crash-recovery).
  if (EnvHasValue("MOZ_SAFE_MODE_RESTART")) {
    result = true;
    if (aFlags & SafeModeFlag::Unset) {
      // unset the env variable
      SaveToEnv("MOZ_SAFE_MODE_RESTART=");
    }
  }

  return Some(result);
}

}  // namespace mozilla

#endif  // mozilla_SafeMode_h

Messung V0.5 in Prozent
C=94 H=90 G=91

¤ Dauer der Verarbeitung: 0.17 Sekunden  (vorverarbeitet am  2026-06-04) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik