Pyrogenesis  trunk
Functions | Variables
wutil.cpp File Reference
#include "precompiled.h"
#include "lib/sysdep/os/win/wutil.h"
#include <stdio.h>
#include <stdlib.h>
#include "lib/file/file.h"
#include "lib/posix/posix.h"
#include "lib/sysdep/sysdep.h"
#include "lib/sysdep/os/win/win.h"
#include "lib/sysdep/os/win/wdbg.h"
#include "lib/sysdep/os/win/winit.h"
#include <shlobj.h>
#include <SDL_loadso.h>
#include <SDL_syswm.h>
Include dependency graph for wutil.cpp:

Functions

 WINIT_REGISTER_EARLY_INIT (wutil_Init)
 
 WINIT_REGISTER_LATE_SHUTDOWN (wutil_Shutdown)
 
void * wutil_Allocate (size_t size)
 
void wutil_Free (void *p)
 
void wutil_Lock (WinLockId id)
 
void wutil_Unlock (WinLockId id)
 
bool wutil_IsLocked (WinLockId id)
 
static void InitLocks ()
 
static void ShutdownLocks ()
 
Status StatusFromWin ()
 
const OsPathwutil_SystemPath ()
 
const OsPathwutil_ExecutablePath ()
 
const OsPathwutil_LocalAppdataPath ()
 
const OsPathwutil_RoamingAppdataPath ()
 
const OsPathwutil_PersonalPath ()
 
static OsPathGetFolderPath (int csidl)
 
static void GetDirectories ()
 
static void FreeDirectories ()
 
static void EnableLowFragmentationHeap ()
 
static WUTIL_FUNC (pIsWow64Process, BOOL,(HANDLE, PBOOL))
 
static WUTIL_FUNC (pWow64DisableWow64FsRedirection, BOOL,(PVOID *))
 
static WUTIL_FUNC (pWow64RevertWow64FsRedirection, BOOL,(PVOID))
 
static void ImportWow64Functions ()
 
static void DetectWow64 ()
 
bool wutil_IsWow64 ()
 
Status wutil_SetPrivilege (const wchar_t *privilege, bool enable)
 
HMODULE wutil_LibModuleHandle ()
 
void wutil_SetAppWindow (SDL_Window *window)
 
void * wutil_GetAppHDC ()
 
void wutil_SetAppWindow (void *hwnd)
 
HWND wutil_AppWindow ()
 
void wutil_EnableHiDPIOnWindows ()
 
static Status wutil_Init ()
 
static Status wutil_Shutdown ()
 

Variables

const char * main_window_name
 
static CRITICAL_SECTION cs [NUM_CS]
 
static bool cs_valid
 
static OsPathsystemPath
 
static OsPathexecutablePath
 
static OsPathlocalAppdataPath
 
static OsPathroamingAppdataPath
 
static OsPathpersonalPath
 
static bool isWow64
 
static HWND hAppWindow
 

Function Documentation

◆ DetectWow64()

static void DetectWow64 ( )
static

◆ EnableLowFragmentationHeap()

static void EnableLowFragmentationHeap ( )
static

◆ FreeDirectories()

static void FreeDirectories ( )
static

◆ GetDirectories()

static void GetDirectories ( )
static

◆ GetFolderPath()

static OsPath* GetFolderPath ( int  csidl)
static

◆ ImportWow64Functions()

static void ImportWow64Functions ( )
static

◆ InitLocks()

static void InitLocks ( )
static

◆ ShutdownLocks()

static void ShutdownLocks ( )
static

◆ StatusFromWin()

Status StatusFromWin ( )
Returns
the Status equivalent of GetLastError(), or ERR::FAIL if there's no equivalent. SetLastError(0) should be called before the Windows function to make sure no stale errors are returned.

◆ WINIT_REGISTER_EARLY_INIT()

WINIT_REGISTER_EARLY_INIT ( wutil_Init  )

◆ WINIT_REGISTER_LATE_SHUTDOWN()

WINIT_REGISTER_LATE_SHUTDOWN ( wutil_Shutdown  )

◆ wutil_Allocate()

void* wutil_Allocate ( size_t  size)

◆ wutil_AppWindow()

HWND wutil_AppWindow ( )
Returns
handle to the first window owned by the current process, or 0 if none exist (e.g. it hasn't yet created one).

enumerates all top-level windows and stops if PID matches. once this function returns a non-NULL handle, it will always return that cached value.

◆ wutil_EnableHiDPIOnWindows()

void wutil_EnableHiDPIOnWindows ( )

◆ wutil_ExecutablePath()

const OsPath& wutil_ExecutablePath ( )

◆ wutil_Free()

void wutil_Free ( void *  p)

◆ WUTIL_FUNC() [1/3]

static WUTIL_FUNC ( pIsWow64Process  ,
BOOL  ,
(HANDLE, PBOOL)   
)
static

◆ WUTIL_FUNC() [2/3]

static WUTIL_FUNC ( pWow64DisableWow64FsRedirection  ,
BOOL  ,
(PVOID *)   
)
static

◆ WUTIL_FUNC() [3/3]

static WUTIL_FUNC ( pWow64RevertWow64FsRedirection  ,
BOOL  ,
(PVOID)   
)
static

◆ wutil_GetAppHDC()

void* wutil_GetAppHDC ( )

◆ wutil_Init()

static Status wutil_Init ( )
static

◆ wutil_IsLocked()

bool wutil_IsLocked ( WinLockId  id)

◆ wutil_IsWow64()

bool wutil_IsWow64 ( )

◆ wutil_LibModuleHandle()

HMODULE wutil_LibModuleHandle ( )
Returns
module handle of lib code (that of the main EXE if linked statically, otherwise the DLL). this is necessary for the error dialog.

◆ wutil_LocalAppdataPath()

const OsPath& wutil_LocalAppdataPath ( )

◆ wutil_Lock()

void wutil_Lock ( WinLockId  id)

◆ wutil_PersonalPath()

const OsPath& wutil_PersonalPath ( )

◆ wutil_RoamingAppdataPath()

const OsPath& wutil_RoamingAppdataPath ( )

◆ wutil_SetAppWindow() [1/2]

void wutil_SetAppWindow ( SDL_Window window)

◆ wutil_SetAppWindow() [2/2]

void wutil_SetAppWindow ( void *  hwnd)

◆ wutil_SetPrivilege()

Status wutil_SetPrivilege ( const wchar_t *  privilege,
bool  enable 
)

◆ wutil_Shutdown()

static Status wutil_Shutdown ( )
static

◆ wutil_SystemPath()

const OsPath& wutil_SystemPath ( )

◆ wutil_Unlock()

void wutil_Unlock ( WinLockId  id)

Variable Documentation

◆ cs

CRITICAL_SECTION cs[NUM_CS]
static

◆ cs_valid

bool cs_valid
static

◆ executablePath

OsPath* executablePath
static

◆ hAppWindow

HWND hAppWindow
static

◆ isWow64

bool isWow64
static

◆ localAppdataPath

OsPath* localAppdataPath
static

◆ main_window_name

const char* main_window_name

◆ personalPath

OsPath* personalPath
static

◆ roamingAppdataPath

OsPath* roamingAppdataPath
static

◆ systemPath

OsPath* systemPath
static