Monado OpenXR Runtime
|
Various helpers for doing Windows specific things. More...
#include "xrt/xrt_windows.h"
#include "util/u_windows.h"
#include "util/u_logging.h"
#include "assert.h"
Macros | |
#define | LOG_D(...) U_LOG_IFL_D(log_level, __VA_ARGS__) |
#define | LOG_I(...) U_LOG_IFL_I(log_level, __VA_ARGS__) |
#define | LOG_W(...) U_LOG_IFL_W(log_level, __VA_ARGS__) |
#define | LOG_E(...) U_LOG_IFL_E(log_level, __VA_ARGS__) |
#define | GET_LAST_ERROR_STR(BUF) (u_winerror(BUF, ARRAY_SIZE(BUF), GetLastError(), true)) |
Functions | |
static bool | check_privilege_on_process (HANDLE hProcess, LPCTSTR lpszPrivilege, LPBOOL pfResult) |
static bool | enable_privilege_on_process (HANDLE hProcess, LPCTSTR lpszPrivilege) |
bool | try_to_grant_privilege (enum u_logging_level log_level, HANDLE hProcess, LPCTSTR lpszPrivilege) |
static const char * | get_priority_string (DWORD dwPriorityClass) |
static bool | try_to_raise_priority (enum u_logging_level log_level, HANDLE hProcess) |
const char * | u_winerror (char *s, size_t size, DWORD err, bool remove_end) |
This function formats a Windows error number, as returned by GetLastError , and writes it into the given buffer. More... | |
bool | u_win_grant_inc_base_priorty_base_privileges (enum u_logging_level log_level) |
Tries to grant the 'SeIncreaseBasePriorityPrivilege' privilege to this process. More... | |
bool | u_win_raise_cpu_priority (enum u_logging_level log_level) |
Tries to raise the CPU priority of the process as high as possible. More... | |
void | u_win_try_privilege_or_priority_from_args (enum u_logging_level log_level, int argc, char *argv[]) |
Small helper function that checks process arguments for which to try. More... | |
Various helpers for doing Windows specific things.
bool u_win_grant_inc_base_priorty_base_privileges | ( | enum u_logging_level | log_level | ) |
Tries to grant the 'SeIncreaseBasePriorityPrivilege' privilege to this process.
It is needed for HIGH and REALTIME priority Vulkan queues on NVIDIA.
log_level | Control the amount of logging this function does. |
bool u_win_raise_cpu_priority | ( | enum u_logging_level | log_level | ) |
Tries to raise the CPU priority of the process as high as possible.
Returns false if it could not raise the priority at all. Normal processes can raise themselves from NORMAL to HIGH, while REALTIME requires either administrator privileges or the 'SeIncreaseBasePriorityPrivilege' privilege to be granted.
log_level | Control the amount of logging this function does. |
void u_win_try_privilege_or_priority_from_args | ( | enum u_logging_level | log_level, |
int | argc, | ||
char * | argv[] | ||
) |
Small helper function that checks process arguments for which to try.
The parsing is really simplistic and only looks at the first argument for the values nothing
, priority
, privilege
, both
. No argument at all implies the value both
making the function try to set both.
log_level | Control the amount of logging this function does. |
argc | Number of arguments, as passed into main. |
argv | Array of argument strings, as passed into main. |
This function formats a Windows error number, as returned by GetLastError
, and writes it into the given buffer.
buffer | Buffer to format the error into. |
size | Size of the given buffer. |
err | Error number to format a string for. |
remove_end | Removes and trailing \n , \r and . characters. |