home *** CD-ROM | disk | FTP | other *** search
- unit ScannerDemoUnit1;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- Menus, StdCtrls,
- HVBorDebug, BorDebugScanners, BorDebugDumpScanner, ComCtrls;
-
- type
- TScannerDemoForm = class(TForm)
- MainMenu: TMainMenu;
- FileMenu: TMenuItem;
- OpenItem: TMenuItem;
- ExitItem: TMenuItem;
- N1: TMenuItem;
- OpenDialog: TOpenDialog;
- Memo: TMemo;
- procedure FormCreate(Sender: TObject);
- procedure OpenItemClick(Sender: TObject);
- procedure ExitItemClick(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- private
- Debug: TBorDebug;
- DumpScanner: TDumpBorDebugScanner;
- Dump: string;
- DumpPos: integer;
- procedure ScanIt;
- procedure OnScannerDump(Sender: TObject; const Msg: string);
- public
- end;
-
- var
- ScannerDemoForm: TScannerDemoForm;
-
- implementation
-
- {$R *.DFM}
-
- procedure TScannerDemoForm.FormCreate(Sender: TObject);
- begin
- Debug := TBorDebug.Create;
- DumpScanner := TDumpBorDebugScanner.Create(Debug);
- DumpScanner.OnDump := OnScannerDump;
- end;
-
- procedure TScannerDemoForm.FormDestroy(Sender: TObject);
- begin
- DumpScanner.Free;
- Debug.Free;
- end;
-
- procedure TScannerDemoForm.OnScannerDump(Sender: TObject; const Msg: string);
- var
- NewLength : integer;
- begin
- // Grow the dump buffer if it is too small
- if (Length(Dump) - DumpPos) < Length(Msg) then
- begin
- if Length(Msg) > Length(Dump)
- then NewLength := Length(Dump) + Length(Msg)
- else NewLength := Length(Dump) * 2;
- SetLength(Dump, NewLength);
- end;
- // Just move the contest quickly over to the dump buffer
- Move(Pointer(Msg)^, Pointer(@Dump[DumpPos+1])^, Length(Msg));
- // Update our position in the dump buffer
- Inc(DumpPos, Length(Msg));
- end;
-
- procedure TScannerDemoForm.ScanIt;
- begin
- SetLength(Dump, 4*1024*1024); // 4Meg!
- DumpPos := 0;
- DumpScanner.Scan([soModule, soAlignSym, soSrcModule, soGlobalSym, soGlobalPub,
- soGlobalTypes, soNames, soBrowse, soSrcModuleRanges, soSrcModuleFiles]);
- SetLength(Dump, DumpPos);
- Memo.Lines.Text := Dump;
- Dump := '';
- end;
-
- procedure TScannerDemoForm.OpenItemClick(Sender: TObject);
- begin
- if OpenDialog.Execute then
- begin
- Debug.Filename := OpenDialog.Filename;
- Debug.Open;
- ScanIt;
- end;
- end;
-
- procedure TScannerDemoForm.ExitItemClick(Sender: TObject);
- begin
- Close;
- end;
-
- end.
-