problem with direct sector read

Hi all,

I want to do direct read from first sector of disk using int 13h interrupt.
I have written assembly code for the same.
Code snippest is here;;;;
char buff[512];
_asm{
mov ah,02h //READ SECTOR
mov al,01h //number of sectors to read
mov ecx,0x0001 //cylinder and sector no.
mov dh,0 //head no.
mov dl,0x80 //Drive no.
lea bx,buff //offset pointer to buffer.
int 13h
}
When i go with this code i get bug check 0x12(TRAP_CAUSE_UNKNOWN).
What is wrong with this?
I have doubt about offset pointer to buffer only.
Can anyone guide me?
Or some better option/link to read/write sector from disk?

Thanks in anticipation!!!

You cannot use BIOS calls on Windows (except for some highly specialized
situations and not for things like int13). You are guaranteed to crash,
you can do this by opening the disk directly, look at the CreateFile
documentation to see how to open the raw disk.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

wrote in message news:xxxxx@ntdev…
> Hi all,
>
> I want to do direct read from first sector of disk using int 13h
> interrupt.
> I have written assembly code for the same.
> Code snippest is here;;;;
> char buff[512];
> _asm{
> mov ah,02h //READ SECTOR
> mov al,01h //number of sectors to read
> mov ecx,0x0001 //cylinder and sector no.
> mov dh,0 //head no.
> mov dl,0x80 //Drive no.
> lea bx,buff //offset pointer to buffer.
> int 13h
> }
> When i go with this code i get bug check 0x12(TRAP_CAUSE_UNKNOWN).
> What is wrong with this?
> I have doubt about offset pointer to buffer only.
> Can anyone guide me?
> Or some better option/link to read/write sector from disk?
>
> Thanks in anticipation!!!
>
>
>
>

Thanks Don!

Do you mean to say there is no workaround for that?
I know the createfile option, but it’s not useful for me.
I have to do read sector operation without createfile option. Is there any workaround for the same?

Why do you think that createfile will not work? You can access the whole
disk, you can from other calls get the geometry Windows is using, so what do
you think is missing?


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

wrote in message news:xxxxx@ntdev…
> Thanks Don!
>
> Do you mean to say there is no workaround for that?
> I know the createfile option, but it’s not useful for me.
> I have to do read sector operation without createfile option. Is there any
> workaround for the same?
>

Int13h won’t work better just because you rename & restart your post.
You still have not answered our questions and as long as you do not tell us
from which environment
you work (Realmode, Windows boot executable, KernelMode, Usermode) it’s
pretty hard to help you out.

Else

|---------±-------------------------------->
| | xxxxx@yahoo.com |
| | Sent by: |
| | bounce-316287-16691@li|
| | sts.osr.com |
| | |
| | |
| | 03/03/2008 02:35 PM |
| | Please respond to |
| | “Windows System |
| | Software Devs Interest|
| | List” |
|---------±-------------------------------->
>-----------------------------------------------------------------------------------------------------------|
| |
| To: “Windows System Software Devs Interest List” |
| cc: |
| Subject: [ntdev] problem with direct sector read |
>-----------------------------------------------------------------------------------------------------------|

Hi all,

I want to do direct read from first sector of disk using int 13h interrupt.
I have written assembly code for the same.
Code snippest is here;;;;
char buff[512];
_asm{
mov ah,02h //READ SECTOR
mov al,01h //number of sectors to read
mov ecx,0x0001 //cylinder and sector no.
mov dh,0 //head no.
mov dl,0x80 //Drive no.
lea bx,buff //offset pointer to buffer.
int 13h
}
When i go with this code i get bug check 0x12(TRAP_CAUSE_UNKNOWN).
What is wrong with this?
I have doubt about offset pointer to buffer only.
Can anyone guide me?
Or some better option/link to read/write sector from disk?

Thanks in anticipation!!!


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

>>Why do you think that createfile will not work?
I am not thinking, i tried for that one.
My case is quite different in which i have no chance to use createfile at all !!!
are you sure that there is no workaround except createfile?
As DPMI is one solution but it’s in user mode, is there something similar in kernel mode?

Hi Else,

I already told(in last post) that i have volume filter driver which is in kernel mode.
It’s a kernel mode environment!!!

int 13h does not work in Windows in any possible way. It ceases to work
somewhere inside NTLDR.


Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

wrote in message news:xxxxx@ntdev…
> Hi all,
>
> I want to do direct read from first sector of disk using int 13h interrupt.
> I have written assembly code for the same.
> Code snippest is here;;;;
> char buff[512];
> _asm{
> mov ah,02h //READ SECTOR
> mov al,01h //number of sectors to read
> mov ecx,0x0001 //cylinder and sector no.
> mov dh,0 //head no.
> mov dl,0x80 //Drive no.
> lea bx,buff //offset pointer to buffer.
> int 13h
> }
> When i go with this code i get bug check 0x12(TRAP_CAUSE_UNKNOWN).
> What is wrong with this?
> I have doubt about offset pointer to buffer only.
> Can anyone guide me?
> Or some better option/link to read/write sector from disk?
>
> Thanks in anticipation!!!
>
>
>
>

> Do you mean to say there is no workaround for that?

No. int 13h just plain does not work, because the BIOS data structures needed
for it is long ago wiped - Windows does not care to save them, it uses int 13h
in boot loader only.

I have to do read sector operation without createfile option. Is there any
workaround for the same?

No.


Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

> As DPMI is one solution but it’s in user mode, is there something similar in
kernel

mode?

int 13h will not work with DPMI too.


Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

Just create the IRP and send it down the volume stack.


Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

wrote in message news:xxxxx@ntdev…
> Hi Else,
>
> I already told(in last post) that i have volume filter driver which is in
kernel mode.
> It’s a kernel mode environment!!!
>

At 02:24 PM 3/3/2008, xxxxx@yahoo.com wrote:

Hi Else,

I already told(in last post) that i have volume filter driver which
is in kernel mode.
It’s a kernel mode environment!!!

And you’ve been told numerous times that ZwCreateFile, ZwWriteFile
are your solution in kernel mode. You’ve also been told that the
code you posted was using the wrong device name to access the raw
disk. The device name you used in ZwCreateFile was for the volume
not the disk.

Several of the people who have answered you have experience of
accessing the raw disk in the manner you want to. Their solutions are correct.

Use the correct device name with ZwCreateFile and make sure that all
reads and writes are sector aligned and a multiple of sectors in
length and it will work.

Mark.

Ok, must have missed this. So you are you still trying to read the MBR via
your volume filter ?
Build the appropriate device name and get the appropriate DeviceObject
(IoGetDeviceObjectPointer).
Then build your read/write IRPs for the device.

Else

|---------±-------------------------------->
| | xxxxx@yahoo.com |
| | Sent by: |
| | bounce-316297-16691@li|
| | sts.osr.com |
| | |
| | |
| | 03/03/2008 03:24 PM |
| | Please respond to |
| | “Windows System |
| | Software Devs Interest|
| | List” |
|---------±-------------------------------->
>-------------------------------------------------------------------------------------------------------------|
| |
| To: “Windows System Software Devs Interest List” |
| cc: |
| Subject: RE:[ntdev] problem with direct sector read |
>-------------------------------------------------------------------------------------------------------------|

Hi Else,

I already told(in last post) that i have volume filter driver which is in
kernel mode.
It’s a kernel mode environment!!!


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

>>Build the appropriate device name and get the appropriate DeviceObject

>(IoGetDeviceObjectPointer).
>Then build your read/write IRPs for the device.

Do you mean to say device name as \Device\HarddiskVolume\ and get dev. object to this which won’t work by saying STATUS_OBJECT_PATH_NOT_FOUND. And if i make it to \Device\HarddiskVolume1 then i think i will not be able to get MBR/first sector.
Am i right?

That will not get you what you need, if you read the CreateFile
documentation you would know you need to access the \.\PhysicalDriveN where
N is the drive number.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

wrote in message news:xxxxx@ntdev…
>>>Build the appropriate device name and get the appropriate DeviceObject
>>>(IoGetDeviceObjectPointer).
>>>Then build your read/write IRPs for the device.
>
> Do you mean to say device name as \Device\HarddiskVolume\ and get dev.
> object to this which won’t work by saying STATUS_OBJECT_PATH_NOT_FOUND.
> And if i make it to \Device\HarddiskVolume1 then i think i will not be
> able to get MBR/first sector.
> Am i right?
>
>

> Do you mean to say device name as \Device\HarddiskVolume\ and get dev.

object to this which won’t work by saying
STATUS_OBJECT_PATH_NOT_FOUND. And if i make it to
\Device\HarddiskVolume1 then i think i will not be able to get MBR/first
sector.
Am i right?

\Device\Harddisk%d\Partition0 or ??\PhysicalDrive%d are the correct names.


Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com