Check proper deviceID and update spec to latest Azahar

This commit is contained in:
PabloMK7 2025-03-25 21:06:31 +01:00
parent 67a76a8db3
commit 665a12e416
7 changed files with 69 additions and 9 deletions

View File

@ -1,6 +1,6 @@
VERSION_MAJOR := 1 VERSION_MAJOR := 1
VERSION_MINOR := 0 VERSION_MINOR := 0
VERSION_REVISION := 1 VERSION_REVISION := 2
all: all:
mkdir -p plugin/build mkdir -p plugin/build

View File

@ -26,7 +26,7 @@ LIBRARIES := ctru
VERSION_MAJOR := 1 VERSION_MAJOR := 1
VERSION_MINOR := 0 VERSION_MINOR := 0
VERSION_MICRO := 1 VERSION_MICRO := 2
BUILD_FLAGS := -march=armv6k -mtune=mpcore -mfloat-abi=hard BUILD_FLAGS := -march=armv6k -mtune=mpcore -mfloat-abi=hard
BUILD_FLAGS_CC := -g -Wall -Wno-strict-aliasing -O3 -mword-relocations \ BUILD_FLAGS_CC := -g -Wall -Wno-strict-aliasing -O3 -mword-relocations \

View File

@ -150,12 +150,12 @@ void Logger::Handler() {
printf("[I] %s\n", log.string.c_str()); printf("[I] %s\n", log.string.c_str());
break; break;
case PendingLog::Type::WARNING: case PendingLog::Type::WARNING:
topScreenConsole.fg = 19; topScreenConsole.fg = 3;
printf("[W] %s\n", log.string.c_str()); printf("[W] %s\n", log.string.c_str());
topScreenConsole.fg = 0; topScreenConsole.fg = 0;
break; break;
case PendingLog::Type::ERROR: case PendingLog::Type::ERROR:
topScreenConsole.fg = 17; topScreenConsole.fg = 1;
printf("[E] %s\n", log.string.c_str()); printf("[E] %s\n", log.string.c_str());
topScreenConsole.fg = 0; topScreenConsole.fg = 0;
break; break;

View File

@ -127,6 +127,12 @@ bool launchPlugin() {
return true; return true;
} }
bool checkEmulator() {
s64 out = 0;
svcGetSystemInfo(&out, 0x20000, 0);
return out != 0;
}
PrintConsole topScreenConsole, bottomScreenConsole; PrintConsole topScreenConsole, bottomScreenConsole;
int transferedBytes = 0; int transferedBytes = 0;
void Main() { void Main() {
@ -148,14 +154,20 @@ void Main() {
consoleSelect(&topScreenConsole); consoleSelect(&topScreenConsole);
consoleClear(); consoleClear();
bool isEmulator = checkEmulator();
{ {
CTRPluginFramework::BCLIM((void*)__data_logo_bin, __data_logo_bin_size).Render(CTRPluginFramework::Rect<int>((320 - 128) / 2, (240 - 128) / 2, 128, 128)); CTRPluginFramework::BCLIM((void*)__data_logo_bin, __data_logo_bin_size).Render(CTRPluginFramework::Rect<int>((320 - 128) / 2, (240 - 128) / 2, 128, 128));
} }
logger.Raw(false, "\n Azahar Artic Setup v%d.%d.%d\n", VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION); logger.Raw(false, "\n Azahar Artic Setup v%d.%d.%d\n", VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION);
logger.Raw(false, " Press A to launch setup tool."); logger.Raw(false, isEmulator ? " " : " Press A to launch setup tool.");
logger.Raw(false, " Press B or START to exit."); logger.Raw(false, " Press B or START to exit.");
logger.Raw(true, ""); logger.Raw(true, "");
logger.Info("Welcome to Azahar Artic Setup Tool!\n Only use this tool with Azahar Emulator\n\n Check bottom screen for controls."); logger.Info("Welcome to Azahar Artic Setup Tool!\n Only use this tool with Azahar Emulator\n\n Check bottom screen for controls.");
if (isEmulator) {
logger.Error("This tool can only be used on a real console.");
}
bool do_jump = false; bool do_jump = false;
while (aptMainLoop()) while (aptMainLoop())
@ -170,7 +182,7 @@ void Main() {
break; break;
} }
if (kDown & KEY_A) { if ((kDown & KEY_A) && !isEmulator) {
logger.Info("Launching Azahar Artic Setup"); logger.Info("Launching Azahar Artic Setup");
bool done = extractPlugin() && launchPlugin(); bool done = extractPlugin() && launchPlugin();
if (done) { if (done) {

@ -1 +1 @@
Subproject commit faa3a2d62172fd0964a495a8b4143827cad1b0db Subproject commit eca355a4961f7550f8a1d1a7e1d3b90e34a7b920

View File

@ -16,7 +16,7 @@ SOURCES := ArticProtocol/sources sources sources/CTRPluginFramework
VERSION_MAJOR := 1 VERSION_MAJOR := 1
VERSION_MINOR := 0 VERSION_MINOR := 0
VERSION_REVISION := 1 VERSION_REVISION := 2
SERVER_PORT := 5543 SERVER_PORT := 5543
IP := 19 IP := 19

View File

@ -15,7 +15,7 @@ extern "C" {
} }
extern bool isControllerMode; extern bool isControllerMode;
constexpr u32 INITIAL_SETUP_APP_VERSION = 0; constexpr u32 INITIAL_SETUP_APP_VERSION = 1;
enum class HandleType { enum class HandleType {
FILE, FILE,
@ -523,10 +523,25 @@ namespace ArticFunctions {
} }
void System_IsAzaharInitialSetup(ArticProtocolServer::MethodInterface& mi) { void System_IsAzaharInitialSetup(ArticProtocolServer::MethodInterface& mi) {
// This function is stubbed, only kept for compatibility reasons
bool good = true; bool good = true;
if (good) mi.FinishInputParameters(); if (good) mi.FinishInputParameters();
logger.Error("Tool and Azahar version mismatch.\n Please check for updates.");
mi.FinishGood(-1);
}
void System_ArticSetupVersion(ArticProtocolServer::MethodInterface& mi) {
bool good = true;
s32 expected;
if (good) good = mi.GetParameterS32(expected);
if (good) mi.FinishInputParameters();
ArticProtocolCommon::Buffer* ret_buf = mi.ReserveResultBuffer(0, 4); ArticProtocolCommon::Buffer* ret_buf = mi.ReserveResultBuffer(0, 4);
if (!ret_buf) { if (!ret_buf) {
return; return;
@ -534,6 +549,37 @@ namespace ArticFunctions {
reinterpret_cast<u32*>(ret_buf->data)[0] = INITIAL_SETUP_APP_VERSION; reinterpret_cast<u32*>(ret_buf->data)[0] = INITIAL_SETUP_APP_VERSION;
isAzaharCalled = true; isAzaharCalled = true;
if ((u32)expected != INITIAL_SETUP_APP_VERSION) {
logger.Error("Tool and Azahar version mismatch.\n Please check for updates.");
}
mi.FinishGood(0);
}
void System_ReportDeviceID(ArticProtocolServer::MethodInterface& mi) {
bool good = true;
s32 deviceID;
if (good) good = mi.GetParameterS32(deviceID);
if (good) mi.FinishInputParameters();
Result res = amInit();
if (R_FAILED(res)) {
mi.FinishGood(res);
return;
}
u32 myDeviceID;
res = AM_GetDeviceId(&myDeviceID);
amExit();
if ((u32)deviceID != myDeviceID) {
logger.Error("Azahar is linked to a different console than this one. Please unlink your previous console from emulator settings before continuing.");
mi.FinishGood(-1);
return;
}
mi.FinishGood(0); mi.FinishGood(0);
} }
@ -898,6 +944,8 @@ namespace ArticFunctions {
{METHOD_NAME("FSDIR_Close"), FSDIR_Close_}, {METHOD_NAME("FSDIR_Close"), FSDIR_Close_},
{METHOD_NAME("System_IsAzaharInitialSetup"), System_IsAzaharInitialSetup}, {METHOD_NAME("System_IsAzaharInitialSetup"), System_IsAzaharInitialSetup},
{METHOD_NAME("System_ArticSetupVersion"), System_ArticSetupVersion},
{METHOD_NAME("System_ReportDeviceID"), System_ReportDeviceID},
{METHOD_NAME("System_GetSystemFile"), System_GetSystemFile}, {METHOD_NAME("System_GetSystemFile"), System_GetSystemFile},
{METHOD_NAME("System_GetNIM"), System_GetNIM}, {METHOD_NAME("System_GetNIM"), System_GetNIM},
}; };