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


Posted in Python onOctober 05, 2014

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

Python 相关文章推荐
从CentOS安装完成到生成词云python的实例
Dec 01 Python
Python用csv写入文件_消除空余行的方法
Jul 06 Python
python利用多种方式来统计词频(单词个数)
May 27 Python
PyQt5实现从主窗口打开子窗口的方法
Jun 19 Python
解决Django migrate不能发现app.models的表问题
Aug 31 Python
python实现手势识别的示例(入门)
Apr 15 Python
使用SQLAlchemy操作数据库表过程解析
Jun 10 Python
PyCharm 2020.2 安装详细教程
Sep 25 Python
python获取本周、上周、本月、上月及本季的时间代码实例
Sep 08 Python
基于Python实现全自动下载抖音视频
Nov 06 Python
python中的插入排序的简单用法
Jan 19 Python
Python爬虫爬取微博热搜保存为 Markdown 文件的源码
Feb 22 Python
python求crc32值的方法
Oct 05 #Python
Python获取文件ssdeep值的方法
Oct 05 #Python
python获取Linux下文件版本信息、公司名和产品名的方法
Oct 05 #Python
python获取文件版本信息、公司名和产品名的方法
Oct 05 #Python
python实现调用其他python脚本的方法
Oct 05 #Python
跟老齐学Python之让人欢喜让人忧的迭代
Oct 02 #Python
跟老齐学Python之关于循环的小伎俩
Oct 02 #Python
You might like
php+AJAX传送中文会导致乱码的问题的解决方法
2008/09/08 PHP
2014最热门的24个php类库汇总
2014/12/18 PHP
Javascript异步表单提交,图片上传,兼容异步模拟ajax技术
2010/05/10 Javascript
jQuery+jqmodal弹出窗口实现代码分明
2010/06/14 Javascript
jQuery Mobile和HTML5开发App推广注册页
2016/11/07 Javascript
利用Chrome DevTools直接调试Node.js和JavaScript的方法详解(并行)
2017/02/16 Javascript
underscore之Collections_动力节点Java学院整理
2017/07/10 Javascript
详解Webpack DLL用法以及功能
2017/07/11 Javascript
JS 中可以提升幸福度的小技巧(可以识别更多另类写法)
2018/07/28 Javascript
JS调用安卓手机摄像头扫描二维码
2018/10/16 Javascript
微信小程序图片加载失败时替换为默认图片的方法
2019/12/09 Javascript
[01:00:35]2018DOTA2亚洲邀请赛3月30日B组 EffcetVSMineski
2018/03/31 DOTA
Python 命令行非阻塞输入的小例子
2013/09/27 Python
使用python实现正则匹配检索远端FTP目录下的文件
2015/03/25 Python
安装dbus-python的简要教程
2015/05/05 Python
Python批量创建迅雷任务及创建多个文件
2016/02/13 Python
Python开发的实用计算器完整实例
2017/05/10 Python
Python 关于反射和类的特殊成员方法
2017/09/14 Python
tensorflow入门之训练简单的神经网络方法
2018/02/26 Python
Python3基于sax解析xml操作示例
2018/05/22 Python
python Django 创建应用过程图示详解
2019/07/29 Python
关于python中plt.hist参数的使用详解
2019/11/28 Python
Pytorch实现的手写数字mnist识别功能完整示例
2019/12/13 Python
TensorFLow 不同大小图片的TFrecords存取实例
2020/01/20 Python
解决python3.x安装numpy成功但import出错的问题
2020/11/17 Python
HTML5页面无缝闪开的问题及解决方案
2020/06/11 HTML / CSS
中国第一家杂志折扣订阅网:杂志铺
2016/08/30 全球购物
家佳咖啡店创业计划书
2013/12/27 职场文书
项目合作协议书
2014/04/16 职场文书
加入学生会演讲稿
2014/04/24 职场文书
计算机网络专业自荐信
2014/07/04 职场文书
创先争优活动承诺书
2014/08/30 职场文书
民主评议党员登记表自我评价
2014/10/20 职场文书
王金山在党的群众路线教育实践活动总结大会上的讲话稿
2014/10/25 职场文书
Pytorch 如何实现LSTM时间序列预测
2021/05/17 Python
Python Django框架介绍之模板标签及模板的继承
2021/05/27 Python