So I've just got done with some of Casey's videos explaining some of the in's and out's of windows memory management and how program's address spaces are basically divided up on 4KB page boundaries for which the OS will bring in and push out of RAM. After watching these I also noticed someone put up a link with some great talks by Mark Russinovich who goes into much more detail on how exactly windows manages memory. Within these talks, Mark goes into how the OS first begins a program. In the video, when talking about how windows first boots up a program's exe he states [paraphrasing], "Exe's are mapped into the address space. When something like notepad.exe is first started up, notepad.exe is mapped into the address space and then the first thread is created with a start address that points to the first line of code in notepad.exe. When this is run, a page fault is incurred and the system pulls in the first page of the exe into RAM and connects the RAM with the virtual memory of the notepad process and the tread continues".
What I'm confused about is what does he mean exe's are first 'mapped into the address space'? What address space is he talking about? In my mind, when he says 'a program's address space' I think he's referring to a program's virtual address space which, in the beginning, only lives within the exe file itself on disk (within the .code/text section of the exe correct?). If this is true, then how can a program map itself into it's own address space? According to Mark, the first page of a program isn't actually in RAM until part of the exe is already memory mapped 'somewhere' and the first line of the code is executed which then incurs the page fault and puts the first page of code into RAM.