a oe@s.ddlZddlZddlZddlZddlZddlmZmZmZm Z m Z m Z m Z ddl mZmZmZddlmZdaGdddZddZd d ZGd d d e jZGd ddZGdddZGdddZddZddZeZeZddZddZ ddZ!e"dkr*e#de!e#de$e%fdS) N)adbaxdebug codecontainercontexts documents expressionsgateways)_wrap _wrap_removetrace)axscriptc@s0eZdZdZddZddZddZdd Zd S) ModuleTreeNodez'Helper class for building a module treecCs(|j}||_||_d|_t||_dSN)__name__Z moduleNamemodulerealNoderZSourceModuleContainercont)selfrZmodNamer=C:\Program Files\Certbot\pkgs\win32comext\axdebug\debugger.py__init__s zModuleTreeNode.__init__cCs d|jS)Nz)rrrrr__repr__ szModuleTreeNode.__repr__cCs|j|dSr)rAttach)rZparentRealNoderrrr#szModuleTreeNode.AttachcCsd|_d|_d|_dSr)rrrrrrrClose&szModuleTreeNode.CloseN)r __module__ __qualname____doc__rrrrrrrrr s r c Cs|rF|j}|o||du}|rFt|drFttj|jddv}|r|rt |}|||<||f|}||_ t |jd}|ddddkr|dd}t |ddd} |} | rt j| } t| ||||| |vr|| j } || dS)N__file__)z.pydz.dll.r)rgethasattrstringlowerospathsplitextrr rsplitjoinsysmodules BuildModuler) rZ built_nodesrootNodeZcreate_node_fncreate_node_argsZkeepnoderpartsparentZ parentNodeZ parentModulerrrr.,s.    r.cCs(ttjD]}t|||||qdSr)listr,r-valuesr.)Z builtItemsr/Z create_noder0rrrrRefreshAllModulesMsr6c@s$eZdZddZddZddZdS)CodeContainerProvidercCs8||_tj|ttj|_i|_|j |j|dSr) axdebuggerrr7rlenr,r-ZcurrentNumModulesnodesr6)rr8rrrrWs   zCodeContainerProvider.__init__cCstj||Sr)rr7 FromFileName)rfnamerrrr;^sz"CodeContainerProvider.FromFileNamecCsFtj|d|_tdt|j|jD] }|q.i|_dS)NzClosing %d nodes)rr7rr8printr9r:r5)rr1rrrrgs   zCodeContainerProvider.CloseN)rrrrr;rrrrrr7Vs r7c@seZdZddZddZdS)OriginalInterfaceMakercCs&|j}|||_|}||fSr)pdmZCreateApplicationZAddApplicationcookie GetRootNoderr?approotrrrMakeInterfacesqs  z%OriginalInterfaceMaker.MakeInterfacescCs||jdSr)ZRemoveApplicationr@rr?rrrCloseInterfaceswsz&OriginalInterfaceMaker.CloseInterfacesNrrrrErGrrrrr>psr>c@seZdZddZddZdS)SimpleHostStyleInterfaceMakercCs|}|}||fSr)ZGetDefaultApplicationrArBrrrrE|sz,SimpleHostStyleInterfaceMaker.MakeInterfacescCsdSrrrFrrrrGsz-SimpleHostStyleInterfaceMaker.CloseInterfacesNrHrrrrrI{srIc@s6eZdZd ddZddZddZdd Zd d ZdS) AXDebuggerNcCs|dur d}|durt}t|_ttjdtjtj |_ | |j \|_ |_ |j |||_tttj}|j ||_t|}|j|j |dS)NzPython Process)rIrZDebugger pydebugger pythoncomZCoCreateInstancerZCLSID_ProcessDebugManagerZ CLSCTX_ALLZIID_IProcessDebugManagerr?rErCrDZSetNameinterfaceMakerr rZProvideExpressionContextsZIID_IProvideExpressionContextsZ"AddGlobalExpressionContextProviderexpressionCookier7Z AttachApp)rrMZ processNameZexpressionProviderZ contProviderrrrrs.  zAXDebugger.__init__cCsPz ddWntdjj}Yn0|j|jd||jdS)Nr) r,exc_infotb_framef_backrCZStartDebugSessionrKZSetupAXDebugging set_trace)rframerrrBreaks  zAXDebugger.BreakcCsR|j|j|j|j|j|jd|_d|_d|_d|_d|_ dSr) rKZResetAXDebuggingrMrGr?ZCloseApprCZ%RemoveGlobalExpressionContextProviderrNrDrrrrrs  zAXDebugger.ClosecCst||j|j|fdSr)r6rDCreateApplicationNode)rr:containerProviderrrrr6szAXDebugger.RefreshAllModulescCs\|j}t|j}t|tj}||j_t |}t|tj }| || |j||Sr) rCrWrZDebugDocumentTextrr rZIID_IDebugDocumentZ debugDocumentZDebugDocumentProviderZIID_IDebugDocumentProviderZSetDocumentProviderZAddCodeContainer)rr1rXrZdocumentZproviderrrrrWs      z AXDebugger.CreateApplicationNode)NN)rrrrrVrr6rWrrrrrJs   rJcCstdurtatSr)currentDebuggerrJrrrr_GetCurrentDebuggersrZcCstdSr)rZrVrrrrrVsrVcCs d}d}dS)NrPzHi thererabrrrdosomethingelsesr^cCsd}d}tdS)NrrP)r^r[rrr dosomethingsr_cCs ttdttddS)Nz Waiting...ZDone)rVinputr_r=rrrrtestsra__main__z'About to test the debugging interfaces!z %d/%d com objects still alive)&r'r%r,rLZwin32apiZwin32com.axdebugrrrrrrrZwin32com.axdebug.utilr r r Zwin32com.axscriptr rYr r.r6r7r>rIrJrZrVZbrkrTr^r_rarr=Z_GetInterfaceCountZ_GetGatewayCountrrrrs<$  !   N