Skip to content

Instantly share code, notes, and snippets.

@vgmoose
vgmoose / readme.md
Last active July 12, 2022 20:31
Mario 3D All Stars - Mario 64 Shindou Edition BLJ mod
//
// This file should be used in the following way:
// - reload executable into IDA with using switch -c
// - use File, Load IDC file and load this file.
//
// NOTE: This file doesn't contain all information from the database.
//
#define UNLOADED_FILE 1
#include <idc.idc>
int mprotect(void *addr, void *base, size_t len, int prot)
{
Result rc=0;
static bool isMapped=false;
Handle hProc = envGetOwnProcessHandle();
if (isMapped) {
rc=svcUnmapProcessCodeMemory(hProc, (u64)addr, (u64)base, len);
if (R_FAILED(rc)) {
printf(" Error, svcUnmapProcessCodeMemory() failed w. rc: %X\n", rc);
from Crypto.Cipher import AES
from Crypto.Util import Counter
import struct
"""
typedef struct boot_dat_hdr
{
unsigned char ident[0x10];
unsigned char sha2_s2[0x20];
unsigned int s2_dst;
@tesnos6921
tesnos6921 / info.md
Last active January 5, 2019 16:58
patchnso.py + sample patches for SMO 1.2.0

patchnso.py: a simple script to patch the .text sections of nso files and reassemble them

Python 2.7, requires lz4 module to be installed

Usage Instructions:

  1. Using hactool, extract the exefs of your game
  2. Within the exefsdir, there should be "main" and "main.npdm" and possibly a few others
  3. "main" is the game's main nso, you can load it into IDA and create your own patches or go out and find some
  4. When you have your patches put them all in a file in this format: (all values should be in hex) location:codepatch Example:
#include <string.h>
#include <stdio.h>
#include <switch.h>
static Handle g_port;
static uint64_t g_procID;
#define MODULE_HBL 111
0xbc100: ; save start
mov x19, x0
mov x0, #0xC0000000
adrp x1, #0x15000
ldr x1, [x1, #0x730]
ldr x1, [x1]
add x0, x1, x0
adrp x1, #0x15000
ldr x1, [x1, #0x668]
ldr x1, [x1]
[Patched Kernel]
kernel=kernel.bin
[Patched SecureMonitor]
secmon=secmon.bin
[Injected KIP1]
kip1=sysmodule.kip1
# You can mix options in the individual sections, possible are 'warmboot', 'secmon', 'kernel', 'kip1'.
@SciresM
SciresM / Loader_1_0_0.idc
Created April 25, 2018 23:18
IDCs for the Nintendo Switch's "Loader" sysmodule.
This file has been truncated, but you can view the full file.
#define UNLOADED_FILE 1
#include <idc.idc>
static main(void)
{
// set 'loading idc file' mode
set_inf_attr(INF_GENFLAGS, INFFL_LOADIDC|get_inf_attr(INF_GENFLAGS));
GenInfo(); // various settings
Segments(); // segmentation
Enums(); // enumerations
@SciresM
SciresM / tz_5x.idc
Created April 24, 2018 01:12
IDC for the Nintendo Switch's Secure Monitor, version 5.0.0.
#define UNLOADED_FILE 1
#include <idc.idc>
static main(void)
{
// set 'loading idc file' mode
set_inf_attr(INF_GENFLAGS, INFFL_LOADIDC|get_inf_attr(INF_GENFLAGS));
GenInfo(); // various settings
Segments(); // segmentation
Enums(); // enumerations