Changeset 1336 for trunk/fm3.c


Ignore:
Timestamp:
Dec 13, 2008, 1:01:10 AM (17 years ago)
Author:
Steven Levine
Message:

Ticket 26: add thread 1 exception handler support to fm3.exe

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/fm3.c

    r1215 r1336  
    1111  05 Jan 08 SHL Sync
    1212  18 Jul 08 SHL Add Fortify support
     13  11 Dec 08 SHL Add exception handler support
    1314
    1415***********************************************************************/
     
    1920#define INCL_WIN
    2021#define INCL_LONGLONG
     22#define INCL_DOSEXCEPTIONS              // XCTP_...
     23#define INCL_DOSERRORS                  // NO_ERROR
    2124
    2225#include "dll\fm3dll.h"
    23 #include "dll\mainwnd.h"                        // Data declaration(s)
     26#include "dll\mainwnd.h"                // Data declaration(s)
    2427#include "dll\tools.h"
    2528#include "dll\version.h"
     
    2831#include "dll\init.h"                   // StartFM3
    2932#include "dll\notebook.h"               // Data declaration(s)
     33#include "dll\errutil.h"                // Error reporting
     34#include "dll\excputil.h"               // Exception handlers
     35
     36static PSZ pszSrcFile = __FILE__;
    3037
    3138int main(int argc, char *argv[])
     
    3542  QMSG qmsg;
    3643  HWND hwndFrame;
     44  APIRET regRet;
     45  EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
    3746
    3847  strcpy(appname, "FM/3");
    3948  DosError(FERR_DISABLEHARDERR);
     49
     50  regRec.ExceptionHandler = HandleException;
     51  regRet = DosSetExceptionHandler(&regRec);
     52  if (regRet != NO_ERROR) {
     53#if 0 // 10 Dec 08 SHL fixme to report later maybe?
     54    Dos_Error(MB_ENTER, regRet, HWND_DESKTOP, pszSrcFile, __LINE__,
     55              "DosSetExceptionHandler");
     56#endif
     57    DbgMsg(pszSrcFile, __LINE__,
     58           "DosSetExceptionHandler failed with error %u", regRet);
     59  }
     60
    4061  hab = WinInitialize(0);
    4162  if (hab) {
     
    7899              break;
    79100          }
     101          Fortify_DumpAllMemory();
    80102#         endif
    81103        }
     
    86108    WinTerminate(hab);
    87109  }
     110
     111  if (regRet == NO_ERROR) {
     112    regRet = DosUnsetExceptionHandler(&regRec);
     113    if (regRet != NO_ERROR) {
     114      DbgMsg(pszSrcFile, __LINE__,
     115             "DosUnsetExceptionHandler failed with error %u", regRet);
     116    }
     117  }
    88118  return 0;
    89119}
Note: See TracChangeset for help on using the changeset viewer.