@ -39,7 +39,6 @@ void Module::serialize(Archive& ar, const unsigned int file_version) {
ar & shared_font_mem ;
ar & shared_font_loaded ;
ar & shared_font_relocated ;
ar & lock ;
ar & cpu_percent ;
ar & unknown_ns_state_field ;
ar & screen_capture_buffer ;
@ -63,8 +62,8 @@ std::shared_ptr<Module> Module::NSInterface::GetModule() const {
void Module : : NSInterface : : SetWirelessRebootInfo ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x06 , 1 , 2 ) ; // 0x00060042
u32 size = rp . Pop < u32 > ( ) ;
auto buffer = rp . PopStaticBuffer ( ) ;
const auto size = rp . Pop < u32 > ( ) ;
const auto buffer = rp . PopStaticBuffer ( ) ;
apt - > wireless_reboot_info = std : : move ( buffer ) ;
@ -76,8 +75,8 @@ void Module::NSInterface::SetWirelessRebootInfo(Kernel::HLERequestContext& ctx)
void Module : : APTInterface : : Initialize ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x2 , 2 , 0 ) ; // 0x20080
AppletId app_id = rp . PopEnum < AppletId > ( ) ;
u32 attributes = rp . Pop < u32 > ( ) ;
const auto app_id = rp . PopEnum < AppletId > ( ) ;
const auto attributes = rp . Pop < u32 > ( ) ;
LOG_DEBUG ( Service_APT , " called app_id={:#010X}, attributes={:#010X} " , app_id , attributes ) ;
@ -86,10 +85,9 @@ void Module::APTInterface::Initialize(Kernel::HLERequestContext& ctx) {
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( result . Code ( ) ) ;
} else {
auto events = std : : move ( result ) . Unwrap ( ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 3 ) ;
rb . Push ( RESULT_SUCCESS ) ;
rb . PushCopyObjects ( events. notification_event , events . parameter_event ) ;
rb . PushCopyObjects ( result- > notification_event , result - > parameter_event ) ;
}
}
@ -148,9 +146,10 @@ static u32 DecompressLZ11(const u8* in, u8* out) {
}
bool Module : : LoadSharedFont ( ) {
u8 font_region_code ;
auto cfg = Service : : CFG : : GetModule ( system ) ;
ASSERT_MSG ( cfg , " CFG Module missing! " ) ;
u8 font_region_code ;
switch ( cfg - > GetRegionValue ( ) ) {
case 4 : // CHN
font_region_code = 2 ;
@ -279,7 +278,7 @@ void Module::APTInterface::GetSharedFont(Kernel::HLERequestContext& ctx) {
void Module : : APTInterface : : GetWirelessRebootInfo ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x45 , 1 , 0 ) ; // 0x00450040
u32 size = rp . Pop < u32 > ( ) ;
const auto size = rp . Pop < u32 > ( ) ;
LOG_WARNING ( Service_APT , " called size={:08X} " , size ) ;
@ -290,9 +289,11 @@ void Module::APTInterface::GetWirelessRebootInfo(Kernel::HLERequestContext& ctx)
void Module : : APTInterface : : NotifyToWait ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x43 , 1 , 0 ) ; // 0x430040
u32 app_id = rp . Pop < u32 > ( ) ;
const auto app_id = rp . Pop < u32 > ( ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( RESULT_SUCCESS ) ; // No error
LOG_WARNING ( Service_APT , " (STUBBED) app_id={} " , app_id ) ;
}
@ -302,24 +303,26 @@ void Module::APTInterface::GetLockHandle(Kernel::HLERequestContext& ctx) {
// Bits [0:2] are the applet type (System, Library, etc)
// Bit 5 tells the application that there's a pending APT parameter,
// this will cause the app to wait until parameter_event is signaled.
u32 applet_attributes = rp . Pop < u32 > ( ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 3 , 2 ) ;
rb . Push ( RESULT_SUCCESS ) ; // No error
const auto attributes = rp . Pop < u32 > ( ) ;
// TODO(Subv): The output attributes should have an AppletPos of either Library or System |
// Library (depending on the type of the last launched applet) if the input attributes'
// AppletPos has the Library bit set.
LOG_DEBUG ( Service_APT , " called applet_attributes={:#010X} " , attributes ) ;
rb . Push ( applet_attributes ) ; // Applet Attributes, this value is passed to Enable.
rb . Push < u32 > ( 0 ) ; // Least significant bit = power button state
rb . PushCopyObjects ( apt - > lock ) ;
LOG_WARNING ( Service_APT , " (STUBBED) called applet_attributes={:#010X} " , applet_attributes ) ;
auto result = apt - > applet_manager - > GetLockHandle ( attributes ) ;
if ( result . Failed ( ) ) {
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( result . Code ( ) ) ;
} else {
IPC : : RequestBuilder rb = rp . MakeBuilder ( 3 , 2 ) ;
rb . Push ( RESULT_SUCCESS ) ;
rb . PushRaw ( result - > corrected_attributes ) ;
rb . Push < u32 > ( result - > state ) ;
rb . PushCopyObjects ( result - > lock ) ;
}
}
void Module : : APTInterface : : Enable ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x3 , 1 , 0 ) ; // 0x30040
u32 attributes = rp . Pop < u32 > ( ) ;
const auto attributes = rp . Pop < u32 > ( ) ;
LOG_DEBUG ( Service_APT , " called attributes={:#010X} " , attributes ) ;
@ -329,7 +332,8 @@ void Module::APTInterface::Enable(Kernel::HLERequestContext& ctx) {
void Module : : APTInterface : : GetAppletManInfo ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x5 , 1 , 0 ) ; // 0x50040
u32 unk = rp . Pop < u32 > ( ) ;
const auto unk = rp . Pop < u32 > ( ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 5 , 0 ) ;
rb . Push ( RESULT_SUCCESS ) ; // No error
rb . Push < u32 > ( 0 ) ;
@ -342,7 +346,8 @@ void Module::APTInterface::GetAppletManInfo(Kernel::HLERequestContext& ctx) {
void Module : : APTInterface : : IsRegistered ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x9 , 1 , 0 ) ; // 0x90040
AppletId app_id = rp . PopEnum < AppletId > ( ) ;
const auto app_id = rp . PopEnum < AppletId > ( ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 2 , 0 ) ;
rb . Push ( RESULT_SUCCESS ) ; // No error
rb . Push ( apt - > applet_manager - > IsRegistered ( app_id ) ) ;
@ -352,21 +357,23 @@ void Module::APTInterface::IsRegistered(Kernel::HLERequestContext& ctx) {
void Module : : APTInterface : : InquireNotification ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0xB , 1 , 0 ) ; // 0xB0040
u32 app_id = rp . Pop < u32 > ( ) ;
const auto app_id = rp . Pop < u32 > ( ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 2 , 0 ) ;
rb . Push ( RESULT_SUCCESS ) ; // No error
rb . Push ( static_cast < u32 > ( SignalType : : None ) ) ; // Signal type
LOG_WARNING ( Service_APT , " (STUBBED) called app_id={:#010X} " , app_id ) ;
}
void Module : : APTInterface : : SendParameter ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0xC , 4 , 4 ) ; // 0xC0104
AppletId src_app_id = rp . PopEnum < AppletId > ( ) ;
AppletId dst_app_id = rp . PopEnum < AppletId > ( ) ;
SignalType signal_type = rp . PopEnum < SignalType > ( ) ;
u32 buffer_size = rp . Pop < u32 > ( ) ;
std : : shared_ptr < Kernel : : Object > object = rp . PopGenericObject ( ) ;
std : : vector < u8 > buffer = rp . PopStaticBuffer ( ) ;
const auto src_app_id = rp . PopEnum < AppletId > ( ) ;
const auto dst_app_id = rp . PopEnum < AppletId > ( ) ;
const auto signal_type = rp . PopEnum < SignalType > ( ) ;
const auto buffer_size = rp . Pop < u32 > ( ) ;
const auto object = rp . PopGenericObject ( ) ;
const auto buffer = rp . PopStaticBuffer ( ) ;
LOG_DEBUG ( Service_APT ,
" called src_app_id={:#010X}, dst_app_id={:#010X}, signal_type={:#010X}, "
@ -374,42 +381,39 @@ void Module::APTInterface::SendParameter(Kernel::HLERequestContext& ctx) {
src_app_id , dst_app_id , signal_type , buffer_size ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
MessageParameter param ;
param . destination_id = dst_app_id ;
param . sender_id = src_app_id ;
param . object = std : : move ( object ) ;
param . signal = signal_type ;
param . buffer = std : : move ( buffer ) ;
rb . Push ( apt - > applet_manager - > SendParameter ( param ) ) ;
rb . Push ( apt - > applet_manager - > SendParameter ( {
. sender_id = src_app_id ,
. destination_id = dst_app_id ,
. signal = signal_type ,
. object = object ,
. buffer = buffer ,
} ) ) ;
}
void Module : : APTInterface : : ReceiveParameter ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0xD , 2 , 0 ) ; // 0xD0080
const auto app_id = rp . PopEnum < AppletId > ( ) ;
const u32 buffer_size = rp . Pop < u32 > ( ) ;
const auto buffer_size = rp . Pop < u32 > ( ) ;
LOG_DEBUG ( Service_APT , " called app_id={:#010X}, buffer_size={:#010X} " , app_id , buffer_size ) ;
auto next_parameter = apt - > applet_manager - > ReceiveParameter ( app_id ) ;
if ( next_parameter . Failed ( ) ) {
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( next_parameter . Code ( ) ) ;
return ;
} else {
const auto size = std : : min ( static_cast < u32 > ( next_parameter - > buffer . size ( ) ) , buffer_size ) ;
next_parameter - > buffer . resize (
buffer_size ) ; // APT always push a buffer with the maximum size
IPC : : RequestBuilder rb = rp . MakeBuilder ( 4 , 4 ) ;
rb . Push ( RESULT_SUCCESS ) ; // No error
rb . PushEnum ( next_parameter - > sender_id ) ;
rb . PushEnum ( next_parameter - > signal ) ; // Signal type
rb . Push ( size ) ; // Parameter buffer size
rb . PushMoveObjects ( next_parameter - > object ) ;
rb . PushStaticBuffer ( std : : move ( next_parameter - > buffer ) , 0 ) ;
}
IPC : : RequestBuilder rb = rp . MakeBuilder ( 4 , 4 ) ;
rb . Push ( RESULT_SUCCESS ) ; // No error
rb . PushEnum ( next_parameter - > sender_id ) ;
rb . PushEnum ( next_parameter - > signal ) ; // Signal type
ASSERT_MSG ( next_parameter - > buffer . size ( ) < = buffer_size , " Input static buffer is too small! " ) ;
rb . Push ( static_cast < u32 > ( next_parameter - > buffer . size ( ) ) ) ; // Parameter buffer size
rb . PushMoveObjects ( next_parameter - > object ) ;
next_parameter - > buffer . resize ( buffer_size ) ; // APT always push a buffer with the maximum size
rb . PushStaticBuffer ( std : : move ( next_parameter - > buffer ) , 0 ) ;
}
void Module : : APTInterface : : GlanceParameter ( Kernel : : HLERequestContext & ctx ) {
@ -420,42 +424,40 @@ void Module::APTInterface::GlanceParameter(Kernel::HLERequestContext& ctx) {
LOG_DEBUG ( Service_APT , " called app_id={:#010X}, buffer_size={:#010X} " , app_id , buffer_size ) ;
auto next_parameter = apt - > applet_manager - > GlanceParameter ( app_id ) ;
if ( next_parameter . Failed ( ) ) {
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( next_parameter . Code ( ) ) ;
return ;
}
} else {
const auto size = std : : min ( static_cast < u32 > ( next_parameter - > buffer . size ( ) ) , buffer_size ) ;
next_parameter - > buffer . resize (
buffer_size ) ; // APT always push a buffer with the maximum size
IPC : : RequestBuilder rb = rp . MakeBuilder ( 4 , 4 ) ;
rb . Push ( RESULT_SUCCESS ) ; // No error
rb . PushEnum ( next_parameter - > sender_id ) ;
rb . PushEnum ( next_parameter - > signal ) ; // Signal type
ASSERT_MSG ( next_parameter - > buffer . size ( ) < = buffer_size , " Input static buffer is too small! " ) ;
rb . Push ( static_cast < u32 > ( next_parameter - > buffer . size ( ) ) ) ; // Parameter buffer size
rb . PushMoveObjects ( next_parameter - > object ) ;
next_parameter - > buffer . resize ( buffer_size ) ; // APT always push a buffer with the maximum size
rb . PushStaticBuffer ( std : : move ( next_parameter - > buffer ) , 0 ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 4 , 4 ) ;
rb . Push ( RESULT_SUCCESS ) ; // No error
rb . PushEnum ( next_parameter - > sender_id ) ;
rb . PushEnum ( next_parameter - > signal ) ; // Signal type
rb . Push ( size ) ; // Parameter buffer size
rb . PushMoveObjects ( next_parameter - > object ) ;
rb . PushStaticBuffer ( std : : move ( next_parameter - > buffer ) , 0 ) ;
}
}
void Module : : APTInterface : : CancelParameter ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0xF , 4 , 0 ) ; // 0xF0100
const auto check_sender = rp . Pop < bool > ( ) ;
const auto sender_appid = rp . PopEnum < AppletId > ( ) ;
const auto check_receiver = rp . Pop < bool > ( ) ;
const auto receiver_appid = rp . PopEnum < AppletId > ( ) ;
bool check_sender = rp . Pop < bool > ( ) ;
AppletId sender_appid = rp . PopEnum < AppletId > ( ) ;
bool check_receiver = rp . Pop < bool > ( ) ;
AppletId receiver_appid = rp . PopEnum < AppletId > ( ) ;
LOG_DEBUG (
Service_APT ,
" called check_sender={}, sender_appid={:#010X}, check_receiver={}, receiver_appid={:#010X} " ,
check_sender , sender_appid , check_receiver , receiver_appid ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 2 , 0 ) ;
rb . Push ( RESULT_SUCCESS ) ; // No error
rb . Push ( apt - > applet_manager - > CancelParameter ( check_sender , sender_appid , check_receiver ,
receiver_appid ) ) ;
LOG_DEBUG ( Service_APT ,
" called check_sender={}, sender_appid={:#010X}, "
" check_receiver={}, receiver_appid={:#010X} " ,
check_sender , sender_appid , check_receiver , receiver_appid ) ;
}
void Module : : APTInterface : : PrepareToDoApplicationJump ( Kernel : : HLERequestContext & ctx ) {
@ -464,8 +466,8 @@ void Module::APTInterface::PrepareToDoApplicationJump(Kernel::HLERequestContext&
u64 title_id = rp . Pop < u64 > ( ) ;
u8 media_type = rp . Pop < u8 > ( ) ;
LOG_ WARNING ( Service_APT , " (STUBBED) called title_id={:016X}, media_type={:#01X}, flags={:#08X}" ,
title_id , media_type , flags ) ;
LOG_ INFO ( Service_APT , " called title_id={:016X}, media_type={:#01X}, flags={:#08X}" , title_id ,
media_type , flags ) ;
ResultCode result = apt - > applet_manager - > PrepareToDoApplicationJump (
title_id , static_cast < FS : : MediaType > ( media_type ) , flags ) ;
@ -476,32 +478,15 @@ void Module::APTInterface::PrepareToDoApplicationJump(Kernel::HLERequestContext&
void Module : : APTInterface : : DoApplicationJump ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x32 , 2 , 4 ) ; // 0x00320084
auto param_size = rp . Pop < u32 > ( ) ;
auto hmac_size = rp . Pop < u32 > ( ) ;
constexpr u32 max_param_size { 0x300 } ;
constexpr u32 max_hmac_size { 0x20 } ;
if ( param_size > max_param_size ) {
LOG_ERROR ( Service_APT ,
" Param size is outside the valid range (capped to {:#010X}): param_size={:#010X} " ,
max_param_size , param_size ) ;
param_size = max_param_size ;
}
if ( hmac_size > max_hmac_size ) {
LOG_ERROR ( Service_APT ,
" HMAC size is outside the valid range (capped to {:#010X}): hmac_size={:#010X} " ,
max_hmac_size , hmac_size ) ;
hmac_size = max_hmac_size ;
}
auto param = rp . PopStaticBuffer ( ) ;
auto hmac = rp . PopStaticBuffer ( ) ;
const auto param_size = rp . Pop < u32 > ( ) ;
const auto hmac_size = rp . Pop < u32 > ( ) ;
const auto param = rp . PopStaticBuffer ( ) ;
const auto hmac = rp . PopStaticBuffer ( ) ;
LOG_INFO ( Service_APT , " called param_size={:08X}, hmac_size={:08X} " , param_size , hmac_size ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( apt - > applet_manager - > DoApplicationJump (
AppletManager : : DeliverArg { std : : move ( param ) , std : : move ( hmac ) } ) ) ;
rb . Push ( apt - > applet_manager - > DoApplicationJump ( DeliverArg { param , hmac } ) ) ;
}
void Module : : APTInterface : : GetProgramIdOnApplicationJump ( Kernel : : HLERequestContext & ctx ) {
@ -509,7 +494,7 @@ void Module::APTInterface::GetProgramIdOnApplicationJump(Kernel::HLERequestConte
LOG_DEBUG ( Service_APT , " called " ) ;
auto parameters = apt - > applet_manager - > GetApplicationJumpParameters ( ) ;
const auto parameters = apt - > applet_manager - > GetApplicationJumpParameters ( ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 7 , 0 ) ;
rb . Push ( RESULT_SUCCESS ) ;
@ -520,13 +505,13 @@ void Module::APTInterface::GetProgramIdOnApplicationJump(Kernel::HLERequestConte
}
void Module : : APTInterface : : ReceiveDeliverArg ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x35 , 2 , 4 ) ; // 0x00350080
IPC : : RequestParser rp ( ctx , 0x35 , 2 , 0 ) ; // 0x00350080
const auto param_size = rp . Pop < u32 > ( ) ;
const auto hmac_size = rp . Pop < u32 > ( ) ;
LOG_DEBUG ( Service_APT , " called param_size={:08X}, hmac_size={:08X} " , param_size , hmac_size ) ;
auto arg = apt - > applet_manager - > ReceiveDeliverArg ( ) . value_or ( AppletManager: : DeliverArg{ } ) ;
auto arg = apt - > applet_manager - > ReceiveDeliverArg ( ) . value_or ( DeliverArg{ } ) ;
arg . param . resize ( param_size ) ;
arg . hmac . resize ( std : : min < std : : size_t > ( hmac_size , 0x20 ) ) ;
@ -540,40 +525,40 @@ void Module::APTInterface::ReceiveDeliverArg(Kernel::HLERequestContext& ctx) {
void Module : : APTInterface : : PrepareToStartApplication ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x15 , 5 , 0 ) ; // 0x00150140
const u64 title_id = rp . Pop < u64 > ( ) ;
const auto media_type = rp . PopEnum < FS : : MediaType > ( ) ;
const auto title_id = rp . Pop < u64 > ( ) ;
const auto media_type = static_cast < FS : : MediaType > ( rp . Pop < u8 > ( ) ) ;
rp . Skip ( 1 , false ) ; // Padding
const u32 flags = rp . Pop < u32 > ( ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( apt - > applet_manager - > PrepareToStartApplication ( title_id , media_type ) ) ;
const auto flags = rp . Pop < u32 > ( ) ;
LOG_INFO ( Service_APT , " called title_id={:#010X} media_type={} flags={:#010X} " , title_id ,
media_type , flags ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( apt - > applet_manager - > PrepareToStartApplication ( title_id , media_type ) ) ;
}
void Module : : APTInterface : : StartApplication ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x1B , 3 , 4 ) ; // 0x001B00C4
const u32 parameter_size = rp . Pop < u32 > ( ) ;
const u32 hmac_size = rp . Pop < u32 > ( ) ;
const bool paused = rp . Pop < bool > ( ) ;
const std : : vector < u8 > parameter = rp . PopStaticBuffer ( ) ;
const std : : vector < u8 > hmac = rp . PopStaticBuffer ( ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( apt - > applet_manager - > StartApplication ( parameter , hmac , paused ) ) ;
const auto parameter_size = rp . Pop < u32 > ( ) ;
const auto hmac_size = rp . Pop < u32 > ( ) ;
const auto paused = rp . Pop < bool > ( ) ;
const auto parameter = rp . PopStaticBuffer ( ) ;
const auto hmac = rp . PopStaticBuffer ( ) ;
LOG_INFO ( Service_APT , " called parameter_size={:#010X}, hmac_size={:#010X}, paused={} " ,
parameter_size , hmac_size , paused ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( apt - > applet_manager - > StartApplication ( parameter , hmac , paused ) ) ;
}
void Module : : APTInterface : : WakeupApplication ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x1C , 0 , 0 ) ; // 0x001C0000
LOG_DEBUG ( Service_APT , " called " ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( apt - > applet_manager - > WakeupApplication ( ) ) ;
LOG_DEBUG ( Service_APT , " called " ) ;
}
void Module : : APTInterface : : AppletUtility ( Kernel : : HLERequestContext & ctx ) {
@ -583,49 +568,49 @@ void Module::APTInterface::AppletUtility(Kernel::HLERequestContext& ctx) {
const auto utility_command = rp . Pop < u32 > ( ) ;
const auto input_size = rp . Pop < u32 > ( ) ;
const auto output_size = rp . Pop < u32 > ( ) ;
[[maybe_unused]] const std : : vector < u8 > input = rp . PopStaticBuffer ( ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( RESULT_SUCCESS ) ; // No error
[[maybe_unused]] const auto input = rp . PopStaticBuffer ( ) ;
LOG_WARNING ( Service_APT ,
" (STUBBED) called command={:#010X}, input_size={:#010X}, output_size={:#010X} " ,
utility_command , input_size , output_size ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( RESULT_SUCCESS ) ; // No error
}
void Module : : APTInterface : : SetAppCpuTimeLimit ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x4F , 2 , 0 ) ; // 0x4F0080
u32 valu e = rp . Pop < u32 > ( ) ;
apt - > cpu_percent = rp . Pop < u32 > ( ) ;
const auto must_be_on e = rp . Pop < u32 > ( ) ;
const auto value = rp . Pop < u32 > ( ) ;
if ( value ! = 1 ) {
LOG_ERROR ( Service_APT , " This value should be one, but is actually {}! " , value ) ;
LOG_WARNING ( Service_APT , " (STUBBED) called, must_be_one={}, value={} " , must_be_one , value ) ;
if ( must_be_one ! = 1 ) {
LOG_ERROR ( Service_APT , " This value should be one, but is actually {}! " , must_be_one ) ;
}
apt - > cpu_percent = value ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( RESULT_SUCCESS ) ; // No error
LOG_WARNING ( Service_APT , " (STUBBED) called, cpu_percent={}, value={} " , apt - > cpu_percent , value ) ;
}
void Module : : APTInterface : : GetAppCpuTimeLimit ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x50 , 1 , 0 ) ; // 0x500040
u32 valu e = rp . Pop < u32 > ( ) ;
const auto must_be_on e = rp . Pop < u32 > ( ) ;
if ( value ! = 1 ) {
LOG_ERROR ( Service_APT , " This value should be one, but is actually {}! " , value ) ;
LOG_WARNING ( Service_APT , " (STUBBED) called, must_be_one={} " , must_be_one ) ;
if ( must_be_one ! = 1 ) {
LOG_ERROR ( Service_APT , " This value should be one, but is actually {}! " , must_be_one ) ;
}
IPC : : RequestBuilder rb = rp . MakeBuilder ( 2 , 0 ) ;
rb . Push ( RESULT_SUCCESS ) ; // No error
rb . Push ( apt - > cpu_percent ) ;
LOG_WARNING ( Service_APT , " (STUBBED) called, value={} " , value ) ;
}
void Module : : APTInterface : : PrepareToStartLibraryApplet ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x18 , 1 , 0 ) ; // 0x180040
AppletId applet_id = rp . PopEnum < AppletId > ( ) ;
const auto applet_id = rp . PopEnum < AppletId > ( ) ;
LOG_DEBUG ( Service_APT , " called, applet_id={:08X} " , applet_id ) ;
@ -633,23 +618,33 @@ void Module::APTInterface::PrepareToStartLibraryApplet(Kernel::HLERequestContext
rb . Push ( apt - > applet_manager - > PrepareToStartLibraryApplet ( applet_id ) ) ;
}
void Module : : APTInterface : : PrepareToStartSystemApplet ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x19 , 1 , 0 ) ; // 0x190040
const auto applet_id = rp . PopEnum < AppletId > ( ) ;
LOG_DEBUG ( Service_APT , " called, applet_id={:08X} " , applet_id ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( apt - > applet_manager - > PrepareToStartSystemApplet ( applet_id ) ) ;
}
void Module : : APTInterface : : PrepareToStartNewestHomeMenu ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x1A , 0 , 0 ) ; // 0x1A0000
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
LOG_DEBUG ( Service_APT , " called " ) ;
// TODO(Subv): This command can only be called by a System Applet (return 0xC8A0CC04 otherwise).
// This command must return an error when called, otherwise the Home Menu will try to reboot the
// system.
rb . Push ( ResultCode ( ErrorDescription : : AlreadyExists , ErrorModule : : Applet ,
ErrorSummary : : InvalidState , ErrorLevel : : Status ) ) ;
LOG_DEBUG ( Service_APT , " called " ) ;
}
void Module : : APTInterface : : PreloadLibraryApplet ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x16 , 1 , 0 ) ; // 0x160040
AppletId applet_id = rp . PopEnum < AppletId > ( ) ;
const auto applet_id = rp . PopEnum < AppletId > ( ) ;
LOG_DEBUG ( Service_APT , " called, applet_id={:08X} " , applet_id ) ;
@ -659,7 +654,7 @@ void Module::APTInterface::PreloadLibraryApplet(Kernel::HLERequestContext& ctx)
void Module : : APTInterface : : FinishPreloadingLibraryApplet ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x17 , 1 , 0 ) ; // 0x00170040
AppletId applet_id = rp . PopEnum < AppletId > ( ) ;
const auto applet_id = rp . PopEnum < AppletId > ( ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( apt - > applet_manager - > FinishPreloadingLibraryApplet ( applet_id ) ) ;
@ -669,23 +664,35 @@ void Module::APTInterface::FinishPreloadingLibraryApplet(Kernel::HLERequestConte
void Module : : APTInterface : : StartLibraryApplet ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x1E , 2 , 4 ) ; // 0x1E0084
AppletId applet_id = rp . PopEnum < AppletId > ( ) ;
const auto applet_id = rp . PopEnum < AppletId > ( ) ;
const auto buffer_size = rp . Pop < u32 > ( ) ;
const auto object = rp . PopGenericObject ( ) ;
const auto buffer = rp . PopStaticBuffer ( ) ;
[[maybe_unused]] const std : : size_t buffer_size = rp . Pop < u32 > ( ) ;
std : : shared_ptr < Kernel : : Object > object = rp . PopGenericObject ( ) ;
const std : : vector < u8 > buffer = rp . PopStaticBuffer ( ) ;
LOG_DEBUG ( Service_APT , " called, applet_id={:08X} " , applet_id ) ;
LOG_DEBUG ( Service_APT , " called, applet_id={:08X}, size={:08X} " , applet_id , buffer_size ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( apt - > applet_manager - > StartLibraryApplet ( applet_id , std : : move ( object ) , buffer ) ) ;
rb . Push ( apt - > applet_manager - > StartLibraryApplet ( applet_id , object , buffer ) ) ;
}
void Module : : APTInterface : : StartSystemApplet ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x1F , 2 , 4 ) ; // 0x1F0084
const auto applet_id = rp . PopEnum < AppletId > ( ) ;
const auto buffer_size = rp . Pop < u32 > ( ) ;
const auto object = rp . PopGenericObject ( ) ;
const auto buffer = rp . PopStaticBuffer ( ) ;
LOG_DEBUG ( Service_APT , " called, applet_id={:08X}, size={:08X} " , applet_id , buffer_size ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( apt - > applet_manager - > StartSystemApplet ( applet_id , object , buffer ) ) ;
}
void Module : : APTInterface : : CloseApplication ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x27 , 1 , 4 ) ;
[[maybe_unused]] const u32 parameters_size = rp . Pop < u32 > ( ) ;
[[maybe_unused]] const std : : shared_ptr < Kernel : : Object > object = rp . PopGenericObject ( ) ;
[[maybe_unused]] const std : : vector < u8 > buffer = rp . PopStaticBuffer ( ) ;
[[maybe_unused]] const auto parameters_size = rp . Pop < u32 > ( ) ;
[[maybe_unused]] const auto object = rp . PopGenericObject ( ) ;
[[maybe_unused]] const auto buffer = rp . PopStaticBuffer ( ) ;
LOG_DEBUG ( Service_APT , " called " ) ;
@ -697,19 +704,19 @@ void Module::APTInterface::CloseApplication(Kernel::HLERequestContext& ctx) {
void Module : : APTInterface : : CancelLibraryApplet ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x3B , 1 , 0 ) ; // 0x003B0040
bool exiting = rp . Pop < bool > ( ) ;
const auto app_exiting = rp . Pop < bool > ( ) ;
LOG_DEBUG ( Service_APT , " called app_exiting={} " , app_exiting ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push < u32 > ( 1 ) ; // TODO: Find the return code meaning
LOG_WARNING ( Service_APT , " (STUBBED) called exiting={} " , exiting ) ;
rb . Push ( apt - > applet_manager - > CancelLibraryApplet ( app_exiting ) ) ;
}
void Module : : APTInterface : : PrepareToCloseLibraryApplet ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x25 , 3 , 0 ) ; // 0x002500C0
bool not_pause = rp . Pop < bool > ( ) ;
bool exiting = rp . Pop < bool > ( ) ;
bool jump_to_home = rp . Pop < bool > ( ) ;
const auto not_pause = rp . Pop < bool > ( ) ;
const auto exiting = rp . Pop < bool > ( ) ;
const auto jump_to_home = rp . Pop < bool > ( ) ;
LOG_DEBUG ( Service_APT , " called not_pause={} exiting={} jump_to_home={} " , not_pause , exiting ,
jump_to_home ) ;
@ -718,32 +725,52 @@ void Module::APTInterface::PrepareToCloseLibraryApplet(Kernel::HLERequestContext
rb . Push ( apt - > applet_manager - > PrepareToCloseLibraryApplet ( not_pause , exiting , jump_to_home ) ) ;
}
void Module : : APTInterface : : PrepareToCloseSystemApplet ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x26 , 0 , 0 ) ; // 0x260000
LOG_DEBUG ( Service_APT , " called " ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( apt - > applet_manager - > PrepareToCloseSystemApplet ( ) ) ;
}
void Module : : APTInterface : : CloseLibraryApplet ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x28 , 1 , 4 ) ; // 0x00280044
u32 parameter_size = rp . Pop < u32 > ( ) ;
auto object = rp . PopGenericObject ( ) ;
std : : vector < u8 > buffer = rp . PopStaticBuffer ( ) ;
const auto parameter_size = rp . Pop < u32 > ( ) ;
const auto object = rp . PopGenericObject ( ) ;
const auto buffer = rp . PopStaticBuffer ( ) ;
LOG_DEBUG ( Service_APT , " called size={} " , parameter_size ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( apt - > applet_manager - > CloseLibraryApplet ( std : : move ( object ) , std : : move ( buffer ) ) ) ;
rb . Push ( apt - > applet_manager - > CloseLibraryApplet ( object , buffer ) ) ;
}
void Module : : APTInterface : : CloseSystemApplet ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x29 , 1 , 4 ) ; // 0x00280044
const auto parameter_size = rp . Pop < u32 > ( ) ;
const auto object = rp . PopGenericObject ( ) ;
const auto buffer = rp . PopStaticBuffer ( ) ;
LOG_DEBUG ( Service_APT , " called size={} " , parameter_size ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( apt - > applet_manager - > CloseSystemApplet ( object , buffer ) ) ;
}
void Module : : APTInterface : : LoadSysMenuArg ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x36 , 1 , 0 ) ; // 0x00360040
const auto size = std : : min ( std : : size_t { rp . Pop < u32 > ( ) } , SysMenuArgSize ) ;
// This service function does not clear the buffer.
LOG_DEBUG ( Service_APT , " called " ) ;
// This service function does not clear the buffer.
std : : vector < u8 > buffer ( size ) ;
std : : copy_n ( apt - > sys_menu_arg_buffer . cbegin ( ) , size , buffer . begin ( ) ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 2 ) ;
rb . Push ( RESULT_SUCCESS ) ;
rb . PushStaticBuffer ( std : : move ( buffer ) , 0 ) ;
LOG_DEBUG ( Service_APT , " called " ) ;
}
void Module : : APTInterface : : StoreSysMenuArg ( Kernel : : HLERequestContext & ctx ) {
@ -751,21 +778,24 @@ void Module::APTInterface::StoreSysMenuArg(Kernel::HLERequestContext& ctx) {
const auto size = std : : min ( std : : size_t { rp . Pop < u32 > ( ) } , SysMenuArgSize ) ;
const auto & buffer = rp . PopStaticBuffer ( ) ;
LOG_DEBUG ( Service_APT , " called " ) ;
ASSERT_MSG ( buffer . size ( ) > = size , " Buffer too small to hold requested data " ) ;
std : : copy_n ( buffer . cbegin ( ) , size , apt - > sys_menu_arg_buffer . begin ( ) ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( RESULT_SUCCESS ) ;
LOG_DEBUG ( Service_APT , " called " ) ;
}
void Module : : APTInterface : : SendCaptureBufferInfo ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x40 , 1 , 2 ) ; // 0x00400042
u32 size = rp . Pop < u32 > ( ) ;
const auto size = rp . Pop < u32 > ( ) ;
const auto buffer = rp . PopStaticBuffer ( ) ;
LOG_DEBUG ( Service_APT , " called " ) ;
ASSERT ( size = = 0x20 ) ;
apt - > screen_capture_buffer = rp . PopStaticBuffer ( ) ;
apt - > screen_capture_buffer = buffer ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( RESULT_SUCCESS ) ;
@ -773,7 +803,10 @@ void Module::APTInterface::SendCaptureBufferInfo(Kernel::HLERequestContext& ctx)
void Module : : APTInterface : : ReceiveCaptureBufferInfo ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x41 , 1 , 0 ) ; // 0x00410040
u32 size = rp . Pop < u32 > ( ) ;
const auto size = rp . Pop < u32 > ( ) ;
LOG_DEBUG ( Service_APT , " called " ) ;
ASSERT ( size = = 0x20 ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 2 , 2 ) ;
@ -784,7 +817,9 @@ void Module::APTInterface::ReceiveCaptureBufferInfo(Kernel::HLERequestContext& c
void Module : : APTInterface : : GetCaptureInfo ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x4A , 1 , 0 ) ; // 0x004A0040
const u32 size = rp . Pop < u32 > ( ) ;
const auto size = rp . Pop < u32 > ( ) ;
LOG_DEBUG ( Service_APT , " called " ) ;
ASSERT ( size = = 0x20 ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 2 , 2 ) ;
@ -797,29 +832,31 @@ void Module::APTInterface::GetCaptureInfo(Kernel::HLERequestContext& ctx) {
void Module : : APTInterface : : SetScreenCapPostPermission ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x55 , 1 , 0 ) ; // 0x00550040
LOG_DEBUG ( Service_APT , " called, screen_capture_post_permission={} " ,
apt - > screen_capture_post_permission ) ;
apt - > screen_capture_post_permission = static_cast < ScreencapPostPermission > ( rp . Pop < u32 > ( ) & 0xF ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 0 ) ;
rb . Push ( RESULT_SUCCESS ) ; // No error
LOG_WARNING ( Service_APT , " (STUBBED) called, screen_capture_post_permission={} " ,
apt - > screen_capture_post_permission ) ;
}
void Module : : APTInterface : : GetScreenCapPostPermission ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x56 , 0 , 0 ) ; // 0x00560000
LOG_DEBUG ( Service_APT , " (STUBBED) called, screen_capture_post_permission={} " ,
apt - > screen_capture_post_permission ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 2 , 0 ) ;
rb . Push ( RESULT_SUCCESS ) ; // No error
rb . Push ( static_cast < u32 > ( apt - > screen_capture_post_permission ) ) ;
LOG_WARNING ( Service_APT , " (STUBBED) called, screen_capture_post_permission={} " ,
apt - > screen_capture_post_permission ) ;
}
void Module : : APTInterface : : GetAppletInfo ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x6 , 1 , 0 ) ; // 0x60040
auto app_id = rp . PopEnum < AppletId > ( ) ;
const auto app_id = rp . PopEnum < AppletId > ( ) ;
LOG_DEBUG ( Service_APT , " called, app_id={ }" , app_id ) ;
LOG_DEBUG ( Service_APT , " called, app_id={ :08X }" , app_id ) ;
auto info = apt - > applet_manager - > GetAppletInfo ( app_id ) ;
if ( info . Failed ( ) ) {
@ -838,20 +875,11 @@ void Module::APTInterface::GetAppletInfo(Kernel::HLERequestContext& ctx) {
void Module : : APTInterface : : GetStartupArgument ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x51 , 2 , 0 ) ; // 0x00510080
u32 parameter_size = rp . Pop < u32 > ( ) ;
constexpr u32 max_parameter_size { 0x1000 } ;
const auto parameter_size = rp . Pop < u32 > ( ) ;
const auto startup_argument_type = static_cast < StartupArgumentType > ( rp . Pop < u8 > ( ) ) ;
LOG_WARNING ( Service_APT , " called, startup_argument_type={}, parameter_size={:#010X} " ,
startup_argument_type , parameter_size ) ;
if ( parameter_size > max_parameter_size ) {
LOG_ERROR ( Service_APT ,
" Parameter size is outside the valid range (capped to {:#010X}): "
" parameter_size={:#010X} " ,
max_parameter_size , parameter_size ) ;
parameter_size = max_parameter_size ;
}
LOG_INFO ( Service_APT , " called, startup_argument_type={}, parameter_size={:#010X} " ,
startup_argument_type , parameter_size ) ;
std : : vector < u8 > param ;
bool exists = false ;
@ -877,7 +905,8 @@ void Module::APTInterface::GetStartupArgument(Kernel::HLERequestContext& ctx) {
}
}
param . resize ( parameter_size ) ;
constexpr u32 max_parameter_size { 0x1000 } ;
param . resize ( std : : min ( parameter_size , max_parameter_size ) ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 2 , 2 ) ;
rb . Push ( RESULT_SUCCESS ) ;
@ -887,13 +916,17 @@ void Module::APTInterface::GetStartupArgument(Kernel::HLERequestContext& ctx) {
void Module : : APTInterface : : Wrap ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x46 , 4 , 4 ) ;
const u32 output_size = rp . Pop < u32 > ( ) ;
const u32 input_size = rp . Pop < u32 > ( ) ;
const u32 nonce_offset = rp . Pop < u32 > ( ) ;
u32 nonce_size = rp . Pop < u32 > ( ) ;
const auto output_size = rp . Pop < u32 > ( ) ;
const auto input_size = rp . Pop < u32 > ( ) ;
const auto nonce_offset = rp . Pop < u32 > ( ) ;
auto nonce_size = rp . Pop < u32 > ( ) ;
auto & input = rp . PopMappedBuffer ( ) ;
ASSERT ( input . GetSize ( ) = = input_size ) ;
auto & output = rp . PopMappedBuffer ( ) ;
LOG_DEBUG ( Service_APT , " called, output_size={}, input_size={}, nonce_offset={}, nonce_size={} " ,
output_size , input_size , nonce_offset , nonce_size ) ;
ASSERT ( input . GetSize ( ) = = input_size ) ;
ASSERT ( output . GetSize ( ) = = output_size ) ;
// Note: real 3DS still returns SUCCESS when the sizes don't match. It seems that it doesn't
@ -901,9 +934,6 @@ void Module::APTInterface::Wrap(Kernel::HLERequestContext& ctx) {
ASSERT_MSG ( output_size = = input_size + HW : : AES : : CCM_MAC_SIZE ,
" input_size ({}) doesn't match to output_size ({}) " , input_size , output_size ) ;
LOG_DEBUG ( Service_APT , " called, output_size={}, input_size={}, nonce_offset={}, nonce_size={} " ,
output_size , input_size , nonce_offset , nonce_size ) ;
// Note: This weird nonce size modification is verified against real 3DS
nonce_size = std : : min < u32 > ( nonce_size & ~ 3 , HW : : AES : : CCM_NONCE_SIZE ) ;
@ -924,7 +954,6 @@ void Module::APTInterface::Wrap(Kernel::HLERequestContext& ctx) {
IPC : : RequestBuilder rb = rp . MakeBuilder ( 1 , 4 ) ;
rb . Push ( RESULT_SUCCESS ) ;
// Unmap buffer
rb . PushMappedBuffer ( input ) ;
rb . PushMappedBuffer ( output ) ;
@ -932,13 +961,17 @@ void Module::APTInterface::Wrap(Kernel::HLERequestContext& ctx) {
void Module : : APTInterface : : Unwrap ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x47 , 4 , 4 ) ;
const u32 output_size = rp . Pop < u32 > ( ) ;
const u32 input_size = rp . Pop < u32 > ( ) ;
const u32 nonce_offset = rp . Pop < u32 > ( ) ;
u32 nonce_size = rp . Pop < u32 > ( ) ;
const auto output_size = rp . Pop < u32 > ( ) ;
const auto input_size = rp . Pop < u32 > ( ) ;
const auto nonce_offset = rp . Pop < u32 > ( ) ;
auto nonce_size = rp . Pop < u32 > ( ) ;
auto & input = rp . PopMappedBuffer ( ) ;
ASSERT ( input . GetSize ( ) = = input_size ) ;
auto & output = rp . PopMappedBuffer ( ) ;
LOG_DEBUG ( Service_APT , " called, output_size={}, input_size={}, nonce_offset={}, nonce_size={} " ,
output_size , input_size , nonce_offset , nonce_size ) ;
ASSERT ( input . GetSize ( ) = = input_size ) ;
ASSERT ( output . GetSize ( ) = = output_size ) ;
// Note: real 3DS still returns SUCCESS when the sizes don't match. It seems that it doesn't
@ -946,9 +979,6 @@ void Module::APTInterface::Unwrap(Kernel::HLERequestContext& ctx) {
ASSERT_MSG ( output_size = = input_size - HW : : AES : : CCM_MAC_SIZE ,
" input_size ({}) doesn't match to output_size ({}) " , input_size , output_size ) ;
LOG_DEBUG ( Service_APT , " called, output_size={}, input_size={}, nonce_offset={}, nonce_size={} " ,
output_size , input_size , nonce_offset , nonce_size ) ;
// Note: This weird nonce size modification is verified against real 3DS
nonce_size = std : : min < u32 > ( nonce_size & ~ 3 , HW : : AES : : CCM_NONCE_SIZE ) ;
@ -984,6 +1014,8 @@ void Module::APTInterface::Unwrap(Kernel::HLERequestContext& ctx) {
void Module : : APTInterface : : CheckNew3DSApp ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x101 , 0 , 0 ) ; // 0x01010000
LOG_WARNING ( Service_APT , " (STUBBED) called " ) ;
IPC : : RequestBuilder rb = rp . MakeBuilder ( 2 , 0 ) ;
if ( apt - > unknown_ns_state_field ) {
rb . Push ( RESULT_SUCCESS ) ;
@ -991,41 +1023,39 @@ void Module::APTInterface::CheckNew3DSApp(Kernel::HLERequestContext& ctx) {
} else {
PTM : : CheckNew3DS ( rb ) ;
}
LOG_WARNING ( Service_APT , " (STUBBED) called " ) ;
}
void Module : : APTInterface : : CheckNew3DS ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x102 , 0 , 0 ) ; // 0x01020000
IPC : : RequestBuilder rb = rp . MakeBuilder ( 2 , 0 ) ;
PTM : : CheckNew3DS ( rb ) ;
LOG_WARNING ( Service_APT , " (STUBBED) called " ) ;
PTM : : CheckNew3DS ( rb ) ;
}
void Module : : APTInterface : : Unknown0x0103 ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x103 , 0 , 0 ) ; // 0x01030000
IPC : : RequestBuilder rb = rp . MakeBuilder ( 2 , 0 ) ;
LOG_WARNING ( Service_APT , " (STUBBED) called " ) ;
rb . Push ( RESULT_SUCCESS ) ;
rb . Push < u8 > ( Settings : : values . is_new_3ds ? 2 : 1 ) ;
LOG_WARNING ( Service_APT , " (STUBBED) called " ) ;
}
void Module : : APTInterface : : IsTitleAllowed ( Kernel : : HLERequestContext & ctx ) {
IPC : : RequestParser rp ( ctx , 0x105 , 4 , 0 ) ; // 0x01050100
const u64 program_id = rp . Pop < u64 > ( ) ;
const auto media_type = rp . PopEnum < FS : : MediaType > ( ) ;
const auto program_id = rp . Pop < u64 > ( ) ;
const auto media_type = static_cast < FS : : MediaType > ( rp . Pop < u8 > ( ) ) ;
rp . Skip ( 1 , false ) ; // Padding
LOG_DEBUG ( Service_APT , " called, title_id={:016X} media_type={} " , program_id , media_type ) ;
// We allow all titles to be launched, so this function is a no-op
IPC : : RequestBuilder rb = rp . MakeBuilder ( 2 , 0 ) ;
rb . Push ( RESULT_SUCCESS ) ;
rb . Push ( true ) ;
LOG_DEBUG ( Service_APT , " called, title_id={:016X} media_type={} " , program_id , media_type ) ;
}
Module : : APTInterface : : APTInterface ( std : : shared_ptr < Module > apt , const char * name , u32 max_session )
@ -1046,8 +1076,6 @@ Module::Module(Core::System& system) : system(system) {
MemoryPermission : : ReadWrite , MemoryPermission : : Read ,
0 , Kernel : : MemoryRegion : : SYSTEM , " APT:SharedFont " )
. Unwrap ( ) ;
lock = system . Kernel ( ) . CreateMutex ( false , " APT_U:Lock " ) ;
}
Module : : ~ Module ( ) { }