Skip to content

Commit

Permalink
load elf on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
bucanero committed Dec 6, 2024
1 parent 5c8fb36 commit f371a29
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ target_link_libraries(${PROJECT_NAME}
zip
lzma
mc
elf-loader
# un7zip
ahx
z
Expand Down
26 changes: 26 additions & 0 deletions source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <sifrpc.h>
#include <loadfile.h>
#include <libmc.h>
#include <elf-loader.h>
#include <sbv_patches.h>

#include "saves.h"
#include "utils.h"
Expand Down Expand Up @@ -371,11 +373,35 @@ static void registerSpecialChars(void)
RegisterSpecialCharacter(CHAR_TRP_SYNC, 0, 1.2f, &menu_textures[trp_sync_png_index]);
}

static void check_boot(const char* bootpath)
{
if (file_exists(bootpath) == SUCCESS)
{
LOG("Launching BOOT.ELF from %s", bootpath);
LoadELFFromFile(bootpath, 0, NULL);
}
}

static void terminate(void)
{
char bootpath[28] = "mc0:/BADATA-SYSTEM/BOOT.ELF";
char region[4] = {'A', 'E', 'I', 'C'};

LOG("Exiting...");

AHX_Quit();
sbv_patch_disable_prefix_check();

for (int i = 0; i < 4; i++)
{
bootpath[6] = region[i];
check_boot(bootpath);
}

check_boot("mc0:/BOOT/BOOT.ELF");
check_boot("mc1:/BOOT/BOOT.ELF");
check_boot("mc0:/MATRIXTEAM/MANAGER.ELF");
check_boot("mass:/BOOT/BOOT.ELF");
}

static int initInternal(void)
Expand Down

0 comments on commit f371a29

Please sign in to comment.