fs.mitm: Add domain support (closes #202)

This commit is contained in:
Michael Scire 2018-10-16 13:33:45 -07:00
parent c66fc1ab8a
commit b8ac9a8fcf
2 changed files with 16 additions and 8 deletions

View File

@ -459,7 +459,9 @@ struct Encoder<std::tuple<Args...>> {
raw = (decltype(raw))ipcPrepareHeader(&out_command, sizeof(*raw) + size_in_raw_data_for_arguments<Args... >::value - sizeof(Result));
} else {
raw = (decltype(raw))ipcPrepareHeaderForDomain(&out_command, sizeof(*raw) + size_in_raw_data_for_arguments<Args... >::value + (num_out_sessions_in_arguments<Args... >::value * sizeof(u32)) - sizeof(Result), 0);
*((DomainMessageHeader *)((uintptr_t)raw - sizeof(DomainMessageHeader))) = {0};
auto resp_header = (DomainResponseHeader *)((uintptr_t)raw - sizeof(DomainResponseHeader));
*resp_header = {0};
resp_header->NumObjectIds = num_out_sessions_in_arguments<Args... >::value;
}
@ -474,7 +476,13 @@ struct Encoder<std::tuple<Args...>> {
if (R_FAILED(rc)) {
std::fill(tls, tls + 0x100, 0x00);
ipcInitialize(&out_command);
raw = (decltype(raw))ipcPrepareHeader(&out_command, sizeof(raw));
if (domain_owner != NULL) {
raw = (decltype(raw))ipcPrepareHeaderForDomain(&out_command, sizeof(raw), 0);
auto resp_header = (DomainResponseHeader *)((uintptr_t)raw - sizeof(DomainResponseHeader));
*resp_header = {0};
} else {
raw = (decltype(raw))ipcPrepareHeader(&out_command, sizeof(raw));
}
raw->magic = SFCO_MAGIC;
raw->result = rc;
}
@ -526,7 +534,7 @@ Result WrapIpcCommandImpl(Class *this_ptr, IpcParsedCommand& r, IpcCommand &out_
auto args = Decoder<OutArgs, InArgsWithoutThis>::Decode(r, out_command, pointer_buffer);
auto result = std::apply( [=](auto&&... args) { return (this_ptr->*IpcCommandImpl)(args...); }, args);
DomainOwner *down = NULL;
if (r.IsDomainMessage) {
if (r.IsDomainRequest) {
down = this_ptr->get_owner();
}

View File

@ -118,12 +118,12 @@ class ISession : public IWaitable {
IpcCommand c;
ipcInitialize(&c);
if (r.IsDomainMessage && this->active_object == NULL) {
if (r.IsDomainRequest && this->active_object == NULL) {
return 0xF601;
}
if (r.IsDomainMessage && r.MessageType == DomainMessageType_Close) {
if (r.IsDomainRequest && r.InMessageType == DomainMessageType_Close) {
this->domain->delete_object(this->active_object);
this->active_object = NULL;
struct {
@ -198,11 +198,11 @@ class ISession : public IWaitable {
Result retval = ipcParse(&r);
if (R_SUCCEEDED(retval)) {
if (this->is_domain && (r.CommandType == IpcCommandType_Request || r.CommandType == IpcCommandType_RequestWithContext)) {
retval = ipcParseForDomain(&r);
if (!r.IsDomainMessage || r.ThisObjectId >= DOMAIN_ID_MAX) {
retval = ipcParseDomainRequest(&r);
if (!r.IsDomainRequest || r.InThisObjectId >= DOMAIN_ID_MAX) {
retval = 0xF601;
} else {
this->active_object = this->domain->get_domain_object(r.ThisObjectId);
this->active_object = this->domain->get_domain_object(r.InThisObjectId);
}
} else {
this->active_object = this->service_object;