Skip to content

Instantly share code, notes, and snippets.

View hydranix's full-sized avatar

Hydranix hydranix

  • San Francisco Bay Area, California
View GitHub Profile
@hydranix
hydranix / gist:87eed6c5c38cb52c7ba98a159302647e
Created March 2, 2023 04:02
Regex to convert C++ const-ref parameter signature
I wanted an easy way to change the ordering of a bunch of
const ref function parameters in visual studio
warning: not all corner cases are covered, use it carefully
Search for:
(const)\s+(\w+)(&)\s+(\w+[^\w])
Replace with:
$2 $1$3 $4
@hydranix
hydranix / gist:b8af0c197a1cc11429da600c33c15418
Created April 16, 2017 14:35
[Undocumented WinAPI] Timer Resolution
// From Oskar Dahlberg's post at:
// http://stackoverflow.com/a/31411628/4725495
#include <Windows.h>
static NTSTATUS(__stdcall *NtDelayExecution)(BOOL Alertable, PLARGE_INTEGER DelayInterval) = (NTSTATUS(__stdcall*)(BOOL, PLARGE_INTEGER)) GetProcAddress(GetModuleHandle("ntdll.dll"), "NtDelayExecution");
static NTSTATUS(__stdcall *ZwSetTimerResolution)(IN ULONG RequestedResolution, IN BOOLEAN Set, OUT PULONG ActualResolution) = (NTSTATUS(__stdcall*)(ULONG, BOOLEAN, PULONG)) GetProcAddress(GetModuleHandle("ntdll.dll"), "ZwSetTimerResolution");