flat assembler
Message board for the users of flat assembler.

Index > Main > Import and Export with equal names

Author
Thread Post new topic Reply to topic
twgt



Joined: 23 Jan 2007
Posts: 8
twgt 30 Dec 2007, 10:56
May be it's bug.

This code is compileable(can be compiled)
But I don't define function MyTestFunc and exported func pointing to importing func in result file.

Code:
;test.asm
format PE GUI 4.0 DLL
entry DllMain
include '%fasminc%\win32ax.inc'

section '.code' code readable executable
proc DllMain Instance,Reason,Reserved
     xor eax,eax
     inc eax
     ret
endp

section '.idata' import data readable
     library test,'test.dll'
     import test,\
         MyTestFunc,'MyTestFunc'

section '.edata' export data readable

     export 'test.dll',\
        MyTestFunc,'MyTestFunc'    
Post 30 Dec 2007, 10:56
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20303
Location: In your JS exploiting you and your system
revolution 30 Dec 2007, 11:06
The macros are not designed to know whether the function is in your code or in your imports section. The easy way to solve it is not to duplicate such entries, it makes no sense anyway to do that.
Post 30 Dec 2007, 11:06
View user's profile Send private message Visit poster's website Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 30 Dec 2007, 14:08
It's an easy way to steal credit for something if the other person isn't very quick on the draw.
Post 30 Dec 2007, 14:08
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20303
Location: In your JS exploiting you and your system
revolution 30 Dec 2007, 14:22
kohlrak wrote:
It's an easy way to steal credit for something if the other person isn't very quick on the draw.
What do you mean Dr. Pepper?
Post 30 Dec 2007, 14:22
View user's profile Send private message Visit poster's website Reply with quote
twgt



Joined: 23 Jan 2007
Posts: 8
twgt 30 Dec 2007, 23:20
Quote:

The easy way to solve it is not to duplicate such entries, it makes no sense anyway to do that.

Yes. I casually reamarked that.

Quote:

It's an easy way to steal credit for something if the other person isn't very quick on the draw.

kohlrak, I also can't understand this phrase.
Post 30 Dec 2007, 23:20
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 31 Dec 2007, 00:14
Hm, interesting - you're creating a DLL that imports it's own export? How does the PE loader handle that?

As for Kohlrak's remark, ignore it - he probably doesn't even known about forwarded exports Smile
Post 31 Dec 2007, 00:14
View user's profile Send private message Visit poster's website Reply with quote
FrozenKnight



Joined: 24 Jun 2005
Posts: 128
FrozenKnight 31 Dec 2007, 17:16
Can't this method be used for things like intercepting calls and making dll's that intercept api's?
Post 31 Dec 2007, 17:16
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 31 Dec 2007, 18:26
FrozenKnight wrote:
Can't this method be used for things like intercepting calls and making dll's that intercept api's?


Not for intercepting per se., but the ability to have forwarded exports makes it much easier to set up proxy DLLs. And it's very easy to do from VC++, there's some #pragmas for it.

_________________
Image - carpe noctem
Post 31 Dec 2007, 18:26
View user's profile Send private message Visit poster's website Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6115
Location: Poland
MHajduk 01 Jan 2008, 14:09
twgt

if I understand correctly, you are going to export all (or only some?) procedures used inside 'test.dll' (and then import them) in order to treat their calls in the same way as calls of procedures placed in the other libraries? I think it could be used to hide calls of internal procedures within general mass of other calls. Am I right?
Post 01 Jan 2008, 14:09
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 01 Jan 2008, 14:42
When you import MyTestFunc, you create MyTestFunc DWORD variable that will hold the imported address. When you export MyTestFunc, you export the address MyTestFunc itself - so in this case you export the address of DWORD variable, which will the be filled with imported address (the address of itself). Thus this code assembles correctly, it just doesn't make much sense. If you really wanted to import your own exported function, you'd have to it like:
Code:
;test.asm
format PE GUI 4.0 DLL
entry DllMain
include '%fasminc%\win32ax.inc'

section '.code' code readable executable
proc DllMain Instance,Reason,Reserved
     xor eax,eax
     inc eax
     ret
endp

proc MyTestFunc_implementation
     ret
endp

section '.idata' import data readable
     library test,'test.dll'
     import test,\
         MyTestFunc,'MyTestFunc'

section '.edata' export data readable

     export 'test.dll',\
        MyTestFunc_implementation,'MyTestFunc'    

You'd then be able to call your function in two ways, either:
Code:
invoke MyTestFunc    
or
Code:
stdcall MyTestFunc_implementation    
.
Post 01 Jan 2008, 14:42
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.