//以下函数用以获得硬盘出厂序列号。
//******一个全汇编过程*********//
procedure Ring0Proc();
asm
// Wait for controller not busy
mov dx,01f7h
@1:in al,dx
cmp al,050h
jne @1// Get first/second drive
dec dx
mov al,0a0h
out dx,al// Get drive info data
inc dx
mov al,0ech
out dx,al
nop
nop// Wait for data ready
@2:in al,dx
cmp al,058h
jne @2
nop
nop
// Read sector
xor ecx,ecx
mov dx,01f0h
@3:in ax,dx
mov word ptr dd[ecx*2],ax
inc ecx
cmp ecx,256
jne @3iretd 
end;procedure Change2Ring0();
begin
asm
mov eax, offset Ring0Proc
mov OurGate.off2, ax 
shr eax, 16 
mov OurGate.off1, ax 
mov OurGate.op,0028h
mov OurGate.seg,0ee00h
mov ebx,offset IDTR
sidt [ebx]
mov ebx, dword ptr [IDTR+2]
add ebx, 8*3
mov edi, offset SavedGate
mov esi, ebx
movsd 
movsd 
mov edi, ebx
mov esi, offset OurGate
cli
movsd 
movsd 
sti
mov eax,6200h
mov ecx,0
int 3h
mov edi, ebx
mov esi, offset SavedGate
cli
movsd
movsd
sti
end;
asm
xor ecx,ecx
mov ebx,offset dd[10*2]
@4:mov ax,[ebx]
mov byte ptr dsn[ecx],ah
inc ecx
mov byte ptr dsn[ecx],al
inc ebx
inc ebx
inc ecx
cmp ecx,10
jne @4
end;
showmessage(dsn);
end;