Skip to content

Instantly share code, notes, and snippets.

@namazso
namazso / SuperReturn.c
Last active June 26, 2025 05:51
SuperReturn
/// Return, but across multiple frames.
///
/// This function unwinds the given number of frames, then sets the return value provided, emulating as if this number
/// of functions returned, with the last one returning the value provided in RetVal. Can be used to hook a callee when
/// you don't have a convenient way to hook it directly and actually just want to stub it out with a return value.
///
/// @param FramesToSkip The number of frames to skip, starting from the current frame.
/// @param RetVal The value to return from the last frame.
/// @param Context Context to start from, in case you want to SuperReturn from somewhere deeper.
DECLSPEC_NOINLINE void SuperReturn(
@namazso
namazso / tofu_totp_export.md
Last active June 27, 2025 07:55
Export Tofu TOTP tokens

1. Exporting the secrets

Make an iTunes encrypted backup which contains the Keychain, where Tofu stores all the tokens.

2. Decrypting Keychain

You'll need irestore for decrypting the keychain. Use it like this:

irestore iPhone dumpkeys dump.txt
@namazso
namazso / CMakeLists.txt
Created March 26, 2024 10:22
Universal function proxy
cmake_minimum_required(VERSION 3.28)
project(untitled C ASM)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "")
set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "")
set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug "")
set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL "")
@namazso
namazso / config.json
Created February 21, 2024 01:52
Syanpse matrix.org media piggyback for Caddy
{
"match": [
{
"host": [
"matrix.yourdomain.com"
],
"path": [
"/_matrix/media/*/download/*/*",
"/_matrix/media/*/download/*/*/*",
"/_matrix/media/*/thumbnail/*/*"
@namazso
namazso / wg-nm-firewalld.md
Last active December 24, 2023 17:02
Wireguard VPN with NetworkManager and firewalld

WireGuard VPN setup with NetworkManager and firewalld

Prerequisites

This guide uses NetworkManager and firewalld. Both of these are installed and used by default on current versions of Red Hat Enterprise Linux and Fedora.

First, test that NetworkManager is in use:

# nmcli
@namazso
namazso / ThemeManagerDemo.cs
Last active March 6, 2025 05:33
Setting themes with IThemeManager2 in C#
// Copyright (c) 2022 namazso <[email protected]>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
@namazso
namazso / settings.json
Created February 22, 2022 09:20
MSYS2 in Windows terminal
{
"commandline": "cmd /c \"set MSYSTEM=MINGW32 && set LOGINSHELL=bash && C:\\msys64\\usr\\bin\\bash.exe --login\"",
"name": "MSYS2 MinGW 32-bit",
"icon": "C:\\msys64\\mingw32.ico"
},
{
"commandline": "cmd /c \"set MSYSTEM=MINGW64 && set LOGINSHELL=bash && C:\\msys64\\usr\\bin\\bash.exe --login\"",
"name": "MSYS2 MinGW 64-bit",
"icon": "C:\\msys64\\mingw64.ico"
},
@namazso
namazso / coff.ksy
Created January 13, 2022 20:41
Kaitai Struct YAML for COFF
meta:
id: coff
title: Common Object Format File
file-extension:
- obj
license: CC0-1.0
ks-version: 0.9
endian: le
doc-ref: https://wiki.osdev.org/COFF
seq:
@namazso
namazso / flags.asm
Created December 15, 2021 07:25
get/set RFLAGS with perfect unwinding
.code
getflags PROC FRAME
pushfq
.pushreg rax
.endprolog
.beginepilog
pop rax
ret
getflags ENDP
@namazso
namazso / irc_format.cpp
Created October 15, 2021 03:29
IRC formatting parser
#include <string>
#include "irc_format.h"
struct IRCParser
{
enum State : int
{
Normal,
Color1_1,
Color1_2,