Page 2 of 3
Re: BootSector problem
Posted: Wed Jun 08, 2011 8:46 am
by iocoder
and the program wich is loaded is this i don't think the ORG directive is correct
Hey, you have already got the answer through your mind
I am making progress i succeded in loading the other program from the sector 2 and load it
Good work man! Go on
Re: BootSector problem
Posted: Wed Jun 08, 2011 9:36 am
by Chandra
i don't think the ORG directive is correct but what should i put there if it's loaded at 0x1000:0x0000 ?
Seriously, you've no idea how 'Real Mode' addressing works. You really need to read docs on x86 architecture.
And yes, you're right. The ORG directive isn't correct. Now, what you should specify in the ORG directive depends upon how you setup the segment registers. Note that CS:IP must point to 0x10000 because that is the physical address the jump refers to. You can specify ORG 0x10000 and then setup the segment registers to 0 or, you can specify ORG 0 and setup the segment registers to 0x1000. I won't go further than this because you really need to refer to docs that explain about segmentation, memory addressing (real mode and protected mode) and some such.
Cheers.
Re: BootSector problem
Posted: Wed Jun 08, 2011 10:13 am
by opc0de
Ok i have solved all the problems and succesefully loaded windows mbr at correct address jumped to that adress but now i get an error.It says : couldn't open drive multi(0)disk(0)rdisk(0)partition(1) this error is from NTLDR what the heck is it and how i can bypass it?
Re: BootSector problem
Posted: Wed Jun 08, 2011 11:15 am
by opc0de
berkus wrote:Probably need to call windows mbr exactly in a state it expects from BIOS (e.g. boot drive in DL)
Tried that doesn't work though maybe some other registers need to be initialized
Re: BootSector problem
Posted: Wed Jun 08, 2011 11:32 am
by neon
If NTLDR is being loaded from the primary boot device successfully by Windows MBR I do not see your boot loader software being the cause. If your software calls the Windows MBR in the same state your MBR was called, your work is done.
Re: BootSector problem
Posted: Wed Jun 08, 2011 4:08 pm
by iocoder
Tried that doesn't work though maybe some other registers need to be initialized
maybe you need to:
Code: Select all
xor bx, bx
mov es, bx
mov ds, bx
mov dl, 0x80
jmp 0x0000:0x7C00
could u try it?
Re: BootSector problem
Posted: Wed Jun 08, 2011 11:59 pm
by opc0de
Nope it doesn't work
if you give me your e-mail address i will provide you the source to try to fix it if you have time. Or maybe this error is caused by vmware ? I really don't have a clue...
Re: BootSector problem
Posted: Thu Jun 09, 2011 12:38 am
by Combuster
opc0de wrote:if you give me your e-mail address i will provide you the source
Why not attach directly to this thread?
Re: BootSector problem
Posted: Thu Jun 09, 2011 4:55 am
by iocoder
opc0de wrote:Nope it doesn't work
if you give me your e-mail address i will provide you the source to try to fix it if you have time. Or maybe this error is caused by vmware ? I really don't have a clue...
I think it is better to post your source code here in this thread to allow all of us to help you
at all it is up to you! if you want to send me the code you can send it in a message through your User Control Panel here in OSDev, my username is: mostafazizo.
sorry i am afraid i couldn't post my e-mail address because this is not allowed in the forums.
Regards,
Mostafa Abd El-Aziz
Re: BootSector problem
Posted: Thu Jun 09, 2011 5:45 am
by opc0de
Here is the code :
The boot loader part :
Code: Select all
[BITS 16]
[ORG 0x7C00]
main:
cli
xor bx,bx
mov es,bx
mov fs,bx
mov gs,bx
mov ds,bx
mov ss,bx
mov sp,0x7C00
sti
MOV SI, Hello
CALL PrintString
MOV AH,0x03
MOV BH,0x00
INT 0x10
ADD DH,2
XOR DL,DL
MOV AH,0x02
XOR BH,BH
INT 0x10
XOR BX,BX
ReadPass:
MOV AH,0x00
INT 0x16
CMP AL,13
JE Verify
MOV [read+BX],AL
PUSH BX
CALL PrintChar
POP BX
INC BX
CMP BX,6
JE Verify
JMP ReadPass
Verify:
MOV SI,read
MOV DI,pass
MOV CX,6
REP CMPSB
JNE the_end
Done:
MOV SI,succ
call PrintString
MOV AH,0x02
MOV AL,1
MOV CH,0
MOV CL,2
MOV DX,0x0080
MOV BX,1000h
MOV ES, BX
XOR BX,BX
INT 13h
CMP AH,0
JNE Done
jmp 0x1000:0x0000
the_end:
INT 0x19
PrintChar:
MOV AH,0x0E
MOV BH,0x04
MOV BL,0x10
INT 0x10
RET
PrintString:
MOV AL,[SI]
CMP AL,0
JE theret
INC SI
CALL PrintChar
JMP PrintString
theret:
ret
pass db 'MUKMIK',0
read times 7 db 0
succ db 'Success booting...',0
Hello db 'Enter password',0
times 510 - ($ - $$) DB 0
dw 0xAA55
The part wich loads the original MBR at 7C00h and jumps to it
Code: Select all
[BITS 16]
[ORG 0x0000]
Start:
MOV AH,0x02
MOV AL,1
MOV CH,0
MOV CL,4
MOV DX,0x0080
MOV BX,0x0000
MOV ES,BX
MOV BX,0x7C00
INT 13h
CMP AH,0
JNE Fail
cli
xor bx,bx
mov es,bx
mov fs,bx
mov gs,bx
mov dl,0x80
mov ds,bx
mov ss,bx
mov sp,0x7C00
sti
JMP 0x0000:0x7C00
Fail:
INT 0x19
times 512 - ($ - $$) DB 0
Re: BootSector problem
Posted: Thu Jun 09, 2011 6:02 am
by bluemoon
I'm not familiar with NTFS but are you sure you not overwriting important data at sector 2, 3, 4, which you used to store your application?
Re: BootSector problem
Posted: Thu Jun 09, 2011 6:14 am
by opc0de
I thought so at first ... but then i just overwritten sectors 2 and 4 but not the mbr and windows booted up normally... so that's not the problem
Re: BootSector problem
Posted: Thu Jun 09, 2011 9:20 am
by opc0de
berkus wrote:No, usually entire first track is reserved (partitions start on track boundary).
You are way offtopic read something about MBR to refresh your memory...
Re: BootSector problem
Posted: Thu Jun 09, 2011 9:54 am
by Chandra
opc0de wrote:berkus wrote:No, usually entire first track is reserved (partitions start on track boundary).
You are way offtopic read something about MBR to refresh your memory...
I didn't find anything off-topic.
Re: BootSector problem
Posted: Thu Jun 09, 2011 10:02 am
by opc0de
Chandra wrote:opc0de wrote:berkus wrote:No, usually entire first track is reserved (partitions start on track boundary).
You are way offtopic read something about MBR to refresh your memory...
I didn't find anything off-topic.
It has been implemented before and should work if i use the original mbr what it has to do with the first track...anyway maybe i don't get it but if others used the same method and worked it should work for me but it's a mistake in the code.if you find it i owe you a pack of beer.cheers