ResponseBuilder: Use a bit field for customizing instead of always_move_handles.
This commit is contained in:
parent
f0b6baf3ad
commit
714a576113
|
@ -58,14 +58,22 @@ class ResponseBuilder : public RequestHelperBase {
|
||||||
public:
|
public:
|
||||||
ResponseBuilder(u32* command_buffer) : RequestHelperBase(command_buffer) {}
|
ResponseBuilder(u32* command_buffer) : RequestHelperBase(command_buffer) {}
|
||||||
|
|
||||||
u32 normal_params_size;
|
u32 normal_params_size{};
|
||||||
u32 num_handles_to_copy;
|
u32 num_handles_to_copy{};
|
||||||
u32 num_objects_to_move; ///< Domain objects or move handles, context dependent
|
u32 num_objects_to_move{}; ///< Domain objects or move handles, context dependent
|
||||||
std::ptrdiff_t datapayload_index;
|
std::ptrdiff_t datapayload_index{};
|
||||||
|
|
||||||
|
/// Flags used for customizing the behavior of ResponseBuilder
|
||||||
|
enum class Flags : u32 {
|
||||||
|
None = 0,
|
||||||
|
/// Uses move handles to move objects in the response, even when in a domain. This is
|
||||||
|
/// required when PushMoveObjects is used.
|
||||||
|
AlwaysMoveHandles = 1,
|
||||||
|
};
|
||||||
|
|
||||||
ResponseBuilder(Kernel::HLERequestContext& context, u32 normal_params_size,
|
ResponseBuilder(Kernel::HLERequestContext& context, u32 normal_params_size,
|
||||||
u32 num_handles_to_copy = 0, u32 num_objects_to_move = 0,
|
u32 num_handles_to_copy = 0, u32 num_objects_to_move = 0,
|
||||||
bool always_move_handles = false)
|
Flags flags = Flags::None)
|
||||||
|
|
||||||
: RequestHelperBase(context), normal_params_size(normal_params_size),
|
: RequestHelperBase(context), normal_params_size(normal_params_size),
|
||||||
num_handles_to_copy(num_handles_to_copy), num_objects_to_move(num_objects_to_move) {
|
num_handles_to_copy(num_handles_to_copy), num_objects_to_move(num_objects_to_move) {
|
||||||
|
@ -82,7 +90,8 @@ public:
|
||||||
|
|
||||||
u32 num_handles_to_move{};
|
u32 num_handles_to_move{};
|
||||||
u32 num_domain_objects{};
|
u32 num_domain_objects{};
|
||||||
|
const bool always_move_handles{
|
||||||
|
(static_cast<u32>(flags) & static_cast<u32>(Flags::AlwaysMoveHandles)) != 0};
|
||||||
if (!context.Session()->IsDomain() || always_move_handles) {
|
if (!context.Session()->IsDomain() || always_move_handles) {
|
||||||
num_handles_to_move = num_objects_to_move;
|
num_handles_to_move = num_objects_to_move;
|
||||||
} else {
|
} else {
|
||||||
|
@ -255,9 +264,9 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
ResponseBuilder MakeBuilder(u32 normal_params_size, u32 num_handles_to_copy,
|
ResponseBuilder MakeBuilder(u32 normal_params_size, u32 num_handles_to_copy,
|
||||||
u32 num_handles_to_move, bool always_move_handles = false) {
|
u32 num_handles_to_move,
|
||||||
return {*context, normal_params_size, num_handles_to_copy, num_handles_to_move,
|
ResponseBuilder::Flags flags = ResponseBuilder::Flags::None) {
|
||||||
always_move_handles};
|
return {*context, normal_params_size, num_handles_to_copy, num_handles_to_move, flags};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
@ -21,7 +21,7 @@ void Controller::ConvertSessionToDomain(Kernel::HLERequestContext& ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::DuplicateSession(Kernel::HLERequestContext& ctx) {
|
void Controller::DuplicateSession(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1, true};
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
rb.PushMoveObjects(ctx.Session());
|
rb.PushMoveObjects(ctx.Session());
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,8 @@ void SM::GetService(Kernel::HLERequestContext& ctx) {
|
||||||
if (session.Succeeded()) {
|
if (session.Succeeded()) {
|
||||||
LOG_DEBUG(Service_SM, "called service=%s -> session=%u", name.c_str(),
|
LOG_DEBUG(Service_SM, "called service=%s -> session=%u", name.c_str(),
|
||||||
(*session)->GetObjectId());
|
(*session)->GetObjectId());
|
||||||
IPC::ResponseBuilder rb = rp.MakeBuilder(2, 0, 1, true);
|
IPC::ResponseBuilder rb =
|
||||||
|
rp.MakeBuilder(2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles);
|
||||||
rb.Push(session.Code());
|
rb.Push(session.Code());
|
||||||
rb.PushMoveObjects(std::move(session).Unwrap());
|
rb.PushMoveObjects(std::move(session).Unwrap());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue