<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <pre wrap="">Hi, Timur. I may be wrong, but it seems that I faced similar problem before. 

The problem is that Windows checks memory region of exception handler for <span id="posttext-379491">MEM_EXECUTE_OPTION_EXECUTE_DISPATCH_ENABLE flag</span>, that is not set by default and can't be set easily.

Before Windows passes control to your handler it does the following checks:

KiUserExceptionDispatcher ->RtlDispatchException -> RtlIsValidHandler (FAIL)

So you need to enable this flag for your memory-generated code. As far as I know it is impossible if permanent DEP is enabled. So you can either run your process without DEP (not an option in the most cases), or use another way to deal with exceptions. One of the possible workarounds is VEH. You can look through OpenJDK as an example.</pre>
  </body>
</html>