diff --git a/include/helpers/util.h b/include/helpers/util.h index 87f03b45..2092c18c 100644 --- a/include/helpers/util.h +++ b/include/helpers/util.h @@ -7,11 +7,6 @@ extern "C" { #endif -Result amspmdmntInitialize(void); -void amspmdmntExit(void); - -Result amspmdmntAtmosphereGetProcessHandle(Handle *out_processHandle); - bool isServiceRunning(const char *serviceName); void getCurrTimeString(char *buffer); void getCurrBatteryPercentage(char *buffer); diff --git a/source/guis/gui_editor.cpp b/source/guis/gui_editor.cpp index dbbf0399..b4981232 100644 --- a/source/guis/gui_editor.cpp +++ b/source/guis/gui_editor.cpp @@ -365,14 +365,14 @@ void uploadBackup(std::string path, std::string fileName) { (new MessageBox("Uploading savefile...\n \nPress \uE0E1 to cancel.", MessageBox::NONE))->show(); requestDraw(); - char serial[0x19]; + SetSysSerialNumber serial; u8 serialHash[0x20]; - setsysGetSerialNumber(serial); + setsysGetSerialNumber(&serial); Sha256Context shaCtx; sha256ContextCreate(&shaCtx); - sha256ContextUpdate(&shaCtx, (u8 *)serial, 0x19); + sha256ContextUpdate(&shaCtx, (u8 *)serial.number, 0x19); sha256ContextGetHash(&shaCtx, serialHash); hashStr.str(""); diff --git a/source/helpers/util.c b/source/helpers/util.c index c5dee301..ec932f20 100644 --- a/source/helpers/util.c +++ b/source/helpers/util.c @@ -6,39 +6,18 @@ #define MHz *1E6 -static Service g_pmdmntService; -static u64 g_refCnt; - static u64 g_uniquePadIds[2]; static size_t g_uniquePadCnt; static HidsysNotificationLedPattern g_patternOn, g_patternOff; -Result amspmdmntInitialize(void) { - atomicIncrement64(&g_refCnt); - - if (serviceIsActive(&g_pmdmntService)) - return 1; - - return smGetService(&g_pmdmntService, "pm:dmnt"); -} - -void amspmdmntExit(void) { - if (atomicDecrement64(&g_refCnt) == 0) { - serviceClose(&g_pmdmntService); - } -} - bool isServiceRunning(const char *serviceName) { - Handle handle; + u8 tmp=0; SmServiceName service_name = smEncodeName(serviceName); - bool running = R_FAILED(smRegisterService(&handle, service_name, false, 1)); - - svcCloseHandle(handle); - - if (!running) - smUnregisterService(service_name); - - return running; + Result rc = serviceDispatchInOut(smGetServiceSession(), 65100, service_name, tmp); + if (R_SUCCEEDED(rc) && tmp & 1) + return true; + else + return false; } void getCurrTimeString(char *buffer) { @@ -86,38 +65,3 @@ void overclockSystem(bool enable) { clkrstCloseSession(&clkrstSession); } } - -Result amspmdmntAtmosphereGetProcessHandle(Handle *out_processHandle) { - IpcCommand c; - ipcInitialize(&c); - - struct { - u64 magic; - u64 cmd_id; - } *raw; - - raw = ipcPrepareHeader(&c, sizeof(*raw)); - - raw->magic = SFCI_MAGIC; - raw->cmd_id = 65000; - - Result rc = serviceIpcDispatch(&g_pmdmntService); - - if (R_SUCCEEDED(rc)) { - IpcParsedCommand r; - - struct { - u64 magic; - u64 result; - } *resp; - - serviceIpcParse(&g_pmdmntService, &r, sizeof(*resp)); - resp = r.Raw; - - *out_processHandle = r.Handles[0]; - - rc = resp->result; - } - - return rc; -} \ No newline at end of file diff --git a/source/main.cpp b/source/main.cpp index 732f38ef..64664518 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -117,7 +117,7 @@ void serviceInitialize() { socketInitializeDefault(); nsInitialize(); accountInitialize(AccountServiceType_Administrator); - plInitialize(); + plInitialize(PlServiceType_User); psmInitialize(); pminfoInitialize(); pmdmntInitialize();