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 "lib/sysdep/os/win/wdll_main.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 ()
 
static void ReadCommandLine ()
 
int wutil_argc ()
 
wchar_t ** wutil_argv ()
 
static void FreeCommandLine ()
 
bool wutil_HasCommandLineArgument (const wchar_t *arg)
 
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 ForciblyLoadUser32Dll ()
 
static void FreeUser32Dll ()
 
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 ()
 
static BOOL CALLBACK FindAppWindowByPid (HWND hWnd, LPARAM lParam)
 
HWND wutil_AppWindow ()
 
static Status wutil_Init ()
 
static Status wutil_Shutdown ()
 

Variables

static CRITICAL_SECTION cs [NUM_CS]
 
static bool cs_valid
 
static wchar_targvContents
 
int s_argc = 0
 
wchar_t ** s_argv = 0
 
static OsPathsystemPath
 
static OsPathexecutablePath
 
static OsPathlocalAppdataPath
 
static OsPathroamingAppdataPath
 
static OsPathpersonalPath
 
static HMODULE hUser32Dll
 
static bool isWow64
 
static HWND hAppWindow
 

Function Documentation

static void DetectWow64 ( )
static
static void EnableLowFragmentationHeap ( )
static
static BOOL CALLBACK FindAppWindowByPid ( HWND  hWnd,
LPARAM  lParam 
)
static
static void ForciblyLoadUser32Dll ( )
static
static void FreeCommandLine ( )
static
static void FreeDirectories ( )
static
static void FreeUser32Dll ( )
static
static void GetDirectories ( )
static
static OsPath* GetFolderPath ( int  csidl)
static
static void ImportWow64Functions ( )
static
static void InitLocks ( )
static
static void ReadCommandLine ( )
static
static void ShutdownLocks ( )
static
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 ( wutil_Init  )
WINIT_REGISTER_LATE_SHUTDOWN ( wutil_Shutdown  )
void* wutil_Allocate ( size_t  size)
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.

int wutil_argc ( )
wchar_t** wutil_argv ( )
const OsPath& wutil_ExecutablePath ( )
void wutil_Free ( void *  p)
static WUTIL_FUNC ( pIsWow64Process  ,
BOOL  ,
(HANDLE, PBOOL)   
)
static
static WUTIL_FUNC ( pWow64DisableWow64FsRedirection  ,
BOOL  ,
(PVOID *)   
)
static
static WUTIL_FUNC ( pWow64RevertWow64FsRedirection  ,
BOOL  ,
(PVOID)   
)
static
bool wutil_HasCommandLineArgument ( const wchar_t arg)
static Status wutil_Init ( )
static
bool wutil_IsLocked ( WinLockId  id)
bool wutil_IsWow64 ( )
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.
const OsPath& wutil_LocalAppdataPath ( )
void wutil_Lock ( WinLockId  id)
const OsPath& wutil_PersonalPath ( )
const OsPath& wutil_RoamingAppdataPath ( )
Status wutil_SetPrivilege ( const wchar_t privilege,
bool  enable 
)
static Status wutil_Shutdown ( )
static
const OsPath& wutil_SystemPath ( )
void wutil_Unlock ( WinLockId  id)

Variable Documentation

wchar_t* argvContents
static
CRITICAL_SECTION cs[NUM_CS]
static
bool cs_valid
static
OsPath* executablePath
static
HWND hAppWindow
static
HMODULE hUser32Dll
static
bool isWow64
static
OsPath* localAppdataPath
static
OsPath* personalPath
static
OsPath* roamingAppdataPath
static
int s_argc = 0
wchar_t** s_argv = 0
OsPath* systemPath
static