This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__pragma(comment(linker, "/entry:main")); | |
__pragma(comment(linker, "/subsystem:console")); | |
void *(*GetProcAddress)(void *module, const char *name); | |
void *(*LoadLibraryA)(const char *name); | |
void (*ExitProcess)(unsigned int return_code); | |
int (*MessageBoxA)(void *hWnd, const char *lpText, const char *lpCaption, unsigned int uType); | |
static inline void load_proc(void *lib, void *fn, char *name) { | |
*(void **)fn = GetProcAddress(lib, name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// libs: Kernel32.lib User32.lib DbgHelp.lib msvcrt.lib (unless you have your own printf) | |
// includes: Windows.h (LEAN_AND_MEAN is ok) WinUser.h DbgHelp.h stdio.h | |
// call SymInitialize() at startup and debug_check_leaks at shutdown | |
#ifndef NDEBUG | |
static void print_stack_trace(void **stack, u64 stack_count, const char *indent) { | |
struct { | |
SYMBOL_INFO si; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Play this game by pasting the script in http://www.puzzlescript.net/editor.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef defer | |
struct defer_dummy {}; | |
template <class F> struct deferrer { F f; ~deferrer() { f(); } }; | |
template <class F> deferrer<F> operator*(defer_dummy, F f) { return {f}; } | |
#define DEFER_(LINE) zz_defer##LINE | |
#define DEFER(LINE) DEFER_(LINE) | |
#define defer auto DEFER(__LINE__) = defer_dummy{} *[&]() | |
#endif // defer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef good_assert /* Better assert() for Windows - public domain */ | |
#ifdef _WIN32 | |
#ifdef __cplusplus | |
extern "C" { | |
#endif | |
#ifndef _WINDOWS_ | |
__declspec(dllimport) int __stdcall ExitProcess(unsigned int a); | |
__declspec(dllimport) int __stdcall MessageBoxA(void *a, const char *b, | |
const char *c, unsigned int d); | |
#endif /* _WINDOWS_ */ |
NewerOlder