Changeset 1077 for trunk/dll/dircnrs.c


Ignore:
Timestamp:
Jul 18, 2008, 8:11:54 PM (17 years ago)
Author:
Steven Levine
Message:

Enhance Fortify infrastructure
Add Fortify_SetOwner Fortify_ChangeOwner Fortify_ChangeScope
Add FORTIFY_VERBOSE_SCOPE_ENTER_EXIT support
Add more fm/2 Fortify tooling and rework existing tooling for correct nesting
Still lots to do for cross-thread allocations
Add misc.h
Add walkem.h

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/dircnrs.c

    r1065 r1077  
    4242  06 Jul 08 GKY Update delete/undelete to include move to and open XWP trashcan
    4343  11 Jul 08 JBS Ticket 230: Simplified code and eliminated some local variables by incorporating
    44                 all the details view settings (both the global variables and those in the
    45                 DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
     44                all the details view settings (both the global variables and those in the
     45                DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
    4646
    4747***********************************************************************/
     
    7070#include "command.h"                    // RunCommand
    7171#include "fm3dll.h"
    72 #include "avl.h"                        // free_archivers
     72#include "avl.h"                        // free_archivers
    7373#include "fortify.h"
    7474
     
    598598  switch (msg) {
    599599  case WM_CREATE:
     600    DbgMsg(pszSrcFile, __LINE__, "WM_CREATE mp1 %p mp2 %p", mp1, mp2);  // 18 Jul 08 SHL fixme
    600601    break;
    601602
     
    606607    dcd = INSTDATA(hwnd);
    607608    if (fFM2Deletes && dcd) {
    608 
    609609      LISTINFO *li;
    610610      CNRDRAGINFO cni;
    611 
    612611      cni.pRecord = NULL;
    613612      cni.pDragInfo = (PDRAGINFO) mp1;
     
    641640
    642641  case UM_SETUP:
     642#   ifdef FORTIFY
     643    Fortify_EnterScope();
     644#   endif
    643645    dcd = WinQueryWindowPtr(hwnd, QWL_USER);
    644646    if (dcd) {
     647#     ifdef FORTIFY
     648      Fortify_ChangeOwner(dcd);
     649#     endif
    645650      /* set unique id */
    646651      WinSetWindowUShort(hwnd, QWS_ID, DIROBJ_FRAME + (DIR_FRAME - dcd->id));
     
    988993  case UM_MASSACTION:
    989994    if (mp1) {
    990 
    991995      dcd = WinQueryWindowPtr(hwnd, QWL_USER);
    992996      if (dcd) {
    993 
    994997        WORKER *wk;
    995 #       ifdef FORTIFY
    996         Fortify_EnterScope();
    997 #        endif
     998#       ifdef FORTIFY
     999        Fortify_EnterScope();
     1000#       endif
    9981001        wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
    9991002        if (!wk)
     
    10101013            Runtime_Error(pszSrcFile, __LINE__,
    10111014                          GetPString(IDS_COULDNTSTARTTHREADTEXT));
    1012             free(wk);
     1015            free(wk);
    10131016            FreeListInfo((LISTINFO *) mp1);
    1014 #           ifdef FORTIFY
    1015             Fortify_LeaveScope();
    1016 #            endif
    1017           }
    1018         }
     1017          }
     1018        }
     1019#       ifdef FORTIFY
     1020        DosSleep(1);             // Allow MassAction to take ownership
     1021        Fortify_LeaveScope();
     1022#       endif
    10191023      }
    10201024    }
     
    10281032
    10291033        WORKER *wk;
    1030 #       ifdef FORTIFY
    1031         Fortify_EnterScope();
    1032 #        endif
     1034#       ifdef FORTIFY
     1035        Fortify_EnterScope();
     1036#       endif
    10331037        wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
    10341038        if (!wk)
     
    10451049            Runtime_Error(pszSrcFile, __LINE__,
    10461050                          GetPString(IDS_COULDNTSTARTTHREADTEXT));
    1047             free(wk);
     1051            free(wk);
    10481052            FreeListInfo((LISTINFO *) mp1);
    1049 #           ifdef FORTIFY
    1050             Fortify_LeaveScope();
    1051 #            endif
    1052           }
    1053         }
     1053          }
     1054        }
     1055#       ifdef FORTIFY
     1056        Fortify_LeaveScope();
     1057#       endif
    10541058      }
    10551059    }
     
    10911095
    10921096  switch (msg) {
     1097  case WM_CREATE:
     1098#   ifdef FORTIFY
     1099    Fortify_EnterScope();
     1100#   endif
     1101    break;
     1102
    10931103  case DM_PRINTOBJECT:
    10941104    return MRFROMLONG(DRR_TARGET);
     
    12421252
    12431253      if (!IsFile(leftdir) && !IsFile(rightdir)) {
     1254#       ifdef FORTIFY
     1255        Fortify_EnterScope();
     1256#       endif
    12441257        cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
    12451258        if (cmp) {
     
    12531266                    CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
    12541267        }
     1268#       ifdef FORTIFY
     1269        Fortify_LeaveScope();
     1270#       endif
    12551271      }
    12561272    }
     
    20402056        {
    20412057          PCNRITEM pci;
    2042           CHAR path[CCHMAXPATH];
    2043           HOBJECT hObject;
    2044           HWND hwndDesktop;
    2045 
    2046           hObject = WinQueryObject("<XWP_TRASHCAN>");
    2047           if (hObject != NULLHANDLE && fTrashCan) {
    2048             hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
     2058          CHAR path[CCHMAXPATH];
     2059          HOBJECT hObject;
     2060          HWND hwndDesktop;
     2061
     2062          hObject = WinQueryObject("<XWP_TRASHCAN>");
     2063          if (hObject != NULLHANDLE && fTrashCan) {
     2064            hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
    20492065            WinSetFocus(HWND_DESKTOP, hwndDesktop);
    2050             WinOpenObject(hObject, 0, TRUE);
    2051           }
    2052           else {
    2053             pci = (PCNRITEM) CurrentRecord(hwnd);
    2054             if (pci && (INT) pci != -1) {
    2055               strcpy(path, pci->pszFileName);
    2056               MakeValidDir(path);
    2057               WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
    2058                         UNDEL_FRAME, MPFROMP(path));
    2059             }
     2066            WinOpenObject(hObject, 0, TRUE);
     2067          }
     2068          else {
     2069            pci = (PCNRITEM) CurrentRecord(hwnd);
     2070            if (pci && (INT) pci != -1) {
     2071              strcpy(path, pci->pszFileName);
     2072              MakeValidDir(path);
     2073              WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
     2074                        UNDEL_FRAME, MPFROMP(path));
     2075            }
    20602076          }
    20612077        }
     
    20632079
    20642080      case IDM_UNDELETESPEC:
    2065         {
    2066           HOBJECT hObject;
    2067           HWND hwndDesktop;
    2068 
    2069           hObject = WinQueryObject("<XWP_TRASHCAN>");
    2070           if (hObject != NULLHANDLE && fTrashCan) {
    2071             hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
     2081        {
     2082          HOBJECT hObject;
     2083          HWND hwndDesktop;
     2084
     2085          hObject = WinQueryObject("<XWP_TRASHCAN>");
     2086          if (hObject != NULLHANDLE && fTrashCan) {
     2087            hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
    20722088            WinSetFocus(HWND_DESKTOP, hwndDesktop);
    2073             WinOpenObject(hObject, 0, TRUE);
    2074           }
    2075         else
     2089            WinOpenObject(hObject, 0, TRUE);
     2090          }
     2091        else
    20762092          WinDlgBox(HWND_DESKTOP,
    20772093                    hwnd,
    20782094                    UndeleteDlgProc,
    2079                     FM3ModHandle, UNDEL_FRAME, MPFROMP(dcd->directory));
    2080         }
    2081         break;
     2095                    FM3ModHandle, UNDEL_FRAME, MPFROMP(dcd->directory));
     2096        }
     2097        break;
    20822098
    20832099      case IDM_RESORT:
     
    33383354
    33393355      if ((INT)mp1 == 5 || (INT)mp1 == 13 || (INT)mp1 == 21)
    3340         hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
    3341                            (CHAR *)mp2, dcd->hwndFrame);
     3356        hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
     3357                           (CHAR *)mp2, dcd->hwndFrame);
    33423358      else
    3343         hwnd = StartMLEEditor(dcd->hwndParent,
    3344                               (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
     3359        hwnd = StartMLEEditor(dcd->hwndParent,
     3360                              (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
    33453361      xfree((CHAR *)mp2, pszSrcFile, __LINE__);
    33463362      return MRFROMLONG(hwnd);
     
    34003416    DirMenu = DirCnrMenu = FileMenu = (HWND) 0;
    34013417    EmptyCnr(hwnd);
     3418#   ifdef FORTIFY
     3419    Fortify_LeaveScope();
     3420#   endif
    34023421    break;
    34033422  } // switch
     
    34403459  if (!hwndMain && !first) {
    34413460    if (DirCnrMenu) {
    3442 
    34433461      MENUITEM mi;
    3444 
    34453462      memset(&mi, 0, sizeof(mi));
    34463463      WinSendMsg(DirCnrMenu,
     
    34703487#     ifdef FORTIFY
    34713488      Fortify_EnterScope();
    3472 #      endif
     3489#     endif
    34733490      dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
    34743491      if (!dcd) {
     
    35213538                     IDS_WINCREATEWINDOW);
    35223539          PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
    3523           free(dcd);
    3524 #         ifdef FORTIFY
    3525           Fortify_LeaveScope();
    3526 #          endif
     3540          free(dcd);
    35273541          hwndFrame = (HWND) 0;
    35283542        }
     
    35733587        }
    35743588      }
     3589#     ifdef FORTIFY
     3590      Fortify_LeaveScope();
     3591#     endif
    35753592    }
    35763593  }
Note: See TracChangeset for help on using the changeset viewer.