acme
Foundational cross-platform layer of the ca2 framework
Toggle main menu visibility
Loading...
Searching...
No Matches
root_tools.h
1
#pragma once
2
3
#ifdef IMPLEMENT_VISTA_TOOLS
4
5
namespace
VistaTools
6
{
7
8
::i32_bool CLASS_DECL_ACME IsVista();
9
10
/*
11
Use IsVista() to determine whether the current process is running under Windows Vista or
12
(or a later version of Windows, whatever it will be)
13
14
Return Values:
15
If the function succeeds, and the current version of Windows is Vista or later,
16
the return value is true.
17
If the function fails, or if the current version of Windows is older than Vista
18
(that is, if it is Windows XP, Windows 2000, Windows Server 2003, Windows 98, etc.)
19
the return value is false.
20
*/
21
22
#ifndef WIN64
23
24
::i32_bool CLASS_DECL_ACME
25
IsWow64();
26
27
/*
28
Use IsWow64() to determine whether the current 32-bit process is running under 64-bit Windows
29
(Vista or XP)
30
31
Return Values:
32
If the function succeeds, and the current version of Windows is x64,
33
the return value is true.
34
If the function fails, or if the current version of Windows is 32-bit,
35
the return value is false.
36
37
While this function is not Vista specific (it works under XP as well),
38
we include it here to be able to prevent execution of the 32-bit code under 64-bit Windows,
39
when required.
40
*/
41
42
#endif
//WIN64
43
44
45
HRESULT CLASS_DECL_ACME
46
GetElevationType( __out TOKEN_ELEVATION_TYPE * ptet );
47
48
/*
49
Use GetElevationType() to determine the elevation type of the current process.
50
51
Parameters:
52
53
ptet
54
[out] Pointer to a ::payload that receives the elevation type of the current process.
55
56
The possible values are:
57
58
TokenElevationTypeDefault - User is not using a "split" token.
59
This value indicates that either UAC is disabled, or the process is started
60
by a standard ::account::user (not a member of the Administrators group).
61
62
The following two values can be returned only if both the UAC is enabled and
63
the ::account::user is a member of the Administrator's group (that is, the ::account::user has a "split" token):
64
65
TokenElevationTypeFull - the process is running elevated.
66
67
TokenElevationTypeLimited - the process is not running elevated.
68
69
Return Values:
70
If the function succeeds, the return value is S_OK.
71
If the function fails, the return value is E_FAIL. To get extended error information,
72
call get_last_error().
73
*/
74
75
HRESULT CLASS_DECL_ACME
76
IsElevated( __out_opt ::i32_bool * pbElevated =
nullptr
);
77
78
/*
79
Use IsElevated() to determine whether the current process is elevated or not.
80
81
Parameters:
82
83
pbElevated
84
[out] [optional] Pointer to a ::i32_bool ::payload that, if non-nullptr, receives the result.
85
86
The possible values are:
87
88
true - the current process is elevated.
89
This value indicates that either UAC is enabled, and the process was elevated by
90
the administrator, or that UAC is disabled and the process was started by a ::account::user
91
who is a member of the Administrators group.
92
93
false - the current process is not elevated (limited).
94
This value indicates that either UAC is enabled, and the process was started normally,
95
without the elevation, or that UAC is disabled and the process was started by a standard ::account::user.
96
97
Return Values
98
If the function succeeds, and the current process is elevated, the return value is S_OK.
99
If the function succeeds, and the current process is not elevated, the return value is S_FALSE.
100
If the function fails, the return value is E_FAIL. To get extended error information,
101
call get_last_error().
102
*/
103
104
::i32_bool CLASS_DECL_ACME
105
RunElevated(
106
__in oswindow hwnd,
107
__in const_char_pointer pszPath,
108
__in_opt const_char_pointer pszParameters =
nullptr
,
109
__in_opt const_char_pointer pszDirectory =
nullptr
,
110
__out_opt HANDLE *phProcess =
nullptr
);
111
112
/*
113
Use RunElevated() to start an elevated process. This function calls ShellExecEx() with the verb "runas"
114
to start the elevated process.
115
116
Parameters:
117
118
hwnd
119
[in] Window handle to any message boxes that the system might produce while executing this function.
120
121
pszPath
122
[in] Address of a null-terminated string that specifies the name of the executable file that
123
should be used to start the process.
124
125
pszParameters
126
[in] [optional] Address of a null-terminated string that contains the command-line parameters for the process.
127
If nullptr, no parameters are passed to the process.
128
129
pszDirectory
130
[in] [optional] Address of a null-terminated string that specifies the name of the working directory.
131
If nullptr, the current directory is used as the working directory. .
132
133
phProcess
134
[out] [optional] Address where to return the handle to the newly started process.
135
You must call CloseHandle( *phProcess ) when the handle is no longer needed.
136
If phProcess is nullptr, no handle is returned.
137
138
Return Values
139
If the function succeeds, the return value is true.
140
If the function fails, the return value is false. To get extended error information,
141
call get_last_error().
142
143
NOTE: This function will start a process elevated no matter which attribute (asInvoker,
144
highestAvailable, or requireAdministrator) is specified in its manifest, and even if
145
there is no such attribute at all.
146
*/
147
148
#ifndef DONTWANT_RunNonElevated
149
150
#ifdef NO_DLL_IMPORTS
151
# error RunNonElevated must be used in a DLL project!
152
#endif
//NO_DLL_IMPORTS
153
154
155
::i32_bool CLASS_DECL_ACME
156
RunNonElevated(
157
__in oswindow hwnd,
158
__in const ::file::path & path,
159
__in_opt const ::scoped_string & scopedstrParameters =
nullptr
,
160
__in_opt const ::scoped_string & scopedstrDirectory =
nullptr
,
161
__out_opt HANDLE *phProcess =
nullptr
);
162
163
/*
164
Use RunNonElevated() to start a non-elevated process. If the current process is not elevated,
165
it calls ShellExecuteEx() to start the ___new process. If the current process is elevated,
166
it injects itself into the (non-elevated) shell process, and starts a non-elevated process from there.
167
168
Parameters:
169
170
hwnd
171
[in] Window handle to any message boxes that the system might produce while executing this function.
172
173
pszPath
174
[in] Address of a null-terminated string that specifies the executable file that
175
should be used to start the process.
176
177
pszParameters
178
[in] [optional] Address of a null-terminated string that contains the command-line parameters for
179
the process. If nullptr, no parameters are passed to the process.
180
181
pszDirectory
182
[in] [optional] Address of a null-terminated string that specifies the name of the working directory.
183
If nullptr, the current directory is used as the working directory. .
184
185
phProcess
186
[out] [optional] Address where to return the handle to the newly started process.
187
You must call CloseHandle( *phProcess ) when the handle is no longer needed.
188
If phProcess is nullptr, no handle is returned.
189
190
Return Values
191
If the function succeeds, the return value is true.
192
If the function fails, the return value is false. To get extended error information,
193
call get_last_error().
194
195
NOTE: For this function to work, the application must be marked with the asInvoker or
196
highestAvailable attributes in its manifest. If the executable to be started is marked
197
as requireAdministrator, it will be started elevated!
198
*/
199
#endif
//DONTWANT_RunNonElevated
200
202
// MyShellExec is just a wrapper around a call to ShellExecuteEx,
203
// to be able to specify the verb easily.
204
205
::i32_bool CLASS_DECL_ACME
206
MyShellExec( oswindow hwnd,
207
const ::scoped_string & scopedstrVerb,
208
const ::file::path & path,
209
const ::scoped_string & scopedstrParameters =
nullptr
,
210
const ::scoped_string & scopedstrDirectory =
nullptr
,
211
HANDLE * phProcess =
nullptr
);
212
213
}
// namespace VistaTools
214
215
216
#endif
operating_system
openbsd
root_tools.h
Generated by
1.17.0