用asm 来嵌入到delphi程序中,
ASM
  .....
END;

解决方案 »

  1.   

    meijg;
      我要完整的答案,实际上,我已经做到下面这个程度:
      CONST
      GDTR=0;        //df
      SavedGate=0;   //dq 0
      Ourgate:DWORD= ARRAY [0..3] OF  Dword=($0,$28,$ee00,$0);
      implementation{$R *.DFM}
    procedure Ring0Proc;
    asm
          mov      eax, CR0
          iretd
    end;procedure  startup;
    asm
          mov      eax, offset Ring0Proc
          mov      [OurGate],AX              // ; Put the offset words
          shr      eax, 16                    //; into our descriptor
          mov      [OurGate+6], ax      xor      eax, eax      sgdt      fword ptr GDTR
          mov      ebx, dword ptr [GDTR+2]    //; load GDT Base Address
          sldt      ax
          add      ebx, eax                  //; Address of the LDT descriptor in
                                             // ; ebx
          mov      al, [ebx+4]               // ; Load the base address
          mov      ah, [ebx+7]               // ; of the LDT itself into
          shl      eax, 16                   // ; eax, refer to your pmode
          mov      ax, [ebx+2]                // ; Address of int9 descriptor in ebx      mov      edi, offset SavedGate
          mov      esi, ebx
          movsd                              // ; Save the old descriptor
          movsd                               //; into SavedGate      mov      edi, ebx
          mov      esi, offset OurGate
          movsd                              // ; Replace the old handler
          movsd                              // ; with our new one      int      9h                        // ; Trigger the exception, thus
                                             // ; passing control to our Ring0
                                             // ; procedure      mov      edi, ebx
          mov      esi, offset SavedGate
          movsd                              //; Restore the old handler
          movsd      call     ExitProcess  LARGE -1end;
     
       编译后,有3出错误!
      mov [ourgate],ax
      .. 
      mov [ourgate+6],ax
      ..
      stid   fWORDd ptr GDTR 
      ..  
      call  winprocexit
      
      若上述4个错误能消灭掉,非常感谢!!!   
      

  2.   

    Ourgate:DWORD= ARRAY [0..3] OF  Dword=($0,$28,$ee00,$0);
    这是个变量吧,你怎么定义在常量里
      

  3.   

    mov ebx,offset ourgate
    mov [ebx],ax
      

  4.   

    就象jiangtao的answer:将变量地址放入ebx或esi,edi
      

  5.   

    1.汇编中dw表示data word,不是double word,所以声明ourgate应为word型.
    2.delphi中没有fword,你可以声明 6个byte大小的array,sidt yourarray即可
    3.call ExitProcess,LRAGE -1 是汇编编译器预处理的内容,是宏,你可以
    push -1
    call ExitProcess
    来结束程序