flat assembler
Message board for the users of flat assembler.

Index > Windows > PE DLL fixups of initialized data

Author
Thread Post new topic Reply to topic
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
When programming a DLL, why does FASM disallow putting direct offsets in data section (gives "invalid use of symbol" error). Only way of putting them is using RVA directive. Initialized data is much like code. Is it not possible to generate fixups for initialize data section as well?

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 27 Mar 2004, 04:45
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
It is possible and working (for example with DD directive). Can you show what kind of code is not working for you?
Post 27 Mar 2004, 12:18
View user's profile Send private message Visit poster's website Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
Code:
macro dbdd bytes,long {
    db bytes
    dd long
}

section ".code" code readable executable
...

blit32:
   mov     eax,[fwidth]
        shl     eax,2
       mov     edx,[fheight]
       sub     [lockrc.Pitch],eax
.line:  mov   ecx,[fwidth]
        rep     movsd
       add     edi,[lockrc.Pitch]
  dec     edx
 ja      .line
       retn

blit16:
     mov     eax,[fwidth]
        add     eax,eax
     mov     edx,[fheight]
       sub     [lockrc.Pitch],eax
.line:  mov   ecx,[fwidth]
.pixel: mov eax,[esi]       ; red
       mov     ebx,[esi]       ; green
     mov     ebp,[esi]       ; blue
      shr     eax,08h
     shr     ebx,05h
     shr     ebp,03h
     and     eax,0000F800h
       and     ebx,000007E0h
       and     ebp,0000001Fh
       add     ebx,ebp
     add     eax,ebx
     stosw
       add     esi,04h
     loop    .pixel
      add     edi,[lockrc.Pitch]
  dec     edx
 ja      .line
       retn

section ".data" data readable writeable
    data import
    library kernel32,"kernel32.dll",user32,"user32.dll"
     include "%include%/apia/kernel32.inc"
     include "%include%/apia/user32.inc"
    end data
    data fixups
    end data

...
blitprocs:   dbdd    D3DFMT_A8R8G8B8,blit32
              dbdd    D3DFMT_X8R8G8B8,blit32
              dbdd    D3DFMT_A1R5G5B5,blit16
              dbdd    D3DFMT_X1R5G5B5,blit16
              dbdd    D3DFMT_R5G6B5,blit16
                db       0    


The latter declarations do not work, I am forced to use RVA operator:
Code:
blitprocs:        dbdd    D3DFMT_A8R8G8B8,RVA blit32
          dbdd    D3DFMT_X8R8G8B8,RVA blit32
          dbdd    D3DFMT_A1R5G5B5,RVA blit16
          dbdd    D3DFMT_X1R5G5B5,RVA blit16
          dbdd    D3DFMT_R5G6B5,RVA blit16
            db      0    

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 27 Mar 2004, 18:58
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
moving "data fixups" after data declarations fixed the problem

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 27 Mar 2004, 19:00
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
Yes, you cannot generate any relocatable code after the fixups table has been made (because it's too late to expand it).
Post 27 Mar 2004, 19:38
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.