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 / 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