如何从Exe或DLL字节数组/内存流中提取图标? [英] How to extract Icons from Exe or DLL byte array / memory stream?

查看:478
本文介绍了如何从Exe或DLL字节数组/内存流中提取图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要直接从.exe和.dll文件流中获取图标,而不需要临时文件。

I need to get icons from .exe and .dll file streams directly without temporary files.

此文件流是从MSI包图标表中获取的。

This file stream is obtained from the MSI package "Icon" table.

我能够成功提取来自MSI软件包图标表格的.ico文件流的图标,代码如下:

I was able to successfully extract Icon from ".ico" file stream from the MSI package "Icon" table with this code:

public static Icon BytesToIcon(byte[] bytes)
{
    using (MemoryStream ms = new MemoryStream(bytes))
    {
     return new Icon(ms);
    }
}

但我不知道我如何阅读图标从.exe和.dll文件流直接。请帮助我查看正确的方向。

but I have no clue of how I could read icons from .exe and .dll file streams directly. Please help me to look into right direction.

问题是关于从Byte [] fileStream读取图标。
没有文件。目标是从没有临时文件的流中读取图标。

The question is about reading Icons from Byte[] fileStream. There is no file. And the goal is to read Icons from that stream without temporary files.

其他类似的问题是关于Icon.ExtractAssociatedIcon(filePath)
这是不合适的对于我来说,因为没有文件路径。

Other similar question is about "Icon.ExtractAssociatedIcon(filePath)" It is not suitable for me because there is no file path.

更新:
我的问题被主持人LB错误地标记为重复。主持人没有检查更新的问题,我的澄清是为什么不是实际的一个重复。不幸的是,网站不允许与用户联系,并且问题被自己的想法标记为重复 - 问题将被宠坏,没有上诉机会。

Update: My question was marked as "duplicate" by moderator "L.B" by mistake. Moderator did not check updated question with my clarification on "why it wasn't actually" a duplicate. Unfortunately site does not allow to contact users, and after question is marked as duplicate by someone on their own thought - the question will be spoiled without a chance of appeal.

推荐答案

我发现一个项目库完成我所要求的一切。
库具有将.exe / .dll作为内存流加载的方法。
我可以将我的byte []数组转换为内存流对象,如下所示:

I have found a project library that does everything exactly what I have asked for. The library has method to Load .exe/.dll as a memory stream. I can convert my byte[] array to memory stream object as follows:

MemoryStream stream = new MemoryStream(myByteArray);

//and then load that MemoryStream with IconLib Load method:

MultiIcon multiIcon = new MultiIcon();
multiIcon.Load(stream)

//Iterate through different resolution icons under index 0
List<Icon> iconList = new List<Icon>();
foreach(IconImage iconImage in multiIcon[0])
{
 iconList.Add iconImage.Icon
}

这篇关于如何从Exe或DLL字节数组/内存流中提取图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆