Add nsGetApplicationControlData2 (#699)

This commit is contained in:
MasaGratoR 2025-12-07 16:20:57 +01:00 committed by GitHub
parent 4a07b079f2
commit 94444aa8d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 44 additions and 0 deletions

View File

@ -312,6 +312,20 @@ Result nsGetDocumentInterface(Service* srv_out);
*/
Result nsGetApplicationControlData(NsApplicationControlSource source, u64 application_id, NsApplicationControlData* buffer, size_t size, u64* actual_size);
/**
* @brief Gets the \ref NsApplicationControlData for the specified application.
* @note Only available on [19.0.0+].
* @param[in] source Source, official sw uses ::NsApplicationControlSource_Storage.
* @param[in] application_id ApplicationId.
* @param[out] buffer \ref NsApplicationControlData
* @param[in] size Size of the buffer.
* @param[in] flag1 Default is 0. 0xFF speeds up execution.
* @param[in] flag2 Default is 0.
* @param[out] actual_size Actual output size.
* @param[out] unk Returned with size, always 0.
*/
Result nsGetApplicationControlData2(NsApplicationControlSource source, u64 application_id, NsApplicationControlData* buffer, size_t size, u8 flag1, u8 flag2, u64* actual_size, u32* unk);
/**
* @brief GetApplicationDesiredLanguage. Selects a \ref NacpLanguageEntry to use from the specified \ref NacpStruct.
* @note Uses \ref nsGetReadOnlyApplicationControlDataInterface on [5.1.0+], otherwise IApplicationManagerInterface is used.

View File

@ -488,6 +488,36 @@ Result nsGetApplicationControlData(NsApplicationControlSource source, u64 applic
return rc;
}
Result nsGetApplicationControlData2(NsApplicationControlSource source, u64 application_id, NsApplicationControlData* buffer, size_t size, u8 flag1, u8 flag2, u64* actual_size, u32* unk) {
if (hosversionBefore(19,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
Service srv={0}, *srv_ptr = &srv;
Result rc=0;
u32 cmd_id = 6;
rc = nsGetReadOnlyApplicationControlDataInterface(&srv);
const struct {
u8 source;
u8 flags[2];
u8 pad[5];
u64 application_id;
} in = { source, {flag1, flag2}, {0}, application_id };
u64 tmp=0;
if (R_SUCCEEDED(rc)) rc = serviceDispatchInOut(srv_ptr, cmd_id, in, tmp,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { buffer, size } },
);
if (R_SUCCEEDED(rc)) {
if (actual_size) *actual_size = tmp >> 32;
if (unk) *unk = (u32)tmp;
}
serviceClose(&srv);
return rc;
}
Result nsGetApplicationDesiredLanguage(NacpStruct *nacp, NacpLanguageEntry **langentry) {
if (nacp==NULL || langentry==NULL)
return MAKERESULT(Module_Libnx, LibnxError_BadInput);