Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View rossy's full-sized avatar
👊
平気、へっちゃら!

James Ross-Gowan rossy

👊
平気、へっちゃら!
View GitHub Profile
@rossy
rossy / loadlibrary_system.c
Created June 25, 2013 07:08
Safe LoadLibrary for DLLs that are expected to be in system32
#include <windows.h>
#include <wchar.h>
#define LOAD_LIBRARY_SEARCH_SYSTEM32 (0x00000800)
HMODULE loadlibrary_system(const wchar_t* name)
{
/* If running on Windows 8 or a system with KB2533623, LoadLibraryEx with
LOAD_LIBRARY_SEARCH_SYSTEM32 does the right thing */
if (GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "AddDllDirectory"))
@rossy
rossy / dark-mode.c
Created September 21, 2019 13:14
Windows 10 dark mode
#include <windows.h>
#include <uxtheme.h>
#include <dwmapi.h>
#define DWMWA_USE_IMMERSIVE_DARK_MODE 19
extern IMAGE_DOS_HEADER __ImageBase;
#define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase)
struct window {
@rossy
rossy / mpv.log
Created January 24, 2022 13:43
gpu-next d3d11 feature level 10_0 log
[ 0.006][v][cplayer] mpv 0.34.0-154-gd92c4238da Copyright © 2000-2021 mpv/MPlayer/mplayer2 projects
[ 0.006][v][cplayer] built on Mon Jan 24 23:47:15 AEDT 2022
[ 0.006][v][cplayer] FFmpeg library versions:
[ 0.007][v][cplayer] libavutil 56.70.100
[ 0.007][v][cplayer] libavcodec 58.134.100
[ 0.007][v][cplayer] libavformat 58.76.100
[ 0.007][v][cplayer] libswscale 5.9.100
[ 0.007][v][cplayer] libavfilter 7.110.100
[ 0.007][v][cplayer] libswresample 3.9.100
[ 0.007][v][cplayer] FFmpeg version: 4.4.1
@rossy
rossy / hole-struct.c
Created January 12, 2022 03:34
Demonstration of how struct padding byte values are unspecified (YMMV depending on compiler)
// clang -Wall -O0 hole-struct.c -o hole-struct
// gcc -Wall -O0 hole-struct.c -o hole-struct
#include <stdio.h>
#include <string.h>
struct hole_struct {
char a;
// char hole1[3];
int b;
@rossy
rossy / dxinteropcaps.c
Last active July 28, 2021 20:46
GL/DX interop capabilities viewer
// gcc dxinteropcaps.c -std=c99 -Wall -o dxinteropcaps -lgdi32 -lopengl32 -ld3d9 -O0 -ggdb3
#define _WIN32_WINNT 0x0600
#define COBJMACROS
#define UNICODE
#define _UNICODE
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
@rossy
rossy / unround.c
Created June 30, 2021 14:09
Windows 11 rounded windows
#include <stdbool.h>
#include <windows.h>
#include <dwmapi.h>
extern IMAGE_DOS_HEADER __ImageBase;
#define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase)
#define DWMWA_WINDOW_CORNER_PREFERENCE (33)
typedef enum {
#include <stdio.h>
#include <windows.h>
static CALLBACK DWORD read_thread(void *arg)
{
HANDLE pipe = arg;
OVERLAPPED ol = { .hEvent = CreateEventW(NULL, TRUE, TRUE, NULL) };
HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
char outbuf[128];
#include <stdio.h>
#include <string.h>
#include <windows.h>
static CALLBACK DWORD discard_thread(void *arg)
{
HANDLE pipe = arg;
OVERLAPPED ol = { 0 };
ol.hEvent = CreateEventW(NULL, TRUE, TRUE, NULL);
#define PLAYLIST_ITEMS (50)
#define RAND_WINDOWS (1)
#define RAND_FREEBSD (2)
#define USE_RAND RAND_WINDOWS
#define BIG_PLAYLIST (PLAYLIST_ITEMS > 50)
#define _CRT_RAND_S
#define __USE_MINGW_ANSI_STDIO
Adapter 0:
Device Name: NVIDIA GeForce GTX 670
Device ID: 10de:1189 (rev a1)
Subsystem ID: 1043:841a
LUID: 0000000000009c30
Output 0:
Device Name: \\.\DISPLAY1
Coordinates: 2560x1440+0+0
Attached to desktop: TRUE
Bits-per-color: 8