Check elevation status on Windows.

This commit is contained in:
Bartosz Taudul 2022-11-27 21:48:20 +01:00
parent e1395f5a53
commit 7e23d873dc
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
4 changed files with 46 additions and 0 deletions

View File

@ -212,6 +212,7 @@
<ClCompile Include="..\..\src\ImGuiContext.cpp" /> <ClCompile Include="..\..\src\ImGuiContext.cpp" />
<ClCompile Include="..\..\src\imgui\imgui_impl_glfw.cpp" /> <ClCompile Include="..\..\src\imgui\imgui_impl_glfw.cpp" />
<ClCompile Include="..\..\src\imgui\imgui_impl_opengl3.cpp" /> <ClCompile Include="..\..\src\imgui\imgui_impl_opengl3.cpp" />
<ClCompile Include="..\..\src\IsElevated.cpp" />
<ClCompile Include="..\..\src\main.cpp" /> <ClCompile Include="..\..\src\main.cpp" />
<ClCompile Include="..\..\src\ResolvService.cpp" /> <ClCompile Include="..\..\src\ResolvService.cpp" />
<ClCompile Include="..\..\src\RunQueue.cpp" /> <ClCompile Include="..\..\src\RunQueue.cpp" />
@ -347,6 +348,7 @@
<ClInclude Include="..\..\src\imgui\imgui_impl_glfw.h" /> <ClInclude Include="..\..\src\imgui\imgui_impl_glfw.h" />
<ClInclude Include="..\..\src\imgui\imgui_impl_opengl3.h" /> <ClInclude Include="..\..\src\imgui\imgui_impl_opengl3.h" />
<ClInclude Include="..\..\src\imgui\imgui_impl_opengl3_loader.h" /> <ClInclude Include="..\..\src\imgui\imgui_impl_opengl3_loader.h" />
<ClInclude Include="..\..\src\IsElevated.hpp" />
<ClInclude Include="..\..\src\ResolvService.hpp" /> <ClInclude Include="..\..\src\ResolvService.hpp" />
<ClInclude Include="..\..\src\RunQueue.hpp" /> <ClInclude Include="..\..\src\RunQueue.hpp" />
<ClInclude Include="..\..\src\stb_image.h" /> <ClInclude Include="..\..\src\stb_image.h" />

View File

@ -378,6 +378,9 @@
<ClCompile Include="..\..\..\server\TracyFileselector.cpp"> <ClCompile Include="..\..\..\server\TracyFileselector.cpp">
<Filter>server</Filter> <Filter>server</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\IsElevated.cpp">
<Filter>src</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\..\server\TracyEvent.hpp"> <ClInclude Include="..\..\..\server\TracyEvent.hpp">
@ -764,6 +767,9 @@
<ClInclude Include="..\..\..\server\TracyFileselector.hpp"> <ClInclude Include="..\..\..\server\TracyFileselector.hpp">
<Filter>server</Filter> <Filter>server</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\IsElevated.hpp">
<Filter>src</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Natvis Include="DebugVis.natvis" /> <Natvis Include="DebugVis.natvis" />

View File

@ -0,0 +1,32 @@
#include "IsElevated.hpp"
#ifdef _WIN32
#include <windows.h>
bool IsElevated()
{
HANDLE token;
if( OpenProcessToken( GetCurrentProcess(), TOKEN_QUERY, &token ) == 0 ) return false;
TOKEN_ELEVATION te;
DWORD sz;
if( GetTokenInformation( token, TokenElevation, &te, sizeof( te ), &sz ) == 0 )
{
CloseHandle( token );
return false;
}
bool ret = te.TokenIsElevated;
CloseHandle( token );
return ret;
}
#else
bool IsElevated()
{
return false;
}
#endif

View File

@ -0,0 +1,6 @@
#ifndef __ISELEVATED_HPP__
#define __ISELEVATED_HPP__
bool IsElevated();
#endif