mirror of
https://github.com/LNH-team/pico-loader.git
synced 2026-06-02 09:16:49 +02:00
Initial work on homebrew return to loader
This commit is contained in:
@@ -95,3 +95,8 @@ bool dldi_patchTo(dldi_header_t* stub)
|
||||
{
|
||||
return sDldiDriver.PatchTo(stub);
|
||||
}
|
||||
|
||||
void dldi_copyTo(void* target)
|
||||
{
|
||||
memcpy(target, sDldiBuffer, sizeof(sDldiBuffer));
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
bool dldi_init();
|
||||
bool dldi_patchTo(dldi_header_t* stub);
|
||||
void dldi_copyTo(void* target);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -10,5 +10,6 @@ extern u8 __bss_size[];
|
||||
pload_header7_t gLoaderHeader
|
||||
{
|
||||
.entryPoint = (void*)&_start,
|
||||
.apiVersion = PICO_LOADER_API_VERSION
|
||||
.apiVersion = PICO_LOADER_API_VERSION,
|
||||
.launcherPath = "/_picoboot.nds"
|
||||
};
|
||||
@@ -344,6 +344,7 @@ void NdsLoader::Load(BootMode bootMode)
|
||||
if (isHomebrew)
|
||||
{
|
||||
InsertArgv();
|
||||
HandleHomebrewPatching();
|
||||
}
|
||||
|
||||
HandleDldiPatching();
|
||||
@@ -429,6 +430,22 @@ void NdsLoader::InsertArgv()
|
||||
HOMEBREW_ARGV->length = argSize;
|
||||
}
|
||||
|
||||
void NdsLoader::HandleHomebrewPatching()
|
||||
{
|
||||
sendToArm9(IPC_COMMAND_ARM9_APPLY_HOMEBREW_PATCHES);
|
||||
sendToArm9(16 * 1024); // required dldi space
|
||||
void* dldiSpace = (void*)receiveFromArm9();
|
||||
char* launcherPath = (char*)receiveFromArm9();
|
||||
if (dldiSpace != nullptr)
|
||||
{
|
||||
dldi_copyTo(dldiSpace);
|
||||
}
|
||||
if (launcherPath != nullptr)
|
||||
{
|
||||
strncpy(launcherPath, _launcherPath, 256);
|
||||
}
|
||||
}
|
||||
|
||||
void NdsLoader::ApplyArm7Patches()
|
||||
{
|
||||
sendToArm9(IPC_COMMAND_ARM9_APPLY_ARM7_PATCHES);
|
||||
|
||||
@@ -26,6 +26,13 @@ public:
|
||||
_savePath = savePath;
|
||||
}
|
||||
|
||||
/// @brief Sets the \p launcherPath to use.
|
||||
/// @param launcherPath The launcher path to use.
|
||||
void SetLauncherPath(const TCHAR* launcherPath)
|
||||
{
|
||||
_launcherPath = launcherPath;
|
||||
}
|
||||
|
||||
/// @brief Sets the argv arguments to pass to the rom.
|
||||
/// @param arguments The argv arguments.
|
||||
/// @param argumentsLength The length of the argv arguments.
|
||||
@@ -41,8 +48,9 @@ public:
|
||||
|
||||
private:
|
||||
FIL _romFile;
|
||||
const TCHAR* _romPath;
|
||||
const TCHAR* _savePath;
|
||||
const TCHAR* _romPath = nullptr;
|
||||
const TCHAR* _savePath = nullptr;
|
||||
const TCHAR* _launcherPath = nullptr;
|
||||
u32 _argumentsLength = 0;
|
||||
const char* _arguments = nullptr;
|
||||
nds_header_twl_t _romHeader;
|
||||
@@ -71,6 +79,7 @@ private:
|
||||
char driveLetter, const char* deviceName, const char* path, u8 flags, u8 accessRights);
|
||||
void SetupDsiDeviceList();
|
||||
void InsertArgv();
|
||||
void HandleHomebrewPatching();
|
||||
bool TrySetupDsiWareSave();
|
||||
bool TryDecryptSecureArea();
|
||||
ConsoleRegion GetRomRegion(u32 gameCode);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#pragma once
|
||||
#include "common.h"
|
||||
|
||||
#define DLDI_MAGIC 0xBF8DA5ED
|
||||
#define DLDI_DRIVER_MAGIC_NONE 0x49444C44
|
||||
|
||||
@@ -222,6 +222,7 @@ extern "C" void loaderMain()
|
||||
sLoader.SetRomPath(gLoaderHeader.loadParams.romPath);
|
||||
handleSavePath();
|
||||
sLoader.SetArguments(gLoaderHeader.loadParams.arguments, gLoaderHeader.loadParams.argumentsLength);
|
||||
sLoader.SetLauncherPath(gLoaderHeader.launcherPath);
|
||||
sLoader.Load(BootMode::Normal);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user