Skip to content

Instantly share code, notes, and snippets.

View CookiePLMonster's full-sized avatar

Silent CookiePLMonster

View GitHub Profile
@CookiePLMonster
CookiePLMonster / sincos.cpp
Last active January 7, 2018 01:21
SSE2 sincos VS15.5.2 issue
#include <iostream>
#include <cmath>
// Compile in Release, x86
// /arch:IA32, /fp:fast
// Resulting code contains SSE opcodes and calls ___libm_sse2_sincosf_
int main()
{
float val = 0.0f;
std::cin >> val;
@CookiePLMonster
CookiePLMonster / auralux2-critsec.md
Created June 14, 2018 20:24
Auralux Constellations

All memory addresses are in relation to the latest public executable (SHA-1: 8CADA155720C5D05596D0838D014E3E018F0708B).

With Application Verifier enabled, an unitialized critical section shows up:

=======================================
VERIFIER STOP 00000210: pid 0x2AA8: Critical section not initialized. 

	14A16FBC : Critical section address. Run !cs -s <address> to get more information.
	1418EFE0 : Critical section debug info address.
@CookiePLMonster
CookiePLMonster / skin-shader.fx
Created June 22, 2018 12:51
CRC2005 skinning shader
//
// Generated by Microsoft (R) D3DX9 Fragment Linker 5.04.00.2904
//
// Parameters:
//
// float4x3 BoneWorldViewT[70];
// float4 FogParams;
// float3 LightAmbientDown;
// float3 LightAmbientUp;
// float3 LightDiffuse;
//
// Generated by Microsoft (R) D3DX9 Fragment Linker 5.04.00.2904
//
// Parameters:
//
// float4x3 BoneWorldViewT[70];
// float4 FogParams;
// float3 LightAmbientDown;
// float3 LightAmbientUp;
// float3 LightDiffuse;
@CookiePLMonster
CookiePLMonster / SafeShutdown.py
Created January 2, 2019 10:54
MegaPi modified Safe Shutdown
#!/usr/bin/env python3
from gpiozero import Button, LED
import os
from signal import pause
import subprocess
resetPin = 2
ledPin = 14
powerenPin = 4
hold = 2
@CookiePLMonster
CookiePLMonster / randimage.py
Last active February 21, 2019 21:01
Random shuffle on image pixels (based on https://stackoverflow.com/a/52437794/9214270)
import scipy.ndimage
import scipy.misc
import numpy as np
import sys
import os.path
if len(sys.argv) < 2:
exit(1)
numShuffles = 1 if len(sys.argv) < 3 else int(sys.argv[2])
@CookiePLMonster
CookiePLMonster / SafeShutdown.py
Created February 25, 2019 18:13
Safe Shutdown Script
#!/usr/bin/env python3
from gpiozero import Button, LED, OutputDevice
import os
from signal import pause
import subprocess
from time import sleep
resetPin = 2
ledPin = 14
powerenPin = 4
@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:
@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 / 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);