我尝试编写在 Delphi 中单击按钮后抛出 BSOD 的程序:
procedure RtlAdjustPrivilege(var Privilege: Integer; var bEnablePrivilege: Boolean; var IsThreadPrivilege: Boolean; var PreviousValue: PBoolean) stdcall; external 'ntdll.dll' name 'RtlAdjustPrivilege';
procedure NtRaiseHardError(var ErrorStatus: UInt64;var NumberOfParameters: UInt64; var UnicodeStringParameterMask: UInt64; var IntPtr: UInt64; var ValidResponseOption: UInt64; var Response: PLongInt) stdcall; external 'ntdll.dll' name 'NtRaiseHardError';
var bl, a, b: Boolean;
var I: Integer;
var Res: LongInt;
var Pb: PBoolean;
var c, d, e, f, g: UInt64;
var PRes: PLongInt;
procedure TForm4.Button1Click(Sender: TObject);
begin
I := 19;
a := True;
b := False;
Pb := @bl;
RtlAdjustPrivilege(I, a, b, pb);
c := 3221225595;
d := 0;
e := 0;
f := 0;
g := 6;
PRes := @Res;
NtRaiseHardError(c,d,e,f,g, PRes);
end;
但是点击按钮后没有任何反应,我想知道我在哪里犯了错误,这是代码,我在Delphi中重写了this answear
编辑:
现在代码看起来像这样,但仍然什么都没有
procedure RtlAdjustPrivilege(var Privilege: Integer; var bEnablePrivilege: Boolean; var IsThreadPrivilege: Boolean; var PreviousValue: PBoolean) stdcall; external 'ntdll.dll' name 'RtlAdjustPrivilege';
procedure NtRaiseHardError(var ErrorStatus: UInt64;var NumberOfParameters: UInt64; var UnicodeStringParameterMask: Pointer; var IntPtr: Pointer; var ValidResponseOption: UInt64; var Response: PLongInt) stdcall; external 'ntdll.dll' name 'NtRaiseHardError';
var bl, a, b: Boolean;
var I: Integer;
var Res: LongInt;
var Pb: PBoolean;
var c, d, g: UInt64;
var e, f: Pointer;
var PRes: PLongInt;
procedure TForm4.Button1Click(Sender: TObject);
begin
I := 19;
a := True;
b := False;
Pb := @bl;
RtlAdjustPrivilege(I, a, b, pb);
c := $C000007B;
d := 0;
e := nil;
f := nil;
g := 6;
PRes := @Res;
NtRaiseHardError(c,d,e,f,g, PRes);
end;
好吧应该是这样的
function RtlAdjustPrivilege(Privilege: Integer; bEnablePrivilege: Boolean; IsThreadPrivilege: Boolean; PreviousValue: PBoolean): Integer stdcall; external 'ntdll.dll' name 'RtlAdjustPrivilege';
function NtRaiseHardError(ErrorStatus: UInt64; NumberOfParameters: Integer; UnicodeStringParameterMask: Pointer; IntPtr: Pointer; ValidResponseOption: Integer; Response: PLongInt): Integer stdcall; external 'ntdll.dll' name 'NtRaiseHardError';
var bl: Boolean;
var Res: LongInt;
procedure TForm4.Button1Click(Sender: TObject);
begin
RtlAdjustPrivilege(19, True, False, @bl);
NtRaiseHardError($C000007B,0,nil,nil,6,@Res);
end;