1
0
Fork 0

Merge pull request #1950 from JamePeng/fix-apt-0x0055004-and-0x00560000

Correct APT::0x00550040 and APT::0x00560000 function
This commit is contained in:
bunnei 2016-07-28 20:50:49 -04:00 committed by GitHub
commit 47fcd68b01
5 changed files with 31 additions and 22 deletions

View File

@ -37,6 +37,8 @@ static u32 cpu_percent; ///< CPU time available to the running application
// APT::CheckNew3DSApp will check this unknown_ns_state_field to determine processing mode // APT::CheckNew3DSApp will check this unknown_ns_state_field to determine processing mode
static u8 unknown_ns_state_field; static u8 unknown_ns_state_field;
static ScreencapPostPermission screen_capture_post_permission;
/// Parameter data to be returned in the next call to Glance/ReceiveParameter /// Parameter data to be returned in the next call to Glance/ReceiveParameter
static MessageParameter next_parameter; static MessageParameter next_parameter;
@ -389,23 +391,23 @@ void StartLibraryApplet(Service::Interface* self) {
cmd_buff[1] = applet->Start(parameter).raw; cmd_buff[1] = applet->Start(parameter).raw;
} }
void SetNSStateField(Service::Interface* self) { void SetScreenCapPostPermission(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer(); u32* cmd_buff = Kernel::GetCommandBuffer();
unknown_ns_state_field = cmd_buff[1]; screen_capture_post_permission = static_cast<ScreencapPostPermission>(cmd_buff[1] & 0xF);
cmd_buff[0] = IPC::MakeHeader(0x55, 1, 0); cmd_buff[0] = IPC::MakeHeader(0x55, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw; cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_APT, "(STUBBED) unknown_ns_state_field=%u", unknown_ns_state_field); LOG_WARNING(Service_APT, "(STUBBED) screen_capture_post_permission=%u", screen_capture_post_permission);
} }
void GetNSStateField(Service::Interface* self) { void GetScreenCapPostPermission(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer(); u32* cmd_buff = Kernel::GetCommandBuffer();
cmd_buff[0] = IPC::MakeHeader(0x56, 2, 0); cmd_buff[0] = IPC::MakeHeader(0x56, 2, 0);
cmd_buff[1] = RESULT_SUCCESS.raw; cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[8] = unknown_ns_state_field; cmd_buff[2] = static_cast<u32>(screen_capture_post_permission);
LOG_WARNING(Service_APT, "(STUBBED) unknown_ns_state_field=%u", unknown_ns_state_field); LOG_WARNING(Service_APT, "(STUBBED) screen_capture_post_permission=%u", screen_capture_post_permission);
} }
void GetAppletInfo(Service::Interface* self) { void GetAppletInfo(Service::Interface* self) {
@ -500,6 +502,7 @@ void Init() {
cpu_percent = 0; cpu_percent = 0;
unknown_ns_state_field = 0; unknown_ns_state_field = 0;
screen_capture_post_permission = ScreencapPostPermission::CleanThePermission; // TODO(JamePeng): verify the initial value
// TODO(bunnei): Check if these are created in Initialize or on APT process startup. // TODO(bunnei): Check if these are created in Initialize or on APT process startup.
notification_event = Kernel::Event::Create(Kernel::ResetType::OneShot, "APT_U:Notification"); notification_event = Kernel::Event::Create(Kernel::ResetType::OneShot, "APT_U:Notification");

View File

@ -94,6 +94,13 @@ enum class StartupArgumentType : u32 {
OtherMedia = 2, OtherMedia = 2,
}; };
enum class ScreencapPostPermission : u32 {
CleanThePermission = 0, //TODO(JamePeng): verify what "zero" means
NoExplicitSetting = 1,
EnableScreenshotPostingToMiiverse = 2,
DisableScreenshotPostingToMiiverse = 3
};
/// Send a parameter to the currently-running application, which will read it via ReceiveParameter /// Send a parameter to the currently-running application, which will read it via ReceiveParameter
void SendParameter(const MessageParameter& parameter); void SendParameter(const MessageParameter& parameter);
@ -383,25 +390,24 @@ void StartLibraryApplet(Service::Interface* self);
void GetStartupArgument(Service::Interface* self); void GetStartupArgument(Service::Interface* self);
/** /**
* APT::SetNSStateField service function * APT::SetScreenCapPostPermission service function
* Inputs: * Inputs:
* 1 : u8 NS state field * 0 : Header Code[0x00550040]
* 1 : u8 The screenshot posting permission
* Outputs: * Outputs:
* 1 : Result of function, 0 on success, otherwise error code * 1 : Result of function, 0 on success, otherwise error code
* Note:
* This writes the input u8 to a NS state field.
*/ */
void SetNSStateField(Service::Interface* self); void SetScreenCapPostPermission(Service::Interface* self);
/** /**
* APT::GetNSStateField service function * APT::GetScreenCapPostPermission service function
* Inputs:
* 0 : Header Code[0x00560000]
* Outputs: * Outputs:
* 1 : Result of function, 0 on success, otherwise error code * 1 : Result of function, 0 on success, otherwise error code
* 8 : u8 NS state field * 2 : u8 The screenshot posting permission
* Note:
* This returns a u8 NS state field(which can be set by cmd 0x00550040), at cmdreply+8.
*/ */
void GetNSStateField(Service::Interface* self); void GetScreenCapPostPermission(Service::Interface* self);
/** /**
* APT::CheckNew3DSApp service function * APT::CheckNew3DSApp service function

View File

@ -33,8 +33,8 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x004F0080, SetAppCpuTimeLimit, "SetAppCpuTimeLimit"}, {0x004F0080, SetAppCpuTimeLimit, "SetAppCpuTimeLimit"},
{0x00500040, GetAppCpuTimeLimit, "GetAppCpuTimeLimit"}, {0x00500040, GetAppCpuTimeLimit, "GetAppCpuTimeLimit"},
{0x00510080, GetStartupArgument, "GetStartupArgument"}, {0x00510080, GetStartupArgument, "GetStartupArgument"},
{0x00550040, SetNSStateField, "SetNSStateField?"}, {0x00550040, SetScreenCapPostPermission, "SetScreenCapPostPermission"},
{0x00560000, GetNSStateField, "GetNSStateField?"}, {0x00560000, GetScreenCapPostPermission, "GetScreenCapPostPermission"},
{0x01010000, CheckNew3DSApp, "CheckNew3DSApp"}, {0x01010000, CheckNew3DSApp, "CheckNew3DSApp"},
{0x01020000, CheckNew3DS, "CheckNew3DS"} {0x01020000, CheckNew3DS, "CheckNew3DS"}
}; };

View File

@ -92,8 +92,8 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x00510080, GetStartupArgument, "GetStartupArgument"}, {0x00510080, GetStartupArgument, "GetStartupArgument"},
{0x00520104, nullptr, "Wrap1"}, {0x00520104, nullptr, "Wrap1"},
{0x00530104, nullptr, "Unwrap1"}, {0x00530104, nullptr, "Unwrap1"},
{0x00550040, SetNSStateField, "SetNSStateField?" }, {0x00550040, SetScreenCapPostPermission, "SetScreenCapPostPermission"},
{0x00560000, GetNSStateField, "GetNSStateField?" }, {0x00560000, GetScreenCapPostPermission, "GetScreenCapPostPermission"},
{0x00580002, nullptr, "GetProgramID"}, {0x00580002, nullptr, "GetProgramID"},
{0x01010000, CheckNew3DSApp, "CheckNew3DSApp"}, {0x01010000, CheckNew3DSApp, "CheckNew3DSApp"},
{0x01020000, CheckNew3DS, "CheckNew3DS"} {0x01020000, CheckNew3DS, "CheckNew3DS"}

View File

@ -92,8 +92,8 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x00510080, GetStartupArgument, "GetStartupArgument"}, {0x00510080, GetStartupArgument, "GetStartupArgument"},
{0x00520104, nullptr, "Wrap1"}, {0x00520104, nullptr, "Wrap1"},
{0x00530104, nullptr, "Unwrap1"}, {0x00530104, nullptr, "Unwrap1"},
{0x00550040, SetNSStateField, "SetNSStateField?"}, {0x00550040, SetScreenCapPostPermission, "SetScreenCapPostPermission"},
{0x00560000, GetNSStateField, "GetNSStateField?"}, {0x00560000, GetScreenCapPostPermission, "GetScreenCapPostPermission"},
{0x00580002, nullptr, "GetProgramID"}, {0x00580002, nullptr, "GetProgramID"},
{0x01010000, CheckNew3DSApp, "CheckNew3DSApp"}, {0x01010000, CheckNew3DSApp, "CheckNew3DSApp"},
{0x01020000, CheckNew3DS, "CheckNew3DS"} {0x01020000, CheckNew3DS, "CheckNew3DS"}