diff --git a/Makefile b/Makefile index 944b0d9..c69fed0 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ SOURCES := source INCLUDES := source # Bei jedem Release erhöhen - das Auto-Update vergleicht diese Nummer -VERSION := 3.0.6 +VERSION := 3.0.7 APP_TITLE := MBMNET APP_DESCRIPTION := Dein eigenes 3DS-Netzwerk diff --git a/source/nnid.c b/source/nnid.c index b192ae4..94d66e9 100644 --- a/source/nnid.c +++ b/source/nnid.c @@ -6,6 +6,8 @@ // vorher in /3ds/mbmnet/alte-nnid.txt gesichert. #include <3ds.h> #include +#include +#include #include #include #include @@ -18,16 +20,36 @@ static bool ready; +// Für Anfragen an den Account-Server (Konto-Abgleich, Anmelde-Nachweis) muss sich die App bei act anmelden: +// SDK-Version und ein gemeinsamer Speicherblock, den act als Arbeitsspeicher nutzt. actInit() aus libctru macht +// das nicht - ohne lehnte act jede Server-Anfrage mit "ungültiger Zustand" ab (C8A14F4B, E0A14CCE). +#define ACT_SDK_VERSION 0xB0502C8 +#define ACT_SHMEM_SIZE 0x20000 +static u8 *actShm; +static Handle actShmBlock; + Result nnid_init(void) { Result rc = actInit(false); // false = act:a (Verwaltung) ready = R_SUCCEEDED(rc); + if (!ready) return rc; + actShm = memalign(0x1000, ACT_SHMEM_SIZE); + if (actShm) { + memset(actShm, 0, ACT_SHMEM_SIZE); + if (R_SUCCEEDED(svcCreateMemoryBlock(&actShmBlock, (u32)actShm, ACT_SHMEM_SIZE, 0, MEMPERM_READ | MEMPERM_WRITE))) + ACT_Initialize(ACT_SDK_VERSION, ACT_SHMEM_SIZE, actShmBlock); + else { free(actShm); actShm = NULL; } + } return rc; } void nnid_exit(void) { - if (ready) actExit(); + if (!ready) return; + actExit(); + if (actShmBlock) svcCloseHandle(actShmBlock); + free(actShm); + actShm = NULL; } static u8 current_slot(void)