Page 2 of 2

Re: MBR- Help

Posted: Tue Jul 15, 2008 5:21 am
by bewing
We're not trying to be mean. We are just pointing out some potential errors.

All partition tables are different. There is no way to give you any kind of tutorial example. The wiki entry for the Partition_Table is pretty complete. If you want to see what a partition table for a particular drive should look like, then partition it with fdisk or your favorite partitioning software, and use some kind of disk editing software to examine LBA 0, and see what the partition table says. It's easier to copy a working example than to try to type an entry in by hand, and hope it works right.

Re: MBR- Help

Posted: Tue Jul 15, 2008 4:58 pm
by PatrickV
doesn't partition table has to follow the IBM Standards.So theoraticly it should be the same as far i was reading. Thanks for the link i will check it out once it's finished

Re: MBR- Help

Posted: Tue Jul 15, 2008 7:35 pm
by bewing
PatrickV wrote:doesn't partition table has to follow the IBM Standards?
Not entirely, no. Only one bit in the first byte (the "active" flag) is defined. What do the other bits do? IBM never said. I have proposed to use bit 0 as a "48 bit lba" flag for the partition table, which means that the CHS fields don't exist.

The IBM standard also never covered the "Filesystem type" byte (#4). It never said what happens when a disk grows bigger than would fit in the CHS fields (which happened a long time ago). Or what would happen when disks grow bigger than would fit in the LBA fields. So there is a lot of stuff that isn't covered by the IBM standard.

Re: MBR- Help

Posted: Wed Jul 16, 2008 5:37 pm
by PatrickV
can anyone help me out or point to someone i can talk to who created something like this, because looks like you guys know about it but you don't code your own

Re: MBR- Help

Posted: Wed Jul 16, 2008 5:42 pm
by Brynet-Inc
PatrickV wrote:can anyone help me out or point to someone i can talk to who created something like this, because looks like you guys know about it but you don't code your own
Don't expect members to spoon feed you code, that article on the Wiki is all you'll possibly need... assuming you have at least moderately notable programming skills.

Re: MBR- Help

Posted: Wed Jul 16, 2008 5:51 pm
by PatrickV
I only got old style VB 4.0 programming skills, Their i don't creat stacks and use opcodes and assembly language. But thanks anyway and point my greadyness to learn from source code

Re: MBR- Help

Posted: Wed Jul 16, 2008 6:46 pm
by pcmattman
PatrickV wrote:I only got old style VB 4.0 programming skills, Their i don't creat stacks and use opcodes and assembly language.
Then writing an OS is not for you.

Re: MBR- Help

Posted: Wed Jul 16, 2008 8:12 pm
by PatrickV
Hey, don't mock me man, i am trying somthing new.

Re: MBR- Help

Posted: Wed Jul 16, 2008 8:29 pm
by Alboin
PatrickV wrote:Hey, don't mock me man, i am trying somthing new.
He meant that you're going to have to learn some lower level languages as only knowing VB and not wanting to get your hands dirty will simply not work in osdev.

Re: MBR- Help

Posted: Thu Jul 17, 2008 7:34 am
by Combuster
He meant that you're going to have to learn some lower level languages as only knowing VB and not wanting to get your hands dirty will simply not work in osdev.
*The resident BASIC guru agrees with this sentiment*

Re: MBR- Help

Posted: Sun Jul 20, 2008 1:22 am
by pcmattman
Learn something like C, which will help to get you into a mindset for coding an OS. Assembly is also suggested, but unless you want to write an all-assembly OS (which, by the looks of your goals, will mean it'll take you much longer) you will need to know C.

Re: MBR- Help

Posted: Sun Jul 20, 2008 2:03 am
by Omega
PatrickV. First off I think it is great that you introduced yourself as PatrickV when clearly your post denotes that fact. You seemed very cute and nice but then you became hypersensitive, what happened there? Listen, writing your own OS isn't something you are going to fly right through, it is going to take years before you get something worthwhile bragging about. You only know VB 4.0, are you a caveman? I started developing my OS having more than 6 years experience in user-mode programming where I have written everything from Switch Sniffers to Fuzzers and I still have major issues writing certain things. I often write code for days and then later delete it all and start again. I have wanted to give up many times and do for months at a time, but I kept trying and I keep learning as much as I can and I get through it; right now I am writing my drivers (I never thought I'd even get past my loader; it took me 5 months until I saw my first response from the keyboard!). My point is, you are taking on a life's challenge that will not end soon and you have started on the wrong foot.

My advice. Don't write your own loader right now (use GRUB). Forget about this MBR business, you're just talking about a single stage loader which will get you nowhere fast. Focus on what your goals are and first evaluate the likelihood of them being met and adjust them accordingly (like don't think your going to be the first person to successfully create a full-fledged NTFS driver, because right now you won't and no one else that can will help you). I am not saying that a few years from now you won't become a great coder, because you might but as of now VB 4.0 is not going to cut it down here; where is your low-level experience?

Now, don't get discouraged or yell at me for this post, I am only trying to slap you back into reality. So, go on and start again and ask us nicely, "How do I write a single stage bootloader?" and I will say:

Code: Select all

[BITS 16] ; Real Mode

[ORG 0x7C00] ; BIOS looks for us right here

mov ax,0x0000 ; Initialize the DS reg
mov ds,ax ; Store our message offset

mov si,sMessage ; Store our String

mov ah,0Eh ; The function to display a character (teletype)
mov bh,00h ; Page number
mov bl,07h ; Normal text attribute

.nextchar ; Internal label
lodsb ; Check for end of string '0'
or al,al ; Set AL=0
jz .return ; If the zero flag has been set then goto quit
int 10h ; Run the BIOS video interrupt
jmp .nextchar ; Loop back round to the top
.return ; quit

; wait for key press
mov ah,00h ; BIOS Scan Keycode
int 16h ; Execute Command

jmp reboot ; We're done, reboot!

reboot:
jmp 0ffffh:0000h ; reboot!
ret ; End Function

sMessage db "Hello, World!",13,10,0

times 510-($-$$) db 0 ; Fill her up to 512

dw 0AA55h ; Look see, I am a boot loader
Happy Coding!

Re: MBR- Help

Posted: Mon Jul 21, 2008 4:19 pm
by PatrickV
Thanks for the input omega. On the other hand i don't have c lanaguage skills. If need c and can anyone point out where i can start. Using grubs is an issue becasue i am using windows first of but i need to create a kernel image which i have no idea how to create for linux. The code you gave me is very useful which i was thinking to apply to my os "Patricknet" But i am still intrested coding my own MBR which you said that everything takes time and i understand that

Re: MBR- Help

Posted: Mon Jul 21, 2008 4:50 pm
by Zenith
Then in what language are you planning to write your OS in? VB.NET?

Sorry to be critical, but you obviously need to read >> Getting Started << on the wiki. Do you meet the Requirements?

Some viable options other than C/C++ include Assembly (but from what we've seen, you're not that skilled at it), FreeBASIC (vaguely related to VB), and Pascal (if you know it).

And if you're going to do OS development and just learn C/C++/Pascal along the way, forget about it. Your time and effort will definitely be better spent working on something else.

Anyway, most people with operating systems already installed might not appreciate you overwriting their MBR. Wikipedia is also a good, language-independent reference about MBRs - http://en.wikipedia.org/wiki/Master_boot_record