TO》温柔一刀
程序是编译过了,可是一运行就死机,帮我看看如何
unit Getsn;
interface
uses
Windows, SysUtils, Classes;
type
TGetsn = class(TComponent)
private
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
end;
var
pw:array[1..256] of word;
idt,int_idt:dword;
Base:dword;
Entry:word;
function inp(rdx:WORD):byte;
function inpw(rdx:WORD):word;
procedure outp(rdx:WORD;ral:integer);
function WaitIde:integer;
procedure ReadIDE;
procedure NowInRing0;
procedure GetIDEInfo;
function harddisksn:string;
implementation
function inp(rdx:WORD):byte;Assembler;
asm
xor eax, eax
mov dx, rdx
in al, dx
mov result,al
end;
function inpw(rdx:WORD):word;Assembler;
asm
xor eax, eax
mov dx, rdx
in ax, dx
mov result,ax;
end;
procedure outp(rdx:WORD;ral:integer);Assembler;
asm
mov dx, rdx
mov eax, ral
out dx, al
end;
function WaitIde:integer;
var
al:word;
begin
al:=inp($1F7);
while (al<$80)do
al:=inp($1F7);
result:=al;
end;
procedure ReadIDE;
var
al,i:byte;
begin
WaitIde;
outp($1F6,$A0);
al:= WaitIde;
if ((al and $50)<>$50) then exit;
outp($1F6,$A0);
outp($1F7,$EC);
al:=WaitIde;
if ((al and $58)<>$58) then exit;
for i:=0 to 255 do
pw
:=inpw($1F0);
end;
procedure NowInRing0;Assembler;
asm
push ebp
mov ebp,esp
call ReadIDE;
cli
mov ebx, int_idt
mov ax, Entry
mov word ptr[ebx-4], ax
mov eax, Base
shr eax, 16
mov [ebx+2], ax
sti
leave
iretd
end;
procedure GetIDEInfo;Assembler;
var
dwExceptWORD;
begin
dwexcept:=dword(addr(nowinring0));
asm
mov eax, fs:[0]
push eax
sidt [esp-02h]
pop ebx
mov idt, ebx
add ebx, $1C
mov int_idt, ebx
mov eax, [ebx]
mov [Base], eax
mov ax, [ebx-4]
mov [Entry], ax
cli
mov esi, dwExcept
push esi
mov [ebx-4], si
shr esi, 16
mov [ebx+2], si
pop esi
sti //到这里死机
int 3
end;
end;
function harddisksn:string;
var
s:array[1..80] of char;
i,j:integer;
begin
GetIDEInfo;
j:=0;
for i:=0 to 9 do
while (j<=19) do
begin
s[j]:=chr(pw[10+i]shr 8);
j:=j+1;
s[j]:=chr(pw[10+i]and $FF);
j:=j+1;
end;
s[j]:=chr(0);
result:=s;
end;
end.