Skip to content

Commit

Permalink
- add new hax for FW > 10.3
Browse files Browse the repository at this point in the history
- downgrade browser and homemenu last (but before native_firm)
- few bug fix and improvements
  • Loading branch information
Cpasjuste committed Mar 10, 2016
1 parent 665fbff commit 7b13bc4
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
@@ -1,3 +1,6 @@
[submodule "source/SuperUserLib3DS"]
path = source/SuperUserLib3DS
url = https://github.com/delebile/SuperUserLib3DS
[submodule "source/svchax"]
path = source/svchax
url = https://github.com/aliaspider/svchax.git
10 changes: 9 additions & 1 deletion CMakeLists.txt
Expand Up @@ -14,8 +14,16 @@ include(Tools3DS) # Include all the macros and tools needed for 3ds development.
find_package(CTRULIB REQUIRED) # Look for ctrulib

file(GLOB_RECURSE SOURCE_FILES
source/*
source/*
)
file(GLOB FILTER_FILES
source/SuperUserLib3DS/demo/source/*
source/svchax/test.c
)
list(REMOVE_ITEM SOURCE_FILES
${FILTER_FILES}
)

add_executable(SafeSysUpdater ${SOURCE_FILES}) # Create the elf file

target_link_libraries(SafeSysUpdater ${LIBCTRU_LIBRARIES}) # Link ctrulib
Expand Down
6 changes: 3 additions & 3 deletions source/Main.cpp
Expand Up @@ -168,6 +168,8 @@ void downgrade() {
quit();
}

std::sort(titlesToInstall.begin(), titlesToInstall.end(), Utility::sortTitles);

// downgrade !
debug->printr("\n-> DOWNGRADING <-\n\n");
for (auto it : titlesToInstall) {
Expand Down Expand Up @@ -221,16 +223,14 @@ int main(int argc, char *argv[]) {
}

consoleClear();
printf("HAX INIT...\n");

if (mode > MODE_TITLES_CHECK) { // needs AM
gfxExit();
if (Utility::getAMu() != 0) {
_gfxInit();
debug->printr("FAIL\n");
debug->printr("Can't get am:u service ... try again :x\n");
quit();
}
_gfxInit();
debug->printg("HAX SUCCESS\n");
}

Expand Down
84 changes: 68 additions & 16 deletions source/Utility.cpp
Expand Up @@ -11,27 +11,67 @@
#define BUFSIZE 131072
static FS_Archive sdmcArchive;

extern void _gfxInit();
extern u8 isNew3DS;
extern "C" {
void patchServiceAccess();
void svchax_init();
}

static const u32 titleTypes[7] = {
0x00040138, // System Firmware
0x00040130, // System Modules
0x00040030, // Applets
0x00040010, // System Applications
0x0004001B, // System Data Archives
0x0004009B, // System Data Archives (Shared Archives)
0x000400DB, // System Data Archives
0x00040138, // System Firmware
0x00040130, // System Modules
0x00040030, // Applets
0x00040010, // System Applications
0x0004001B, // System Data Archives
0x0004009B, // System Data Archives (Shared Archives)
0x000400DB, // System Data Archives
};

static const u64 titleHomeMenu[3] = {
0x0004003000008F02, // USA Home Menu
0x0004003000009802, // EUR Home Menu
0x0004003000008202, // JPN Home Menu
};

static const u64 titleBrowser[6] = {
0x0004003020009402, // USA New3DS Internet Browser
0x0004003020009D02, // EUR New3DS Internet Browser
0x0004003020008802, // JPN New3DS Internet Browser
0x0004003000009402, // USA Internet Browser
0x0004003000009D02, // EUR Internet Browser
0x0004003000008802, // JPN Internet Browser
};

static u32 getTitlePriority(u64 id) {
u32 Utility::getTitlePriority(u64 id) {

// nfirm last
if( id == 0x0004013800000002LL
|| id == 0x0004013820000002LL) {
return 0;
}

// downgrade browser and homemenu last
for (u32 i = 0; i < 6; i++) {
if (id == titleBrowser[i]) {
return 2;
}
}
for (u32 i = 0; i < 3; i++) {
if (id == titleHomeMenu[i]) {
return 1;
}
}
u32 type = (u32) (id >> 32);
for (u32 i = 0; i < 7; i++) {
if (type == titleTypes[i]) {
return i;
return i+3;
}
}
return 0;
}

static bool sortTitles(const TitleInfo &a, const TitleInfo &b) {
bool Utility::sortTitles(const TitleInfo &a, const TitleInfo &b) {
bool aSafe = (a.titleID & 0xFF) == 0x03;
bool bSafe = (b.titleID & 0xFF) == 0x03;
if (aSafe != bSafe) {
Expand Down Expand Up @@ -189,14 +229,26 @@ int Utility::getAMu() {
}

// try to get arm11
if (suInit() == 0) {
// verify am:u access
srvGetServiceHandleDirect(&amHandle, "am:u");
if (amHandle) {
svcCloseHandle(amHandle);
return 0;
if(osGetKernelVersion() > SYSTEM_VERSION(2,50,9)) {
svchax_init();
aptInit();
APT_CheckNew3DS(&isNew3DS);
patchServiceAccess();
} else {
gfxExit();
if (suInit() != 0) {
_gfxInit();
return 1;
}
_gfxInit();
}

srvGetServiceHandleDirect(&amHandle, "am:u");
if (amHandle) {
svcCloseHandle(amHandle);
return 0;
}

return 1;
}

Expand Down
4 changes: 4 additions & 0 deletions source/Utility.h
Expand Up @@ -29,6 +29,10 @@ class Utility {

static bool installTitle(std::string path);

static u32 getTitlePriority(u64 id);

static bool sortTitles(const TitleInfo &a, const TitleInfo &b);

static int cmp(std::vector<TitleInfo> &installedTitles, u64 &titleID, u16 version);

static int version(std::vector<TitleInfo> &titles, u64 &titleID);
Expand Down
1 change: 1 addition & 0 deletions source/svchax
Submodule svchax added at 40d050

0 comments on commit 7b13bc4

Please sign in to comment.