v3.0.9: Admin-Prüfung lädt und loggt das Konto bei Bedarf ein (ACTA_LoadConsoleAccount, AcquireAccountTokenEx), zeigt alle Zwischenergebnisse
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
68ee20f35c
commit
f4ff27b375
+32
-6
@@ -22,17 +22,43 @@ static bool wanted; // MBMNET-Konto angemeldet: prüfen
|
||||
// Liest die Tokens des angemeldeten Kontos aus dem Konto-Dienst (lokal, ohne Server-Anfrage von act) und lässt
|
||||
// sie vom MBMNET-Server prüfen. Die Tokens hat dieser Server beim Anmelden ausgestellt, er kann sie selbst prüfen.
|
||||
// (Früher: Service-Token über act angefordert - act lehnte das mit "ungültiger Zustand" ab, C8A14F4B.)
|
||||
static Result read_token(u8 slot, AccountAccessToken *at)
|
||||
{
|
||||
memset(at, 0, sizeof(*at));
|
||||
return ACT_GetAccountInfo(at, sizeof(*at), slot, INFO_TYPE_ACCOUNT_ACCESS_TOKEN);
|
||||
}
|
||||
|
||||
// Konto bei act einloggen (wie Spiele vor dem Online-Gehen): mit dem gespeicherten Passwort, Ergebnis per Ereignis
|
||||
static Result login(u8 slot)
|
||||
{
|
||||
Handle done;
|
||||
Result rc = svcCreateEvent(&done, RESET_ONESHOT);
|
||||
if (R_FAILED(rc)) return rc;
|
||||
rc = ACTA_AcquireAccountTokenEx(slot, NULL, true, done); // true = gespeichertes Passwort benutzen
|
||||
if (R_SUCCEEDED(rc)) rc = svcWaitSynchronization(done, 15ULL * 1000 * 1000 * 1000);
|
||||
if (rc == 0) rc = ACT_GetLastResponseResult();
|
||||
svcCloseHandle(done);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void check_once(void)
|
||||
{
|
||||
lastAct = 0;
|
||||
u8 slot = 0;
|
||||
ACT_GetCommonInfo(&slot, sizeof(slot), INFO_TYPE_COMMON_CURRENT_ACCOUNT_SLOT);
|
||||
if (!slot) ACT_GetCommonInfo(&slot, sizeof(slot), INFO_TYPE_COMMON_DEFAULT_ACCOUNT_SLOT);
|
||||
static AccountAccessToken at;
|
||||
memset(&at, 0, sizeof(at));
|
||||
Result rc = ACT_GetAccountInfo(&at, sizeof(at), slot, INFO_TYPE_ACCOUNT_ACCESS_TOKEN);
|
||||
if (R_FAILED(rc) || (!at.accessToken[0] && !at.refreshToken[0])) {
|
||||
lastAct = rc;
|
||||
snprintf(why, sizeof(why), "Werkzeuge: keine Anmeldung im Konto-Dienst (%08lX).\nEinmal online gehen und neu öffnen.", (unsigned long)rc);
|
||||
// 1. direkt lesen; 2. sonst Konto laden (falls nach dem Umschalten nicht geladen); 3. sonst einloggen
|
||||
Result r1 = read_token(slot, &at), r2 = 0, r3 = 0, r4 = 0;
|
||||
if (R_FAILED(r1) || !at.refreshToken[0]) {
|
||||
r2 = ACTA_LoadConsoleAccount(slot, false, NULL, false, false);
|
||||
r3 = login(slot);
|
||||
r4 = read_token(slot, &at);
|
||||
}
|
||||
if (!at.accessToken[0] && !at.refreshToken[0]) {
|
||||
lastAct = R_FAILED(r4) ? r4 : r1;
|
||||
snprintf(why, sizeof(why), "Werkzeuge: Konto nicht eingeloggt.\nPlatz %u L %08lX A %08lX T %08lX/%08lX",
|
||||
slot, (unsigned long)r2, (unsigned long)r3, (unsigned long)r1, (unsigned long)r4);
|
||||
return;
|
||||
}
|
||||
static char tokens[0x50];
|
||||
@@ -68,7 +94,7 @@ void admin_check(void)
|
||||
{
|
||||
if (!wanted) return;
|
||||
// act noch mit etwas anderem beschäftigt ("ungültiger Zustand"): kurz warten und noch einmal
|
||||
for (int attempt = 0; attempt < 4; attempt++) {
|
||||
for (int attempt = 0; attempt < 2; attempt++) {
|
||||
check_once();
|
||||
if (isAdmin || !lastAct || ((lastAct >> 21) & 0x3F) != 5) break; // 5 = InvalidState
|
||||
svcSleepThread(1000ULL * 1000 * 1000);
|
||||
|
||||
Reference in New Issue
Block a user