| 21 |
|
value_viewer_context_copyasstring: TMenuItem; |
| 22 |
|
value_viewer_context_copyashex: TMenuItem; |
| 23 |
|
VTHPopup: TVTHeaderPopupMenu; |
| 24 |
+ |
panel_imexport: TPanel; |
| 25 |
+ |
btn_export: TButton; |
| 26 |
+ |
btn_import: TButton; |
| 27 |
|
procedure FormCreate(Sender: TObject); |
| 28 |
|
procedure NewFile(fileinfo: TFileInfo); |
| 29 |
|
|
| 36 |
|
|
| 37 |
|
procedure LoadDat(_fileid: Integer); |
| 38 |
|
function Save: Boolean; |
| 39 |
< |
function GetValue(datatype: Word; offset: LongWord): String; |
| 40 |
< |
procedure SetNewValue(datatype: Word; offset: LongWord; Value: String); |
| 39 |
> |
function GetValue(datatype: Word; offset: Integer): String; |
| 40 |
> |
procedure SetNewValue(datatype: Word; offset: Integer; Value: String); |
| 41 |
|
|
| 42 |
|
procedure WriteStructureInfos; |
| 43 |
|
procedure ClearStructViewer; |
| 61 |
|
private |
| 62 |
|
fileid: Integer; |
| 63 |
|
ConID: Integer; |
| 64 |
+ |
rawlist: TRawDataList; |
| 65 |
|
public |
| 66 |
|
end; |
| 67 |
|
|
| 70 |
|
|
| 71 |
|
implementation |
| 72 |
|
|
| 73 |
< |
uses ValueEdit, Main, Functions, DatStructureLoader{, RawEdit}; |
| 73 |
> |
uses ValueEdit, Main, Functions, DatStructureLoader, RawEdit; |
| 74 |
|
{$R *.dfm} |
| 75 |
|
|
| 76 |
|
type |
| 143 |
|
procedure TForm_BinEdit.LoadDat(_fileid: Integer); |
| 144 |
|
var |
| 145 |
|
mem: TMemoryStream; |
| 142 |
– |
Data: TByteData; |
| 146 |
|
begin |
| 147 |
|
if ConID <> -1 then |
| 148 |
|
begin |
| 164 |
|
Self.ClearStructViewer; |
| 165 |
|
mem := nil; |
| 166 |
|
ConManager.Connection[ConID].LoadDatFile(fileid, TStream(mem)); |
| 167 |
+ |
rawlist := ConManager.Connection[ConID].GetRawList(fileid); |
| 168 |
|
hex.LoadFromStream(mem); |
| 169 |
|
mem.Free; |
| 170 |
|
ClearValues; |
| 177 |
|
Self.ClearStructViewer; |
| 178 |
|
ClearValues; |
| 179 |
|
hex.DataSize := 0; |
| 180 |
+ |
SetLength(rawlist, 0); |
| 181 |
|
end; |
| 182 |
|
end; |
| 183 |
|
|
| 184 |
|
|
| 185 |
|
|
| 186 |
< |
function TForm_BinEdit.GetValue(datatype: Word; offset: LongWord): String; |
| 186 |
> |
function TForm_BinEdit.GetValue(datatype: Word; offset: Integer): String; |
| 187 |
|
var |
| 188 |
|
Data: TByteData; |
| 189 |
< |
i: Word; |
| 189 |
> |
i: Integer; |
| 190 |
|
floatformat: TFormatSettings; |
| 191 |
|
begin |
| 192 |
|
floatformat.DecimalSeparator := '.'; |
| 222 |
|
10: |
| 223 |
|
Result := IntToBin(hex.Data[offset]); |
| 224 |
|
11: |
| 225 |
< |
Result := '0x' + IntToHex(ConManager.Connection[ConID].GetRawInfo(fileid, offset).RawAddr, 8); |
| 225 |
> |
begin |
| 226 |
> |
if Length(rawlist) > 0 then |
| 227 |
> |
begin |
| 228 |
> |
for i := 0 to High(rawlist) do |
| 229 |
> |
if rawlist[i].SrcOffset = offset then |
| 230 |
> |
begin |
| 231 |
> |
if rawlist[i].RawAddr > 0 then |
| 232 |
> |
Result := '0x' + IntToHex(rawlist[i].RawAddr, 8) |
| 233 |
> |
else |
| 234 |
> |
Result := 'unused'; |
| 235 |
> |
Break; |
| 236 |
> |
end; |
| 237 |
> |
if i > High(rawlist) then |
| 238 |
> |
Result := 'unused'; |
| 239 |
> |
end; |
| 240 |
> |
end; |
| 241 |
|
12: |
| 242 |
< |
Result := FormatNumber(hex.Data[offset + 1] + hex.Data[offset + 2] * 256 + |
| 243 |
< |
hex.Data[offset + 3] * 256 * 256, 5, '0'); |
| 242 |
> |
if hex.Data[offset] = 1 then |
| 243 |
> |
Result := FormatNumber(hex.Data[offset + 1] + hex.Data[offset + 2] * 256 + |
| 244 |
> |
hex.Data[offset + 3] * 256 * 256, 5, '0') |
| 245 |
> |
else |
| 246 |
> |
Result := 'no link'; |
| 247 |
|
13: |
| 248 |
|
Result := IntToStr(hex.Data[offset]); |
| 249 |
|
14: |
| 296 |
|
|
| 297 |
|
procedure TForm_BinEdit.WriteStructureInfos; |
| 298 |
|
var |
| 299 |
< |
i, j: LongWord; |
| 299 |
> |
i, j: Integer; |
| 300 |
|
pdata: PNodeData; |
| 301 |
|
Data: TNodeData; |
| 302 |
|
node: PVirtualNode; |
| 330 |
|
begin |
| 331 |
|
if Pos('#', SubName) > 0 then |
| 332 |
|
begin |
| 333 |
< |
Data.Offset := HexToLong(MidStr(SubName, Pos('#', SubName) + 1, 8)); |
| 334 |
< |
Data.Value := |
| 333 |
> |
Data.Offset := StrToInt('$'+MidStr(SubName, Pos('#', SubName) + 1, 8)); |
| 334 |
> |
Data.Value := '$' + |
| 335 |
|
MidStr(SubName, PosEx('#', SubName, Pos('#', SubName) + 1) + 1, 8); |
| 336 |
|
Data.Caption := MidStr(SubName, 1, Pos('#', SubName) - 1); |
| 337 |
|
Data.Description := SubDesc; |
| 398 |
|
i, j: Integer; |
| 399 |
|
Data: TByteData; |
| 400 |
|
str: String; |
| 401 |
< |
Value: LongWord; |
| 401 |
> |
Value: Integer; |
| 402 |
|
floatformat: TFormatSettings; |
| 403 |
|
begin |
| 404 |
|
floatformat.DecimalSeparator := '.'; |
| 481 |
|
str := ''; |
| 482 |
|
if hex.SelCount = 0 then |
| 483 |
|
begin |
| 484 |
< |
while (hex.Data[hex.SelStart + j] > 0) and ((hex.SelStart + j) < hex.DataSize) do |
| 484 |
> |
while (hex.SelStart + j) < hex.DataSize do |
| 485 |
|
begin |
| 486 |
+ |
if hex.Data[hex.SelStart + j] = 0 then |
| 487 |
+ |
Break; |
| 488 |
|
if hex.Data[hex.selstart + j] >= 32 then |
| 489 |
|
str := str + Char(hex.Data[hex.SelStart + j]) |
| 490 |
|
else |
| 513 |
|
function TForm_BinEdit.Save: Boolean; |
| 514 |
|
var |
| 515 |
|
mem: TMemoryStream; |
| 516 |
< |
i: LongWord; |
| 516 |
> |
i: Integer; |
| 517 |
|
begin |
| 518 |
|
case MessageBox(Self.Handle, PChar('Save changes to file ' + |
| 519 |
|
ConManager.Connection[ConID].GetFileInfo(fileid).Name + '?'), PChar('Data changed...'), |
| 695 |
|
procedure TForm_BinEdit.value_viewer_context_copyClick(Sender: TObject); |
| 696 |
|
var |
| 697 |
|
Name: String; |
| 698 |
< |
Value: LongWord; |
| 698 |
> |
Value: Integer; |
| 699 |
|
begin |
| 700 |
|
Name := TMenuItem(Sender).Name; |
| 701 |
|
if Pos('asstring', Name) > 0 then |
| 758 |
|
var |
| 759 |
|
node: PVirtualNode; |
| 760 |
|
nodedata: PNodeData; |
| 761 |
+ |
rawinfo: TRawDataInfo; |
| 762 |
|
form: TForm_ToolTemplate; |
| 763 |
|
begin |
| 764 |
|
if VST.FocusedColumn = 3 then |
| 774 |
|
end |
| 775 |
|
else |
| 776 |
|
begin |
| 777 |
< |
if nodedata.DataType = 11 then |
| 777 |
> |
if (nodedata.DataType = 11) and (nodedata.Value <> 'unused') then |
| 778 |
|
begin |
| 779 |
< |
if ConManager.Connection[ConID].GetRawInfo(fileid, nodedata.offset).RawSize > 0 then |
| 780 |
< |
Form_Main.open_child('rawedit', ConID, fileid); |
| 779 |
> |
rawinfo := ConManager.Connection[ConID].GetRawInfo(fileid, nodedata.offset); |
| 780 |
> |
if rawinfo.RawSize > 0 then |
| 781 |
> |
begin |
| 782 |
> |
form := nil; |
| 783 |
> |
form := Form_Main.open_child('rawedit', ConID, fileid); |
| 784 |
> |
if Assigned(form) then |
| 785 |
> |
TForm_RawEdit(form).LoadRaw(rawinfo); |
| 786 |
> |
end; |
| 787 |
|
end; |
| 788 |
< |
if nodedata.DataType = 12 then |
| 788 |
> |
if (nodedata.DataType = 12) and (nodedata.Value <> 'no link') then |
| 789 |
|
begin |
| 790 |
|
if (StrToInt(nodedata.Value) < ConManager.Connection[ConID].GetFileCount) and |
| 791 |
|
(StrToInt(nodedata.Value) > 0) and |
| 825 |
|
else |
| 826 |
|
begin |
| 827 |
|
hex.SelStart := Data.Offset; |
| 828 |
< |
hex.SelEnd := Data.Offset + HexToLong(Data.Value) - 1; |
| 828 |
> |
hex.SelEnd := Data.Offset + StrToInt(Data.Value) - 1; |
| 829 |
|
end; |
| 830 |
|
end; |
| 831 |
|
|
| 856 |
|
if Data.DataType > 0 then |
| 857 |
|
CellText := Data.Value //GetValue(data.DataType, data.Offset) |
| 858 |
|
else if Length(Data.Value) > 0 then |
| 859 |
< |
CellText := IntToStr(HexToLong(Data.Value)) + ' Bytes'; |
| 859 |
> |
CellText := IntToStr(StrToInt(Data.Value)) + ' Bytes'; |
| 860 |
|
4: |
| 861 |
|
CellText := Data.Description; |
| 862 |
|
end; |
| 887 |
|
|
| 888 |
|
|
| 889 |
|
|
| 890 |
< |
procedure TForm_BinEdit.SetNewValue(datatype: Word; offset: LongWord; Value: String); |
| 890 |
> |
procedure TForm_BinEdit.SetNewValue(datatype: Word; offset: Integer; Value: String); |
| 891 |
|
var |
| 892 |
|
Data: TByteData; |
| 893 |
|
value_int: LongWord; |
| 954 |
|
|
| 955 |
|
procedure TForm_BinEdit.value_viewerDblClick(Sender: TObject); |
| 956 |
|
var |
| 957 |
< |
offset: LongWord; |
| 957 |
> |
offset: Integer; |
| 958 |
|
datatype: Word; |
| 959 |
|
objectname: String; |
| 960 |
|
Value: String; |