seh

Catching opcode 0xCC as an exception

拜拜、爱过 提交于 2019-12-08 04:29:46
问题 Say a C program might trigger an exception of opcode 0xCC How can I catch it? I tried: __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! 回答1: You're not checking for the right exception code. int 3 throws EXCEPTION_SINGLE_STEP . You handle it this way : __try { // some code that might cause an int3 } __except(GetExceptionCode() == EXCEPTION_SINGLE_STEP ? EXCEPTION

OllyDbg can't debug visual studio exe

此生再无相见时 提交于 2019-12-08 02:05:33
问题 I've just created a new vc++ exe with this simple code: #include<stdio.h> #include<string.h> #include<windows.h> int ExceptionHandler(void); int main(int argc,char *argv[]){ char temp[512]; printf("Application launched"); try { throw "error"; } catch (... ) { ExceptionHandler(); } return 0; } int ExceptionHandler(void) { printf("Exception"); return 0; } The app is extremely simple, and an exe file depending on kernel32.dll and MSVCR100D.dll is created. When I try to import and debug it into

Does a legitmate epilog need to include a dummy rsp adjustment even if not otherwise necessary?

末鹿安然 提交于 2019-12-07 21:24:36
问题 The x86-64 Windows ABI has the concept of a legitimate epilog , which is a special type of function epilog that can be simulated during exception handling in order to restore the callers context 1 as described here: If the RIP is within an epilog [when an exception occurs], then control is leaving the function, ... and the effects of the epilog must be continued to compute the context of the caller function. To determine if the RIP is within an epilog, the code stream from RIP on is examined.

Does a legitmate epilog need to include a dummy rsp adjustment even if not otherwise necessary?

余生颓废 提交于 2019-12-06 08:26:58
The x86-64 Windows ABI has the concept of a legitimate epilog , which is a special type of function epilog that can be simulated during exception handling in order to restore the callers context 1 as described here : If the RIP is within an epilog [when an exception occurs], then control is leaving the function, ... and the effects of the epilog must be continued to compute the context of the caller function. To determine if the RIP is within an epilog, the code stream from RIP on is examined. If that code stream can be matched to the trailing portion of a legitimate epilog, then it is in an

How to handle V8 engine crash when process runs out of memory

左心房为你撑大大i 提交于 2019-12-05 20:48:28
问题 Both node console and Qt5's V8-based QJSEngine can be crashed by the following code: a = []; for (;;) { a.push("hello"); } node's output before crash: FATAL ERROR: JS Allocation failed - process out of memory QJSEngine 's output before crash: # # Fatal error in JS # Allocation failed - process out of memory # If I run my QJSEngine test app (see below) under a debugger, it shows a v8::internal::OS::DebugBreak call inside V8 code. If I wrap the code calling QJSEngine::evaluate into __try-_

Issue with exceptions being caught by Win32 message dispatcher

让人想犯罪 __ 提交于 2019-12-05 16:00:29
This is kinda a very low-level type question, but maybe someone here has some insight... I'm having an issue where unhandled SEH exceptions (such as Access Violations) are seemingly being caught at the Win32 message dispatch level, rather than terminating the program. I found the following reference blog, which explains the problem, but in the context of WM_TIMER messages only: http://bugswar.blogspot.com/2010/07/why-its-not-crashing.html I'm experiencing the issue with Win 2008R2, and on "normal" messages (eg: WM_COMMAND, etc.). I suspect it might be Windows trying to "help" by masking

Enable Safe Exception Handling in C++ Builder

北战南征 提交于 2019-12-05 00:10:06
For Windows 8 application certification, there are (among other) these requirements: 3.2 Your app must be compiled using the /SafeSEH flag to ensure safe exceptions handling 3.3 Your app must be compiled using the /NXCOMPAT flag to prevent data execution 3.4 Your app must be compiled using the /DYNAMICBASE flag for address space layout randomization (ASLR) I wasn't able to find out how to enable either of these in C++Builder XE. For /NXCOMPAT and /DYNAMICBASE , one can use editbin.exe from VS or peflags.exe from Cygwin. Though I would feel more confident about possible side-effects, if there

64bit exceptions in WndProc silently fail

余生颓废 提交于 2019-12-04 05:19:25
The following code will give a hard fail when run under Windows 7 32bit: void CTestView::OnDraw(CDC* /*pDC*/) { *(int*)0 = 0; // Crash CTestDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return; // TODO: add draw code for native data here } However, if I try this on Windows 7 64bit, I just get this in the output window: First-chance exception at 0x13929384 in Test.exe: 0xC0000005: Access violation writing location 0x00000000. First-chance exception at 0x77c6ee42 in Test.exe: 0xC0150010: The activation context being deactivated is not active for the current thread of execution. What

What are the consequences of mixing exception handling models in Visual Studio 2010?

孤街浪徒 提交于 2019-12-04 05:13:25
I have third-party static library built with Enable C++ Exceptions set to No ( /EH flag not specified). What are the consequences to calling into it from code built with C++ exceptions enabled ( /EHa )? If a Structured Exception is thrown from within the library, will the function provided to _set_se_translator by the main application be reliably called? (My experiments show that it will, but just wondering if this is defined behavior). Are there any other considerations when mixing /EH exception handing models? Calling into code which does not have exceptions enabled shouldn't produce any

How to handle V8 engine crash when process runs out of memory

一曲冷凌霜 提交于 2019-12-04 03:48:59
Both node console and Qt5's V8-based QJSEngine can be crashed by the following code: a = []; for (;;) { a.push("hello"); } node's output before crash: FATAL ERROR: JS Allocation failed - process out of memory QJSEngine 's output before crash: # # Fatal error in JS # Allocation failed - process out of memory # If I run my QJSEngine test app (see below) under a debugger, it shows a v8::internal::OS::DebugBreak call inside V8 code. If I wrap the code calling QJSEngine::evaluate into __try-__except ( SEH ), then the app won't crash, but this solution is Windows-specific. Question: Is there a way