u64 titlesFreeSpace; ///< Free space for titles.
} AM_TWLPartitionInfo;
-/// Initializes AM.
+/// Initializes AM. This doesn't initialize with "am:app", see amAppInit().
Result amInit(void);
+/// Initializes AM with a service which has access to the amapp-commands. This should only be used when using the amapp commands, not non-amapp AM commands.
+Result amAppInit(void);
+
/// Exits AM.
void amExit(void);
ret = srvGetServiceHandle(&amHandle, "am:net");
if (R_FAILED(ret)) ret = srvGetServiceHandle(&amHandle, "am:u");
if (R_FAILED(ret)) ret = srvGetServiceHandle(&amHandle, "am:sys");
+ if (R_FAILED(ret)) AtomicDecrement(&amRefCount);
+
+ return ret;
+}
+
+Result amAppInit(void)
+{
+ Result ret;
+
+ if (AtomicPostIncrement(&amRefCount)) return 0;
+
+ ret = srvGetServiceHandle(&amHandle, "am:sys");
if (R_FAILED(ret)) ret = srvGetServiceHandle(&amHandle, "am:app");
if (R_FAILED(ret)) AtomicDecrement(&amRefCount);