Okay, I followed the setup recommendations for MSVC++ and the linker. I am not sure about the code in my kernel but that doesn't appear to be the problem right now. Or it is and I just don't know any better. The problem that I am running into is that when I try to read the headers from the PE file to find where my code starts there is no information at the address offset 0x3C / 60 the area is all zeros. I thought maybe I was reading it wrong or something but I checked and in the tutorial I am stepping through they have 60 and in the OSDev Wiki article I found it says 0x3C, same thing and I have tried both. a hex offset of 0x60 which I know is wrong does have data, it is 0x2020 but that still doesn't point me to the right spot. Does anyone here have VC++ experiance that could maybe point me in the right direction. I think I might be missing a config or I might have built my kernel incorrectly. If VC suppots two file types where do you specify which to use??
thanks in advance
Problem with VC++ / PE files
Problem with VC++ / PE files
Getting back in the game.
Hello,
Can you post the current code that executes the PE kernel?
I suspect the problem lies in the configuation of your PE kernel. Insure that the base address is that where it is being loaded at (Like 1 MB), and the entry point routine is set correctly.
Also, insure the entry routine is a naked function so MSVC++ does not add additional code for the stack frame--You don't want that
Can you post the current code that executes the PE kernel?
I suspect the problem lies in the configuation of your PE kernel. Insure that the base address is that where it is being loaded at (Like 1 MB), and the entry point routine is set correctly.
Also, insure the entry routine is a naked function so MSVC++ does not add additional code for the stack frame--You don't want that
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Okay, I don't have the code with me, I am at work but I this is it
File read to 0x100000
like I said though, even if this code is totally borked the problem I think I have is that there is not FILE HEADER info at offset + 0x3C / 60.
I can post my command line configurations for the compiler and linker when I get home. Are you using VC++ for your kernel, if so could you maybe link to a project file that is configured correctly so I can see or just post the command line codes.
File read to 0x100000
Code: Select all
mov ebx, [0x100000+60]
add ebx, 0x100000
add ebx, 24
mov ax, [ebx]
add ebx, 12
jmp ebx ; This being the suppossed location of the Kernel code
like I said though, even if this code is totally borked the problem I think I have is that there is not FILE HEADER info at offset + 0x3C / 60.
I can post my command line configurations for the compiler and linker when I get home. Are you using VC++ for your kernel, if so could you maybe link to a project file that is configured correctly so I can see or just post the command line codes.
Getting back in the game.
I will see if I can upload a basic demo for that tutorial for everyone.
I have been kind of busy working on the OS (and just now PIC tutorial), which is why I have not uploaded anything yet.
There is a small issue with that tutorial (That I will fix), but it does not relate to your current problem.
The configuation settings I use are listed in the tutorial. I assume you are using the same configuations as the tutorial?
I have been kind of busy working on the OS (and just now PIC tutorial), which is why I have not uploaded anything yet.
There is a small issue with that tutorial (That I will fix), but it does not relate to your current problem.
The configuation settings I use are listed in the tutorial. I assume you are using the same configuations as the tutorial?
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
cool, that would be extremely helpful. I have an old DOS game programming book that has tons of video, keyboard, mouse, and other functions and explanations. I will play around with those as soon as I get something running but I just need to get something running right now. plus I was unsure about where to put the runtime stuff, just kinda winging it until you post more info They are good tuts though
Getting back in the game.
Its up. Please tell me if you have any problems with the download.
I put the runtime initialization code inside of the system core library code, and keep it seperate from the Kernel and system initialization code. This helps insure the MSVC++ specific code is encapsulated away from the rest of the system for easier portability.
The system core links with the system library object files, and insures mainCRTStartup() is the first routine executed to insure the C++ runtime is initialized properly. mainCRTStartup() calls the system core initialization routine--kmain().
If you have any questions, please let me know.
I put the runtime initialization code inside of the system core library code, and keep it seperate from the Kernel and system initialization code. This helps insure the MSVC++ specific code is encapsulated away from the rest of the system for easier portability.
The system core links with the system library object files, and insures mainCRTStartup() is the first routine executed to insure the C++ runtime is initialized properly. mainCRTStartup() calls the system core initialization routine--kmain().
If you have any questions, please let me know.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}