Author Topic: Exceptions  (Read 13789 times)

Offline Borneq

  • Jr. Member
  • *
  • Posts: 26
Exceptions
« on: December 11, 2012, 04:19:57 PM »
I am interested both: handling exceptions in Windows using Structured Exceptions Handling and in Linux without system aid. On Windows I see example: http://ry.pl/~omega/asm/exc.zip

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Exceptions
« Reply #1 on: December 11, 2012, 05:47:05 PM »
Well... you're probably familiar with the section in the Friendly Manual?
http://www.nasm.us/xdoc/2.10.06/html/nasmdoc7.html#section-7.5.2
That's about all I know about exception handling, safe or otherwise (including Linux). Randy Hyde's HLA uses it. There's some "boilerplate" that has to go in your Nasm code if you want to use the  HLA Standard Library from Nasm code. I never figured out what it did besides "keep the library happy". Could delve into that, if all else fails. :)

I've got some 64-bit code, "exception.asm" and "exceptions.inc" - I don't recall where I got 'em... probably right here. Check the "Example Code" section...

I note that your example is for "-f obj" format (and includes "omeg.inc" which doesn't seem to be in the .zip). Might be a good thing to "upgrade" it to "-f win32" format(?).

Best,
Frank


Offline Borneq

  • Jr. Member
  • *
  • Posts: 26
Re: Exceptions
« Reply #2 on: December 11, 2012, 06:06:40 PM »
Thank for info about HLA and Nasm documentation, examples I give is from http://ry.pl/~omega/?what=asm&lang=en, include is http://ry.pl/~omega/asm/inc.zip

Offline Bryant Keller

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 360
  • Country: us
    • About Bryant Keller
Re: Exceptions
« Reply #3 on: December 11, 2012, 08:53:30 PM »
Probably the best document about Win32 exception handling was written by Jeremy Gordon (developer of GoASM). It's a really good document and explains things in a clear and easy to follow structure.

Structured Exception Handling

About Bryant Keller
bkeller@about.me

Offline Borneq

  • Jr. Member
  • *
  • Posts: 26
Re: Exceptions
« Reply #4 on: December 12, 2012, 11:14:59 PM »
Probably the best document about Win32 exception handling was written by Jeremy Gordon (developer of GoASM). It's a really good document and explains things in a clear and easy to follow structure.

Structured Exception Handling
Yes, this document is OK.

Offline Borneq

  • Jr. Member
  • *
  • Posts: 26
Re: Exceptions
« Reply #5 on: December 13, 2012, 10:00:13 PM »
I try to write code with unwind. I wrote raise http://forum.nasm.us/index.php?topic=1545.0 example but are problems.
In http://godevtool.com/ExceptFrame.htm is "Now we are ready to see how the handler can ensure that execution continues from a safe-place, instead of allowing the process to close, should an exception occur. "
- safe place is a finally place or other?
- RtlUnwind need params: pointer to ERR structure, pointer to exception record. How can give this parameters to RtlUnwind?
pointer to ERR structure I can - it is on stack, but pointer to exception record? I call RtlUnwind not from safe place but from handler, but still are problem - return from RaiseException.
« Last Edit: December 13, 2012, 10:48:57 PM by Borneq »

Offline Bryant Keller

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 360
  • Country: us
    • About Bryant Keller
Re: Exceptions
« Reply #6 on: December 14, 2012, 02:34:33 AM »
- safe place is a finally place or other?

Safe place is the location that your exception handler will continue executing if it was able to recover from the exception.

- RtlUnwind need params: pointer to ERR structure, pointer to exception record. How can give this parameters to RtlUnwind?
pointer to ERR structure I can - it is on stack, but pointer to exception record? I call RtlUnwind not from safe place but from handler, but still are problem - return from RaiseException.

The pointer to the exception record is on the stack at [ebp+8].

About Bryant Keller
bkeller@about.me