U vfQ @ s d Z ddlZddlZddlZddlZddlmZ ddlm Z ddl Zddlm Z dZdZd Zd d Zdd Ze d dkrejZnejZG dd dejZdd ZG dd dZdS )zP Functions for communicating with Pageant, the basic windows ssh agent program. N) zero_byte)b )_winapil P i J c C s t jjddS )Ns Pageant)ctypeswindlluser32ZFindWindowA r r E/opt/alt/python38/lib/python3.8/site-packages/paramiko/win_pageant.py_get_pageant_window_object+ s r c C s t t S )z Check to see if there is a "Pageant" agent we can talk to. This checks both if we have the required libraries (win32all or ctypes) and if there is a Pageant currently running. )boolr r r r r can_talk_to_agent/ s r 64bitc @ s, e Zd ZdZdefdejjfdejfgZ dS )COPYDATASTRUCTzy ctypes implementation of http://msdn.microsoft.com/en-us/library/windows/desktop/ms649010%28v=vs.85%29.aspx Znum_data data_sizeZdata_locN) __name__ __module____qualname____doc__ ULONG_PTRr ZwintypesZDWORDZc_void_pZ_fields_r r r r r ? s r c C s t }|sdS dt d}t|tt }| || tdt |t }| \}}tt ||}tjj|tt|t|}|dkr|d |d} td| d } | || W 5 Q R S W 5 Q R dS Q R X dS )za Communication with the Pageant process is done through a shared memory-mapped file. NZPageantRequest08xr r z>I)r thread get_identr Z MemoryMap_AGENT_MAX_MSGLENZ get_security_attributes_for_userwritearrayr r buffer_infor _AGENT_COPYDATA_IDr r r ZSendMessageAwin32con_WM_COPYDATAZsizeofZbyrefseekreadstructunpack)msgZhwndZmap_nameZpymapZchar_bufferZchar_buffer_addressZchar_buffer_sizeZcdsresponseZdatalenZretlenr r r _query_pageantL s<