捕获“运行时检查失败 #0 - ESP 的值不正确”

发布于 2024-08-23 11:04:00 字数 184 浏览 4 评论 0原文

因此,我从我的 C# 代码中调用非托管 .dll 文件中的函数。根据传递给该函数的参数,它可能会导致“运行时检查失败#0 - ESP 的值不正确”错误。这是该函数完全正常的行为(是的,我知道这听起来很奇怪,但是请耐心听我说)。 但是,如果发生这种情况,我希望能够处理它,就像处理异常一样:只是优雅地失败,向用户输出一条消息并避免整个程序崩溃。 这可能吗?

So, I am calling a function from an unmanaged .dll file from my C# code. Depending on the arguments passed to that function, it can cause "Run-Time Check Failure #0 - The value of ESP was not properly " error.This is completely normal behavior for the function ( yes , I know this sounds VERY strange, but bear with me ).
However, if this happens I want to be able to handle it , like I would handle an exception: just fail gracefully , output a message to the user and avoid crashing my entire program.
Is this possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纸短情长 2024-08-30 11:04:00

如果您使用 GS 标志,则可以通过调用函数 __set_security_error_handler 来覆盖该行为。这允许您指定当 GS 标志和其他安全错误被触发时调用的函数。

不过我强烈建议不要这样做。任何经常破坏 ESP 的函数听起来都是一个真正的问题。您还可能通过覆盖此函数来隐藏其他真正的安全问题。

更好的解决方案是将单个方法标记为裸方法并防止发生 GS 检查。

If you are using the GS flag you can override the behavior by calling the function __set_security_error_handler. This allows you to specify the function that is called when the GS flag, and other security errors, is tripped.

I highly advise against this though. Any function that regularly corrupts ESP sounds like a real problem. You also risk hiding other real security issues by overriding this function.

A much better solution would be to mark the individual method as naked and prevent the GS check from occuring.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文