有会的吗?
分不够可加

解决方案 »

  1.   

    procedure SetRing(value:word); stdcall; 
    const ZDH = $03; // 設一個中斷號
    var
    IDT : array [0..5] of byte; // 保存IDT表
    OG : dword; //存放舊向量
    begin
    asm
    push ebx
    sidt IDT //讀入中斷描述符表
    mov ebx, dword ptr [IDT+2] //IDT表基地址
    add ebx, 8*ZDH //計算中斷在中斷描述符表中的位置
    cli //關中斷
    mov dx, word ptr [ebx+6] 
    shl edx, 16d 
    mov dx, word ptr [ebx] 
    mov [OG], edx 
    mov eax, offset @@Ring0 //指向Ring0級代碼段
    mov word ptr [ebx], ax //低16位,保存在1,2位
    shr eax, 16d
    mov word ptr [ebx+6], ax //高16位,保存在6,7位
    int ZDH //中斷
    mov ebx, dword ptr [IDT+2] //重新定位
    add ebx, 8*ZDH
    mov edx, [OG]
    mov word ptr [ebx], dx
    shr edx, 16d
    mov word ptr [ebx+6], dx //恢復被改了的向量
    pop ebx
    jmp @@exitasm //到exitasm處
    @@Ring0: //Ring0,這個也是最最最核心的東東
    mov al,$34 //寫入8253控制寄存器
    out $43,al
    mov ax,value //寫入定時值
    out $40,al //寫定時值低位
    mov al,ah
    out $40,al //寫定時值高位
    iretd //返回
    @@exitasm:
    end;
    end;
    http://delphi.ktop.com.tw/topic.asp?TOPIC_ID=30640
      

  2.   

    取得Ring 0级权限 
    原文由Delfan发表于网易社区广州站 
    网上找到好多Ring3层运行Ring0级的资料,可惜都是Asm,C/C++的代码,有一个用Delphi编写VXD的例子,还只能在Delphi3上编译。经过多方参考,终于搞定。让各位大虾见笑了。此段代码只能在95/98中运行,其实原理和CIH的开头获取特权级部分一样。小弟很菜,不足之处请各位大虾指教。谢谢。 button1 : 直接执行Int 03h,在IDE环境中会产生单步调试的中断,独立运行会发生异常,是为了证明button2执行的代码正确性而设置的。 
    button2 : 实际获取Ring 0 级的代码,使用了内嵌汇编。 
    button3 : 停止button2中的发声 unit main; interface uses 
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 
    StdCtrls; type 
    TForm1 = class(TForm) 
    Button1: TButton; 
    Button2: TButton; 
    Button3: TButton; 
    procedure Button1Click(Sender: TObject); 
    procedure Button2Click(Sender: TObject); 
    procedure Button3Click(Sender: TObject); 
    private 
    { Private declarations } 
    public 
    { Public declarations } 
    end; var 
    Form1: TForm1; 
    var IDT : array [0..5] of byte; // 保存中断描述符表 
    lpOldGate : dword; // 存放旧向量 
    implementation {$R *.DFM} procedure aa; stdcall; 
    const ExceptionUsed = $03; // 中断号。 
    begin 
    asm 
    sidt IDT // 读入中断描述符表 
    mov ebx, dword ptr [IDT+2] 
    add ebx, 8*ExceptionUsed 
    cli 
    mov dx, word ptr [ebx+6] 
    shl edx, 16d 
    mov dx, word ptr [ebx] 
    mov [lpOldGate], edx 
    mov eax, offset @@Ring0Code // 修改向量,指向Ring0级代码段 
    mov word ptr [ebx], ax 
    shr eax, 16d 
    mov word ptr [ebx+6], ax 
    int ExceptionUsed // 发生中断 
    mov ebx, dword ptr [IDT+2] 
    add ebx, 8*ExceptionUsed 
    mov edx, [lpOldGate] 
    mov word ptr [ebx], dx 
    shr edx, 16d 
    mov word ptr [ebx+6], dx // 恢复被改了的向量 
    ret @@Ring0Code: // Ring0级代码段 
    mov eax,cr0 // 此句在Ring3级会发生异常错误 
    mov dx, $61 // 以下语句是为了证明执行了此段代码,让PCSpeak发声 
    mov al, $ff 
    out dx, al 
    mov dx, $43 
    mov al, $b6 
    out dx, al 
    mov dx, $42 
    mov al, $f0 
    out dx, al 
    mov dx, $42 
    mov al, $0 
    out dx, al 
    iretd // 中断返回 
    end; 
    end; procedure TForm1.Button1Click(Sender: TObject); 
    begin 
    aa; 
    end; procedure TForm1.Button2Click(Sender: TObject); 
    begin 
    asm 
    int 03h // 
    end; 
    end; procedure TForm1.Button3Click(Sender: TObject); 
    var bvalue : byte; 
    value : word; 
    begin // 停止PCSpeak发声 
    asm 
    mov dx, $61 
    in al, dx 
    mov bValue, al 
    end ; 
    value := bValue and $fc; 
    bValue := Trunc(Value and 255); 
    asm 
     mov dx, $61 
       mov al, bValue 
       out dx, al 
    end; 
    end; end. 
     
      
      

  3.   

    我要获得Ring0 权限
    为了在2000 下面对打印机并口操作
      

  4.   

    LYSoft提供D7的DCU文件和Demo,可以在Ring0访问端口LY的Blog都提供方法:http://blog.csdn.net/ly_liuyanghttp://lysoft.7u7.net