Skip to content

Instantly share code, notes, and snippets.

View CookiePLMonster's full-sized avatar

Silent CookiePLMonster

View GitHub Profile
@CookiePLMonster
CookiePLMonster / dinput-test.cpp
Created September 9, 2023 18:05
DirectInput 3-7 test app, for testing dinputto8
#include <Windows.h>
#include <iomanip>
#include <iostream>
#pragma comment(lib, "dxguid.lib")
#define DIRECTINPUT_VERSION 0x700
#include <dinput.h>
@CookiePLMonster
CookiePLMonster / unpack_rom.py
Created January 21, 2022 20:19
Unpacker for NES ROMs included in Memorial Series games
import sys
import os
if len(sys.argv) < 2:
exit()
# Dump all files specified in the command line
for arg in sys.argv[1:]:
decrypted = []
@CookiePLMonster
CookiePLMonster / migrate_launchbox_playtime.py
Created December 11, 2021 14:15
Migrate LaunchBox playtime from the PlaytimeTracker plugin to a native XML entry
import os
import re
import sys
import datetime
import xml.etree.ElementTree as ET
PLATFORMS_DIR = 'Data/Platforms'
PLAYTIME_PLUGIN_DIR = 'Plugins/PlaytimeTracker'
if len(sys.argv) > 1:
@CookiePLMonster
CookiePLMonster / imported_patch.yml
Created October 2, 2021 15:03
Stuntman Ignition crash workaround
Version: 1.2
PPU-ca1f38fe2396cb3c99cac50faffca4ed340b3748:
"Crash workaround":
Games:
"Stuntman Ignition":
BLUS30073: [ 01.02 ]
Author: "Silent"
Patch Version: 1.0
Patch:
@CookiePLMonster
CookiePLMonster / VDFParser.hpp
Last active May 16, 2021 21:29
Simple VDF (Valve Data Format) parser
#pragma once
#include <fstream>
#include <istream>
#include <iomanip>
#include <memory>
#include <unordered_map>
#include <variant>
class VDFParser
@CookiePLMonster
CookiePLMonster / repro.cpp
Created March 2, 2021 23:42
"Invalid template argument, expected compile-time constant expression" VS16.9.0 bug
#pragma once
#include <array>
#include <cstddef>
#include <cstdint>
#include <type_traits>
namespace detail {
template<typename T, std::size_t rank, std::size_t... sizes>
struct DimensionalArrayExplicitRank;
@CookiePLMonster
CookiePLMonster / repro.cpp
Last active September 16, 2020 13:23 — forked from riverar/repro.cpp
VS optimizer bug sample
#include <iostream>
#include <cmath>
// Sample of an optimizer bug in Visual Studio 2003 - 2019 (or more)
//
// Compiling this program in Release (/O1, /O2 or /Ox and LTCG) in both x86 and x64
// configurations produces a different output from unoptimized (Debug) configurations.
//
// Expected output: 709
// Produced output: 31
@CookiePLMonster
CookiePLMonster / RuntimeDyldELF.diff
Created February 1, 2020 20:44
LLVM RuntimeDyldELF SmallVector crash fix
--- lib\ExecutionEngine\RuntimeDyld\RuntimeDyldELF.cpp (A) 2020-02-01 21:42:12.039755300 +0100
+++ lib\ExecutionEngine\RuntimeDyld\RuntimeDyldELF.cpp (B) 2020-02-01 21:07:03.168621000 +0100
@@ -926,8 +926,7 @@
// symbol in the target address space.
void RuntimeDyldELF::resolveRelocation(const RelocationEntry &RE,
uint64_t Value) {
- const SectionEntry &Section = Sections[RE.SectionID];
- return resolveRelocation(Section, RE.Offset, Value, RE.RelType, RE.Addend,
+ return resolveRelocation(Sections[RE.SectionID], RE.Offset, Value, RE.RelType, RE.Addend,
RE.SymOffset, RE.SectionID);
@CookiePLMonster
CookiePLMonster / dinput8-bug-sample.cpp
Created August 2, 2019 16:38
Windows 10 dinput8.dll premature deinitialization bug
// Simple test program for Windows 10's dinput8.dll premature deinitialization bug
// Adrian Zdanowicz (Silent), 2019
// This basic program showcases an issue with how dinput8 queues a work item in its own DllMain.
// The issue comes from a fact that unloading dinput8 does not wait for this work item to finish,
// so if it's not quick enough, DLL will get unloaded while a thread pool still executes this work item.
// To observe the crash:
// - With a ready executable, add it to Application Verifier.
// - Uncheck all tests excepts Basic -> Threadpool test and save changes.
@CookiePLMonster
CookiePLMonster / flatten-screenshots.py
Last active March 25, 2019 19:14
Flatten Vita's SCREENSHOT directory, and unhide files
import os
import sys
import subprocess
extensions = [".png", ".jpg", ".bmp"]
rootpath = os.path.normpath(os.path.join(sys.argv[1], os.sep, 'picture', 'SCREENSHOT')) if len(sys.argv) > 1 else '.'
dir_list = os.walk(rootpath)
next(dir_list) # Skip root path
for root, dirs, files in dir_list: