Skip to content

Instantly share code, notes, and snippets.

@jeremyd2019
jeremyd2019 / windows_releases.md
Created March 28, 2025 19:14
windows releases
Build number Pretty version Silly name
9200 8
9600 8.1
10240 10
10586 10 1511
14393 10 1607 Anniversary
15063 10 1703 Creators
16299 10 1709 Fall Creators
17134 10 1803
@jeremyd2019
jeremyd2019 / find_fast_cwd.cc
Last active April 9, 2025 09:34
prototype code to find fast cwd pointer on arm64
#include <windows.h>
/* hacks on top of hacks ... */
#define _PEB _NOT__PEB
#define PEB _NOT_PEB
#define PPEB _NOT_PPEB
#define _TEB _NOT__TEB
#define TEB _NOT_TEB
#define PTEB _NOT_PTEB
#include <winternl.h>
#undef _PEB
@jeremyd2019
jeremyd2019 / iswow64process2_aarch64.exe
Last active November 22, 2024 19:44
prototype code for identifying wow64 in cygwin uname
@jeremyd2019
jeremyd2019 / wine-arch-detector.c
Last active June 20, 2024 19:56
exec proper wine based on arch of PE binary
/* Register with:
* echo :wine:M::MZ::/opt/wine-arch-detector:PO > /proc/sys/fs/binfmt_misc/register
*/
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/auxv.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
@jeremyd2019
jeremyd2019 / cygwin_volumes.c
Created June 4, 2024 00:19
use cygwin functions to list windows volume roots as `\0`-delimited cygwin paths
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/cygwin.h>
struct dos_drive_mappings
{
struct mapping
{
struct mapping *next;
@jeremyd2019
jeremyd2019 / cygwin.py
Last active February 20, 2025 23:55
python ctypes interface to cygwin apis
import contextlib
import ctypes
import errno
import os
__all__ = ["CCP_POSIX_TO_WIN_A", "CCP_POSIX_TO_WIN_W",
"CCP_WIN_A_TO_POSIX", "CCP_WIN_W_TO_POSIX",
"CCP_ABSOLUTE", "CCP_RELATIVE", "CCP_PROC_CYGDRIVE",
"cygwin_conv_path", "cygwin_conv_path_list",
"cygwin_winpid_to_pid", "cygwin_pid_to_winpid",
@jeremyd2019
jeremyd2019 / volumes.c
Last active May 30, 2024 23:47
list windows volume roots as `\0`-delimited cygwin paths
#include <windows.h>
#include <stdio.h>
#include <wchar.h>
#include <sys/cygwin.h>
/* based on the starting point
https://learn.microsoft.com/en-us/windows/win32/fileio/displaying-volume-paths
*/
void main(void)
{
@jeremyd2019
jeremyd2019 / pacman.strace.txt
Created May 27, 2024 02:37
strace of pacman trying to unlink msys-2.0.dll
122 237566414 [main] pacman 494 unlink_nt: Trying to delete \??\D:\t\msys64\usr\bin\msys-2.0.dll, isdir = 0
252 237566666 [main] pacman 494 unlink_nt: Setting delete disposition on \??\D:\t\msys64\usr\bin\msys-2.0.dll failed, status = 0xC0000121
172 237566838 [main] pacman 494 unlink_nt: Cannot delete \??\D:\t\msys64\usr\bin\msys-2.0.dll, try delete-on-close
252 237567090 [main] pacman 494 unlink_nt: Setting delete-on-close on \??\D:\t\msys64\usr\bin\msys-2.0.dll failed, status = 0xC0000121
685 237567775 [main] pacman 494 try_to_bin: Setting delete disposition on $RECYCLE.BIN\S-1-5-21-XXX\.����60000001071944502ffdd679fdc9c66a (\??\D:\t\msys64\usr\bin\msys-2.0.dll) failed, status = 0xC0000121
522 237568297 [main] pacman 494 try_to_bin: Overwriting $RECYCLE.BIN\S-1-5-21-XXX\.����60000001071944502ffdd679fdc9c66a (\??\D:\t\msys64\usr\bin\msys-2.0.dll) with $RECYCLE.BIN\S-1-5-21-XXX\.����60000001071944502ffdd679fdc9c66aX failed, status = 0xC0000022
215 237568512 [main] pacman 494 try_to_bin: \??\D:\t
@jeremyd2019
jeremyd2019 / cleanup.sh
Last active March 3, 2025 06:50
Script to clean up files that msys2-runtime moved to recycle bin because they were in use
#!/bin/bash -ex
export LC_CTYPE=C.UTF-8 LC_COLLATE=C.UTF-8
IFS=. read -r cygmajor cygminor _ < <(uname -r)
declare -a roots
if [ "${cygmajor}" -gt 3 -o "${cygmajor}" -eq 3 -a "${cygminor}" -ge 6 ]; then
# as of cygwin 3.6, volume roots are parsable from /proc/mounts
@jeremyd2019
jeremyd2019 / testfork.c
Last active May 21, 2024 00:27
reproducer for cygwin hangs under emulation on arm64
#include <stdio.h>
#include <sys/wait.h>
#include <unistd.h>
#ifndef BINARY
#define BINARY "/bin/true"
#endif
#ifndef ARG
#define ARG "0.1"