sf: properly support preservation of inline context

This commit is contained in:
Michael Scire 2020-04-16 23:51:42 -07:00
parent 94ec9ae41b
commit d77fe98203
5 changed files with 148 additions and 0 deletions

View file

@ -239,6 +239,24 @@ namespace ams::sf::hipc {
Result ServerSessionManager::ProcessRequestImpl(ServerSession *session, const cmif::PointerAndSize &in_message, const cmif::PointerAndSize &out_message) {
/* TODO: Inline context support, retrieve from raw data + 0xC. */
const auto cmif_command_type = GetCmifCommandType(in_message);
const auto GetInlineContext = [&]() -> cmif::InlineContext {
cmif::InlineContext ret = {};
switch (cmif_command_type) {
case CmifCommandType_RequestWithContext:
case CmifCommandType_ControlWithContext:
if (in_message.GetSize() >= 0x10) {
static_assert(sizeof(cmif::InlineContext) == 4);
std::memcpy(std::addressof(ret), static_cast<u8 *>(in_message.GetPointer()) + 0xC, sizeof(ret));
}
break;
default:
break;
}
return ret;
};
cmif::ScopedInlineContextChanger sicc(GetInlineContext());
switch (cmif_command_type) {
case CmifCommandType_Request:
case CmifCommandType_RequestWithContext: