利用ICSharpCode.SharpZipLib.dll解析 出错:“Wrong Local header signature: 0xFF8”

简介: ## 分析原因利用ICSharpCode.SharpZipLib.dll解析APK时,进入APK的AndroidXml获取时出现报错## 出错代码```csharpusing (ICSharpCode.SharpZipLib.Zip.ZipInputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(path))) { using (var filestream = new FileStream(path, FileMode.Open, FileAccess.Read)) {

分析原因

利用ICSharpCode.SharpZipLib.dll解析APK时,进入APK的AndroidXml获取时出现报错

出错代码

using (ICSharpCode.SharpZipLib.Zip.ZipInputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(path))) 
{
   
    using (var filestream = new FileStream(path, FileMode.Open, FileAccess.Read)) 
    {
   
        ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(filestream);
        ICSharpCode.SharpZipLib.Zip.ZipEntry item;
        // 出错部分
        while ((item = zip.GetNextEntry()) != null) 
        {
   
            if (item.Name.ToLower() == "androidmanifest.xml") 
            {
   
                manifestData = new byte[50 * 1024];
                using (Stream strm = zipfile.GetInputStream(item)) 
                {
   
                    strm.Read(manifestData, 0, manifestData.Length);
                }
            }
            if (item.Name.ToLower() == "resources.arsc") 
            {
   
                using (Stream strm = zipfile.GetInputStream(item)) 
                {
   
                    using (BinaryReader s = new BinaryReader(strm)) 
                    {
   
                        resourcesData = s.ReadBytes((int)s.BaseStream.Length);
                    }
                }
            }
        }
    }

解决方法

经过查阅资料,解决方法如下

using (ZipInputStream zip = new ZipInputStream(File.OpenRead(path))) 
{
   
    using (var filestream = new FileStream(path, FileMode.Open, FileAccess.Read)) 
    {
   
        System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
        ZipFile zipfile = new ZipFile(filestream);
        // 代码更换部分
        foreach (ZipEntry entry in zipfile) 
        {
   
            if (entry != null) 
            {
   
                if (entry.Name.ToLower() == "androidmanifest.xml") 
                {
   
                    manifestData = new byte[50 * 1024];
                    Stream strm = zipfile.GetInputStream(entry);
                    strm.Read(manifestData, 0, manifestData.Length);
                }
                if (entry.Name.ToLower() == "resources.arsc") 
                {
   
                    Stream strm = zipfile.GetInputStream(entry);
                    using (BinaryReader s = new BinaryReader(strm)) 
                    {
   
                        resourcesData = s.ReadBytes((int)entry.Size);
                    }
                }
            }
        }
    }
}

参考链接

Wrong Local header signature: 0xFF8

以上就是利用ICSharpCode.SharpZipLib.dll解析 出错:“Wrong Local header signature: 0xFF8”的介绍,做此记录,如有帮助,欢迎点赞关注收藏!

目录
相关文章
|
编解码
AAC_LC用LATM封装header信息解析 Audio Specific Config格式分析
通常来说AAC的头信息在编解码过程中是可以获取到的,但今天需要根据音频参数生成相应的AAC头。项目中使用的是AAC_LC,今天先对它的结构进行分析。     项目中使用ffmpeg进行音频编码,音频编码库为FAAC,好吧,直接看代码吧。
2636 0
|
搜索推荐 语音技术 数据安全/隐私保护
RTP协议之Header结构解析
实时传输协议 RTP,RTP 提供带有实时特性的端对端数据传输服务,传输的数据如:交互式的音频和视频。那些服务包括有效载荷类型定义,序列号,时间戳和传输监测控制。应用程序在 UDP 上运行 RTP 来使用它的多路技术和 checksum 服务。
1210 0
|
编解码
【H.264/AVC视频编解码技术详解】十一、H.264的Slice Header解析
《H.264/AVC视频编解码技术详解》视频教程已经在“CSDN学院”上线,视频中详述了H.264的背景、标准协议和实现,并通过一个实战工程的形式对H.
1698 0
|
6天前
|
缓存 Java 开发者
10个点介绍SpringBoot3工作流程与核心组件源码解析
Spring Boot 是Java开发中100%会使用到的框架,开发者不仅要熟练使用,对其中的核心源码也要了解,正所谓知其然知其所以然,V 哥建议小伙伴们在学习的过程中,一定要去研读一下源码,这有助于你在开发中游刃有余。欢迎一起交流学习心得,一起成长。
|
7天前
|
安全 网络协议 Java
Netty核心NioEventLoop源码解析(下)
Netty核心NioEventLoop源码解析(下)
21 0
|
7天前
|
算法 Java 索引
Netty核心NioEventLoop源码解析(上)
Netty核心NioEventLoop源码解析(上)
20 0
|
7天前
|
消息中间件 缓存 前端开发
Netty消息编码及发送源码解析
Netty消息编码及发送源码解析
7 0
|
9天前
|
移动开发 网络协议 Java
Netty解码器源码解析
Netty解码器源码解析
13 0
|
9天前
|
SQL XML Java
Mybatis源码解析
Mybatis源码解析
19 0
|
10天前
|
SQL 缓存 Java

推荐镜像

更多