mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-14 23:34:08 +00:00
UI: Load debug privileges for program
Debug privileges help prevent issues with things like game capture
This commit is contained in:
parent
e8002dc9ed
commit
e9f8374bf4
|
@ -575,12 +575,42 @@ static void main_crash_handler(const char *format, va_list args, void *param)
|
|||
UNUSED_PARAMETER(param);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
static void load_debug_privilege(void)
|
||||
{
|
||||
const DWORD flags = TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY;
|
||||
bool success = false;
|
||||
TOKEN_PRIVILEGES tp;
|
||||
HANDLE token;
|
||||
LUID val;
|
||||
|
||||
if (!OpenProcessToken(GetCurrentProcess(), flags, &token)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &val)) {
|
||||
tp.PrivilegeCount = 1;
|
||||
tp.Privileges[0].Luid = val;
|
||||
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
|
||||
success = !!AdjustTokenPrivileges(token, false, &tp,
|
||||
sizeof(tp), NULL, NULL);
|
||||
}
|
||||
|
||||
CloseHandle(token);
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#ifndef WIN32
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
load_debug_privilege();
|
||||
#endif
|
||||
|
||||
base_set_crash_handler(main_crash_handler, nullptr);
|
||||
base_get_log_handler(&def_log_handler, nullptr);
|
||||
|
||||
|
|
Loading…
Reference in a new issue