Skip to content

Instantly share code, notes, and snippets.

@ughman
ughman / magic.py
Created August 11, 2022 23:31
C header to rust declarations hack script
import re
import sys
import os.path
import clang.cindex as ci
declarations = set()
references = set()
def traverse(node, path, decls):
for child in node.get_children():
/*
* mkpsxiso
*
* Converts an ISO to a .bin/.cue of a Playstation disk
*/
#include <stdio.h>
#include <string.h>
char iso2raw_sec[16];
@ughman
ughman / wotreplay-stat-dumper-script.py
Last active February 26, 2022 21:33
Basic statistics dump script for World of Tanks replay files
import json
import struct
import sys
import re
def read_chunk(f):
size, = struct.unpack('<I', f.read(4))
return f.read(size)
for filename in sys.argv[1:]:
@ughman
ughman / hehe.c
Created June 19, 2021 23:41
linux EISCONN client socket poc
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
int main()
{
int listening_fd = socket(AF_INET, SOCK_STREAM, 0);
if (listening_fd == -1) {
print "Hello, world!"
-- Example: Change starting level of NTSC-U Crash 2 to Ruination
write8(0x800117E4, 0xF)
-- Example: Print a message on every NTSC-U Crash 2 GOOL RNG instruction
trapexec(0x8003A368, function()
print("RNG(" .. v0 .. ", " .. v1 .. ")")
end)
#include <stdio.h>
#include <stdint.h>
const unsigned char data[128] = {
0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ughman
ughman / mingw_msvc_lib_fix.sh
Created May 9, 2018 03:15
Hack fix for MSVC broken DLL imports when using MinGW-generated LIB import libraries
# fixes strange issue when using mingw-generated import libs in msvc
#
# issue only appears if using multiple mingw-generated import libs
# simultaneously; the MSVC linker runs OK but produces a binary which
# pulls all of its import symbols from a single DLL and doesn't appear
# to pull anything from the other linked DLL's
#
# issue appears to stem from the usage of non-unique object names across
# multiple import libs (they are generated with a sequential id of some
# kind)
#include <stdio.h>
long test_short(
long a0,
long a1)
{
printf("a0: %lX\n", a0);
printf("a1: %lX\n", a1);
return 0xDEADDEADDEADDEAD;
.text
.globl dyncall
dyncall:
pushq %rbp
movq %rsp, %rbp
pushq %rdx
movl %edi, %ecx
movl %ecx, %eax
template <typename T,typename R,typename... Args,R (T::*f)(Args...)>
static void connect_signal(
GtkWidget *widget,
const char *signal,
T *t)
{
g_signal_connect(
widget,
signal,
[](Args... args,gpointer user_data) -> R {