Changeset 376
- Timestamp:
- 8/10/2008 8:57:32 AM (5 years ago)
- File:
-
- 1 edited
-
trunk/EraserDll/Eraser.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/EraserDll/Eraser.cpp
r286 r376 2373 2373 } 2374 2374 2375 // do the post-erase task2376 if (0 != context->m_dwFinishAction)2377 {2378 if (context->m_dwFinishAction != -1)2379 {2380 // Get this process' token2381 HANDLE processToken;2382 if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,2383 &processToken))2384 {2385 // Get the shut down privilege LUID2386 TOKEN_PRIVILEGES privilegeToken;2387 LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &privilegeToken.Privileges[0].Luid);2388 privilegeToken.PrivilegeCount = 1;2389 privilegeToken.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;2390 2391 // Get the privilege to shut down the computer2392 AdjustTokenPrivileges(processToken, FALSE, &privilegeToken, 0, NULL, 0);2393 ExitWindowsEx(context->m_dwFinishAction, SHTDN_REASON_MAJOR_OPERATINGSYSTEM | SHTDN_REASON_FLAG_PLANNED);2394 }2395 }2396 else2397 SetSystemPowerState(true, false);2398 }2399 2375 if (eraserInternalCompleted(context)) { 2400 2376 eraserEndThread(context, EXIT_SUCCESS); 2377 2378 // do the post-erase task 2379 if (0 != context->m_dwFinishAction) 2380 { 2381 if (context->m_dwFinishAction != -1) 2382 { 2383 // Get this process' token 2384 HANDLE processToken; 2385 if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, 2386 &processToken)) 2387 { 2388 // Get the shut down privilege LUID 2389 TOKEN_PRIVILEGES privilegeToken; 2390 LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &privilegeToken.Privileges[0].Luid); 2391 privilegeToken.PrivilegeCount = 1; 2392 privilegeToken.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; 2393 2394 // Get the privilege to shut down the computer 2395 AdjustTokenPrivileges(processToken, FALSE, &privilegeToken, 0, NULL, 0); 2396 ExitWindowsEx(context->m_dwFinishAction, SHTDN_REASON_MAJOR_OPERATINGSYSTEM | SHTDN_REASON_FLAG_PLANNED); 2397 } 2398 } 2399 else 2400 SetSystemPowerState(true, false); 2401 } 2401 2402 } else { 2402 2403 eraserEndThread(context, EXIT_FAILURE);
Note: See TracChangeset
for help on using the changeset viewer.
