How to use VC++ to make a kernel
Posted: Sun Feb 17, 2002 8:20 am
I don't know if this deserves its own topic but here goes:
INSTURCTIONS How to use VC++ 6 to build a kernel.
A:
As we all know VC++ only outputs PE executables.
However inside these there are the normal segments of the program, .text & .data . Along with other sections such as .reloc, etc.
Using part copy we can extract these sections easily and copy them to a disk or disk image.(go to john fines web page to find partcopy).
By default the .text sector is located at 0x1000 and .data sector located at 0x2000 in the *.exe file. (VS .NET 0x200 0x400 instead) We can set the size of these pages by using
/filealign:0x1000 in the linker.
partcopy vskern.exe 1000 200 -f0 200
B:
To set the base of the program use the linker switch /BASE:0x10000
however the .text section will have a base of 0x1000 greater than you set the base to, so you must take this into account when load the kernel into memory.(.data section has offset of 0x2000). Maintain the offsets between sections unless you can change the values.
If this is too much it is possible to merge the sections. /merge:.text = .data
C:
Another section in PE files is the .reloc sector. This provides runtime relocations. We don't want this. So we use the linker switch /FIXED. now our text and data sections will be layed out as is.
D:
All the other options set in gcc for kernels like nostdlib, no rtti can be set in vc too, use the project options.
To exactly whats going on get "PE Explorer". Includes disassembler and can show you clearly the layout of your PE file. Jut search for it on google. If possible get bochs with BFE then you can see exactly whats goin on in the kernel.
I hope this helps, if there are any questions just shout and I'll get back to you. This works so far, but i'm not very far on in my os.
P.S.: I'd like another star, please.
INSTURCTIONS How to use VC++ 6 to build a kernel.
A:
As we all know VC++ only outputs PE executables.
However inside these there are the normal segments of the program, .text & .data . Along with other sections such as .reloc, etc.
Using part copy we can extract these sections easily and copy them to a disk or disk image.(go to john fines web page to find partcopy).
By default the .text sector is located at 0x1000 and .data sector located at 0x2000 in the *.exe file. (VS .NET 0x200 0x400 instead) We can set the size of these pages by using
/filealign:0x1000 in the linker.
partcopy vskern.exe 1000 200 -f0 200
B:
To set the base of the program use the linker switch /BASE:0x10000
however the .text section will have a base of 0x1000 greater than you set the base to, so you must take this into account when load the kernel into memory.(.data section has offset of 0x2000). Maintain the offsets between sections unless you can change the values.
If this is too much it is possible to merge the sections. /merge:.text = .data
C:
Another section in PE files is the .reloc sector. This provides runtime relocations. We don't want this. So we use the linker switch /FIXED. now our text and data sections will be layed out as is.
D:
All the other options set in gcc for kernels like nostdlib, no rtti can be set in vc too, use the project options.
To exactly whats going on get "PE Explorer". Includes disassembler and can show you clearly the layout of your PE file. Jut search for it on google. If possible get bochs with BFE then you can see exactly whats goin on in the kernel.
I hope this helps, if there are any questions just shout and I'll get back to you. This works so far, but i'm not very far on in my os.
P.S.: I'd like another star, please.