Exporting Dynamic Functions using the .def file

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
Post Reply
DarkBrute





Posts: 157
Joined: Wed Aug 11, 2004 12:08 pm
Location: Installation 07 Library Trying to reason with a flood about not eating me.

Exporting Dynamic Functions using the .def file

Post by DarkBrute »

Some of you know that the .def file is used to export function from dlls to because you don't know the memory adress of a funtion in a dll.

Now, is there a way to export funtions from dlls if you don't know the funtion name? Say you have a dll. You don't have the source, and you have no idea what the name is of the funtion you want to export. Is there a way to export the funtion, view it, without knowing the name of it in the DLL?

Just asking...
kyboren





Posts: 58
Joined: Thu Feb 12, 2004 8:49 pm

Post by kyboren »

You can always get the address of a function with the Windows API function call GetProcAddress().

Are you trying to import or export? Your statements seem contradictory:
you have a DLL (but not the source), but you want to export a function you don't know?

Could you please elaborate?
DarkBrute





Posts: 157
Joined: Wed Aug 11, 2004 12:08 pm
Location: Installation 07 Library Trying to reason with a flood about not eating me.

Post by DarkBrute »

I wish to export a funtion that I have no idea what its ID is. It is in the DLL but I have no idea what its name is and such.
kyboren





Posts: 58
Joined: Thu Feb 12, 2004 8:49 pm

Post by kyboren »

Erm, then you just want to look for the function that's exported in a DLL? You can download a free trial of IDA Pro and disassemble the DLL and get the exports section (or you could just open it up in a hex editor and go to the exports section yourself and look around).
kaptainkommie




Wordewatician 500

Posts: 732
Joined: Wed Nov 26, 2003 11:59 pm
Location: Raleigh, NC, USA

Post by kaptainkommie »

http://msdn.microsoft.com/library/defau ... y_name.asp

You can export the functions by Ordinal. Click the above link to learn more.
kyboren





Posts: 58
Joined: Thu Feb 12, 2004 8:49 pm

Post by kyboren »

I think he really means import.

You'll still have to know the name of the function you want to import with a .def file. They will be listed in there, though.

You can also load without a .def file by ordinal (going with kaptainkommie's idea here) with good ol' GetProcAddress(). Just specify the ordinal you want to import in the low-order word of the parameter you'd usually use for the name of the function.
Post Reply