Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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"

Go to the source code of this file.

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

Definition at line 415 of file wutil.cpp.

static void EnableLowFragmentationHeap ( )
static

Definition at line 372 of file wutil.cpp.

static BOOL CALLBACK FindAppWindowByPid ( HWND  hWnd,
LPARAM  lParam 
)
static

Definition at line 520 of file wutil.cpp.

static void ForciblyLoadUser32Dll ( )
static

Definition at line 357 of file wutil.cpp.

static void FreeCommandLine ( )
static

Definition at line 229 of file wutil.cpp.

static void FreeDirectories ( )
static

Definition at line 324 of file wutil.cpp.

static void FreeUser32Dll ( )
static

Definition at line 363 of file wutil.cpp.

static void GetDirectories ( )
static

Definition at line 296 of file wutil.cpp.

static OsPath* GetFolderPath ( int  csidl)
static

Definition at line 284 of file wutil.cpp.

static void ImportWow64Functions ( )
static

Definition at line 408 of file wutil.cpp.

static void InitLocks ( )
static

Definition at line 103 of file wutil.cpp.

static void ReadCommandLine ( )
static

Definition at line 173 of file wutil.cpp.

static void ShutdownLocks ( )
static

Definition at line 111 of file wutil.cpp.

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.

Definition at line 125 of file wutil.cpp.

WINIT_REGISTER_EARLY_INIT ( wutil_Init  )
WINIT_REGISTER_LATE_SHUTDOWN ( wutil_Shutdown  )
void* wutil_Allocate ( size_t  size)

Definition at line 54 of file wutil.cpp.

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.

Definition at line 532 of file wutil.cpp.

int wutil_argc ( )

Definition at line 217 of file wutil.cpp.

wchar_t** wutil_argv ( )

Definition at line 222 of file wutil.cpp.

const OsPath& wutil_ExecutablePath ( )

Definition at line 263 of file wutil.cpp.

void wutil_Free ( void *  p)

Definition at line 60 of file wutil.cpp.

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)

Definition at line 236 of file wutil.cpp.

static Status wutil_Init ( )
static

Definition at line 546 of file wutil.cpp.

bool wutil_IsLocked ( WinLockId  id)

Definition at line 91 of file wutil.cpp.

bool wutil_IsWow64 ( )

Definition at line 430 of file wutil.cpp.

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.

Definition at line 490 of file wutil.cpp.

const OsPath& wutil_LocalAppdataPath ( )

Definition at line 268 of file wutil.cpp.

void wutil_Lock ( WinLockId  id)

Definition at line 77 of file wutil.cpp.

const OsPath& wutil_PersonalPath ( )

Definition at line 278 of file wutil.cpp.

const OsPath& wutil_RoamingAppdataPath ( )

Definition at line 273 of file wutil.cpp.

Status wutil_SetPrivilege ( const wchar_t privilege,
bool  enable 
)

Definition at line 459 of file wutil.cpp.

static Status wutil_Shutdown ( )
static

Definition at line 565 of file wutil.cpp.

const OsPath& wutil_SystemPath ( )

Definition at line 258 of file wutil.cpp.

void wutil_Unlock ( WinLockId  id)

Definition at line 84 of file wutil.cpp.

Variable Documentation

wchar_t* argvContents
static

Definition at line 168 of file wutil.cpp.

CRITICAL_SECTION cs[NUM_CS]
static

Definition at line 74 of file wutil.cpp.

bool cs_valid
static

Definition at line 75 of file wutil.cpp.

OsPath* executablePath
static

Definition at line 253 of file wutil.cpp.

HWND hAppWindow
static

Definition at line 518 of file wutil.cpp.

HMODULE hUser32Dll
static

Definition at line 355 of file wutil.cpp.

bool isWow64
static

Definition at line 406 of file wutil.cpp.

OsPath* localAppdataPath
static

Definition at line 254 of file wutil.cpp.

OsPath* personalPath
static

Definition at line 256 of file wutil.cpp.

OsPath* roamingAppdataPath
static

Definition at line 255 of file wutil.cpp.

int s_argc = 0

Definition at line 170 of file wutil.cpp.

wchar_t** s_argv = 0

Definition at line 171 of file wutil.cpp.

OsPath* systemPath
static

Definition at line 252 of file wutil.cpp.