We don't display ads so we rely on your Bitcoin donations to 1KWEk9QaiJb2NwP5YFmR24LyUBa4JyuKqZ
Post date: Sep 29, 2010 1:21:37 PM
This code was created to instantly restart windows without performing it's shutdown sequence. As in windows 9x when you press ctrl+alt+delete twice.
Author: opc0de
Compiled: Delphi 2007
Tested: Windows 7
program reboot;//by opc0de {$APPTYPE CONSOLE}uses SysUtils, Windows;function RtlSetProcessIsCritical(unu:DWORD;proc:POinter;doi:DWORD):LongInt;stdcall; external 'ntdll.dll'; const SE_DEBUG_NAME = 'SeDebugPrivilege'; function NTSetPrivilege(sPrivilege: string; bEnabled: Boolean): Boolean;var hToken: THandle; TokenPriv: TOKEN_PRIVILEGES; PrevTokenPriv: TOKEN_PRIVILEGES; ReturnLength: Cardinal;begin Result := False; if OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then begin try if LookupPrivilegeValue(nil, PChar(sPrivilege), TokenPriv.Privileges[0].Luid) then begin TokenPriv.PrivilegeCount := 1; case bEnabled of True: TokenPriv.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED; False: TokenPriv.Privileges[0].Attributes := 0; end; ReturnLength := 0; PrevTokenPriv := TokenPriv; AdjustTokenPrivileges(hToken, False, TokenPriv, SizeOf(PrevTokenPriv), PrevTokenPriv, ReturnLength); end; finally CloseHandle(hToken); end; end; end;beginNTSetPrivilege(SE_DEBUG_NAME,TRUE);RtlSetProcessIsCritical(1,nil,0);end.