|
-
Jul 7th, 2001, 05:02 PM
#1
Thread Starter
Lively Member
DLL Exports
I am making a Win32 DLL. I want my DLL to export the same symbols as another DLL made by someone else. In their DLL their exports look like so:
___TSAFDIsSet@8
_t_accept@12
_t_bind@12
_t_closesocket@4
_t_connect@12
_t_gethostbyaddr@12
_t_gethostbyname@4
Now when i add a .def file to my project, i add the exports just as how they have them, but the compiler says that the ordinal can not sit next to the export name so i have to do this:
___TSAFDIsSet @8
_t_accept @12
_t_bind @12
_t_closesocket @4
_t_connect @12
_t_gethostbyaddr @12
_t_gethostbyname @4
But, then when i compile it, it throws a fit that i used the same ordinal number twice. Plus if i use the spaces between the export name and ordinal number, the "@num" doesnt show up in its export table. The calls have to match perfectly though!
So my question is, how the heck did the person who made this DLL get the exports in this format, and how did this person use the same ordinal number in multiple exports?
i am using Microsoft Visual C++ 6.0
thanks
-
Jul 7th, 2001, 06:34 PM
#2
Guru
Let's say the function's name in the code is MyFakeConnectFunction, and you want the export symbol to be _t_connect@12...
In that case, try this for your .DEF file:
Code:
EXPORTS
_t_connect@12=MyFakeConnectFunction
Note: I'm not sure about the syntax, it might require "quotation marks" in some places such as:
Code:
EXPORTS
"_t_connect@12"="MyFakeConnectFunction"
But then again, it might not. Test and find out 
And regarding your other question: In this case the @ does not specify an ordinal number. It is part of what Microsoft likes to call "function name decoration".
-
Jul 7th, 2001, 09:38 PM
#3
Thread Starter
Lively Member
thanks for the reply.. it *does* change the name.. if i do this:
_t_connect@12=MyFakeConnectFunction
BUT, the export after its compiled is this:
_t_connect
it drops everything after the '@' char. like this:
_t_connect@doiexist=MyFakeConnectFunction
will show like this:
_t_connect
in a export viewer.. i even tried loadlibrary and getprocaddress to make sure, and i can only access the function by calling "_t_connect" even with the export defined as "_t_connect@12" or "_t_connect@doiexist"
any other ideas? man this is odd
oh yeah, and i did try using quotes in every possible way
Last edited by ExciteMouse; Jul 7th, 2001 at 09:43 PM.
-
Jul 9th, 2001, 05:14 AM
#4
Monday Morning Lunatic
Welcome to the wonderful world of name mangling 
_name@size is the standard calling convention name style. "name" is the function name, and "size" is the parameter size in bytes:
Code:
int func(int x, short y);
_func@6 (I think ). If you don't use a .DEF file they're exported like this, otherwise the linker rewrites the external names for you.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|