我发现了一篇发表在1999.11.29   b13版的   
  《令win32应用程序跳入系统层》东南大学   卢威   luwei@126.com   
  是用vc++嵌汇编做的,   
  很接近了,可试试   
    
  BCB或DELPHI进入Ring0   
  东南大学卢威1999.12发表在<<计算机世界>>报上的一篇   
  <<WIN32跳入系统0层>>,原采用VC++编程,现改成C++Builder   
  供诸位参考,DELPHI类似;     
    
    
  void   Ring0Proc()     //   在Ring0中执行你自已的代码   
  {   
          //   .......   
          asm   mov   eax,CR0;     //   试验一下Ring3不能执行的特权指令   
          //   .......   
  }   
  //   =====================================================   
  void     __declspec(naked)   NewInt()   //新中断   
  {   
              Ring0Proc();   
              asm     iretd;   
  }   
  #define     IntNo     9   
  DWORDLONG     IDTR,SavedGate;   
  WORD   OurGate[4]={0,0x0028,0xee00,0x0000};   
  void     GotoRing0()   
  {   
              asm   
                  {   
                          mov     eax,offset   NewInt;   
                          mov     [OurGate],ax;   
                          shr     eax,16;   
                          mov     [OurGate+6],ax;   
                          sidt   fword   ptr   IDTR;   
                          mov     ebx,dword   ptr   [IDTR+2];   
                          add     ebx,IntNo*8;   
                          mov     edi,offset   SavedGate;   
                          mov     esi,ebx;   
                          movsd;   
                          movsd;   
                          mov     edi,ebx;   
                          mov     esi,offset   OurGate;   
                          movsd;   
                          movsd;   
                          int     IntNo;   
                          mov     edi,ebx;     //   开始恢复原中断门   
                          mov     esi,offset   SavedGate;   
                          movsd;   
                          movsd;   
                  }   
  }   
  //   ===================================================   
    
  void   __fastcall   TForm1::Button1Click(TObject   *Sender)   
  {   
          GotoRing0();   
  }   
  ***********************************************   
    
  编译是通过了,你自己调试一下吧。   
  lea         esi,   MyInt;   一句语法应该有逻辑错误,要在Debug中仔细看一下。   
    
  procedure   MyInt;   
  asm   
      //   这里面的内容可要你自己写哦。   
  end;   
    
  const   HookExceptionNumber   =   3;   
    
  procedure   GetRing0;   
  asm   
  //   连续压入8个字节作为缓冲区   
  push         eax   
  push         eax;   
    
  //   取得idt偏移,共6字节,含段选择子2字节,偏移4字节。   
  sidt         [esp-02h];   //   Get   IDT   Base   Address   
    
  //   弹出4字节偏移   
  pop         ebx;   
    
  //   每个中断门8字节,所以偏移是HookExceptionNumber*08h   
  //   另外的4字节是定位到中心,因为中断门的4字节偏移分开放在8字节的0、1、6、7中。   
  //   0、1存放偏移低16位,6、7存放高16位。2,3是段选择子。4、5是门属性。   
  add         ebx,   HookExceptionNumber*08h   +   04h;   
    
  //   关中断,准备修改idt。   
  cli   
    
  //   取得中断门的4、5、6、7字节,其中6、7字节在ebp高16位   
  mov         ebp,   [ebx];   //   Get   Exception   Base   
    
  //   取得中断门的0、1字节到bp(实际上是ebp的低16位)。   
  mov         bp,   [ebx-04h];   //   Entry   Point   
  //   这样就合成了完整的32位偏移。   
    
  //   取得自己中断函数入口地址,放入esi中。   
  lea         esi,   MyInt;       
    
  //   压入堆栈   
  push         esi   
    
  //   填充入口低16位到中断门0、1字节。   
  mov         [ebx-04h],   si;   
    
  //   将高16位移动到低16位。   
  shr         esi,   16;   //   Modify   Exception   
    
  //   填充入口高16位到中断门6、7字节。   
  mov         [ebx+02h],   si;   //   Entry   Point   Address   
    
  //   idt修改完毕。   
    
  //   调整堆栈   
  pop         esi   
    
  //   此时堆栈比初始状态多压8字节。估计是在引发的中断中处理。   
  //   ebp的初始中断入口估计也是在自己的中断函数中用于恢复现场。   
    
  //   后面的就是引发软中断,取得ring0权力。   
  //   不过说句老实话。CIH的创意是不错,不过CIH的汇编的水平其实很一般。   
    
  int         HookExceptionNumber;   //   GenerateException   
    
  //   ReadyRestoreSE:   
  sti   
    
  end;   
  ----------------------------------   
  const   IntNo=9;   
    
  var   
  IDTR,SavedGate:int64;   
  OurGate:array[0..3]   of   word=(0,$0028,$ee00,$0000);   
    
  procedure   Ring0Proc;     //   在Ring0中执行你自已的代码   
  begin   
          //   .......   
          asm   
          mov   eax,CR0;     //   试验一下Ring3不能执行的特权指令   
          end;   
  end;   
  //   =====================================================   
  procedure       NewInt();   //新中断   
  begin   
              Ring0Proc();   
              asm   
              iretd;   
              end;   
  end;   
    
  procedure     GotoRing0;   
  begin   
              asm   
                          mov     eax,offset   NewInt;   
                          mov     word   ptr[OurGate],ax;   
                          shr     eax,16;   
                          mov     word   ptr[OurGate+6],ax;   
                          sidt   fword   ptr   IDTR;//在Delphi中应该改成:lea   ebx,   idtr;           sidt   [ebx]   
                          mov     ebx,dword   ptr   [IDTR+2];   
                          add     ebx,IntNo*8;   
                          mov     edi,offset   SavedGate;   
                          mov     esi,ebx;   
                          movsd;   
                          movsd;   
                          mov     edi,ebx;   
                          mov     esi,offset   OurGate;   
                          movsd;   
                          movsd;   
                          int     IntNo;   
                          mov     edi,ebx;     //   开始恢复原中断门   
                          mov     esi,offset   SavedGate;   
                          movsd;   
                          movsd;   
                  end;   
  end;   
  //   ===================================================   
    
  procedure   TForm1.Button1Click(Sender:   TObject);   
  begin   
    gotoring0;   
  end;   
  ********************************   
  const   IntNo=3;   
    
  //var   
  //IDTR,SavedGate:int64;   
    
  procedure   Ring0Proc;     //   在Ring0中执行你自已的代码   
  begin   
          //   .......   
  //         showmessage('kfsdj;fk');   
          asm   
          mov   eax,CR0;     //   试验一下Ring3不能执行的特权指令   
          end;   
  end;   
  //   =====================================================   
  procedure       NewInt();   //新中断   
  begin   
              Ring0Proc();   
              asm   
              iretd;   
              end;   
  end;   
    
  procedure     GotoRing0;   
  begin   
              asm   
                          mov     edi,offset   buf;   
                          sidt   [edi];         //Get   IDT-->buf;   
                          mov   ebx,[edi+2]       //求中断门基址   
                          add   ebx,IntNo*8;   
                          mov   esi,ebx;   
                          push   edi;   
                          push   esi;   
                          movsd;   
                          movsd;   
                          cli;   
                          mov   eax,offset   newint;   
                          mov   [ebx],ax;   
                          shr   eax,16;   
                          mov   [ebx+6],ax;   
                          mov   ax,0ee00h;   
                          mov   [ebx+4],ax;   
                          int   intno;   
                          pop   edi   
                          pop   esi;   
                          movsd;   
                          movsd;   
                          sti;   
                  end;   
  end;

http://blog.csdn.net/diligentcatrich/article/details/5493254

Delphi 能不能从Ring 3进入Ring 0的更多相关文章

  1. delphi vlc 安装bug 处理编译错误"0" is an invalid value for the "DebugInformation" parameter of the "DCC"

    处理编译错误"0" is an invalid value for the "DebugInformation" parameter of the "DCC" [摘要:http://blog.csdn ...

  2. 问题-[Delphi]用LoadLibrary加载DLL时返回0的错误

    问题现象:用LoadLibrary加载DLL一直返回0句柄,无法进行下一步操作,但同样的代码可以访问到别的DLL.问题处理:1.你加载的路径是不对的,一定要看好路径.2.你是在虚拟机中操作的DLL,因 ...

  3. Delphi中,FALSE 和 nil ,true 和 nil,0的区别

    True和False是布尔型(Boolean)的值,就是"是"或"否"的意思.nil就是空,一般用于指针或对象变量,指对针或对象对象一般初始化为nil或者释放后 ...

  4. uva 524 prime ring problem——yhx

      Prime Ring Problem  A ring is composed of n (even number) circles as shown in diagram. Put natural ...

  5. Lockless Ring Buffer Design

    https://www.kernel.org/doc/Documentation/trace/ring-buffer-design.txt Lockless Ring Buffer Design == ...

  6. OpenStack_Swift源代码分析——创建Ring及加入�设备源代码算法具体分析

    1 创建Ring 代码具体分析 在OpenStack_Swift--Ring组织架构中我们具体分析了Ring的具体工作过程,以下就Ring中添加�设备,删除设备,已经又一次平衡的实现过程作具体的介绍. ...

  7. OpenStack_Swift源代码分析——Ring基本原理及一致性Hash算法

    1.Ring的基本概念 Ring是swfit中最重要的组件.用于记录存储对象与物理位置之间的映射关系,当用户须要对Account.Container.Object操作时,就须要查询相应的Ring文件( ...

  8. UVa 524 Prime Ring Problem(DFS , 回溯)

    题意  把1到n这n个数以1为首位围成一圈  输出全部满足随意相邻两数之和均为素数的全部排列 直接枚举排列看是否符合肯定会超时的  n最大为16  利用回溯法 边生成边推断  就要快非常多了 #inc ...

  9. Segment,Path,Ring和Polyline对象

    Segment几何对象   Segment对象是一个有起点和终点的“线“,也就是说Segement只有两个点,至于两点之间的线是直的,还是曲的,需要其余的参数定义.所以Segment是由起点,终点和参 ...

随机推荐

  1. ViewPager,模仿慕课网

    源码:http://pan.baidu.com/s/1DhM14 使用fragment实现的:http://pan.baidu.com/s/1mgzWlM4 SecondActivity.java p ...

  2. ASP.net 学习路线(详细)

    .net学习路线 入门篇1.         学习面向对象(OOP)的编程思想 许多高级语言都是面向对象的编程,.NET也不例外.如果您第一次接触面向对象的编程,就必须理解类.对象.字段.属性.方法和 ...

  3. Javascript DOM 03 表格添加、删除 + 搜索

    获取 tBodies.tHead.tFoot.rows.cells   隔行变色 鼠标移入高亮   添加.删除一行 DOM方法的使用                                   ...

  4. 【转】Shell编程

    原文链接: Shell编程  打算有时间简单了解shell编程 1.shell结构 一个简单的例子: [root@localhost shell]# vi example #!/bin/sh #Thi ...

  5. nginx sendfile tcp_nopush tcp_nodelay参数解释

    sendfile 现在流行的web 服务器里面都提供 sendfile 选项用来提高服务器性能,那到底 sendfile是什么,怎么影响性能的呢?sendfile实际上是 Linux2.0+以后的推出 ...

  6. lua序列化table表到文件中

    先上代码 function luautil.serialize(t, sort_parent, sort_child) local mark={} local assign={} local func ...

  7. E. Riding in a Lift(Codeforces Round #274)

    E. Riding in a Lift time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  8. Java NIO与IO

    当学习了Java NIO和IO的API后,一个问题立即涌入脑海: 我应该何时使用IO,何时使用NIO呢?在本文中,我会尽量清晰地解析Java NIO和IO的差异.它们的使用场景,以及它们怎样影响您的代 ...

  9. 新买一款打印机hp5525N

    11900 RMB 彩色.激光.彩打. 让法国的工艺工程师给改成法语的了.

  10. UItableViewCell上的button点击无响应的办法

    由于IOS7中添加了滑动后出现编辑按钮的操作,所以使用scrollView来处理,UITableViewCellScrollView有对触摸的相应处理,导致按钮的点击效果被屏蔽了,但是点击事件还是在的 ...