News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

A Heavily Commented Example of SEH aimed at newbies

Started by fallenhobbit, January 27, 2005, 02:58:04 PM

Previous topic - Next topic

fallenhobbit

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]

pbrennick

HI fallenhobbit,

fhcrt.dll?  Where can we get this file?

Paul

Relvinian

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

pbrennick

Relvinian,
I tried to get it there.  Maybe it is a bandwidth thing.  I will try again later.

Thank you,
Paul

fallenhobbit

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).

pbrennick

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

Jibz

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.