--- oup/current/Tools/BinEdit.pas 2007/02/25 17:20:22 113 +++ oup/current/Tools/BinEdit.pas 2007/06/15 15:12:11 217 @@ -2,9 +2,10 @@ unit BinEdit; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, - Dialogs, Template, StdCtrls, ExtCtrls, VirtualTrees, Grids, Wrapgrid, - MPHexEditor, VTHeaderPopup, Menus, StrUtils, Clipbrd, - Data, TypeDefs, ConnectionManager, Buttons; + Dialogs, VirtualTrees, Grids, Wrapgrid, MPHexEditor, StdCtrls, + Menus, VTHeaderPopup, ExtCtrls, Buttons, StrUtils, Clipbrd, + Data, TypeDefs, ConnectionManager, Template, + _BaseTemplate, _TemplateFile, _TemplateFileList; type TForm_BinEdit = class(TForm_ToolTemplate) @@ -21,6 +22,9 @@ type value_viewer_context_copyasstring: TMenuItem; value_viewer_context_copyashex: TMenuItem; VTHPopup: TVTHeaderPopupMenu; + panel_imexport: TPanel; + btn_export: TButton; + btn_import: TButton; procedure FormCreate(Sender: TObject); procedure NewFile(fileinfo: TFileInfo); @@ -58,6 +62,7 @@ type private fileid: Integer; ConID: Integer; + rawlist: TRawDataList; public end; @@ -66,7 +71,7 @@ var implementation -uses ValueEdit, Main, Functions, DatStructureLoader{, RawEdit}; +uses ValueEdit, Main, Functions, DatStructureLoader, RawEdit; {$R *.dfm} type @@ -160,6 +165,7 @@ begin Self.ClearStructViewer; mem := nil; ConManager.Connection[ConID].LoadDatFile(fileid, TStream(mem)); + rawlist := ConManager.Connection[ConID].GetRawList(fileid); hex.LoadFromStream(mem); mem.Free; ClearValues; @@ -172,6 +178,7 @@ begin Self.ClearStructViewer; ClearValues; hex.DataSize := 0; + SetLength(rawlist, 0); end; end; @@ -180,8 +187,7 @@ end; function TForm_BinEdit.GetValue(datatype: Word; offset: Integer): String; var Data: TByteData; - i: Word; - tempi: Integer; + i: Integer; floatformat: TFormatSettings; begin floatformat.DecimalSeparator := '.'; @@ -218,11 +224,20 @@ begin Result := IntToBin(hex.Data[offset]); 11: begin - tempi := ConManager.Connection[ConID].GetRawInfo(fileid, offset).RawAddr; - if tempi >= 0 then - Result := '0x' + IntToHex(tempi, 8) - else - Result := 'unused'; + if Length(rawlist) > 0 then + begin + for i := 0 to High(rawlist) do + if rawlist[i].SrcOffset = offset then + begin + if rawlist[i].RawAddr > 0 then + Result := '0x' + IntToHex(rawlist[i].RawAddr, 8) + else + Result := 'unused'; + Break; + end; + if i > High(rawlist) then + Result := 'unused'; + end; end; 12: if hex.Data[offset] = 1 then @@ -467,8 +482,10 @@ begin str := ''; if hex.SelCount = 0 then begin - while (hex.Data[hex.SelStart + j] > 0) and ((hex.SelStart + j) < hex.DataSize) do + while (hex.SelStart + j) < hex.DataSize do begin + if hex.Data[hex.SelStart + j] = 0 then + Break; if hex.Data[hex.selstart + j] >= 32 then str := str + Char(hex.Data[hex.SelStart + j]) else @@ -742,7 +759,8 @@ procedure TForm_BinEdit.VSTDblClick(Send var node: PVirtualNode; nodedata: PNodeData; - form: TForm_ToolTemplate; + rawinfo: TRawDataInfo; + form: TForm_TemplateFileList; begin if VST.FocusedColumn = 3 then begin @@ -759,8 +777,14 @@ begin begin if (nodedata.DataType = 11) and (nodedata.Value <> 'unused') then begin - if ConManager.Connection[ConID].GetRawInfo(fileid, nodedata.offset).RawSize > 0 then - Form_Main.open_child('rawedit', ConID, fileid); + rawinfo := ConManager.Connection[ConID].GetRawInfo(fileid, nodedata.offset); + if rawinfo.RawSize > 0 then + begin + form := nil; + form := TForm_TemplateFileList(Form_Main.open_child('rawedit', ConID, fileid)); + if Assigned(form) then + TForm_RawEdit(form).LoadRaw(rawinfo); + end; end; if (nodedata.DataType = 12) and (nodedata.Value <> 'no link') then begin @@ -776,7 +800,7 @@ begin end; if (nodedata.DataType >= 100) and (nodedata.DataType <= 300) then begin - form := Form_Main.open_child('binedit', ConID, -1); + form := TForm_TemplateFileList(Form_Main.open_child('binedit', ConID)); if Assigned(form) then form.SetFileFilters(nodedata.Value, '', False); end;