Auto Cheats

Olá visitante, conheça as novidades de ser um mebro :

•Iniciar novos tópicos e responder a outros.
•Ter um perfil.
•Fazer novos amigos.
•Concorres a Cargos.
•E muito mais.
Registre-se abaixo!

Obrigado, ~Shout, Fundador da Auto Cheats

Participe do fórum, é rápido e fácil

Auto Cheats

Olá visitante, conheça as novidades de ser um mebro :

•Iniciar novos tópicos e responder a outros.
•Ter um perfil.
•Fazer novos amigos.
•Concorres a Cargos.
•E muito mais.
Registre-se abaixo!

Obrigado, ~Shout, Fundador da Auto Cheats

Auto Cheats

Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.

Simplesmente o Melhor


    (Classe)TMemory!

    avatar
    ~Shout



    Mensagens : 33
    Pontos : 43
    Reputação : 0
    Data de inscrição : 26/11/2009

    (Classe)TMemory! Empty (Classe)TMemory!

    Mensagem por ~Shout Dom Nov 29, 2009 1:51 pm

    Aki Vai o code da unit inteira :


    Código:
    unit UMemory;

    interface

    uses
    sysutils,windows;

    type

    Tmemory = class(Tobject)
    public
            Function ReadByte(Address:integer):byte;Overload;
            Function ReadByte(Address,OffSet:integer):byte;Overload;

            Function ReadFloat(Address:integer):Single;Overload;
            Function ReadFloat(Address,OffSet:integer):Single;Overload;

            function ReadInteger(Address:integer):integer;Overload;
            function ReadInteger(Address,OffSet:integer):integer;Overload;

            Function ReadString(Address:integer):string;Overload;
            Function ReadString(Address,OffSet:integer):string;Overload;

            Function WriteByte(Address:integer;Value:byte):boolean;Overload;
            Function WriteByte(Address,OffSet:integer;Value:byte):boolean;Overload;

            Function WriteBytes(Address:Integer;Value,Bytes:byte):boolean;Overload;
            Function WriteBytes(Address,OffSet:Integer;Value,Bytes:byte):boolean;Overload;

            function WriteFloat(Address:integer;Value:Single):boolean;Overload;
            function WriteFloat(Address,OffSet:integer;Value:Single):boolean;Overload;

            Function WriteInteger(Address,Value:integer):boolean;Overload;
            Function WriteInteger(Address,OffSet,Value:integer):boolean;Overload;

            Function WriteString(Address:integer;Value:string):boolean;Overload;
            Function WriteString(Address,OffSet:integer;Value:string):boolean;Overload;
    end;

    var
    Memory:Tmemory;


    implementation

    { Tmemory }

    {Trate o error do geito que quiser nessa função,geralmente o error que acontece mais nessas
    funções são Access Violation.}

    procedure CreateException(Error:Exception);
    begin

    end;

    //Função ReadByte,Lê um Address e retorna um valor do tipo Byte.

    function Tmemory.ReadByte(Address: integer): byte;
    begin
      result := 0;
      try
        Result := Pbyte(Address)^;
      except
        on E : Exception do
          begin
            CreateException(e);
          end;
      end;
    end;

    //Função ReadByte,Agora com pointers.

    function Tmemory.ReadByte(Address, OffSet: integer): byte;
    begin
      result := 0;
      try
        Result := Pbyte(PInteger(Address)^ + OffSet)^;
      except
        on E : Exception do
          begin
            CreateException(e);
          end;
      end;
    end;

    //Função ReadFloat,Lê um Address e retorna um valor do tipo Single.

    function Tmemory.ReadFloat(Address: integer): Single;
    begin
      result := 0.0;
      try
        result := PSingle(Address)^;
      except
        on E : Exception do
          begin
            CreateException(e);
          end;
      end;
    end;

    //Função ReadFloat,Agora com Pointer.

    function Tmemory.ReadFloat(Address, OffSet: integer): Single;
    begin
      result := 0.0;
      try
        result := PSingle(PInteger(Address)^ + OffSet)^;
      except
        on E : Exception do
          begin
            CreateException(e);
          end;
      end;
    end;

    //Função ReadInteger,Lê um address e retorna um valor do tipo integer.

    function Tmemory.ReadInteger(Address: integer): integer;
    begin
      result := 0;
      try
        result := Pinteger(Address)^;
      except
        on E : Exception do
          begin
            CreateException(e);
          end;
      end;
    end;

    //Função ReadInteger,Agora com Pointers.

    function Tmemory.ReadInteger(Address, OffSet: integer): integer;
    begin
      result := 0;
      try
        result := Pinteger(PInteger(Address)^ + OffSet)^;
      except
        on E : Exception do
          begin
            CreateException(e);
          end;
      end;
    end;

    //Função ReadString,Lê um address e retorna um valor do tipo String.

    function Tmemory.ReadString(Address: integer): string;
    var
      i, Value : Byte;
    begin
      Result  :=  '';
      try
        i:= 0;
        repeat
          Value := pbyte(Address + i)^;
          Result:=  Result  + char(Value);
          inc(i);
        until Value = 0;
        Result:=Copy(Result,1,Length(Result)-1);
      except
        on e : Exception do
          begin
            CreateException(e);
          end;
      end;
    end;

    //Função ReadString,Agora com Pointers.

    function Tmemory.ReadString(Address, OffSet: integer): string;
    var
      i,PAddress, Value : Byte;
    begin
      Result  :=  '';
      try
        PAddress := Pinteger(Address)^ + OffSet;
        i:= 0;
        repeat
          Value := pbyte(PAddress + i)^;
          Result:=  Result  + char(Value);
          inc(i);
        until Value = 0;
        Result:=Copy(Result,1,Length(Result)-1);
      except
        on e : Exception do
          begin
            CreateException(e);
          end;
      end;
    end;

    //Procedure WriteByte,Escreve um valor do tipo Byte.

    Function Tmemory.WriteByte(Address: integer; Value: byte):boolean;
    begin
      Result := true;
      try
        pbyte(Address)^ := value;
      except
        on E : Exception do
          begin
            CreateException(e);
            Result := False;
          end;
      end;
    end;

    //Procedure WriteByte,Agora com Pointers.

    Function Tmemory.WriteByte(Address, OffSet: integer; Value: byte):boolean;
    begin
      Result := true;
      try
        pbyte(Pinteger(Address)^ + OffSet)^ := value;
      except
        on E : Exception do
          begin
            CreateException(e);
            Result := False;
          end;
      end;
    end;

    //Procedure WriteBytes,Escreve varios bytes de uma vez só.

    Function Tmemory.WriteBytes(Address: Integer; Value, Bytes: byte):boolean;
    var
    I:integer;
    begin
      Result := true;
      try
        for i := 0 to bytes - 1 do
          begin
            Pbyte(Address + i)^ := value;
          end;
      except
        On E : Exception do
          begin
            CreateException(e);
            Result := False;
          end;
      end;
    end;

    //Procedure WriteBytes,Agora com Pointers.

    Function Tmemory.WriteBytes(Address, OffSet: Integer; Value, Bytes: byte):boolean;
    var
    I,Paddress:integer;
    begin
      Result := true;
      try
        Paddress := PInteger(Address)^ + OffSet;
        for i := 0 to bytes - 1 do
          begin
            Pbyte(PAddress + i)^ := value;
          end;
      except
        On E : Exception do
          begin
            CreateException(e);
            Result := False;
          end;
      end;
    end;

    //Procedure WriteFloat,Escreve um valor do tipo Single.

    function Tmemory.WriteFloat(Address: integer; Value: Single): boolean;
    begin
      Result := true;
      try
        PSingle(Address)^ := Value;
      except
        On E : Exception do
          begin
            CreateException(e);
            Result := False;
          end;
      end;
    end;

    //Procedure WriteFloat,Agora com Pointers.

    function Tmemory.WriteFloat(Address, OffSet: integer;
      Value: Single): boolean;
    begin
      Result := true;
      try
        PSingle(Pinteger(Address)^ + OffSet)^ := Value;
      except
        On E : Exception do
          begin
            CreateException(e);
            Result := False;
          end;
      end;
    end;

    //Procedure WriteInteger,Escreve um valor do tipo Integer.

    Function Tmemory.WriteInteger(Address,Value: integer):boolean;
    begin
      Result := true;
      try
        Pinteger(Address)^ := Value;
      except
        On E : Exception do
          begin
            CreateException(e);
            Result := False;
          end;
      end;
    end;

    //Procedure WriteInteger,Agora com Pointers.

    Function Tmemory.WriteInteger(Address, OffSet, Value: integer):boolean;
    begin
      Result := true;
      try
        Pinteger(Pinteger(Address)^ + OffSet)^ := Value;
      except
        On E : Exception do
          begin
            CreateException(e);
            Result := False;
          end;
      end;
    end;

    //Procedure WriteString,Escreve um valor do tipo String.

    Function Tmemory.WriteString(Address: integer; Value: string):boolean;
    var
      TVal : Byte;
      i: integer;
    begin
      Result := true;
      try
        for i:=1 to Length(Value) do
          begin
            TVal:=ord(Value[i]);
            pbyte(Address + i - 1)^ := Tval;
            if i = Length(Value) then
              begin
                TVal:=0;
                pbyte(Address + i)^ := Tval;
              end;
          end;
      except
        On E : Exception do
          begin
            CreateException(e);
            Result := False;
          end;
      end;
    end;

    //Procedure WriteString,Agora com Pointers.

    Function Tmemory.WriteString(Address, OffSet: integer; Value: string):boolean;
    var
      TVal : Byte;
      i,Paddress: integer;
    begin
      Result := true;
      try
        Paddress := Pinteger(Address)^ + OffSet;
        for i:=1 to Length(Value) do
          begin
            TVal:=ord(Value[i]);
            pbyte(PAddress + i - 1)^ := Tval;
            if i = Length(Value) then
              begin
                TVal:=0;
                pbyte(PAddress + i)^ := Tval;
              end;
          end;
      except
        On E : Exception do
          begin
            CreateException(e);
            Result := False;
          end;
      end;
    end;

    initialization
    {initialization code goes here}
    Memory := Tmemory.Create;
    finalization
    {finalization code goes here}
    FreeAndNil(Memory);
    end.

    Para usar é o seguinte :



    Código:
    //Por exemplo,você quer escrever um valor integer(4 Bytes) na memoria,usando Pointers :

    Memory.WriteInteger(AddressPointer,OffSet,Value);

    //Ou,sem Pointer

    Memory.WriteInteger(Address,Value);

    //Todas as funções Write(De escrever) retornam um valor Boolean(True,False) que se for verdadeiro a operação deu certou e se for Falso deu errado.



    Créditos : Cm~

    Ps : Nos Atachmments tem a unit inteira.

      Data/hora atual: Sex Abr 19, 2024 9:26 am