DElphi4中的汇编问题,50分,答案2句话,快来拿分!!

sungw 2000-08-18 05:56:00
汇编:

.data

GDTR df 0


CallPtr dd 00h
dw 0Fh

OurGate dw 0 ; Offset low-order word
dw 028h ; Segment selector
dw 0EC00h ;
dw 0 ; Offset high-order word

.code

Start:
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] ; manual for details

add eax, 8 ; Skip NULL Descriptor

mov edi, eax
mov esi, offset OurGate
movsd ; Move our custom callgate
movsd ; into the LDT

call fword ptr [CallPtr] ; Execute the Ring0 Procedure

xor eax, eax ; Clean up the LDT
sub edi, 8
stosd
stosd

call ExitProcess, LARGE -1

Ring0Proc PROC
mov eax, CR0
retf
Ring0Proc ENDP

end Start




应该怎样转化成delphi4?

...全文
170 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
www2 2000-08-20
  • 打赏
  • 举报
回复
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
来结束程序

StarRainBow 2000-08-20
  • 打赏
  • 举报
回复
就象jiangtao的answer:将变量地址放入ebx或esi,edi
sungw 2000-08-19
  • 打赏
  • 举报
回复
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 -1

end;



编译后,有3出错误!
mov [ourgate],ax
..
mov [ourgate+6],ax
..
stid fWORDd ptr GDTR
..
call winprocexit

若上述4个错误能消灭掉,非常感谢!!!

jiangtao 2000-08-19
  • 打赏
  • 举报
回复
mov ebx,offset ourgate
mov [ebx],ax
meijg 2000-08-19
  • 打赏
  • 举报
回复
用asm 来嵌入到delphi程序中,
ASM
.....
END;
meijg 2000-08-19
  • 打赏
  • 举报
回复
Ourgate:DWORD= ARRAY [0..3] OF Dword=($0,$28,$ee00,$0);
这是个变量吧,你怎么定义在常量里
StarRainBow 2000-08-19
  • 打赏
  • 举报
回复
用InLine直接嵌入机器码。

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧