mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 20:42:44 +02:00
ns: Added nsGetFactoryResetInterface(). Added support for IFactoryResetInterface. Improved docs, etc.
This commit is contained in:
parent
4a493775b4
commit
8ae9b5e1a9
@ -234,6 +234,50 @@ Service* nsGetServiceSession_GetterInterface(void);
|
||||
/// Gets the Service object for IApplicationManagerInterface.
|
||||
Service* nsGetServiceSession_ApplicationManagerInterface(void);
|
||||
|
||||
/// Gets the Service object for IFactoryResetInterface via the cmd for that.
|
||||
Result nsGetFactoryResetInterface(Service* srv_out);
|
||||
|
||||
///@}
|
||||
|
||||
///@name IFactoryResetInterface
|
||||
///@{
|
||||
|
||||
/**
|
||||
* @brief ResetToFactorySettings
|
||||
* @note Uses \ref nsGetFactoryResetInterface on [3.0.0+], otherwise IApplicationManagerInterface is used.
|
||||
*/
|
||||
Result nsResetToFactorySettings(void);
|
||||
|
||||
/**
|
||||
* @brief ResetToFactorySettingsWithoutUserSaveData
|
||||
* @note Uses \ref nsGetFactoryResetInterface on [3.0.0+], otherwise IApplicationManagerInterface is used.
|
||||
*/
|
||||
Result nsResetToFactorySettingsWithoutUserSaveData(void);
|
||||
|
||||
/**
|
||||
* @brief ResetToFactorySettingsForRefurbishment
|
||||
* @note Uses \ref nsGetFactoryResetInterface on [3.0.0+], otherwise IApplicationManagerInterface is used.
|
||||
* @note Only available on [2.0.0+].
|
||||
*/
|
||||
Result nsResetToFactorySettingsForRefurbishment(void);
|
||||
|
||||
/**
|
||||
* @brief ResetToFactorySettingsWithPlatformRegion
|
||||
* @note Only available on [9.1.0+].
|
||||
*/
|
||||
Result nsResetToFactorySettingsWithPlatformRegion(void);
|
||||
|
||||
/**
|
||||
* @brief ResetToFactorySettingsWithPlatformRegionAuthentication
|
||||
* @note Only available on [9.1.0+].
|
||||
*/
|
||||
Result nsResetToFactorySettingsWithPlatformRegionAuthentication(void);
|
||||
|
||||
///@}
|
||||
|
||||
///@name IApplicationManagerInterface
|
||||
///@{
|
||||
|
||||
/**
|
||||
* @brief Gets an listing of \ref NsApplicationRecord.
|
||||
* @param[out] records Output array of \ref NsApplicationRecord.
|
||||
|
@ -46,6 +46,10 @@ Service* nsGetServiceSession_ApplicationManagerInterface(void) {
|
||||
return &g_nsAppManSrv;
|
||||
}
|
||||
|
||||
Result nsGetFactoryResetInterface(Service* srv_out) {
|
||||
return _nsGetSession(&g_nsGetterSrv, srv_out, 7994);
|
||||
}
|
||||
|
||||
static Result _nsGetSession(Service* srv, Service* srv_out, u32 cmd_id) {
|
||||
return serviceDispatch(srv, cmd_id,
|
||||
.out_num_objects = 1,
|
||||
@ -234,6 +238,81 @@ static Result _nsCheckNifm(void) {
|
||||
return nifmIsAnyInternetRequestAccepted(nifmGetClientId()) ? 0 : MAKERESULT(16, 340);
|
||||
}
|
||||
|
||||
// IFactoryResetInterface
|
||||
|
||||
Result nsResetToFactorySettings(void) {
|
||||
Service srv={0}, *srv_ptr = &srv;
|
||||
Result rc=0;
|
||||
if (hosversionAtLeast(3,0,0))
|
||||
rc = nsGetFactoryResetInterface(&srv);
|
||||
else
|
||||
srv_ptr = &g_nsAppManSrv;
|
||||
|
||||
if (R_SUCCEEDED(rc)) rc = _nsCmdNoIO(srv_ptr, 100);
|
||||
|
||||
serviceClose(&srv);
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result nsResetToFactorySettingsWithoutUserSaveData(void) {
|
||||
Service srv={0}, *srv_ptr = &srv;
|
||||
Result rc=0;
|
||||
if (hosversionAtLeast(3,0,0))
|
||||
rc = nsGetFactoryResetInterface(&srv);
|
||||
else
|
||||
srv_ptr = &g_nsAppManSrv;
|
||||
|
||||
if (R_SUCCEEDED(rc)) rc = _nsCmdNoIO(srv_ptr, 101);
|
||||
|
||||
serviceClose(&srv);
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result nsResetToFactorySettingsForRefurbishment(void) {
|
||||
if (hosversionBefore(2,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
||||
Service srv={0}, *srv_ptr = &srv;
|
||||
Result rc=0;
|
||||
if (hosversionAtLeast(3,0,0))
|
||||
rc = nsGetFactoryResetInterface(&srv);
|
||||
else
|
||||
srv_ptr = &g_nsAppManSrv;
|
||||
|
||||
if (R_SUCCEEDED(rc)) rc = _nsCmdNoIO(srv_ptr, 102);
|
||||
|
||||
serviceClose(&srv);
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result nsResetToFactorySettingsWithPlatformRegion(void) {
|
||||
if (hosversionBefore(9,1,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
||||
Service srv={0};
|
||||
Result rc = nsGetFactoryResetInterface(&srv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) rc = _nsCmdNoIO(&srv, 103);
|
||||
|
||||
serviceClose(&srv);
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result nsResetToFactorySettingsWithPlatformRegionAuthentication(void) {
|
||||
if (hosversionBefore(9,1,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
||||
Service srv={0};
|
||||
Result rc = nsGetFactoryResetInterface(&srv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) rc = _nsCmdNoIO(&srv, 104);
|
||||
|
||||
serviceClose(&srv);
|
||||
return rc;
|
||||
}
|
||||
|
||||
// IApplicationManagerInterface
|
||||
|
||||
Result nsListApplicationRecord(NsApplicationRecord* records, s32 count, s32 entry_offset, s32* out_entrycount) {
|
||||
return serviceDispatchInOut(&g_nsAppManSrv, 0, entry_offset, *out_entrycount,
|
||||
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
|
||||
|
Loading…
Reference in New Issue
Block a user