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#
  4. exception handling for another program, is it possible in c#?

exception handling for another program, is it possible in c#?

Scheduled Pinned Locked Moved C#
tutorialquestioncsharpdebuggingperformance
3 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
    Cptkli
    wrote on last edited by
    #1

    For example, if i VirtualProtectEx portion of memory of another program, with page guard or no access, how can i handle the exception when it will be raised, and get exception informations like registers value ect...? I think to handle the exception my program would require enabled debug privileges which i know how to code but then i don't know how to set a top level exception filter. I am still learning so any help would be great. :)

    D 1 Reply Last reply
    0
    • C Cptkli

      For example, if i VirtualProtectEx portion of memory of another program, with page guard or no access, how can i handle the exception when it will be raised, and get exception informations like registers value ect...? I think to handle the exception my program would require enabled debug privileges which i know how to code but then i don't know how to set a top level exception filter. I am still learning so any help would be great. :)

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Cptkli wrote:

      For example, if i VirtualProtectEx portion of memory of another program, with page guard or no access, how can i handle the exception when it will be raised, and get exception informations like registers value ect...?

      You can't. Your code will never see the exception. This would require a technique called ".DLL Injection", which is something that C# alone cannot do because of the .DLL library requirements of the technique. This is a very advanced technique. Not something for beginners to try and pull off.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      C 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Cptkli wrote:

        For example, if i VirtualProtectEx portion of memory of another program, with page guard or no access, how can i handle the exception when it will be raised, and get exception informations like registers value ect...?

        You can't. Your code will never see the exception. This would require a technique called ".DLL Injection", which is something that C# alone cannot do because of the .DLL library requirements of the technique. This is a very advanced technique. Not something for beginners to try and pull off.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008

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

        But i did read it's possible to replace the exception handler of a program without injecting any code with the SetUnhandledExceptionFilter api. It replaces the existing top-level exception filter of the targeted program. Is it wrong?

        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