惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
罗磊的独立博客
T
The Blog of Author Tim Ferriss
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Last Week in AI
Last Week in AI
美团技术团队
Google Online Security Blog
Google Online Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
Docker
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件
月光博客
月光博客
L
LINUX DO - 最新话题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
W
WeLiveSecurity
H
Heimdal Security Blog
Vercel News
Vercel News
SecWiki News
SecWiki News
Forbes - Security
Forbes - Security
Blog — PlanetScale
Blog — PlanetScale
Google DeepMind News
Google DeepMind News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
TaoSecurity Blog
TaoSecurity Blog
T
Troy Hunt's Blog
A
About on SuperTechFans
C
Check Point Blog
S
Security Affairs
Hacker News - Newest:
Hacker News - Newest: "LLM"
AI
AI
WordPress大学
WordPress大学
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Help Net Security
Help Net Security
博客园_首页
The Last Watchdog
The Last Watchdog
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
I
Intezer
K
Kaspersky official blog
M
MIT News - Artificial intelligence
J
Java Code Geeks
G
GRAHAM CLULEY
P
Palo Alto Networks Blog

博客园 - zsi

在线程中调用SaveFileDialog DSOFramer 之一:在 64 位系统注册 DSOFramer GridView 绑定数据不满一页时填充空行的方法 GridView 始终显示 Pager 分页行的一种方法 Chrome: Google加入浏览器大战之兼容性 ASP.NET 2.0无法打开到 SQL Server 的连接 扯扯OpenFileDialog和.NET的缺省目录 给ASP.NET程序换换地儿 对象序列化:经验小结 对象序列化:使用XmlSerializer走完最后一步 对象序列化:使用System.Xml.Serialization命名空间 在.NET中实现对象序列化 了解HTTP协议一些有用资料 Yahoo!十岁! 在VB.NET中处理构造函数时值得注意的两个陈述 微软新发布的共享设计模式的WIKI 还不快进入Design Pattern的世界? 另人费解的IsNot关键字 也说金山词霸2005内存泄露的问题
调用unrar.dll时SEHException外部组件异常的处理
zsi · 2008-01-26 · via 博客园 - zsi

  最近使用UnRARNet 处理 RAR格式的压缩文件。UnRARNet 是由 RARLab 随 unrar.dll 控件一起提供的.net 平台的封装。UnRARNet 使用VB.net语言,应该说对unrar.dll 进行了近乎完美的封装,几乎所有压缩和解压缩工作都完成的很漂亮。

  不过,最近在测试解压缩文件时,遇到一个 System.Runtime.InteropServices.

SEHException 异常,异常信息是“外部组件发生异常”。具体位置是在 Decompressor 类的 LoadFileList() 方法中,其中有一句

mRARHandle = RAROpenArchiveEx(uRAREx)

是调用 unrar.dll 外部组件的RAROpenArchiveEx() 方法,异常就发生在这里。

  微软关于SEHExcption的描述中说:

SEHException 类处理从非托管代码引发的、但尚未映射到另一个 .NET Framework 异常的 SEH 错误。SEHException 类还响应 HRESULT E_FAIL(它具有值 0x80004005)。

.NET Framework 经常会遇到非托管 SEH 异常,这些异常自动映射到托管等效项。例如,STATUS_NO_MEMORY SEH 异常自动映射到 OutOfMemoryException 类,而 STATUS_ACCESS_VIOLATION SEH 异常自动映射到 NullReferenceException 类。但是默认情况下,任何未自动映射到特定异常的 SEH 异常将映射到 SEHException 类。

  我用Google搜索网页和Google Groups,都没有发现解决这类问题的方法,看来我足够幸运:),让我先碰到了。

  经过仔细分析,发现问题出在压缩文件的注释上,当注释长度超过一个临界值时,就会发生 SEHException 外部组件异常。RAR 命令指南中提到RAR 压缩包的最大注释长度是 62000 字节,而测试的压缩文件注释只有19000多个字节,完全没有超出最大注释长度。因为注释长度而发生异常似乎没有道理。难道是UnRARNet有问题?

  再回过头看

Decompressor 类,发现在 Init() 方法中有这么一段代码:

        uRAREx.CmtBuf = Space(16384)
        uRAREx.CmtBufSize 
= 16384
        uRAREx.ArcName 
= mRARFile

        uHeaderEx.CmtBuf 

= Space(16384)


  原来,UnRARNet 将默认的注释长度设置成了 16384,难怪解压缩时发生异常了。将注释长度设置成RAR 压缩包的最大注释长度62000,测试通过:)