您好,欢迎访问一九零五行业门户网

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

本文实例讲述了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程序设计有所帮助。
其它类似信息

推荐信息