
    i                         S r SSKJr  SSKJrJr  \R                  " \5      r	Sr
SrSrSrSrS	rSS
 jrSS jrSS jrS rg)z2
Read and write resources from/to Win32 PE files.
    N)
pywintypeswin32api      i  i  i  i  c           	         Ub  [        U5      OS1nUb  [        U5      OS1nUb  [        U5      OS1n0 n[        [        [        [        1n[
        R                  " U S[        5      n [
        R                  " U5      nSU;  a  U V	s/ s H  oU;   d  M
  U	PM     nn	U H  n	 [
        R                  " Xi5      n
SU;  a  U
 Vs/ s H  oU;   d  M
  UPM     n
nU
 H}  n [
        R                  " XiU5      nSU;  a  U Vs/ s H  oU;   d  M
  UPM     nnU H=  n [
        R                  " XiX5      nX;  a  0 XI'   XU	   ;  a  0 XI   U'   XU	   U   U'   M?     M     M     [
        R                  " U5        U$ ! [        R                   a!  nUR                  S   U;  a  e / n SnAGN)SnAff = fs  sn	f ! [        R                   a   nUR                  S   U;  a  e  SnAGMD  SnAff = fs  snf ! [        R                   a   nUR                  S   U;  a  e  SnAGME  SnAff = fs  snf ! [        R                   a   nUR                  S   U;  a  e  SnAGME  SnAff = f)a  
Retrieve resources from the given PE file.

filename: path to the PE file.
types: a list of resource types (integers or strings) to search for (None = all).
names: a list of resource names (integers or strings) to search for (None = all).
languages: a list of resource languages (integers) to search for (None = all).

Returns a dictionary of the form {type: {name: {language: data}}}, which might also be empty if no matching
resources were found.
N*r   )setERROR_RESOURCE_DATA_NOT_FOUNDERROR_RESOURCE_TYPE_NOT_FOUNDERROR_RESOURCE_NAME_NOT_FOUNDERROR_RESOURCE_LANG_NOT_FOUNDr   LoadLibraryExLOAD_LIBRARY_AS_DATAFILEEnumResourceTypesr   errorargsEnumResourceNamesEnumResourceLanguagesLoadResourceFreeLibrary)filenametypesnames	languagesoutput_IGNORE_EXCEPTIONSmodule_handleavailable_typeseres_typeavailable_namesres_nameavailable_languagesres_langdatas                  PC:\des-py\RoboSAPF\venv\Lib\site-packages\PyInstaller\utils\win32\winresource.pyget_resourcesr'      sq     +CJ#E+CJ#E"+"7IcUIF 	&%%%	 **8Q8PQM"44]C %4CYOSXGX8OY#	&88QO e8G]HW\K\xO]'H&.&D&D]^f&g# )#@S&m@SHclWlx@S#&m/#00(]D )')F$(#3313F$X.7;x *84 0 ( $P 'Me  66!9.. Z  	vvay 22	 ^ ## 66!9$66 'n "'' vvay(::s   )E8 		F0F0$F5	G,G,G1 	H(H(H-8F-F((F-5G)	G$$G)1H%H  H%-I!	I	I!	c           	         US:X  a  [        S5      eUb  [        U5      OS1nUb  [        U5      OS1n[        X/X45      nUR                  U0 5      nU H6  nUS:X  a  M  Xe;  a  0 XV'   U H  nUS:X  a  M  XuU   ;  d  M  SXV   U'   M     M8     [        R
                  " U S5      nUR                  5        H4  nXV   R                  5        H  n[        R                  " XXaU5        M     M6     [        R                  " US5        g)al  
Update or add a single resource in the PE file with the given binary data.

filename: path to the PE file.
data: binary data to write to the resource.
res_type: resource type to add/update (integer or string).
names: a list of resource names (integers or strings) to update (None = all).
languages: a list of resource languages (integers) to update (None = all).
r   z"res_type cannot be a wildcard (*)!Nr   )	
ValueErrorr	   r'   getr   BeginUpdateResourcekeysUpdateResourceEndUpdateResource)	r   r%   r    r   r   	resourcesr"   r$   r   s	            r&   add_or_update_resourcer0   q   s
    3=>>+CJ#E"+"7IcUI h
EEI h+Is?$"$I!H32204	#H-	 "  001=MNN$!+002H##MXXV 3 % }a0    c           
         Ub  [        U5      OS1nUb  [        U5      OS1nUb  [        U5      OS1n[        XX45      nUR                  5        Hm  u  pgSU;  a  Xb;  a  M  UR                  5        HG  u  pSU;  a  X;  a  M  U	R                  5        H!  u  pSU;  a  X;  a  M  [        XXh/U
/5        M#     MI     Mo     g)a  
Update or add resources in the given PE file by copying them over from the specified source PE file.

filename: path to the PE file.
src_filename: path to the source PE file.
types: a list of resource types (integers or strings) to add/update via copy for (None = all).
names: a list of resource names (integers or strings) to add/update via copy (None = all).
languages: a list of resource languages (integers) to add/update via copy (None = all).
Nr   )r	   r'   itemsr0   )r   src_filenamer   r   r   r/   r    resources_for_typer"   resources_for_type_namer$   r%   s               r&   copy_resources_from_pe_filer7      s      +CJ#E+CJ#E"+"7IcUI l5DI(1(9$e 51C1I1I1K-H%H$9"9"?"?"Ai'H,E&xxhZX #B 2L ):r1   c                 `    [         R                  " U S5      n[         R                  " US5        g)z.
Remove all resources from the given PE file:
TFN)r   r+   r.   )r   r   s     r&   remove_all_resourcesr9      s&     004@M}e4r1   )NNN)NN)__doc__PyInstaller.loglogloggingPyInstaller.compatr   r   	getLogger__name__loggerr   ERROR_BAD_EXE_FORMATr
   r   r   r   r'   r0   r7   r9    r1   r&   <module>rD      s^    " 3			8	$   $  $  $  $ Rj'1TY:5r1   