From 306739c2c479b646270f7cd8000bb11483613d50 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sun, 30 Sep 2018 18:13:22 -0400 Subject: ips_layer: Add IPSwitchCompiler to process IPSwitch format --- src/core/file_sys/ips_layer.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/core/file_sys/ips_layer.h') diff --git a/src/core/file_sys/ips_layer.h b/src/core/file_sys/ips_layer.h index 81c163494..bb35542c8 100644 --- a/src/core/file_sys/ips_layer.h +++ b/src/core/file_sys/ips_layer.h @@ -12,4 +12,30 @@ namespace FileSys { VirtualFile PatchIPS(const VirtualFile& in, const VirtualFile& ips); +class IPSwitchCompiler { +public: + explicit IPSwitchCompiler(VirtualFile patch_text); + std::array GetBuildID() const; + bool IsValid() const; + VirtualFile Apply(const VirtualFile& in) const; + +private: + void Parse(); + + bool valid; + + struct IPSwitchPatch { + std::string name; + bool enabled; + std::map> records; + }; + + VirtualFile patch_text; + std::vector patches; + std::array nso_build_id; + bool is_little_endian; + u64 offset_shift; + bool print_values; +}; + } // namespace FileSys -- cgit v1.2.3 From 9669cdb710e3242b7c0b705ea613587d36f79e00 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Mon, 1 Oct 2018 08:31:34 -0400 Subject: ips_layer: Add support for escape sequences and midline comments More accurately follows IPSwitch specification. --- src/core/file_sys/ips_layer.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/core/file_sys/ips_layer.h') diff --git a/src/core/file_sys/ips_layer.h b/src/core/file_sys/ips_layer.h index bb35542c8..847e9bf3c 100644 --- a/src/core/file_sys/ips_layer.h +++ b/src/core/file_sys/ips_layer.h @@ -34,8 +34,9 @@ private: std::vector patches; std::array nso_build_id; bool is_little_endian; - u64 offset_shift; + s64 offset_shift; bool print_values; + std::string last_comment; }; } // namespace FileSys -- cgit v1.2.3 From 70bd2bb1d3aec23fc052c9612f9e530c1a2de72d Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Mon, 1 Oct 2018 17:17:08 -0400 Subject: ips_layer: Deduplicate resource usage --- src/core/file_sys/ips_layer.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/core/file_sys/ips_layer.h') diff --git a/src/core/file_sys/ips_layer.h b/src/core/file_sys/ips_layer.h index 847e9bf3c..b07cc5673 100644 --- a/src/core/file_sys/ips_layer.h +++ b/src/core/file_sys/ips_layer.h @@ -15,6 +15,8 @@ VirtualFile PatchIPS(const VirtualFile& in, const VirtualFile& ips); class IPSwitchCompiler { public: explicit IPSwitchCompiler(VirtualFile patch_text); + ~IPSwitchCompiler(); + std::array GetBuildID() const; bool IsValid() const; VirtualFile Apply(const VirtualFile& in) const; @@ -22,7 +24,7 @@ public: private: void Parse(); - bool valid; + bool valid = false; struct IPSwitchPatch { std::string name; @@ -32,11 +34,11 @@ private: VirtualFile patch_text; std::vector patches; - std::array nso_build_id; - bool is_little_endian; - s64 offset_shift; - bool print_values; - std::string last_comment; + std::array nso_build_id{}; + bool is_little_endian = false; + s64 offset_shift = 0; + bool print_values = false; + std::string last_comment = ""; }; } // namespace FileSys -- cgit v1.2.3 From 110d5784702282c594fe57f84f8d6bda21a82d50 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Thu, 4 Oct 2018 12:23:18 -0400 Subject: ips_layer: Fix inaccuracies with comments and flags Specifically bugs/crashes that arise when putting them in positions that are legal but not typical, such as midline, between patch data, or between patch records. --- src/core/file_sys/ips_layer.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core/file_sys/ips_layer.h') diff --git a/src/core/file_sys/ips_layer.h b/src/core/file_sys/ips_layer.h index b07cc5673..57da00da8 100644 --- a/src/core/file_sys/ips_layer.h +++ b/src/core/file_sys/ips_layer.h @@ -22,6 +22,7 @@ public: VirtualFile Apply(const VirtualFile& in) const; private: + void ParseFlag(const std::string& flag); void Parse(); bool valid = false; -- cgit v1.2.3