Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Within a DLL, how is the function table structured?

I've been looking into the implementation of a device library that doesn't explicitly support my operating system. In particular, I have a disassembled DLL, and a fair amount of supporting source code. Now, how is the function table/export table structured?

My understanding is that the first structure of the .data section is a table of RVAs. Next is a table of strings linked by index to that first address table. This makes sense to me, as a linker could translate between symbols and addresses.

How do functions referenced by ordinals fit into this picture? How does one know which function has such and such ordinal number, and how does the linker resolve this? In other words, given that some other DLL imports SOME_LIBRARY_ordinal_7, how does the linker know which function to work with?

Thanks, all!

edit More information...

Im working with the FTDI libraries, and would like to resolve which function is being invoked. In particular, I see something like:

extern FTD2XX_Ordinal_28: near

how might I go about determining which function is being referenced, and how does the linker do this?

like image 487
Willi Ballenthin Avatar asked Feb 21 '10 22:02

Willi Ballenthin


1 Answers

To learn how the linkers and the loader works on Windows, probably the most accessible information comes from a set of columns Matt Pietrek did more than a decade ago:

  • July 1997: http://www.microsoft.com/msj/0797/hood0797.aspx
  • April 1998: http://www.microsoft.com/msj/0498/hood0498.aspx
  • September 1999: http://www.microsoft.com/msj/0999/hood/hood0999.aspx

And the biggest and best one:

  • Peering Inside the PE: A tour of the Win32 Portable Executable File Format (from 1994!)
like image 197
Michael Burr Avatar answered Oct 17 '22 06:10

Michael Burr