diff --git a/libraries/libstratosphere/include/stratosphere/scs/scs_command_processor.hpp b/libraries/libstratosphere/include/stratosphere/scs/scs_command_processor.hpp index 77aaef917..38a35da1d 100644 --- a/libraries/libstratosphere/include/stratosphere/scs/scs_command_processor.hpp +++ b/libraries/libstratosphere/include/stratosphere/scs/scs_command_processor.hpp @@ -18,17 +18,21 @@ namespace ams::scs { - struct CommandHeader { - u64 id; + struct alignas(alignof(u32)) CommandHeader { + u64 id __attribute__((packed)); u32 command; u32 body_size; }; + static_assert(sizeof(CommandHeader) == 0x10); + static_assert(alignof(CommandHeader) == alignof(u32)); - struct ResponseHeader { - u64 id; + struct alignas(alignof(u32)) ResponseHeader { + u64 id __attribute__((packed)); u32 response; u32 body_size; }; + static_assert(sizeof(ResponseHeader) == 0x10); + static_assert(alignof(ResponseHeader) == alignof(u32)); class CommandProcessor { protected: diff --git a/libraries/libstratosphere/source/cs/cs_command_processor.cpp b/libraries/libstratosphere/source/cs/cs_command_processor.cpp index 4de8cd29d..bc32b44b7 100644 --- a/libraries/libstratosphere/source/cs/cs_command_processor.cpp +++ b/libraries/libstratosphere/source/cs/cs_command_processor.cpp @@ -109,11 +109,17 @@ namespace ams::cs { .buffer_size = sizeof(g_data), }; - /* Acquire the send lock. */ - auto lk = MakeSendGuardBlock(); - /* Take the screenshot. */ - const Result result = DoTakeScreenShotCommand(params); + Result result; + { + /* Acquire the send lock. */ + auto lk = MakeSendGuardBlock(); + + /* Perform the command. */ + result = DoTakeScreenShotCommand(params); + } + + /* Handle the error case. */ if (R_FAILED(result)) { SendErrorResult(socket, header, result); }