Skip to content

Instantly share code, notes, and snippets.

View MolecularMatters's full-sized avatar

MolecularMatters

View GitHub Profile
@MolecularMatters
MolecularMatters / main.cpp
Created July 26, 2022 10:10
VirtualAllocEx hang in Windows 10
#include <Windows.h>
#include <stdio.h>
#include <type_traits>
#include <algorithm>
namespace pointer
{
template <typename T>
@MolecularMatters
MolecularMatters / record_to_layout.cpp
Last active January 20, 2022 13:21
Safely casting records of different types to correct class types
#include <cstdint>
#include <assert.h>
/*
base approach: each class corresponds to the layout of a symbol of a certain kind.
however, there is no relationship between any of the SymbolRecordKind values and the corresponding class layout.
this leads to more copy-and-paste errors and makes it harder to enforce that the underlying data is cast correctly.
*/
enum class SymbolRecordKind : uint16_t
#include <Windows.h>
#include <stdio.h>
#include <chrono>
static const int COUNT = 50000u;
int main()
{
DWORD charCount = MAX_PATH;