Loading an image at a virtual address 0X00000

This is a discussion on Loading an image at a virtual address 0X00000 within the Windows Programming forums, part of the Platform Specific Boards category; Why does the loader load any exe at a virtual address which is basically 0X10000 or, in most cases 0X400000?? ...

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    384

    Loading an image at a virtual address 0X00000

    Why does the loader load any exe at a virtual address which is basically 0X10000 or, in most cases 0X400000?? Isn't it supposed to load it at address 0X00000, afterall the address is virtual and each process has its own address space?? Wouldn't this be more convenient??

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,537
    How would you detect NULL pointer dereferences, if 0x00000000 were a mapped address?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Aug 2011
    Posts
    384
    Ok fine. But why particulaly 0X400000, what's wrong with all the addresses less than 0X400000. If 0X00000 is to be reserved for NULL references then why not start from say 0X00001..

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,537
    If you have
    Code:
    struct foo {
      int bar;
      int baz;
    };
    struct foo *p = NULL;
    Now p->bar is NULL, but p->baz would be 0x00004

    You can't get too close to address 0, otherwise large offsets from NULL would suddenly map to valid memory locations.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Aug 2011
    Posts
    384
    Can you address these other two questions..

    Need for relocations in an exe
    section header location in an exe

  6. #6
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    Other things are mapped into the address space besides the code in the executable. DLLs are mapped into the virtual address space too. Actually, they can be mapped into the VA space of multiple processes at once. Presumably, given the numbers you mention, statically linked DLLs are mapped into the low addresses.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Loading image from Resource
    By parad0x13 in forum C++ Programming
    Replies: 1
    Last Post: 03-15-2009, 10:36 PM
  2. Loading & displaying an image
    By csonx_p in forum Windows Programming
    Replies: 1
    Last Post: 06-19-2008, 06:40 AM
  3. Loading Image from file path
    By csonx_p in forum Windows Programming
    Replies: 16
    Last Post: 04-25-2008, 07:38 AM
  4. Image class - loading image file
    By GaPe in forum Windows Programming
    Replies: 2
    Last Post: 07-11-2004, 01:35 PM
  5. Image Loading Troubles
    By frenchfry164 in forum C++ Programming
    Replies: 3
    Last Post: 11-02-2003, 12:07 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21