R
R
Rag'n' Code Man2020-08-15 15:00:48
.NET
Rag'n' Code Man, 2020-08-15 15:00:48

How do Anticheat's ObscuredTypes work?

Good afternoon!

I have already said 20 times that I am making my own game, and now I want to protect it from changing values ​​in RAM.

I saw videos where they simply save this value with offset, and when taken, they take it away, well, or XOR.

Recently, I came across a fun Unity Asset called Anticheat Toolkit . And there, in order to protect the game from substitution of values, it is necessary to use not the standard int, float, etc., but their "ObscuredTypes".

And it became interesting to me: how could they assign an integer value to the class not a constructor, but immediately (in the example with ObscuredInt)?

private ObscuredInt gems = 10;

At first I thought it was an overload of the assignment operator, but when I looked in MSDN, it said that it was impossible to overload the assignment operator. Actually, that's how I got here: how did they implement it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
ayazer, 2020-08-15
@iDmitriyWinX

something like this

public struct WrappedInt
    {
        private readonly int _value;

        public WrappedInt(int val)
        {
            _value = val;
        }

        public static implicit operator WrappedInt(int val)
        {
            return new WrappedInt(val);
        }

       ... 
    }

....

WrappedInt wrapped = 1;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question