Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ MAKEFILES := sysmod overlay
TARGETS := $(foreach dir,$(MAKEFILES),$(CURDIR)/$(dir))

# the below was taken from atmosphere + switch-examples makefile
export VERSION := 1.5.7
export VERSION := 1.5.6

ifneq ($(strip $(shell git symbolic-ref --short HEAD 2>/dev/null)),)
export GIT_BRANCH := $(shell git symbolic-ref --short HEAD)
Expand Down
9 changes: 2 additions & 7 deletions overlay/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ class GuiToggle final : public tsl::Gui {
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_old2.create_list_item("noncasigchk_old2"));
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"));
Expand All @@ -120,9 +119,7 @@ class GuiToggle final : public tsl::Gui {
list->addItem(config_ctest2.create_list_item("ctest2"));

list->addItem(new tsl::elm::CategoryHeader("NIM - 0100000000000025"));
list->addItem(config_nim.create_list_item("nim_old"));
list->addItem(config_nim.create_list_item("nim_new"));

list->addItem(config_nim.create_list_item("nim"));

list->addItem(new tsl::elm::CategoryHeader("Disable CA Verification - apply all"));
list->addItem(config_ssl1.create_list_item("disablecaverification1"));
Expand All @@ -136,7 +133,6 @@ class GuiToggle final : public tsl::Gui {
ConfigEntry config_noacidsigchk1{"fs", "noacidsigchk1", true};
ConfigEntry config_noacidsigchk2{"fs", "noacidsigchk2", true};
ConfigEntry config_noncasigchk_old{"fs", "noncasigchk_old", true};
ConfigEntry config_noncasigchk_old2{"fs", "noncasigchk_old2", true};
ConfigEntry config_noncasigchk_new{"fs", "noncasigchk_new", true};
ConfigEntry config_nocntchk{"fs", "nocntchk", true};
ConfigEntry config_nocntchk2{"fs", "nocntchk2", true};
Expand All @@ -146,8 +142,7 @@ class GuiToggle final : public tsl::Gui {
ConfigEntry config_es3{"es", "es3", true};
ConfigEntry config_ctest{"nifm", "ctest", true};
ConfigEntry config_ctest2{"nifm", "ctest2", true};
ConfigEntry config_nim{"nim_old", "nim_old", true};
ConfigEntry config_nim{"nim_new", "nim_new", true};
ConfigEntry config_nim{"nim", "nim", true};
ConfigEntry config_ssl1{"ssl", "disablecaverification1", false};
ConfigEntry config_ssl2{"ssl", "disablecaverification2", false};
ConfigEntry config_ssl3{"ssl", "disablecaverification3", false};
Expand Down
37 changes: 25 additions & 12 deletions sysmod/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,18 @@ struct PatchEntry {
const u32 max_fw_ver{FW_VER_ANY}; // set to FW_VER_ANY to ignore
};

constexpr auto subi_cond(u32 inst) -> bool {
// # Used on Atmosphère-NX 0.11.0 - 0.12.0.
const auto type = (inst >> 24) & 0xFF;
const auto imm = (inst >> 10) & 0xFFF;
return (type == 0x71) && (imm == 0x0A);
}

constexpr auto cmp_cond(u32 inst) -> bool {
const auto type = inst >> 24;
return type == 0x6B; // cmp w0, w1
constexpr auto subr_cond(u32 inst) -> bool {
// # Used on Atmosphère-NX 0.13.0 and later.
const auto type = (inst >> 21) & 0x7F9;
const auto reg = (inst >> 16) & 0x1F;
return (type == 0x358) && (reg == 0x01);
}

constexpr auto bl_cond(u32 inst) -> bool {
Expand All @@ -141,6 +149,10 @@ constexpr auto tbz_cond(u32 inst) -> bool {
return ((inst >> 24) & 0x7F) == 0x36;
}

constexpr auto subs_cond(u32 inst) -> bool {
return subi_cond(inst) || subr_cond(inst);
}

constexpr auto cbz_cond(u32 inst) -> bool {
const auto type = inst >> 24;
return type == 0x34 || type == 0xB4;
Expand Down Expand Up @@ -201,17 +213,16 @@ constexpr PatchData nop_patch_data{ "0x1F2003D5" };
constexpr PatchData mov0_patch_data{ "0xE0031FAA" };
//mov x2, xzr
constexpr PatchData mov2_patch_data{ "0xE2031FAA" };
constexpr PatchData cmp_patch_data{ "0x00" };
constexpr PatchData ssl1_patch_data{ "0x0A" };
constexpr PatchData ssl2_patch_data{ "0x08008052" };
constexpr PatchData ctest_patch_data{ "0x00309AD2001EA1F2610100D4E0031FAAC0035FD6" };

constexpr auto ret0_patch(u32 inst) -> PatchData { return ret0_patch_data; }
constexpr auto ret1_patch(u32 inst) -> PatchData { return ret1_patch_data; }
constexpr auto nop_patch(u32 inst) -> PatchData { return nop_patch_data; }
constexpr auto subs_patch(u32 inst) -> PatchData { return subi_cond(inst) ? (u8)0x1 : (u8)0x0; }
constexpr auto mov0_patch(u32 inst) -> PatchData { return mov0_patch_data; }
constexpr auto mov2_patch(u32 inst) -> PatchData { return mov2_patch_data; }
constexpr auto cmp_patch(u32 inst) -> PatchData { return cmp_patch_data; }
constexpr auto ssl1_patch(u32 inst) -> PatchData { return ssl1_patch_data; }
constexpr auto ssl2_patch(u32 inst) -> PatchData { return ssl2_patch_data; }
constexpr auto ctest_patch(u32 inst) -> PatchData { return ctest_patch_data; }
Expand All @@ -234,8 +245,12 @@ constexpr auto nop_applied(const u8* data, u32 inst) -> bool {
return nop_patch(inst).cmp(data);
}

constexpr auto cmp_applied(const u8* data, u32 inst) -> bool {
return cmp_patch(inst).cmp(data);
constexpr auto subs_applied(const u8* data, u32 inst) -> bool {
const auto type_i = (inst >> 24) & 0xFF;
const auto imm = (inst >> 10) & 0xFFF;
const auto type_r = (inst >> 21) & 0x7F9;
const auto reg = (inst >> 16) & 0x1F;
return ((type_i == 0x71) && (imm == 0x1)) || ((type_r == 0x358) && (reg == 0x0));
}

constexpr auto b_applied(const u8* data, u32 inst) -> bool {
Expand Down Expand Up @@ -266,14 +281,13 @@ 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_old2", "0x.94..0036.258052", 2, 0, tbz_cond, nop_patch, nop_applied, true, MAKEHOSVERSION(17,0,0), MAKEHOSVERSION(20,5,0) }, // 17.0.0 - 20.5.0
{ "noncasigchk_new", "0x.94..0036.........258052", 2, 0, tbz_cond, nop_patch, nop_applied, true, MAKEHOSVERSION(21,0,0), FW_VER_ANY }, // 21.0.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[] = {
{ "noacidsigchk", "17..009401C0BE121F00", 9, 2, cmp_cond, cmp_patch, cmp_applied, true, FW_VER_ANY }, // 1F00016B - cmp w0, w1 patched to 1F00006B - cmp w0, w0
{ "noacidsigchk", "0xFD7B.A8C0035FD6", 16, 2, subs_cond, subs_patch, subs_applied, true, FW_VER_ANY },
};

constinit Patterns es_patterns[] = {
Expand All @@ -288,8 +302,7 @@ constinit Patterns nifm_patterns[] = {
};

constinit Patterns nim_patterns[] = {
{ "nim_old", "0x.0F00351F2003D5", 8, 0, adr_cond, mov2_patch, mov2_applied, true, MAKEHOSVERSION(17,0,0), MAKEHOSVERSION(20,5,0) },
{ "nim_new", "0x.0700351F2003D5", 8, 0, adr_cond, mov2_patch, mov2_applied, true, MAKEHOSVERSION(21,0,0), FW_VER_ANY },
{ "nim", "0x.0F00351F2003D5", 8, 0, adr_cond, mov2_patch, mov2_applied, true, MAKEHOSVERSION(17,0,0), FW_VER_ANY },
};

constinit Patterns ssl_patterns[] = {
Expand Down