home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Stone / windows / excep.inc < prev    next >
Encoding:
Text File  |  2000-05-25  |  1020 b   |  54 lines

  1. Comment % This snippet will set an ExceptionFrame which will allow structured
  2.       exception handling in tasm-PROC's. It's particularly well-suited for
  3.       parameter verification layers - the purpose for which it was designed.
  4.       It's quite crude but very efficient.
  5.  
  6.       Notice you should only use this in single threaded processes
  7.  
  8.  
  9.       You may use this snippet at your OWN risc. 
  10.  
  11.       2nd&mi
  12.       Stone
  13.       email: stone@one.se
  14.       http://www.cracking.net
  15.  
  16.  
  17.     %
  18. SetExceptionFrame Macro 
  19.     xor    edx,edx
  20.     push    offset @@ErrHandler
  21.     push    dword ptr fs:[edx]
  22.     mov    [OldStack], esp
  23.     mov    [OldEbp], ebp
  24.  
  25.     mov    fs:[edx], esp    
  26.     jmp    @@Continiue
  27.  
  28. @@ErrHandler:            ; This will execute in event of an error
  29. ;    int 3
  30.     mov    esp, [OldStack]
  31.     mov    ebp, [OldEbp]
  32.     pop    edx
  33.     mov    fs:[0],edx
  34.  
  35.     pop    eax        ; adjust stack
  36.     xor    eax,eax        ; Return False
  37.     ret
  38.  
  39. @@Continiue:
  40. EndM
  41.  
  42. RestoreExceptionFrame Macro
  43.     pop    edx
  44.     mov    fs:[0],edx
  45.     pop    edx        ; adjust stack
  46. EndM
  47.  
  48.  
  49. .data
  50.     OldStack    dd 0    ; static data
  51.     OldEbp        dd 0
  52.  
  53.  
  54.