Base memory address

Hi,

Below lines is from the Book "Programming application for Microsoft".
I don't understand the base address of a process. I have a doubt about the the base address, how it can be fixed to(0x00400000).
I think I am not getting the explanation correctly. I would request to please let me clear my doubt about this.

Thanks

The actual value of (w)WinMain's hinstExe parameter is the base memory address where the system loaded the executable file's image into the process's address space. For example, if the system opens the executable file and loads its contents at address 0x00400000, (w)WinMain's hinstExe parameter has a value of 0x00400000.

The base address where an executable file's image loads is determined by the linker. Different linkers can use different default base addresses. The Visual C++ linker uses a default base address of 0x00400000 because this is the lowest address an executable file image can load to when you run Windows 98. You can change the base address that your application loads to by using the /BASE: address linker switch for Microsoft's linker.

If you attempt to load an executable that has a base address below 0x00400000 on Windows 98, the Windows 98 loader must relocate the executable to a different address. This increases the loading time of the application, but at least the application can run. If you are developing an application that will run on both Windows 98 and Windows 2000, you should make sure that the application's base address is at 0x00400000 or above.

The GetModuleHandle function, shown below, returns the handle/base address where an executable or DLL file is loaded in the process's address space:


HMODULE GetModuleHandle(PCTSTR pszModule);



This is a good example of something it might be best to just accept and move on. Realize that all addresses you receive from Windows are virtual - there is no way of determining how they actually map to physical addresses. As far as I know, only Windows knows that.
I guess that you first need to understand the concept of the virtual address space before you can understand this part. Google that up. Then come back to this topic. You'll say "Ahhh, I see".

Now, I myself has wondered a bit about: Why is this in the hands of the developer? What is the importance or even benefit of being able to specify the base address of an executable or DLL? Since I haven't really needed it, I haven't sought the answer, but yes, I do wonder about it.
Topic archived. No new replies allowed.