pydumper.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # pydumper.py
  2. #
  3. # This is being worked on - it does not yet work at all, in ay way
  4. # shape or form :-)
  5. #
  6. # A new script engine, derived from the standard scripting engine,
  7. # which dumps information.
  8. # This generally can be used to grab all sorts of useful details about
  9. # an engine - expose bugs in it or Python, dump the object model, etc.
  10. # As it is derived from the standard engine, it fully supports Python
  11. # as a scripting language - meaning the dumps produced can be quite dynamic,
  12. # and based on the script code you execute.
  13. from . import pyscript
  14. from win32com.axscript import axscript
  15. from .pyscript import RaiseAssert, trace, Exception, SCRIPTTEXT_FORCEEXECUTION
  16. PyDump_CLSID = '{ac527e60-c693-11d0-9c25-00aa00125a98}'
  17. class AXScriptAttribute(pyscript.AXScriptAttribute):
  18. pass
  19. class NamedScriptAttribute(pyscript.NamedScriptAttribute):
  20. pass
  21. class PyScript(pyscript.PyScript):
  22. pass
  23. def Register():
  24. import sys
  25. if '-d' in sys.argv:
  26. dispatcher = "DispatcherWin32trace"
  27. debug_desc = " ("+dispatcher+")"
  28. debug_option = "Yes"
  29. else:
  30. dispatcher = None
  31. debug_desc = ""
  32. debug_option = ""
  33. categories = [axscript.CATID_ActiveScript,axscript.CATID_ActiveScriptParse]
  34. clsid = PyDump_CLSID
  35. lcid = 0x0409 # // english
  36. policy = None # "win32com.axscript.client.axspolicy.AXScriptPolicy"
  37. print("Registering COM server%s..." % debug_desc)
  38. from win32com.server.register import RegisterServer
  39. languageName = "PyDump"
  40. verProgId = "Python.Dumper.1"
  41. RegisterServer(clsid = clsid, pythonInstString = "win32com.axscript.client.pyscript.PyDumper",
  42. className = "Python Debugging/Dumping ActiveX Scripting Engine",
  43. progID = languageName, verProgID = verProgId,
  44. catids = categories,
  45. policy=policy, dispatcher = dispatcher)
  46. CreateRegKey(languageName + "\\OLEScript")
  47. # Basic Registration for wsh.
  48. win32com.server.register._set_string(".pysDump", "pysDumpFile")
  49. win32com.server.register._set_string("pysDumpFile\\ScriptEngine", languageName)
  50. print("Dumping Server registered.")
  51. if __name__=='__main__':
  52. Register()