diff --git a/libctru/include/3ds/services/boss.h b/libctru/include/3ds/services/boss.h index aad3ce4..10f9202 100644 --- a/libctru/include/3ds/services/boss.h +++ b/libctru/include/3ds/services/boss.h @@ -39,11 +39,22 @@ typedef struct u8 property_x3e[0x200]; } bossContext; +/// BOSS task status. typedef enum { BOSSTASKSTATUS_STARTED = 0x2, BOSSTASKSTATUS_ERROR = 0x7, } bossTaskStatus; +/// Type values for bossGetNsDataHeaderInfo(). +typedef enum { + bossNsDataHeaderInfoType_ContentSize = 0x3 /// Size of the content. +} bossNsDataHeaderInfoTypes; + +/// Size of the output data for bossGetNsDataHeaderInfo(). +typedef enum { + bossNsDataHeaderInfoTypeSize_ContentSize = 0x4 ///Type2 +} bossNsDataHeaderInfoTypeSizes; + /** * @brief Initializes BOSS. * @param programID programID to use, 0 for the current process. Only used when BOSSP is available without *hax payload. @@ -98,6 +109,15 @@ Result bossSendProperty(u16 PropertyID, const void* buf, u32 size); */ Result bossDeleteNsData(u32 NsDataId); +/** + * @brief Gets header info for the specified NsDataId. + * @param NsDataId NsDataId + * @param type Type of data to load. + * @param buffer Output buffer. + * @param size Output buffer size. + */ +Result bossGetNsDataHeaderInfo(u32 NsDataId, u8 type, void* buffer, u32 size); + /** * @brief Reads data from the content for the specified NsDataId. * @param NsDataId NsDataId diff --git a/libctru/source/services/boss.c b/libctru/source/services/boss.c index 26cd899..1d669fc 100644 --- a/libctru/source/services/boss.c +++ b/libctru/source/services/boss.c @@ -247,6 +247,23 @@ Result bossDeleteNsData(u32 NsDataId) return (Result)cmdbuf[1]; } +Result bossGetNsDataHeaderInfo(u32 NsDataId, u8 type, void* buffer, u32 size) +{ + Result ret = 0; + u32 *cmdbuf = getThreadCommandBuffer(); + + cmdbuf[0] = IPC_MakeHeader(0x27,3,2); // 0x2700C2 + cmdbuf[1] = NsDataId; + cmdbuf[2] = type; + cmdbuf[3] = size; + cmdbuf[4] = IPC_Desc_Buffer(size, IPC_BUFFER_W); + cmdbuf[5] = (u32)buffer; + + if(R_FAILED(ret = svcSendSyncRequest(bossHandle)))return ret; + + return (Result)cmdbuf[1]; +} + Result bossReadNsData(u32 NsDataId, u64 offset, void* buffer, u32 size, u32 *transfer_total, u32 *unk_out) { Result ret = 0;