54 lines
1.0 KiB
C
54 lines
1.0 KiB
C
W32_SharedState W32_shared_state = ZI;
|
|
|
|
////////////////////////////////
|
|
//~ @hookdef Core hooks
|
|
|
|
//- Startup
|
|
void StartupBase(void)
|
|
{
|
|
W32_SharedState *g = &W32_shared_state;
|
|
g->tls_index = TlsAlloc();
|
|
TlsSetValue(g->tls_index, 0);
|
|
}
|
|
|
|
//- Command line args
|
|
StringList GetCommandLineArgs(void)
|
|
{
|
|
StringList result = ZI;
|
|
return result;
|
|
}
|
|
|
|
//- Panic
|
|
b32 Panic(String msg)
|
|
{
|
|
char msg_cstr[4096];
|
|
CstrFromStringToBuff(StringFromArray(msg_cstr), msg);
|
|
{
|
|
u32 mb_flags = MB_SETFOREGROUND | MB_ICONERROR;
|
|
MessageBoxExA(0, msg_cstr, "Fatal error", mb_flags, 0);
|
|
}
|
|
HANDLE console_handle = GetStdHandle(STD_ERROR_HANDLE);
|
|
WriteConsoleA(console_handle, msg.text, msg.len, 0, 0);
|
|
if (IsRunningInDebugger())
|
|
{
|
|
Assert(0);
|
|
}
|
|
else
|
|
{
|
|
ExitProcess(1);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
//- Debugger check
|
|
b32 IsRunningInDebugger(void)
|
|
{
|
|
return IsDebuggerPresent();
|
|
}
|
|
|
|
//- True randomness
|
|
void TrueRand(String buffer)
|
|
{
|
|
BCryptGenRandom(BCRYPT_RNG_ALG_HANDLE, (u8 *)buffer.text, buffer.len, 0);
|
|
}
|