The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: MusicalMike on August 24, 2006, 07:35:40 PM

Title: Exceptions in Asm
Post by: MusicalMike on August 24, 2006, 07:35:40 PM
How do I impliment exception handling in assembly language?
Title: Re: Exceptions in Asm
Post by: Biterider on August 24, 2006, 08:44:23 PM
Hi
there are several places where you can get the SEH implementation. OA32 has a file called SEH.inc in the macros directory containing supporting macros for this Windows functionality. Keep an eye on VEH for newer OSs.

Regards,

Biterider
Title: Re: Exceptions in Asm
Post by: zooba on August 24, 2006, 11:44:44 PM
My ASM Runtime (http://www.masm32.com/board/index.php?topic=3148.45) has macros for implementing exception handling as well as a built in exception handler which will catch everything (except an INT3) and print a nice message on the console.

If you don't want to start using a new library, check out Jeremy Gordon's exception handling (http://www.jorgon.freeserve.co.uk/Except/Except.htm) tutorial. There are also macro sets out there for exception handling. Use Google.

Cheers,

Zooba
Title: Re: Exceptions in Asm
Post by: MusicalMike on August 25, 2006, 12:08:13 AM
I was hoping for something that was OS independent.
Title: Re: Exceptions in Asm
Post by: ToutEnMasm on August 25, 2006, 05:44:26 AM
Hello,
Os independant is possible only if you have a computer without system.
You can also try to make a system driver.
Good work.
With a system and symbolic debugging ,you can have other thing that a "nice messagebox" .You can have the name of the source file and the line where the exception occure.
Exceptions are not the only way to debug an application and others methods are needed to complete debugging.
Samples that are in the internet are a little old,and use only FS:0 to instal the exceptions.XP provide functions that works better,look at the SDK (SEH et VEH)

                               ToutEnMasm
Title: Re: Exceptions in Asm
Post by: zooba on August 25, 2006, 06:30:58 AM
For OS independent, you just have to check everything before you use it (ie. memory pointers, divisors, etc.).

Of course, OS independent is incredibly hard in assembly language, especially if you're doing anything complicated enough to require SEH. Perhaps you could investigate the output created by a C compiler to find out what is compiled for Windows, *nix and MacOS. I can't imagine any need to be more independent than this.

Cheers,

Zooba :U

Edit: Removed bad words
Title: Re: Exceptions in Asm
Post by: PBrennick on August 25, 2006, 11:51:00 AM
Why is it we are hearing more about reverse engineering, lately.  zooba, you are a disappointment to me.  You should not post such words.  If you feel strongly about it, use PM next time.  Be admonished.

Paul
Title: Re: Exceptions in Asm
Post by: Vortex on August 25, 2006, 05:30:53 PM
QuotePerhaps you could reverse-engineer some C code to find out what is compiled for...

zooba, why r*verse-engineering? The net offers a lot of material to study about structural exception handling.
Title: Re: Exceptions in Asm
Post by: Mark Jones on August 25, 2006, 06:46:54 PM
This battle is a lesson in futility; save your breath.
Title: Re: Exceptions in Asm
Post by: MusicalMike on August 25, 2006, 07:31:07 PM
Hey, I never said anything about reverse engineering. I do not want to reverse engineer anything. And I am sure as hell not going to do anything illegal. So, please keep those things out of the threads.
Title: Re: Exceptions in Asm
Post by: PBrennick on August 25, 2006, 07:55:30 PM
Yes, I understand how you feel.  YOUR posting was quite proper and your wish that this type of thing be left out of your thread is commendable.

Paul
Title: Re: Exceptions in Asm
Post by: zooba on August 26, 2006, 08:54:27 AM
I've clarified my meaning. I never meant disassemble other peoples programs, simply to create and compile a C program using SEH and then check the output.

9 times out of 10 the information on the net will have been found this way. Using the output and source to find the process is one valid (and legal) definition of reverse-engineering.

From Jeremy Gordon's tutorial:
QuoteThe information in this article was obtained using a test program and a debugger, and by disassembling code produced by "C" compilers.
Title: Re: Exceptions in Asm
Post by: PBrennick on August 26, 2006, 11:36:37 AM
zooba,
You just don't give up.  I am done with you.  You cannot justify your actions by the actions of others.  It looks like Mark Jones said it best.  Thank you Mark, I will follow your advice.
Paul
Title: Re: Exceptions in Asm
Post by: japheth on August 26, 2006, 01:03:49 PM

I don't understand the issue here: is it forbidden now to let a C compiler create an assembly listing and examine the listing then? AFAICS this is what zooba suggested. ??? Confused.
Title: Re: Exceptions in Asm
Post by: hutch-- on August 26, 2006, 01:15:59 PM
I honestly don't know what the big deal is about, its common practice to write a test piece in C, compile it with the assembler output option then play with the assembler output. Its a perfectly viable method to look at compiled output that has nothing to do with reverse engineering.

Now cracking other peoples software is another matter, it involves working on someone elses binary without their permission which we will not allow in here but normal investigation of compiled output from a compiler is the option of the owner so there is nothing wrong with it at all.
Title: Re: Exceptions in Asm
Post by: PBrennick on August 26, 2006, 01:40:05 PM
Hutch,
Cracking others code is EXACTLY what zooba was talking about.  It is the ONLY interpretation that makes sense as MusicalMike obviously has no code of his own.  How come this is not obvius to you and Japheth?

Japheth, never was letting a C compiler create an assembly listing and examine the listing EVER discussed.  If you think otherwise, please show me where.  Postings such as your just confuse the issue.  Read carefully next time.  :U

Paul
Title: Re: Exceptions in Asm
Post by: PBrennick on August 26, 2006, 02:41:15 PM
Since zooba has modify his posting to remove the words Reverse Engineer in the post that Vortex and I re-acted to, that may be the cause for the confusion here.

Paul

Title: Re: Exceptions in Asm
Post by: hutch-- on August 26, 2006, 02:50:52 PM
Guys,

can we just give up on this one, its just a semantic issue where the term "reverse engineering" can be pointed at a wider range than just illegal cracking of commercial software. The admin well know the difference and this has been a non-issue so there is simply nothing to argue about.

I am closing the topic as it has generated more noise than content. Rest assured that the admin team spot any illegal stuff very quickly and act on it just as quickly.