Skip to content

Instantly share code, notes, and snippets.

@iamahuman
iamahuman / mvdir.c
Last active June 25, 2019 18:21
(*nix) Merge two dirs w/o copying
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#ifndef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 64
#endif
#define _LARGEFILE64_SOURCE
@iamahuman
iamahuman / capiblob.py
Created March 8, 2021 15:01
Parse Crypto API certificate blobs in Windows Registry
#!/usr/bin/env python3
import sys
import os
import struct
PROP_STRUCT = struct.Struct("<3I")
# {{{ constants
PROP_IDS = {
1: "KEY_PROV_HANDLE",
@iamahuman
iamahuman / deb-decompress.c
Created April 4, 2021 08:15
Decompress inner archives (control.tar, data.tar) of Debian packages (.deb)
#define _FILE_OFFSET_BITS 64
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <limits.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
@iamahuman
iamahuman / Makefile
Last active January 1, 2022 16:59
openat() tracer
CC = gcc
CFLAGS = -O2 -g -shared -fPIC -Wall $(EXTRACFLAGS)
LDFLAGS = -Wl,-z,now,-z,relro $(EXTRALDFLAGS)
LIBS = -lunwind-x86_64 -lpthread
all: libmain.so
libmain.so: main.c
$(CC) $(CFLAGS) -o libmain.so main.c $(LDFLAGS) $(LIBS)
@iamahuman
iamahuman / gdi_argb8888_to_pargb8888.c
Created March 13, 2022 23:09
Convert ARGB8888 bitmap to Premultipled ARGB8888 bitmap (expected by GdiAlphaBlt)
#define WIN32_LEAN_AND_MEAN
#define WINVER 0x0601
#define _WIN32_WINNT 0x0601
#include <windows.h>
HBITMAP argb8888_to_pargb8888(HBITMAP hbm, HDC hdc)
{
const BLENDFUNCTION blendfn = { AC_SRC_OVER, 0, 0xff, AC_SRC_ALPHA };
HDC hdcSrc, hdcTmp1, hdcTmp2;
HBITMAP hbmRes = NULL, hbmTmp1, hbmTmp2;
@iamahuman
iamahuman / dnf-set-metalink-params.py
Last active September 1, 2023 17:17
Set metalink parameters in DNF repo config