捕获操作码0xCC作为异常 [英] Catching opcode 0xCC as an exception
本文介绍了捕获操作码0xCC作为异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
说C程序可能会触发操作码 0xCC
的异常?如何捕获它?
Say a C program might trigger an exception of opcode 0xCC
How can I catch it?
我尝试过:
__try
{
...some code
}
__except(GetExceptionCode()==EXCEPTION_EXECUTE_HANDLER)
{
_tprintf(_T("Error\n"),i);
return 0;
}
这对我不起作用。我究竟做错了什么?
谢谢!
This is not working for me. What am I doing wrong? Thanks!
推荐答案
您没有在检查正确的异常代码。
You're not checking for the right exception code.
int 3
引发 EXCEPTION_SINGLE_STEP
。
您可以这样处理:
__try
{
// some code that might cause an int3
}
__except(GetExceptionCode() == EXCEPTION_SINGLE_STEP ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
{
// error handling of int3
}
编辑:请注意,附加了调试器的代码将不会运行,因为调试器将其处理并清除,然后再将其传递回代码。
Please note that a code running with a debugger attached will not see the exception, because the debugger handles it and clears it before passing the hand back to the code.
这篇关于捕获操作码0xCC作为异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文