阅读:1163回复:2
关于利用驱动来实现硬盘数据的读取问题
我想写一个wdm驱动
通过调用来获得硬盘主引导记录区的数据 在devicecontrol部分中 case IOCTL_DISK_GET_MBR: (自己定义的IOCTL_)下 我如何获得指向PhysicalDrive0的DeviceObject对象 可以通过HalExamineMBR( DeviceObject, 512, (ULONG)0x55, &lpBuffer);获得我所需要的数据 这种思路是否可能... 大家多多指点 |
|
沙发#
发布于:2003-10-16 09:38
在驱动中可以直接IO获得MBR
buffer db 512 dup(?) .CODE start: _Ring0Proc PROC ; Ring0 code here.. mov dx,1f6h ;Drive and head port mov al,0a0h ;Drive 0,Head 0 out dx,al mov dx,1f2h ;Sector count port mov al,1 ;Read One Sector out dx,al mov dx,1f3h ;Sector number port mov al,1 ;Read One Sector out dx,al mov dx,1f4h ;Cylinder low port xor al,al ;Cylinder 0 out dx,al mov dx,1f5h ;Cylinder high port xor al,al ;The rest of Cylinder 0 out dx,al mov dx,1f7h ;Command port mov al,20h ;Read with Entry out dx,al Still_going: in al,dx test al,8 ;This means the sector buffer requires servcing jz Still_going;do not continue until the sector buffer is ready xor ecx,ecx mov cx,512/2 ;one sector/2 mov edi,offset buffer mov dx,1f0h ;data port - data comes in and out here cli cld rep insw sti RET _Ring0Proc ENDP |
|
|
板凳#
发布于:2003-10-16 10:23
谢谢 马上试验 :D
|
|