Add new files

This commit is contained in:
XorTroll 2020-02-12 22:04:30 +01:00
parent d905b1e008
commit 330634ab74
4 changed files with 84 additions and 0 deletions

View file

@ -0,0 +1,28 @@
#pragma once
#include <stratosphere.hpp>
#include <ul_Include.hpp>
namespace ipc
{
class IPrivateService : public ams::sf::IServiceObject
{
private:
enum class CommandId
{
GetLatestMessage = 0
};
public:
ams::Result GetLatestMessage(ams::sf::Out<u32> msg, const ams::sf::ClientProcessId &client_pid);
public:
DEFINE_SERVICE_DISPATCH_TABLE
{
MAKE_SERVICE_COMMAND_META(GetLatestMessage)
};
};
}

View file

@ -0,0 +1,24 @@
#pragma once
#include <stratosphere.hpp>
#include <ul_Include.hpp>
namespace ipc
{
class IPublicService : public ams::sf::IServiceObject
{
private:
enum class CommandId
{
};
public:
public:
DEFINE_SERVICE_DISPATCH_TABLE
{
};
};
}

View file

@ -0,0 +1,26 @@
#include <ipc/ipc_IPrivateService.hpp>
#include <am/am_DaemonMenuInteraction.hpp>
#include <am/am_LibraryApplet.hpp>
extern ams::os::Mutex g_last_menu_msg_lock;
extern am::MenuMessage g_last_menu_msg;
namespace ipc
{
ams::Result IPrivateService::GetLatestMessage(ams::sf::Out<u32> msg, const ams::sf::ClientProcessId &client_pid)
{
u64 program_id = 0;
UL_ASSERT(pminfoGetProgramId(&program_id, client_pid.process_id.value));
auto last_menu_program_id = am::LibraryAppletGetProgramIdForAppletId(am::LibraryAppletGetMenuAppletId());
// If Menu hasn't been launched it's program ID will be 0/invalid, thus a != check wouldn't be enough
// If any of the IDs is invalid, something unexpected is happening...
if((last_menu_program_id == 0) || (program_id == 0) || (program_id != last_menu_program_id)) return RES_VALUE(Daemon, PrivateServiceInvalidProcess);
std::scoped_lock _lock(g_last_menu_msg_lock);
msg.SetValue((u32)g_last_menu_msg);
g_last_menu_msg = am::MenuMessage::Invalid;
return ams::ResultSuccess();
}
}

View file

@ -0,0 +1,6 @@
#include <ipc/ipc_IPublicService.hpp>
namespace ipc
{
}