The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: fallenhobbit on January 27, 2005, 02:58:04 PM

Title: A Heavily Commented Example of SEH aimed at newbies
Post by: fallenhobbit on January 27, 2005, 02:58:04 PM
I wrote this example to teach myself how to do structured exception handling. All the code (code or bad) is mine. It shows how to handle an exception and return back to your code block (hopefuilly) unscathed. Feel free to flame me and/or ask me for further clarification.

[attachment deleted by admin]
Title: Re: A Heavily Commented Example of SEH aimed at newbies
Post by: pbrennick on January 27, 2005, 09:21:19 PM
HI fallenhobbit,

fhcrt.dll?  Where can we get this file?

Paul
Title: Re: A Heavily Commented Example of SEH aimed at newbies
Post by: Relvinian on January 27, 2005, 09:32:47 PM
Quote from: pbrennick on January 27, 2005, 09:21:19 PM
HI fallenhobbit,

fhcrt.dll?  Where can we get this file?

Paul


Paul,

In his source file, he has this line:

include fhcrt.inc ;this is my wrapper for the c++ runtime....you can get it at my website "http://students.csci.unt.edu/~jcb0075"


That link he provided has a project he made which will build the .DLL or I guess depending on how you build it a .LIB.

Relvinian
Title: Re: A Heavily Commented Example of SEH aimed at newbies
Post by: pbrennick on January 27, 2005, 09:41:57 PM
Relvinian,
I tried to get it there.  Maybe it is a bandwidth thing.  I will try again later.

Thank you,
Paul
Title: Re: A Heavily Commented Example of SEH aimed at newbies
Post by: fallenhobbit on January 29, 2005, 01:21:27 PM
Yes, fhcrt.dll is in the file fhcrt.zip at my site...,. The dll is just a wrapper for msvcrt.dll, the MS
c++ runtime. I wrote the dll so I could call the c++ runtime using the invoke syntax. The runtime has a lot of functions Id just rather not try and rewrite do to my own laziness. You can of course do the stack cleaning yourself and call the runtime by hand, but thats a major pain to me. The reason you can not directly use invoke to call the runtime is that c++ uses the _cdecl calling convention, while the windows programs you write uses stdcall. Masm wants you to use either/or but not both within a single .obj module (I refer to the .model flat,stdcall line all windows asm programs have).
Title: Re: A Heavily Commented Example of SEH aimed at newbies
Post by: pbrennick on January 29, 2005, 01:48:07 PM
fallenhobbit,
This is a very innovated approach to solve this problem.  Very well done.  I had some problems accessing your webpage but I eventually got the zip that I needed.  Just for grins, whey the convoluted approach?  You could have included it all in one zip.  It isn't that large and edu sites are problematic.  Still, worth the effort, though.

Paul
Title: Re: A Heavily Commented Example of SEH aimed at newbies
Post by: Jibz on January 29, 2005, 03:36:39 PM
Quote from: fallenhobbit on January 29, 2005, 01:21:27 PM
The reason you can not directly use invoke to call the runtime is that c++ uses the _cdecl calling convention, while the windows programs you write uses stdcall. Masm wants you to use either/or but not both within a single .obj module (I refer to the .model flat,stdcall line all windows asm programs have).

The invoke method in masm will use whatever calling convention you tell it to in the prototype, so if you do

strlen PROTO C :DWORD

then invoke will use the c calling convention even if the module the invokation is in has .model flat,stdcall at the top :U.