File: //usr/local/CyberCP/lib64/python3.10/site-packages/paramiko/__pycache__/win_pageant.cpython-310.pyc
o
�hQ � @ s� d Z ddlZddlZddlZddlZddlmZ ddlm Z ddl
Zddlm
Z
dZdZd Zd
d� Zdd
� Ze�� d dkrBejZnejZG dd� dej�Zdd� ZG dd� d�ZdS )zP
Functions for communicating with Pageant, the basic windows ssh agent program.
� N)� zero_byte)�b� )�_winapil �P� i �J c C s t jj�dd�S )Ns Pageant)�ctypes�windll�user32�FindWindowA� r r �G/usr/local/CyberCP/lib/python3.10/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
�num_data� data_size�data_locN)
�__name__�
__module__�__qualname__�__doc__� ULONG_PTRr �wintypes�DWORD�c_void_p�_fields_r r r r r ? s
�r c C s� t � }|sdS dt�� d��}t�|tt�� �}|�Y |�| � t�dt |�t
�}|�� \}}tt
||�}tjj�|tt�|�t�|��}|dkrj|�d� |�d�} t�d| �d }
| |�|
� W d � S W d � dS 1 svw Y dS )za
Communication with the Pageant process is done through a shared
memory-mapped file.
N�PageantRequest�08xr r � z>I)r
�thread� get_identr � MemoryMap�_AGENT_MAX_MSGLEN� get_security_attributes_for_user�write�arrayr r �buffer_infor �_AGENT_COPYDATA_IDr r r �SendMessageA�win32con_WM_COPYDATA�sizeof�byref�seek�read�struct�unpack)�msg�hwnd�map_name�pymap�char_buffer�char_buffer_address�char_buffer_size�cds�response�datalen�retlenr r r �_query_pageantL s2
�
��
�$�r= c @ s0 e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
S )�PageantConnectiona
Mock "connection" to an agent which roughly approximates the behavior of
a unix local-domain socket (as used by Agent). Requests are sent to the
pageant daemon via special Windows magick, and responses are buffered back
for subsequent reads.
c C s
d | _ d S �N�� _response��selfr r r �__init__z s
zPageantConnection.__init__c C s t |�| _d S r? )r= rA )rC �datar r r �send} s zPageantConnection.sendc C s@ | j d u rdS | j d |� }| j |d � | _ | j dkrd | _ |S )N� r@ )rC �n�retr r r �recv� s
zPageantConnection.recvc C s d S r? r rB r r r �close� s zPageantConnection.closeN)r r r r rD rF rJ rK r r r r r>