Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. the problem of SEH

the problem of SEH

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    crazyzhou
    wrote on last edited by
    #1

    Hi! Once I used "SetUnhandledExceptionFilter()" function to set my own exception filter function.Then I could turn to the filter function when the exception occured.But the problem was that I could not get the exception information(EXCEPTION_RECORD).I wanted to use "GetExceptionInformation()" to get it,but the compiler prompted:'_exception_info' : bad context for intrinsic function',I could not understand it,why? Thanks!

    B 1 Reply Last reply
    0
    • C crazyzhou

      Hi! Once I used "SetUnhandledExceptionFilter()" function to set my own exception filter function.Then I could turn to the filter function when the exception occured.But the problem was that I could not get the exception information(EXCEPTION_RECORD).I wanted to use "GetExceptionInformation()" to get it,but the compiler prompted:'_exception_info' : bad context for intrinsic function',I could not understand it,why? Thanks!

      B Offline
      B Offline
      Brad Sokol
      wrote on last edited by
      #2

      The function GetExceptionInformation can only be used in the context of an __except block. An easy way to use structured exceptions is to define an SE handler using the C run-time function _set_se_translator(). The CRT takes care of wiring everything together for you, so you don't have to worry about SetUnhandledExceptionFilter etc. You can even avoid __try/__except blocks by throwing a C++ exception. Brad

      C 1 Reply Last reply
      0
      • B Brad Sokol

        The function GetExceptionInformation can only be used in the context of an __except block. An easy way to use structured exceptions is to define an SE handler using the C run-time function _set_se_translator(). The CRT takes care of wiring everything together for you, so you don't have to worry about SetUnhandledExceptionFilter etc. You can even avoid __try/__except blocks by throwing a C++ exception. Brad

        C Offline
        C Offline
        crazyzhou
        wrote on last edited by
        #3

        Brad Sokol: Your solution is good! Thanks very much! Now I can do it well. On the other hand,I have another idea in my exception function,I want to get more information about the locale of exception,such as the information of the stack,like the vc++'s debug tools! Thanks!

        B 1 Reply Last reply
        0
        • C crazyzhou

          Brad Sokol: Your solution is good! Thanks very much! Now I can do it well. On the other hand,I have another idea in my exception function,I want to get more information about the locale of exception,such as the information of the stack,like the vc++'s debug tools! Thanks!

          B Offline
          B Offline
          Brad Sokol
          wrote on last edited by
          #4

          Getting a stack trace including source file and line number is possible in both debug and release builds. The key is the EXCEPTION_POINTERS parameter. You need to use the symbols engine API which is in the dbghelp.dll library in the Platform SDK to translate the exception pointers into more useful information. The best reference I've found for this is "Debugging Windows Applications" by John Robbins. He used to write the Bug Slayer column in MSDN magazine. You can find lots of his archived articles over at the href='http://msdn.microsoft.com'>MSDN site. There is probably lots of useful stuff elswhere on the web but I don't have any links handy. Google for StackWalk or "win32 stack trace" and you'll probably find some useful links. HTH Brad

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups