Skip to content

Instantly share code, notes, and snippets.

View TuxSH's full-sized avatar
😼

TuxSH

😼
View GitHub Profile
@TuxSH
TuxSH / exheader.h
Last active July 30, 2017 18:17
exheader.h
/// ARM9 descriptor flags
enum
{
ARM9DESC_MOUNT_NAND = BIT(0), ///< Mount "nand:/"
ARM9DESC_MOUNT_NANDRO_RW = BIT(1), ///< Mount nand:/ro/ as read-write
ARM9DESC_MOUNT_TWLN = BIT(2), ///< Mount "twln:/"
ARM9DESC_MOUNT_WNAND = BIT(3), ///< Mount "wnand:/"
ARM9DESC_MOUNT_CARDSPI = BIT(4), ///< Mount "cardspi:/"
ARM9DESC_USE_SDIF3 = BIT(5), ///< Use SDIF3
ARM9DESC_CREATE_SEED = BIT(6), ///< Create seed (movable.sed)
@TuxSH
TuxSH / dma.s1.cdma330.s
Last active August 2, 2017 08:24
dma code found on channel 1
00000000: FLUSHP 0x2
00000002: MOV DAR, #0x00000000
00000008: MOV SAR, #0x10320000
0000000E: MOV DAR, #0x1F219540
00000014: MOV CCR, #0x00BDC2F6
0000001A: LP.0 0x1E
0000001C: WFP 0x2, periph
0000001E: LP.1 0x27
00000020: WMB
00000021: LD
@TuxSH
TuxSH / notes.txt
Last active August 13, 2017 14:55
M3i Zero-GMPZ003 notes
(word = 32-bit)
-----
Write and read commands
C5 oooooo xx 00 00 => ROM write, FIFO read 0 words write 0x200 words
C9 oooooo xx 00 00 => ROM read, FIFO read 0x200 words write 0 word
oooooo => offset in number of words (?), MSB first
@TuxSH
TuxSH / 1de27c5.diff
Last active January 16, 2018 17:23
1de27c5.diff
diff --git a/sysmodules/rosalina/source/menus/cheats.c b/sysmodules/rosalina/source/menus/cheats.c
index 3fbe273..5fb2ae7 100644
--- a/sysmodules/rosalina/source/menus/cheats.c
+++ b/sysmodules/rosalina/source/menus/cheats.c
@@ -70,8 +70,6 @@ static s32 Cheats_FetchProcessInfo(void)
u32 pidList[0x40];
s32 processAmount;
- s64 sa, textTotalRoundedSize, rodataTotalRoundedSize, dataTotalRoundedSize;
-
@TuxSH
TuxSH / ioctls.txt
Last active January 28, 2018 00:04
switch bsdsockets ioctls
_IOC(inout,group,num,len)
r B 102 4 BIOCGBLEN
w B 108 32 BIOCSETIF
w B 112 4 BIOCIMMEDIATE
r B 113 4 BIOCVERSION
r f 118 4 FIONSPACE
r f 119 4 FIONWRITE
@TuxSH
TuxSH / main.c
Created February 19, 2018 08:35
ifcfg
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <switch.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <net/if.h>
#include <arpa/inet.h>
@TuxSH
TuxSH / kernel50.py
Created March 26, 2018 00:16
Kernel 5.0 loader
# Copyright 2017 Reswitched Team
#
# Permission to use, copy, modify, and/or distribute this software for any purpose with or
# without fee is hereby granted, provided that the above copyright notice and this permission
# notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
# SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
@TuxSH
TuxSH / fs_dev.c
Last active June 5, 2019 00:29
fs_dev.c for fatfs
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <fcntl.h>
#include <sys/iosupport.h>
#include <sys/param.h>
#include <unistd.h>
Result __fastcall Kip1::ParseHeader(Kip1 **thisPtr, ProcessCreationInfo *a2, bool aslrEnabled)
{
Kip1 **v3; // x20
Kip1 *v4; // x22
__int64 textOutOffset; // x8
bool v6; // w21
ProcessCreationInfo *v7; // x19
unsigned __int64 v8; // x9
unsigned __int64 dataOutOffset; // x10
Result result; // w0
@TuxSH
TuxSH / getlastthreadinfo.md
Last active August 6, 2018 18:04
svcGetLastThreadInfo
  • GetLastThreadInfo returns the last thread of the process that was scheduled on the current core.
  • A thread holds a reference to itself; only a thread that has exited can be destroyed

Two possibilities arise:

  • the thread exited before the svc, in which case it clears cctx->scheduler->previousScheduledThread, and that field will never point to the exiting thread. This is safe.
  • the svc executes first: it fetches the last thread ptr & info with all interrupts masked. Therefore, the thread executing the svc will not be switched and no thread on the same core is going to be terminated/destroyed, this is also safe.