flat assembler
Message board for the users of flat assembler.

Index > Windows > Question about 'how windows loads a program'

Author
Thread Post new topic Reply to topic
The_CodeMaster



Joined: 25 Jul 2005
Posts: 8
The_CodeMaster 27 Aug 2005, 13:39
When windows executes a program, does it load this program into a new code-segment (starting from 0) or does this program somehow gets mapped randomly (where there is room)??
Post 27 Aug 2005, 13:39
View user's profile Send private message Reply with quote
polygon7



Joined: 14 Aug 2003
Posts: 62
Location: Poznan, Poland
polygon7 27 Aug 2005, 15:41

_________________
best regards
p7
Post 27 Aug 2005, 15:41
View user's profile Send private message Visit poster's website Reply with quote
The_CodeMaster



Joined: 25 Jul 2005
Posts: 8
The_CodeMaster 27 Aug 2005, 16:33
well, that didn't realy help, anyway, does 32-bit assembler use the segment-selectors at all, when jumping (since 32 bit can adress 4 gig anyway)?
Post 27 Aug 2005, 16:33
View user's profile Send private message Reply with quote
El Tangas



Joined: 11 Oct 2003
Posts: 120
Location: Sunset Empire
El Tangas 27 Aug 2005, 18:07
By default, all programs are loaded at address 400000h. Because of paging, all user programs "think" they are loaded at the same address. You can ask windows to load your program at other addresses with the "at" operator in Fasm.
Post 27 Aug 2005, 18:07
View user's profile Send private message Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend 27 Aug 2005, 22:02
The address in which the loaded program is loaded is called an ImageBase and it is saved in the PE header of every windows' .exe file. Fasm (as it builds the PE file with no linker) lets you decide what should the ImageBase be (defaulting to 400000h). But in fact some addresses are unaccessible for programs. Some memory is reserved for dlls only, some is reserved for drivers, etc. I don't know them all, but I'm sure all 8xxxxxxxh addresses are unaccessible.
Post 27 Aug 2005, 22:02
View user's profile Send private message Visit poster's website Reply with quote
The_CodeMaster



Joined: 25 Jul 2005
Posts: 8
The_CodeMaster 27 Aug 2005, 23:55
so adress 400000h is indeed a new codesgment (since it is a multiple of 2^16), thx for clearing it up.
Post 27 Aug 2005, 23:55
View user's profile Send private message Reply with quote
El Tangas



Joined: 11 Oct 2003
Posts: 120
Location: Sunset Empire
El Tangas 29 Aug 2005, 20:36
Quote:

so adress 400000h is indeed a new codesgment (since it is a multiple of 2^16), thx for clearing it up.


Well, yes you could say that, but in protected mode segments of size 2^16 don't have much meaning because memory is managed in page units (4Kb in size). Newer processors support a larger page size, but I think windows only uses 4k.
Post 29 Aug 2005, 20:36
View user's profile Send private message Reply with quote
Ancient One



Joined: 28 Feb 2005
Posts: 55
Ancient One 30 Aug 2005, 02:12
we don't need to bother about segment selector in windows because windows set it up for us. segment selector in p-mode purpose is not the same in real-mode vs p-mode.
Post 30 Aug 2005, 02:12
View user's profile Send private message MSN Messenger Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3174
Location: Denmark
f0dder 30 Aug 2005, 03:04
A more correct answer would be that CS,DS,ES,SS are set up as selectors for flat descriptors - segments of memory that are 4GB long and starts at base address zero Smile

And the link from Polygon7 *is* pretty damn useful.
Post 30 Aug 2005, 03:04
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.