Skip to content

Instantly share code, notes, and snippets.

View 0x1F9F1's full-sized avatar
🧱

Brick 0x1F9F1

🧱
  • Nottingham, United Kingdom
View GitHub Profile
@0x1F9F1
0x1F9F1 / ArchiveReader.cs
Last active November 8, 2017 00:59
Midtown Madness Archive Reader
using System;
using System.Text;
using System.IO;
using System.Linq;
using System.IO.Compression;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
public class MMArchiveHelper
/*
Copyright 2018 Brick
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 copies or
@0x1F9F1
0x1F9F1 / scoped_seh.h
Last active September 12, 2018 22:45
A raii based SEH to C++ exception translater
#pragma once
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <stdexcept>
#include <cstdio>
class scoped_seh
{
@0x1F9F1
0x1F9F1 / ReadModStatic.cs
Last active January 28, 2018 21:52
ReadModStatic
public static int GfxFVFOffset(int fvfFlags, int a2)
{
int result = 0;
if (a2 != 0x2)
{
result += 12;
if (a2 != 0x10)
{
@0x1F9F1
0x1F9F1 / FindModule.cpp
Last active April 6, 2023 12:22
FindModule
#include <Windows.h>
#include <TlHelp32.h>
#include <functional>
typedef struct _UNICODE_STRING
{
USHORT Length;
USHORT MaximumLength;
PWSTR Buffer;
import sqlite3
import contextlib
import os
import sys
def clean_binja_snapshots(conn, limit = 1):
with conn as cur:
for section in [ 'snapshot', 'file_data' ]:
cur.execute(f'DELETE FROM {section} WHERE id NOT IN (SELECT id FROM {section} ORDER BY id DESC LIMIT ?)', (limit,))
@0x1F9F1
0x1F9F1 / bin2hex.cpp
Created December 9, 2018 19:56
SIMD Accelerated bytes to hex string
#include <immintrin.h> // SSE
#include <emmintrin.h> // SSE2
#include <tmmintrin.h> // SSSE3
alignas(16) static constexpr const char hex_chars[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
void bin2hex(const byte* src, char* dst, size_t num) noexcept
{
if (num >= 8)
{
@0x1F9F1
0x1F9F1 / unpack_ce_trainer.py
Last active December 23, 2023 04:17
Unpack Cheat Engine Trainer
import zlib
import struct
import base64
import json
import os
import xml.etree.ElementTree as ET
ce_base85_char_map = dict(zip(
'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%()*+,-./:;=?@[]^_{}',
'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~'
@0x1F9F1
0x1F9F1 / read_bndb_snapshot.py
Created February 14, 2019 16:41
Convert a bndb snapshot to json
import struct
import json
if True:
import lzf # pip install python-lzf
else:
import ctypes
class lzf:
_lzf_dll = ctypes.CDLL('lzf.dll')
#include <cstddef>
#include <cstdint>
#include <initializer_list>
#include <limits>
#include <type_traits>
constexpr std::size_t popcount(std::uint8_t value) noexcept
{
value -= (value >> 1) & 0x55;
value = (value & 0x33) + ((value >> 2) & 0x33);