分析原因

利用ICSharpCode.SharpZipLib.Zip进行APK解析时,因为APK内编译的名称为中文,查询微软开发文档936为gb2312中文编码

微软开发文档地址https://docs.microsoft.com/zh-cn/windows/win32/intl/code-page-identifiers

错误代码

using (ZipInputStream zip = new ZipInputStream(File.OpenRead(path)))
{
using (var filestream = new FileStream(path, FileMode.Open, FileAccess.Read))
{ // 出现错误部分
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);
}
}
}
}
}
}

解决方法

using (ZipInputStream zip = new ZipInputStream(File.OpenRead(path)))
{
using (var filestream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
// 在.Net Core中默认System.Text中不支持CodePagesEncodingProvider.Instance
// 添加下方这行代码允许访问.Net Framework平台上不支持的编码提供程序
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);
}
}
}
}
}
}

最新文章

  1. iOS UISearchBar 设置取消按钮,回收键盘,并修改cancel为“取消”
  2. LayaAir引擎——(一)
  3. 查询SQLServer的启动时间
  4. 文件与目录的默认权限与隐藏权限【转vbird】
  5. HDU-2262 Where is the canteen 概率DP,高斯消元
  6. AOJ 0525 穷举
  7. 关于Resharper的使用经验
  8. C++库研究笔记——函数名的宏定义
  9. Brief introduction to Java String Split 【简单介绍下Java String Split】
  10. 基于Dubbo的http自动测试工具分享
  11. NVIDIA Geforce GT 730 OpenGL 图形显示异常花屏
  12. D3---01基础的柱状图制作(转)
  13. jquery源码 整体架构
  14. django在centos部署
  15. remote staging type or host is not specified
  16. BitAdminCore框架更新日志20180519
  17. redis的常用公共方法(2)
  18. kaggle _Titanic: Machine Learning from Disaster
  19. 推荐6款极具个性化的在线生成logo的网站
  20. git --mixed --soft --hard之间的区别

热门文章

  1. 【Android逆向】rpc调用某安App的X-App-Token签名函数
  2. DTSE Tech Talk 第13期:Serverless凭什么被誉为未来云计算范式?
  3. MISC图片批量处理jio本
  4. 5V升压12.6V
  5. 使用sanic框架实现分布式爬虫
  6. Graph Neural Network——图神经网络
  7. Jmeter在结果树中查看响应数据为空
  8. Windows上使用QEMU创建银河麒麟ARM64虚拟机完全手册
  9. 11、lombok日志记录
  10. electron + go 如何从sqlite获取数据