Re: LSA Disk Sector Read - using int 13h ah 42 (extended read)



On 5 Oct 2006 11:56:05 -0700, "jay" <spamtrap@xxxxxxxxxx> wrote:

I'm just messing around here trying to learn how some of this low level
stuff works, and to my surprise I can not find a working example any
where...

Can someone please help. I'm about to pull my hair out!
I'm using visual studio 1.52 to compile my 16 bit code. I'm doing C
with inline ASM.
Note: I called check_extensions and extension are on my computer.

When i compile and run the following code bError prints out "0" so that
is no error i think? Yet when i print out my buffer the buffer is all
0's which i know is wrong because i have another functions that read
the MBR in with CHS format call and then it prints out the mbr just
fine. Any ideas?


struct disk_packet //needed for int13 42h
{
BYTE size_pack; //size of packet must be 16 or 16+
BYTE reserved1; //reserved
BYTE no_of_blocks; //no:of blocks for transfer
BYTE reserved2; //reserved

WORD offset; //offset address
WORD segment; //segment address

DWORD lba1;
DWORD lba2;
} disk_pack;

void LBASectorRead(void *buffer, unsigned long lba )
{
unsigned char bError = 0;
disk_pack.size_pack=16; //set size to 16
disk_pack.no_of_blocks=1; //1 block ie read one sector
disk_pack.reserved1=0; //reserved word
disk_pack.reserved2=0; //reserved word

disk_pack.segment=FP_SEG(buffer); //segment of buffer
disk_pack.offset=FP_OFF(buffer); //offset of buffer

disk_pack.lba1=0; //lba first 32 bits
disk_pack.lba2=0; //last 32 bit address

_asm
{
mov dl, 80h;
mov [disk_pack.segment], ds;

mov ds, [disk_pack.segment]; // I think
though wouldn't this use the same FP_??? as in the packet?


mov si, disk_pack;
mov ah, 42h;
int 13h
jc NoError ; //No error, ignore error code
mov bError, ah ; // Error, get the error code
NoError:
}

printf( "%d", bError);

}

int main(void)
{
static unsigned char currentMBR[SECTOR_SIZE] = {0};
printf("\n\n");
LBASectorRead(currentMBR );
PrintSector(currentMBR); //function to print buffer in hex
}

--
Doors - Dont look at the future in a window.
Walk to a door - Open it, and go there.

http://www.freedoors.org

doorsremove@xxxxxxxxxxxxxxx
mailto:doorsremove@xxxxxxxxxxxxxxx

.



Relevant Pages