OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 12:32 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: MSVC - KernelStart and KernelEnd Location
PostPosted: Fri Apr 08, 2022 6:33 am 
Offline

Joined: Sun Aug 22, 2021 2:59 pm
Posts: 2
Hi,

Im Writting an Operating System and got to the Point where i have to setup my Memory (Paging etc.).
Memory and Paging are setted up so far but i have the Problem to tell my MemoryManager where the Kernel Starts and Ends. In GCC i can simply say

Code:
_KernelStart = .; <-----
   .text : ALIGN(0x1000)
   .data : ALIGN(0x1000)
   .rodata : ALIGN(0x1000)
   .bss : ALIGN(0x1000)
_KernelEnd = .; <-----


and using the variables in cpp but how can i do that in msvc?


Top
 Profile  
 
 Post subject: Re: MSVC - KernelStart and KernelEnd Location
PostPosted: Sat Apr 09, 2022 12:31 pm 
Offline
Member
Member
User avatar

Joined: Sun Feb 18, 2007 7:28 pm
Posts: 1564
Hi,

The kernel already has all the information needed; its header information and associated data structures are in memory at the image base address. It can obtain the locations and sizes of all the sections there.

To provide a little more context, this is a small snippet from our system:
Code:
PUBLIC size_t PeGetImageSize(IN char* imageBase) {

   IMAGE_DOS_HEADER*     p;
   IMAGE_NT_HEADERS*     ntHeaders;

   p = (IMAGE_DOS_HEADER*)imageBase;
   ntHeaders = (IMAGE_NT_HEADERS*) (p->lfanew + imageBase);

   return (size_t) ntHeaders->optionalHeader.sizeOfImage;
}
...
PeGetImageSize (KERNEL_PHYSICAL)

_________________
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 94 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group