|
List Info
Thread: Recovering a DLL with ctypes from a VB project
|
|
| Recovering a DLL with ctypes from a VB
project |
  Spain |
2007-04-10 07:23:43 |
|
Hello.
I have an old VB project using a dynamic library. I thought it would be
good to use this from Python through ctypes. However, the information
of function names in the dll is stripped. If I open the dll with the
dependency viewer I get something like:
4 (0x0004) Function N/A Entry point 0x0006C3A8
6 (0x0006) Function N/A Entry point 0x00001000
...
up to entry 1081.
However, the VB project using this DLL contains a "Public declare" file
which only uses 22 functions, and they are in the form:
Public Declare Function DllGetVersion _
Lib "LIBDLL" _
Alias "#2" _
() _
As String
where the only thing changing is the name of the function, the alias
number and the type of parameters (this function doesn't require any).
The aliases start with "#1" and go up to "#21".
Now, how do I relate this into Python? I can access the DLL:
dll = ctypes.windll.LIBDLL
prototype = ctypes.WINFUNCTYPE(ctypes.wintypes.LPCSTR)
GetDllVersion = prototype(dll[6])
print "GetDllVersion: '%s'" % repr(GetDllVersion())
So I thought the alias #2 thingy specifies the order inside the DLL,
which would be function 6, since that is the second one. But the result
I'm getting is
GetDllVersion: '' x07x10D''
The respective VB code would be:
MsgBox ("Version " & DllGetVersion)
Which outputs:
Version 1.3.0 (Build 403)
Far different from what I'm getting in python. So how can I use the VB
declaration file to access the DLL the same way? Unfortunately the DLL
doesn't expose the names, so I can only access functions with the
attribute getter using an index.
I tried to search for the function using a loop over all the functions,
but that seems to hang up on nearly every second function. Besides, I
might be doing something wrong with the return value.
Any suggestions?
--
rastertech.es" border="0">
|
Grzegorz Adam Hankiewicz
Jefe de Producto TeraVial
C/ Perfumería 21. Nave I. Polígono
industrial La Mina
28770 Colmenar Viejo. Madrid (España)
|
|
 |
| View Original Image |
[1]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|