Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Macros | Enumerations | Functions
wutil.h File Reference
#include "lib/os_path.h"
#include "lib/sysdep/os/win/win.h"

Go to the source code of this file.

Classes

class  WinScopedLock
 
class  WinScopedPreserveLastError
 some WinAPI functions SetLastError(0) on success, which is bad because it can hide previous errors. More...
 
class  WinScopedDisableWow64Redirection
 

Macros

#define WUTIL_FUNC(varName, ret, params)   ret (WINAPI* varName) params
 
#define WUTIL_IMPORT(hModule, procName, varName)
 
#define WUTIL_IMPORT_KERNEL32(procName, varName)   WUTIL_IMPORT(GetModuleHandleW(L"kernel32.dll"), procName, varName)
 

Enumerations

enum  WinLockId { WDBG_SYM_CS, WDIR_WATCH_CS, NUM_CS }
 

Functions

template<typename H >
bool wutil_IsValidHandle (H h)
 
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)
 
Status StatusFromWin ()
 
int wutil_argc ()
 
wchar_t ** wutil_argv ()
 
bool wutil_HasCommandLineArgument (const wchar_t *arg)
 
const OsPathwutil_SystemPath ()
 
const OsPathwutil_ExecutablePath ()
 
const OsPathwutil_LocalAppdataPath ()
 
const OsPathwutil_RoamingAppdataPath ()
 
const OsPathwutil_PersonalPath ()
 
bool wutil_IsWow64 ()
 
LIB_API Status wutil_SetPrivilege (const wchar_t *privilege, bool enable)
 
HMODULE wutil_LibModuleHandle ()
 
HWND wutil_AppWindow ()
 

Macro Definition Documentation

#define WUTIL_FUNC (   varName,
  ret,
  params 
)    ret (WINAPI* varName) params

Definition at line 44 of file wutil.h.

#define WUTIL_IMPORT (   hModule,
  procName,
  varName 
)
Value:
const FARPROC f = GetProcAddress(hModule, #procName);\
memcpy(&varName, &f, sizeof(FARPROC));\
)
#define STMT(STMT_code__)
package code into a single statement.

Definition at line 55 of file wutil.h.

#define WUTIL_IMPORT_KERNEL32 (   procName,
  varName 
)    WUTIL_IMPORT(GetModuleHandleW(L"kernel32.dll"), procName, varName)

Definition at line 63 of file wutil.h.

Enumeration Type Documentation

enum WinLockId
Enumerator
WDBG_SYM_CS 
WDIR_WATCH_CS 
NUM_CS 

Definition at line 78 of file wutil.h.

Function Documentation

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.

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.

bool wutil_HasCommandLineArgument ( const wchar_t arg)

Definition at line 236 of file wutil.cpp.

bool wutil_IsLocked ( WinLockId  id)

Definition at line 91 of file wutil.cpp.

template<typename H >
bool wutil_IsValidHandle ( h)

Definition at line 34 of file wutil.h.

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.

LIB_API Status wutil_SetPrivilege ( const wchar_t privilege,
bool  enable 
)

Definition at line 459 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.