blabberer
November 22nd, 2012, 04:35
i Normally Avoid answering dead threads where the original questioner has disappeared
but since i see constants like 0x80000000 etc i just thought i would chime in incase some one else is reading this thread in future
the following remarks assume you have xpsp3 as os on a 32 bit machine
the maximum user space is controlled by by a boot switch /3gb 3 gb userspace and 1 gb kernel space (boot.ini )
default is 2gb of user space and 2 gb of kernel space
this 2gb can be queried using several methods including some wmic queries easiest is to use windbg
Code:
lkd> ? poi(nt!MmHighestUserAddress)
Evaluate expression: 2147418111 = 7ffeffff
(puzzle what does the last page contain why effff not fffff what is the characteristics of the page that spans from 7fff0000 to 7fffffff)
lkd>
the kernel space is common to all processes
like wise physical pages also have a defined pattern check MmHighestPhysicalPage and MmLowestPhysicalPage globals
so if you exceed say the upper limit your machine might crash citing insufficient resources
the smoke and mirror can only go thus far not extend into hyperspace
when a process is started the windows loader reads the executables header determines what is its base of image and
would start mapping your executable to that address (preferred image base) in case of helper objects like dll this preferred base
might not be available so they can be relocated to what the loader finds as the next available slot
the Imagebase is decided by certain switches to the linker (check /DRIVER /FIXED /DYNAMICBASE etc)
and based on certain other switches to linker relocation information is appended to the executable
an exe normally will not have a reloc section (probably because this file is the first to be mapped and it can be successfully mapped to
say a constant 0x400000 address (default preferred imagebase for exes)
the space from 0 to imagebase is used by the loader for various activities that include mapping language support code pages and mapping
environment variables specific to the process
the mapped system dlls in a process is what is termed as smoke and mirrors (magic)
suppose you have 1000 process and each process need ntdll.dll the loader gives each of the process the same ntdll.dll map
which has been mapped only once and not 1000 times and increments a counter saying ntdll is mapped 1000 times
as long as there is no write operation to the ntdll from the process a single copy can insert itself into every process
the loader plays rummy and uses a joker to substitute an ace in a triplet
if there is a write operation a separate copy of ntdll is provided to the specific processes that writes
now if all the 1000 processes write a separate copy might eat the resources to the point of suffocation
(ever seen the not enough virtual memory windows is increasing the virtual memory warning dialog) and
consequent death (bsod )
in the phase where windows states that it is increasing virtual memory it uses a mechanism called paging
where by diskspace is used as temporary ram
further blabbering on further questions