MCPcopy Create free account
hub / github.com/NullArray/WinKernel-Resources / Reboot

Function Reboot

Drivers/Driver-SRC/setup/devcon/devcon.cpp:166–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166BOOL Reboot()
167/*++
168
169Routine Description:
170
171 Attempt to reboot computer
172
173Arguments:
174
175 none
176
177Return Value:
178
179 TRUE if API suceeded
180
181--*/
182{
183 HANDLE Token;
184 TOKEN_PRIVILEGES NewPrivileges;
185 LUID Luid;
186
187 //
188 // we need to "turn on" reboot privilege
189 // if any of this fails, try reboot anyway
190 //
191 if(!OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES,&Token)) {
192 goto final;
193 }
194
195 if(!LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME,&Luid)) {
196 CloseHandle(Token);
197 goto final;
198 }
199
200 NewPrivileges.PrivilegeCount = 1;
201 NewPrivileges.Privileges[0].Luid = Luid;
202 NewPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
203
204 AdjustTokenPrivileges(
205 Token,
206 FALSE,
207 &NewPrivileges,
208 0,
209 NULL,
210 NULL
211 );
212
213 CloseHandle(Token);
214
215final:
216
217 //
218 // attempt reboot - inform system that this is planned hardware install
219 //
220 // warning 28159 is a warning to rearchitect to avoid rebooting. However,
221 // sometimes during device installation, a reboot is needed, so this warning
222 // is being suppressed for the call to InitiateSystemShutdownEx.
223 //

Callers 2

_tmainFunction · 0.85
cmdRebootFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected