├── .gitattributes ├── keyfont ├── A.bmp ├── B.bmp ├── L.bmp ├── R.bmp ├── X.bmp ├── Y.bmp ├── ZL.bmp ├── ZR.bmp ├── up.bmp ├── Select.bmp ├── Start.bmp ├── down.bmp ├── error.bmp ├── left.bmp ├── right.bmp ├── cpad-up.bmp ├── keyicon.psd ├── touchpad.bmp ├── cpad-down.bmp ├── cpad-left.bmp ├── cpad-right.bmp ├── cstick-down.bmp ├── cstick-left.bmp ├── cstick-up.bmp ├── cstick-right.bmp └── generatecode.py ├── unifont_cn.bin ├── unifont_full.bin ├── sysmodules ├── pm │ ├── source │ │ ├── process_monitor.h │ │ ├── pmdbg.h │ │ ├── pmapp.h │ │ ├── firmlaunch.h │ │ ├── exheader_info_heap.h │ │ ├── reslimit.h │ │ ├── termination.h │ │ ├── my_thread.h │ │ ├── task_runner.h │ │ ├── manager.h │ │ ├── service_manager.h │ │ ├── info.h │ │ ├── launch.h │ │ ├── my_thread.c │ │ ├── luma.h │ │ ├── luma.c │ │ ├── exheader_info_heap.c │ │ ├── task_runner.c │ │ ├── luma_shared_config.h │ │ └── firmlaunch.c │ ├── README.md │ └── LICENSE ├── loader │ ├── source │ │ ├── loader.h │ │ ├── strings.h │ │ ├── memory.h │ │ ├── paslr.h │ │ ├── bps_patcher.h │ │ ├── strings.c │ │ ├── romfsredir.h │ │ ├── ifile.h │ │ ├── memory.c │ │ ├── luma_shared_config.h │ │ ├── hbldr.h │ │ ├── patcher.h │ │ ├── file_util.h │ │ └── service_manager.h │ ├── LICENSE │ └── README.md ├── rosalina │ ├── include │ │ ├── plugin.h │ │ ├── gdb │ │ │ ├── tio.h │ │ │ ├── stop_point.h │ │ │ ├── monitor.h │ │ │ ├── verbose.h │ │ │ ├── regs.h │ │ │ ├── hio.h │ │ │ ├── query.h │ │ │ ├── breakpoints.h │ │ │ ├── watchpoints.h │ │ │ ├── debug.h │ │ │ ├── xfer.h │ │ │ ├── mem.h │ │ │ ├── remote_command.h │ │ │ ├── thread.h │ │ │ ├── server.h │ │ │ └── net.h │ │ ├── pmdbgext.h │ │ ├── task_runner.h │ │ ├── redshift │ │ │ └── colorramp.h │ │ ├── shell.h │ │ ├── bootdiag.h │ │ ├── sleep.h │ │ ├── menus │ │ │ ├── process_list.h │ │ │ ├── n3ds.h │ │ │ ├── cheats.h │ │ │ ├── debugger.h │ │ │ ├── miscellaneous.h │ │ │ └── sysconfig.h │ │ ├── luminance.h │ │ ├── fmt.h │ │ ├── errdisp.h │ │ ├── luma_shared_config.h │ │ ├── ntp.h │ │ ├── process_patches.h │ │ ├── memory.h │ │ ├── input_redirection.h │ │ ├── minisoc.h │ │ ├── MyThread.h │ │ ├── menus.h │ │ ├── ifile.h │ │ └── service_manager.h │ └── source │ │ ├── gdb │ │ ├── xml │ │ │ ├── osdata_cfw_version_template.xml │ │ │ ├── osdata.xml │ │ │ ├── osdata_memory_template.xml │ │ │ └── target.xml │ │ ├── stop_point.c │ │ └── verbose.c │ │ ├── plugin │ │ ├── pluginLoader.s │ │ └── swapFunc.s │ │ ├── pmdbgext.c │ │ └── task_runner.c ├── sm │ ├── source │ │ ├── srv.h │ │ ├── srv_pm.h │ │ ├── list.h │ │ ├── notifications.h │ │ ├── processes.h │ │ └── services.h │ ├── README.md │ └── LICENSE ├── pxi │ ├── source │ │ ├── receiver.h │ │ ├── sender.h │ │ ├── MyThread.h │ │ ├── MyThread.c │ │ └── PXI.h │ ├── README.md │ └── LICENSE └── Makefile ├── arm9 ├── source │ ├── fatfs │ │ ├── sdmmc │ │ │ ├── delay.h │ │ │ └── delay.s │ │ └── 00readme.txt │ ├── alignedseqmemcpy.h │ ├── chainloader.h │ ├── strings.h │ ├── fmt.h │ ├── arm9_exception_handlers.h │ ├── exceptions.h │ ├── deliver_arg.h │ ├── pin.h │ ├── large_patches.h │ ├── memory.h │ ├── emunand.h │ ├── strings.c │ ├── firm.h │ ├── cache.h │ ├── fs.h │ └── draw.h └── linker.specs ├── k11_extension ├── include │ ├── svc │ │ ├── ExitProcess.h │ │ ├── ControlProcess.h │ │ ├── Backdoor.h │ │ ├── SetGpuProt.h │ │ ├── Break.h │ │ ├── SetWifiEnabled.h │ │ ├── CustomBackdoor.h │ │ ├── SendSyncRequest.h │ │ ├── UnmapProcessMemoryEx.h │ │ ├── ConnectToPort.h │ │ ├── GetSystemInfo.h │ │ ├── GetHandleInfo.h │ │ ├── GetThreadInfo.h │ │ ├── GetProcessInfo.h │ │ ├── TranslateHandle.h │ │ ├── ControlMemoryUnsafe.h │ │ ├── KernelSetState.h │ │ ├── CreateThread.h │ │ ├── CopyHandle.h │ │ ├── MapProcessMemoryEx.h │ │ ├── ControlMemory.h │ │ └── ControlService.h │ ├── config.h │ ├── svcHandler.h │ ├── svc.h │ ├── debug.h │ └── fatalExceptionHandlers.h ├── linker.specs └── source │ └── svc │ ├── ExitProcess.c │ ├── SetGpuProt.c │ ├── Break.s │ ├── SetWifiEnabled.c │ ├── CustomBackdoor.s │ ├── ControlMemory.c │ ├── Backdoor.s │ └── CreateThread.c ├── arm11 ├── linker.specs └── source │ ├── memory.h │ └── memory.c ├── .gitignore ├── .github └── workflows │ └── build.yml ├── sendfile.py └── Makefile /.gitattributes: -------------------------------------------------------------------------------- 1 | *.xml text eol=lf 2 | *.ini text eol=lf 3 | -------------------------------------------------------------------------------- /keyfont/A.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/A.bmp -------------------------------------------------------------------------------- /keyfont/B.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/B.bmp -------------------------------------------------------------------------------- /keyfont/L.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/L.bmp -------------------------------------------------------------------------------- /keyfont/R.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/R.bmp -------------------------------------------------------------------------------- /keyfont/X.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/X.bmp -------------------------------------------------------------------------------- /keyfont/Y.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/Y.bmp -------------------------------------------------------------------------------- /keyfont/ZL.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/ZL.bmp -------------------------------------------------------------------------------- /keyfont/ZR.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/ZR.bmp -------------------------------------------------------------------------------- /keyfont/up.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/up.bmp -------------------------------------------------------------------------------- /unifont_cn.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/unifont_cn.bin -------------------------------------------------------------------------------- /keyfont/Select.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/Select.bmp -------------------------------------------------------------------------------- /keyfont/Start.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/Start.bmp -------------------------------------------------------------------------------- /keyfont/down.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/down.bmp -------------------------------------------------------------------------------- /keyfont/error.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/error.bmp -------------------------------------------------------------------------------- /keyfont/left.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/left.bmp -------------------------------------------------------------------------------- /keyfont/right.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/right.bmp -------------------------------------------------------------------------------- /unifont_full.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/unifont_full.bin -------------------------------------------------------------------------------- /keyfont/cpad-up.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/cpad-up.bmp -------------------------------------------------------------------------------- /keyfont/keyicon.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/keyicon.psd -------------------------------------------------------------------------------- /keyfont/touchpad.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/touchpad.bmp -------------------------------------------------------------------------------- /keyfont/cpad-down.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/cpad-down.bmp -------------------------------------------------------------------------------- /keyfont/cpad-left.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/cpad-left.bmp -------------------------------------------------------------------------------- /keyfont/cpad-right.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/cpad-right.bmp -------------------------------------------------------------------------------- /keyfont/cstick-down.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/cstick-down.bmp -------------------------------------------------------------------------------- /keyfont/cstick-left.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/cstick-left.bmp -------------------------------------------------------------------------------- /keyfont/cstick-up.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/cstick-up.bmp -------------------------------------------------------------------------------- /sysmodules/pm/source/process_monitor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void processMonitor(void *p); 4 | -------------------------------------------------------------------------------- /keyfont/cstick-right.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CynricXu/Luma3DS/HEAD/keyfont/cstick-right.bmp -------------------------------------------------------------------------------- /arm9/source/fatfs/sdmmc/delay.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../types.h" 4 | 5 | void waitcycles(u32 us); 6 | -------------------------------------------------------------------------------- /sysmodules/pm/source/pmdbg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include <3ds/types.h> 4 | 5 | void pmDbgHandleCommands(void *ctx); 6 | -------------------------------------------------------------------------------- /sysmodules/pm/source/pmapp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include <3ds/types.h> 4 | 5 | void pmAppHandleCommands(void *ctx); 6 | 7 | -------------------------------------------------------------------------------- /sysmodules/loader/source/loader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include <3ds/types.h> 4 | 5 | void loaderHandleCommands(void *ctx); 6 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/plugin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "plugin/plgloader.h" 4 | #include "plugin/plgldr.h" 5 | #include "plugin/3gx.h" -------------------------------------------------------------------------------- /sysmodules/loader/source/strings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include <3ds/types.h> 4 | #include 5 | 6 | void progIdToStr(char *strEnd, u64 progId); 7 | -------------------------------------------------------------------------------- /k11_extension/include/svc/ExitProcess.h: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | #include "kernel.h" 3 | #include "svc.h" 4 | 5 | void ExitProcessHook(void); 6 | void ExitProcessHookWrapper(void); -------------------------------------------------------------------------------- /sysmodules/loader/source/memory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include <3ds/types.h> 4 | #include 5 | 6 | u8 *memsearch(u8 *startPos, const void *pattern, u32 size, u32 patternSize); 7 | -------------------------------------------------------------------------------- /sysmodules/loader/source/paslr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include <3ds/types.h> 4 | #include <3ds/exheader.h> 5 | 6 | Result allocateProgramMemory(const ExHeader_Info *exhi, u32 vaddr, u32 size); 7 | -------------------------------------------------------------------------------- /arm11/linker.specs: -------------------------------------------------------------------------------- 1 | %rename link old_link 2 | 3 | *link: 4 | %(old_link) -T %:getenv(TOPDIR /linker.ld) --nmagic --gc-sections --no-warn-rwx-segments 5 | 6 | *startfile: 7 | crti%O%s crtbegin%O%s 8 | -------------------------------------------------------------------------------- /arm9/linker.specs: -------------------------------------------------------------------------------- 1 | %rename link old_link 2 | 3 | *link: 4 | %(old_link) -T %:getenv(TOPDIR /linker.ld) --nmagic --gc-sections --no-warn-rwx-segments 5 | 6 | *startfile: 7 | crti%O%s crtbegin%O%s 8 | -------------------------------------------------------------------------------- /k11_extension/linker.specs: -------------------------------------------------------------------------------- 1 | %rename link old_link 2 | 3 | *link: 4 | %(old_link) -T %:getenv(TOPDIR /linker.ld) --nmagic --gc-sections --no-warn-rwx-segments 5 | 6 | *startfile: 7 | crti%O%s crtbegin%O%s 8 | -------------------------------------------------------------------------------- /sysmodules/loader/source/bps_patcher.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | #include <3ds/types.h> 7 | 8 | bool patcherApplyCodeBpsPatch(u64 progId, u8* code, u32 size); 9 | 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | -------------------------------------------------------------------------------- /sysmodules/sm/source/srv.h: -------------------------------------------------------------------------------- 1 | /* 2 | srv.h 3 | 4 | (c) TuxSH, 2017-2020 5 | This is part of 3ds_sm, which is licensed under the MIT license (see LICENSE for details). 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "common.h" 11 | 12 | Result srvHandleCommands(SessionData *sessionData); 13 | -------------------------------------------------------------------------------- /sysmodules/sm/source/srv_pm.h: -------------------------------------------------------------------------------- 1 | /* 2 | srv_pm.h 3 | 4 | (c) TuxSH, 2017-2020 5 | This is part of 3ds_sm, which is licensed under the MIT license (see LICENSE for details). 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "common.h" 11 | 12 | Result srvPmHandleCommands(SessionData *sessionData); 13 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/gdb/tio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS. 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * SPDX-License-Identifier: (MIT OR GPL-2.0-or-later) 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "gdb.h" 11 | 12 | GDB_DECLARE_VERBOSE_HANDLER(File); 13 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/gdb/stop_point.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS. 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * SPDX-License-Identifier: (MIT OR GPL-2.0-or-later) 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "gdb.h" 11 | 12 | GDB_DECLARE_HANDLER(ToggleStopPoint); 13 | -------------------------------------------------------------------------------- /sysmodules/loader/source/strings.c: -------------------------------------------------------------------------------- 1 | #include "strings.h" 2 | 3 | void progIdToStr(char *strEnd, u64 progId) 4 | { 5 | while(progId > 0) 6 | { 7 | static const char hexDigits[] = "0123456789ABCDEF"; 8 | *strEnd-- = hexDigits[(u32)(progId & 0xF)]; 9 | progId >>= 4; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /sysmodules/pm/source/firmlaunch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include <3ds/types.h> 4 | 5 | void mapFirmlaunchParameters(void); 6 | Result GetFirmlaunchParams(void *outParams, size_t size); 7 | Result SetFirmlaunchParams(const void *params, size_t size); 8 | Result LaunchFirm(u32 firmTidLow, const void *params, size_t size); 9 | -------------------------------------------------------------------------------- /sysmodules/pm/source/exheader_info_heap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include <3ds/exheader.h> 4 | 5 | // Official PM uses an overly complicated allocator with semaphores 6 | 7 | void ExHeaderInfoHeap_Init(void *buf, size_t num); 8 | ExHeader_Info *ExHeaderInfoHeap_New(void); 9 | void ExHeaderInfoHeap_Delete(ExHeader_Info *data); 10 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/gdb/monitor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS. 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * SPDX-License-Identifier: (MIT OR GPL-2.0-or-later) 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "gdb.h" 11 | #include "gdb/server.h" 12 | 13 | void GDB_RunMonitor(GDBServer *server); 14 | -------------------------------------------------------------------------------- /sysmodules/rosalina/source/gdb/xml/osdata_cfw_version_template.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %s 6 | %08lx 7 | %s 8 | 9 | 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | out 3 | build 4 | arm11/build 5 | sysmodules/loader/build 6 | sysmodules/rosalina/build 7 | chainloader/build 8 | exceptions/arm9/build 9 | exceptions/arm11/build 10 | *.bin 11 | *.firm 12 | *.o 13 | *.d 14 | *.elf 15 | *.cxi 16 | *.3dsx 17 | .DS_Store 18 | *.dmp 19 | .project 20 | .cproject 21 | .settings 22 | 23 | Luma3DS*.zip 24 | -------------------------------------------------------------------------------- /sysmodules/pxi/source/receiver.h: -------------------------------------------------------------------------------- 1 | /* 2 | receiver.h: 3 | Fetches replies coming from Process9, writing them in the appropriate buffer. 4 | 5 | (c) TuxSH, 2016-2020 6 | This is part of 3ds_pxi, which is licensed under the MIT license (see LICENSE for details). 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "common.h" 12 | 13 | void receiver(void); 14 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/gdb/verbose.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS. 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * SPDX-License-Identifier: (MIT OR GPL-2.0-or-later) 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "gdb.h" 11 | 12 | GDB_DECLARE_HANDLER(VerboseCommand); 13 | GDB_DECLARE_VERBOSE_HANDLER(ContinueSupported); 14 | -------------------------------------------------------------------------------- /arm9/source/fatfs/sdmmc/delay.s: -------------------------------------------------------------------------------- 1 | .text 2 | .arm 3 | .align 4 4 | 5 | .global waitcycles 6 | .type waitcycles, %function 7 | waitcycles: 8 | push {r0-r2, lr} 9 | str r0, [sp, #4] 10 | waitcycles_loop: 11 | ldr r3, [sp, #4] 12 | subs r2, r3, #1 13 | str r2, [sp, #4] 14 | cmp r3, #0 15 | bne waitcycles_loop 16 | pop {r0-r2, pc} 17 | -------------------------------------------------------------------------------- /sysmodules/pm/README.md: -------------------------------------------------------------------------------- 1 | # 3ds_pm 2 | Open source replacement of the Arm11 PM system module. 3 | This is licensed under the MIT license. 4 | 5 | # Usage 6 | To run this system module, use a recent release or commit of [Luma3DS](https://github.com/LumaTeam/Luma3DS/), build this project and copy the generated CXI file to `/luma/sysmodules/pm.cxi`. 7 | 8 | # Credits 9 | @fincs 10 | @Stary 11 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/gdb/regs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS. 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * SPDX-License-Identifier: (MIT OR GPL-2.0-or-later) 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "gdb.h" 11 | 12 | GDB_DECLARE_HANDLER(ReadRegisters); 13 | GDB_DECLARE_HANDLER(WriteRegisters); 14 | GDB_DECLARE_HANDLER(ReadRegister); 15 | GDB_DECLARE_HANDLER(WriteRegister); 16 | -------------------------------------------------------------------------------- /sysmodules/sm/README.md: -------------------------------------------------------------------------------- 1 | # 3ds_sm 2 | Open source replacement of the Arm11 SM system module. 3 | This is licensed under the MIT license. 4 | 5 | # Usage 6 | To run this system module, use a recent release or commit of [Luma3DS](https://github.com/LumaTeam/Luma3DS/), build this project and copy sm.cxi to /luma/sysmodules/. 7 | 8 | # Credits 9 | Everyone that helped me fix some of stupid bugs I had been making: @fincs, @Hikari-chin, etc. 10 | -------------------------------------------------------------------------------- /sysmodules/sm/source/list.h: -------------------------------------------------------------------------------- 1 | /* 2 | list.h 3 | 4 | (c) TuxSH, 2017-2020 5 | This is part of 3ds_sm, which is licensed under the MIT license (see LICENSE for details). 6 | */ 7 | 8 | #pragma once 9 | 10 | #include <3ds/types.h> 11 | 12 | void buildList(void *list, void *pool, u32 nb, u32 elementSize); 13 | void moveNode(void *node, void *dst, bool back); 14 | void *allocateNode(void *inUseList, void *freeList, u32 elementSize, bool back); 15 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/gdb/hio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS. 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * SPDX-License-Identifier: (MIT OR GPL-2.0-or-later) 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "gdb.h" 11 | 12 | bool GDB_FetchPackedHioRequest(GDBContext *ctx, u32 addr); 13 | bool GDB_IsHioInProgress(GDBContext *ctx); 14 | int GDB_SendCurrentHioRequest(GDBContext *ctx); 15 | 16 | GDB_DECLARE_HANDLER(HioReply); 17 | -------------------------------------------------------------------------------- /sysmodules/pm/source/reslimit.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include <3ds/svc.h> 4 | 5 | Result initializeReslimits(void); 6 | Result setAppMemLimit(u32 limit); 7 | Result resetAppMemLimit(void); 8 | Result setAppCpuTimeLimit(s64 limit); 9 | void setAppCpuTimeLimitAndSchedModeFromDescriptor(u64 titleId, u16 descriptor); 10 | 11 | Result SetAppResourceLimit(u32 mbz, ResourceLimitType category, u32 value, u64 mbz2); 12 | Result GetAppResourceLimit(s64 *value, u32 mbz, ResourceLimitType category, u32 mbz2, u64 mbz3); 13 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/gdb/query.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS. 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * SPDX-License-Identifier: (MIT OR GPL-2.0-or-later) 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "gdb.h" 11 | 12 | int GDB_HandleReadQuery(GDBContext *ctx); 13 | int GDB_HandleWriteQuery(GDBContext *ctx); 14 | 15 | GDB_DECLARE_QUERY_HANDLER(Supported); 16 | GDB_DECLARE_QUERY_HANDLER(StartNoAckMode); 17 | GDB_DECLARE_QUERY_HANDLER(Attached); 18 | GDB_DECLARE_QUERY_HANDLER(CatchSyscalls); 19 | -------------------------------------------------------------------------------- /sysmodules/pxi/source/sender.h: -------------------------------------------------------------------------------- 1 | /* 2 | sender.h 3 | Handles commands from arm11 processes, then sends them to Process9, and replies to arm11 processes the replies received from Process9 (=> receiver.c) (except for PXISRV11). 4 | 5 | (c) TuxSH, 2016-2020 6 | This is part of 3ds_pxi, which is licensed under the MIT license (see LICENSE for details). 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "common.h" 12 | 13 | Result sendPXICmdbuf(Handle *additionalHandle, u32 serviceId, u32 *buffer); 14 | void sender(void); 15 | void PXISRV11Handler(void); 16 | -------------------------------------------------------------------------------- /sysmodules/pm/source/termination.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "process_data.h" 4 | #include <3ds/exheader.h> 5 | 6 | Result listAndTerminateDependencies(ProcessData *process, ExHeader_Info *exheaderInfo); 7 | ProcessData *terminateAllProcesses(u32 callerPid, s64 timeout); // callerPid = -1 for firmlaunch 8 | 9 | Result TerminateApplication(s64 timeout); 10 | Result TerminateTitle(u64 titleId, s64 timeout); 11 | Result TerminateProcess(u32 pid, s64 timeout); 12 | Result PrepareForReboot(u32 pid, s64 timeout); 13 | 14 | Result ChainloadHomebrewDirty(void); 15 | -------------------------------------------------------------------------------- /sysmodules/Makefile: -------------------------------------------------------------------------------- 1 | ifeq ($(BUILD_FOR_EXPLOIT_DEV),1) 2 | # Keep Loader so that we can execute 3DSX 3 | SUBFOLDERS := loader 4 | else 5 | SUBFOLDERS := loader sm pm pxi rosalina 6 | endif 7 | 8 | CXIS := $(foreach dir, $(SUBFOLDERS), $(dir)/$(dir).cxi) 9 | 10 | .PHONY: all clean $(SUBFOLDERS) 11 | 12 | all: sysmodules.bin 13 | 14 | clean: 15 | @$(foreach dir, $(SUBFOLDERS), $(MAKE) -C $(dir) clean &&) true 16 | @rm -rf sysmodules.bin 17 | 18 | sysmodules.bin: $(SUBFOLDERS) 19 | @cat $(CXIS) > $@ 20 | @echo built... $(notdir $@) 21 | 22 | $(SUBFOLDERS): 23 | @$(MAKE) -C $@ all 24 | -------------------------------------------------------------------------------- /sysmodules/pm/source/my_thread.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include <3ds/types.h> 4 | #include <3ds/result.h> 5 | #include <3ds/svc.h> 6 | #include <3ds/synchronization.h> 7 | 8 | #define THREAD_STACK_SIZE 0x1000 9 | 10 | typedef struct MyThread { 11 | Handle handle; 12 | void *p; 13 | void (*ep)(void *p); 14 | bool finished; 15 | void* stacktop; 16 | } MyThread; 17 | 18 | Result MyThread_Create(MyThread *t, void (*entrypoint)(void *p), void *p, void *stack, u32 stackSize, int prio, int affinity); 19 | Result MyThread_Join(MyThread *thread, s64 timeout_ns); 20 | void MyThread_Exit(void); 21 | -------------------------------------------------------------------------------- /sysmodules/loader/source/romfsredir.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include <3ds/types.h> 4 | 5 | extern const u8 romfsRedirPatch[]; 6 | extern const u32 romfsRedirPatchSize; 7 | 8 | extern u32 romfsRedirPatchSubstituted1, romfsRedirPatchHook1; 9 | extern u32 romfsRedirPatchSubstituted2, romfsRedirPatchHook2; 10 | 11 | extern u32 romfsRedirPatchArchiveName; 12 | extern u32 romfsRedirPatchFsMountArchive; 13 | extern u32 romfsRedirPatchFsRegisterArchive; 14 | extern u32 romfsRedirPatchArchiveId; 15 | extern u32 romfsRedirPatchRomFsMount; 16 | extern u32 romfsRedirPatchUpdateRomFsMount; 17 | extern u32 romfsRedirPatchCustomPath; 18 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/pmdbgext.h: -------------------------------------------------------------------------------- 1 | // License for this file: ctrulib's license 2 | // Copyright AuroraWright, TuxSH 2019-2020 3 | 4 | #pragma once 5 | 6 | #include <3ds/services/pmapp.h> 7 | #include <3ds/services/pmdbg.h> 8 | 9 | /// Custom launch flags for PM launch commands. 10 | enum { 11 | PMLAUNCHFLAGEXT_FAKE_DEPENDENCY_LOADING = BIT(24), 12 | }; 13 | 14 | Result PMDBG_GetCurrentAppInfo(FS_ProgramInfo *outProgramInfo, u32 *outPid, u32 *outLaunchFlags); 15 | Result PMDBG_DebugNextApplicationByForce(bool debug); 16 | Result PMDBG_LaunchTitleDebug(Handle *outDebug, const FS_ProgramInfo *programInfo, u32 launchFlags); 17 | -------------------------------------------------------------------------------- /sysmodules/pm/source/task_runner.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include <3ds/types.h> 4 | #include <3ds/synchronization.h> 5 | 6 | typedef struct TaskRunner { 7 | LightEvent readyEvent; 8 | LightEvent parametersSetEvent; 9 | void (*task)(void *argdata); 10 | u8 argStorage[0x40]; 11 | bool shouldTerminate; 12 | } TaskRunner; 13 | 14 | extern TaskRunner g_taskRunner; 15 | 16 | void TaskRunner_Init(void); 17 | void TaskRunner_RunTask(void (*task)(void *argdata), void *argdata, size_t argsize); 18 | void TaskRunner_Terminate(void); 19 | 20 | /// Thread function 21 | void TaskRunner_HandleTasks(void *p); 22 | void TaskRunner_WaitReady(void); 23 | -------------------------------------------------------------------------------- /keyfont/generatecode.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | rootdir = "." 4 | for root, dirs, files in os.walk(rootdir): 5 | for f in files: 6 | if(f.find(".bmp") != -1): 7 | filename = os.path.join(root, f) 8 | print("//" + f.split(".bmp")[0]) 9 | fp = open(filename,"rb") 10 | 11 | a = fp.read() 12 | bytesarr = a[0x436:-2] 13 | 14 | for i in range(15,-1,-1): 15 | hexdata = 0x0000 16 | for j in range(0,16): 17 | if(bytesarr[i * 16 + j] > 0): 18 | hexdata += (0b1 << (15 - j)) 19 | print('0x{:04X},'.format(hexdata)) 20 | fp.close() -------------------------------------------------------------------------------- /sysmodules/pxi/README.md: -------------------------------------------------------------------------------- 1 | # 3ds_pxi 2 | Open source replacement of the Arm11 PXI system module. 3 | This is licensed under the MIT license. 4 | 5 | # Usage 6 | To run this system module, use a recent release or commit of [Luma3DS](https://github.com/LumaTeam/Luma3DS/) and copy pxi.cxi to /luma/sysmodules/. 7 | 8 | # Credits 9 | This list is not complete at all: 10 | 11 | * @Subv, for the process patch that used to be used in Luma3DS which I modified to assist me in PXI sysmodule reverse-engineering 12 | * @yifanlu, for the work his own work on loader 13 | * @Mrrraou, for intensive testing back in June/July 2016 14 | * @jackron, for makerom support and help 15 | * Many #Cakey and #3dsdev folks I haven't mentioned here, etc. 16 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/task_runner.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include <3ds/types.h> 4 | #include <3ds/synchronization.h> 5 | #include "MyThread.h" 6 | 7 | typedef struct TaskRunner { 8 | LightEvent readyEvent; 9 | LightEvent parametersSetEvent; 10 | void (*task)(void *argdata); 11 | u8 argStorage[0x40]; 12 | bool shouldTerminate; 13 | } TaskRunner; 14 | 15 | extern TaskRunner g_taskRunner; 16 | 17 | MyThread *taskRunnerCreateThread(void); 18 | 19 | void TaskRunner_Init(void); 20 | void TaskRunner_RunTask(void (*task)(void *argdata), void *argdata, size_t argsize); 21 | void TaskRunner_Terminate(void); 22 | 23 | /// Thread function 24 | void TaskRunner_HandleTasks(void); 25 | void TaskRunner_WaitReady(void); 26 | -------------------------------------------------------------------------------- /sysmodules/rosalina/source/gdb/xml/osdata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | cfwversion 6 | Listing of the Luma3DS version, commit hash, etc. 7 | CFW 8 | 9 | 10 | memory 11 | Listing of memory usage per region 12 | Memory 13 | 14 | 15 | processes 16 | Listing of all processes 17 | Processes 18 | 19 | 20 | -------------------------------------------------------------------------------- /sysmodules/pm/source/manager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include <3ds/types.h> 4 | #include "process_data.h" 5 | 6 | typedef struct Manager { 7 | ProcessList processList; 8 | ProcessData *runningApplicationData; 9 | ProcessData *debugData; // note: official PM uses runningApplicationData for both, and has queuedApplicationProcessHandle 10 | Handle reslimits[4]; 11 | Handle newProcessEvent; 12 | Handle allNotifiedTerminationEvent; 13 | bool waitingForTermination; 14 | bool preparingForReboot; 15 | u8 maxAppCpuTime; 16 | s8 cpuTimeBase; 17 | } Manager; 18 | 19 | extern Manager g_manager; 20 | 21 | void Manager_Init(void *procBuf, size_t numProc); 22 | void Manager_RegisterKips(void); 23 | Result UnregisterProcess(u64 titleId); 24 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/gdb/breakpoints.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS. 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * SPDX-License-Identifier: (MIT OR GPL-2.0-or-later) 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "gdb.h" 11 | 12 | // We'll actually use SVC 0xFF for breakpoints :P 13 | #define BREAKPOINT_INSTRUCTION_ARM 0xEF0000FF 14 | #define BREAKPOINT_INSTRUCTION_THUMB 0xDFFF 15 | 16 | u32 GDB_FindClosestBreakpointSlot(GDBContext *ctx, u32 address); 17 | int GDB_GetBreakpointInstruction(u32 *instr, GDBContext *ctx, u32 address); 18 | int GDB_AddBreakpoint(GDBContext *ctx, u32 address, bool thumb, bool persist); 19 | int GDB_DisableBreakpointById(GDBContext *ctx, u32 id); 20 | int GDB_RemoveBreakpoint(GDBContext *ctx, u32 address); 21 | -------------------------------------------------------------------------------- /sysmodules/pxi/source/MyThread.h: -------------------------------------------------------------------------------- 1 | /* 2 | MyThread.h: 3 | Small threading library, based off ctrulib. 4 | 5 | (c) TuxSH, 2016-2020 6 | This is part of 3ds_pxi, which is licensed under the MIT license (see LICENSE for details). 7 | */ 8 | 9 | #pragma once 10 | 11 | #include <3ds/types.h> 12 | #include <3ds/result.h> 13 | #include <3ds/svc.h> 14 | #include <3ds/synchronization.h> 15 | 16 | #define THREAD_STACK_SIZE 0x1000 17 | 18 | typedef struct MyThread 19 | { 20 | Handle handle; 21 | void (*ep)(void); 22 | bool finished; 23 | void* stacktop; 24 | } MyThread; 25 | 26 | Result MyThread_Create(MyThread *t, void (*entrypoint)(void), void *stack, u32 stackSize, int prio, int affinity); 27 | Result MyThread_Join(MyThread *thread, s64 timeout_ns); 28 | void MyThread_Exit(void); 29 | -------------------------------------------------------------------------------- /sysmodules/pm/source/service_manager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include <3ds/types.h> 4 | 5 | typedef struct ServiceManagerServiceEntry { 6 | const char *name; 7 | u32 maxSessions; 8 | void (*handler)(void *ctx); 9 | bool isGlobalPort; 10 | } ServiceManagerServiceEntry; 11 | 12 | typedef struct ServiceManagerNotificationEntry { 13 | u32 id; 14 | void (*handler)(u32 id); 15 | } ServiceManagerNotificationEntry; 16 | 17 | typedef struct ServiceManagerContextAllocator { 18 | void* (*newSessionContext)(u8 serviceId); 19 | void (*freeSessionContext)(void *ctx); 20 | } ServiceManagerContextAllocator; 21 | 22 | Result ServiceManager_Run(const ServiceManagerServiceEntry *services, const ServiceManagerNotificationEntry *notifications, const ServiceManagerContextAllocator *allocator); 23 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/gdb/watchpoints.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS. 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * SPDX-License-Identifier: (MIT OR GPL-2.0-or-later) 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "gdb.h" 11 | 12 | typedef enum WatchpointKind 13 | { 14 | WATCHPOINT_DISABLED = 0, 15 | WATCHPOINT_READ, 16 | WATCHPOINT_WRITE, 17 | WATCHPOINT_READWRITE 18 | } WatchpointKind; 19 | 20 | void GDB_ResetWatchpoints(void); // needed for software breakpoints to be detected as debug events as well 21 | 22 | int GDB_AddWatchpoint(GDBContext *ctx, u32 address, u32 size, WatchpointKind kind); 23 | int GDB_RemoveWatchpoint(GDBContext *ctx, u32 address, WatchpointKind kind); 24 | 25 | WatchpointKind GDB_GetWatchpointKind(GDBContext *ctx, u32 address); 26 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | paths-ignore: 6 | - '.github/ISSUE_TEMPLATE/**' 7 | - '.github/*' 8 | - 'LICENSE.txt' 9 | - 'README.md' 10 | pull_request: 11 | paths-ignore: 12 | - '.github/ISSUE_TEMPLATE/**' 13 | - '.github/*' 14 | - 'LICENSE.txt' 15 | - 'README.md' 16 | workflow_dispatch: 17 | 18 | jobs: 19 | build: 20 | runs-on: ubuntu-latest 21 | container: pablomk7/luma3dsbuildtools 22 | steps: 23 | - uses: actions/checkout@v2.3.1 24 | with: 25 | fetch-depth: 0 26 | - name: debug 27 | run: git describe --tags 28 | - name: Build 29 | run: make -j$(nproc --all) 30 | - uses: actions/upload-artifact@v2 31 | with: 32 | name: Luma3DS 33 | path: boot.firm 34 | -------------------------------------------------------------------------------- /sysmodules/rosalina/source/plugin/pluginLoader.s: -------------------------------------------------------------------------------- 1 | .section .data 2 | .balign 4 3 | .arm 4 | 5 | .global gamePatchFunc 6 | .type gamePatchFunc, %function 7 | gamePatchFunc: 8 | stmfd sp!, {r0-r12} 9 | mrs r0, cpsr 10 | stmfd sp!, {r0} 11 | adr r0, g_savedGameInstr 12 | ldr r1, =0x00100000 13 | ldr r2, [r0] 14 | str r2, [r1] 15 | ldr r2, [r0, #4] 16 | str r2, [r1, #4] 17 | svc 0x92 18 | svc 0x94 19 | 20 | startplugin: 21 | adr r0, g_savedGameInstr 22 | push {r0} 23 | ldr r5, =0x07000100 24 | blx r5 25 | add sp, sp, #4 26 | 27 | exit: 28 | ldmfd sp!, {r0} 29 | msr cpsr, r0 30 | ldmfd sp!, {r0-r12} 31 | ldr lr, =0x00100000 32 | mov pc, lr 33 | 34 | .global g_savedGameInstr 35 | g_savedGameInstr: 36 | .word 0, 0 37 | -------------------------------------------------------------------------------- /sysmodules/sm/source/notifications.h: -------------------------------------------------------------------------------- 1 | /* 2 | notifications.h 3 | 4 | (c) TuxSH, 2017-2020 5 | This is part of 3ds_sm, which is licensed under the MIT license (see LICENSE for details). 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "common.h" 11 | 12 | Result EnableNotification(SessionData *sessionData, Handle *notificationSemaphore); 13 | Result Subscribe(SessionData *sessionData, u32 notificationId); 14 | Result Unsubscribe(SessionData *sessionData, u32 notificationId); 15 | Result ReceiveNotification(SessionData *sessionData, u32 *notificationId); 16 | Result PublishToSubscriber(u32 notificationId, u32 flags); 17 | Result PublishAndGetSubscriber(u32 *pidCount, u32 *pidList, u32 notificationId, u32 flags); 18 | Result PublishToProcess(Handle process, u32 notificationId); 19 | Result PublishToAll(u32 notificationId); 20 | 21 | Result AddToNdmuWorkaroundCount(s32 count); 22 | -------------------------------------------------------------------------------- /sysmodules/loader/source/ifile.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include <3ds/services/fs.h> 4 | 5 | #define PATH_MAX 255 6 | 7 | typedef struct 8 | { 9 | Handle handle; 10 | u64 pos; 11 | u64 size; 12 | } IFile; 13 | 14 | Result IFile_Open(IFile *file, FS_ArchiveID archiveId, FS_Path archivePath, FS_Path filePath, u32 flags); 15 | Result IFile_OpenFromArchive(IFile *file, FS_Archive archive, FS_Path filePath, u32 flags); 16 | Result IFile_Close(IFile *file); 17 | Result IFile_GetSize(IFile *file, u64 *size); 18 | Result IFile_SetSize(IFile *file, u64 size); 19 | Result IFile_Read(IFile *file, u64 *total, void *buffer, u32 len); 20 | Result IFile_Write(IFile *file, u64 *total, const void *buffer, u32 len, u32 flags); 21 | 22 | Result IFile_ReadAt(IFile *file, u64 *total, void *buffer, u32 offset, u32 len); 23 | u32 IFile_Read2(IFile *file, void *buffer, u32 size, u32 offset); 24 | -------------------------------------------------------------------------------- /sysmodules/pm/source/info.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include <3ds/exheader.h> 4 | #include <3ds/services/fs.h> 5 | #include "process_data.h" 6 | 7 | Result registerProgram(u64 *programHandle, const FS_ProgramInfo *programInfo, const FS_ProgramInfo *programInfoUpdate); 8 | Result getAndListDependencies(u64 *dependencies, u32 *numDeps, ProcessData *process, ExHeader_Info *exheaderInfo); 9 | Result listDependencies(u64 *dependencies, u32 *numDeps, const ExHeader_Info *exheaderInfo); 10 | Result listMergeUniqueDependencies(ProcessData **procs, u64 *dependencies, u32 *remrefcounts, u32 *numDeps, const ExHeader_Info *exheaderInfo); 11 | 12 | Result GetTitleExHeaderFlags(ExHeader_Arm11CoreInfo *outCoreInfo, ExHeader_SystemInfoFlags *outSiFlags, const FS_ProgramInfo *programInfo); 13 | 14 | // Custom 15 | Result GetCurrentAppInfo(FS_ProgramInfo *outProgramInfo, u32 *outPid, u32 *outLaunchFlags); 16 | -------------------------------------------------------------------------------- /sysmodules/loader/source/memory.c: -------------------------------------------------------------------------------- 1 | #include "memory.h" 2 | 3 | //Boyer-Moore Horspool algorithm, adapted from http://www-igm.univ-mlv.fr/~lecroq/string/node18.html#SECTION00180 4 | u8 *memsearch(u8 *startPos, const void *pattern, u32 size, u32 patternSize) 5 | { 6 | const u8 *patternc = (const u8 *)pattern; 7 | u32 table[256]; 8 | 9 | //Preprocessing 10 | for(u32 i = 0; i < 256; i++) 11 | table[i] = patternSize; 12 | for(u32 i = 0; i < patternSize - 1; i++) 13 | table[patternc[i]] = patternSize - i - 1; 14 | 15 | //Searching 16 | u32 j = 0; 17 | while(j <= size - patternSize) 18 | { 19 | u8 c = startPos[j + patternSize - 1]; 20 | if(patternc[patternSize - 1] == c && memcmp(pattern, startPos + j, patternSize - 1) == 0) 21 | return startPos + j; 22 | j += table[c]; 23 | } 24 | 25 | return NULL; 26 | } 27 | -------------------------------------------------------------------------------- /sysmodules/pm/source/launch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include <3ds/exheader.h> 4 | #include <3ds/services/fs.h> 5 | #include "process_data.h" 6 | 7 | /// Custom launch flags for PM launch commands. 8 | enum { 9 | PMLAUNCHFLAGEXT_FAKE_DEPENDENCY_LOADING = BIT(24), 10 | }; 11 | 12 | Result LaunchTitle(u32 *outPid, const FS_ProgramInfo *programInfo, u32 launchFlags, bool allowAsync); 13 | Result LaunchTitleUpdate(const FS_ProgramInfo *programInfo, const FS_ProgramInfo *programInfoUpdate, u32 launchFlags); 14 | Result LaunchApp(const FS_ProgramInfo *programInfo, u32 launchFlags); 15 | Result RunQueuedProcess(Handle *outDebug); 16 | Result LaunchAppDebug(Handle *outDebug, const FS_ProgramInfo *programInfo, u32 launchFlags); 17 | 18 | Result autolaunchSysmodules(void); 19 | 20 | // Custom 21 | Result DebugNextApplicationByForce(bool debug); 22 | Result LaunchTitleDebug(Handle *outDebug, const FS_ProgramInfo *programInfo, u32 launchFlags); 23 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/gdb/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS. 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * SPDX-License-Identifier: (MIT OR GPL-2.0-or-later) 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "gdb.h" 11 | 12 | GDB_DECLARE_VERBOSE_HANDLER(Run); 13 | GDB_DECLARE_HANDLER(Restart); 14 | GDB_DECLARE_VERBOSE_HANDLER(Attach); 15 | GDB_DECLARE_HANDLER(Detach); 16 | GDB_DECLARE_HANDLER(Kill); 17 | GDB_DECLARE_VERBOSE_HANDLER(Kill); 18 | GDB_DECLARE_HANDLER(Break); 19 | GDB_DECLARE_HANDLER(Continue); 20 | GDB_DECLARE_VERBOSE_HANDLER(Continue); 21 | GDB_DECLARE_HANDLER(GetStopReason); 22 | 23 | void GDB_ContinueExecution(GDBContext *ctx); 24 | void GDB_PreprocessDebugEvent(GDBContext *ctx, DebugEventInfo *info); 25 | int GDB_SendStopReply(GDBContext *ctx, const DebugEventInfo *info); 26 | int GDB_HandleDebugEvents(GDBContext *ctx); 27 | void GDB_BreakProcessAndSinkDebugEvents(GDBContext *ctx, DebugFlags flags); 28 | -------------------------------------------------------------------------------- /sysmodules/rosalina/source/gdb/xml/osdata_memory_template.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | APPLICATION 6 | %u 7 | %u 8 | %u 9 | %u%% 10 | 11 | 12 | SYSTEM 13 | %u 14 | %u 15 | %u 16 | %u%% 17 | 18 | 19 | BASE 20 | %u 21 | %u 22 | %u 23 | %u%% 24 | 25 | 26 | -------------------------------------------------------------------------------- /arm9/source/fatfs/00readme.txt: -------------------------------------------------------------------------------- 1 | FatFs Module Source Files R0.15 2 | 3 | 4 | FILES 5 | 6 | 00readme.txt This file. 7 | 00history.txt Revision history. 8 | ff.c FatFs module. 9 | ffconf.h Configuration file of FatFs module. 10 | ff.h Common include file for FatFs and application module. 11 | diskio.h Common include file for FatFs and disk I/O module. 12 | diskio.c An example of glue function to attach existing disk I/O module to FatFs. 13 | ffunicode.c Optional Unicode utility functions. 14 | ffsystem.c An example of optional O/S related functions. 15 | 16 | 17 | Low level disk I/O module is not included in this archive because the FatFs 18 | module is only a generic file system layer and it does not depend on any specific 19 | storage device. You need to provide a low level disk I/O module written to 20 | control the storage device that attached to the target system. 21 | 22 | -------------------------------------------------------------------------------- /sysmodules/pm/source/my_thread.c: -------------------------------------------------------------------------------- 1 | #include <3ds.h> 2 | #include "my_thread.h" 3 | 4 | static void _thread_begin(void* arg) 5 | { 6 | MyThread *t = (MyThread *)arg; 7 | t->ep(t->p); 8 | MyThread_Exit(); 9 | } 10 | 11 | Result MyThread_Create(MyThread *t, void (*entrypoint)(void *p), void *p, void *stack, u32 stackSize, int prio, int affinity) 12 | { 13 | t->ep = entrypoint; 14 | t->p = p; 15 | t->stacktop = (u8 *)stack + stackSize; 16 | 17 | return svcCreateThread(&t->handle, _thread_begin, (u32)t, (u32*)t->stacktop, prio, affinity); 18 | } 19 | 20 | Result MyThread_Join(MyThread *thread, s64 timeout_ns) 21 | { 22 | if (thread == NULL) return 0; 23 | Result res = svcWaitSynchronization(thread->handle, timeout_ns); 24 | if(R_FAILED(res)) return res; 25 | 26 | svcCloseHandle(thread->handle); 27 | thread->handle = (Handle)0; 28 | 29 | return res; 30 | } 31 | 32 | void MyThread_Exit(void) 33 | { 34 | svcExitThread(); 35 | } 36 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/gdb/xfer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS. 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * SPDX-License-Identifier: (MIT OR GPL-2.0-or-later) 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "gdb.h" 11 | 12 | #define GDB_XFER_HANDLER(name) GDB_HANDLER(Xfer##name) 13 | #define GDB_DECLARE_XFER_HANDLER(name) int GDB_XFER_HANDLER(name)(GDBContext *ctx, bool write, const char *annex, u32 offset, u32 length) 14 | 15 | #define GDB_XFER_OSDATA_HANDLER(name) GDB_XFER_HANDLER(OsData##name) 16 | #define GDB_DECLARE_XFER_OSDATA_HANDLER(name) int GDB_XFER_OSDATA_HANDLER(name)(GDBContext *ctx, bool write, u32 offset, u32 length) 17 | 18 | GDB_DECLARE_XFER_HANDLER(Features); 19 | 20 | GDB_DECLARE_XFER_OSDATA_HANDLER(CfwVersion); 21 | GDB_DECLARE_XFER_OSDATA_HANDLER(Memory); 22 | GDB_DECLARE_XFER_OSDATA_HANDLER(Processes); 23 | 24 | GDB_DECLARE_XFER_HANDLER(OsData); 25 | 26 | GDB_DECLARE_QUERY_HANDLER(Xfer); 27 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/gdb/mem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS. 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * SPDX-License-Identifier: (MIT OR GPL-2.0-or-later) 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "gdb.h" 11 | 12 | Result GDB_ReadTargetMemoryInPage(void *out, GDBContext *ctx, u32 addr, u32 len); 13 | Result GDB_WriteTargetMemoryInPage(GDBContext *ctx, const void *in, u32 addr, u32 len); 14 | u32 GDB_ReadTargetMemory(void *out, GDBContext *ctx, u32 addr, u32 len); 15 | u32 GDB_WriteTargetMemory(GDBContext *ctx, const void *in, u32 addr, u32 len); 16 | 17 | int GDB_SendMemory(GDBContext *ctx, const char *prefix, u32 prefixLen, u32 addr, u32 len); 18 | int GDB_WriteMemory(GDBContext *ctx, const void *buf, u32 addr, u32 len); 19 | u32 GDB_SearchMemory(bool *found, GDBContext *ctx, u32 addr, u32 len, const void *pattern, u32 patternLen); 20 | 21 | GDB_DECLARE_HANDLER(ReadMemory); 22 | GDB_DECLARE_HANDLER(WriteMemory); 23 | GDB_DECLARE_HANDLER(WriteMemoryRaw); 24 | GDB_DECLARE_QUERY_HANDLER(SearchMemory); 25 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/gdb/remote_command.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS. 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * SPDX-License-Identifier: (MIT OR GPL-2.0-or-later) 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "gdb.h" 11 | 12 | #define GDB_REMOTE_COMMAND_HANDLER(name) GDB_HANDLER(RemoteCommand##name) 13 | #define GDB_DECLARE_REMOTE_COMMAND_HANDLER(name) GDB_DECLARE_HANDLER(RemoteCommand##name) 14 | 15 | GDB_DECLARE_REMOTE_COMMAND_HANDLER(ConvertVAToPA); 16 | GDB_DECLARE_REMOTE_COMMAND_HANDLER(SyncRequestInfo); 17 | GDB_DECLARE_REMOTE_COMMAND_HANDLER(TranslateHandle); 18 | GDB_DECLARE_REMOTE_COMMAND_HANDLER(ListAllHandles); 19 | GDB_DECLARE_REMOTE_COMMAND_HANDLER(GetMmuConfig); 20 | GDB_DECLARE_REMOTE_COMMAND_HANDLER(GetMemRegions); 21 | GDB_DECLARE_REMOTE_COMMAND_HANDLER(FlushCaches); 22 | GDB_DECLARE_REMOTE_COMMAND_HANDLER(ToggleExternalMemoryAccess); 23 | GDB_DECLARE_REMOTE_COMMAND_HANDLER(CatchSvc); 24 | GDB_DECLARE_REMOTE_COMMAND_HANDLER(GetThreadPriority); 25 | 26 | GDB_DECLARE_QUERY_HANDLER(Rcmd); 27 | -------------------------------------------------------------------------------- /k11_extension/include/svc/ControlProcess.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "utils.h" 4 | #include "kernel.h" 5 | #include "svc.h" 6 | 7 | /// Operations for svcControlProcess 8 | typedef enum ProcessOp 9 | { 10 | PROCESSOP_GET_ALL_HANDLES, ///< List all handles of the process, varg3 can be either 0 to fetch all handles, or token of the type to fetch 11 | ///< svcControlProcess(handle, PROCESSOP_GET_ALL_HANDLES, (u32)&outBuf, 0) 12 | PROCESSOP_SET_MMU_TO_RWX, ///< Set the whole memory of the process with rwx access 13 | ///< svcControlProcess(handle, PROCESSOP_SET_MMU_TO_RWX, 0, 0) 14 | PROCESSOP_GET_ON_MEMORY_CHANGE_EVENT, 15 | PROCESSOP_SIGNAL_ON_EXIT, 16 | PROCESSOP_GET_PA_FROM_VA, ///< Get the physical address of the va within the process 17 | ///< svcControlProcess(handle, PROCESSOP_GET_PA_FROM_VA, (u32)&outPa, va) 18 | PROCESSOP_SCHEDULE_THREADS, 19 | } ProcessOp; 20 | 21 | Result ControlProcess(Handle process, ProcessOp op, u32 varg2, u32 varg3); 22 | -------------------------------------------------------------------------------- /sysmodules/pxi/source/MyThread.c: -------------------------------------------------------------------------------- 1 | /* 2 | MyThread.c: 3 | Small threading library, based off ctrulib. 4 | 5 | (c) TuxSH, 2016-2020 6 | This is part of 3ds_pxi, which is licensed under the MIT license (see LICENSE for details). 7 | */ 8 | 9 | #include "MyThread.h" 10 | 11 | static void _thread_begin(void* arg) 12 | { 13 | MyThread *t = (MyThread *)arg; 14 | t->ep(); 15 | MyThread_Exit(); 16 | } 17 | 18 | Result MyThread_Create(MyThread *t, void (*entrypoint)(void), void *stack, u32 stackSize, int prio, int affinity) 19 | { 20 | t->ep = entrypoint; 21 | t->stacktop = (u8 *)stack + stackSize; 22 | 23 | return svcCreateThread(&t->handle, _thread_begin, (u32)t, (u32*)t->stacktop, prio, affinity); 24 | } 25 | 26 | Result MyThread_Join(MyThread *thread, s64 timeout_ns) 27 | { 28 | if (thread == NULL) return 0; 29 | Result res = svcWaitSynchronization(thread->handle, timeout_ns); 30 | if(R_FAILED(res)) return res; 31 | 32 | svcCloseHandle(thread->handle); 33 | thread->handle = (Handle)0; 34 | 35 | return res; 36 | } 37 | 38 | void MyThread_Exit(void) 39 | { 40 | svcExitThread(); 41 | } 42 | -------------------------------------------------------------------------------- /sysmodules/pm/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019-2020 TuxSH 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /sysmodules/pxi/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-2020 TuxSH 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /sysmodules/sm/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017-2020 TuxSH 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/redshift/colorramp.h: -------------------------------------------------------------------------------- 1 | /* colorramp.h -- color temperature calculation header 2 | This file is part of Redshift. 3 | 4 | Redshift is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | Redshift is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with Redshift. If not, see . 16 | 17 | Copyright (c) 2010-2014 Jon Lund Steffensen 18 | */ 19 | 20 | #ifndef REDSHIFT_COLORRAMP_H 21 | #define REDSHIFT_COLORRAMP_H 22 | 23 | #include 24 | 25 | //#include "redshift.h" 26 | 27 | void colorramp_get_white_point(float *out_white_point, int temperature); // not in original code 28 | 29 | #endif /* ! REDSHIFT_COLORRAMP_H */ 30 | -------------------------------------------------------------------------------- /k11_extension/source/svc/ExitProcess.c: -------------------------------------------------------------------------------- 1 | #include "svc/ExitProcess.h" 2 | 3 | void ExitProcessHook(void) { 4 | KProcess *currentProcess = currentCoreContext->objectContext.currentProcess; 5 | u32 flags = KPROCESS_GET_RVALUE(currentProcess, customFlags); 6 | 7 | if (flags & SignalOnExit) 8 | { 9 | // Signal that the process is about to be terminated 10 | if (PLG_GetStatus() == PLG_CFG_RUNNING) 11 | PLG_SignalEvent(PLG_CFG_EXIT_EVENT); 12 | 13 | // Unlock all threads that might be locked 14 | { 15 | KRecursiveLock__Lock(criticalSectionLock); 16 | 17 | for (KLinkedListNode *node = threadList->list.nodes.first; 18 | node != (KLinkedListNode *)&threadList->list.nodes; 19 | node = node->next) 20 | { 21 | KThread *thread = (KThread *)node->key; 22 | 23 | if (thread->ownerProcess == currentProcess && thread->schedulingMask & 0x20) 24 | thread->schedulingMask &= ~0x20; 25 | } 26 | 27 | KRecursiveLock__Unlock(criticalSectionLock); 28 | } 29 | } 30 | 31 | return ((void(*)())officialSVCs[0x3])(); 32 | } -------------------------------------------------------------------------------- /sysmodules/rosalina/include/gdb/thread.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS. 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * SPDX-License-Identifier: (MIT OR GPL-2.0-or-later) 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "gdb.h" 11 | 12 | static inline u32 GDB_ConvertFromRealPid(u32 pid) 13 | { 14 | return pid + 1; 15 | } 16 | 17 | static inline u32 GDB_ConvertToRealPid(u32 pid) 18 | { 19 | return pid - 1; 20 | } 21 | 22 | const char *GDB_ParseThreadId(GDBContext *ctx, u32 *outPid, u32 *outTid, const char *str, char lastSep); 23 | u32 GDB_ParseDecodeSingleThreadId(GDBContext *ctx, const char *str, char lastSep); 24 | int GDB_EncodeThreadId(GDBContext *ctx, char *outbuf, u32 tid); 25 | 26 | u32 GDB_GetCurrentThreadFromList(GDBContext *ctx, u32 *threadIds, u32 nbThreads); 27 | u32 GDB_GetCurrentThread(GDBContext *ctx); 28 | 29 | GDB_DECLARE_HANDLER(SetThreadId); 30 | GDB_DECLARE_HANDLER(IsThreadAlive); 31 | 32 | GDB_DECLARE_QUERY_HANDLER(CurrentThreadId); 33 | GDB_DECLARE_QUERY_HANDLER(fThreadInfo); 34 | GDB_DECLARE_QUERY_HANDLER(sThreadInfo); 35 | GDB_DECLARE_QUERY_HANDLER(ThreadEvents); 36 | GDB_DECLARE_QUERY_HANDLER(ThreadExtraInfo); 37 | GDB_DECLARE_QUERY_HANDLER(GetTLSAddr); 38 | -------------------------------------------------------------------------------- /sysmodules/loader/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Yifan Lu 4 | Copyright (c) 2016-2020 AuroraWright, TuxSH 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /sysmodules/pm/source/luma.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include <3ds/types.h> 4 | 5 | #define CONFIG(a) (((config >> (a)) & 1) != 0) 6 | #define MULTICONFIG(a) ((multiConfig >> (2 * (a))) & 3) 7 | #define BOOTCONFIG(a, b) ((bootConfig >> (a)) & (b)) 8 | 9 | #define BOOTCFG_NAND BOOTCONFIG(0, 1) 10 | #define BOOTCFG_EMUINDEX BOOTCONFIG(1, 3) 11 | #define BOOTCFG_NOFORCEFLAG BOOTCONFIG(3, 1) 12 | #define BOOTCFG_NTRCARDBOOT BOOTCONFIG(4, 1) 13 | 14 | enum multiOptions 15 | { 16 | DEFAULTEMU = 0, 17 | BRIGHTNESS, 18 | SPLASH, 19 | PIN, 20 | NEWCPU, 21 | AUTOBOOTMODE, 22 | FORCEAUDIOOUTPUT, 23 | }; 24 | 25 | enum singleOptions 26 | { 27 | AUTOBOOTEMU = 0, 28 | LOADEXTFIRMSANDMODULES, 29 | PATCHGAMES, 30 | REDIRECTAPPTHREADS, 31 | PATCHVERSTRING, 32 | SHOWGBABOOT, 33 | ENABLEDSIEXTFILTER, 34 | ALLOWUPDOWNLEFTRIGHTDSI, 35 | PATCHUNITINFO, 36 | DISABLEARM11EXCHANDLERS, 37 | ENABLESAFEFIRMROSALINA, 38 | }; 39 | 40 | extern u32 config, multiConfig, bootConfig; 41 | 42 | void readLumaConfig(void); 43 | bool hasKExt(void); 44 | u32 getKExtSize(void); 45 | u32 getStolenSystemMemRegionSize(void); 46 | bool isTitleLaunchPrevented(u64 titleId); 47 | -------------------------------------------------------------------------------- /sendfile.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | #-*- coding: utf-8 -*- 3 | from ftplib import FTP 4 | import time 5 | import tarfile 6 | import os 7 | import sys 8 | 9 | 10 | from ftplib import FTP 11 | 12 | def ftpconnect(host, port, username, password): 13 | ftp = FTP() 14 | # ftp.set_debuglevel(2) 15 | ftp.connect(host, int(port)) 16 | ftp.login(username, password) 17 | return ftp 18 | 19 | #从ftp下载文件 20 | def downloadfile(ftp, remotepath, localpath): 21 | bufsize = 1024 22 | fp = open(localpath, 'wb') 23 | ftp.retrbinary('RETR ' + remotepath, fp.write, bufsize) 24 | ftp.set_debuglevel(0) 25 | fp.close() 26 | 27 | #从本地上传文件到ftp 28 | def uploadfile(ftp, remotepath, localpath): 29 | bufsize = 1024 30 | fp = open(localpath, 'rb') 31 | ftp.storbinary('STOR ' + remotepath, fp, bufsize) 32 | ftp.set_debuglevel(0) 33 | fp.close() 34 | 35 | if __name__ == "__main__": 36 | ip = sys.argv[1] 37 | port = sys.argv[2] 38 | # username = sys.argv[3] 39 | # password = sys.argv[4] 40 | localfilepath = sys.argv[3] 41 | remotefilename = sys.argv[4] 42 | ftp = ftpconnect(ip, port, "", "") 43 | uploadfile(ftp, localfilepath, remotefilename) 44 | ftp.quit() 45 | 46 | -------------------------------------------------------------------------------- /k11_extension/include/config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types.h" 4 | 5 | #define MAKE_BRANCH(src,dst) (0xEA000000 | ((u32)((((u8 *)(dst) - (u8 *)(src)) >> 2) - 2) & 0xFFFFFF)) 6 | #define MAKE_BRANCH_LINK(src,dst) (0xEB000000 | ((u32)((((u8 *)(dst) - (u8 *)(src)) >> 2) - 2) & 0xFFFFFF)) 7 | 8 | #define CONFIG(a) (((cfwInfo.config >> (a)) & 1) != 0) 9 | #define MULTICONFIG(a) ((cfwInfo.multiConfig >> (2 * (a))) & 3) 10 | #define BOOTCONFIG(a, b) ((cfwInfo.bootConfig >> (a)) & (b)) 11 | 12 | #define BOOTCFG_NAND BOOTCONFIG(0, 1) 13 | #define BOOTCFG_EMUINDEX BOOTCONFIG(1, 3) 14 | #define BOOTCFG_NOFORCEFLAG BOOTCONFIG(3, 1) 15 | #define BOOTCFG_NTRCARDBOOT BOOTCONFIG(4, 1) 16 | 17 | enum multiOptions 18 | { 19 | DEFAULTEMU = 0, 20 | BRIGHTNESS, 21 | SPLASH, 22 | PIN, 23 | NEWCPU, 24 | AUTOBOOTMODE, 25 | FORCEAUDIOOUTPUT, 26 | }; 27 | 28 | enum singleOptions 29 | { 30 | AUTOBOOTEMU = 0, 31 | LOADEXTFIRMSANDMODULES, 32 | PATCHGAMES, 33 | REDIRECTAPPTHREADS, 34 | PATCHVERSTRING, 35 | SHOWGBABOOT, 36 | ENABLEDSIEXTFILTER, 37 | ALLOWUPDOWNLEFTRIGHTDSI, 38 | PATCHUNITINFO, 39 | DISABLEARM11EXCHANDLERS, 40 | ENABLESAFEFIRMROSALINA, 41 | }; 42 | -------------------------------------------------------------------------------- /sysmodules/pm/source/luma.c: -------------------------------------------------------------------------------- 1 | #include <3ds.h> 2 | #include 3 | #include "luma.h" 4 | #include "util.h" 5 | 6 | u32 config, multiConfig, bootConfig; 7 | 8 | void readLumaConfig(void) 9 | { 10 | s64 out = 0; 11 | bool isLumaWithKext = svcGetSystemInfo(&out, 0x20000, 0) == 1; 12 | if (isLumaWithKext) 13 | { 14 | svcGetSystemInfo(&out, 0x10000, 3); 15 | config = (u32)out; 16 | svcGetSystemInfo(&out, 0x10000, 4); 17 | multiConfig = (u32)out; 18 | svcGetSystemInfo(&out, 0x10000, 5); 19 | bootConfig = (u32)out; 20 | } 21 | } 22 | 23 | bool hasKExt(void) 24 | { 25 | s64 val; 26 | return svcGetSystemInfo(&val, 0x20000, 0) == 1; 27 | } 28 | 29 | u32 getKExtSize(void) 30 | { 31 | s64 val; 32 | svcGetSystemInfo(&val, 0x10000, 0x300); 33 | return (u32)val; 34 | } 35 | 36 | u32 getStolenSystemMemRegionSize(void) 37 | { 38 | s64 val; 39 | svcGetSystemInfo(&val, 0x10000, 0x301); 40 | return (u32)val; 41 | } 42 | 43 | bool isTitleLaunchPrevented(u64 titleId) 44 | { 45 | s64 numKips = 0; 46 | 47 | svcGetSystemInfo(&numKips, 26, 0); 48 | return numKips >= 6 && (titleId & ~(N3DS_TID_MASK | 1)) == 0x0004003000008A02ULL; // ErrDisp 49 | } 50 | -------------------------------------------------------------------------------- /sysmodules/sm/source/processes.h: -------------------------------------------------------------------------------- 1 | /* 2 | processes.h 3 | 4 | (c) TuxSH, 2017-2020 5 | This is part of 3ds_sm, which is licensed under the MIT license (see LICENSE for details). 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "common.h" 11 | 12 | struct ProcessDataList; 13 | 14 | typedef struct ProcessData 15 | { 16 | struct ProcessData *prev, *next; 17 | struct ProcessDataList *parent; 18 | 19 | u32 pid; 20 | 21 | Handle notificationSemaphore; 22 | 23 | char (*serviceAccessList)[8]; 24 | u32 serviceAccessListSize; 25 | 26 | bool notificationEnabled; 27 | // Circular buffer 28 | u16 receivedNotificationIndex; 29 | u16 pendingNotificationIndex; 30 | 31 | u16 nbPendingNotifications; 32 | u32 pendingNotifications[16]; 33 | u16 nbSubscribed; 34 | u32 subscribedNotifications[17]; 35 | } ProcessData; 36 | 37 | typedef struct ProcessDataList 38 | { 39 | ProcessData *first, *last; 40 | } ProcessDataList; 41 | 42 | extern ProcessDataList processDataInUseList, freeProcessDataList; 43 | 44 | ProcessData *findProcessData(u32 pid); 45 | ProcessData *doRegisterProcess(u32 pid, char (*serviceAccessList)[8], u32 serviceAccessListSize); 46 | 47 | Result RegisterProcess(u32 pid, char (*serviceAccessList)[8], u32 serviceAccessListSize); 48 | Result UnregisterProcess(u32 pid); 49 | -------------------------------------------------------------------------------- /sysmodules/sm/source/services.h: -------------------------------------------------------------------------------- 1 | /* 2 | services.h 3 | 4 | (c) TuxSH, 2017-2020 5 | This is part of 3ds_sm, which is licensed under the MIT license (see LICENSE for details). 6 | */ 7 | 8 | #pragma once 9 | 10 | #include <3ds.h> 11 | 12 | #include "common.h" 13 | 14 | typedef struct ServiceInfo 15 | { 16 | char name[8]; 17 | Handle clientPort; 18 | u32 pid; 19 | bool isNamedPort; 20 | } ServiceInfo; 21 | 22 | extern ServiceInfo servicesInfo[0xA0]; 23 | extern u32 nbServices; 24 | 25 | Result doRegisterService(u32 pid, Handle *serverPort, const char *name, s32 nameSize, s32 maxSessions); 26 | Result RegisterService(SessionData *sessionData, Handle *serverPort, const char *name, s32 nameSize, s32 maxSessions); 27 | Result RegisterPort(SessionData *sessionData, Handle clientPort, const char *name, s32 nameSize); 28 | Result UnregisterService(SessionData *sessionData, const char *name, s32 nameSize); 29 | Result UnregisterPort(SessionData *sessionData, const char *name, s32 nameSize); 30 | Result IsServiceRegistered(SessionData *SessionData, bool *isRegistered, const char *name, s32 nameSize); 31 | Result GetServiceHandle(SessionData *sessionData, Handle *session, const char *name, s32 nameSize, u32 flags); 32 | Result GetPort(SessionData *sessionData, Handle *port, const char *name, s32 nameSize, u8 flags); 33 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/gdb/server.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS. 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * SPDX-License-Identifier: (MIT OR GPL-2.0-or-later) 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "gdb.h" 11 | 12 | #ifndef GDB_PORT_BASE 13 | #define GDB_PORT_BASE 4000 14 | #endif 15 | 16 | typedef struct GDBServer 17 | { 18 | sock_server super; 19 | s32 referenceCount; 20 | Handle statusUpdated; 21 | Handle statusUpdateReceived; 22 | GDBContext ctxs[MAX_DEBUG]; 23 | } GDBServer; 24 | 25 | Result GDB_InitializeServer(GDBServer *server); 26 | void GDB_FinalizeServer(GDBServer *server); 27 | 28 | void GDB_IncrementServerReferenceCount(GDBServer *server); 29 | void GDB_DecrementServerReferenceCount(GDBServer *server); 30 | 31 | void GDB_RunServer(GDBServer *server); 32 | 33 | void GDB_LockAllContexts(GDBServer *server); 34 | void GDB_UnlockAllContexts(GDBServer *server); 35 | 36 | GDBContext *GDB_SelectAvailableContext(GDBServer *server, u16 minPort, u16 maxPort); 37 | GDBContext *GDB_FindAllocatedContextByPid(GDBServer *server, u32 pid); 38 | 39 | int GDB_AcceptClient(GDBContext *ctx); 40 | int GDB_CloseClient(GDBContext *ctx); 41 | GDBContext *GDB_GetClient(GDBServer *server, u16 port); 42 | void GDB_ReleaseClient(GDBServer *server, GDBContext *ctx); 43 | int GDB_DoPacket(GDBContext *ctx); 44 | -------------------------------------------------------------------------------- /sysmodules/rosalina/source/plugin/swapFunc.s: -------------------------------------------------------------------------------- 1 | .section .text 2 | .balign 4 3 | .arm 4 | 5 | .global saveSwapFunc 6 | .type saveSwapFunc, %function 7 | saveSwapFunc: 8 | BX LR 9 | NOP 10 | NOP 11 | NOP 12 | NOP 13 | NOP 14 | NOP 15 | NOP 16 | NOP 17 | NOP 18 | NOP 19 | NOP 20 | NOP 21 | NOP 22 | NOP 23 | NOP 24 | NOP 25 | NOP 26 | NOP 27 | NOP 28 | NOP 29 | NOP 30 | NOP 31 | NOP 32 | NOP 33 | NOP 34 | NOP 35 | NOP 36 | NOP 37 | NOP 38 | NOP 39 | NOP 40 | 41 | .global loadSwapFunc 42 | .type loadSwapFunc, %function 43 | loadSwapFunc: 44 | BX LR 45 | NOP 46 | NOP 47 | NOP 48 | NOP 49 | NOP 50 | NOP 51 | NOP 52 | NOP 53 | NOP 54 | NOP 55 | NOP 56 | NOP 57 | NOP 58 | NOP 59 | NOP 60 | NOP 61 | NOP 62 | NOP 63 | NOP 64 | NOP 65 | NOP 66 | NOP 67 | NOP 68 | NOP 69 | NOP 70 | NOP 71 | NOP 72 | NOP 73 | NOP 74 | NOP 75 | NOP 76 | 77 | .global loadExeFunc 78 | .type loadExeFunc, %function 79 | loadExeFunc: 80 | BX LR 81 | NOP 82 | NOP 83 | NOP 84 | NOP 85 | NOP 86 | NOP 87 | NOP 88 | NOP 89 | NOP 90 | NOP 91 | NOP 92 | NOP 93 | NOP 94 | NOP 95 | NOP 96 | NOP 97 | NOP 98 | NOP 99 | NOP 100 | NOP 101 | NOP 102 | NOP 103 | NOP 104 | NOP 105 | NOP 106 | NOP 107 | NOP 108 | NOP 109 | NOP 110 | NOP 111 | NOP -------------------------------------------------------------------------------- /k11_extension/include/svcHandler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | void svcHandler(void); 30 | -------------------------------------------------------------------------------- /sysmodules/pm/source/exheader_info_heap.c: -------------------------------------------------------------------------------- 1 | #include <3ds.h> 2 | #include 3 | #include 4 | 5 | typedef union Node { 6 | union Node *next; 7 | ExHeader_Info info; 8 | } Node; 9 | 10 | static Node *g_headNode = NULL; 11 | 12 | void ExHeaderInfoHeap_Init(void *buf, size_t num) 13 | { 14 | Node *node = (Node *)buf; 15 | g_headNode = node; 16 | for (size_t i = 0; i < num; i++) { 17 | node->next = &node[1]; 18 | node = node->next; 19 | } 20 | } 21 | 22 | ExHeader_Info *ExHeaderInfoHeap_New(void) 23 | { 24 | Node *newHead; 25 | Node *oldHead = atomic_load(&g_headNode); 26 | if (oldHead == NULL) { 27 | return NULL; 28 | } else { 29 | do { 30 | newHead = oldHead == NULL ? oldHead : oldHead->next; 31 | } while(!atomic_compare_exchange_weak(&g_headNode, &oldHead, newHead)); 32 | 33 | if (oldHead == NULL) { 34 | return NULL; 35 | } 36 | else { 37 | memset(&oldHead->info, 0, sizeof(ExHeader_Info)); 38 | return &oldHead->info; 39 | } 40 | } 41 | } 42 | 43 | void ExHeaderInfoHeap_Delete(ExHeader_Info *data) 44 | { 45 | Node *newHead = (Node *)data; 46 | Node *oldHead = atomic_load(&g_headNode); 47 | do { 48 | newHead->next = oldHead; 49 | } while(!atomic_compare_exchange_weak(&g_headNode, &oldHead, newHead)); 50 | } 51 | 52 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/shell.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2023 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #include <3ds/types.h> 28 | 29 | void handleShellOpened(void); 30 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/bootdiag.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2022 TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | #include "MyThread.h" 29 | 30 | MyThread *bootdiagCreateThread(void); 31 | -------------------------------------------------------------------------------- /arm9/source/alignedseqmemcpy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | #include "types.h" 27 | 28 | void *alignedseqmemcpy(void *dst, const void *src, u32 len); 29 | -------------------------------------------------------------------------------- /k11_extension/source/svc/SetGpuProt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #include "svc/SetGpuProt.h" 28 | 29 | Result SetGpuProt(bool prot UNUSED) 30 | { 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /sysmodules/pm/source/task_runner.c: -------------------------------------------------------------------------------- 1 | #include <3ds.h> 2 | #include 3 | #include "task_runner.h" 4 | 5 | TaskRunner g_taskRunner; 6 | 7 | static void taskRunnerNoOpFunction(void *args) 8 | { 9 | (void)args; 10 | } 11 | 12 | void TaskRunner_Init(void) 13 | { 14 | memset(&g_taskRunner, 0, sizeof(TaskRunner)); 15 | LightEvent_Init(&g_taskRunner.readyEvent, RESET_ONESHOT); 16 | LightEvent_Init(&g_taskRunner.parametersSetEvent, RESET_ONESHOT); 17 | } 18 | 19 | void TaskRunner_RunTask(void (*task)(void *argdata), void *argdata, size_t argsize) 20 | { 21 | argsize = argsize > sizeof(g_taskRunner.argStorage) ? sizeof(g_taskRunner.argStorage) : argsize; 22 | LightEvent_Wait(&g_taskRunner.readyEvent); 23 | g_taskRunner.task = task; 24 | memcpy(g_taskRunner.argStorage, argdata, argsize); 25 | LightEvent_Signal(&g_taskRunner.parametersSetEvent); 26 | } 27 | 28 | void TaskRunner_Terminate(void) 29 | { 30 | g_taskRunner.shouldTerminate = true; 31 | TaskRunner_RunTask(taskRunnerNoOpFunction, NULL, 0); 32 | } 33 | 34 | void TaskRunner_HandleTasks(void *p) 35 | { 36 | (void)p; 37 | while (!g_taskRunner.shouldTerminate) { 38 | LightEvent_Signal(&g_taskRunner.readyEvent); 39 | LightEvent_Wait(&g_taskRunner.parametersSetEvent); 40 | g_taskRunner.task(g_taskRunner.argStorage); 41 | } 42 | } 43 | 44 | void TaskRunner_WaitReady(void) 45 | { 46 | LightEvent_Wait(&g_taskRunner.readyEvent); 47 | } 48 | -------------------------------------------------------------------------------- /arm9/source/chainloader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "types.h" 30 | #include "firm.h" 31 | 32 | void chainload(int argc, char **argv, Firm *firm); 33 | -------------------------------------------------------------------------------- /arm9/source/strings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "types.h" 30 | 31 | u32 hexAtoi(const char *in, u32 digits); 32 | u32 decAtoi(const char *in, u32 digits); 33 | -------------------------------------------------------------------------------- /k11_extension/include/svc/Backdoor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "utils.h" 30 | #include "kernel.h" 31 | #include "svc.h" 32 | 33 | void Backdoor(void *function); 34 | -------------------------------------------------------------------------------- /k11_extension/include/svc/SetGpuProt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "utils.h" 30 | #include "kernel.h" 31 | #include "svc.h" 32 | 33 | Result SetGpuProt(bool prot); 34 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/sleep.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2018 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | void Sleep__Init(void); 30 | void Sleep__HandleNotification(u32 notifId); 31 | bool Sleep__Status(void); 32 | -------------------------------------------------------------------------------- /k11_extension/include/svc/Break.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "utils.h" 30 | #include "kernel.h" 31 | 32 | void __attribute__((noreturn)) Break(UserBreakType type, ...); 33 | -------------------------------------------------------------------------------- /k11_extension/include/svc/SetWifiEnabled.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "utils.h" 30 | #include "kernel.h" 31 | #include "svc.h" 32 | 33 | Result SetWifiEnabled(bool enable); 34 | -------------------------------------------------------------------------------- /k11_extension/include/svc/CustomBackdoor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "utils.h" 30 | #include "kernel.h" 31 | #include "svc.h" 32 | 33 | void CustomBackdoor(void *function, ...); 34 | -------------------------------------------------------------------------------- /k11_extension/include/svc/SendSyncRequest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "utils.h" 30 | #include "kernel.h" 31 | #include "svc.h" 32 | 33 | Result SendSyncRequestHook(Handle handle); 34 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/menus/process_list.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include <3ds/types.h> 30 | 31 | #define PROCESSES_PER_MENU_PAGE 18 32 | 33 | void RosalinaMenu_ProcessList(void); 34 | -------------------------------------------------------------------------------- /arm9/source/fmt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | #include "memory.h" 29 | #include 30 | 31 | int vsprintf(char *buf, const char *fmt, va_list args); 32 | int sprintf(char *buf, const char *fmt, ...); 33 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/luminance.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include <3ds/types.h> 30 | 31 | u32 getMinLuminancePreset(void); 32 | u32 getMaxLuminancePreset(void); 33 | u32 getCurrentLuminance(bool top); 34 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/fmt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | #include "memory.h" 29 | #include 30 | 31 | int vsprintf(char *buf, const char *fmt, va_list args); 32 | int sprintf(char *buf, const char *fmt, ...); 33 | -------------------------------------------------------------------------------- /k11_extension/include/svc/UnmapProcessMemoryEx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "utils.h" 30 | #include "kernel.h" 31 | #include "svc.h" 32 | 33 | Result UnmapProcessMemoryEx(Handle processHandle, void *dst, u32 size); 34 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/errdisp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include <3ds/types.h> 30 | #include "MyThread.h" 31 | 32 | MyThread *errDispCreateThread(void); 33 | void ERRF_HandleCommands(void); 34 | void errDispThreadMain(void); 35 | -------------------------------------------------------------------------------- /arm9/source/arm9_exception_handlers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #include "types.h" 28 | 29 | extern const u32 arm9ExceptionHandlerAddressTable[6]; 30 | extern u32 arm9ExceptionHandlerSvcBreakAddress; 31 | 32 | u32 safecpy(void *dst, const void *src, u32 len); 33 | -------------------------------------------------------------------------------- /k11_extension/source/svc/Break.s: -------------------------------------------------------------------------------- 1 | @ This file is part of Luma3DS 2 | @ Copyright (C) 2016-2020 Aurora Wright, TuxSH 3 | @ 4 | @ This program is free software: you can redistribute it and/or modify 5 | @ it under the terms of the GNU General Public License as published by 6 | @ the Free Software Foundation, either version 3 of the License, or 7 | @ (at your option) any later version. 8 | @ 9 | @ This program is distributed in the hope that it will be useful, 10 | @ but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | @ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | @ GNU General Public License for more details. 13 | @ 14 | @ You should have received a copy of the GNU General Public License 15 | @ along with this program. If not, see . 16 | @ 17 | @ Additional Terms 7.b and 7.c of GPLv3 apply to this file: 18 | @ * Requiring preservation of specified reasonable legal notices or 19 | @ author attributions in that material or in the Appropriate Legal 20 | @ Notices displayed by works containing it. 21 | @ * Prohibiting misrepresentation of the origin of that material, 22 | @ or requiring that modified versions of such material be marked in 23 | @ reasonable ways as different from the original version. 24 | 25 | .text 26 | .arm 27 | .balign 4 28 | 29 | .global Break 30 | .type Break, %function 31 | Break: 32 | bic r0, sp, #0xf00 33 | bic r0, #0xff 34 | add r0, #0x1000 @ get page context top 35 | bkpt 0xffff 36 | -------------------------------------------------------------------------------- /k11_extension/source/svc/SetWifiEnabled.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #include "svc/SetWifiEnabled.h" 28 | 29 | Result SetWifiEnabled(bool enable) 30 | { 31 | if(enable) 32 | CFG11_WIFICNT |= 1; 33 | else 34 | CFG11_WIFICNT &= ~1; 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /k11_extension/include/svc/ConnectToPort.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "utils.h" 30 | #include "kernel.h" 31 | #include "svc.h" 32 | 33 | Result ConnectToPortHookWrapper(u32 dummy, const char *name); 34 | Result ConnectToPortHook(Handle *out, const char *name); 35 | -------------------------------------------------------------------------------- /k11_extension/include/svc/GetSystemInfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "utils.h" 30 | #include "kernel.h" 31 | #include "svc.h" 32 | 33 | Result GetSystemInfoHookWrapper(u32 dummy, s32 type, s32 param); 34 | Result GetSystemInfoHook(s64 *out, s32 type, s32 param); 35 | -------------------------------------------------------------------------------- /k11_extension/include/svc/GetHandleInfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "utils.h" 30 | #include "kernel.h" 31 | #include "svc.h" 32 | 33 | Result GetHandleInfoHookWrapper(u32 dummy, Handle handle, u32 type); 34 | Result GetHandleInfoHook(s64 *out, Handle handle, u32 type); 35 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/menus/n3ds.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include <3ds/types.h> 30 | #include "menu.h" 31 | 32 | extern Menu N3DSMenu; 33 | 34 | void N3DSMenu_UpdateStatus(void); 35 | void N3DSMenu_ChangeClockRate(void); 36 | void N3DSMenu_EnableDisableL2Cache(void); 37 | -------------------------------------------------------------------------------- /arm9/source/exceptions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "types.h" 30 | 31 | void installArm9Handlers(void); 32 | u32 installArm11Handlers(u32 *exceptionsPage, u32 stackAddress, u32 codeSetOffset, u32 *dAbtHandler, u32 dAbtHandlerMemAddress); 33 | void detectAndProcessExceptionDumps(void); 34 | -------------------------------------------------------------------------------- /k11_extension/include/svc/GetThreadInfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "utils.h" 30 | #include "kernel.h" 31 | #include "svc.h" 32 | 33 | Result GetThreadInfoHookWrapper(u32 dummy, Handle threadHandle, u32 type); 34 | Result GetThreadInfoHook(s64 *out, Handle threadHandle, u32 type); 35 | -------------------------------------------------------------------------------- /k11_extension/source/svc/CustomBackdoor.s: -------------------------------------------------------------------------------- 1 | @ This file is part of Luma3DS 2 | @ Copyright (C) 2016-2020 Aurora Wright, TuxSH 3 | @ 4 | @ This program is free software: you can redistribute it and/or modify 5 | @ it under the terms of the GNU General Public License as published by 6 | @ the Free Software Foundation, either version 3 of the License, or 7 | @ (at your option) any later version. 8 | @ 9 | @ This program is distributed in the hope that it will be useful, 10 | @ but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | @ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | @ GNU General Public License for more details. 13 | @ 14 | @ You should have received a copy of the GNU General Public License 15 | @ along with this program. If not, see . 16 | @ 17 | @ Additional Terms 7.b and 7.c of GPLv3 apply to this file: 18 | @ * Requiring preservation of specified reasonable legal notices or 19 | @ author attributions in that material or in the Appropriate Legal 20 | @ Notices displayed by works containing it. 21 | @ * Prohibiting misrepresentation of the origin of that material, 22 | @ or requiring that modified versions of such material be marked in 23 | @ reasonable ways as different from the original version. 24 | 25 | .text 26 | .arm 27 | .balign 4 28 | 29 | .global CustomBackdoor 30 | .type CustomBackdoor, %function 31 | CustomBackdoor: 32 | push {r4, lr} 33 | mov r4, r0 34 | mov r0, r1 35 | mov r1, r2 36 | mov r2, r3 37 | blx r4 38 | pop {r4, pc} 39 | -------------------------------------------------------------------------------- /arm9/source/deliver_arg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2022 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "types.h" 30 | 31 | u8 *loadDeliverArg(void); 32 | void commitDeliverArg(void); 33 | 34 | bool hasValidTlncAutobootParams(void); 35 | bool isTwlToCtrLaunch(void); // assumes TLNC block is valid 36 | 37 | bool configureHomebrewAutoboot(void); 38 | -------------------------------------------------------------------------------- /k11_extension/include/svc/GetProcessInfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "utils.h" 30 | #include "kernel.h" 31 | #include "svc.h" 32 | 33 | Result GetProcessInfoHookWrapper(u32 dummy, Handle processHandle, u32 type); 34 | Result GetProcessInfoHook(s64 *out, Handle processHandle, u32 type); 35 | -------------------------------------------------------------------------------- /sysmodules/pm/source/luma_shared_config.h: -------------------------------------------------------------------------------- 1 | /* This paricular file is licensed under the following terms: */ 2 | 3 | /* 4 | * This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable 5 | * for any damages arising from the use of this software. 6 | * 7 | * Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it 8 | * and redistribute it freely, subject to the following restrictions: 9 | * 10 | * The origin of this software must not be misrepresented; you must not claim that you wrote the original software. 11 | * If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 12 | * 13 | * Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 14 | * This notice may not be removed or altered from any source distribution. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include <3ds/types.h> 20 | 21 | /// Luma shared config type (private!). 22 | typedef struct LumaSharedConfig { 23 | u64 hbldr_3dsx_tid; ///< Title ID to use for 3DSX loading (current). 24 | u64 selected_hbldr_3dsx_tid; ///< Title ID to use for 3DSX loading (to be moved to "current" when the current app closes). 25 | bool use_hbldr; ///< Whether or not Loader should use hb:ldr (reset to true). 26 | } LumaSharedConfig; 27 | 28 | /// Luma shared config. 29 | #define Luma_SharedConfig ((volatile LumaSharedConfig *)(OS_SHAREDCFG_VADDR + 0x800)) 30 | -------------------------------------------------------------------------------- /sysmodules/loader/source/luma_shared_config.h: -------------------------------------------------------------------------------- 1 | /* This paricular file is licensed under the following terms: */ 2 | 3 | /* 4 | * This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable 5 | * for any damages arising from the use of this software. 6 | * 7 | * Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it 8 | * and redistribute it freely, subject to the following restrictions: 9 | * 10 | * The origin of this software must not be misrepresented; you must not claim that you wrote the original software. 11 | * If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 12 | * 13 | * Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 14 | * This notice may not be removed or altered from any source distribution. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include <3ds/types.h> 20 | 21 | /// Luma shared config type (private!). 22 | typedef struct LumaSharedConfig { 23 | u64 hbldr_3dsx_tid; ///< Title ID to use for 3DSX loading (current). 24 | u64 selected_hbldr_3dsx_tid; ///< Title ID to use for 3DSX loading (to be moved to "current" when the current app closes). 25 | bool use_hbldr; ///< Whether or not Loader should use hb:ldr (reset to true). 26 | } LumaSharedConfig; 27 | 28 | /// Luma shared config. 29 | #define Luma_SharedConfig ((volatile LumaSharedConfig *)(OS_SHAREDCFG_VADDR + 0x800)) 30 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/luma_shared_config.h: -------------------------------------------------------------------------------- 1 | /* This paricular file is licensed under the following terms: */ 2 | 3 | /* 4 | * This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable 5 | * for any damages arising from the use of this software. 6 | * 7 | * Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it 8 | * and redistribute it freely, subject to the following restrictions: 9 | * 10 | * The origin of this software must not be misrepresented; you must not claim that you wrote the original software. 11 | * If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 12 | * 13 | * Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 14 | * This notice may not be removed or altered from any source distribution. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include <3ds/types.h> 20 | 21 | /// Luma shared config type (private!). 22 | typedef struct LumaSharedConfig { 23 | u64 hbldr_3dsx_tid; ///< Title ID to use for 3DSX loading (current). 24 | u64 selected_hbldr_3dsx_tid; ///< Title ID to use for 3DSX loading (to be moved to "current" when the current app closes). 25 | bool use_hbldr; ///< Whether or not Loader should use hb:ldr (reset to true). 26 | } LumaSharedConfig; 27 | 28 | /// Luma shared config. 29 | #define Luma_SharedConfig ((volatile LumaSharedConfig *)(OS_SHAREDCFG_VADDR + 0x800)) 30 | -------------------------------------------------------------------------------- /k11_extension/include/svc/TranslateHandle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "utils.h" 30 | #include "kernel.h" 31 | #include "svc.h" 32 | 33 | Result TranslateHandleWrapper(u32 *outKAddr, char *outClassName, Handle handle); 34 | Result TranslateHandle(u32 *outKAddr, char *outClassName, Handle handle); 35 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/menus/cheats.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | /* This file was entirely written by Duckbill */ 28 | 29 | #pragma once 30 | 31 | #include <3ds/types.h> 32 | 33 | #define CHEATS_PER_MENU_PAGE 9 34 | 35 | void RosalinaMenu_Cheats(void); 36 | void Cheat_SeedRng(u64 seed); 37 | void Cheat_ApplyCheats(void); 38 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/ntp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2021 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include <3ds/types.h> 30 | #include 31 | 32 | Result ntpGetTimeStamp(u64 *msSince1900, u64 *samplingTick); 33 | Result ntpSetTimeDate(u64 msSince1900, u64 samplingTick); 34 | Result ntpNullifyUserTimeOffset(void); // not actually used for NTP 35 | -------------------------------------------------------------------------------- /arm9/source/pin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | /* 28 | * Code originally by reworks 29 | */ 30 | 31 | #pragma once 32 | 33 | #include "types.h" 34 | 35 | #define PIN_FILE "pin.bin" 36 | #define PIN_VERSIONMAJOR 1 37 | #define PIN_VERSIONMINOR 3 38 | 39 | void newPin(bool allowSkipping, u32 pinMode); 40 | bool verifyPin(u32 pinMode); 41 | -------------------------------------------------------------------------------- /k11_extension/include/svc/ControlMemoryUnsafe.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2018 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "utils.h" 30 | #include "kernel.h" 31 | #include "svc.h" 32 | 33 | Result ControlMemoryUnsafe(u32 *out, u32 addr0, u32 size, MemOp op, MemPerm perm); 34 | Result ControlMemoryUnsafeWrapper(u32 *out, u32 addr0, u32 size, MemOp op, MemPerm perm); 35 | -------------------------------------------------------------------------------- /k11_extension/include/svc/KernelSetState.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "utils.h" 30 | #include "kernel.h" 31 | #include "svc.h" 32 | 33 | extern u8 svcSignalingEnabled; 34 | 35 | bool shouldSignalSyscallDebugEvent(KProcess *process, u8 svcId); 36 | Result KernelSetStateHook(u32 type, u32 varg1, u32 varg2, u32 varg3); 37 | -------------------------------------------------------------------------------- /k11_extension/include/svc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "types.h" 30 | #include "globals.h" 31 | #include "kernel.h" 32 | #include "utils.h" 33 | 34 | extern void *officialSVCs[0x7E]; 35 | extern void *alteredSvcTable[0x100]; 36 | 37 | void buildAlteredSvcTable(void); 38 | 39 | void postprocessSvc(void); 40 | void svcDefaultHandler(u8 svcId); 41 | -------------------------------------------------------------------------------- /k11_extension/include/svc/CreateThread.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2023 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #include "utils.h" 28 | #include "kernel.h" 29 | #include "svc.h" 30 | 31 | Result CreateThreadHookWrapper(Handle *outThreadHandle, u32 ep, u32 arg, u32 stackTop, s32 priority, s32 processorId); 32 | Result CreateThreadHook(Handle *outThreadHandle, u32 ep, u32 arg, u32 stackTop, s32 priority, s32 processorId); 33 | -------------------------------------------------------------------------------- /sysmodules/loader/README.md: -------------------------------------------------------------------------------- 1 | 3DS Loader Replacement 2 | ====================== 3 | 4 | This is an open source implementation of 3DS `loader` system module--with 5 | additional features. The current aim of the project is to provide a nice 6 | entry point for patching 3DS modules. 7 | 8 | ## Roadmap 9 | Right now, this can serve as an open-source replacement for the built in loader. 10 | There is additional support for patching any executable after it's loaded but 11 | before it starts. For example, you can patch `menu` to skip region checks and 12 | have region free game launching directly from the home menu. There is also 13 | support for SDMC reading (not found in original loader implementation) which 14 | means that patches can be loaded from the SD card. Ultimately, there would be 15 | a patch system that supports easy loading of patches from the SD card. 16 | 17 | ## Build 18 | You need a working 3DS build environment with a fairly recent copy of devkitARM, 19 | ctrulib, and makerom. If you see any errors in the build process, it's likely 20 | that you're using an older version. 21 | 22 | Currently, there is no support for FIRM building, so you need to do some steps 23 | manually. First, you have to add padding to make sure the NCCH is of the right 24 | size to drop in as a replacement. A hacky way is 25 | [this patch](http://pastebin.com/nyKXLnNh) which adds junk data. Play around 26 | with the size value to get the NCCH to be the exact same size as the one 27 | found in your decrypted FIRM dump. 28 | 29 | Once you have a NCCH of the right size, just replace it in your decrypted FIRM 30 | and find a way to launch it (for example with ReiNAND). 31 | -------------------------------------------------------------------------------- /k11_extension/include/svc/CopyHandle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "utils.h" 30 | #include "kernel.h" 31 | #include "svc.h" 32 | 33 | Result CopyHandleWrapper(Handle *outHandle, Handle outProcessHandle, Handle inHandle, Handle inProcessHandle); 34 | Result CopyHandle(Handle *outHandle, Handle outProcessHandle, Handle inHandle, Handle inProcessHandle); 35 | -------------------------------------------------------------------------------- /k11_extension/include/svc/MapProcessMemoryEx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "utils.h" 30 | #include "kernel.h" 31 | #include "svc.h" 32 | 33 | Result MapProcessMemoryEx(Handle dstProcessHandle, u32 vaDst, Handle srcProcessHandle, u32 vaSrc, u32 size); 34 | Result MapProcessMemoryExWrapper(Handle dstProcessHandle, u32 vaDst, Handle srcProcessHandle, u32 vaSrc, u32 size); 35 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/gdb/net.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS. 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * SPDX-License-Identifier: (MIT OR GPL-2.0-or-later) 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "gdb.h" 11 | #define _REENT_ONLY 12 | #include 13 | 14 | u8 GDB_ComputeChecksum(const char *packetData, u32 len); 15 | void GDB_EncodeHex(char *dst, const void *src, u32 len); 16 | u32 GDB_DecodeHex(void *dst, const char *src, u32 len); 17 | u32 GDB_EscapeBinaryData(u32 *encodedCount, void *dst, const void *src, u32 len, u32 maxLen); 18 | u32 GDB_UnescapeBinaryData(void *dst, const void *src, u32 len); 19 | const char *GDB_ParseIntegerList(u32 *dst, const char *src, u32 nb, char sep, char lastSep, u32 base, bool allowPrefix); 20 | const char *GDB_ParseHexIntegerList(u32 *dst, const char *src, u32 nb, char lastSep); 21 | const char *GDB_ParseIntegerList64(u64 *dst, const char *src, u32 nb, char sep, char lastSep, u32 base, bool allowPrefix); 22 | const char *GDB_ParseHexIntegerList64(u64 *dst, const char *src, u32 nb, char lastSep); 23 | int GDB_ReceivePacket(GDBContext *ctx); 24 | int GDB_SendPacket(GDBContext *ctx, const char *packetData, u32 len); 25 | int GDB_SendFormattedPacket(GDBContext *ctx, const char *packetDataFmt, ...); 26 | int GDB_SendHexPacket(GDBContext *ctx, const void *packetData, u32 len); 27 | int GDB_SendStreamData(GDBContext *ctx, const char *streamData, u32 offset, u32 length, u32 totalSize, bool forceEmptyLast); 28 | int GDB_SendDebugString(GDBContext *ctx, const char *fmt, ...); // unsecure 29 | int GDB_ReplyEmpty(GDBContext *ctx); 30 | int GDB_ReplyOk(GDBContext *ctx); 31 | int GDB_ReplyErrno(GDBContext *ctx, int no); 32 | -------------------------------------------------------------------------------- /k11_extension/source/svc/ControlMemory.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #include "svc/ControlMemory.h" 28 | 29 | Result ControlMemoryHook(u32 *addrOut, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm) 30 | { 31 | KProcess *currentProcess = currentCoreContext->objectContext.currentProcess; 32 | return ControlMemory(addrOut, addr0, addr1, size, op, perm, idOfProcess(currentProcess) == 1); 33 | } 34 | 35 | -------------------------------------------------------------------------------- /sysmodules/rosalina/source/pmdbgext.c: -------------------------------------------------------------------------------- 1 | // License for this file: ctrulib's license 2 | // Copyright AuroraWright, TuxSH 2019-2020 3 | 4 | #include 5 | #include <3ds/types.h> 6 | #include <3ds/result.h> 7 | #include <3ds/svc.h> 8 | #include <3ds/srv.h> 9 | #include <3ds/synchronization.h> 10 | #include <3ds/services/pmdbg.h> 11 | #include <3ds/ipc.h> 12 | 13 | Result PMDBG_GetCurrentAppInfo(FS_ProgramInfo *outProgramInfo, u32 *outPid, u32 *outLaunchFlags) 14 | { 15 | Result ret = 0; 16 | u32 *cmdbuf = getThreadCommandBuffer(); 17 | cmdbuf[0] = IPC_MakeHeader(0x100, 0, 0); 18 | if(R_FAILED(ret = svcSendSyncRequest(*pmDbgGetSessionHandle()))) return ret; 19 | 20 | memcpy(outProgramInfo, cmdbuf + 2, sizeof(FS_ProgramInfo)); 21 | *outPid = cmdbuf[6]; 22 | *outLaunchFlags = cmdbuf[7]; 23 | return cmdbuf[1]; 24 | } 25 | 26 | Result PMDBG_DebugNextApplicationByForce(bool debug) 27 | { 28 | Result ret = 0; 29 | u32 *cmdbuf = getThreadCommandBuffer(); 30 | cmdbuf[0] = IPC_MakeHeader(0x101, 1, 0); 31 | cmdbuf[1] = (u32)debug; 32 | 33 | if(R_FAILED(ret = svcSendSyncRequest(*pmDbgGetSessionHandle()))) return ret; 34 | return cmdbuf[1]; 35 | } 36 | 37 | Result PMDBG_LaunchTitleDebug(Handle *outDebug, const FS_ProgramInfo *programInfo, u32 launchFlags) 38 | { 39 | Result ret = 0; 40 | u32 *cmdbuf = getThreadCommandBuffer(); 41 | 42 | cmdbuf[0] = IPC_MakeHeader(0x102, 5, 0); 43 | memcpy(&cmdbuf[1], programInfo, sizeof(FS_ProgramInfo)); 44 | cmdbuf[5] = launchFlags; 45 | 46 | if(R_FAILED(ret = svcSendSyncRequest(*pmDbgGetSessionHandle()))) return ret; 47 | 48 | *outDebug = cmdbuf[3]; 49 | return (Result)cmdbuf[1]; 50 | } 51 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/process_patches.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2021 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include <3ds/types.h> 30 | #include "menu.h" 31 | 32 | typedef Result(* OperateOnProcessCb)(Handle processHandle, u32 textSz, u32 roSz, u32 rwSz); 33 | 34 | Result OpenProcessByName(const char *name, Handle *h); 35 | Result OperateOnProcessByName(const char *name, OperateOnProcessCb func); // doesn't operate on the heap 36 | -------------------------------------------------------------------------------- /arm11/source/memory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | /* 28 | * memcpy adapted from https://github.com/mid-kid/CakesForeveryWan/blob/557a8e8605ab3ee173af6497486e8f22c261d0e2/source/memfuncs.c 29 | */ 30 | 31 | #pragma once 32 | 33 | #include "types.h" 34 | 35 | void memcpy(void *dest, const void *src, u32 size); 36 | void memset(void *dest, u32 value, u32 size) __attribute__((used)); 37 | void memset32(void *dest, u32 filler, u32 size); 38 | -------------------------------------------------------------------------------- /arm9/source/large_patches.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "types.h" 30 | 31 | extern const u8 emunandPatch[]; 32 | extern const u32 emunandPatchSize; 33 | extern u32 emunandPatchSdmmcStructPtr, emunandPatchNandOffset, emunandPatchNcsdHeaderOffset; 34 | 35 | extern const u8 rebootPatch[]; 36 | extern const u32 rebootPatchSize; 37 | extern u32 rebootPatchFopenPtr; 38 | extern u16 rebootPatchFileName[80+1]; 39 | -------------------------------------------------------------------------------- /sysmodules/pm/source/firmlaunch.c: -------------------------------------------------------------------------------- 1 | #include <3ds.h> 2 | #include 3 | #include "firmlaunch.h" 4 | #include "termination.h" 5 | #include "task_runner.h" 6 | #include "util.h" 7 | 8 | static void *const g_firmlaunchParameters = (void *)0x12000000; 9 | 10 | void mapFirmlaunchParameters(void) 11 | { 12 | assertSuccess(svcKernelSetState(3, 0, (u64)((uintptr_t)g_firmlaunchParameters))); 13 | } 14 | 15 | Result GetFirmlaunchParams(void *outParams, size_t size) 16 | { 17 | size = size >= 0x1000 ? 0x1000 : size; 18 | memcpy(outParams, g_firmlaunchParameters, size); 19 | return 0; 20 | } 21 | 22 | Result SetFirmlaunchParams(const void *params, size_t size) 23 | { 24 | size = size >= 0x1000 ? 0x1000 : size; 25 | memcpy(g_firmlaunchParameters, params, size); 26 | if (size < 0x1000) { 27 | memset(g_firmlaunchParameters + size, 0, 0x1000 - size); 28 | } 29 | return 0; 30 | } 31 | 32 | static void LaunchFirmAsync(void *argdata) 33 | { 34 | struct { 35 | u32 firmTidLow; 36 | } *args = argdata; 37 | 38 | terminateAllProcesses((u32)-1, 4 * 1000 * 1000 * 1000LL); 39 | // pm has dead code there (notification 0x179, but there's no 'caller process'... (-1)) 40 | 41 | u64 firmTid = args->firmTidLow; // note: tidHigh doesn't matter 42 | firmTid = IS_N3DS ? (firmTid & ~N3DS_TID_MASK) | N3DS_TID_BIT : firmTid; 43 | assertSuccess(svcKernelSetState(0, firmTid)); 44 | } 45 | 46 | Result LaunchFirm(u32 firmTidLow, const void *params, size_t size) 47 | { 48 | struct { 49 | u32 firmTidLow; 50 | } args = { firmTidLow }; 51 | 52 | SetFirmlaunchParams(params, size); 53 | TaskRunner_RunTask(LaunchFirmAsync, &args, sizeof(args)); 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/menus/debugger.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include <3ds/types.h> 30 | #include "menu.h" 31 | 32 | extern Menu debuggerMenu; 33 | 34 | void debuggerFetchAndSetNextApplicationDebugHandleTask(void *argdata); 35 | Result debuggerDisable(s64 timeout); 36 | 37 | void DebuggerMenu_EnableDebugger(void); 38 | void DebuggerMenu_DisableDebugger(void); 39 | void DebuggerMenu_DebugNextApplicationByForce(void); 40 | -------------------------------------------------------------------------------- /k11_extension/include/svc/ControlMemory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "utils.h" 30 | #include "kernel.h" 31 | #include "svc.h" 32 | 33 | Result ControlMemoryHookWrapper(u32 *addrOut, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm); 34 | Result ControlMemoryHook(u32 *addrOut, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm); 35 | Result ControlMemoryEx(u32 *addrOut, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm, bool isLoader); 36 | -------------------------------------------------------------------------------- /sysmodules/rosalina/source/gdb/stop_point.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS. 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * SPDX-License-Identifier: (MIT OR GPL-2.0-or-later) 6 | */ 7 | 8 | #include "gdb.h" 9 | #include "gdb/net.h" 10 | #include "gdb/watchpoints.h" 11 | #include "gdb/breakpoints.h" 12 | 13 | GDB_DECLARE_HANDLER(ToggleStopPoint) 14 | { 15 | bool add = ctx->commandData[-1] == 'Z'; 16 | u32 lst[3]; 17 | 18 | const char *pos = GDB_ParseHexIntegerList(lst, ctx->commandData, 3, ';'); 19 | if(pos == NULL) 20 | return GDB_ReplyErrno(ctx, EILSEQ); 21 | bool persist = *pos != 0 && strncmp(pos, ";cmds:1", 7) == 0; 22 | 23 | u32 kind = lst[0]; 24 | u32 addr = lst[1]; 25 | u32 size = lst[2]; 26 | 27 | int res; 28 | static const WatchpointKind kinds[3] = { WATCHPOINT_WRITE, WATCHPOINT_READ, WATCHPOINT_READWRITE }; 29 | switch(kind) 30 | { 31 | case 0: // software breakpoint 32 | if(size != 2 && size != 4) 33 | return GDB_ReplyEmpty(ctx); 34 | else 35 | { 36 | res = add ? GDB_AddBreakpoint(ctx, addr, size == 2, persist) : 37 | GDB_RemoveBreakpoint(ctx, addr); 38 | return res == 0 ? GDB_ReplyOk(ctx) : GDB_ReplyErrno(ctx, -res); 39 | } 40 | 41 | // Watchpoints 42 | case 2: 43 | case 3: 44 | case 4: 45 | res = add ? GDB_AddWatchpoint(ctx, addr, size, kinds[kind - 2]) : 46 | GDB_RemoveWatchpoint(ctx, addr, kinds[kind - 2]); 47 | return res == 0 ? GDB_ReplyOk(ctx) : GDB_ReplyErrno(ctx, -res); 48 | 49 | default: 50 | return GDB_ReplyEmpty(ctx); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /arm9/source/memory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | /* 28 | * Boyer-Moore Horspool algorithm adapted from http://www-igm.univ-mlv.fr/~lecroq/string/node18.html#SECTION00180 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #include "types.h" 35 | 36 | u8 *memsearch(u8 *startPos, const void *pattern, u32 size, u32 patternSize); 37 | void *copyFromLegacyModeFcram(void *dst, const void *src, size_t size); 38 | void *copyToLegacyModeFcram(void *dst, const void *src, size_t size); 39 | -------------------------------------------------------------------------------- /sysmodules/rosalina/source/task_runner.c: -------------------------------------------------------------------------------- 1 | #include <3ds.h> 2 | #include 3 | #include "task_runner.h" 4 | 5 | TaskRunner g_taskRunner; 6 | 7 | static MyThread taskRunnerThread; 8 | static u8 ALIGN(8) taskRunnerThreadStack[0x1000]; 9 | 10 | static void taskRunnerNoOpFunction(void *args) 11 | { 12 | (void)args; 13 | } 14 | 15 | MyThread *taskRunnerCreateThread(void) 16 | { 17 | TaskRunner_Init(); 18 | MyThread_Create(&taskRunnerThread, TaskRunner_HandleTasks, taskRunnerThreadStack, THREAD_STACK_SIZE, 58, 1); 19 | return &taskRunnerThread; 20 | } 21 | 22 | void TaskRunner_Init(void) 23 | { 24 | memset(&g_taskRunner, 0, sizeof(TaskRunner)); 25 | LightEvent_Init(&g_taskRunner.readyEvent, RESET_ONESHOT); 26 | LightEvent_Init(&g_taskRunner.parametersSetEvent, RESET_ONESHOT); 27 | } 28 | 29 | void TaskRunner_RunTask(void (*task)(void *argdata), void *argdata, size_t argsize) 30 | { 31 | argsize = argsize > sizeof(g_taskRunner.argStorage) ? sizeof(g_taskRunner.argStorage) : argsize; 32 | LightEvent_Wait(&g_taskRunner.readyEvent); 33 | g_taskRunner.task = task; 34 | memcpy(g_taskRunner.argStorage, argdata, argsize); 35 | LightEvent_Signal(&g_taskRunner.parametersSetEvent); 36 | } 37 | 38 | void TaskRunner_Terminate(void) 39 | { 40 | g_taskRunner.shouldTerminate = true; 41 | TaskRunner_RunTask(taskRunnerNoOpFunction, NULL, 0); 42 | } 43 | 44 | void TaskRunner_HandleTasks(void) 45 | { 46 | while (!g_taskRunner.shouldTerminate) { 47 | LightEvent_Signal(&g_taskRunner.readyEvent); 48 | LightEvent_Wait(&g_taskRunner.parametersSetEvent); 49 | g_taskRunner.task(g_taskRunner.argStorage); 50 | } 51 | } 52 | 53 | void TaskRunner_WaitReady(void) 54 | { 55 | LightEvent_Wait(&g_taskRunner.readyEvent); 56 | } 57 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/memory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include <3ds/types.h> 30 | #include 31 | 32 | u8 *memsearch(u8 *startPos, const void *pattern, u32 size, u32 patternSize); 33 | void hexItoa(u64 number, char *out, u32 digits, bool uppercase); 34 | unsigned long int xstrtoul(const char *nptr, char **endptr, int base, bool allowPrefix, bool *ok); 35 | unsigned long long int xstrtoull(const char *nptr, char **endptr, int base, bool allowPrefix, bool *ok); 36 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/input_redirection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include <3ds/types.h> 30 | #include "MyThread.h" 31 | 32 | extern bool inputRedirectionEnabled; 33 | extern Handle inputRedirectionThreadStartedEvent; 34 | 35 | extern int inputRedirectionStartResult; 36 | 37 | MyThread *inputRedirectionCreateThread(void); 38 | void inputRedirectionThreadMain(void); 39 | Result InputRedirection_Disable(s64 timeout); 40 | Result InputRedirection_DoOrUndoPatches(void); 41 | 42 | -------------------------------------------------------------------------------- /arm9/source/emunand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | /* 28 | * Code for locating the SDMMC struct by Normmatt 29 | */ 30 | 31 | #pragma once 32 | 33 | #include "types.h" 34 | 35 | #define ROUND_TO_4MB(a) (((a) + 0x2000 - 1) & (~(0x2000 - 1))) 36 | 37 | extern u32 emuOffset, 38 | emuHeader; 39 | 40 | void locateEmuNand(FirmwareSource *nandType, u32 *emunandIndex, bool configureCtrNandParams); 41 | u32 patchEmuNand(u8 *arm9Section, u32 kernel9Size, u8 *process9Offset, u32 process9Size, u8 *kernel9Address, u32 firmVersion); 42 | -------------------------------------------------------------------------------- /sysmodules/rosalina/source/gdb/verbose.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS. 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * SPDX-License-Identifier: (MIT OR GPL-2.0-or-later) 6 | */ 7 | 8 | #include "gdb/verbose.h" 9 | #include "gdb/net.h" 10 | #include "gdb/debug.h" 11 | #include "gdb/tio.h" 12 | 13 | static const struct 14 | { 15 | const char *name; 16 | GDBCommandHandler handler; 17 | } gdbVerboseCommandHandlers[] = 18 | { 19 | { "Attach", GDB_VERBOSE_HANDLER(Attach) }, 20 | { "Cont?", GDB_VERBOSE_HANDLER(ContinueSupported) }, 21 | { "Cont", GDB_VERBOSE_HANDLER(Continue) }, 22 | { "File", GDB_VERBOSE_HANDLER(File) }, 23 | { "MustReplyEmpty", GDB_HANDLER(Unsupported) }, 24 | { "Run", GDB_VERBOSE_HANDLER(Run) }, 25 | { "Kill", GDB_VERBOSE_HANDLER(Kill) }, 26 | }; 27 | 28 | GDB_DECLARE_HANDLER(VerboseCommand) 29 | { 30 | char *nameBegin = ctx->commandData; // w/o leading 'v' 31 | if(*nameBegin == 0) 32 | return GDB_ReplyErrno(ctx, EILSEQ); 33 | 34 | char *nameEnd; 35 | char *vData = NULL; 36 | 37 | for(nameEnd = nameBegin; *nameEnd != 0 && *nameEnd != ';' && *nameEnd != ':'; nameEnd++); 38 | if(*nameEnd != 0) 39 | { 40 | *nameEnd = 0; 41 | vData = nameEnd + 1; 42 | } 43 | 44 | for(u32 i = 0; i < sizeof(gdbVerboseCommandHandlers) / sizeof(gdbVerboseCommandHandlers[0]); i++) 45 | { 46 | if(strcmp(gdbVerboseCommandHandlers[i].name, nameBegin) == 0) 47 | { 48 | ctx->commandData = vData; 49 | return gdbVerboseCommandHandlers[i].handler(ctx); 50 | } 51 | } 52 | 53 | return GDB_HandleUnsupported(ctx); // No handler found! 54 | } 55 | 56 | GDB_DECLARE_VERBOSE_HANDLER(ContinueSupported) 57 | { 58 | return GDB_SendPacket(ctx, "vCont;c;C", 9); 59 | } 60 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/menus/miscellaneous.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2021 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include <3ds/types.h> 30 | #include "menu.h" 31 | 32 | extern Menu miscellaneousMenu; 33 | extern int lastNtpTzOffset; 34 | 35 | void MiscellaneousMenu_SwitchBoot3dsxTargetTitle(void); 36 | void MiscellaneousMenu_ChangeMenuCombo(void); 37 | void MiscellaneousMenu_InputRedirection(void); 38 | void MiscellaneousMenu_UpdateTimeDateNtp(void); 39 | void MiscellaneousMenu_NullifyUserTimeOffset(void); 40 | void MiscellaneousMenu_DumpDspFirm(void); 41 | -------------------------------------------------------------------------------- /k11_extension/include/svc/ControlService.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "utils.h" 30 | #include "kernel.h" 31 | #include "svc.h" 32 | 33 | /// Operations for svcControlService 34 | typedef enum ServiceOp 35 | { 36 | SERVICEOP_STEAL_CLIENT_SESSION = 0, ///< Steal a client session given a service or global port name 37 | SERVICEOP_GET_NAME, ///< Get the name of a service or global port given a client or session handle 38 | } ServiceOp; 39 | 40 | Result ControlService(ServiceOp op, u32 varg1, u32 varg2); 41 | -------------------------------------------------------------------------------- /k11_extension/source/svc/Backdoor.s: -------------------------------------------------------------------------------- 1 | @ This file is part of Luma3DS 2 | @ Copyright (C) 2016-2020 Aurora Wright, TuxSH 3 | @ 4 | @ This program is free software: you can redistribute it and/or modify 5 | @ it under the terms of the GNU General Public License as published by 6 | @ the Free Software Foundation, either version 3 of the License, or 7 | @ (at your option) any later version. 8 | @ 9 | @ This program is distributed in the hope that it will be useful, 10 | @ but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | @ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | @ GNU General Public License for more details. 13 | @ 14 | @ You should have received a copy of the GNU General Public License 15 | @ along with this program. If not, see . 16 | @ 17 | @ Additional Terms 7.b and 7.c of GPLv3 apply to this file: 18 | @ * Requiring preservation of specified reasonable legal notices or 19 | @ author attributions in that material or in the Appropriate Legal 20 | @ Notices displayed by works containing it. 21 | @ * Prohibiting misrepresentation of the origin of that material, 22 | @ or requiring that modified versions of such material be marked in 23 | @ reasonable ways as different from the original version. 24 | 25 | .text 26 | .arm 27 | .balign 4 28 | 29 | .global Backdoor 30 | .type Backdoor, %function 31 | Backdoor: 32 | @ Nintendo's code 33 | bic r1, sp, #0xff 34 | orr r1, r1, #0xf00 35 | add r1, r1, #0x28 @ get user stack. 36 | 37 | ldr r2, [r1] 38 | stmdb r2!, {sp, lr} 39 | mov sp, r2 @ sp_svc = sp_usr. You'll get nice crashes if an interrupt or context switch occurs during svcBackdoor 40 | blx r0 41 | pop {r0, r1} 42 | mov sp, r0 43 | bx r1 44 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/menus/sysconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include <3ds/types.h> 30 | #include "menu.h" 31 | 32 | extern Menu sysconfigMenu; 33 | extern bool isConnectionForced; 34 | 35 | void SysConfigMenu_UpdateStatus(bool control); 36 | 37 | void SysConfigMenu_ToggleLEDs(void); 38 | void SysConfigMenu_ToggleWireless(void); 39 | void SysConfigMenu_TogglePowerButton(void); 40 | void SysConfigMenu_ControlWifi(void); 41 | void SysConfigMenu_DisableForcedWifiConnection(void); 42 | void SysConfigMenu_ToggleCardIfPower(void); 43 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/minisoc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS. 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * SPDX-License-Identifier: (MIT OR GPL-2.0-or-later) 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | #include <3ds/types.h> 12 | #include <3ds/svc.h> 13 | #include <3ds/srv.h> 14 | #include <3ds/services/soc.h> 15 | #include 16 | 17 | #define _REENT_ONLY 18 | #include 19 | 20 | #define SYNC_ERROR ENODEV 21 | extern bool miniSocEnabled; 22 | 23 | Result miniSocInit(void); 24 | 25 | void miniSocLockState(void); 26 | void miniSocUnlockState(bool force); 27 | 28 | Result miniSocExitDirect(void); 29 | Result miniSocExit(void); 30 | 31 | s32 _net_convert_error(s32 sock_retval); 32 | 33 | int socSocket(int domain, int type, int protocol); 34 | int socBind(int sockfd, const struct sockaddr *addr, socklen_t addrlen); 35 | int socListen(int sockfd, int max_connections); 36 | int socAccept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); 37 | int socConnect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); 38 | int socPoll(struct pollfd *fds, nfds_t nfds, int timeout); 39 | int socSetsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen); 40 | int socClose(int sockfd); 41 | long socGethostid(void); 42 | 43 | ssize_t socRecvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen); 44 | ssize_t socSendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen); 45 | 46 | static inline ssize_t socRecv(int sockfd, void *buf, size_t len, int flags) 47 | { 48 | return socRecvfrom(sockfd, buf, len, flags, NULL, 0); 49 | } 50 | 51 | static inline ssize_t socSend(int sockfd, const void *buf, size_t len, int flags) 52 | { 53 | return socSendto(sockfd, buf, len, flags, NULL, 0); 54 | } 55 | -------------------------------------------------------------------------------- /arm9/source/strings.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #include "strings.h" 28 | 29 | u32 hexAtoi(const char *in, u32 digits) 30 | { 31 | u32 res = 0; 32 | char *tmp = (char *)in; 33 | 34 | for(u32 i = 0; i < digits && *tmp != 0; tmp++, i++) 35 | res = (*tmp > '9' ? *tmp - 'A' + 10 : *tmp - '0') + (res << 4); 36 | 37 | return res; 38 | } 39 | 40 | u32 decAtoi(const char *in, u32 digits) 41 | { 42 | u32 res = 0; 43 | char *tmp = (char *)in; 44 | 45 | for(u32 i = 0; i < digits && *tmp != 0; tmp++, i++) 46 | res = *tmp - '0' + res * 10; 47 | 48 | return res; 49 | } 50 | -------------------------------------------------------------------------------- /k11_extension/include/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "types.h" 30 | #include "globals.h" 31 | #include "kernel.h" 32 | #include "utils.h" 33 | 34 | extern KRecursiveLock dbgParamsLock; 35 | extern u32 dbgParamWatchpointId, dbgParamDVA, dbgParamWCR, dbgParamContextId; 36 | 37 | KSchedulableInterruptEvent *enableMonitorModeDebugging(KBaseInterruptEvent *this, u32 interruptID); 38 | KSchedulableInterruptEvent *disableWatchpoint(KBaseInterruptEvent *this, u32 interruptID); 39 | KSchedulableInterruptEvent *setWatchpointWithContextId(KBaseInterruptEvent *this, u32 interruptID); 40 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/MyThread.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include <3ds/types.h> 30 | #include <3ds/result.h> 31 | #include <3ds/svc.h> 32 | #include <3ds/synchronization.h> 33 | 34 | #define THREAD_STACK_SIZE 0x1000 35 | 36 | typedef struct MyThread 37 | { 38 | Handle handle; 39 | void (*ep)(void); 40 | bool finished; 41 | void* stacktop; 42 | } MyThread; 43 | 44 | Result MyThread_Create(MyThread *t, void (*entrypoint)(void), void *stack, u32 stackSize, int prio, int affinity); 45 | Result MyThread_Join(MyThread *thread, s64 timeout_ns); 46 | void MyThread_Exit(void); 47 | -------------------------------------------------------------------------------- /sysmodules/loader/source/hbldr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2022 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include <3ds.h> 30 | #include "luma_shared_config.h" 31 | 32 | Result hbldrLoadProcess(Handle *outProcessHandle, const ExHeader_Info *exhi); 33 | void hbldrPatchExHeaderInfo(ExHeader_Info *exhi); 34 | void hbldrHandleCommands(void *ctx); 35 | 36 | static inline bool hbldrIs3dsxTitle(u64 tid) 37 | { 38 | if (!Luma_SharedConfig->use_hbldr) 39 | return false; 40 | u64 hbldrTid = Luma_SharedConfig->hbldr_3dsx_tid; 41 | 42 | // Just like p9 clears them, ignore platform/N3DS bits 43 | return ((tid ^ hbldrTid) & ~0xF0000000ull) == 0; 44 | } 45 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ifneq ($(strip $(shell firmtool -v 2>&1 | grep usage)),) 2 | $(error "Please install firmtool v1.1 or greater") 3 | endif 4 | 5 | # Disable kext and firmlaunch patches, all custom sysmodules except Loader, enable PASLR. 6 | # Dangerous. Don't enable this unless you know what you're doing! 7 | export BUILD_FOR_EXPLOIT_DEV ?= 0 8 | 9 | # Build with O0 & frame pointer information for use with GDB 10 | export BUILD_FOR_GDB ?= 0 11 | 12 | # Default 3DSX TitleID for hb:ldr 13 | export HBLDR_DEFAULT_3DSX_TID ?= 000400000D921E00 14 | 15 | # What to call the title corresponding to HBLDR_DEFAULT_3DSX_TID 16 | export HBLDR_DEFAULT_3DSX_TITLE_NAME ?= "hblauncher_loader" 17 | 18 | NAME := $(notdir $(CURDIR)) 19 | REVISION := $(shell git describe --tags --match v[0-9]* --abbrev=8 | sed 's/-[0-9]*-g/-/') 20 | FTP_HOST := "192.168.1.139" 21 | FTP_PORT := "5000" 22 | 23 | export ONLY_CN_FONTLIB := 1 24 | 25 | SUBFOLDERS := sysmodules arm11 arm9 k11_extension 26 | 27 | .PHONY: all release clean $(SUBFOLDERS) 28 | 29 | all: boot.firm 30 | 31 | release: $(NAME)$(REVISION).zip 32 | 33 | clean: 34 | @$(foreach dir, $(SUBFOLDERS), $(MAKE) -C $(dir) clean &&) true 35 | @rm -rf *.firm *.zip *.3dsx 36 | 37 | # boot.3dsx comes from https://github.com/fincs/new-hbmenu/releases 38 | $(NAME)$(REVISION).zip: boot.firm boot.3dsx 39 | @zip -r $@ $^ -x "*.DS_Store*" "*__MACOSX*" 40 | 41 | boot.firm: $(SUBFOLDERS) 42 | @firmtool build $@ -D sysmodules/sysmodules.bin arm11/arm11.elf arm9/arm9.elf k11_extension/k11_extension.elf \ 43 | -A 0x18180000 -C XDMA XDMA NDMA XDMA 44 | @echo built... $(notdir $@) 45 | @make send 46 | 47 | boot.3dsx: 48 | @curl -sSfLO "https://github.com/fincs/new-hbmenu/releases/latest/download/$@" 49 | @echo downloaded... $(notdir $@) 50 | 51 | send: 52 | @echo "Sending firm over FTP." 53 | @python $(CURDIR)/sendfile.py $(FTP_HOST) $(FTP_PORT) "boot.firm" "boot.firm" 54 | 55 | $(SUBFOLDERS): 56 | @$(MAKE) -C $@ all 57 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/menus.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * This file is part of Luma3DS 4 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 20 | * * Requiring preservation of specified reasonable legal notices or 21 | * author attributions in that material or in the Appropriate Legal 22 | * Notices displayed by works containing it. 23 | * * Prohibiting misrepresentation of the origin of that material, 24 | * or requiring that modified versions of such material be marked in 25 | * reasonable ways as different from the original version. 26 | */ 27 | 28 | #pragma once 29 | 30 | #include <3ds/types.h> 31 | #include "menu.h" 32 | 33 | extern Menu rosalinaMenu; 34 | 35 | void RosalinaMenu_TakeScreenshot(void); 36 | void RosalinaMenu_ChangeScreenBrightness(void); 37 | void RosalinaMenu_ShowCredits(void); 38 | void RosalinaMenu_AboutCnVer(void); 39 | void RosalinaMenu_ProcessList(void); 40 | void RosalinaMenu_SaveSettings(void); 41 | void RosalinaMenu_PowerOff(void); 42 | void RosalinaMenu_Reboot(void); 43 | void RosalinaMenu_Cheats(void); 44 | 45 | bool rosalinaMenuShouldShowDebugInfo(void); 46 | void RosalinaMenu_ShowDebugInfo(void); 47 | -------------------------------------------------------------------------------- /k11_extension/source/svc/CreateThread.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2023 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #include "svc/CreateThread.h" 28 | 29 | // Keep in sync with csvc.h 30 | #define OVERRIDE_THREAD_REDIRECTION_FLAG 0x40 31 | 32 | Result CreateThreadHook(Handle *outThreadHandle, u32 ep, u32 arg, u32 stackTop, s32 priority, s32 processorId) 33 | { 34 | u32 flags = flagsOfProcess(currentCoreContext->objectContext.currentProcess); 35 | if (isN3DS && CONFIG(REDIRECTAPPTHREADS) && !disableThreadRedirection && processorId == 1 && (flags & 0xF00) == 0x100) 36 | processorId = 2; 37 | 38 | return CreateThread(outThreadHandle, ep, arg, stackTop, priority, processorId); 39 | } 40 | 41 | -------------------------------------------------------------------------------- /arm9/source/firm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "types.h" 30 | #include "3dsheaders.h" 31 | 32 | u32 loadNintendoFirm(FirmwareType *firmType, FirmwareSource nandType, bool loadFromStorage, bool isSafeMode); 33 | void loadHomebrewFirm(u32 pressed); 34 | u32 patchNativeFirm(u32 firmVersion, FirmwareSource nandType, bool loadFromStorage, bool isFirmProtEnabled, bool needToInitSd, bool doUnitinfoPatch); 35 | u32 patchTwlFirm(u32 firmVersion, bool loadFromStorage, bool doUnitinfoPatch); 36 | u32 patchAgbFirm(bool loadFromStorage, bool doUnitinfoPatch); 37 | u32 patch1x2xNativeAndSafeFirm(void); 38 | void launchFirm(int argc, char **argv); 39 | -------------------------------------------------------------------------------- /sysmodules/pxi/source/PXI.h: -------------------------------------------------------------------------------- 1 | /* 2 | PXI.h: 3 | PXI I/O functions. 4 | 5 | (c) TuxSH, 2016-2020 6 | This is part of 3ds_pxi, which is licensed under the MIT license (see LICENSE for details). 7 | */ 8 | 9 | #pragma once 10 | 11 | #include <3ds.h> 12 | 13 | #define PXI_REGS_BASE 0x1EC63000 14 | #define REG_PXI_SYNC *(vu32 *)(PXI_REGS_BASE + 0) 15 | #define REG_PXI_BYTE_RECEIVED_FROM_REMOTE *(vu8 *)(PXI_REGS_BASE) 16 | #define REG_PXI_BYTE_SENT_TO_REMOTE *(vu8 *)(PXI_REGS_BASE + 1) 17 | #define REG_PXI_INTERRUPT_CNT *(vu8 *)(PXI_REGS_BASE + 3) 18 | #define SYNC_TRIGGER_SYNC9_IRQ (1U << 6) 19 | #define SYNC_ENABLE_SYNC11_IRQ (1U << 7) 20 | 21 | #define REG_PXI_CNT *(vu16 *)(PXI_REGS_BASE + 4) 22 | #define CNT_SEND_FIFO_FULL_STATUS (1U << 1) 23 | #define CNT_ENABLE_SEND_FIFO_EMPTY_IRQ (1U << 2) 24 | #define CNT_CLEAR_SEND_FIFO (1U << 3) 25 | #define CNT_RECEIVE_FIFO_EMPTY_STATUS (1U << 8) 26 | #define CNT_ENABLE_RECEIVE_FIFO_NOT_EMPTY_IRQ (1U << 10) 27 | #define CNT_ACKNOWLEDGE_FIFO_ERROR (1U << 14) 28 | #define CNT_ENABLE_FIFOs (1U << 15) 29 | 30 | #define REG_PXI_SEND *(vu32 *)(PXI_REGS_BASE + 8) 31 | #define REG_PXI_RECV *(vu32 *)(PXI_REGS_BASE + 12) 32 | 33 | void PXIReset(void); 34 | void PXITriggerSync9IRQ(void); 35 | 36 | bool PXIIsSendFIFOFull(void); 37 | void PXISendByte(u8 byte); 38 | void PXISendWord(u32 word); 39 | void PXISendBuffer(const u32 *buffer, u32 nbWords); 40 | 41 | bool PXIIsReceiveFIFOEmpty(void); 42 | u8 PXIReceiveByte(void); 43 | u32 PXIReceiveWord(void); 44 | void PXIReceiveBuffer(u32 *buffer, u32 nbWords); 45 | 46 | Result bindPXIInterrupts(Handle *syncInterrupt, Handle *receiveFIFONotEmptyInterrupt, Handle *sendFIFOEmptyInterrupt); 47 | void unbindPXIInterrupts(Handle *syncInterrupt, Handle *receiveFIFONotEmptyInterrupt, Handle *sendFIFOEmptyInterrupt); 48 | -------------------------------------------------------------------------------- /arm9/source/cache.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "types.h" 30 | 31 | /*** 32 | The following functions flush the data cache, then waits for all memory transfers to be finished. 33 | The data cache and/or the instruction cache MUST be flushed before doing one of the following: 34 | - rebooting 35 | - powering down 36 | - setting the Arm11 entrypoint to execute a function 37 | - jumping to a payload 38 | ***/ 39 | 40 | void flushEntireDCache(void); //actually: "clean and flush" 41 | void flushDCacheRange(void *startAddress, u32 size); 42 | void flushEntireICache(void); 43 | void flushICacheRange(void *startAddress, u32 size); 44 | -------------------------------------------------------------------------------- /sysmodules/rosalina/source/gdb/xml/target.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | arm 5 | 3DS 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /k11_extension/include/fatalExceptionHandlers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "types.h" 30 | 31 | bool isExceptionFatal(u32 spsr, u32 *regs, u32 index); 32 | bool isDataAbortExceptionRangeControlled(u32 spsr, u32 addr); 33 | 34 | void FIQHandler(void); 35 | void undefinedInstructionHandler(void); 36 | void prefetchAbortHandler(void); 37 | void dataAbortHandler(void); 38 | 39 | typedef struct 40 | { 41 | u32 magic[2]; 42 | u16 versionMinor, versionMajor; 43 | 44 | u16 processor, core; 45 | u32 type; 46 | 47 | u32 totalSize; 48 | u32 registerDumpSize; 49 | u32 codeDumpSize; 50 | u32 stackDumpSize; 51 | u32 additionalDataSize; 52 | } ExceptionDumpHeader; 53 | -------------------------------------------------------------------------------- /sysmodules/loader/source/patcher.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include <3ds/types.h> 4 | #include <3ds/exheader.h> 5 | #include "ifile.h" 6 | #include "util.h" 7 | 8 | #define MAKE_BRANCH(src,dst) (0xEA000000 | ((u32)((((u8 *)(dst) - (u8 *)(src)) >> 2) - 2) & 0xFFFFFF)) 9 | #define MAKE_BRANCH_LINK(src,dst) (0xEB000000 | ((u32)((((u8 *)(dst) - (u8 *)(src)) >> 2) - 2) & 0xFFFFFF)) 10 | 11 | #define CONFIG(a) (((config >> (a)) & 1) != 0) 12 | #define MULTICONFIG(a) ((multiConfig >> (2 * (a))) & 3) 13 | #define BOOTCONFIG(a, b) ((bootConfig >> (a)) & (b)) 14 | 15 | #define BOOTCFG_NAND BOOTCONFIG(0, 1) 16 | #define BOOTCFG_EMUINDEX BOOTCONFIG(1, 3) 17 | #define BOOTCFG_NOFORCEFLAG BOOTCONFIG(3, 1) 18 | #define BOOTCFG_NTRCARDBOOT BOOTCONFIG(4, 1) 19 | 20 | enum multiOptions 21 | { 22 | DEFAULTEMU = 0, 23 | BRIGHTNESS, 24 | SPLASH, 25 | PIN, 26 | NEWCPU, 27 | AUTOBOOTMODE, 28 | FORCEAUDIOOUTPUT, 29 | }; 30 | 31 | enum singleOptions 32 | { 33 | AUTOBOOTEMU = 0, 34 | LOADEXTFIRMSANDMODULES, 35 | PATCHGAMES, 36 | REDIRECTAPPTHREADS, 37 | PATCHVERSTRING, 38 | SHOWGBABOOT, 39 | ENABLEDSIEXTFILTER, 40 | ALLOWUPDOWNLEFTRIGHTDSI, 41 | PATCHUNITINFO, 42 | DISABLEARM11EXCHANDLERS, 43 | ENABLESAFEFIRMROSALINA, 44 | }; 45 | 46 | extern u32 config, multiConfig, bootConfig; 47 | extern bool isN3DS, isSdMode, nextGamePatchDisabled; 48 | 49 | void patchCode(u64 progId, u16 progVer, u8 *code, u32 size, u32 textSize, u32 roSize, u32 dataSize, u32 roAddress, u32 dataAddress); 50 | bool loadTitleCodeSection(u64 progId, u8 *code, u32 size); 51 | bool loadTitleExheaderInfo(u64 progId, ExHeader_Info *exheaderInfo); 52 | 53 | Result openSysmoduleCxi(IFile *outFile, u64 progId); 54 | bool readSysmoduleCxiNcchHeader(Ncch *outNcchHeader, IFile *file); 55 | bool readSysmoduleCxiExHeaderInfo(ExHeader_Info *outExhi, const Ncch *ncchHeader, IFile *file); 56 | bool readSysmoduleCxiCode(u8 *outCode, u32 *outSize, u32 maxSize, IFile *file, const Ncch *ncchHeader); 57 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/ifile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2022 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include <3ds/services/fs.h> 30 | 31 | #define PATH_MAX 255 32 | 33 | typedef struct 34 | { 35 | Handle handle; 36 | u64 pos; 37 | u64 size; 38 | } IFile; 39 | 40 | Result IFile_Open(IFile *file, FS_ArchiveID archiveId, FS_Path archivePath, FS_Path filePath, u32 flags); 41 | Result IFile_OpenFromArchive(IFile *file, FS_Archive archive, FS_Path filePath, u32 flags); 42 | Result IFile_Close(IFile *file); 43 | Result IFile_GetSize(IFile *file, u64 *size); 44 | Result IFile_SetSize(IFile *file, u64 size); 45 | Result IFile_Read(IFile *file, u64 *total, void *buffer, u32 len); 46 | Result IFile_Write(IFile *file, u64 *total, const void *buffer, u32 len, u32 flags); 47 | -------------------------------------------------------------------------------- /sysmodules/loader/source/file_util.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | extern "C" 7 | { 8 | #include <3ds/result.h> 9 | #include <3ds/services/fs.h> 10 | #include <3ds/svc.h> 11 | #include <3ds/types.h> 12 | } 13 | 14 | namespace util 15 | { 16 | inline FS_Path MakePath(const char *path) 17 | { 18 | return fsMakePath(PATH_ASCII, path); 19 | } 20 | 21 | // A small wrapper to make forgetting to close a file and 22 | // to check read lengths impossible. 23 | class File 24 | { 25 | public: 26 | File() = default; 27 | File(const File &other) = delete; 28 | File &operator=(const File &) = delete; 29 | File(File &&other) { *this = std::move(other); } 30 | File &operator=(File &&other) 31 | { 32 | std::swap(m_handle, other.m_handle); 33 | return *this; 34 | } 35 | 36 | ~File() { Close(); } 37 | 38 | bool Close() 39 | { 40 | const bool ok = !m_handle || R_SUCCEEDED(FSFILE_Close(*m_handle)); 41 | if(ok) 42 | m_handle = std::nullopt; 43 | return ok; 44 | } 45 | 46 | bool Open(const char *path, int open_flags) 47 | { 48 | const FS_Path archive_path = {PATH_EMPTY, 1, ""}; 49 | Handle handle; 50 | const bool ok = R_SUCCEEDED(FSUSER_OpenFileDirectly(&handle, ARCHIVE_SDMC, archive_path, 51 | MakePath(path), open_flags, 0)); 52 | if(ok) 53 | m_handle = handle; 54 | return ok; 55 | } 56 | 57 | bool Read(void *buffer, u32 size, u64 offset) 58 | { 59 | u32 bytes_read = 0; 60 | const Result res = FSFILE_Read(*m_handle, &bytes_read, offset, buffer, size); 61 | return R_SUCCEEDED(res) && bytes_read == size; 62 | } 63 | 64 | std::optional GetSize() const 65 | { 66 | u64 size; 67 | if(!R_SUCCEEDED(FSFILE_GetSize(*m_handle, &size))) 68 | return std::nullopt; 69 | return size; 70 | } 71 | 72 | private: 73 | std::optional m_handle; 74 | }; 75 | 76 | } // namespace util 77 | -------------------------------------------------------------------------------- /arm11/source/memory.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | /* 28 | * memcpy adapted from https://github.com/mid-kid/CakesForeveryWan/blob/557a8e8605ab3ee173af6497486e8f22c261d0e2/source/memfuncs.c 29 | */ 30 | 31 | #include "memory.h" 32 | 33 | void memcpy(void *dest, const void *src, u32 size) 34 | { 35 | u8 *destc = (u8 *)dest; 36 | const u8 *srcc = (const u8 *)src; 37 | 38 | for(u32 i = 0; i < size; i++) 39 | destc[i] = srcc[i]; 40 | } 41 | 42 | void memset(void *dest, u32 filler, u32 size) 43 | { 44 | u8 *destc = (u8 *)dest; 45 | 46 | for(u32 i = 0; i < size; i++) 47 | destc[i] = (u8)filler; 48 | } 49 | 50 | void memset32(void *dest, u32 filler, u32 size) 51 | { 52 | u32 *dest32 = (u32 *)dest; 53 | 54 | for(u32 i = 0; i < size / 4; i++) 55 | dest32[i] = filler; 56 | } 57 | -------------------------------------------------------------------------------- /sysmodules/loader/source/service_manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include <3ds/types.h> 30 | 31 | typedef struct ServiceManagerServiceEntry { 32 | const char *name; 33 | u32 maxSessions; 34 | void (*handler)(void *ctx); 35 | bool isGlobalPort; 36 | } ServiceManagerServiceEntry; 37 | 38 | typedef struct ServiceManagerNotificationEntry { 39 | u32 id; 40 | void (*handler)(u32 id); 41 | } ServiceManagerNotificationEntry; 42 | 43 | typedef struct ServiceManagerContextAllocator { 44 | void* (*newSessionContext)(u8 serviceId); 45 | void (*freeSessionContext)(void *ctx); 46 | } ServiceManagerContextAllocator; 47 | 48 | Result ServiceManager_Run(const ServiceManagerServiceEntry *services, const ServiceManagerNotificationEntry *notifications, const ServiceManagerContextAllocator *allocator); 49 | -------------------------------------------------------------------------------- /arm9/source/fs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2021 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include "types.h" 30 | 31 | #define PATTERN(a) a "_*.firm" 32 | 33 | bool mountSdCardPartition(bool switchMainDir); 34 | bool remountCtrNandPartition(bool switchMainDir); 35 | void unmountPartitions(void); 36 | 37 | u32 fileRead(void *dest, const char *path, u32 maxSize); 38 | u32 getFileSize(const char *path); 39 | bool fileWrite(const void *buffer, const char *path, u32 size); 40 | bool fileDelete(const char *path); 41 | bool fileCopy(const char *pathSrc, const char *pathDst, bool replace, void *tmpBuffer, size_t bufferSize); 42 | bool findPayload(char *path, u32 pressed); 43 | bool payloadMenu(char *path, bool *hasDisplayedMenu); 44 | u32 firmRead(void *dest, u32 firmType); 45 | void findDumpFile(const char *folderPath, char *fileName); 46 | 47 | bool doLumaUpgradeProcess(void); 48 | -------------------------------------------------------------------------------- /sysmodules/rosalina/include/service_manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include <3ds/types.h> 30 | 31 | typedef struct ServiceManagerServiceEntry { 32 | const char *name; 33 | u32 maxSessions; 34 | void (*handler)(void *ctx); 35 | bool isGlobalPort; 36 | } ServiceManagerServiceEntry; 37 | 38 | typedef struct ServiceManagerNotificationEntry { 39 | u32 id; 40 | void (*handler)(u32 id); 41 | } ServiceManagerNotificationEntry; 42 | 43 | typedef struct ServiceManagerContextAllocator { 44 | void* (*newSessionContext)(u8 serviceId); 45 | void (*freeSessionContext)(void *ctx); 46 | } ServiceManagerContextAllocator; 47 | 48 | Result ServiceManager_Run(const ServiceManagerServiceEntry *services, const ServiceManagerNotificationEntry *notifications, const ServiceManagerContextAllocator *allocator); 49 | -------------------------------------------------------------------------------- /arm9/source/draw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Luma3DS 3 | * Copyright (C) 2016-2020 Aurora Wright, TuxSH 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Additional Terms 7.b and 7.c of GPLv3 apply to this file: 19 | * * Requiring preservation of specified reasonable legal notices or 20 | * author attributions in that material or in the Appropriate Legal 21 | * Notices displayed by works containing it. 22 | * * Prohibiting misrepresentation of the origin of that material, 23 | * or requiring that modified versions of such material be marked in 24 | * reasonable ways as different from the original version. 25 | */ 26 | 27 | /* 28 | * Code to print to the screen by mid-kid @CakesFW 29 | * https://github.com/mid-kid/CakesForeveryWan/ 30 | */ 31 | 32 | #pragma once 33 | 34 | #include "types.h" 35 | 36 | #define SPACING_Y 10 37 | #define SPACING_X 8 38 | 39 | #define COLOR_TITLE 0xFF9900 40 | #define COLOR_WHITE 0xFFFFFF 41 | #define COLOR_RED 0x0000FF 42 | #define COLOR_GREEN 0x00FF00 43 | #define COLOR_BLACK 0x000000 44 | #define COLOR_YELLOW 0x00FFFF 45 | 46 | #define DRAW_MAX_FORMATTED_STRING_SIZE 512 47 | 48 | bool loadSplash(void); 49 | void drawCharacter(bool isTopScreen, u32 posX, u32 posY, u32 color, char character); 50 | u32 drawString(bool isTopScreen, u32 posX, u32 posY, u32 color, const char *string); 51 | 52 | __attribute__((format(printf,5,6))) 53 | u32 drawFormattedString(bool isTopScreen, u32 posX, u32 posY, u32 color, const char *fmt, ...); 54 | --------------------------------------------------------------------------------