--- oup/rewrite/Tools/BinEdit.pas 2007/02/21 00:29:27 105 +++ oup/current/Tools/BinEdit.pas 2007/05/02 15:16:00 174 @@ -33,8 +33,8 @@ type procedure LoadDat(_fileid: Integer); function Save: Boolean; - function GetValue(datatype: Word; offset: LongWord): String; - procedure SetNewValue(datatype: Word; offset: LongWord; Value: String); + function GetValue(datatype: Word; offset: Integer): String; + procedure SetNewValue(datatype: Word; offset: Integer; Value: String); procedure WriteStructureInfos; procedure ClearStructViewer; @@ -139,7 +139,6 @@ end; procedure TForm_BinEdit.LoadDat(_fileid: Integer); var mem: TMemoryStream; - Data: TByteData; begin if ConID <> -1 then begin @@ -178,10 +177,11 @@ end; -function TForm_BinEdit.GetValue(datatype: Word; offset: LongWord): String; +function TForm_BinEdit.GetValue(datatype: Word; offset: Integer): String; var Data: TByteData; i: Word; + tempi: Integer; floatformat: TFormatSettings; begin floatformat.DecimalSeparator := '.'; @@ -217,10 +217,19 @@ begin 10: Result := IntToBin(hex.Data[offset]); 11: - Result := '0x' + IntToHex(ConManager.Connection[ConID].GetRawInfo(fileid, offset).RawAddr, 8); + begin + tempi := ConManager.Connection[ConID].GetRawInfo(fileid, offset).RawAddr; + if tempi >= 0 then + Result := '0x' + IntToHex(tempi, 8) + else + Result := 'unused'; + end; 12: - Result := FormatNumber(hex.Data[offset + 1] + hex.Data[offset + 2] * 256 + - hex.Data[offset + 3] * 256 * 256, 5, '0'); + if hex.Data[offset] = 1 then + Result := FormatNumber(hex.Data[offset + 1] + hex.Data[offset + 2] * 256 + + hex.Data[offset + 3] * 256 * 256, 5, '0') + else + Result := 'no link'; 13: Result := IntToStr(hex.Data[offset]); 14: @@ -273,7 +282,7 @@ end; procedure TForm_BinEdit.WriteStructureInfos; var - i, j: LongWord; + i, j: Integer; pdata: PNodeData; Data: TNodeData; node: PVirtualNode; @@ -307,8 +316,8 @@ begin begin if Pos('#', SubName) > 0 then begin - Data.Offset := HexToLong(MidStr(SubName, Pos('#', SubName) + 1, 8)); - Data.Value := + Data.Offset := StrToInt('$'+MidStr(SubName, Pos('#', SubName) + 1, 8)); + Data.Value := '$' + MidStr(SubName, PosEx('#', SubName, Pos('#', SubName) + 1) + 1, 8); Data.Caption := MidStr(SubName, 1, Pos('#', SubName) - 1); Data.Description := SubDesc; @@ -375,7 +384,7 @@ var i, j: Integer; Data: TByteData; str: String; - Value: LongWord; + Value: Integer; floatformat: TFormatSettings; begin floatformat.DecimalSeparator := '.'; @@ -458,8 +467,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 @@ -488,7 +499,7 @@ end; function TForm_BinEdit.Save: Boolean; var mem: TMemoryStream; - i: LongWord; + i: Integer; begin case MessageBox(Self.Handle, PChar('Save changes to file ' + ConManager.Connection[ConID].GetFileInfo(fileid).Name + '?'), PChar('Data changed...'), @@ -670,7 +681,7 @@ end; procedure TForm_BinEdit.value_viewer_context_copyClick(Sender: TObject); var Name: String; - Value: LongWord; + Value: Integer; begin Name := TMenuItem(Sender).Name; if Pos('asstring', Name) > 0 then @@ -748,12 +759,12 @@ begin end else begin - if nodedata.DataType = 11 then + 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); end; - if nodedata.DataType = 12 then + if (nodedata.DataType = 12) and (nodedata.Value <> 'no link') then begin if (StrToInt(nodedata.Value) < ConManager.Connection[ConID].GetFileCount) and (StrToInt(nodedata.Value) > 0) and @@ -793,7 +804,7 @@ begin else begin hex.SelStart := Data.Offset; - hex.SelEnd := Data.Offset + HexToLong(Data.Value) - 1; + hex.SelEnd := Data.Offset + StrToInt(Data.Value) - 1; end; end; @@ -824,7 +835,7 @@ begin if Data.DataType > 0 then CellText := Data.Value //GetValue(data.DataType, data.Offset) else if Length(Data.Value) > 0 then - CellText := IntToStr(HexToLong(Data.Value)) + ' Bytes'; + CellText := IntToStr(StrToInt(Data.Value)) + ' Bytes'; 4: CellText := Data.Description; end; @@ -855,7 +866,7 @@ end; -procedure TForm_BinEdit.SetNewValue(datatype: Word; offset: LongWord; Value: String); +procedure TForm_BinEdit.SetNewValue(datatype: Word; offset: Integer; Value: String); var Data: TByteData; value_int: LongWord; @@ -922,7 +933,7 @@ end; procedure TForm_BinEdit.value_viewerDblClick(Sender: TObject); var - offset: LongWord; + offset: Integer; datatype: Word; objectname: String; Value: String;