o
    Žõ±j‚l  ã                   @   sn  d dl Z d dlmZ d dlmZmZmZmZmZm	Z	m
Z
 d dlmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ ed
ƒZG dd„ deƒZeZG dd„ deƒZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2d Z3d Z4d!Z5d Z6d"Z7d#Z8d Z9d$Z:d%Z;d&Z<d'Z=d(Z>d)Z?dZ@dZAd*ZBd+ZCd,ZDd-ZEd.ZFd/ZGd(ZHd&ZId0ZJd1ZKd)ZLd'ZMd2ZNd#ZOd$ZPd ZQd3ZRd"ZSd4ZTd5ZUd6ZVd7ZWd8ZXd9ZYdZZdZ[d:Z\dZ]dZ^dZ_dZ`dZadZbd;Zcd<Zdd#Zed Zfd$Zgd=Zhd7Zid Zjd#Zkd ZldZmdZndZodZpdZqd>Zrd?Zsd<Ztd#ZuG d@dA„ dAeƒZvG dBdC„ dCeƒZwG dDdE„ dEeƒZxG dFdG„ dGeƒZyG dHdI„ dIeƒZzG dJdK„ dKeƒZ{G dLdM„ dMeƒZ|G dNdO„ dOeƒZ}G dPdQ„ dQeƒZ~G dRdS„ dSeƒZG dTdU„ dUeƒZ€G dVdW„ dWeƒZ�G dXdY„ dYeƒZ‚G dZd[„ d[eƒZƒG d\d]„ d]eƒZ„G d^d_„ d_eƒZ…G d`da„ daeƒZ†G dbdc„ dceƒZ‡G ddde„ deeƒZˆG dfdg„ dgeƒZ‰G dhdi„ dieƒZŠG djdk„ dkeƒZ‹G dldm„ dmeƒZŒG dndo„ doeƒZ�G dpdq„ dqƒZŽG drds„ dsƒZ�G dtdu„ duƒZ�G dvdw„ dweƒZ‘G dxdy„ dyeƒZ’G dzd{„ d{eƒZ“G d|d}„ d}eƒZ”G d~d„ deƒZ•G d€d�„ d�eƒZ–G d‚dƒ„ dƒeƒZ—G d„d…„ d…eƒZ˜G d†d‡„ d‡eƒZ™G dˆd‰„ d‰eƒZšG dŠd‹„ d‹eƒZ›G dŒd�„ d�eƒZœG dŽd�„ d�eƒZ�G d�d‘„ d‘eƒZžG d’d“„ d“eƒZŸG d”d•„ d•eƒZ e‘e’fe“e”fe�ežfe•e–fe—e˜fe™ešfe›eœfd–œZ¡d—d˜„ Z¢e
e
e/fd™dš„Z£d›dœ„ Z¤e
e
e/e
fd�dž„Z¥d e
d e
fdŸd „Z¦d e
d e
fd¡d¢„Z§e
dfd£d¤„Z¨d¥d¦„ Z©d§d¨„ ZªdS )©é    N)Ústat)Ú	ULONGLONGÚUINTÚUSHORTÚLPWSTRÚDWORDÚULONGÚNULL)ÚNDRCALLÚ	NDRSTRUCTÚNDRUNIONÚ
NDRPOINTERÚNDRUniConformantArray)ÚNDRVaryingString)ÚDCERPCException)Úsystem_errors)Úuuidtup_to_bin)Ú	Structure)z$12345678-1234-ABCD-EF00-0123456789ABz1.0c                   @   s   e Zd Zddd„Zdd„ ZdS )ÚDCERPCSessionErrorNc                 C   s   t  | |||¡ d S ©N)r   Ú__init__)ÚselfÚerror_stringÚ
error_codeÚpacket© r   úˆ/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/aiosmb/dcerpc/v5/rprn.pyr   %   s   zDCERPCSessionError.__init__c                 C   sF   | j }|tjv rtj| d }tj| d }d| j ||f S d| j  S )Nr   é   z'RPRN SessionError: code: 0x%x - %s - %sz+RPRN SessionError: unknown error code: 0x%x)r   r   ÚERROR_MESSAGES)r   ÚkeyÚerror_msg_shortÚerror_msg_verboser   r   r   Ú__str__(   s   

zDCERPCSessionError.__str__)NNN©Ú__name__Ú
__module__Ú__qualname__r   r"   r   r   r   r   r   $   s    
r   c                   @   ó   e Zd ZdeffZdS )ÚPSTRING_HANDLEÚDataN)r$   r%   r&   ÚSTRING_HANDLEÚreferentr   r   r   r   r(   6   ó    ÿr(   é   é    i  i   i0  é   é   é@   i  i  r   é   i  i  i  iÿÿ  i   i   i   i   i   i   i   l        i   @i    i   éÿ   é   i   i   i   i ÿ  iÿÿwwiÿÿwi   pi   i    i  @ i  p i   i   i   i   i @  i €  i  € i   i    c                   @   s   e Zd ZdZdd„ ZdS )ÚPRINTER_HANDLE))r)   z20s=b""c                 C   s   | j du rdS dS )NTr0   r/   )Ú_isNDR64©r   r   r   r   ÚgetAlignment©   s   
zPRINTER_HANDLE.getAlignmentN)r$   r%   r&   Ú	structurer8   r   r   r   r   r5   ¥   s    r5   c                   @   ó   e Zd ZdZdS )Ú
BYTE_ARRAYÚcN©r$   r%   r&   Úitemr   r   r   r   r;   °   ó    r;   c                   @   r'   )ÚPBYTE_ARRAYr)   N)r$   r%   r&   r;   r+   r   r   r   r   r@   ³   r,   r@   c                   @   ó   e Zd ZdefdeffZdS )ÚDEVMODE_CONTAINERÚcbBufÚpDevModeN)r$   r%   r&   r   r@   r9   r   r   r   r   rB   ¸   ó    þrB   c                   @   s:   e Zd ZdefdefdefdefdefdefdeffZdS )	ÚSPLCLIENT_INFO_1ÚdwSizeÚpMachineNameÚ	pUserNameÚ
dwBuildNumÚdwMajorVersionÚdwMinorVersionÚwProcessorArchitectureN)r$   r%   r&   r   r   r   r9   r   r   r   r   rF   ¿   s    ùrF   c                   @   r'   )ÚPSPLCLIENT_INFO_1r)   N)r$   r%   r&   rF   r+   r   r   r   r   rN   Ê   r,   rN   c                   @   r'   )ÚSPLCLIENT_INFO_2ÚnotUsedN)r$   r%   r&   r   r9   r   r   r   r   rO   Ð   r,   rO   c                   @   r'   )ÚPSPLCLIENT_INFO_2r)   N)r$   r%   r&   rO   r+   r   r   r   r   rQ   Õ   r,   rQ   c                   @   sL   e Zd Zdefdefdefdefdefdefdefdefdefd	eff
Zd
S )ÚSPLCLIENT_INFO_3ÚcbSizeÚdwFlagsrH   rI   rJ   rK   rL   rM   ÚhSplPrinterN)	r$   r%   r&   r   r   r   r   r   r9   r   r   r   r   rR   Ú   s    örR   c                   @   r'   )ÚPSPLCLIENT_INFO_3r)   N)r$   r%   r&   rR   r+   r   r   r   r   rV   è   r,   rV   c                   @   s.   e Zd ZdeffZdefdefdefdœZdS )ÚCLIENT_INFO_UNIONÚtagÚpClientInfo1Ú	pNotUsed1Ú	pNotUsed2)r   r2   é   N)	r$   r%   r&   r   Ú	commonHdrrN   rQ   rV   Úunionr   r   r   r   rW   í   s    ÿ
ýrW   c                   @   rA   )ÚSPLCLIENT_CONTAINERÚLevelÚ
ClientInfoN)r$   r%   r&   r   rW   r9   r   r   r   r   r_   ÷   rE   r_   c                   @   r:   )ÚUSHORT_ARRAYz<HNr=   r   r   r   r   rb   ÿ   r?   rb   c                   @   r'   )ÚPUSHORT_ARRAYr)   N)r$   r%   r&   rb   r+   r   r   r   r   rc     r,   rc   c                   @   s4   e Zd ZdefdefdefdefdefdeffZdS )ÚRPC_V2_NOTIFY_OPTIONS_TYPEÚTypeÚ	Reserved0Ú	Reserved1Ú	Reserved2ÚCountÚpFieldsN)r$   r%   r&   r   r   rc   r9   r   r   r   r   rd     ó    úrd   c                   @   r'   )Ú!PRPC_V2_NOTIFY_OPTIONS_TYPE_ARRAYr)   N)r$   r%   r&   rd   r+   r   r   r   r   rl     r,   rl   c                   @   s(   e Zd ZdefdefdefdeffZdS )ÚRPC_V2_NOTIFY_OPTIONSÚVersionÚReservedri   ÚpTypesN)r$   r%   r&   r   rl   r9   r   r   r   r   rm     ó    ürm   c                   @   r'   )ÚPRPC_V2_NOTIFY_OPTIONSr)   N)r$   r%   r&   rm   r+   r   r   r   r   rr     r,   rr   c                   @   r'   )ÚDRIVER_INFO_1ÚpNameN)r$   r%   r&   r*   r9   r   r   r   r   rs   %  r,   rs   c                   @   r'   )ÚPDRIVER_INFO_1r)   N)r$   r%   r&   rs   r+   r   r   r   r   ru   )  r,   ru   c                   @   s4   e Zd ZdefdefdefdefdefdeffZdS )ÚDRIVER_INFO_2ÚcVersionrt   ÚpEnvironmentÚpDriverPathÚ	pDataFileÚpConfigFileN)r$   r%   r&   r   r*   r9   r   r   r   r   rv   /  rk   rv   c                   @   r'   )ÚPDRIVER_INFO_2r)   N)r$   r%   r&   rv   r+   r   r   r   r   r|   8  r,   r|   c                   @   s(   e Zd ZdeffZdefdefdœZdS )ÚDRIVER_INFO_UNIONrX   ÚpNotUsedÚLevel2)r   r2   N)r$   r%   r&   r   r]   ru   r|   r^   r   r   r   r   r}   =  s    ÿ
þr}   c                   @   rA   )ÚDRIVER_CONTAINERr`   Ú
DriverInfoN)r$   r%   r&   r   r}   r9   r   r   r   r   r€   F  rE   r€   c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚDRIVER_INFO_2_ENTRYc                 C   s"   d | _ d | _d | _d | _d | _d S r   ©ÚNameÚEnvironmentÚ
DriverPathÚDataFileÚ
ConfigFiler7   r   r   r   r   P  s
   
zDRIVER_INFO_2_ENTRY.__init__c                 C   sN   d}|d| j  7 }|d| j 7 }|d| j 7 }|d| j 7 }|d| j 7 }|S )NzDRIVER_INFO_2_ENTRY
zName       : %s
zEnvironment: %s
zDriverPath : %s
zDataFile   : %s
zConfigFile : %s
rƒ   ©r   Útr   r   r   r"   W  s   zDRIVER_INFO_2_ENTRY.__str__Nr#   r   r   r   r   r‚   O  s    r‚   c                   @   s4   e Zd Zdd„ Zedd„ ƒZedd„ ƒZdd„ Zd	S )
ÚDRIVER_INFO_2_ARRAYc                 C   s   g | _ d| _g | _d S )Né   )ÚfixedÚ
fixed_sizeÚdriversr7   r   r   r   r   a  s   
zDRIVER_INFO_2_ARRAY.__init__c                 C   s   t  t | ¡|¡S r   )r‹   Úfrom_bufferÚioÚBytesIO)ÚdataÚ	elementNor   r   r   Ú
from_bytesg  s   zDRIVER_INFO_2_ARRAY.from_bytesc                 C   sX   t ƒ }t|ƒD ]}|j t | ¡¡ qt|jƒD ]\}}|j | | |j	| ¡¡ q|S r   )
r‹   Úranger�   ÚappendÚDRIVER_INFO_2_FIXEDr�   Ú	enumerater�   Ú	read_datarŽ   )Úbuffr”   ÚresÚ_Úir�   r   r   r   r�   k  s   zDRIVER_INFO_2_ARRAY.from_bufferc                 C   s.   d}| j D ]}|d| 7 }|d|j 7 }q|S )NzDRIVER_INFO_2_ARRAY
zFIXED: %s
zDRIVER: %s
)r�   Údriver)r   rŠ   Úxr   r   r   r"   w  s
   
zDRIVER_INFO_2_ARRAY.__str__N)r$   r%   r&   r   Ústaticmethodr•   r�   r"   r   r   r   r   r‹   `  s    

r‹   c                   @   sH   e Zd Zdd„ Zedd„ ƒZdd„ Zedd„ ƒZed	d
„ ƒZdd„ Z	dS )r˜   c                 C   s.   d | _ d | _d | _d | _d | _d | _d | _d S r   )rw   Ú
NameOffsetÚEnvironmentOffsetÚDriverPathOffsetÚDataFileOffsetÚConfigFileOffsetrŸ   r7   r   r   r   r   €  s   
zDRIVER_INFO_2_FIXED.__init__c                 C   s:   d}	 ||   d¡7 }|dd … dkrnq|d d…  d¡S )Nó    Tr   éýÿÿÿs      éþÿÿÿz	utf-16-le)ÚreadÚdecode©r›   rœ   r   r   r   Úread_utf16leŠ  s   ýz DRIVER_INFO_2_FIXED.read_utf16lec                 C   s®   t ƒ | _| | j| d¡ t |¡| j_| | j| d¡ t |¡| j_| | j	| d¡ t |¡| j_
| | j| d¡ t |¡| j_| | j| d¡ t |¡| j_| jS )Nr   )r‚   rŸ   Úseekr¦   r˜   r­   rˆ   r¥   r‡   r¤   r†   r£   r…   r¢   r„   )r   r›   Úoffset_deltar   r   r   rš   “  s   zDRIVER_INFO_2_FIXED.read_datac                 C   s   t  t | ¡¡S r   )r˜   r�   r‘   r’   )r“   r   r   r   r•   ¦  s   zDRIVER_INFO_2_FIXED.from_bytesc                 C   sš   t ƒ }tj|  d¡ddd�|_tj|  d¡ddd�|_tj|  d¡ddd�|_tj|  d¡ddd�|_tj|  d¡ddd�|_tj|  d¡ddd�|_	|S )Nr/   ÚlittleF)Ú	byteorderÚsigned)
r˜   Úintr•   rª   rw   r¢   r£   r¤   r¥   r¦   r¬   r   r   r   r�   ª  s   zDRIVER_INFO_2_FIXED.from_bufferc                 C   s\   d}|d| j  7 }|d| j 7 }|d| j 7 }|d| j 7 }|d| j 7 }|d| j 7 }|S )NzDRIVER_INFO_2_FIXED
zVersion          : %s
zNameOffset       : %s
zEnvironmentOffset: %s
zDriverPathOffset : %s
zDataFileOffset   : %s
zConfigFileOffset : %s
)rw   r¢   r£   r¤   r¥   r¦   r‰   r   r   r   r"   ¶  s   zDRIVER_INFO_2_FIXED.__str__N)
r$   r%   r&   r   r¡   r­   rš   r•   r�   r"   r   r   r   r   r˜     s    



r˜   c                   @   s2   e Zd ZdZdefdefdefdefdeffZdS )ÚRpcEnumPrintersr   ÚFlagsr„   r`   ÚpPrinterEnumrC   N)r$   r%   r&   Úopnumr   r*   r@   r9   r   r   r   r   r´   Ä  ó    ûr´   c                   @   ó(   e Zd ZdefdefdefdeffZdS )ÚRpcEnumPrintersResponser¶   Ú	pcbNeededÚ
pcReturnedÚ	ErrorCodeN©r$   r%   r&   r@   r   r   r9   r   r   r   r   rº   Î  rq   rº   c                   @   s,   e Zd ZdZdefdefdefdeffZdS )ÚRpcOpenPrinterr   ÚpPrinterNameÚ	pDatatypeÚpDevModeContainerÚAccessRequiredN)	r$   r%   r&   r·   r*   r   rB   r   r9   r   r   r   r   r¿   Ö  s    ür¿   c                   @   rA   )ÚRpcOpenPrinterResponseÚpHandler½   N©r$   r%   r&   r5   r   r9   r   r   r   r   rÄ   ß  rE   rÄ   c                   @   s   e Zd ZdZdeffZdS )ÚRpcClosePrinteré   Ú	phPrinterN)r$   r%   r&   r·   r5   r9   r   r   r   r   rÇ   æ  s    ÿrÇ   c                   @   rA   )ÚRpcClosePrinterResponserÉ   r½   NrÆ   r   r   r   r   rÊ   ì  rE   rÊ   c                   @   ó8   e Zd ZdZdefdefdefdefdefdeffZdS )	Ú+RpcRemoteFindFirstPrinterChangeNotificationéA   ÚhPrinterÚfdwFlagsÚ
fdwOptionsÚpszLocalMachineÚdwPrinterLocalÚpOptionsN©	r$   r%   r&   r·   r5   r   r   rr   r9   r   r   r   r   rÌ   ó  ó    úrÌ   c                   @   r'   )Ú3RpcRemoteFindFirstPrinterChangeNotificationResponser½   N©r$   r%   r&   r   r9   r   r   r   r   rÖ   þ  r,   rÖ   c                   @   rË   )	Ú-RpcRemoteFindFirstPrinterChangeNotificationExrÍ   rÎ   rÏ   rÐ   rÑ   rÒ   rÓ   NrÔ   r   r   r   r   rØ     rÕ   rØ   c                   @   r'   )Ú5RpcRemoteFindFirstPrinterChangeNotificationExResponser½   Nr×   r   r   r   r   rÙ     r,   rÙ   c                   @   s2   e Zd ZdZdefdefdefdefdeffZ	dS )ÚRpcOpenPrinterExéE   rÀ   rÁ   rÂ   rÃ   ÚpClientInfoN)
r$   r%   r&   r·   r*   r   rB   r   r_   r9   r   r   r   r   rÚ     r¸   rÚ   c                   @   rA   )ÚRpcOpenPrinterExResponserÅ   r½   NrÆ   r   r   r   r   rÝ     rE   rÝ   c                   @   s2   e Zd ZdZdefdefdefdefdeffZdS )ÚRpcEnumPrinterDriversé
   rt   rx   r`   ÚpDriversrC   N)	r$   r%   r&   r·   r*   r   r   r@   r9   r   r   r   r   rÞ   &  r¸   rÞ   c                   @   r¹   )ÚRpcEnumPrinterDriversResponserà   r»   r¼   r½   Nr¾   r   r   r   r   rá   0  rq   rá   c                   @   s&   e Zd ZdZdefdefdeffZdS )ÚRpcAddPrinterDriverExéY   rt   ÚpDriverContainerÚdwFileCopyFlagsN)r$   r%   r&   r·   r*   r€   r   r9   r   r   r   r   râ   9  s    ýrâ   c                   @   r'   )ÚRpcAddPrinterDriverExResponser½   Nr×   r   r   r   r   ræ   A  r,   ræ   )r   r   rß   rÈ   é>   rÍ   rÛ   c                 C   s(   | t kr| S | dd … dkr| d S | S )Néÿÿÿÿú )r	   )Ústringr   r   r   ÚcheckNullStringW  s
   rë   c                 Ã   sR   �t ƒ }t|ƒ|d< ||d< |tu rt|d d< n||d< ||d< |  |¡I dH S )az  
	RpcOpenPrinter retrieves a handle for a printer, port, port monitor, print job, or print server.
	Full Documentation: https://msdn.microsoft.com/en-us/library/cc244808.aspx

	:param DCERPC_v5 dce: a connected DCE instance.
	:param string printerName: A string for a printer connection, printer object, server object, job object, port
	object, or port monitor object. This MUST be a Domain Name System (DNS), NetBIOS, Internet Protocol version 4
	(IPv4), Internet Protocol version 6 (IPv6), or Universal Naming Convention (UNC) name that remote procedure
	call (RPC) binds to, and it MUST uniquely identify a print server on the network.
	:param string pDatatype: A string that specifies the data type to be associated with the printer handle.
	:param DEVMODE_CONTAINER pDevModeContainer: A DEVMODE_CONTAINER structure. This parameter MUST adhere to the specification in
	DEVMODE_CONTAINER Parameters (section 3.1.4.1.8.1).
	:param int accessRequired: The access level that the client requires for interacting with the object to which a
	handle is being opened.

	:return: a RpcOpenPrinterResponse instance, raises DCERPCSessionError on error.
	rÀ   rÁ   rÂ   rD   rÃ   N)r¿   rë   r	   Úrequest)ÚdceÚprinterNamerÁ   rÂ   ÚaccessRequiredrì   r   r   r   ÚhRpcOpenPrinter`  s   €rð   c                 Ã   s    �t ƒ }||d< |  |¡I dH S )aŸ  
	RpcClosePrinter closes a handle to a printer object, server object, job object, or port object.
	Full Documentation: https://msdn.microsoft.com/en-us/library/cc244768.aspx

	:param DCERPC_v5 dce: a connected DCE instance.
	:param PRINTER_HANDLE phPrinter: A handle to a printer object, server object, job object, or port object.

	:return: a RpcClosePrinterResponse instance, raises DCERPCSessionError on error.
	rÉ   N)rÇ   rì   )rí   rÉ   rì   r   r   r   ÚhRpcClosePrinter}  s   €
rñ   c                 Ã   sj   �t ƒ }t|ƒ|d< ||d< |tu rt|d d< n||d< ||d< |tu r)tdƒ‚||d< |  |¡I dH S )	aù  
	RpcOpenPrinterEx retrieves a handle for a printer, port, port monitor, print job, or print server
	Full Documentation: https://msdn.microsoft.com/en-us/library/cc244809.aspx

	:param DCERPC_v5 dce: a connected DCE instance.
	:param string printerName: A string for a printer connection, printer object, server object, job object, port
	object, or port monitor object. This MUST be a Domain Name System (DNS), NetBIOS, Internet Protocol version 4
	(IPv4), Internet Protocol version 6 (IPv6), or Universal Naming Convention (UNC) name that remote procedure
	call (RPC) binds to, and it MUST uniquely identify a print server on the network.
	:param string pDatatype: A string that specifies the data type to be associated with the printer handle.
	:param DEVMODE_CONTAINER pDevModeContainer: A DEVMODE_CONTAINER structure. This parameter MUST adhere to the specification in
	DEVMODE_CONTAINER Parameters (section 3.1.4.1.8.1).
	:param int accessRequired: The access level that the client requires for interacting with the object to which a
	handle is being opened.
	:param SPLCLIENT_CONTAINER pClientInfo: This parameter MUST adhere to the specification in SPLCLIENT_CONTAINER Parameters.

	:return: a RpcOpenPrinterExResponse instance, raises DCERPCSessionError on error.
	rÀ   rÁ   rÂ   rD   rÃ   zpClientInfo cannot be NULLrÜ   N)rÚ   rë   r	   Ú	Exceptionrì   )rí   rî   rÁ   rÂ   rï   rÜ   rì   r   r   r   ÚhRpcOpenPrinterExŒ  s   €ró   c                 Ã   ó\   �t ƒ }||d< ||d< ||d< ||d< |tu rtdƒ‚t|ƒ|d< ||d< |  |¡I dH S )	aë  
	creates a remote change notification object that monitors changes to printer objects and sends change notifications
	to a print client using either RpcRouterReplyPrinter (section 3.2.4.1.2) or RpcRouterReplyPrinterEx (section 3.2.4.1.4)
	Full Documentation: https://msdn.microsoft.com/en-us/library/cc244813.aspx

	:param DCERPC_v5 dce: a connected DCE instance.
	:param PRINTER_HANDLE hPrinter: A handle to a printer or server object.
	:param int fdwFlags: Flags that specify the conditions that are required for a change notification object to enter a signaled state.
	:param int fdwOptions: The category of printers for which change notifications are returned.
	:param string pszLocalMachine: A string that represents the name of the client computer.
	:param int dwPrinterLocal: An implementation-specific unique value that MUST be sufficient for the client to determine
	whether a call to RpcReplyOpenPrinter by the server is associated with the hPrinter parameter in this call.
	:param RPC_V2_NOTIFY_OPTIONS pOptions:  An RPC_V2_NOTIFY_OPTIONS structure that specifies printer or job members that the client listens to for notifications.

	:return: a RpcRemoteFindFirstPrinterChangeNotificationExResponse instance, raises DCERPCSessionError on error.
	rÎ   rÏ   rÐ   rÒ   úpszLocalMachine cannot be NULLrÑ   rÓ   N)rØ   r	   rò   rë   rì   ©rí   rÎ   rÏ   rÐ   rÑ   rÒ   rÓ   rì   r   r   r   Ú.hRpcRemoteFindFirstPrinterChangeNotificationEx°  s   €r÷   c                 Ã   rô   )	z
	rÎ   rÏ   rÐ   rÒ   rõ   rÑ   rÓ   N)rÌ   r	   rò   rë   rì   rö   r   r   r   Ú,hRpcRemoteFindFirstPrinterChangeNotificationÎ  s   €rø   c              
   Ã   sÂ   �t ƒ }||d< ||d< t|d< ||d< d}z|  |¡ W n" ty? } zt|ƒ d¡dk r/‚ | ¡ d }W Y d}~nd}~ww t ƒ }||d< ||d< ||d< ||d	< d
| |d< |  |¡I dH S )a¬  
	RpcEnumPrinters enumerates available printers, print servers, domains, or print providers.
	Full Documentation: https://msdn.microsoft.com/en-us/library/cc244794.aspx

	:param DCERPC_v5 dce: a connected DCE instance.
	:param int flags: The types of print objects that this method enumerates. The value of this parameter is the
	result of a bitwise OR of one or more of the Printer Enumeration Flags (section 2.2.3.7).
	:param string name: NULL or a server name parameter as specified in Printer Server Name Parameters (section 3.1.4.1.4).
	:param level: The level of printer information structure.

	:return: a RpcEnumPrintersResponse instance, raises DCERPCSessionError on error.
	rµ   r„   r¶   r`   r   ÚERROR_INSUFFICIENT_BUFFERr»   NrC   ó   a)r´   r	   rì   r   ÚstrÚfindÚ
get_packet)rí   ÚflagsÚnameÚlevelrì   ÚbytesNeededÚer   r   r   ÚhRpcEnumPrintersÞ  s,   €€ýr  c                 Ã   s4   �t ƒ }t|ƒ|d< ||d< ||d< |  |¡I dH S )af  
	RpcAddPrinterDriverEx installs a printer driver on the print server
	Full Documentation: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rprn/b96cc497-59e5-4510-ab04-5484993b259b

	:param DCERPC_v5 dce: a connected DCE instance.
	:param pName
	:param pDriverContainer
	:param dwFileCopyFlags

	:return: raises DCERPCSessionError on error.
	rt   rä   rå   N)râ   rë   rì   )rí   rt   rä   rå   rì   r   r   r   ÚhRpcAddPrinterDriverEx  s   €r  c              
   Ã   sF  �t ƒ }t|ƒ|d< ||d< ||d< t|d< d|d< z|  |¡I dH \}}|dur+|‚W n7 tyN } zt|ƒ d¡dk r>‚ | ¡ d	 }W Y d}~nd}~w tyc } z
d|fW  Y d}~S d}~ww t ƒ }t|ƒ|d< ||d< ||d< d
| |d< ||d< |  |¡I dH \}	}|dur‘d|fS t	 
d |	d ¡|	d ¡}
|
j|fS )a´  
	RpcEnumPrinterDrivers enumerates the printer drivers installed on a specified print server.
	Full Documentation: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rprn/857d00ac-3682-4a0d-86ca-3d3c372e5e4a

	:param DCERPC_v5 dce: a connected DCE instance.
	:param pName
	:param pEnvironment
	:param Level
	:param pDrivers
	:param cbBuf
	:param pcbNeeded
	:param pcReturned

	:return: raises DCERPCSessionError on error.
	rt   rx   r`   rà   r   rC   Nrù   r»   rú   r§   r¼   )rÞ   rë   r	   rì   r   rû   rü   rý   rò   r‹   r•   Újoinr�   )rí   rt   rx   r`   rì   r�   Úerrr  r  Údata_rawr“   r   r   r   ÚhRpcEnumPrinterDrivers  s@   €ÿ€€ÿ
r  )«r‘   Úosr   Úaiosmb.dcerpc.v5.dtypesr   r   r   r   r   r   r	   Úaiosmb.dcerpc.v5.ndrr
   r   r   r   r   r   Úaiosmb.dcerpc.v5.rpcrtr   Úaiosmb.dcerpc.v5r   Úaiosmb.dcerpc.v5.uuidr   Úaiosmb.dcerpc.v5.structurer   ÚMSRPC_UUID_RPRNr   r*   r(   ÚJOB_ACCESS_ADMINISTERÚJOB_ACCESS_READÚJOB_EXECUTEÚJOB_READÚ	JOB_WRITEÚJOB_ALL_ACCESSÚPRINTER_ACCESS_ADMINISTERÚPRINTER_ACCESS_USEÚPRINTER_ACCESS_MANAGE_LIMITEDÚPRINTER_ALL_ACCESSÚPRINTER_EXECUTEÚPRINTER_READÚPRINTER_WRITEÚSERVER_ACCESS_ADMINISTERÚSERVER_ACCESS_ENUMERATEÚSERVER_ALL_ACCESSÚSERVER_EXECUTEÚSERVER_READÚSERVER_WRITEÚSPECIFIC_RIGHTS_ALLÚSTANDARD_RIGHTS_ALLÚSTANDARD_RIGHTS_EXECUTEÚSTANDARD_RIGHTS_READÚSTANDARD_RIGHTS_REQUIREDÚSTANDARD_RIGHTS_WRITEÚSYNCHRONIZEÚDELETEÚREAD_CONTROLÚ	WRITE_DACÚWRITE_OWNERÚGENERIC_READÚGENERIC_WRITEÚGENERIC_EXECUTEÚGENERIC_ALLÚPRINTER_CHANGE_SET_PRINTERÚPRINTER_CHANGE_DELETE_PRINTERÚPRINTER_CHANGE_PRINTERÚPRINTER_CHANGE_ADD_JOBÚPRINTER_CHANGE_SET_JOBÚPRINTER_CHANGE_DELETE_JOBÚPRINTER_CHANGE_WRITE_JOBÚPRINTER_CHANGE_JOBÚ!PRINTER_CHANGE_SET_PRINTER_DRIVERÚPRINTER_CHANGE_TIMEOUTÚPRINTER_CHANGE_ALLÚPRINTER_CHANGE_ALL_2Ú!PRINTER_CHANGE_ADD_PRINTER_DRIVERÚ$PRINTER_CHANGE_DELETE_PRINTER_DRIVERÚPRINTER_CHANGE_PRINTER_DRIVERÚPRINTER_CHANGE_ADD_FORMÚPRINTER_CHANGE_DELETE_FORMÚPRINTER_CHANGE_SET_FORMÚPRINTER_CHANGE_FORMÚPRINTER_CHANGE_ADD_PORTÚPRINTER_CHANGE_CONFIGURE_PORTÚPRINTER_CHANGE_DELETE_PORTÚPRINTER_CHANGE_PORTÚ"PRINTER_CHANGE_ADD_PRINT_PROCESSORÚ%PRINTER_CHANGE_DELETE_PRINT_PROCESSORÚPRINTER_CHANGE_PRINT_PROCESSORÚPRINTER_CHANGE_ADD_PRINTERÚ(PRINTER_CHANGE_FAILED_CONNECTION_PRINTERÚPRINTER_CHANGE_SERVERÚPRINTER_ENUM_LOCALÚPRINTER_ENUM_CONNECTIONSÚPRINTER_ENUM_NAMEÚPRINTER_ENUM_REMOTEÚPRINTER_ENUM_SHAREDÚPRINTER_ENUM_NETWORKÚPRINTER_ENUM_EXPANDÚPRINTER_ENUM_CONTAINERÚPRINTER_ENUM_ICON1ÚPRINTER_ENUM_ICON2ÚPRINTER_ENUM_ICON3ÚPRINTER_ENUM_ICON8ÚPRINTER_ENUM_HIDEÚPRINTER_NOTIFY_CATEGORY_2DÚPRINTER_NOTIFY_CATEGORY_ALLÚPRINTER_NOTIFY_CATEGORY_3DÚAPD_STRICT_UPGRADEÚAPD_STRICT_DOWNGRADEÚAPD_COPY_ALL_FILESÚAPD_COPY_NEW_FILESÚAPD_COPY_FROM_DIRECTORYÚAPD_DONT_COPY_FILES_TO_CLUSTERÚAPD_COPY_TO_ALL_SPOOLERSÚAPD_INSTALL_WARNED_DRIVERÚAPD_RETURN_BLOCKING_STATUS_CODEr5   r;   r@   rB   rF   rN   rO   rQ   rR   rV   rW   r_   rb   rc   rd   rl   rm   rr   rs   ru   rv   r|   r}   r€   r‚   r‹   r˜   r´   rº   r¿   rÄ   rÇ   rÊ   rÌ   rÖ   rØ   rÙ   rÚ   rÝ   rÞ   rá   râ   ræ   ÚOPNUMSrë   rð   rñ   ró   r÷   rø   r  r  r  r   r   r   r   Ú<module>   sN  $

			E
	

	
ù	
ÿ$
ÿ
ÿ#