Jump to content
  • Advertisement
Sign in to follow this  
Verg

where is the assembled code mapped (Win32/assembler)

This topic is 4756 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is related to the other thread... HINSTANCE/HMODULE... doesn't that just indicate where the assembly code begins in memory? When an invalid page fault happens (if it does)... the address of the fault point is (of course) relative to the HMODULE value... correct? IOW: HMODULE = 0x00400000 page fault point = 0x00401100 where things broke, then == 0x1100 bytes from the beginning of the module correct? ---- The reason I'm asking is that on a different user's computer, the HMODULE/HINSTANCE value will vary, and we still want to be able to find where the code broke. ---- Sorry if this seems a little dull; I'm slow on the uptake sometimes. Just looking for a confirmation, or a "no, no, no you stupid ass" or something [smile] Thanks Chad

Share this post


Link to post
Share on other sites
Advertisement
Yes. The location of code in an executable is fixed relative to the base address of the executable (note that this does not always translate into the offset in the EXE file - there can be holes in memory). I should also note that unless you screw with the compiler settings to make it default to a weird load address, the address it gets loaded at will be the same on all computers (this is only true for EXEs; it is not necessarily true for DLLs).

Share this post


Link to post
Share on other sites
When you create a DLL, the general practice is to change the default base address (otherwise the DLL loader will need to rebase the DLL at run time, which is a relatively slow process). If the DLL doesn't overlap any other DLLs loaded, then the base address will also be the same on all computers as well. Remember, the base address is virtual memory, and every process gets it's own virtual address space.

Share this post


Link to post
Share on other sites
Quote:
Original post by Promit
You know though, I think an executable always begins at 0x00400000.


Nope. The base address is a linker setting that defaults to 0x400000, but can be changed. Also, an executable can be loaded into memory like a DLL.

Share this post


Link to post
Share on other sites
Quote:
Original post by Dean Harding
When you create a DLL, the general practice is to change the default base address (otherwise the DLL loader will need to rebase the DLL at run time, which is a relatively slow process). If the DLL doesn't overlap any other DLLs loaded, then the base address will also be the same on all computers as well. Remember, the base address is virtual memory, and every process gets it's own virtual address space.

Yes, assuming nothing grabs memory in the preferred region before then (not as much a problem with compile-time linked DLLs as run-time linked ones). EXEs don't have to worry about that because they're almost the first thing to get allocated in the new process (there are some things that get allocated before the EXE, but they're generally predictable, so a well-chosen preferred load address eliminates the possibility of needing to relocate the executable).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!