mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-05 19:51:45 +00:00
set.mitm: fix 1.0.0 compat (closes #459)
This commit is contained in:
parent
a611027eeb
commit
20ba6432b9
4 changed files with 58 additions and 23 deletions
|
@ -26,6 +26,7 @@
|
|||
#include "setmitm_main.hpp"
|
||||
#include "setsys_mitm_service.hpp"
|
||||
#include "setsys_settings_items.hpp"
|
||||
#include "setsys_firmware_version.hpp"
|
||||
|
||||
#include "../utils.hpp"
|
||||
|
||||
|
@ -41,6 +42,9 @@ void SetMitmMain(void *arg) {
|
|||
/* Wait for SD to initialize. */
|
||||
Utils::WaitSdInitialized();
|
||||
|
||||
/* Initialize version manager. */
|
||||
VersionManager::Initialize();
|
||||
|
||||
/* Create server manager */
|
||||
auto server_manager = new SetMitmManager(3);
|
||||
|
||||
|
|
|
@ -21,35 +21,65 @@
|
|||
|
||||
static HosMutex g_version_mutex;
|
||||
static bool g_got_version = false;
|
||||
static SetSysFirmwareVersion g_ams_fw_version = {0};
|
||||
static SetSysFirmwareVersion g_fw_version = {0};
|
||||
|
||||
Result VersionManager::GetFirmwareVersion(u64 title_id, SetSysFirmwareVersion *out) {
|
||||
void VersionManager::Initialize() {
|
||||
std::scoped_lock<HosMutex> lock(g_version_mutex);
|
||||
if (!g_got_version) {
|
||||
Result rc = setsysGetFirmwareVersion(&g_fw_version);
|
||||
if (R_FAILED(rc)) {
|
||||
return rc;
|
||||
|
||||
if (g_got_version) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Mount firmware version data archive. */
|
||||
if (R_SUCCEEDED(romfsMountFromDataArchive(0x0100000000000809ul, FsStorageId_NandSystem, "809"))) {
|
||||
ON_SCOPE_EXIT { romfsUnmount("809"); };
|
||||
|
||||
SetSysFirmwareVersion fw_ver;
|
||||
|
||||
/* Firmware version file must exist. */
|
||||
FILE *f = fopen("809:/file", "rb");
|
||||
if (f == NULL) {
|
||||
std::abort();
|
||||
}
|
||||
|
||||
/* Must be possible to read firmware version from file. */
|
||||
if (fread(&fw_ver, sizeof(fw_ver), 1, f) != 1) {
|
||||
std::abort();
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
||||
g_fw_version = fw_ver;
|
||||
g_ams_fw_version = fw_ver;
|
||||
} else {
|
||||
/* Failure to open data archive is an abort. */
|
||||
std::abort();
|
||||
}
|
||||
|
||||
/* Modify the output firmware version. */
|
||||
{
|
||||
u32 major, minor, micro;
|
||||
char display_version[sizeof(g_fw_version.display_version)] = {0};
|
||||
char display_version[sizeof(g_ams_fw_version.display_version)] = {0};
|
||||
|
||||
GetAtmosphereApiVersion(&major, &minor, µ, nullptr, nullptr);
|
||||
snprintf(display_version, sizeof(display_version), "%s (AMS %u.%u.%u)", g_fw_version.display_version, major, minor, micro);
|
||||
snprintf(display_version, sizeof(display_version), "%s (AMS %u.%u.%u)", g_ams_fw_version.display_version, major, minor, micro);
|
||||
|
||||
memcpy(g_fw_version.display_version, display_version, sizeof(g_fw_version.display_version));
|
||||
memcpy(g_ams_fw_version.display_version, display_version, sizeof(g_ams_fw_version.display_version));
|
||||
}
|
||||
|
||||
g_got_version = true;
|
||||
}
|
||||
|
||||
Result VersionManager::GetFirmwareVersion(u64 title_id, SetSysFirmwareVersion *out) {
|
||||
VersionManager::Initialize();
|
||||
|
||||
/* Report atmosphere string to qlaunch, maintenance and nothing else. */
|
||||
if (title_id == 0x0100000000001000ULL || title_id == 0x0100000000001015ULL) {
|
||||
*out = g_fw_version;
|
||||
return 0;
|
||||
*out = g_ams_fw_version;
|
||||
} else {
|
||||
return setsysGetFirmwareVersion(out);
|
||||
*out = g_fw_version;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -20,5 +20,6 @@
|
|||
|
||||
class VersionManager {
|
||||
public:
|
||||
static void Initialize();
|
||||
static Result GetFirmwareVersion(u64 title_id, SetSysFirmwareVersion *out);
|
||||
};
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 49d2188f6fb71b54532f089a2c9439665a327ccd
|
||||
Subproject commit 31c1dc1a825dae11e5ae3424728c8fe411e42142
|
Loading…
Reference in a new issue