mirror of
https://github.com/citra-emu/citra.git
synced 2024-12-23 20:40:05 +00:00
Kernel/IPC: Support translation of null handles
Missed this in my first implementation. Thanks to @wwylele for pointing out that this was missing.
This commit is contained in:
parent
c4f0927a62
commit
f64d0b3f26
@ -67,10 +67,13 @@ ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(const u32_le* sr
|
|||||||
ASSERT(i + num_handles <= command_size); // TODO(yuriks): Return error
|
ASSERT(i + num_handles <= command_size); // TODO(yuriks): Return error
|
||||||
for (u32 j = 0; j < num_handles; ++j) {
|
for (u32 j = 0; j < num_handles; ++j) {
|
||||||
Handle handle = src_cmdbuf[i];
|
Handle handle = src_cmdbuf[i];
|
||||||
SharedPtr<Object> object = src_table.GetGeneric(handle);
|
SharedPtr<Object> object = nullptr;
|
||||||
ASSERT(object != nullptr); // TODO(yuriks): Return error
|
if (handle != 0) {
|
||||||
if (descriptor == IPC::DescriptorType::MoveHandle) {
|
object = src_table.GetGeneric(handle);
|
||||||
src_table.Close(handle);
|
ASSERT(object != nullptr); // TODO(yuriks): Return error
|
||||||
|
if (descriptor == IPC::DescriptorType::MoveHandle) {
|
||||||
|
src_table.Close(handle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_buf[i++] = AddOutgoingHandle(std::move(object));
|
cmd_buf[i++] = AddOutgoingHandle(std::move(object));
|
||||||
@ -112,9 +115,11 @@ ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf, P
|
|||||||
ASSERT(i + num_handles <= command_size);
|
ASSERT(i + num_handles <= command_size);
|
||||||
for (u32 j = 0; j < num_handles; ++j) {
|
for (u32 j = 0; j < num_handles; ++j) {
|
||||||
SharedPtr<Object> object = GetIncomingHandle(cmd_buf[i]);
|
SharedPtr<Object> object = GetIncomingHandle(cmd_buf[i]);
|
||||||
|
Handle handle = 0;
|
||||||
// TODO(yuriks): Figure out the proper error handling for if this fails
|
if (object != nullptr) {
|
||||||
Handle handle = dst_table.Create(object).Unwrap();
|
// TODO(yuriks): Figure out the proper error handling for if this fails
|
||||||
|
handle = dst_table.Create(object).Unwrap();
|
||||||
|
}
|
||||||
dst_cmdbuf[i++] = handle;
|
dst_cmdbuf[i++] = handle;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -94,6 +94,18 @@ TEST_CASE("HLERequestContext::PopoulateFromIncomingCommandBuffer", "[core][kerne
|
|||||||
REQUIRE(context.GetIncomingHandle(output[5]) == c);
|
REQUIRE(context.GetIncomingHandle(output[5]) == c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("translates null handles") {
|
||||||
|
const u32_le input[]{
|
||||||
|
IPC::MakeHeader(0, 0, 2), IPC::MoveHandleDesc(1), 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
auto result = context.PopulateFromIncomingCommandBuffer(input, *process, handle_table);
|
||||||
|
|
||||||
|
REQUIRE(result == RESULT_SUCCESS);
|
||||||
|
auto* output = context.CommandBuffer();
|
||||||
|
REQUIRE(context.GetIncomingHandle(output[2]) == nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("translates CallingPid descriptors") {
|
SECTION("translates CallingPid descriptors") {
|
||||||
const u32_le input[]{
|
const u32_le input[]{
|
||||||
IPC::MakeHeader(0, 0, 2), IPC::CallingPidDesc(), 0x98989898,
|
IPC::MakeHeader(0, 0, 2), IPC::CallingPidDesc(), 0x98989898,
|
||||||
@ -171,6 +183,17 @@ TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") {
|
|||||||
REQUIRE(handle_table.GetGeneric(output[4]) == b);
|
REQUIRE(handle_table.GetGeneric(output[4]) == b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("translates null handles") {
|
||||||
|
input[0] = IPC::MakeHeader(0, 0, 2);
|
||||||
|
input[1] = IPC::MoveHandleDesc(1);
|
||||||
|
input[2] = context.AddOutgoingHandle(nullptr);
|
||||||
|
|
||||||
|
auto result = context.WriteToOutgoingCommandBuffer(output, *process, handle_table);
|
||||||
|
|
||||||
|
REQUIRE(result == RESULT_SUCCESS);
|
||||||
|
REQUIRE(output[2] == 0);
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("translates multi-handle descriptors") {
|
SECTION("translates multi-handle descriptors") {
|
||||||
auto a = MakeObject();
|
auto a = MakeObject();
|
||||||
auto b = MakeObject();
|
auto b = MakeObject();
|
||||||
|
Loading…
Reference in New Issue
Block a user