flat assembler
Message board for the users of flat assembler.

Index > Windows > import macro improvement?

Author
Thread Post new topic Reply to topic
Phrodu



Joined: 19 Jun 2004
Posts: 1
Phrodu 19 Jun 2004, 21:21
I found a way to get rid of 2, seemingly unnecessary, extra bytes at the front of each imported function. In the import macro, inside macro\import.inc, I changed:
Code:
label dd RVA _label

to

label dd RVA _label-2
    


and

Code:
_label dw 0
       db string,0

to

_label db string,0
    


to get:
Code:
macro import name,[label,string]
 { common
    name:
   forward
    if used label
     if string eqtype ''
      local _label
      label dd RVA _label-2
     else
      label dd 80000000h + string
     end if
    end if
   common
    if $ > name
     name#.redundant = 0
     dd 0
    else
     name#.redundant = 1
    end if
   forward
    if used label & string eqtype ''
    _label db string,0
    end if }
    



I'm not very experienced with macros or the structure of PE's, but this seems to work alright. Why were those 2 bytes there? Are there any reasons to not use this new way?
Post 19 Jun 2004, 21:21
View user's profile Send private message Reply with quote
Tommy



Joined: 17 Jun 2003
Posts: 489
Location: Norway
Tommy 19 Jun 2004, 21:48
Aren't they there for unicode support or something? Confused
Post 19 Jun 2004, 21:48
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 19 Jun 2004, 21:50
That 16-bit value should contain a "hint" what ordinal number the function has, so the PE loader can find it faster. If the hint is wrong, the value is ignored, and loader just scans the sorted export table of DLL to find the function.
Post 19 Jun 2004, 21:50
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.