Page 1 of 1

USB Pendrive and MBR

Posted: Fri May 16, 2014 8:58 am
by digo_rp
Hi all, guys I´m trying to read fat32 partition at my usb pendrive " stick ", the first sector CHS 0,0,1 I can read the mbr, and partition table 16 bytes entries, until here everyting is ok!, but when I get the CHS 0,1,1 for the first partition " type C, fat32 LBA Win " I read that sector CHS 0,1,1 and boom!!!!!!!!, I get all those 512 bytes as 00, zeroes,,,,, 00, 00, 00, 00, 00 ... 512

my usb pen drive is detected as type 3 using bios services 15, 3 = hard disk drive.... the odd stuff is that inside qemu, virtualbox works fine! and at real hardware pc, doesn´t....

could anyone give me some idea! please!

forgive me about my poor english, please!

tnx in advance,

Digo_RP,

Re: USB Pendrive and MBR

Posted: Fri May 16, 2014 10:03 am
by Octocontrabass
Why aren't you using LBA?

What the heck is "bios services 15, 3"? Are you referring to an interrupt?

Are you sure the BIOS is using the same geometry as the emulators? The sector at CHS 0,1,1 will be different depending on how many sectors the BIOS has chosen to emulate.

Re: USB Pendrive and MBR

Posted: Fri May 16, 2014 10:19 am
by digo_rp
I wrote wrong, the bios service 15h is for detect disk. ah=15h, dl=drive and do int 13h it´s returned in al the disk type...
1 = it´s used for floppy
2 = it´s used for floppy
3 = hard disk

the type 1, 2 I don´t know the diference between those, as I don´t speak much english...

Re: USB Pendrive and MBR

Posted: Fri May 16, 2014 10:33 am
by Octocontrabass
You don't need to use the BIOS to tell what the drive is being emulated as. If DL=0x00, it's being emulated as a floppy disk, and if DL=0x80, it's being emulated as a hard disk.

If it's a hard disk, you need to use int 0x13 AH=0x08 to find the correct CHS values. But, why not use LBA instead of CHS?

Re: USB Pendrive and MBR

Posted: Sun May 18, 2014 9:43 am
by digo_rp
Now I found the big mistake... the problem was using the struct with function 42h of int 13h

buffer location... I had to use unsigned long* buffer_address;
now I can read fat entries using LBA... tnx a lot guys... for now I´m just trying to understand how dos dpmi works...

to use all bios int´s, do I need to create something like low_mem_malloc, to allocate memory below 1/mb+64kb?

I´m using some areas that I know is free... like segment 0x1000, segment 0, offset 0x500,

is that right?

all bios ints are working very well int 0x10, int 0x15, int 0x13, int 0x16,

tnx a lot guys and in case anyone wants any help, i´ll be so glad to try to help and share my code...

tnx a lot all

have a nice day...