十万火急,请高手相助

blueeyes 2000-07-25 09:01:00
如何用汇编在win9x系统上实现对510h口的读写
...全文
194 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
「已注销」 2000-08-05
  • 打赏
  • 举报
回复
.386P
LOCALS
JUMPS
.MODEL FLAT, STDCALL

.data

GDTR df 0 ; This will receive the contents of the IDTR
; register

CallPtr dd 00h ; As we're using the first descriptor (8) and
dw 0Fh ; its located in the LDT and the privilege level
; is 3, our selector will be 000Fh.
; That is because the low-order two bits of the
; selector are the privilege level, and the 3rd
; bit is set if the selector is in the LDT.

OurGate dw 0 ; Offset low-order word
dw 028h ; Segment selector
dw 0EC00h ;
dw 0 ; Offset high-order word
; Call _Sprintf to change stack
keepesp0 dd 0
keepesp dd 0
keepeip dd 0
MyStack db 512 dup(0)

.code
Ring0Code:
.............这里就可以写Ring0的程序,可以读写任何port。

retf
ReadPort:
push ebp
mov ebp,esp
push offset Ring0Code
call RunRing0
pop ebp
ret 12
RunRing0:
push ebp
mov ebp,esp
pushad

mov eax,dword ptr [ebp+8]
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

push esi
push edi

call fword ptr [CallPtr] ; Execute the Ring0 Procedure

pop edi
pop esi

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

popad
pop ebp
ret 4

end
茂奇软件 2000-07-26
  • 打赏
  • 举报
回复
you should come into the ring0.
it is better for you to access
the io port.
if you use 16bit dll and so on.
you can access the io port directly
by OUT 0234H, IN 0234H.

jansen zhu.
blueeyes 2000-07-25
  • 打赏
  • 举报
回复
wwwunix 你能抄录这篇文章给我吗
wwwunix 2000-07-25
  • 打赏
  • 举报
回复
建议你看看《电脑编程与维护》2000.7期,上面有一篇关于在WIN9X下对端口编程的文章。

21,459

社区成员

发帖
与我相关
我的任务
社区描述
汇编语言(Assembly Language)是任何一种用于电子计算机、微处理器、微控制器或其他可编程器件的低级语言,亦称为符号语言。
社区管理员
  • 汇编语言
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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