ctypes list library

L

luca72

There is a command for ctypes that help me to know the entry points
inside a library.

Thanks Luca
 
D

Diez B. Roggisch

luca72 said:
There is a command for ctypes that help me to know the entry points
inside a library.

dir() on a loaded library?

But it won't do you any good, without having the header-file you can't
possibly know what the functions take for parameters.

Diez
 
L

luca72

Thanks for your reply.
I have another question i can load a list of library?
Thanks

Luca
 
C

Carlo Salinari

Diez said:
dir() on a loaded library?

But it won't do you any good, without having the header-file you can't
possibly know what the functions take for parameters.

I was trying this right now, but I can't even get the exported function
names:
['_FuncPtr', '__class__', '__delattr__', '__dict__', '__doc__',
'__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__',
'__getitem__', '__gt__', '__hash__', '__init__', '__le__', '__lt__',
'__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__',
'__weakref__', '_func_flags_', '_func_restype_', '_handle', '_name']


shouldn't the C functions names be there?
 
D

Diez B. Roggisch

Carlo said:
I was trying this right now, but I can't even get the exported function
names:

To be honest, I wasn't 100% sure about this. That was the reason for
the "?", but I admit that I should have phrased it more explicitly.

But again, it is pretty useless anyway.

Diez
 
D

Diez B. Roggisch

luca72 said:
Can you tell me how load a list of library

from ctypes.util import find_library
from ctypes import CDLL

for name in list_of_libraries:
lib = CDLL(find_library(name))

Do you actually read the documentation of ctypes? Or python, for that
matter?

Diez
 
D

Dave Angel

Nick said:
I don't know..

However nm on the library works quite well on the command line

$ nm --defined-only -D /usr/lib/libdl.so
00000000 A GLIBC_2.0
00000000 A GLIBC_2.1
00000000 A GLIBC_2.3.3
00000000 A GLIBC_2.3.4
00000000 A GLIBC_PRIVATE
0000304c B _dlfcn_hook
000013b0 T dladdr
00001400 T dladdr1
00000ca0 T dlclose
00001170 T dlerror
00001490 T dlinfo
00001760 T dlmopen
00000ae0 T dlopen
000018d0 T dlopen
00000cf0 T dlsym
00000dd0 W dlvsym

nm from the mingw distribution works on Windows too IIRC.
For Windows, you can use the Microsoft tool DUMPBIN to display entry
points (and other stuff) for a DLL. Notice that a DLL may have almost
any extension, including EXE, SYS, DRV, ...
 
L

luca72

Hello but find_library find only the lib. but if i need to load from a
list of lib how i have to do.
My proble is that i have 5 lib (a,b,c,d,e), if i load the a i get lib
b not found, if for first i load the b and than the a i get the same
error how i have to proceed.

Thanks

Luca
 
G

Gabriel Genellina

Hello but find_library find only the lib. but if i need to load from a
list of lib how i have to do.
My proble is that i have 5 lib (a,b,c,d,e), if i load the a i get lib
b not found, if for first i load the b and than the a i get the same
error how i have to proceed.

Try adding the parameter mode=ctypes.RTLD_GLOBAL when loading the library.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top