Question About PE Relocation #17
-
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Hi @S3xyG4y !
I hope it answers your questions! |
Beta Was this translation helpful? Give feedback.
-
Hello, I am very grateful for your quick reply About your answer (i am talking about my question number 2)that PE Optional Header's "Image Base" option can simultaneously points both of them (of course in specific situation basically it points only "Original Image Base") My Guess is when a PE file loaded on memory by PE loader and that Memory location matches with preferred Image base Do you think I'm right? |
Beta Was this translation helpful? Give feedback.
-
@S3xyG4y - so, the thing is, Image Base in the Optional Header is the base to which currently PE is relocated (when it is in the raw format, on the disk): meaning, every relative address in the PE is added to this default base. This base is never 0, because 0 is not a valid base at which a PE can ever be loaded. It is some valid base, which may or may not be used as an effective base on the load. On modern Windows, with ASLR enabled, it is proffered to use a randomized Image Base, instead of the hardcoded one (from the header). So, the base from the header won't really be used as preferred. It will be used only in cases when for some reason (that I described in the point 3) using a dynamic base was not possible/disabled. Please have a look at below examples.
As you can see, in the second case the PE got loaded at the base that was set in the Optional Header, that is |
Beta Was this translation helpful? Give feedback.
@S3xyG4y - so, the thing is, Image Base in the Optional Header is the base to which currently PE is relocated (when it is in the raw format, on the disk): meaning, every relative address in the PE is added to this default base. This base is never 0, because 0 is not a valid base at which a PE can ever be loaded. It is some valid base, which may or may not be used as an effective base on the load.
PE does not need to be relocated if it happens to be load at the same base that is set in the Optional Header.
On modern Windows, with ASLR enabled, it is proffered to use a randomized Image Base, instead of the hardcoded one (from the header). So, the base from the header won't really be used as…