1。使用VC可以通过,我试过
2。与操作系统环境无关!
3。此代码在VC中无误!
4。中断门的结构没有错误。
注意:Ring0Proc程序中不能设断点,不能跟踪Ring0级程序

解决方案 »

  1.   

    Hi, 
        I know the processing of CPU load the mechine code
    is different between the ring0 and ring3. so same mechine
    code array means the different code in the ring0 and ring3.
    So we need write a jmp far code in the ring0 mode. Would you
    please reference i386p asm book.
    I guess vc++ compiler have solve the problem. but c++builder
    still do not know it, you need do it by yourself.
    I can not assure whether my solution will help you.
    Would you please let me know the result, whatever
    it can solve it or not.Regards
    Jansen Zhu
    void __declspec( naked ) Ring0Proc(void) // 中 断 例 程, 运 行 在Ring0
    {
          _asm{
                mov  _eax,eax  //
                mov  _ecx,ecx  //
                mov  eax, CR0  // 测 试Ring3 中 不 能 执 行 的 特 权 指 令
                mov  _cr0,eax  //
                jmp  far next:  
    next:
                iretd            // 中断返回,与在实模式编程无 本 质 区 别
              }
    }
      

  2.   

    像            jmp  far next:  
    next:
    这样的的操作一般有两种用途:
    1清除cpu中的指令预取队列,这一般是用在一些加/解密软件或病毒中,由于程序动态修改代码,所以要清除cpu中的指令预取队列.
    2由实模式进入保护模式时,通过该操作来装入cs.
    在该程序中既不修改自身代码,也无需再装入(调用中断时,已经装入cs了),所以不用jmp far.
    "I know the processing of CPU load the mechine code
    is different between the ring0 and ring3. so same mechine
    code array means the different code in the ring0 and ring3."
    这里的不同应该是在实模式与保护模式之间,而不是保护模式下的ring0和ring3之间.
    win9x下的主控台程序仍是保护模式下的32位程序.
    出现蓝屏现象应该是另有原因.
      

  3.   

    可能是由于Cbuilder优化的问题,试一下将编译开关中的优化选项去掉后再试一下。
      

  4.   

    经典的CIH手段运用.:)
    http://lu0.126.com
      

  5.   

    我用C++Builder3 的命令行编译器BCC32编译通过,程序运行后结果:
    CR0=80000013 EAX=6200 EBX=0
      

  6.   


    void Ring0Proc()  // 在Ring0中执行你自已的子程序
    {
        asm mov eax,CR0;  // 测验Ring3不能执行的特权指令
    }
    // =====================================================
    void  __declspec(naked) NewInt() //新中断
    {
          Ring0Proc();
          asm  iretd;
    }
    #define IntNo  3void  GotoRing0()
    {
          static DWORDLONG Buf;      //静态或全局变量
          asm
            {
                mov    edi,offset Buf;
                sidt  [edi];      // 取IDT->Buf
                mov    ebx,[edi+2]; // 求中断门基址
                add    ebx,IntNo*8;
                mov    esi,ebx;
                push  edi;
                push  esi;
                movsd;        //保存原中断门->Buf
                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;
            }
    }
    // ===================================================