--- oup/rewrite/Tools/BinEdit.pas 2007/02/20 22:03:11 104 +++ oup/current/Tools/BinEdit.pas 2007/02/25 17:20:22 113 @@ -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,23 +177,11 @@ end; - -function IntToBin(Value: Byte): String; -var - i: Byte; -begin - Result := ''; - for i := 7 downto 0 do - Result := Result + IntToStr((Value shr i) and $01); -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 := '.'; @@ -230,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: @@ -286,7 +282,7 @@ end; procedure TForm_BinEdit.WriteStructureInfos; var - i, j: LongWord; + i, j: Integer; pdata: PNodeData; Data: TNodeData; node: PVirtualNode; @@ -320,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; @@ -388,7 +384,7 @@ var i, j: Integer; Data: TByteData; str: String; - Value: LongWord; + Value: Integer; floatformat: TFormatSettings; begin floatformat.DecimalSeparator := '.'; @@ -501,7 +497,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...'), @@ -683,7 +679,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 @@ -761,12 +757,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 @@ -806,7 +802,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; @@ -837,7 +833,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; @@ -868,7 +864,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; @@ -935,7 +931,7 @@ end; procedure TForm_BinEdit.value_viewerDblClick(Sender: TObject); var - offset: LongWord; + offset: Integer; datatype: Word; objectname: String; Value: String;