aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp34
-rw-r--r--src/main.rc4
-rw-r--r--src/resource_ids.h8
3 files changed, 28 insertions, 18 deletions
diff --git a/src/main.cpp b/src/main.cpp
index c2ffb21..ff409e3 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -14,7 +14,7 @@
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
-bool is_user_in_administrators()
+bool is_administrator()
{
const auto token = token::impersonate(
token::get_linked(
@@ -33,21 +33,32 @@ bool is_elevated()
return token::is_elevated(token::open_for_current_process());
}
-void set_label(HWND root, int id, bool val)
+DWORD get_integrity_level()
{
- const auto label = GetDlgItem(root, id);
+ return token::query_integrity_level(
+ token::open_for_current_process());
+}
+
+std::wstring get_integrity_level_as_string()
+{
+ return token::integrity_level_to_string(get_integrity_level());
+}
+
+void set_label(HWND wnd, int id, bool val)
+{
+ const auto label = GetDlgItem(wnd, id);
SetWindowTextW(label, val ? L"True" : L"False");
}
-void set_label(HWND root, int id, const wchar_t* s)
+void set_label(HWND wnd, int id, const wchar_t* s)
{
- const auto label = GetDlgItem(root, id);
+ const auto label = GetDlgItem(wnd, id);
SetWindowTextW(label, s);
}
-void set_label(HWND root, int id, const std::wstring& s)
+void set_label(HWND wnd, int id, const std::wstring& s)
{
- const auto label = GetDlgItem(root, id);
+ const auto label = GetDlgItem(wnd, id);
SetWindowTextW(label, s.c_str());
}
@@ -55,7 +66,7 @@ BOOL on_init_dialog(HWND wnd, HWND, LPARAM)
{
try
{
- set_label(wnd, IDC_ADMINISTRATOR, is_user_in_administrators());
+ set_label(wnd, IDC_ADMINISTRATOR, is_administrator());
}
catch (const Error& e)
{
@@ -91,8 +102,7 @@ BOOL on_init_dialog(HWND wnd, HWND, LPARAM)
try
{
- set_label(wnd, IDC_INTEGRITY_LEVEL, token::integrity_level_to_string(
- token::query_integrity_level(token::open_for_current_process())));
+ set_label(wnd, IDC_INTEGRITY_LEVEL, get_integrity_level_as_string());
}
catch (const Error& e)
{
@@ -112,8 +122,8 @@ BOOL on_init_dialog(HWND wnd, HWND, LPARAM)
void report_already_elevated(HWND wnd)
{
MessageBoxW(wnd,
- resource::load_string(IDS_ALREADY_ELEVATED).c_str(),
- resource::load_string(IDS_ELEVATION_CAPTION).c_str(),
+ resource::load_string(IDS_ALREADY_ELEVATED_TEXT).c_str(),
+ resource::load_string(IDS_ALREADY_ELEVATED_CAPTION).c_str(),
MB_OK);
}
diff --git a/src/main.rc b/src/main.rc
index 28cb4f2..4e304b2 100644
--- a/src/main.rc
+++ b/src/main.rc
@@ -103,8 +103,8 @@ END
STRINGTABLE
BEGIN
- IDS_ELEVATION_CAPTION "Privilege test"
- IDS_ALREADY_ELEVATED "Already elevated."
+ IDS_ALREADY_ELEVATED_CAPTION "Privilege test"
+ IDS_ALREADY_ELEVATED_TEXT "Already elevated."
END
#endif // English (United States) resources
diff --git a/src/resource_ids.h b/src/resource_ids.h
index 8c12cf8..4d45fdd 100644
--- a/src/resource_ids.h
+++ b/src/resource_ids.h
@@ -3,8 +3,8 @@
// Used by main.rc
//
#define IDD_MAINDIALOG 100
-#define IDS_ELEVATION_CAPTION 2000
-#define IDS_ALREADY_ELEVATED 2001
+#define IDS_ALREADY_ELEVATED_CAPTION 2000
+#define IDS_ALREADY_ELEVATED_TEXT 2001
#define IDC_BUTTON_ELEVATE 1000
#define IDC_ADMINISTRATOR 1001
#define IDC_RUN_AS_ADMINISTRATOR 1002
@@ -17,9 +17,9 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
-#define _APS_NEXT_RESOURCE_VALUE 130
+#define _APS_NEXT_RESOURCE_VALUE 2002
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1005
-#define _APS_NEXT_SYMED_VALUE 110
+#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif