From a223006c50aa3fa2370b40a1eacd3d6046c5d361 Mon Sep 17 00:00:00 2001
From: Morph <39850852+Morph1984@users.noreply.github.com>
Date: Mon, 19 Apr 2021 11:17:47 -0400
Subject: [PATCH 1/2] time: Fix GetClockSnapshotFromSystemClockContext

This removes an incorrect alignment usage and corrects the positions of the popped parameters.

- Fixes Super Kirby Clash crashing on boot
---
 src/core/hle/service/time/time.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp
index 63e0247de2..8427555e95 100644
--- a/src/core/hle/service/time/time.cpp
+++ b/src/core/hle/service/time/time.cpp
@@ -303,7 +303,7 @@ void Module::Interface::GetClockSnapshotFromSystemClockContext(Kernel::HLEReques
     IPC::RequestParser rp{ctx};
     const auto type{rp.PopEnum<Clock::TimeType>()};
 
-    rp.AlignWithPadding();
+    rp.Skip(1, false);
 
     const Clock::SystemClockContext user_context{rp.PopRaw<Clock::SystemClockContext>()};
     const Clock::SystemClockContext network_context{rp.PopRaw<Clock::SystemClockContext>()};
@@ -319,9 +319,10 @@ void Module::Interface::GetClockSnapshotFromSystemClockContext(Kernel::HLEReques
         return;
     }
 
+    ctx.WriteBuffer(clock_snapshot);
+
     IPC::ResponseBuilder rb{ctx, 2};
     rb.Push(RESULT_SUCCESS);
-    ctx.WriteBuffer(clock_snapshot);
 }
 
 void Module::Interface::CalculateStandardUserSystemClockDifferenceByUser(

From 8285776603a968b8d0068bb1f2006ce2ecb8a972 Mon Sep 17 00:00:00 2001
From: Morph <39850852+Morph1984@users.noreply.github.com>
Date: Mon, 19 Apr 2021 12:09:18 -0400
Subject: [PATCH 2/2] time: Write buffer before pushing RESULT_SUCCESS in
 GetClockSnapshot

---
 src/core/hle/service/time/time.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp
index 8427555e95..32f372d71c 100644
--- a/src/core/hle/service/time/time.cpp
+++ b/src/core/hle/service/time/time.cpp
@@ -294,9 +294,10 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) {
         return;
     }
 
+    ctx.WriteBuffer(clock_snapshot);
+
     IPC::ResponseBuilder rb{ctx, 2};
     rb.Push(RESULT_SUCCESS);
-    ctx.WriteBuffer(clock_snapshot);
 }
 
 void Module::Interface::GetClockSnapshotFromSystemClockContext(Kernel::HLERequestContext& ctx) {