flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Tomasz Grysztar 18 Oct 2017, 15:26
You'd need to calculate the RVA of the top of initialized part of the section, and then how many bytes are left to the nearest 512 byte boundary.
What would help here is if I backported fasmg's "$@" feature into fasm 1. Currently fasm 1 has nothing similar, so you have to manually place the calculation at the boundary between initialized and uninitialized data. |
|||
![]() |
|
DimonSoft 18 Oct 2017, 15:43
Tomasz Grysztar wrote: You'd need to calculate the RVA of the top of initialized part of the section, and then how many bytes are left to the nearest 512 byte boundary. Thanks, it almost works, there’s just a small difficulty. Since I’m doing size coding, I decided to store a pointer to all the data my program needs in a non-volatile register. To make access to the data more readable I put all the fields into a struct and then put a single instance of it, like this: Code: data import library kernel32, 'kernel32.dll',\ ... struct TProgramData szEdit db "EDIT", 0 ; More initialized data here pBuffer dd ? ; More uninitialized data here ends ProgramData TProgramData end data The following formula works almost well: Code: 512 - ((rva ProgramData.pBuffer) mod 512) … until the value becomes 3. When it does, it nevers gets to zero, but becomes 511, 510, etc. after file size increases. Seems to be caused by some kind of alignment. It’s not critical, but would be quite nice to solve the problem. Is it possible? |
|||
![]() |
|
Tomasz Grysztar 18 Oct 2017, 16:18
This certainly does sound like some kind of alignment causing the jump in size. The "import" macro does contain one that looks like this:
Code: rb (- rva $) and 3 |
|||
![]() |
|
DimonSoft 18 Oct 2017, 17:41
Tomasz Grysztar wrote: This certainly does sound like some kind of alignment causing the jump in size. The "import" macro does contain one that looks like this: Nope, commenting it and/or a few other lines that reserve some bytes depenging on current offset $ just makes the actual values shift this or that way, but doesn’t make them change smoothly near the 512 byte boundary. I guess, it’s not a big deal anyway: at least it shows the right values in most cases and the values are not expected to be used for anything except being a reference value. So, thanks for your help. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.