From 4354179156e38bac0819ba6c10c1a2245ba879d7 Mon Sep 17 00:00:00 2001
From: Hamish Milne <hamishmilne83@gmail.com>
Date: Thu, 26 Dec 2019 18:14:22 +0000
Subject: [PATCH] Added ERR service serialization

---
 TODO                           |  2 +-
 src/core/hle/service/err_f.cpp | 14 ++++++++++++++
 src/core/hle/service/err_f.h   | 14 ++++++++++++++
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/TODO b/TODO
index c3e8a57d7..4a07c0608 100644
--- a/TODO
+++ b/TODO
@@ -76,7 +76,7 @@
         ✔ CSND @started(19-12-26 17:51) @done(19-12-26 17:56) @lasted(5m30s)
         ✔ DLP @done(19-12-26 18:02)
         ✔ DSP @done(19-12-26 18:10)
-        ☐ ERR
+        ✔ ERR @done(19-12-26 18:14)
         ☐ FRD
         ☐ FS
         ☐ GSP
diff --git a/src/core/hle/service/err_f.cpp b/src/core/hle/service/err_f.cpp
index b218eb793..0efc600e8 100644
--- a/src/core/hle/service/err_f.cpp
+++ b/src/core/hle/service/err_f.cpp
@@ -6,6 +6,7 @@
 #include <chrono>
 #include <iomanip>
 #include <sstream>
+#include "common/archives.h"
 #include "common/bit_field.h"
 #include "common/common_types.h"
 #include "common/logging/log.h"
@@ -16,6 +17,19 @@
 #include "core/hle/service/err_f.h"
 #undef exception_info
 
+SERIALIZE_EXPORT_IMPL(Service::ERR::ERR_F)
+
+namespace boost::serialization {
+    template <class Archive>
+    void load_construct_data(Archive& ar, Service::ERR::ERR_F* t, const unsigned int)
+    {
+        ::new(t)Service::ERR::ERR_F(Core::Global<Core::System>());
+    }
+
+    template
+    void load_construct_data<iarchive>(iarchive& ar, Service::ERR::ERR_F* t, const unsigned int);
+}
+
 namespace Service::ERR {
 
 enum class FatalErrType : u32 {
diff --git a/src/core/hle/service/err_f.h b/src/core/hle/service/err_f.h
index 4a1684caf..a3d0cf11e 100644
--- a/src/core/hle/service/err_f.h
+++ b/src/core/hle/service/err_f.h
@@ -34,8 +34,22 @@ private:
     void ThrowFatalError(Kernel::HLERequestContext& ctx);
 
     Core::System& system;
+
+    template <class Archive>
+    void serialize(Archive& ar, const unsigned int)
+    {
+        ar & boost::serialization::base_object<Kernel::SessionRequestHandler>(*this);
+    }
+    friend class boost::serialization::access;
 };
 
 void InstallInterfaces(Core::System& system);
 
 } // namespace Service::ERR
+
+BOOST_CLASS_EXPORT_KEY(Service::ERR::ERR_F)
+
+namespace boost::serialization {
+    template <class Archive>
+    void load_construct_data(Archive& ar, Service::ERR::ERR_F* t, const unsigned int);
+}