Changeset 1335 for trunk/dll/mle.c


Ignore:
Timestamp:
Dec 13, 2008, 12:49:02 AM (17 years ago)
Author:
Steven Levine
Message:

Ticket 26: Add exception handlers to all threads using xbeginthread

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/mle.c

    r1225 r1335  
    77
    88  Copyright (c) 1993-97 M. Kimes
    9   Copyright (c) 2004, 2007 Steven H.Levine
     9  Copyright (c) 2004, 2008 Steven H.Levine
    1010
    1111  01 Aug 04 SHL Rework lstrip/rstrip usage
     
    2121  22 Jun 08 GKY Fixed memory buffer access after it had been freed
    2222  06 Jul 08 GKY Rework LoadThread logic with Steven's help
     23  10 Dec 08 SHL Integrate exception handler support
    2324
    2425***********************************************************************/
     
    2829#include <ctype.h>
    2930#include <share.h>
    30 #include <process.h>                    // _beginthread
     31// #include <process.h>                 // _beginthread
    3132
    3233#define INCL_DOS
     
    5556#include "misc.h"                       // PostMsg
    5657#include "fortify.h"
     58#include "excputil.h"                   // xbeginthread
    5759
    5860static PSZ pszSrcFile = __FILE__;
     
    6062#define FAKEROT 1
    6163#define DOROT13(c)     (!isalpha((c)))?(c):((((c) >= (char) 'A') && \
    62         ((c) <= (char) 'M')) || (((c) >= (char) 'a') && ((c) <= (char) 'm')))?((c) + (char) 0xd)\
    63         :((((c) >= (char) 'N') && ((c) <= (char) 'Z')) || (((c) >= (char) 'n') && ((c) <= (char) 'z')))?\
    64         ((c) - (char) 0xd):(c)
     64        ((c) <= (char) 'M')) || (((c) >= (char) 'a') && ((c) <= (char) 'm')))?((c) + (char) 0xd)\
     65        :((((c) >= (char) 'N') && ((c) <= (char) 'Z')) || (((c) >= (char) 'n') && ((c) <= (char) 'z')))?\
     66        ((c) - (char) 0xd):(c)
    6567
    6668/*((FAKEROT==0)?(c):(FAKEROT==1)?(!isalpha((c)))?(c):((((c) >= (char) 'A') && \
    67         ((c) <= (char) 'M')) || (((c) >= (char) 'a') && ((c) <= (char) 'm')))?((c) + (char) 0xd)\
    68         :((((c) >= (char) 'N') && ((c) <= (char) 'Z')) || (((c) >= (char) 'n') && ((c) <= (char) 'z')))?\
    69         ((c) - (char) 0xd):(c):((c) >= (char) '!') ? ((((c) + (char) 47) > (char) '~') ? ((c) - (char) 47) :\
    70         ((c) + (char) 47)) : (c))*/
     69        ((c) <= (char) 'M')) || (((c) >= (char) 'a') && ((c) <= (char) 'm')))?((c) + (char) 0xd)\
     70        :((((c) >= (char) 'N') && ((c) <= (char) 'Z')) || (((c) >= (char) 'n') && ((c) <= (char) 'z')))?\
     71        ((c) - (char) 0xd):(c):((c) >= (char) '!') ? ((((c) + (char) 47) > (char) '~') ? ((c) - (char) 47) :\
     72        ((c) + (char) 47)) : (c))*/
    7173
    7274LONG MLEgetlinetext(HWND h, LONG l, CHAR * buf, INT maxlen)
     
    196198        bstripcr(temp);
    197199        if (*temp) {
    198           if (ftp) {
    199             if (fFtpRunWPSDefault) {
    200               CHAR WPSDefaultFtpRun[CCHMAXPATH], WPSDefaultFtpRunDir[CCHMAXPATH];
    201 
    202               size = sizeof(WPSDefaultFtpRun);
    203               PrfQueryProfileData(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS",
    204                                   "DefaultBrowserExe", WPSDefaultFtpRun, &size);
    205               size = sizeof(WPSDefaultFtpRunDir);
    206               PrfQueryProfileData(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS",
    207                                   "DefaultWorkingDir", WPSDefaultFtpRunDir, &size);
    208               runemf2(SEPARATE | WINDOWED,
    209                       h, pszSrcFile, __LINE__,
    210                       WPSDefaultFtpRunDir,
    211                       fLibPathStrictFtpRun ? "SET LIBPATHSTRICT=TRUE" : NULL,
    212                       "%s %s", WPSDefaultFtpRun, temp);
    213             }
    214             else
    215               runemf2(SEPARATE | WINDOWED,
    216                       h, pszSrcFile, __LINE__,
    217                       ftprundir, NULL, "%s %s", ftprun, temp);
    218           }
    219           else
    220             if (fHttpRunWPSDefault) {
    221               CHAR WPSDefaultHttpRun[CCHMAXPATH], WPSDefaultHttpRunDir[CCHMAXPATH];
    222 
    223               size = sizeof(WPSDefaultHttpRun);
    224               PrfQueryProfileData(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS",
    225                                   "DefaultBrowserExe", WPSDefaultHttpRun, &size);
    226               size = sizeof(WPSDefaultHttpRunDir);
    227               PrfQueryProfileData(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS",
    228                                   "DefaultWorkingDir", WPSDefaultHttpRunDir, &size);
    229               runemf2(SEPARATE | WINDOWED,
    230                       h, pszSrcFile, __LINE__,
    231                       WPSDefaultHttpRunDir,
    232                       fLibPathStrictHttpRun ? "SET LIBPATHSTRICT=TRUE" : NULL,
    233                       "%s %s", WPSDefaultHttpRun, temp);
    234             }
    235             else
    236               runemf2(SEPARATE | WINDOWED,
    237                       h, pszSrcFile, __LINE__,
    238                       httprundir, NULL, "%s %s", httprun, temp);
     200          if (ftp) {
     201            if (fFtpRunWPSDefault) {
     202              CHAR WPSDefaultFtpRun[CCHMAXPATH], WPSDefaultFtpRunDir[CCHMAXPATH];
     203
     204              size = sizeof(WPSDefaultFtpRun);
     205              PrfQueryProfileData(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS",
     206                                  "DefaultBrowserExe", WPSDefaultFtpRun, &size);
     207              size = sizeof(WPSDefaultFtpRunDir);
     208              PrfQueryProfileData(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS",
     209                                  "DefaultWorkingDir", WPSDefaultFtpRunDir, &size);
     210              runemf2(SEPARATE | WINDOWED,
     211                      h, pszSrcFile, __LINE__,
     212                      WPSDefaultFtpRunDir,
     213                      fLibPathStrictFtpRun ? "SET LIBPATHSTRICT=TRUE" : NULL,
     214                      "%s %s", WPSDefaultFtpRun, temp);
     215            }
     216            else
     217              runemf2(SEPARATE | WINDOWED,
     218                      h, pszSrcFile, __LINE__,
     219                      ftprundir, NULL, "%s %s", ftprun, temp);
     220          }
     221          else
     222            if (fHttpRunWPSDefault) {
     223              CHAR WPSDefaultHttpRun[CCHMAXPATH], WPSDefaultHttpRunDir[CCHMAXPATH];
     224
     225              size = sizeof(WPSDefaultHttpRun);
     226              PrfQueryProfileData(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS",
     227                                  "DefaultBrowserExe", WPSDefaultHttpRun, &size);
     228              size = sizeof(WPSDefaultHttpRunDir);
     229              PrfQueryProfileData(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS",
     230                                  "DefaultWorkingDir", WPSDefaultHttpRunDir, &size);
     231              runemf2(SEPARATE | WINDOWED,
     232                      h, pszSrcFile, __LINE__,
     233                      WPSDefaultHttpRunDir,
     234                      fLibPathStrictHttpRun ? "SET LIBPATHSTRICT=TRUE" : NULL,
     235                      "%s %s", WPSDefaultHttpRun, temp);
     236            }
     237            else
     238              runemf2(SEPARATE | WINDOWED,
     239                      h, pszSrcFile, __LINE__,
     240                      httprundir, NULL, "%s %s", httprun, temp);
    239241        }
    240242      }
     
    609611          free(buffer);
    610612#         ifdef FORTIFY
    611           Fortify_LeaveScope();
     613          Fortify_LeaveScope();
    612614#          endif
    613615        }
     
    813815      }
    814816      else
    815         PostMsg(bkg->hwndReport, bkg->msg, MPVOID, MPVOID);
     817        PostMsg(bkg->hwndReport, bkg->msg, MPVOID, MPVOID);
    816818      DecrThreadUsage();
    817819      WinTerminate(thab);
     
    826828  Fortify_LeaveScope();
    827829#  endif
    828   _endthread();
     830  // _endthread();                      // 10 Dec 08 SHL
    829831}
    830832
     
    837839
    838840  BKGLOAD *bkg;
    839   INT rc;
    840841
    841842  bkg = xmallocz(sizeof(BKGLOAD), pszSrcFile, __LINE__);
     
    848849  bkg->h = h;
    849850  strcpy(bkg->filename, filename);
    850   rc = _beginthread(LoadThread, NULL, 65536, bkg);
    851   if (rc == -1)
    852     Runtime_Error(pszSrcFile, __LINE__,
    853                   GetPString(IDS_COULDNTSTARTTHREADTEXT));
    854   return rc;
     851  return xbeginthread(LoadThread,
     852                      65536,
     853                      bkg,
     854                      pszSrcFile,
     855                      __LINE__);
    855856}
    856857
Note: See TracChangeset for help on using the changeset viewer.