flat assembler
Message board for the users of flat assembler.

Index > Windows > How I can get PointerToRawData?

Author
Thread Post new topic Reply to topic
IceStudent



Joined: 19 Dec 2003
Posts: 60
Location: Ukraine
IceStudent 10 Oct 2006, 07:41
Hi!

I creating image_debug_directory, it needs file pointer to raw data. How I can get it?
Post 10 Oct 2006, 07:41
View user's profile Send private message Reply with quote
IceStudent



Joined: 19 Dec 2003
Posts: 60
Location: Ukraine
IceStudent 10 Oct 2006, 07:58
It seems to impossible. File offsets knows only formatter, so at the assembly-level I can't get it.
Post 10 Oct 2006, 07:58
View user's profile Send private message Reply with quote
IceStudent



Joined: 19 Dec 2003
Posts: 60
Location: Ukraine
IceStudent 10 Oct 2006, 09:23
But it's possible:
Code:
section_align   = 0x1000
file_align      = 0x200
adjust          = section_align-file_align

display 'start', <rva __start - adjust %%H    


Last edited by IceStudent on 10 Oct 2006, 15:57; edited 1 time in total
Post 10 Oct 2006, 09:23
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7103
Location: Slovakia
vid 10 Oct 2006, 09:48
it is more complicated.

you for example need to know number of sections preceding that computations. For that you can overload "section" directive with macro
Post 10 Oct 2006, 09:48
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
IceStudent



Joined: 19 Dec 2003
Posts: 60
Location: Ukraine
IceStudent 10 Oct 2006, 12:16
Thanks, I was tested it only in one section.
Post 10 Oct 2006, 12:16
View user's profile Send private message Reply with quote
IceStudent



Joined: 19 Dec 2003
Posts: 60
Location: Ukraine
IceStudent 10 Oct 2006, 15:56
Now, I wrote this macroses. Big thanks to vid for solution.
Code:
macro section attrs
 {
        local secnum,rawsize,secsize,filesize,heresec
        section_align   = 0x1000
        file_align      = 0x200

        if defined heresec | ~ defined _secnum
                heresec:
                secnum = 1
                filesize = $-$$
                if filesize > 0
                        ; previosly defined data, default section was created
                        secnum = 2
                        filesize = (filesize + file_align) and not (file_align-1)
                end if
                filesize = file_align + filesize
        else
                secnum  = _secnum
                rawsize = $ - _secbase
                secsize = (rawsize + section_align) and not (section_align-1)
                filesize= (rawsize + file_align) and not (file_align-1)
                filesize=_filesize + filesize
        end if
        section attrs
        _secnum = secnum + 1
        _secbase = $$
        _filesize = filesize
 }

macro get_fo addr
 {
        local off
        section_align   = 0x1000
        file_align      = 0x200

        if ~ addr eq
                off = addr
        else
                off = $
        end if
        if ~defined _secnum
                ; simple formula for default single section
                _fileoffset = off - $$ + file_align
        else
                ; calculated from sections statistics
                if $$ <> _secbase
                        display 'current base is different from the section base' __err
                end if
                _fileoffset = off - $$ + _filesize
        end if
 }
    
Post 10 Oct 2006, 15:56
View user's profile Send private message 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.