02-10-2015, 19:14
PHP Kod:
FUNCTION BUFFER_READ (_File_Name_:String;_Offset_:Int64;_TYPE_:Byte=1): STRING;
FUNCTION BUFFER_WRITE(_File_Name_:String;_Offset_:Int64;_Value_:Byte): STRING;
function BUFFER_READ(_File_Name_: String; _Offset_: Int64;_TYPE_:BYTE): STRING;
VAR
fexe: TFileStream;
_Value_: byte;
begin
fexe := TFileStream.Create(_File_Name_, fmOpenReadWrite or fmShareExclusive);
fexe.Position := _Offset_;
fexe.ReadBuffer(_Value_,sizeof(_Value_));
IF _TYPE_ = 1 THEN RESULT := IntToHex(_Value_,2)
ELSE IF _TYPE_ = 2 THEN RESULT := CHR(_Value_)
ELSE IF _TYPE_ = 3 THEN RESULT := IntToStr(_Value_);
fexe.Free;
{ BUFFER_READ('C:\Example.txt',$4,3); }
end;
function BUFFER_WRITE(_File_Name_: String; _Offset_: Int64;
_Value_: Byte): STRING;
VAR
fexe: TFileStream;
begin
fexe := TFileStream.Create(_File_Name_, fmOpenReadWrite or fmShareExclusive);
fexe.Position := _Offset_;
fexe.WriteBuffer(_Value_,sizeof(_Value_));
fexe.Free;
{ BUFFER_WRITE('C:\Example.txt',$186F79,$80); }
end;
* _Value_ değişkeninin tipi Word olunca 2'li okuyor yani sütun sütun buda 4 karakter, Byte olunca 1'li yani ikili olarak.
Bu kodlar sayesinde istediğiniz offset'deki bilgiyi okuyup istediğinizi yazabilirsiniz.