From e21b1eeab2b545d982a0c23ac3c98d0d4d8f0fb5 Mon Sep 17 00:00:00 2001 From: borntohonk <6264306+borntohonk@users.noreply.github.com> Date: Sun, 27 Oct 2024 10:57:15 +0100 Subject: [PATCH 1/5] :) --- .github/workflows/build-jobs.yaml | 31 ++++++++++++++++++------- .github/workflows/build.yml | 14 ------------ .github/workflows/release.yml | 38 ------------------------------- README.md | 14 ++++-------- overlay/src/main.cpp | 2 -- sysmod/src/main.cpp | 10 ++++---- 6 files changed, 32 insertions(+), 77 deletions(-) delete mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build-jobs.yaml b/.github/workflows/build-jobs.yaml index 9858275..b5e6ec9 100644 --- a/.github/workflows/build-jobs.yaml +++ b/.github/workflows/build-jobs.yaml @@ -2,24 +2,39 @@ name: Build jobs on: workflow_call: + workflow_dispatch: jobs: build: - name: build runs-on: ubuntu-latest - container: ghcr.io/pgalonza/devkita64-atmosphere:latest - #or you can use a generic one - #container: devkitpro/devkita64:latest + container: devkitpro/devkita64 steps: - name: Checkout uses: actions/checkout@v4 with: submodules: recursive + - name: Build sys-patch run: | - make dist -j $(nproc) - - name: Upload artifacts + make -j $(nproc) dist + VERSION=$(grep 'export VERSION := ' Makefile | cut -c 19-) + echo "VERSION=${VERSION}" >> $GITHUB_ENV + + - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: sys-patch-artifacts - path: ./sys-patch.zip + name: sys-patch-${{ env.VERSION }}.zip + path: out/ + + + - name: Fetch git cli and upload release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + wget -q $(curl -s https://api.github.com/repos/cli/cli/releases/latest | grep "browser_download_url" | grep "linux_amd64.tar.gz" | head -1 | cut -d '"' -f 4) && \ + tar -xzf gh*.tar.gz && \ + chmod +x gh*/bin/gh && \ + cp gh*/bin/gh /bin/gh && \ + rm gh*.tar.gz && \ + rm -rf gh* && \ + gh release create v${{ env.VERSION }} sys-patch.zip --title "Sys-patch version ${{ env.VERSION }}" --repo github.com/$GITHUB_REPOSITORY \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 6443090..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Build sys-patch - -on: - push: - branches: - - master - - feature-integration - paths-ignore: - - 'Dockerfile' - - '.github/workflows/image.yml' - -jobs: - build-workflow: - uses: ./.github/workflows/build-jobs.yaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index ce4f921..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Create release - -on: - push: - tags: - - '[0-9]+.[0-9]+.[0-9]+' - -permissions: - contents: write - -jobs: - build-workflow: - uses: ./.github/workflows/build-jobs.yaml - create-release: - runs-on: ubuntu-latest - needs: build-workflow - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Generate a changelog - uses: orhun/git-cliff-action@v3 - with: - config: ./configs/cliff.toml - args: --verbose - - name: Download artifact - uses: actions/download-artifact@v4 - with: - name: sys-patch-artifacts - path: "./" - - name: Create release - uses: ncipollo/release-action@v1 - with: - artifacts: "sys-patch.zip" - prerelease: false - name: "ns-sys-patch ${{ github.ref_name }}" - bodyFile: "git-cliff/CHANGELOG.md" diff --git a/README.md b/README.md index ad833ca..f1940d8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # sys-patch -A script-like system module that patches **fs**, **es**, **ldr** and **nifm** on boot. +A script-like system module that patches **fs**, **es**, **ldr**, **nifm** and **nim** on boot. --- @@ -57,14 +57,10 @@ To activate the sys-module, reboot your switch, or, use [sysmodules overlay](htt Here's a quick run down of what's being patched: -- **fs** -- **es** -- **ldr** -- **nifm** - -**fs** and **es** need new patches after every new firmware version. -**ldr** needs new patches after every new [Atmosphere](https://github.com/Atmosphere-NX/Atmosphere/) release. -**nifm** ctest patch allows the device to connect to a network without needing to make a connection to a server. +- **fs** and **es** need new patches after every new firmware version. +- **ldr** needs new patches after every new [Atmosphere](https://github.com/Atmosphere-NX/Atmosphere/) release. +- **nifm** ctest patch allows the device to connect to a network without needing to make a connection to a server +- **nim** patches to the ssl function call within nim that queries "https://api.hac.%.ctest.srv.nintendo.net/v1/time", and crashes the console if console ssl certificate is not intact. This patch instead makes the console not crash. The patches are applied on boot. Once done, the sys-module stops running. The memory footprint *(16kib)* and the binary size *(~50kib)* are both very small. diff --git a/overlay/src/main.cpp b/overlay/src/main.cpp index 46a1500..26ae815 100644 --- a/overlay/src/main.cpp +++ b/overlay/src/main.cpp @@ -103,7 +103,6 @@ class GuiToggle final : public tsl::Gui { list->addItem(config_noacidsigchk2.create_list_item("noacidsigchk2")); list->addItem(config_noncasigchk_old.create_list_item("noncasigchk_old")); list->addItem(config_noncasigchk_new.create_list_item("noncasigchk_new")); - list->addItem(config_noncasigchk_new2.create_list_item("noncasigchk_new2")); list->addItem(config_nocntchk.create_list_item("nocntchk")); list->addItem(config_nocntchk2.create_list_item("nocntchk2")); @@ -129,7 +128,6 @@ class GuiToggle final : public tsl::Gui { ConfigEntry config_noacidsigchk2{"fs", "noacidsigchk2", true}; ConfigEntry config_noncasigchk_old{"fs", "noncasigchk_old", true}; ConfigEntry config_noncasigchk_new{"fs", "noncasigchk_new", true}; - ConfigEntry config_noncasigchk_new2{"fs", "noncasigchk_new2", true}; ConfigEntry config_nocntchk{"fs", "nocntchk", true}; ConfigEntry config_nocntchk2{"fs", "nocntchk2", true}; ConfigEntry config_noacidsigchk{"ldr", "noacidsigchk", true}; diff --git a/sysmod/src/main.cpp b/sysmod/src/main.cpp index cce3ae3..595ae6d 100644 --- a/sysmod/src/main.cpp +++ b/sysmod/src/main.cpp @@ -250,11 +250,10 @@ constexpr auto ctest_applied(const u8* data, u32 inst) -> bool { constinit Patterns fs_patterns[] = { { "noacidsigchk1", "0xC8FE4739", -24, 0, bl_cond, ret0_patch, ret0_applied, true, FW_VER_ANY, MAKEHOSVERSION(9,2,0) }, { "noacidsigchk2", "0x0210911F000072", -5, 0, bl_cond, ret0_patch, ret0_applied, true, FW_VER_ANY, MAKEHOSVERSION(9,2,0) }, - { "noncasigchk_old", "0x1E42B9", -5, 0, tbz_cond, nop_patch, nop_applied, true, MAKEHOSVERSION(10,0,0), MAKEHOSVERSION(14,2,1) }, - { "noncasigchk_new", "0x3E4479", -5, 0, tbz_cond, nop_patch, nop_applied, true, MAKEHOSVERSION(15,0,0), MAKEHOSVERSION(16,1,0) }, - { "noncasigchk_new2", "0x258052", -5, 0, tbz_cond, nop_patch, nop_applied, true, MAKEHOSVERSION(17,0,0), FW_VER_ANY }, - { "nocntchk", "0x081C00121F050071..0054", -4, 0, bl_cond, ret0_patch, ret0_applied, true, MAKEHOSVERSION(10,0,0), MAKEHOSVERSION(18,1,0) }, - { "nocntchk2", "0x091C00123F05007161010054", -8, 0, bl_cond, ret0_patch, ret0_applied, true, MAKEHOSVERSION(19,0,0), FW_VER_ANY }, + { "noncasigchk_old", "0x0036.......71..0054..4839", -2, 0, tbz_cond, nop_patch, nop_applied, true, MAKEHOSVERSION(10,0,0), MAKEHOSVERSION(16,1,0) }, + { "noncasigchk_new", "0x.94..0036.258052", 2, 0, tbz_cond, nop_patch, nop_applied, true, MAKEHOSVERSION(17,0,0), FW_VER_ANY }, // 17.0.0 - 19.0.0+ + { "nocntchk", "0x40f9...9408.0012.050071", 2, 0, bl_cond, ret0_patch, ret0_applied, true, MAKEHOSVERSION(10,0,0), MAKEHOSVERSION(18,1,0) }, + { "nocntchk2", "0x40f9...94..40b9..0012", 2, 0, bl_cond, ret0_patch, ret0_applied, true, MAKEHOSVERSION(19,0,0), FW_VER_ANY }, }; constinit Patterns ldr_patterns[] = { @@ -273,7 +272,6 @@ constinit Patterns nifm_patterns[] = { constinit Patterns nim_patterns[] = { { "nim", "0x.0F00351F2003D5", 8, 0, adr_cond, mov2_patch, mov2_applied, true, MAKEHOSVERSION(17,0,0), FW_VER_ANY }, - // { "nim2", "0x600F00351F2003D5", 8, 0, adr_cond, mov2_patch, mov2_applied, true, MAKEHOSVERSION(19,0,0), FW_VER_ANY }, }; // NOTE: add system titles that you want to be patched to this table. From eea97eed5b347f8e5d833619d627681ede36ca00 Mon Sep 17 00:00:00 2001 From: borntohonk <6264306+borntohonk@users.noreply.github.com> Date: Wed, 30 Oct 2024 09:08:24 +0100 Subject: [PATCH 2/5] Workflow, README.MD --- .github/workflows/build-jobs.yaml | 53 ++++++++++++++++++------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build-jobs.yaml b/.github/workflows/build-jobs.yaml index b5e6ec9..6e2149e 100644 --- a/.github/workflows/build-jobs.yaml +++ b/.github/workflows/build-jobs.yaml @@ -3,38 +3,47 @@ name: Build jobs on: workflow_call: workflow_dispatch: + push: jobs: build: runs-on: ubuntu-latest container: devkitpro/devkita64 - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: recursive - - name: Build sys-patch - run: | - make -j $(nproc) dist - VERSION=$(grep 'export VERSION := ' Makefile | cut -c 19-) - echo "VERSION=${VERSION}" >> $GITHUB_ENV + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-tags: true + path: sys-patch + submodules: recursive - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: sys-patch-${{ env.VERSION }}.zip - path: out/ + - name: Build sys-patch + run: | + make -C sys-patch -j$(nproc) && \ + VERSION=$(grep 'export VERSION := ' sys-patch/Makefile | cut -c 19-) + TAGVERSION=$(curl -s https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest | grep "tag_name" | head -1 | cut -d '"' -f 4) + echo "VERSION=${VERSION}" >> $GITHUB_ENV + echo "TAGVERSION=${TAGVERSION}" >> $GITHUB_ENV + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: sys-patch-${{ env.VERSION }}.zip + path: sys-patch/out/ - - name: Fetch git cli and upload release - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | + - name: Fetch git cli and upload release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if [ ${{ env.TAGVERSION }} = v${{ env.VERSION }} ]; + then echo "Tag version and makefile version are same, don't publish release, only artifact uploaded." + else wget -q $(curl -s https://api.github.com/repos/cli/cli/releases/latest | grep "browser_download_url" | grep "linux_amd64.tar.gz" | head -1 | cut -d '"' -f 4) && \ tar -xzf gh*.tar.gz && \ chmod +x gh*/bin/gh && \ - cp gh*/bin/gh /bin/gh && \ + chmod +x gh*/bin/gh && \ rm gh*.tar.gz && \ - rm -rf gh* && \ - gh release create v${{ env.VERSION }} sys-patch.zip --title "Sys-patch version ${{ env.VERSION }}" --repo github.com/$GITHUB_REPOSITORY \ No newline at end of file + rm -rf gh* + gh release create v${{ env.VERSION }} sys-patch.zip --title "Sys-patch version ${{ env.VERSION }}" --repo github.com/$GITHUB_REPOSITORY + fi From 4525f482b1e87f6d3701e86c92e765f18714c2f4 Mon Sep 17 00:00:00 2001 From: borntohonk <6264306+borntohonk@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:57:07 +0100 Subject: [PATCH 3/5] Ensure overlay files are added to artifact --- .github/workflows/build-jobs.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-jobs.yaml b/.github/workflows/build-jobs.yaml index 6e2149e..17f24dc 100644 --- a/.github/workflows/build-jobs.yaml +++ b/.github/workflows/build-jobs.yaml @@ -29,6 +29,8 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: + include-hidden-files: true + overwrite: true name: sys-patch-${{ env.VERSION }}.zip path: sys-patch/out/ From a1d76f8a26d6dda36653506b0bf7ebf8e9046644 Mon Sep 17 00:00:00 2001 From: lsp199308 <77911322+lsp199308@users.noreply.github.com> Date: Mon, 4 Nov 2024 00:19:09 +0800 Subject: [PATCH 4/5] Update main.cpp --- sysmod/src/main.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sysmod/src/main.cpp b/sysmod/src/main.cpp index 595ae6d..4151d6b 100644 --- a/sysmod/src/main.cpp +++ b/sysmod/src/main.cpp @@ -248,12 +248,15 @@ constexpr auto ctest_applied(const u8* data, u32 inst) -> bool { } constinit Patterns fs_patterns[] = { - { "noacidsigchk1", "0xC8FE4739", -24, 0, bl_cond, ret0_patch, ret0_applied, true, FW_VER_ANY, MAKEHOSVERSION(9,2,0) }, - { "noacidsigchk2", "0x0210911F000072", -5, 0, bl_cond, ret0_patch, ret0_applied, true, FW_VER_ANY, MAKEHOSVERSION(9,2,0) }, - { "noncasigchk_old", "0x0036.......71..0054..4839", -2, 0, tbz_cond, nop_patch, nop_applied, true, MAKEHOSVERSION(10,0,0), MAKEHOSVERSION(16,1,0) }, - { "noncasigchk_new", "0x.94..0036.258052", 2, 0, tbz_cond, nop_patch, nop_applied, true, MAKEHOSVERSION(17,0,0), FW_VER_ANY }, // 17.0.0 - 19.0.0+ - { "nocntchk", "0x40f9...9408.0012.050071", 2, 0, bl_cond, ret0_patch, ret0_applied, true, MAKEHOSVERSION(10,0,0), MAKEHOSVERSION(18,1,0) }, - { "nocntchk2", "0x40f9...94..40b9..0012", 2, 0, bl_cond, ret0_patch, ret0_applied, true, MAKEHOSVERSION(19,0,0), FW_VER_ANY }, + { "1-9A", "0x........0036..00b4..40b9", 2, 0, bl_cond, ret0_patch, ret0_applied, true, MAKEHOSVERSION(1,0,0), MAKEHOSVERSION(9,2,0) }, + { "1-9B", "0x....0094.0210911f000072", 2, 0, bl_cond, ret0_patch, ret0_applied, true, MAKEHOSVERSION(1,0,0), MAKEHOSVERSION(9,2,0) }, + { "1-9C", "0x.40f9...94081c00121f050071", 2, 0, bl_cond, ret0_patch, ret0_applied, true, MAKEHOSVERSION(1,0,0), MAKEHOSVERSION(9,2,0) }, + { "10-18A", "0x40f9...9408.0012.050071", 2, 0, bl_cond, ret0_patch, ret0_applied, true, MAKEHOSVERSION(10,0,0), MAKEHOSVERSION(18,1,0) }, + { "19A", "0x40f9...94..40b9..0012", 2, 0, bl_cond, ret0_patch, ret0_applied, true, MAKEHOSVERSION(19,0,0) }, + + { "1-9D", "0x.97..0036881e42b9", 2, 0, tbz_cond, nop_patch, nop_applied, true, MAKEHOSVERSION(1,0,0), MAKEHOSVERSION(9,2,0) }, + { "10-16D", "0x0036.......71..0054..4839", -2, 0, tbz_cond, nop_patch, nop_applied, true, MAKEHOSVERSION(10,0,0), MAKEHOSVERSION(16,1,0) }, + { "17-19D", "0x.94..0036.258052", 2, 0, tbz_cond, nop_patch, nop_applied, true, MAKEHOSVERSION(17,0,0), FW_VER_ANY },//fw17-fw19 }; constinit Patterns ldr_patterns[] = { From 8e7822bdf300caa78124f0e64d65994f3c0b54ac Mon Sep 17 00:00:00 2001 From: lsp199308 <77911322+lsp199308@users.noreply.github.com> Date: Mon, 4 Nov 2024 00:21:09 +0800 Subject: [PATCH 5/5] Update main.cpp --- overlay/src/main.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/overlay/src/main.cpp b/overlay/src/main.cpp index 26ae815..920b1c9 100644 --- a/overlay/src/main.cpp +++ b/overlay/src/main.cpp @@ -99,12 +99,14 @@ class GuiToggle final : public tsl::Gui { auto list = new tsl::elm::List(); list->addItem(new tsl::elm::CategoryHeader("FS - 0100000000000000")); - list->addItem(config_noacidsigchk1.create_list_item("noacidsigchk1")); - list->addItem(config_noacidsigchk2.create_list_item("noacidsigchk2")); - list->addItem(config_noncasigchk_old.create_list_item("noncasigchk_old")); - list->addItem(config_noncasigchk_new.create_list_item("noncasigchk_new")); - list->addItem(config_nocntchk.create_list_item("nocntchk")); - list->addItem(config_nocntchk2.create_list_item("nocntchk2")); + list->addItem(config_1_9A.create_list_item("1_9A")); + list->addItem(config_1_9B.create_list_item("1_9B")); + list->addItem(config_1_9C.create_list_item("1_9C")); + list->addItem(config_10_18A.create_list_item("10_18A")); + list->addItem(config_19A.create_list_item("19A")); + list->addItem(config_1_9D.create_list_item("1_9D")); + list->addItem(config_10_16D.create_list_item("10_16D")); + list->addItem(config_17_19D.create_list_item("17_19D")); list->addItem(new tsl::elm::CategoryHeader("LDR - 0100000000000001")); list->addItem(config_noacidsigchk.create_list_item("noacidsigchk")); @@ -124,12 +126,14 @@ class GuiToggle final : public tsl::Gui { return frame; } - ConfigEntry config_noacidsigchk1{"fs", "noacidsigchk1", true}; - ConfigEntry config_noacidsigchk2{"fs", "noacidsigchk2", true}; - ConfigEntry config_noncasigchk_old{"fs", "noncasigchk_old", true}; - ConfigEntry config_noncasigchk_new{"fs", "noncasigchk_new", true}; - ConfigEntry config_nocntchk{"fs", "nocntchk", true}; - ConfigEntry config_nocntchk2{"fs", "nocntchk2", true}; + ConfigEntry config_1_9A{"fs", "1_9A", true}; + ConfigEntry config_1_9B{"fs", "1_9B", true}; + ConfigEntry config_1_9C{"fs", "1_9C", true}; + ConfigEntry config_10_18A{"fs", "10_18A", true}; + ConfigEntry config_19A{"fs", "19A", true}; + ConfigEntry config_1_9D{"fs", "1_9D", true}; + ConfigEntry config_10_16D{"fs", "10_16D", true}; + ConfigEntry config_17_19D{"fs", "17_19D", true};; ConfigEntry config_noacidsigchk{"ldr", "noacidsigchk", true}; ConfigEntry config_es1{"es", "es1", true}; ConfigEntry config_es2{"es", "es2", true};