Int13h AH=42h Boot From Hard Drive just fails [Solved]

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: Int13h AH=42h Boot From Hard Drive just fails

Post by pcmattman »

Well, yeah, but right now with Qemu, I can just go: qemu -hdb d: -L <whatever>
and it boots my D: partiton. The problem is: how to do the same with Bochs?
IIRC, Bochs can access partitions in a similar way:

Code: Select all

ata0-slave: type=disk, path="\\.\D:", mode=flat, translation=auto
Note that I'm going purely from memory here, I may be wrong.
User avatar
CmpXchg
Member
Member
Posts: 61
Joined: Mon Apr 28, 2008 12:14 pm
Location: Petrozavodsk, Russia during school months, Vänersborg Sweden in the summertime

Re: Int13h AH=42h Boot From Hard Drive just fails

Post by CmpXchg »

Bad news: INT13 preserves BP and the structure doesn't need to be aligned.
I've figured this out under FreeDOS with the aid of AFDPro debugger...

@pcmattman: Thanx, I'm gonna try it out. Bochs for Windows is still alpha, though.

@Love4Boobies: Nah, the origin is alright. If the origin were 7C00h, the code would erase the BPB and Extended BPB structures in the bootsector.
Every Man Must Learn David DeAngelo's Stuff, Period.
http://www.doubleyourdating.com/Catalog
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Int13h AH=42h Boot From Hard Drive just fails

Post by Love4Boobies »

CmpXchg wrote:@Love4Boobies: Nah, the origin is alright. If the origin were 7C00h, the code would erase the BPB and Extended BPB structures in the bootsector.
Think about if for a bit. The MBR will load the boot sector into memory and pass control to it. You need to have an instruction that jumps over the BPB and whatever other data structures NTFS uses. In case you did that (to the right offset) outside of the assembly file (which is sort of weird) then nevermind.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
CmpXchg
Member
Member
Posts: 61
Joined: Mon Apr 28, 2008 12:14 pm
Location: Petrozavodsk, Russia during school months, Vänersborg Sweden in the summertime

Re: Int13h AH=42h Boot From Hard Drive just fails

Post by CmpXchg »

Guys? I got it working!

The issue was that I pushed Hidden Sectors value without incrementing it first, so that would load the bootsector all over again... And I've triple-checked all the values there, so it's working allright now. On my real machine.

The curious thing is that it still didn't work under QEMU when I go:

Code: Select all

qemu -L <whatever> -hdb d:
So I made an image file of the starting sectors of the harddisk (the NTFS partition is the first, so that image spans MBR and the first 2 sectors of NTFS partition).
Ran with

Code: Select all

qemu -L <whatever> -hdb <imagefile>
and it worked!
Love4Boobies wrote:In case you did that (to the right offset) outside of the assembly file (which is sort of weird) then nevermind.
Yep, I did that outside of the assembly file. The JMP instruction was down there all the time, actually. On NTFS, it always jumps to the offset 0x54.

Well, how could I change this so it wouldn't look weird to you? If I made the file from the origin 7C00h and replaced the whole partition bootsector with it, it would erase all the whatever structures it had. So I wrote an installer that uses Win32 API to paste the bootloader binary file at the exact offset (and it also checks the 55h, 0AAh signature to make sure the length is allright).

btw, I love your nickname 8) Don't get too angry with me.
Every Man Must Learn David DeAngelo's Stuff, Period.
http://www.doubleyourdating.com/Catalog
User avatar
CmpXchg
Member
Member
Posts: 61
Joined: Mon Apr 28, 2008 12:14 pm
Location: Petrozavodsk, Russia during school months, Vänersborg Sweden in the summertime

Re: Int13h AH=42h Boot From Hard Drive just fails

Post by CmpXchg »

OK, solved completely.
Works in qemu when invoked like this:

Code: Select all

qemu -L <whatever> -hda \\\\.\\PhysicalDrive1
I use my second hard drive to test the OS.
Every Man Must Learn David DeAngelo's Stuff, Period.
http://www.doubleyourdating.com/Catalog
Post Reply