Pyrogenesis  trunk
Classes | Macros | Enumerations | Functions
wutil.h File Reference
#include "lib/os_path.h"
#include "lib/sysdep/os/win/win.h"
Include dependency graph for wutil.h:
This graph shows which files directly or indirectly include this file:

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)
 
#define WUTIL_IMPORT_NTDLL(procName, varName)   WUTIL_IMPORT(GetModuleHandleW(L"ntdll.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 ()
 
const OsPathwutil_SystemPath ()
 
const OsPathwutil_ExecutablePath ()
 
const OsPathwutil_LocalAppdataPath ()
 
const OsPathwutil_RoamingAppdataPath ()
 
const OsPathwutil_PersonalPath ()
 
bool wutil_IsWow64 ()
 
Status wutil_SetPrivilege (const wchar_t *privilege, bool enable)
 
HMODULE wutil_LibModuleHandle ()
 
HWND wutil_AppWindow ()
 
void wutil_SetAppWindow (void *hwnd)
 
void wutil_EnableHiDPIOnWindows ()
 

Macro Definition Documentation

◆ WUTIL_FUNC

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

◆ WUTIL_IMPORT

#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: code_generation.h:41

◆ WUTIL_IMPORT_KERNEL32

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

◆ WUTIL_IMPORT_NTDLL

#define WUTIL_IMPORT_NTDLL (   procName,
  varName 
)    WUTIL_IMPORT(GetModuleHandleW(L"ntdll.dll"), procName, varName)

Enumeration Type Documentation

◆ WinLockId

enum WinLockId
Enumerator
WDBG_SYM_CS 
WDIR_WATCH_CS 
NUM_CS 

Function Documentation

◆ 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.

◆ 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_IsLocked()

bool wutil_IsLocked ( WinLockId  id)

◆ wutil_IsValidHandle()

template<typename H >
bool wutil_IsValidHandle ( h)

◆ 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()

void wutil_SetAppWindow ( void *  hwnd)

◆ wutil_SetPrivilege()

Status wutil_SetPrivilege ( const wchar_t *  privilege,
bool  enable 
)

◆ wutil_SystemPath()

const OsPath& wutil_SystemPath ( )

◆ wutil_Unlock()

void wutil_Unlock ( WinLockId  id)