Skip to content

Instantly share code, notes, and snippets.

View mmozeiko's full-sized avatar

Mārtiņš Možeiko mmozeiko

View GitHub Profile
@mmozeiko
mmozeiko / build.cmd
Last active March 27, 2024 04:20
download & build llvm+clang on Windows
@echo off
setlocal enabledelayedexpansion
rem !!! build requirements !!!
rem Visual Studio 2022 - https://visualstudio.microsoft.com/vs/
rem 7-Zip - https://www.7-zip.org/download.html
rem Python - https://www.python.org/downloads/
rem CMake - http://www.cmake.org/download/
rem ninja.exe - https://github.com/ninja-build/ninja/releases/latest
@mmozeiko
mmozeiko / etw_createfile.c
Last active March 14, 2024 00:14
Monitor which files are accessed with ETW
// this code will work only when compiled as 64-bit code, and on Windows 10
// older Windows version might require different structure definitions
#define NOMINMAX
#define INITGUID
#include <windows.h>
#include <evntrace.h>
#include <evntcons.h>
#pragma comment (lib, "shell32.lib")
@mmozeiko
mmozeiko / _d3d11_hook_and_cofm_shader_replacement.md
Last active January 3, 2021 01:11
d3d11 hook + cofm shader replacement
  1. compile dxgi.c & d3d11.c files - these create dxgi.dll and d3d11.dll that allows to dump & replace shaders.
cl.exe /nologo /O2 /W3 /MT dxgi.c /link /DLL /OUT:dxgi.dll /INCREMENTAL:NO kernel32.lib user32.lib
cl.exe /nologo /O2 /W3 /MT d3d11.c /link /DLL /OUT:d3d11.dll /INCREMENTAL:NO kernel32.lib user32.lib d3dcompiler.lib dxguid.lib shlwapi.lib
  1. put dxgi.dll and d3d11.dll files next to ChildrenOfMorta.exe

  2. create d3d11_shaders folder next to ChildrenOfMorta.exe and put ps_b1c05ceb9ca8a14c.hlsl into this folder.

@mmozeiko
mmozeiko / write_bmp.c
Created September 23, 2020 00:57
saving simple 32-bit RGBA top-down bmp file
#include <stdarg.h>
#include <stdio.h>
static void write(FILE* f, const char* fmt, ...)
{
va_list ap;
va_start(ap, fmt);
char ch;
while ((ch = *fmt++))
{
@mmozeiko
mmozeiko / astar.h
Last active December 29, 2023 10:18
generic A* in C
// generic A* pathfinding
//
// INTERFACE
//
// mandatory macros
#ifndef ASTAR_POS_TYPE
#error ASTAR_POS_TYPE should specify position type
@mmozeiko
mmozeiko / GLES.txt
Last active July 26, 2020 22:36
Nvidia Jetson Nano info
EGL_VERSION: 1.5
EGL_VENDOR: NVIDIA
EGL_EXTENSIONS:
EGL_EXT_buffer_age, EGL_EXT_client_sync,
EGL_EXT_create_context_robustness, EGL_EXT_output_base,
EGL_EXT_stream_acquire_mode, EGL_EXT_sync_reuse, EGL_IMG_context_priority,
EGL_KHR_config_attribs, EGL_KHR_create_context_no_error,
EGL_KHR_context_flush_control, EGL_KHR_create_context,
EGL_KHR_display_reference, EGL_KHR_fence_sync,
EGL_KHR_get_all_proc_addresses, EGL_KHR_partial_update,
@mmozeiko
mmozeiko / meow_hash_armv8.h
Last active December 22, 2023 17:02
Meow v0.5 in C and ARMv8
#pragma once
#define MEOW_HASH_VERSION 5
#define MEOW_HASH_VERSION_NAME "0.5/calico"
// Meow hash v0.5 with ARMv8 Crypto Extension instructions
// Ported from https://github.com/cmuratori/meow_hash
// Performance on Pine A64 (Cortex-A53, 1.2GHz)
// (compiled with clang v10.0 with -O3 -mcpu=cortex-a53)
@mmozeiko
mmozeiko / meow_hash_c.h
Created June 29, 2020 00:19
Meow v0.5 in C
#pragma once
#define MEOW_HASH_VERSION 5
#define MEOW_HASH_VERSION_NAME "0.5/calico"
// Meow hash v0.5 in C without dependency on special CPU instructions
// Ported from https://github.com/cmuratori/meow_hash
// Performance on Ryzen 9 3950X
// AESNI code = ~16 bytes/cycle
@mmozeiko
mmozeiko / zipit.py
Last active June 25, 2020 00:17
Create zip file with explicitly setting +x permissions
#!/usr/bin/env python3
import os
import os.path
import sys
from datetime import datetime
from zipfile import ZipFile, ZipInfo, ZIP_DEFLATED
# which files to make executable
EXECUTABLE = [
@mmozeiko
mmozeiko / info.txt
Created June 7, 2020 06:35
OpenGL info with mesa v3d on RaspberryPi 4+ with 64-bit ArchLinuxArm (aarch64)
$ cat /etc/issue
Arch Linux \r (\l)
$ uname -a
Linux archlinux 5.4.38-1-ARCH #1 SMP PREEMPT Wed May 6 11:05:57 MDT 2020 aarch64 GNU/Linux
##### EGL info
EGL client extensions = EGL_EXT_client_extensions EGL_EXT_device_base EGL_EXT_device_enumeration EGL_EXT_device_query EGL_EXT_platform_base EGL_KHR_client_get_all_proc_addresses EGL_KHR_debug EGL_EXT_platform_device EGL_MESA_platform_gbm EGL_KHR_platform_gbm