It outputs a file that doesn't run under windows, and has a 512 block of headers followed by the executable code on the next 512 byte align, 0-padded to the 512 byte align after that. It looks therefore like you can just strip off the first 512 bytes of the
outputted file, lose the last zeros (this doesn't actually help, because of 512 byte block-aligning on disks) and then exporting that.
I was so sure that you can't create a compiled file with the VC++ compiler that would have no PE header... Would that output run in MSDOS?
Edit: looks like the guys inside Microsoft didn't have it all nice 'n' breezy either -
That video is nice as an introduction or general overview
Sven Groot wrote:
evildictaitor wrote:You suggest that a compiler for operating-system-less environments must be done via a cross-compiler or from within the environment. This is not true. From 32bit windows you can create IL code and x64 code, neither of which will
run* on your 32bit windows, but both of which can be created from 32 bit windows
Which is the definition of a cross compiler.
What you need is a compiler capable of creating a binary for your operating-system-less environment. Visual C++ cannot do that. That's unfortunate, but there's not much you and I can do about it.
EDIT: It doesn't make a difference whether you are using C or C++. If you use Visual Studio, it uses the same compiler, cl.exe. If you run it from the command line you'll see it says "Microsoft C/C++ Optimizing Compiler".
Writing your code in Visual Studio is fine, but you will need a different compiler.
Not true, you can _absolutely_ use Visual C++ to do your own OS development. I have some
links about this on my blog. Specifically, there is this
part series that shows how to write multiboot PE kernels using Visual C++.
One of the switches you are looking for is "/nodefaultlib:libc" which will avoid linking all the C Runtime Library. So you could define functions like "memcpy" in your own code (which is kind of necessary when writing your own kernel since there is no C runtime
library to use (unless you build your own of course)). There are also several other switches that should get you closer.
I don't know how many of these switches are depracated (if any) in VS2008 though.
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.