Page 1 of 1
A little help understanding .
Posted: Tue Mar 11, 2008 10:58 pm
by Gavin
I have a USB flash drive and I formatted it using the HP USB Disk Storage Format Tool and it created a Dos Startup Disk. (works great)
After reading about mbr's, boot sectors and boot loaders I have a few things I don't fully understand.
Using hex workshop I opened up the physical disk (not logical) and the first sector has the following first few byte,
33 C0 8E D0 BC 00
It also has the error messages i read about.
Error loading operating system.
Followed by the MBR signature.
55AA
Is this the Master Boot Record?
Anyway using hex workshop again i opened the same disk this time using the logical option and the first sector has the following first few bytes,
EB 3C 90 4D 53 44
I know from reading that these bytes are the jmp to offset.
Is this the boot sector ?
Thanks alot .
Posted: Tue Mar 11, 2008 11:10 pm
by 01000101
The first set of hex ending with the 0xAA55 is the bootsector, the first sector on the drive that allows it to be recognized by the bios as a bootable device. I don't know about the jump as I don't read machine hex that well lol, but Its a safe assumption that it is probably a jump to the fully loaded kernel/program.
Posted: Tue Mar 11, 2008 11:25 pm
by Gavin
Re: A little help understanding .
Posted: Tue Mar 11, 2008 11:56 pm
by Dex
Gavin wrote:I have a USB flash drive and I formatted it using the HP USB Disk Storage Format Tool and it created a Dos Startup Disk. (works great)
I do the same for my OS as the kernel is a mz exe which can run from dos, i stick my kernel32.exe on the usb along with its programs, then i can put the name of my kernel in the autoexe.bat to run it on boot up, works great, can even return to dos if i want to.
But to your ?, you need to know if you pc boots with floppy emulation or hdd emultion. if its fat12 it will be floppy, if its fat16 or fat it will be hdd.
If its fat16 you will find a MBR. At offset 450 you will find ether
0x04
0x06
0x0E
for fat16 or
0x0B
0x0C
for fat32
Also at offset 446 you should find 0x80
Now if it is the MBR you use the next bit of info to load the boot sector, eg:
Code: Select all
mov esi,MBRstart
add esi,446
mov al,byte[ds:esi]
cmp al,80h
jne LoadMbrError
mov dx,word[ds:esi] ; use these with int 13h to load the boot sector
mov cx,word[ds:esi+2] ; and this
;----------------------------------------------------;
; Store partition start cluster. ;
;----------------------------------------------------;
push eax
mov esi,MBRFat16n32
add esi,454
mov eax,dword[ds:esi]
mov [partition_start_cluster],eax ; we will need this later
pop eax
mov [countHdd],0
int13hloop1:
call FddRead
If it a fat12 floppy you will just find the bootsector and the BPB.
Posted: Wed Mar 12, 2008 8:13 am
by Gavin
01000101
Ya i just remembered the hex from programing
Dex
I had a look to see what you where saying and it does neither for my usb key.
But thanks to your post I understand it alot better.
Your operating system is pretty cool had a look on the site .
Posted: Wed Mar 12, 2008 9:03 am
by Brynet-Inc
Well, it looks like a typical DOS MBR, The partition table near the bottom(0x1b5 - 0x1cc) says there is a FAT-16(0x0e) partition with the following geometry.
Start/End:
Cylinder: 0/250
Head: 1/14
Sector: 1/46
Partition starts at LBA 63
Size: 252865 (129466880 bytes..)
That was fun.
Posted: Wed Mar 12, 2008 10:00 am
by Gavin
Brynet-Inc
Ok I understand that part now but
when i open the disk with hex workshop using the physical disk option the first few bytes are
on sector 0
33C08ED0BC007CFB5007
on sector 32
EB3C902B77637A30494843
on sector 63
EB3C904D53444F53352E30
when i open it with hex workshop using the logical disk option the first few bytes are
on sector 0
EB3C904D53444F53352E3000
on sector 32
nothing
on sector 63
nothing
Am i safe in assuming that when i open the disk using the physical option on hexworkshop that it's using the CHS (Cylinder Head Sector) terms.?
And when i open it using the logical option its in LBA (Logical Block Address) terms?
I'm very confussing i know .....
Thanks alot.
Posted: Wed Mar 12, 2008 10:26 am
by Brynet-Inc
When you open up the physical device, you're viewing the "entire" device.
The "Logical Device" on the other hand, starts within the first partition, at an offset of 32k(0x8000) bytes.
How did I calculate that? The partition starts at LBA 63, counting starts at 0, and the LBA size is 512 bytes.
So: 64 * 512 is 32768 bytes.
Hope that helps..
Posted: Wed Mar 12, 2008 11:52 am
by Gavin
Brynet-Inc
Now my head is not wrecked
Thanks alot you've been a great help .
Posted: Wed Mar 12, 2008 1:05 pm
by Dex
Posted: Wed Mar 12, 2008 2:20 pm
by Gavin
Thanks Dex thats a very good read it clears up alot of stuff.
By the way can i delete the mbr(not the boot sector) on my usb key?