mardi 30 août 2016

Capture all runtime calls a wrapper library makes to an inner library in Python

I'm using a closed-source Python library that is mostly wrappers around objects from an open-source Python library. I want to capture the calls the closed-source wrapper is making into the open-source library as my program runs.

(I'm using Python 2.7 on Windows.)

The vendor distributes the conglomeration as *.pyd files, so there is no source code to read or modify. However the inner library objects are reachable at runtime by exposed wrapper object implementation details and Python reflection.

My basic idea is to monkey patch the module as it loads, and capture all method calls. However I'm not familiar enough with Python to know what details I should consider and what other techniques may be available to me.

  • Is there a Python library that does exactly this?
  • What about patching the Python interpreter (would that even have any effect on a pyd file?)
  • Does there exist something that runs a Python program and spits out a smaller/less depencies version of the program with just the code and data used during the run? (Something like Code Data and Environment for Python.)
  • Would a profiling tool or library help with this?
  • What about dumping the (runtime, Python) disassembly of the methods?




Aucun commentaire:

Enregistrer un commentaire