o
    i                     @   s   d dl Z d dl mZ d dlmZmZ e jdddZed Zeje_	ed Z
eje
_	ejejejfe
_e jd	ddZed
 Zeje_	eje ejejejfe_dejdee fddZdeej fddZdee fddZdS )    N)wintypes)ListOptionalkernel32T)use_last_errorGetCurrentProcessGetModuleFileNameWpsapiEnumProcessModulesmodulereturnc                 C   s&   t jd  }t| |t|r|jS d S )Ni  )r   WCHAR_k32_get_module_file_namelenvalue)r   name r   B/home/ubuntu/.local/lib/python3.10/site-packages/dllist/windows.py_get_module_filename    s   r   c                  C   s   t  } t }d}	 tj|  }t| |t|t|s1t }t	|
 }t|d| |jttj }|t|krF|d | S q
)Ni   TzEnumProcessModules failed: )_get_current_processr   DWORDHMODULE_enum_process_modulesctypessizeofbyrefget_last_errorFormatErrorstripWinErrorr   r   )processspace_needednmoduleserrmsgr   r   r   _get_module_handles'   s   r&   c                     s   t  }  fdd| D }|S )Nc                    s    g | ]}t |  d ur qS )N)r   ).0hr   r   r   
<listcomp>:   s     z-_platform_specific_dllist.<locals>.<listcomp>)r&   )r#   	librariesr   r)   r   _platform_specific_dllist8   s   r,   )r   r   typingr   r   WinDLL	_kernel32r   HANDLErestyper   r   r   LPWSTRargtypes_psapir   BOOLPOINTERLPDWORDstrr   r&   r,   r   r   r   r   <module>   s.    
