//////////////////////////////////////////////////////////// //~ Win32 libs //- Windows headers #define COBJMACROS #define WIN32_LEAN_AND_MEAN #define UNICODE #pragma warning(push, 0) #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #pragma warning(pop) #ifndef BCRYPT_RNG_ALG_HANDLE #define BCRYPT_RNG_ALG_HANDLE ((void *)0x00000081) u32 BCryptGenRandom(void *algorithm, u8 *buffer, u32 buffer_size, u32 flags); #endif //- Windows libs #pragma comment(lib, "kernel32") #pragma comment(lib, "user32") #pragma comment(lib, "bcrypt") #pragma comment(lib, "shell32") #pragma comment(lib, "ole32") #pragma comment(lib, "winmm") #pragma comment(lib, "dwmapi") #pragma comment(lib, "synchronization") #pragma comment(lib, "avrt") #pragma comment(lib, "ws2_32.lib") //////////////////////////////////////////////////////////// //~ Embedded data iter types Struct(W32_FindEmbeddedDataCtx) { u64 embedded_strings_count; String embedded_strings[64]; }; //////////////////////////////////////////////////////////// //~ State types #define W32_MaxOnExitFuncs 4096 Struct(W32_SharedState) { SYSTEM_INFO info; u32 main_thread_id; Atomic32 shutdown; Atomic32 exit_code; i64 timer_start_qpc; i64 ns_per_qpc; StringList raw_command_line; //- Application control flow Atomic32 panicking; wchar_t panic_wstr[4096]; HANDLE panic_event; HANDLE exit_begin_event; //- Exit funcs Atomic32 num_exit_funcs; ExitFunc *exit_funcs[W32_MaxOnExitFuncs]; } extern W32_shared_state; //////////////////////////////////////////////////////////// //~ Embedded data initialization #define W32_EmbeddedDataPrefix EMBEDDED_RESOURCE_DATA__ BOOL W32_FindEmbeddedRcData(HMODULE module, LPCWSTR type, LPWSTR wstr_entry_name, LONG_PTR udata); //////////////////////////////////////////////////////////// //~ Main i32 W32_Main(void);