use visual studio for building os
use visual studio for building os
Hi,
One day i was googling around and found some article (or blog i beleave) about haw to setup a custom (makefile) project wich enabled compiling a operating sytem with visual studio .net 2003.
But i lost the link so i was wondering if enyone had seen it and remembers the link or even better if you know how to settup such a project please explain.
Now i use DJGPP with NASM and MAKE but i would like to use VS.net
anyone ???
thx in advance.
One day i was googling around and found some article (or blog i beleave) about haw to setup a custom (makefile) project wich enabled compiling a operating sytem with visual studio .net 2003.
But i lost the link so i was wondering if enyone had seen it and remembers the link or even better if you know how to settup such a project please explain.
Now i use DJGPP with NASM and MAKE but i would like to use VS.net
anyone ???
thx in advance.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:use visual studio for building os
Missed that one. ;D
this is indeed a nice resource but i remember to have found a blog with screenshots,etc...
so maybe this could be a greate opportunity for everyone to post all link related to os development with visual studio in this thread.
if thats ok with the moderator.
this is indeed a nice resource but i remember to have found a blog with screenshots,etc...
so maybe this could be a greate opportunity for everyone to post all link related to os development with visual studio in this thread.
if thats ok with the moderator.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:use visual studio for building os
np, of course. Whatever is helpful for osdeving suits fine here, afai'm concerned.
Re:use visual studio for building os
i found this link wich should provide a sample project
but didn't get it to work. Maybe someone else can do something with it.
http://www.osdcom.info/component/option,com_mamboboard/Itemid,36/func,view/id,616/catid,1/
but didn't get it to work. Maybe someone else can do something with it.
http://www.osdcom.info/component/option,com_mamboboard/Itemid,36/func,view/id,616/catid,1/
Re:use visual studio for building os
hi i've been playing around and followed the instructions on the FAQ
i created a project with a small sample of code, nothing fancy (just a hello world sample).
wath i would like to become is a project file that compiles a kernel in a format that grub can read.
i think i got lost somewhere
in the attachement you can see what i got so far
anyone care to help???
i created a project with a small sample of code, nothing fancy (just a hello world sample).
wath i would like to become is a project file that compiles a kernel in a format that grub can read.
i think i got lost somewhere
in the attachement you can see what i got so far
anyone care to help???
Re:use visual studio for building os
i thought you were talking about this page...but perhaps it's different:
http://ksrenevasan.blogspot.com/2005/10 ... using.html
either way, this one seems useful.
proxy
http://ksrenevasan.blogspot.com/2005/10 ... using.html
either way, this one seems useful.
proxy
- Kevin McGuire
- Member
- Posts: 843
- Joined: Tue Nov 09, 2004 12:00 am
- Location: United States
- Contact:
Re:use visual studio for building os
Yeah, but I have never heard of being able to use MSVC's compiler and linker to produce a kernel image loadable by GRUB. Can you really? I just do not think you are going to have much luck.
- Kevin McGuire
- Member
- Posts: 843
- Joined: Tue Nov 09, 2004 12:00 am
- Location: United States
- Contact:
Re:use visual studio for building os
I would post that code but I had formatted my hard drive a while back; that guy at osdcom did have a version that worked uploaded, but for some reason he removed it. I even remember sending a message to him multiple times with the better template that only needed a stub file to be used with the MSVC linker to make it work, but he never replied or posted it and I keep putting those silly links that never worked up. - I sure learned my lesson about that now. :-\
I think, if I remember correctly, you can tell the linker to generate position independant code. Then write a STUB program in assembler that includes a multi-boot header, and set the entry point to a routine in ASM. That routine needs to transverse the PE32 format and find the entry point for the executable and jump there. Once that is done everything should work. I can not remember how I did the base address or if it it was only used as a preferred load address once you set the position independant code option.
If I had windows I would try and get it working again, but I only have my laptop and linux installed..but it turned out that using the PE32 could be done with very few steps, a assembler, and the MSVC compiler/linker.
Also the STUB needs to include the MS-DOS magic number at the beginning, be of the exact size, and set as a option to the linker.
I think, if I remember correctly, you can tell the linker to generate position independant code. Then write a STUB program in assembler that includes a multi-boot header, and set the entry point to a routine in ASM. That routine needs to transverse the PE32 format and find the entry point for the executable and jump there. Once that is done everything should work. I can not remember how I did the base address or if it it was only used as a preferred load address once you set the position independant code option.
If I had windows I would try and get it working again, but I only have my laptop and linux installed..but it turned out that using the PE32 could be done with very few steps, a assembler, and the MSVC compiler/linker.
Also the STUB needs to include the MS-DOS magic number at the beginning, be of the exact size, and set as a option to the linker.
Re:use visual studio for building os
I don't know anything about grub, but the VS linker cannot generate PIC. What you can do, though, is write an assembly-language program, assemble it as binary, and pad it to a multiple of a fixed size (mine is 1K, although it does a bunch of other stuff, like switching into pmode, entering long mode if supported, reading hw info from the bios, etc).
In my OS, the bootsector loads the boot loader to 0x1000 - which is actually an assembly stub pre-pended to a PE file. Since the assembly stub is 1K, I rebase the loader to 0x00001400.
Then run a post-build event to "copy loader.bin+loader.sys osloader.exe" which will concatenate the first two files. So what you have is:
I'm assuming GRUB can load a binary to a specified address. If the address is arbitrary, it is relatively straightforward to rebase the file in the assembly stub.
In fact, this is the same technique used by Microsoft for NT! The NTLDR file on your boot volume is a _very_ large assembly stub (actually probably written in C with some internal C compiler that can output 16bit code) followed by a PE file at offset 0x4CB0 in my version of Windows. (osloader.exe - the embedded EXE file - appears to contain a TFTP server! For what, I wonder...)
HTH,
Mike
In my OS, the bootsector loads the boot loader to 0x1000 - which is actually an assembly stub pre-pended to a PE file. Since the assembly stub is 1K, I rebase the loader to 0x00001400.
Then run a post-build event to "copy loader.bin+loader.sys osloader.exe" which will concatenate the first two files. So what you have is:
Code: Select all
| |
--------------- 0x1000
| Loader (1K) |
--------------- 0x1400
| OS Loader |
| |
| |
| |
---------------
| |
In fact, this is the same technique used by Microsoft for NT! The NTLDR file on your boot volume is a _very_ large assembly stub (actually probably written in C with some internal C compiler that can output 16bit code) followed by a PE file at offset 0x4CB0 in my version of Windows. (osloader.exe - the embedded EXE file - appears to contain a TFTP server! For what, I wonder...)
HTH,
Mike
Re:use visual studio for building os
the link http://ksrenevasan.blogspot.com/2005/10/writing-multiboot-pe-kernels-using.html talks of a kernel that can be compiled & linked using msvc++.
in the next few day's i'll try to create a project file that dous just that. :-\
i realy don't care in wath format my kernel is compiled. I will use grub to load it.
All i care about is having a tool that gives me intellisense, manages my project and compiles it to a file. that way i just have to move it to the floppy image and test it with some virtual x86.
i do not want to hasle around with make files and constantly have to update them.
MS Windows was compiled using msvc++ so it has to be possible.
At the end of this thread i want to have a project file (or template if possible) where i can add classes and code files at will, hit compile and see my result.
It would be a boost for everyone trying so start with os development to just open a template and add some code.
So for everyone who thinks or feels the same way just take 15 minutes of your time to look for some resources on the subject and post wath you find (or even better upload a sample kernel project in msvc++ ;D).
thanks in advance.
in the next few day's i'll try to create a project file that dous just that. :-\
i realy don't care in wath format my kernel is compiled. I will use grub to load it.
All i care about is having a tool that gives me intellisense, manages my project and compiles it to a file. that way i just have to move it to the floppy image and test it with some virtual x86.
i do not want to hasle around with make files and constantly have to update them.
MS Windows was compiled using msvc++ so it has to be possible.
At the end of this thread i want to have a project file (or template if possible) where i can add classes and code files at will, hit compile and see my result.
It would be a boost for everyone trying so start with os development to just open a template and add some code.
So for everyone who thinks or feels the same way just take 15 minutes of your time to look for some resources on the subject and post wath you find (or even better upload a sample kernel project in msvc++ ;D).
thanks in advance.
- Kevin McGuire
- Member
- Posts: 843
- Joined: Tue Nov 09, 2004 12:00 am
- Location: United States
- Contact:
Re:use visual studio for building os
http://www.mega-tokyo.com/forum/index.p ... eadid=6336
HA, Tell me I did not know what I was doing when telling you how it worked. I did it with out all that crazy relinking, objcopying, and crap.
Make a DLL it was, not a EXE that was how I did it... There is a big chance that I left out something important in that post for a setting in MSVC, but I know it is nothing that can not be found.
Now why can someone not verify that it works for them, since I no longer have a windows machine, and then include it in the OsFaq under the Visual C++ section? ::)
I just looked through:
http://ksrenevasan.blogspot.com/2005/10 ... using.html
It has the exact same results as using my STUB, but could be easier since you have no external source. The only advantage the STUB has over that is being able to handle larger sections than 4KB automaticaly.
Where here you have to assume that each section is 4K.
So I guess it really comes down to preference.
HA, Tell me I did not know what I was doing when telling you how it worked. I did it with out all that crazy relinking, objcopying, and crap.
Make a DLL it was, not a EXE that was how I did it... There is a big chance that I left out something important in that post for a setting in MSVC, but I know it is nothing that can not be found.
Now why can someone not verify that it works for them, since I no longer have a windows machine, and then include it in the OsFaq under the Visual C++ section? ::)
I just looked through:
http://ksrenevasan.blogspot.com/2005/10 ... using.html
It has the exact same results as using my STUB, but could be easier since you have no external source. The only advantage the STUB has over that is being able to handle larger sections than 4KB automaticaly.
Where here you have to assume that each section is 4K.
Code: Select all
dd(0x00101000) ; header_addr
dd(0x00101000) ; load_addr
dd(0x0010200F) ; load_end_addr
dd(0x0010200F) ; bss_end_addr
dd(0x00101030) ; entry_addr
Re:use visual studio for building os
Hey all, I'm a new guy here. I'm also new to OS Development. I went ahead and went through the two blog posts linked to and tried it using Visual Studio 2005. To my amazement and joy, it worked like a champ . I used the options he suggested, compiled it to Kernel.exe, added Kernel.exe to the pre-built Grub disk image, and Bochs booted it up just fine (and the OS printed "Hello World!" to the screen). I didn't have to rip out the PE format either. Simply by using the filealign and baseaddress linking options, GRUB is able to boot it just fine in the PE format and all .
I'm not sure how "abnormal" the kernel image itself is. With the way I compiled/linked it, it is 16k right now.
Considering that I'm a Windows guy and use Visual Studio 2005 for most development work I do, it's pretty cool being able to use VS2005 to do OS development now. I want to see if I can do the same thing using Visual C++ 2005 Express. If an "intro to OS development" tutorial can be written using VC2005 Express, Bochs, and the pre-built Grub disk image, it might be a promising "head start" to people. Of course, there's always value in learning how bootloaders work (and I feel everyone should at least know), you don't necessarily want to write your own bootloader from the ground up either. This is just coming from a "new guy" to OS Development though, so YMMV.
I do have to admit that there are certain aspects from the blog posts that I don't understand, so I'm going to do some more research and learning before I move on (that old "understand everything that is going on" adage, don't cha' know).
Anyways, so perhaps OS development on Windows as your main platform is actually feasible? But I still don't know that much information yet on the compilation process, so I don't know what it would take to augment VC2005 to be able to have your own CRT, or if its even possible.
Enjoy .
I'm not sure how "abnormal" the kernel image itself is. With the way I compiled/linked it, it is 16k right now.
Considering that I'm a Windows guy and use Visual Studio 2005 for most development work I do, it's pretty cool being able to use VS2005 to do OS development now. I want to see if I can do the same thing using Visual C++ 2005 Express. If an "intro to OS development" tutorial can be written using VC2005 Express, Bochs, and the pre-built Grub disk image, it might be a promising "head start" to people. Of course, there's always value in learning how bootloaders work (and I feel everyone should at least know), you don't necessarily want to write your own bootloader from the ground up either. This is just coming from a "new guy" to OS Development though, so YMMV.
I do have to admit that there are certain aspects from the blog posts that I don't understand, so I'm going to do some more research and learning before I move on (that old "understand everything that is going on" adage, don't cha' know).
Anyways, so perhaps OS development on Windows as your main platform is actually feasible? But I still don't know that much information yet on the compilation process, so I don't know what it would take to augment VC2005 to be able to have your own CRT, or if its even possible.
Enjoy .
Re:use visual studio for building os
Hi i've been trying the instructions on the blog.
everytime i try testing the kernel in a virtual pc (boch & virtual pc) the machine reboots.
i can't figure out wath is wrong with the code. i use VS2005 just like jolson88 but the thing keeps rebooting.
can someone pls have look.
or if jolson88 could upload his code so i can compare and see wat's wrong with my project file.
thx.
everytime i try testing the kernel in a virtual pc (boch & virtual pc) the machine reboots.
i can't figure out wath is wrong with the code. i use VS2005 just like jolson88 but the thing keeps rebooting.
can someone pls have look.
or if jolson88 could upload his code so i can compare and see wat's wrong with my project file.
thx.