[BangPypers] How to get class names from DLL file

Anand Balachandran Pillai abpillai at gmail.com
Tue Feb 1 08:14:24 CET 2011


On Tue, Feb 1, 2011 at 10:51 AM, Noufal Ibrahim <noufal at gmail.com> wrote:

> On Tue, Feb 01 2011, Sibtey Mehdi wrote:
>
> > Hi,
> >
> > I am trying to get the class names from the DLL files in unix plateform.
> Any
> > can please help me out to solve this problem.
>
> The format of Microsoft DLL files is detailed over here
>
> http://download.microsoft.com/download/9/c/5/9c5b2167-8017-4bae-9fde-d599bac8184a/pecoff_v8.docx
>
> I think it should be possible to parse the file and find out the entry
> points. I've never done it but it's the first thing that occurs to me.
>
> Apparently, they also release a tool called Dependency Walker
> http://en.wikipedia.org/wiki/Dependency_Walker which allows you to list
> functions exported by an executable which might work for you as well.
>

 I think he said "unix" :)

 "DLL files" on Unix are called shared libraries ending with a ".so"
extension.
 If the library is not stripped you can view the symbols exported by it,
including
 class names.

 E.g:

 $ nm /usr/lib64/python2.4/lib-dynload/regex.so

  However on production unix or any *nixes, the libraries are typically
stripped
 of such additional data. In that case you can use "readelf" command (works
 only if your system supports ELF executables).

$ readelf -s zlibmodule.so

Symbol table '.dynsym' contains 45 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000ff8     0 SECTION LOCAL  DEFAULT    8
     2: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND
PyModule_AddObject
     3: 0000000000000000    78 FUNC    GLOBAL DEFAULT  UND inflateEnd
     4: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND PyExc_ValueError
...

"objdump -T" also works similarly.

$ objdump -T zlibmodule.so

zlibmodule.so:     file format elf64-x86-64

DYNAMIC SYMBOL TABLE:
0000000000000ff8 l    d  .init  0000000000000000              .init
0000000000000000      D  *UND*  0000000000000000
PyModule_AddObject
0000000000000000      DF *UND*  000000000000004e              inflateEnd
0000000000000000      D  *UND*  0000000000000000
PyExc_ValueError
0000000000000000      D  *UND*  0000000000000000
PyModule_AddStringConstant
0000000000000000  w   D  *UND*  0000000000000000              __gmon_start__
0000000000000000  w   D  *UND*  0000000000000000
_Jv_RegisterClasses
0000000000000000      DF *UND*  0000000000000a24              deflate

Play with these and figure out which one does the trick for you.

--Anand




> [...]
>
>
> --
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 
--Anand


More information about the BangPypers mailing list