o
    Žõ±j³  ã                   @   sn   d dl Z d dl mZ d dlmZmZmZ ddlT d ZeZe j	Z	dd„ Z
dd
d„Zdd„ Zedkr5eƒ  dS dS )é    N)Úwindll)ÚULONGÚBOOLÚLONGé   )Ú*c                 C   s   t j | ¡}t |¡S )z/
	Converts NTSTATUS codes into WinError codes
	)r   ÚntdllÚRtlNtStatusToDosErrorÚctypesÚWinError)ÚstatusÚerr© r   ú£/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/pypykatz/commons/readers/local/common/privileges.pyÚNtError   s   
r   TFc                 C   sV   t jj}tttttƒg|_t|_|}tƒ }|| ||t	 
|¡ƒ}|tkr)tt|ƒƒ‚dS )z
	privilige_id: int
	T)r   r   ÚRtlAdjustPrivileger   r   ÚPOINTERÚargtypesÚNTSTATUSÚrestyper
   ÚbyrefÚSTATUS_SUCCESSÚ	Exceptionr   )Úprivilige_idÚenableÚthread_or_processÚ_RtlAdjustPrivilegeÚCurrentThreadÚEnabledr   r   r   r   r      s   r   c                   C   s   t tjjƒ dS )zš
    Enables the SE_DEBUG privilege for the currently running process, if the process has SE_DEBUG privilege. (You'll need to be admin most probably)
    N)r   ÚPrivilegeValuesÚSE_DEBUGÚvaluer   r   r   r   Úenable_debug_privilege0   s   r"   Ú__main__)TF)r
   r   Úctypes.wintypesr   r   r   Úprivileges_typesr   r   r   r   r   r"   Ú__name__r   r   r   r   Ú<module>   s   

ÿ