flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Get variable's raw offset

Author
Thread Post new topic Reply to topic
booze



Joined: 24 Jul 2013
Posts: 2
booze 24 Jul 2013, 18:35
Hello,

is it possible in FASM get raw offset of a variable? I mean offset from the beginning of the physical file.

For example, I have a variable:
Code:
section '.data' data readable writeable
    var dd 0x00000001
    


If i write
Code:
section '.data' data readable writeable
    var dd 0x00000001
    var_offset dd var
    

var_offset will contain the VA of the var.

Also I can write
Code:
section '.data' data readable writeable
    var dd 0x00000001
    var_offset dd var - $$
    

Here var_offset will contain raw offset from the beginning of '.data' section. To get 'var' raw offset, I need to get '.data' PointerToRawData. How can I get it?

Thank you in advance, and excuse me my English.
Post 24 Jul 2013, 18:35
View user's profile Send private message Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 24 Jul 2013, 19:29
booze
Unfortunately, not possible. You can neither find the raw size of the header nor raw sizes of sections (because of possible uninitialized data at the end of sections).

I never needed this, but it still could be a nice feature to have. Like raw operator analogous to the rva operator.

_________________
Faith is a superposition of knowledge and fallacy
Post 24 Jul 2013, 19:29
View user's profile Send private message Reply with quote
booze



Joined: 24 Jul 2013
Posts: 2
booze 25 Jul 2013, 07:13
l_inc
Thank you. Probably there is only one solution - patch the binary after assembling.
Post 25 Jul 2013, 07:13
View user's profile Send private message Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 555
fasmnewbie 30 Jul 2013, 20:45
I don't know what you meant by 'raw' offset but If you meant the starting address of the '.data' section then this is the way I always use.

section '.data' data readable writable
@myoffset:
;data declarations

mov eax, @myoffset
Post 30 Jul 2013, 20:45
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.