Skip to content

Instantly share code, notes, and snippets.

View Stehfyn's full-sized avatar

Stephen Foster Stehfyn

View GitHub Profile
@Stehfyn
Stehfyn / crt.c
Created September 5, 2025 15:00
crt
#define _CRTALLOC(x) __declspec(allocate(x))
//typedef void(__cdecl* _PVFV)(void);
typedef int(__cdecl* _PIFV)(void);
static int __cdecl __myscrt_cursed_modify_apptype(void)
{
PIMAGE_NT_HEADERS hdrs;
MEMORY_BASIC_INFORMATION mbi;
//FreeConsole();
#include "video.h"
#define __STDC_CONSTANT_MACROS //do we need?
#include "libavutil/imgutils.h"
//#include "lavfutils.h"
#include <libavformat/avformat.h>
#include "stdafx.h"
#include <libavcodec/avcodec.h>
@Stehfyn
Stehfyn / wfvb.c
Last active June 18, 2025 10:13
Example implementation of usage D3DKMTWaitForVerticalBlankEvent for an arbitrary HWND
typedef long LONG
typedef unsigned int UINT
typedef LONG NTSTATUS;
typedef UINT D3DKMT_HANDLE;
typedef UINT D3DDDI_VIDEO_PRESENT_SOURCE_ID;
#define D3DKMT_PTR(Type, Name) Type Name
#define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
@Stehfyn
Stehfyn / demo.cpp
Created May 29, 2025 12:36
Circumventing LongPathAware enablement with C++17's std::filesystem on Windows
/*********************************************************************\
| How to circumvent the "long path" limitation on Windows, without: |
| - Your application's manifest declaring LongPathAware |
| - The user having LongPaths enabled in their registry |
\*********************************************************************/
extern "C" {
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
}
@Stehfyn
Stehfyn / relaunch.c
Created May 22, 2025 13:13
Relaunches an executable with the cwd of its image on disk
#define STRICT
#define WIN32_LEAN_AND_MEAN
#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
#include <stdlib.h>
#include <tchar.h>
#define wtf2(y) \
((__targv[0] = (((TCHAR**)malloc(3 * sizeof(TCHAR*)))[0] = _tcsdup(__targv[0]))), __targv[1] = __targv[0], __targv[2] = 0, __targv[0])
@Stehfyn
Stehfyn / ConsoleParentProcess.cpp
Last active September 20, 2024 21:50
Minimal Win32ChildConsole example via the Win32 Console API
#define WIN32_LEAN_AND_MEAN
#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
#include <string>
// Relevant msdn blogs:
// https://devblogs.microsoft.com/commandline/windows-command-line-inside-the-windows-console/
// https://devblogs.microsoft.com/commandline/windows-command-line-introducing-the-windows-pseudo-console-conpty/
#define WINDOW_HELPER_TEMPLATE_EXE_IMAGE ("ConsoleWindowHelper.exe")
#include <GUIConstants.au3>
Global Const $MF_BYPOSITION = 0x00000400
Global Const $MF_SEPARATOR = 0x00000800
Global Const $MF_CHECKED = 0x00000008
Global Const $MF_POPUP = 0x00000010
Dim $nTPChecked = 0
@Stehfyn
Stehfyn / opengl-transparency-demo.cpp
Created April 24, 2023 03:56 — forked from wilkie/opengl-transparency-demo.cpp
Rendering directly to a composited window in vista+ with opengl.
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <windowsx.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <dwmapi.h>
#pragma comment (lib, "opengl32.lib")
@Stehfyn
Stehfyn / save_dpgplot.py
Last active November 27, 2025 14:32
Saving an image of a DearPyGui Plot
import dearpygui.dearpygui as dpg
from math import sin, cos
import numpy as np
file = ""
x_left, y_left, x_span, y_span = 0, 0, 0, 0
def _framebuffer_callback(sender, user_data):
global file, x_left, y_left, x_span, y_span
w, h = user_data.get_width(), user_data.get_height()