home *** CD-ROM | disk | FTP | other *** search
- (*
- * DlphiErr.dpr
- * $Header: /BoundsChecker/Examples/BUGBNCHX/DLPHIERR/DLPHIERR.DPR 7 4/03/97 11:41a Bob $
- *
- * Description:
- * Defines the interface to the DlphiErr bug module.
- *
- * Notes:
- * <implementation notes go here>
- *
- ***********************************************************************
- *
- * Nu-Mega Technologies, Inc.
- * P.O. Box 7780
- * Nashua, NH 03060
- *
- * (c) Copyright 1994, 1995 Nu-Mega Technologies, Inc.
- * ALL RIGHTS RESERVED.
- *
- ***********************************************************************
- *
- **********************************************************************)
-
- library DlphiErr;
-
- uses CommCtrl, Sysutils, Windows;
- {$R dlphierr.res}
- {$I memory.pas}
- {$I apierr.pas}
- {$I dlphirsr.pas}
- {$I bcerrtyp.pas}
-
- (***********************************************************************)
- (* DlphiErr Constants *)
- const
- constMaxLParam = 1024 ; (* Max number of nodes in the tree *)
- constNumRootObjects = 3 ; (* Max number of root nodes in the tree *)
- constMaxErrsPerCategory = 11 ; (* Max number of errors per category *)
- constMaxNumErrorFuncs = 15 ; (* Max number of leaf nodes in the tree *)
- constMaxErrsPerType = 3 ; (* Max number of errors per root middle node *)
- constNumRandomFuncs = 5 ; (* Number of error funcs to call on DoRandom *)
-
- szModName = 'DlphiErr.bug' ; (* The name of this module *)
-
- (* The root objects that will be placed in the tree control that define the error
- categories. *)
- g_RootObjects : array[0..constNumRootObjects] of ErrorCategory =
- (
- (
- uiCategory : IDS_APIANDOLECHECK ;
- uiDescription : IDS_APIANDOLECHECKDESC
- ) ,
- (
- uiCategory : IDS_MEMORYCHECK ;
- uiDescription : IDS_MEMORYCHECKDESC
- ) ,
- (
- uiCategory : IDS_POINTERANDLEAKCHECK ;
- uiDescription : IDS_POINTERANDLEAKCHECKDESC
- ) ,
- (
- uiCategory : 0 ;
- uiDescription : 0
- )
- ) ;
-
- (* The middle nodes of the tree that describe the type of error *)
- g_ArrayOfTypes : array[0..constNumRootObjects, 0..constMaxErrsPerCategory] of ErrorType =
- (
- (*API and OLE Check Types*)
- (
- ( (* 1 1 *)
- uiError : IDS_APIFAILWINFUNCFAIL;
- bPersonalDoes : True
- ),
- ( (* 1 2 *)
- uiError : IDS_INVALIDARGGENERAL;
- bPersonalDoes : True
- ),
- ( (* 1 3 *)
- uiError : IDS_INVALIDARGBADDESTPTR;
- bPersonalDoes : True
- ),
- ( (* 1 4 *)
- uiError : IDS_INVALIDARGBADHANDLE;
- bPersonalDoes : True
- ),
- ( (* 1 5 *)
- uiError : IDS_INVALIDARGBADSRCPTR;
- bPersonalDoes : True
- ),
- ( (* 1 6 *)
- uiError : IDS_INVALIDARGSTRUCTURE ;
- bPersonalDoes : True
- ),
- ( (* 1 7 *)
- uiError : IDS_INVALIDARGOUTORANGE;
- bPersonalDoes : True
- ),
- ( (* 1 8 *)
- uiError : IDS_INVALIDARGCONFLICT;
- bPersonalDoes : True
- ),
- ( (* 1 9 *)
- uiError : IDS_INVALIDARGUNDEFINED;
- bPersonalDoes : True
- ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False )
- ),
- (* Memory Check Types *)
- (
- ( (* 2 1 *)
- uiError : IDS_DYNMEMOVERRUN;
- bPersonalDoes : True
- ),
- ( (* 2 2 *)
- uiError : IDS_INVALIDARGFREEDHANDLELOCK;
- bPersonalDoes : True
- ),
- ( (* 2 3 *)
- uiError : IDS_INVALIDARGHANDLEUNLOCKED;
- bPersonalDoes : True
- ),
- ( (* 2 4 *)
- uiError : IDS_STACKMEMOVERRUN;
- bPersonalDoes : True
- ),
- ( (* 2 5 *)
- uiError : IDS_PTRREFSUNLOCKEDBLOCK;
- bPersonalDoes : True
- ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False )
- ),
- (* Leak and Pointer Check Types *)
- (
- ( (* 3 1 *)
- uiError : IDS_MEMLEAK;
- bPersonalDoes : True
- ),
- ( (* 3 2 *)
- uiError : IDS_RESOURCELEAK;
- bPersonalDoes : True
- ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False )
- ),
- (* Sentinel *)
- (
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False ),
- ( uiError : 0 ; bPersonalDoes : False )
- )
- );
-
- g_aOccurArray : array [0..constMaxNumErrorFuncs, 0..constMaxErrsPerType] of ErrorOccurance =
- (
- (* APICheck - API failure: Windows function failed *)
- ( (* 1 1 *)
- (
- uiInstance : IDS_APIFAILLOADBITMAPINST ;
- uiDescription : IDS_APIFAILLOADBITMAPDESC ;
- pFunc : LoadBitmapFail
- ),
- (
- uiInstance : IDS_APIFAILLOADMENUINST ;
- uiDescription : IDS_APIFAILLOADMENUDESC ;
- pFunc : LoadMenu_Fail
- ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL )
- ),
- (* APICheck - Invalid argument *)
- ( (* 1 2 *)
- (
- uiInstance : IDS_APIINVALIDARGGETTEXTCOLORINST ;
- uiDescription : IDS_APIINVALIDARGGETTEXTCOLORDESC ;
- pFunc : GetTextColor_Bad_Param
- ),
- (
- uiInstance : IDS_APIINVALIDARGDELETEMENUINST ;
- uiDescription : IDS_APIINVALIDARGDELETEMENUDESC ;
- pFunc : DeleteMenu_Bad_Param
- ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL )
- ),
- (* APICheck - Invalid argument: Bad destination pointer *)
- ( (* 1 3 *)
- (
- uiInstance : IDS_APISTRCOPYBADDESTPTRINST ;
- uiDescription : IDS_APISTRCOPYBADDESTPTRDESC ;
- pFunc : BadDestPtr
- ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL )
- ),
- (* APICheck - Invalid argument: Bad handle *)
- ( (* 1 4 *)
- (
- uiInstance : IDS_APIFREEMEMBADHANDLEINST ;
- uiDescription : IDS_APIFREEMEMBADHANDLEDESC ;
- pFunc : BadFreeMem
- ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL )
- ),
- (* APICheck - Invalid argument: Bad source pointer *)
- ( (* 1 5 *)
- (
- uiInstance : IDS_APISTRCOPYBADSRCPTRINST ;
- uiDescription : IDS_APISTRCOPYBADSRCPTRDESC ;
- pFunc : BadSourcePointer
- ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL )
- ),
- (* APICheck - Invalid argument: Structure size field is not initialized *)
- ( (* 1 6 *)
- (
- uiInstance : IDS_APIGETVERSIONSTRUCTSIZEINST ;
- uiDescription : IDS_APIGETVERSIONSTRUCTSIZEDESC ;
- pFunc : UninitSizeField
- ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL )
- ),
- (* APICheck - Invalid argument: Out of range *)
- ( (* 1 7 *)
- (
- uiInstance : IDS_APIOUTOFRANGEINST ;
- uiDescription : IDS_APIOUTOFRANGEDESC ;
- pFunc : OutOfRange_GetKeyState
- ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL )
- ),
- (* APICheck - Invalid argument: Conflicting combination of flags *)
- ( (* 1 8 *)
- (
- uiInstance : IDS_APICONFLICTFLAGSGETSTRINGTYPEINST ;
- uiDescription : IDS_APICONFLICTFLAGSGETSTRINGTYPEDESC ;
- pFunc : ConflictingFlags_GetStringType
- ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL )
- ),
- (* APICheck - Invalid argument: Undefined or illegal flags *)
- ( (* 1 9 *)
- (
- uiInstance : IDS_APIILLEGALFLAGSAPPENDMENUINST ;
- uiDescription : IDS_APIILLEGALFLAGSAPPENDMENUDESC ;
- pFunc : IllegalFlags_AppendMenu
- ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL )
- ),
- (* Memory Check - Dynamic memory overrun *)
- ( (* 2 1 *)
- (
- uiInstance : IDS_WRITEDYNOVERRUNINST ;
- uiDescription : IDS_WRITEDYNOVERRUNDESC ;
- pFunc : DynamicOverrun
- ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL )
- ),
- (* Memory Check - Freed handle is still locked *)
- ( (* 2 2 *)
- (
- uiInstance : IDS_APIGLOBALFREELOCKINST ;
- uiDescription : IDS_APIGLOBALFREELOCKDESC ;
- pFunc : HandleLocked
- ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL )
- ),
- (* Memory Check - Handle is already unlocked *)
- ( (* 2 3 *)
- (
- uiInstance : IDS_APIGLOBALFREEUNLOCKINST ;
- uiDescription : IDS_APIGLOBALFREEUNLOCKDESC ;
- pFunc : HandleUnlocked
- ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL )
- ),
- (* Memory Check - Stack memory overrun *)
- ( (* 2 4 *)
- (
- uiInstance : IDS_WRITESTACKOVERRUNSTRCOPYINST ;
- uiDescription : IDS_WRITESTACKOVERRUNSTRCOPYDESC ;
- pFunc : StackOverrun
- ),
- (
- uiInstance : IDS_WRITESTACKOVERRUNFILLCHARINST ;
- uiDescription : IDS_WRITESTACKOVERRUNFILLCHARDESC ;
- pFunc : StackOverrun_FillChar
- ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL )
- ),
- (* Memory Check - Pointer references unlocked memory block *)
- ( (* 2 5 *)
- (
- uiInstance : IDS_PTRREFUNLOCKINST ;
- uiDescription : IDS_PTRREFUNLOCKDESC ;
- pFunc : Ptr_Refs_Unlocked_Block
- ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL )
- ),
- (* LeakCheck - Memory Leak (Allocate but do not free) *)
- ( (* 3 1 *)
- (
- uiInstance : IDS_MEMALLOCMEMINST ;
- uiDescription : IDS_MEMALLOCMEMDESC ;
- pFunc : AllocMem_Leak
- ),
- (
- uiInstance : IDS_MEMSTRALLOCINST ;
- uiDescription : IDS_MEMSTRALLOCDESC ;
- pFunc : StrAlloc_Leak
- ),
- (
- uiInstance : IDS_MEMSTRNEWINST ;
- uiDescription : IDS_MEMSTRNEWDESC ;
- pFunc : MemoryLeak_StrNew
- ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL )
- ),
- (* LeakCheck - Resource Leak *)
- ( (* 3 2 *)
- (
- uiInstance : IDS_RESBITMAPINST ;
- uiDescription : IDS_RESBITMAPDESC ;
- pFunc : BitmapLeak
- ),
- (
- uiInstance : IDS_RESMENUINST ;
- uiDescription : IDS_RESMENUDESC ;
- pFunc : MenuLeak
- ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL ),
- ( uiInstance : 0; uiDescription : 0; pFunc : NIL )
- )
- );
-
-
-
- (***********************************************************************)
- (* DlphiErr Variables *)
- var
- SaveExit : Pointer ; (* Required for DLLs *)
- g_nLParam : Integer ; (* The current number of LParamInfo
- objects in the array, g_lParamArray *)
-
- (* The array of LParamInfo objects that will need to be disposed of
- before this DLL is unloaded. *)
- g_lParamArray : array [ 0..constMaxLParam ] of PLParamInfo ;
-
-
-
-
-
- (***********************************************************************)
- (* GetChildWithName checks the tree control for an item with the name,
- szName under the item hParent. If it is there, it returns the child
- item. Otherwise, it returns NIL. *)
- function GetChildWithName ( hwnd : HWND; hParent : HTreeItem; szName : PChar ) : HTreeItem ;
- var
- hChild : HTreeItem ; (* The current child item *)
- hReturn : HTreeItem ; (* The item to be returned *)
- tviChild : TTVItem ; (* Info about the current child *)
- bFoundIt : Boolean ; (* True if the child is found *)
-
- (* Name of the current child *)
- szChildText : array [ 0..1023 ] of Char ;
- begin
- (* Initialize return value *)
- hReturn := NIL;
-
- (* Loop through the children of hParent. If a match on
- szName is found, break out of the loop and return
- the child *)
- hChild := TreeView_GetChild ( hWnd , hParent ) ;
- while ( NIL <> hChild ) do
- begin
-
- (* Initialize the info record to just get the text
- associated with the current child item. *)
- tviChild.mask := TVIF_TEXT or TVIF_HANDLE ;
- tviChild.hItem := hChild ;
- tviChild.pszText := @(szChildText[0]) ;
- tviChild.cchTextMax := 1024 ;
-
- (* Get the child item and compare its text to szName. *)
- if ( TreeView_GetItem ( hWnd , tviChild ) ) then
- begin
- if ( 0 = StrComp ( szName , tviChild.pszText ) ) then
- begin
- hReturn := hChild ;
- Break ;
- end;
- end;
-
- hChild := TreeView_GetNextItem ( hWnd , hChild , TVGN_NEXT ) ;
- end; (* while *)
-
- GetChildWithName := hReturn ;
- end; (* Function GetChildWithName *)
-
- (***********************************************************************)
- (* DlphiErr procedures to support the BugModule DLL interface *)
-
- (* PopulateTree is the only required procedure for the BugModule
- DLL interface. Given an HWND of a tree control, populate the
- tree with named nodes that do not already exist. The tree
- must have the ErrorCategories at the roots, ErrorTypes as
- children of ErrorCategories and ErrorOccurances as leaf nodes.
- If any named node exists, don't add it twice. *)
- procedure PopulateTree ( hwndTree: HWND ); cdecl;export;
- var
- stTVIS : TTVInsertStruct ; (* General purpose insert structure *)
- hItemLevel1 : HTreeItem ; (* Current category item *)
- hItem : HTreeItem ; (* Current type or occurence item *)
- pstEC : ^ErrorCategory ; (* Current category record *)
- i_pstEC : Integer ; (* Current category index *)
- pstET : ^ErrorType ; (* Current error type record *)
- i_pstET : Integer ; (* Current error type index *)
- pstEO : ^ErrorOccurance ; (* Current error occurence record *)
- i_pstEO : Integer ; (* Current error occurence index *)
- iCurrTypes : Integer ; (* Index to the type array *)
- iCurrErrorOccur : Integer ; (* Index to the occurence array *)
- bLoadedStrings : Boolean ; (* True if all resources loaded *)
- pLPI : PLParamInfo ; (* Current LParamInfo record *)
-
- (* Contains current string loaded from resource table *)
- szBuff : array[0..1024] of Char ;
- begin
-
- (* Initialize global array indices *)
- iCurrTypes := 0 ;
- iCurrErrorOccur := 0 ;
- g_nLParam := 0 ;
-
- (* Initialize procedural flags *)
- bLoadedStrings := True;
-
- (* Initialize the insert structure to always insert at the end of the
- tree control and only use the text and LPARAM fields. *)
- stTVIS.hParent := NIL ;
- stTVIS.hInsertAfter := TVI_SORT ;
- stTVIS.item.mask := TVIF_TEXT or TVIF_PARAM ;
-
- (* Start with the root objects array. *)
- i_pstEC := 0 ;
- pstEC := @(g_RootObjects[i_pstEC]) ;
-
- (* Loop through the categories, inserting our own root objects only
- if they are not already present (detected with GetChildWithName. *)
- while ( 0 <> pstEC^.uiCategory ) do
- begin
- (* When filling root objects, always force the parent to NIL. *)
- stTVIS.hParent := NIL ;
-
- (* The root object category string is used as the text so
- load it. *)
- if ( 0 = LoadString ( GetModuleHandle ( szModName ) ,
- pstEC^.uiCategory ,
- szBuff ,
- 1024 ) ) then
- begin
- bLoadedStrings := False ;
- Break ;
- end ;
-
- (* Set the text for the item. *)
- stTVIS.item.pszText := szBuff ;
- (* Allocate the structure that we store in the lParam field and
- save it in the global LParamInfo array for later disposal. *)
- New(pLPI) ;
- g_lParamArray[ g_nLParam ] := pLPI ;
- g_nLParam := g_nLParam + 1 ;
-
- (* This is a root object. *)
- pLPI^.iType := 0 ;
- pLPI^.hModule := GetModuleHandle ( szModName ) ;
-
- (* Set the union to the current value. *)
- pLPI^.stEC := pstEC^ ;
- (* Set the lParam and insert it saving off the HTREEITEM. *)
- stTVIS.item.lParam := LPARAM(pLPI) ;
-
- hItemLevel1 := GetChildWithName ( hwndTree , stTVIS.hParent , szBuff ) ;
-
- if ( NIL = hItemLevel1 ) then
- begin
- hItemLevel1 := TreeView_InsertItem ( hwndTree , stTVIS ) ;
- end;
-
- (* Now fill in the error types for this root object.
- Get the current part of the two dimensional types array and
- loop until we hit the NIL value. *)
- i_pstET := 0 ;
- pstET := @ ( g_ArrayOfTypes[ iCurrTypes ][ i_pstET ] ) ;
- while ( 0 <> pstET^.uiError ) do
- begin
- (* The parent for the current type. *)
- stTVIS.hParent := hItemLevel1 ;
- (* The error string serves as the text for the tree so load it
- and set it. *)
- if ( 0 = LoadString ( GetModuleHandle ( szModName ) ,
- pstET^.uiError ,
- szBuff ,
- 1024 ) ) then
- begin
- bLoadedStrings := False ;
- Break ;
- end ;
-
- stTVIS.item.pszText := szBuff ;
- (* Allocate the structure we set in lParam. *)
- New ( pLPI ) ;
- g_lParamArray[ g_nLParam ] := pLPI ;
- g_nLParam := g_nLParam + 1 ;
-
- (* This is a level one item. *)
- pLPI^.iType := 1 ;
- pLPI^.stET := pstET^ ;
- pLPI^.hModule := GetModuleHandle ( szModName ) ;
- (* Set the lParam and insert it into the tree. *)
- stTVIS.item.lParam := LPARAM(pLPI) ;
-
- hItem := GetChildWithName ( hwndTree , stTVIS.hParent , szBuff ) ;
- if ( NIL = hItem ) then
- begin
- hItem := TreeView_InsertItem ( hwndTree , stTVIS ) ;
- end;
-
- (* Fill in the error occurrences (leaves) for this type.
- Get the current portion of the two dimensional occurrence
- array. *)
- i_pstEO := 0;
- pstEO := @ ( g_aOccurArray[ iCurrErrorOccur ][ i_pstEO ] ) ;
- stTVIS.hParent := hItem ;
-
- while ( 0 <> pstEO^.uiInstance ) do
- begin
- (* The instance serves as the text for the tree. Load it
- and set it. *)
- if ( 0 = LoadString ( GetModuleHandle ( szModName ) ,
- pstEO^.uiInstance ,
- szBuff ,
- 1024 ) ) then
- begin
- bLoadedStrings := False ;
- Break ;
- end ;
-
- stTVIS.item.pszText := szBuff ;
- (* Allocate the structure we put in lParam. *)
- New ( pLPI ) ;
- g_lParamArray[ g_nLParam ] := pLPI ;
- g_nLParam := g_nLParam + 1 ;
-
- (* This is a leaf node. *)
- pLPI^.iType := 2 ;
- pLPI^.stEO := pstEO^ ;
- pLPI^.hModule := GetModuleHandle ( szModName ) ;
-
- (* Set the lParam and insert it. *)
- stTVIS.item.lParam := LPARAM(pLPI) ;
-
- if ( GetChildWithName ( hwndTree , stTVIS.hParent , szBuff ) = NIL ) then
- begin
- TreeView_InsertItem ( hwndTree , stTVIS ) ;
- end;
-
- (* Get the next item in the occurrence array. *)
- i_pstEO := i_pstEO + 1 ;
- pstEO := @ ( g_aOccurArray[ iCurrErrorOccur ][ i_pstEO ] ) ;
- end; (* loop on occurances *)
- (* Get the next error type. *)
- i_pstET := i_pstET + 1 ;
- pstET := @ ( g_ArrayOfTypes[ iCurrTypes ][ i_pstET ] ) ;
-
- (* Bump up the occurrence item index. *)
- iCurrErrorOccur := iCurrErrorOccur + 1 ;
- if ( not bLoadedStrings ) then
- Break ;
- end;
-
- (* Bump up the types item index. *)
- iCurrTypes := iCurrTypes + 1 ;
- (* Get the next category. *)
- i_pstEC := i_pstEC + 1 ;
- pstEC := @(g_RootObjects[i_pstEC]) ;
-
- if ( not bLoadedStrings ) then
- Break ;
- end; (* loop on categories *)
-
- if ( bLoadedStrings ) then
- TreeView_SelectItem ( hwndTree , hItemLevel1 );
-
- end; (* Procedure PopulateTree *)
-
- (* An optional BugModule DLL interface procedure used to perform
- clean-up on memory allocated for use by the tree control. *)
- procedure DePopulateTree ( hwndTree: HWND ); export;
- var
- i : Integer ;
- begin
- for i := 0 to g_nLParam do
- Dispose ( g_lParamArray[ i ] ) ;
- end;
-
- (* An optional BugModule DLL interface procedure used to execute
- random bugs. *)
- procedure DoRandomErrors ; export ;
- var
- iLoop : Integer ;
- iType : Integer ;
- iOccur : Integer ;
- begin
- (* Reseed each time. *)
- randomize ;
-
- for iLoop := 0 to ( constNumRandomFuncs -1 )do
- begin
- (* Pick one of the error types to do. *)
- iType := random ( constMaxNumErrorFuncs );
-
- (* Now pick one of the occurrences for this type.
- Since many have just one item, we will check for that occurrence
- as a special case. If it does have a single item, then we
- will just call it. *)
- if ( not Assigned ( g_aOccurArray[ iType ][ 1 ].pFunc ) ) then
- begin
- (* Double check that the function is not NULL. If it is, then
- we will not call it. *)
- if ( Assigned ( g_aOccurArray[ iType ][ 0 ].pFunc ) ) then
- begin
- g_aOccurArray[ iType ][ 0 ].pFunc ( ) ;
- end;
- end
- else
- begin
-
- (*We have one of the rare ones that have multiple functions.
- We will loop looking for a random valid one, then call it. *)
- iOccur := random ( constMaxErrsPerType );
-
- while ( not Assigned ( g_aOccurArray[ iType ][ iOccur ].pFunc ) ) do
- begin
- iOccur := random ( constMaxErrsPerType );
- end;
- g_aOccurArray[ iType ][ iOccur ].pFunc ( ) ;
- end; (* if-then-else *)
- end; (* for *)
-
- end; (* Procedure DoRandomErrors *)
-
- (* An optional BugModule DLL Interface procedure to execute every bug
- supported by this module. *)
- procedure DoAllErrors ;
- var
- iType : Integer ;
- iOccur : Integer ;
- begin
-
- (* Loop through all items in g_aOccurArray and if there is a function
- to call, call it. *)
- for iType := 0 to constMaxNumErrorFuncs do
- begin
- for iOccur := 0 to constMaxErrsPerType do
- begin
- if ( not Assigned ( g_aOccurArray[ iType ][ iOccur ].pFunc ) ) then
- break ;
- g_aOccurArray[ iType ][ iOccur ].pFunc ( ) ;
- end;
- end;
-
- end ; (* Procedure DoAllErrors *)
-
-
- (***********************************************************************)
- (* DlphiErr DLL Required procedures *)
- procedure LibExit;
- begin
- ExitProc := SaveExit;
- end;
-
-
- (***********************************************************************)
- (* DlphiErr exports (to support the BugModule DLL interface) *)
- exports
- PopulateTree index 1, (* Required for all BugModules *)
- DePopulateTree index 2, (* Optional BugModule entry point *)
- DoRandomErrors index 3, (* Optional BugModule entry point *)
- DoAllErrors index 4; (* Optional BugModule entry point *)
-
-
- (***********************************************************************)
- (* DlphiErr main DLL entrypoint *)
- begin
- SaveExit := ExitProc;
- ExitProc := @LibExit;
- end.
-
-