阅读:1738回复:3
如何在驱动程序中读MBR?
如何在驱动程序中读MBR? 我找到一个IoReadPartitionTableEx,但不知道怎么用? 为什么编译不了?
|
|
最新喜欢:![]() |
沙发#
发布于:2004-03-24 20:57
如何在驱动程序中读MBR? 我找到一个IoReadPartitionTableEx,但不知道怎么用? 为什么编译不了? IoReadPartitionTableEx 只能读取分区表信息,不能读MBR。读MBR可以直接读物理扇区0。 首先取得你要读的硬盘的DeivceObject指针。 再用IoBuildSynchronousFsdRequest构造一个IRP_MJ_READ IRP包。 调用 IoCallDriver。 |
|
|
板凳#
发布于:2004-03-24 23:43
IO读取,自己能做的就不要靠HAL....
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 |
|
|
地板#
发布于:2004-03-25 09:30
[quote]如何在驱动程序中读MBR? 我找到一个IoReadPartitionTableEx,但不知道怎么用? 为什么编译不了? IoReadPartitionTableEx 只能读取分区表信息,不能读MBR。读MBR可以直接读物理扇区0。 首先取得你要读的硬盘的DeivceObject指针。 再用IoBuildSynchronousFsdRequest构造一个IRP_MJ_READ IRP包。 调用 IoCallDriver。 [/quote] 偶认为这种方法比较好。 |
|
|