Requires access to "am:net" or "am:u" service
*/
+
+typedef struct
+{
+ u64 titleID;
+ u64 unknown;
+ u16 titleVersion;
+ u8 unknown2[6];
+} TitleList;
+
+
Result amInit();
Result amExit();
mediatype mediatype to get list from
count number of titleids to get
- buffer buffer to write titleids to
+ titleIDs buffer to write titleids to
*/
-Result AM_GetTitleList(u8 mediatype, u32 count, void *buffer);
+Result AM_GetTitleIdList(u8 mediatype, u32 count, u64 *titleIDs);
/* AM_GetDeviceId()
About: Gets a 32bit device id, it's used for some key slot inits
device_id ptr to where the device id is written to
*/
-Result AM_GetDeviceId(u32 *deviceid);
+Result AM_GetDeviceId(u32 *deviceID);
+
+/* AM_ListTitles()
+About: Get a list with details about the installed titles
+
+ mediatype mediatype of title
+ titleCount number of titles to list
+ titleIdList pointer to a title ID list
+ titleList pointer for the output TitleList array
+*/
+Result AM_ListTitles(u8 mediatype, u32 titleCount, u64 *titleIdList, TitleList *titleList);
/**** Title Install Methods ****/
/* AM_StartCiaInstall()
mediatype mediatype to install CIA to
ciahandle ptr to where the handle should be written to
*/
-Result AM_StartCiaInstall(u8 mediatype, Handle *ciahandle);
+Result AM_StartCiaInstall(u8 mediatype, Handle *ciaHandle);
/* AM_StartDlpChildCiaInstall()
About: Inits CIA install process, the returned ciahandle is where the data for CIA should be written to
ciahandle ptr to where the handle should be written to
*/
-Result AM_StartDlpChildCiaInstall(Handle *ciahandle);
+Result AM_StartDlpChildCiaInstall(Handle *ciaHandle);
/* AM_CancelCIAInstall()
About: Abort CIA install process
ciahandle ptr to cia Handle provided by AM
*/
-Result AM_CancelCIAInstall(Handle *ciahandle);
+Result AM_CancelCIAInstall(Handle *ciaHandle);
/* AM_FinishCiaInstall()
About: Once all data is written to the cia handle, this command signals AM to proceed with CIA install.
mediatype same mediatype specified ciahandle was obtained
ciahandle ptr to cia Handle provided by AM
*/
-Result AM_FinishCiaInstall(u8 mediatype, Handle *ciahandle);
+Result AM_FinishCiaInstall(u8 mediatype, Handle *ciaHandle);
/**** Title Delete Methods ****/
/* AM_DeleteTitle()
mediatype mediatype of title
titleid title id of title
*/
-Result AM_DeleteTitle(u8 mediatype, u64 titleid);
+Result AM_DeleteTitle(u8 mediatype, u64 titleID);
/* AM_DeleteAppTitle()
About: Deletes any title on NAND/SDMC
mediatype mediatype of title
titleid title id of title
*/
-Result AM_DeleteAppTitle(u8 mediatype, u64 titleid);
+Result AM_DeleteAppTitle(u8 mediatype, u64 titleID);
/* AM_InstallFIRM()
About: Installs FIRM to NAND (firm0:/ & firm1:/) from a CXI
mediatype mediatype of title
titleid title id of title
*/
-Result AM_InstallFIRM(u8 mediatype, u64 titleid);
+Result AM_InstallFIRM(u8 mediatype, u64 titleID);
/* AM_GetTitleProductCode()
About: Gets the product code of a title based on its title id.
titleid title id of title
productcode buffer to output the product code to (should have a length of 16)
*/
-Result AM_GetTitleProductCode(u8 mediatype, u64 titleid, char* productcode);
-
+Result AM_GetTitleProductCode(u8 mediatype, u64 titleID, char* productCode);
#include <stdio.h>
+#include <string.h>
#include <stdlib.h>
#include <3ds/types.h>
#include <3ds/svc.h>
return (Result)cmdbuf[1];
}
-Result AM_GetTitleList(u8 mediatype, u32 count, void *buffer)
+Result AM_GetTitleIdList(u8 mediatype, u32 count, u64 *titleIDs)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[1] = count;
cmdbuf[2] = mediatype;
cmdbuf[3] = ((count*8) << 4) | 12;
- cmdbuf[4] = (u32)buffer;
+ cmdbuf[4] = (u32)titleIDs;
if((ret = svcSendSyncRequest(amHandle))!=0) return ret;
return (Result)cmdbuf[1];
}
-Result AM_GetDeviceId(u32 *deviceid)
+Result AM_ListTitles(u8 mediatype, u32 titleCount, u64 *titleIdList, TitleList *titleList)
+{
+ Result ret = 0;
+ u32 *cmdbuf = getThreadCommandBuffer();
+
+ cmdbuf[0] = 0x00030084;
+ cmdbuf[1] = mediatype;
+ cmdbuf[2] = titleCount;
+ cmdbuf[3] = ((titleCount*8)<<4) | 10;
+ cmdbuf[4] = (u32)titleIdList;
+ cmdbuf[5] = ((sizeof(TitleList)*titleCount)<<4) | 12;
+ cmdbuf[6] = (u32)titleList;
+
+ if((ret = svcSendSyncRequest(amHandle))!=0) return ret;
+
+ return (Result)cmdbuf[1];
+}
+
+Result AM_GetDeviceId(u32 *deviceID)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
if((ret = svcSendSyncRequest(amHandle))!=0) return ret;
- *deviceid = cmdbuf[3];
+ *deviceID = cmdbuf[3];
return (Result)cmdbuf[1];
}
-Result AM_StartCiaInstall(u8 mediatype, Handle *ciahandle)
+Result AM_StartCiaInstall(u8 mediatype, Handle *ciaHandle)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
if((ret = svcSendSyncRequest(amHandle))!=0) return ret;
- *ciahandle = cmdbuf[3];
+ *ciaHandle = cmdbuf[3];
return (Result)cmdbuf[1];
}
-Result AM_StartDlpChildCiaInstall(Handle *ciahandle)
+Result AM_StartDlpChildCiaInstall(Handle *ciaHandle)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
if((ret = svcSendSyncRequest(amHandle))!=0) return ret;
- *ciahandle = cmdbuf[3];
+ *ciaHandle = cmdbuf[3];
return (Result)cmdbuf[1];
}
-Result AM_CancelCIAInstall(Handle *ciahandle)
+Result AM_CancelCIAInstall(Handle *ciaHandle)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x04040002;
cmdbuf[1] = 0x10;
- cmdbuf[2] = *ciahandle;
+ cmdbuf[2] = *ciaHandle;
if((ret = svcSendSyncRequest(amHandle))!=0) return ret;
return (Result)cmdbuf[1];
}
-Result AM_FinishCiaInstall(u8 mediatype, Handle *ciahandle)
+Result AM_FinishCiaInstall(u8 mediatype, Handle *ciaHandle)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x04050002;
cmdbuf[1] = 0x10;
- cmdbuf[2] = *ciahandle;
+ cmdbuf[2] = *ciaHandle;
if((ret = svcSendSyncRequest(amHandle))!=0) return ret;
return (Result)cmdbuf[1];
}
-Result AM_DeleteTitle(u8 mediatype, u64 titleid)
+Result AM_DeleteTitle(u8 mediatype, u64 titleID)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x041000C0;
cmdbuf[1] = mediatype;
- cmdbuf[2] = titleid & 0xffffffff;
- cmdbuf[3] = (titleid >> 32) & 0xffffffff;
+ cmdbuf[2] = titleID & 0xffffffff;
+ cmdbuf[3] = (u32)(titleID >> 32);
if((ret = svcSendSyncRequest(amHandle))!=0) return ret;
return (Result)cmdbuf[1];
}
-Result AM_DeleteAppTitle(u8 mediatype, u64 titleid)
+Result AM_DeleteAppTitle(u8 mediatype, u64 titleID)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x000400C0;
cmdbuf[1] = mediatype;
- cmdbuf[2] = titleid & 0xffffffff;
- cmdbuf[3] = (titleid >> 32) & 0xffffffff;
+ cmdbuf[2] = titleID & 0xffffffff;
+ cmdbuf[3] = (u32)(titleID >> 32);
if((ret = svcSendSyncRequest(amHandle))!=0) return ret;
return (Result)cmdbuf[1];
}
-Result AM_InstallFIRM(u8 mediatype, u64 titleid)
+Result AM_InstallFIRM(u8 mediatype, u64 titleID)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x000400C0;
cmdbuf[1] = mediatype;
- cmdbuf[2] = titleid & 0xffffffff;
- cmdbuf[3] = (titleid >> 32) & 0xffffffff;
+ cmdbuf[2] = titleID & 0xffffffff;
+ cmdbuf[3] = (u32)(titleID >> 32);
if((ret = svcSendSyncRequest(amHandle))!=0) return ret;
return (Result)cmdbuf[1];
}
-Result AM_GetTitleProductCode(u8 mediatype, u64 titleid, char* productcode)
+Result AM_GetTitleProductCode(u8 mediatype, u64 titleID, char* productCode)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x000500C0;
cmdbuf[1] = mediatype;
- cmdbuf[2] = titleid & 0xffffffff;
- cmdbuf[3] = (titleid >> 32) & 0xffffffff;
+ cmdbuf[2] = titleID & 0xffffffff;
+ cmdbuf[3] = (u32)(titleID >> 32);
if((ret = svcSendSyncRequest(amHandle))!=0) return ret;
- snprintf(productcode, 16, "%s", (char*)(&cmdbuf[2]));
+ // The product code string can use the full 16 bytes without NULL terminator
+ if(productCode) memcpy(productCode, &cmdbuf[2], 16);
+
return (Result)cmdbuf[1];
}