power_play/src/base/base_win32/base_win32.h

94 lines
2.2 KiB
C

////////////////////////////////////////////////////////////
//~ Win32 libs
//- Windows headers
#define COBJMACROS
#define WIN32_LEAN_AND_MEAN
#define UNICODE
#pragma warning(push, 0)
#include <Windows.h>
#include <combaseapi.h>
#include <dcommon.h>
#include <initguid.h>
#include <unknwn.h>
#include <objbase.h>
#include <uuids.h>
#include <Knownfolders.h>
#include <WinSock2.h>
#include <TlHelp32.h>
#include <WS2tcpip.h>
#include <windowsx.h>
#include <ShlObj_core.h>
#include <fileapi.h>
#include <dwmapi.h>
#include <avrt.h>
#include <shellapi.h>
#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);