moyix / pdbparse

Python code to parse Microsoft PDB files
Other
309 stars 83 forks source link

Add support for undname extension on Windows #40

Closed lucasg closed 7 years ago

lucasg commented 7 years ago

Since it was bothering me I've completed to port the _undname C extension on Windows. Previously _undname was just a shared library loaded via ctypes, now it's a full fledged Python extension à la _hashlib, _socket or _sqlite3.

It works like any Python module :

(lin_env_3) lucasg@DESKTOP-822EGME:/mnt/f/Dev$ python
Python 3.4.3 (default, Nov 17 2016, 01:08:31)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pdbparse import undname
>>> print(undname._undname.__doc__)
_undname module. Provide undname() function for symbol undecoration
>>> dir(undname._undname)
['__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'undname']
>>> print(undname._undname.undname.__doc__)
undname(mangled: str or bytes,flags : int) -> str

Undecorate mangled C++ names. Take a mangled str name and flags.
Return the unmangled name or None if it can not be undecorated.
>>> undname.undname("?Request@MUTEX@@QEAAXXZ")
'MUTEX::Request'
>>> undname._undname.undname(b"?Request@MUTEX@@QEAAXXZ", 0x00)
'public: void __cdecl MUTEX::Request(void) __ptr64'
moyix commented 7 years ago

Very nice, thanks!