PabloMK7 c055fb6f5e
Merge 3GX plugin loader fork (#1916)
This commit adds all the changes made to the 3GX plugin loader fork of Luma3DS. The most important features are:

- Add 3GX plugin loader support. New service added to rosalina: plg:ldr
- Add svcControlProcess, svcControlMemoryUnsafe and improve svcMapProcessMemoryEx (breaking change)
- Allow applications to override certain configurations depending on their needs:
    - Disable core2 thread redirection
    - Disable game patching for the next app
    - Force New 3DS speedup
    - Force next application in a specific memory mode
    - Block the opening of the Rosalina menu
- Add GDB commands to list all process handles and catch all SVC (latter is for IDA Pro as gdb client supports it)
- Other changes necessary for plugins to work properly. Please check changed files in this PR for more details. 

---------

Co-authored-by: PabloMK7 <hackyglitch@gmail.com>
Co-authored-by: Nanquitas <nath.doidi@gmail.com>
Co-authored-by: TuxSH <1922548+TuxSH@users.noreply.github.com>
2023-07-14 20:08:07 +02:00

76 lines
2.1 KiB
C

#pragma once
#include <3ds/types.h>
#include "ifile.h"
#define _3GX_MAGIC (0x3230303024584733) /* "3GX$0002" */
typedef struct PACKED
{
u32 authorLen;
const char* authorMsg;
u32 titleLen;
const char* titleMsg;
u32 summaryLen;
const char* summaryMsg;
u32 descriptionLen;
const char* descriptionMsg;
union {
u32 flags;
struct {
u32 embeddedExeLoadFunc : 1;
u32 embeddedSwapSaveLoadFunc : 1;
u32 memoryRegionSize : 2;
u32 unused : 28;
};
};
u32 exeLoadChecksum;
u32 builtInLoadExeArgs[4];
u32 builtInSwapSaveLoadArgs[4];
} _3gx_Infos;
typedef struct PACKED
{
u32 count;
u32 * titles;
} _3gx_Targets;
typedef struct PACKED
{
u32 nbSymbols;
u32 symbolsOffset;
u32 nameTableOffset;
} _3gx_Symtable;
typedef struct PACKED
{
u32 codeOffset;
u32 rodataOffset;
u32 dataOffset;
u32 codeSize;
u32 rodataSize;
u32 dataSize;
u32 bssSize;
u32 exeLoadFuncOffset; // NOP terminated
u32 swapSaveFuncOffset; // NOP terminated
u32 swapLoadFuncOffset; // NOP terminated
} _3gx_Executable;
typedef struct PACKED
{
u64 magic;
u32 version;
u32 reserved;
_3gx_Infos infos;
_3gx_Executable executable;
_3gx_Targets targets;
_3gx_Symtable symtable;
} _3gx_Header;
Result Check_3gx_Magic(IFile *file);
Result Read_3gx_Header(IFile *file, _3gx_Header *header);
Result Read_3gx_ParseHeader(IFile *file, _3gx_Header *header);
Result Read_3gx_LoadSegments(IFile *file, _3gx_Header *header, void *dst);
Result Read_3gx_EmbeddedPayloads(IFile *file, _3gx_Header *header);
Result Set_3gx_LoadParams(u32* loadFunc, u32* params);
void Reset_3gx_LoadParams(void);