mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-02 23:59:49 -04:00
dns.mitm: support % in hosts file as stand-in for environment identifier
This commit is contained in:
parent
5b0821cb03
commit
874f5b22e0
7 changed files with 148 additions and 8 deletions
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
namespace ams::nsd::impl::device {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr const char SettingsName[] = "nsd";
|
||||
constexpr const char SettingsKey[] = "environment_identifier";
|
||||
|
||||
constinit os::SdkMutex g_environment_identifier_lock;
|
||||
constinit EnvironmentIdentifier g_environment_identifier = {};
|
||||
constinit bool g_determined_environment_identifier = false;
|
||||
|
||||
}
|
||||
|
||||
const EnvironmentIdentifier &GetEnvironmentIdentifierFromSettings() {
|
||||
std::scoped_lock lk(g_environment_identifier_lock);
|
||||
|
||||
if (!g_determined_environment_identifier) {
|
||||
/* Check size. */
|
||||
AMS_ABORT_UNLESS(settings::fwdbg::GetSettingsItemValueSize(SettingsName, SettingsKey) != 0);
|
||||
|
||||
/* Get value. */
|
||||
const size_t size = settings::fwdbg::GetSettingsItemValue(g_environment_identifier.value, EnvironmentIdentifier::Size, SettingsName, SettingsKey);
|
||||
AMS_ABORT_UNLESS(size < EnvironmentIdentifier::Size);
|
||||
AMS_ABORT_UNLESS(g_environment_identifier == EnvironmentIdentifierOfProductDevice || g_environment_identifier == EnvironmentIdentifierOfNotProductDevice);
|
||||
|
||||
g_determined_environment_identifier = true;
|
||||
}
|
||||
|
||||
return g_environment_identifier;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue