wenzi_1980
驱动牛犊
驱动牛犊
  • 注册日期2003-10-14
  • 最后登录2007-01-11
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1163回复:2

关于利用驱动来实现硬盘数据的读取问题

楼主#
更多 发布于:2003-10-16 08:43
我想写一个wdm驱动
通过调用来获得硬盘主引导记录区的数据

在devicecontrol部分中
         case IOCTL_DISK_GET_MBR: (自己定义的IOCTL_)下

我如何获得指向PhysicalDrive0的DeviceObject对象
    可以通过HalExamineMBR( DeviceObject,
                           512,
                           (ULONG)0x55,
                           &lpBuffer);获得我所需要的数据

这种思路是否可能...
 
大家多多指点
wowocock
VIP专家组
VIP专家组
  • 注册日期2002-04-08
  • 最后登录2016-01-09
  • 粉丝16
  • 关注2
  • 积分601分
  • 威望1651点
  • 贡献值1点
  • 好评度1227点
  • 原创分1分
  • 专家分0分
沙发#
发布于: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

花开了,然后又会凋零,星星是璀璨的,可那光芒也会消失。在这样 一瞬间,人降生了,笑者,哭着,战斗,伤害,喜悦,悲伤憎恶,爱。一切都只是刹那间的邂逅,而最后都要归入死亡的永眠
wenzi_1980
驱动牛犊
驱动牛犊
  • 注册日期2003-10-14
  • 最后登录2007-01-11
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2003-10-16 10:23
谢谢 马上试验  :D
游客

返回顶部