Monado OpenXR Runtime
u_windows.h File Reference

Various helpers for doing Windows specific things. More...

#include "xrt/xrt_compiler.h"
#include "xrt/xrt_windows.h"
#include "util/u_logging.h"
Include dependency graph for u_windows.h:

Go to the source code of this file.

Functions

const char * u_winerror (char *buffer, 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...
 

Detailed Description

Various helpers for doing Windows specific things.

Author
Jakob Bornecrantz jakob.nosp@m.@col.nosp@m.labor.nosp@m.a.co.nosp@m.m

Function Documentation

◆ u_win_grant_inc_base_priorty_base_privileges()

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.

Parameters
log_levelControl the amount of logging this function does.

◆ u_win_raise_cpu_priority()

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.

Parameters
log_levelControl the amount of logging this function does.

◆ u_win_try_privilege_or_priority_from_args()

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.

Parameters
log_levelControl the amount of logging this function does.
argcNumber of arguments, as passed into main.
argvArray of argument strings, as passed into main.

◆ u_winerror()

const char * u_winerror ( char *  buffer,
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.

Parameters
bufferBuffer to format the error into.
sizeSize of the given buffer.
errError number to format a string for.
remove_endRemoves and trailing \n, \r and . characters.