flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Ecoste 23 Aug 2016, 23:39
Is it possible to specify the Virtual Offset of a particular section in the generated PE file?
|
|||
![]() |
|
Ecoste 24 Aug 2016, 00:15
revolution wrote: Do you mean the relative virtual address (RVA)? If so then yes, you use the RVA operator: I meant the second thing, I was already doing what you suggested but maybe thought there's a directive or something. I'm very new to fasm. Thank you for the swift response. |
|||
![]() |
|
revolution 24 Aug 2016, 00:21
The documentation PDF shows no "at" or similar setting:
Quote: section directive defines a new section, it should be followed by quoted string defining the name of section, then one or more section flags can follow. Available flags are: code, data, readable, writeable, executable, shareable, discardable, notpageable. The origin of section is aligned to page (4096 bytes). Example declaration of PE section: |
|||
![]() |
|
Grom PE 24 Aug 2016, 11:34
If for some odd reason you want to have a PE section to be loaded at a specified virtual address, you can put your section first and set image base to desired address minus 0x1000.
Or if you don't want to make it the first section, calculate its address according to sizes of the previous sections, rounded up to multiple of 0x1000. Edit: had confused physical size and wrote 0x200 instead of 0x1000 Last edited by Grom PE on 24 Aug 2016, 23:19; edited 1 time in total |
|||
![]() |
|
Ecoste 24 Aug 2016, 15:51
Grom PE wrote: If for some odd reason you want to have a PE section to be loaded at a specified virtual address, you can put your section first and set image base to desired address minus 0x1000. I initially set the image base to desired address minus 0x1000, but the program wouldn't run for some reason. I believe the reason is that the image base must be on a multiple of 64K, so I need to load it up and then have a padding section. I don't have a source for the 64K multiple requirement, except for "The linker issues an error if address is not a multiple of 64K." from https://msdn.microsoft.com/en-us/library/f7f5138s.aspx I think it's a global requirement from Windows for PE files, and not just VS' linker. Can anyone confirm? |
|||
![]() |
|
Grom PE 24 Aug 2016, 23:17
Ah, true, Windows 7 64-bit refuses to run an exe if its image base is not multiple of 0x10000.
You can pad the section with "rb" so the padding won't be stored in the file. |
|||
![]() |
|
revolution 26 Aug 2016, 07:57
Grom PE wrote: You can pad the section with "rb" so the padding won't be stored in the file. You can also use the question mark: Code: rb 100 ;pad 100 uninitialised bytes db 100 dup (?) ;also pad 100 uninitialised bytes |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.