当前位置: 移动技术网 > IT编程>脚本编程>Python > python实现计算资源图标crc值的方法

python实现计算资源图标crc值的方法

2019年03月25日  | 移动技术网IT编程  | 我要评论

溧水114房产,dnf2.8无敌版小游戏,误惹冷魅邪殿下

本文实例讲述了python实现计算资源图标crc值的方法,分享给大家供大家参考。具体方法如下:

实现该功能的关键在于解析资源信息,找到icon的数据,然后计算这些数据的crc

具体实现代码如下:

  def _get_iconcrc(self, file_path): 
    """ 
    generates the crc32 hash of the icon of the file. 
    @return: str, the str value of the file's icon 
    """ 
    icondata = "" 
 
    mype = pefile.pe(file_path) 
    if hasattr(mype, "directory_entry_resource"): 
      resicons = filter(lambda x: x.id==pefile.resource_type['rt_icon'], mype.directory_entry_resource.entries) 
      if len(resicons)>0: 
        resicons = resicons[0] 
        if hasattr(resicons, "directory"): 
          for resid in resicons.directory.entries: 
            if hasattr(resid, 'directory'): 
              for reslang in resid.directory.entries: 
                icondata += mype.get_data(reslang.data.struct.offsettodata, reslang.data.struct.size) 
     
    if not icondata: 
      print "not icondata" 
      return none 
    else: 
      return self._crc32(icondata) 

希望本文所述对大家的python程序设计有所帮助。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网