Results 1 to 3 of 3

Thread: No Memory Hacking?

  1. #1

    No Memory Hacking?

    I am creating a game and I am wondering if anyone knows any ways to prevent memory hacking, or to at least make it difficult to do so.

    I could make everything server sided, but it would waste precious bandwith and I would like to make only the things I need to server sided (ie: weapons, items, ..).
    -AOTA Head Programmer
    <br />www.aotaonline.com
    <br />LiquidIce@aotaonline.om

  2. #2

    No Memory Hacking?

    I've seen a component for C++ Builder that randomly encrypts a memory buffer. Not only does it encrypt it once, it re-encrypts the buffer once a second. This is about the most secure I think you will get from memory hacking. This component is part of a commercial package so you cannot get the source code freely.

  3. #3
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    No Memory Hacking?

    Why not write your own component to do it for you?

    [pascal]
    Type
    TEncryptedMem = Class
    Private
    IntTimer : TTimer;
    FOnReEncrypt: TNotiFyEvent;
    procedure SetOnReEncrypt(const Value: TNotiFyEvent);
    Protected
    procedure SetAsInteger(const Value: Integer); Virtual;
    procedure SetAsString(const Value: String); Virtual;
    procedure SetEncryptInterval(const Value: Integer); Virtual;
    Procedure ReEncrypt(Sender : TObject); Virtual;
    function GetAsInteger: Integer; Virtual;
    function GetAsString: String; Virtual;
    function GetEncryptInterval: Integer; Virtual;
    Published
    Property AsInteger : Integer read GetAsInteger write SetAsInteger;
    Property AsString : String read GetAsString write SetAsString;
    Property EncryptInterval : Integer read GetEncryptInterval write SetEncryptInterval;
    Property OnReEncrypt : TNotiFyEvent read FOnReEncrypt write SetOnReEncrypt;
    Constructor Create;
    Destructor Destroy; Override;
    Public
    DataStr : String;
    End;
    [/pascal]

    Obviously the Datastr should be private but for testing you need it visible.

    [pascal]
    constructor TEncryptedMem.Create;
    begin
    inherited;
    IntTimer := TTimer.Create(Nil);
    IntTimer.Interval := 1000;
    IntTimer.OnTimer := ReEncrypt;
    end;

    destructor TEncryptedMem.Destroy;
    begin
    IntTimer.Free;
    inherited;
    end;

    function TEncryptedMem.GetAsInteger: Integer;
    begin
    Result := StrToInt(Decrypt(DataStr));
    end;

    function TEncryptedMem.GetAsString: String;
    begin
    Result := Decrypt(DataStr);
    end;

    function TEncryptedMem.GetEncryptInterval: Integer;
    begin
    Result := IntTimer.Interval;
    end;

    procedure TEncryptedMem.ReEncrypt(Sender: TObject);
    begin
    DataStr := Encrypt(Decrypt(DataStr));
    If Assigned(OnReEncrypt) then
    OnReEncrypt(Self);
    end;

    procedure TEncryptedMem.SetAsInteger(const Value: Integer);
    begin
    DataStr := Encrypt(IntToStr(Value));
    end;

    procedure TEncryptedMem.SetAsString(const Value: String);
    begin
    DataStr := Encrypt(Value);
    end;

    procedure TEncryptedMem.SetEncryptInterval(const Value: Integer);
    begin
    IntTimer.Interval := Value;
    end;


    procedure TEncryptedMem.SetOnReEncrypt(const Value: TNotiFyEvent);
    begin
    FOnReEncrypt := Value;
    end;
    [/pascal]

    Write your own encryption Algorithms or use a secure system. I have my own little system that I use - not highly secure as the encrypted portion always remains the same but in my environment it does ok - I use it to encrypt password and IDs in the Registry etc.

    [pascal]
    function Encrypt(Str: String): String;
    Var
    I : Integer;
    S : String;
    begin
    S := Char(Trunc(Random*26)+Ord('A'));
    For I := 1 to Length(Str) do
    Begin
    S := S+Char(Ord(Str[I])-I)+Char(Trunc(Random*26)+Ord('A'));
    end;
    Result := S;
    end;

    function Decrypt(Str: String): String;
    Var
    S : String;
    I : Integer;
    begin
    S := '';
    I := 1;
    While I * 2 < Length(Str) do
    Begin
    S := S + Char(Ord(Str[I*2])+I);
    I := I + 1;
    End;
    Result := S;
    end;
    [/pascal]


    To use this just create a unit with it all in. (or send me an email william.cairns@arivia.co.za and I'll send you the unit and the test form.)

    Create a TEncryptedMem object in your program.

    To set a value
    [pascal]Mem.AsString := 'This is my secret memory program';[/pascal]
    To read the value
    [pascal]MyVar := Mem.AsString;[/pascal]
    To see what it looks like in memory
    [pascal]MyEncrypt := Mem.DataStr; // For Debug Purposes Only.[/pascal]

    You can use the OnReEncrypt event to be notified whenever the timer reencrypts the value. - Nive for debugging purposes

    Cheers

    EDIT (BlueCat) - [ pascal ] tags look so much nicer than [ code ]
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •