Struct ProtectedUInt16
Drop-in replacement for System.UInt16 that obfuscates the value in memory and reports tampering to the
Implements
Namespace: GUPS.AntiCheat.Protected
Assembly: cs.temp.dll.dll
Syntax
public struct ProtectedUInt16
Constructors
ProtectedUInt16(UInt16)
Initializes a new protected UInt16 with the specified value.
Declaration
public ProtectedUInt16(UInt16 _Value = null)
Parameters
| Type | Name | Description |
|---|---|---|
| UInt16 | _Value | Initial value. |
Properties
HasIntegrity
Gets a value indicating whether the protected value still has integrity (i.e. the honeypot has not been tampered with).
Declaration
public bool HasIntegrity { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Value
Gets or sets the unobfuscated value.
Declaration
public UInt16 Value { get; set; }
Property Value
| Type | Description |
|---|---|
| UInt16 |
Remarks
Reading the value runs an integrity check; if the honeypot has been tampered with, the
Methods
CheckIntegrity()
Returns true when the honeypot still matches the obfuscated value.
Declaration
public bool CheckIntegrity()
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Dispose()
Clears the obfuscated value and the secret.
Declaration
public void Dispose()
Equals(Object)
Returns true when this protected value equals the given object.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj | Object to compare with. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Overrides
GetHashCode()
Returns the hash code of the unobfuscated value.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 | Hash code of the unobfuscated value. |
Overrides
Obfuscate()
Rerolls the secret and re-obfuscates the current value.
Declaration
public void Obfuscate()
OnAfterDeserialize()
Unity deserialization hook; rebuilds the obfuscation state from the deserialized honeypot value.
Declaration
public void OnAfterDeserialize()
OnBeforeSerialize()
Unity serialization hook; writes the true value into the honeypot field.
Declaration
public void OnBeforeSerialize()
ToString()
Returns the string representation of the unobfuscated value.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String | The string representation of the unobfuscated value. |
Overrides
Operators
Addition(ProtectedUInt16, ProtectedUInt16)
Adds two protected values.
Declaration
public static ProtectedUInt16 operator +(ProtectedUInt16 v1, ProtectedUInt16 v2)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedUInt16 | v1 | First operand. |
| ProtectedUInt16 | v2 | Second operand. |
Returns
| Type | Description |
|---|---|
| ProtectedUInt16 | The sum. |
Division(ProtectedUInt16, ProtectedUInt16)
Divides the first protected value by the second.
Declaration
public static ProtectedUInt16 operator /(ProtectedUInt16 v1, ProtectedUInt16 v2)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedUInt16 | v1 | First operand. |
| ProtectedUInt16 | v2 | Second operand. |
Returns
| Type | Description |
|---|---|
| ProtectedUInt16 | The quotient. |
Equality(ProtectedUInt16, ProtectedUInt16)
Returns true when both protected values represent the same number.
Declaration
public static bool operator ==(ProtectedUInt16 v1, ProtectedUInt16 v2)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedUInt16 | v1 | First operand. |
| ProtectedUInt16 | v2 | Second operand. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
GreaterThan(ProtectedUInt16, ProtectedUInt16)
Returns true when the first value is greater than the second.
Declaration
public static bool operator>(ProtectedUInt16 v1, ProtectedUInt16 v2)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedUInt16 | v1 | First operand. |
| ProtectedUInt16 | v2 | Second operand. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
GreaterThanOrEqual(ProtectedUInt16, ProtectedUInt16)
Returns true when the first value is greater than or equal to the second.
Declaration
public static bool operator >=(ProtectedUInt16 v1, ProtectedUInt16 v2)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedUInt16 | v1 | First operand. |
| ProtectedUInt16 | v2 | Second operand. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Implicit(ProtectedUInt16 to UInt16)
Implicitly unwraps a protected UInt16 to its UInt16 value.
Declaration
public static implicit operator UInt16(ProtectedUInt16 _Value)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedUInt16 | _Value | Protected UInt16 to unwrap. |
Returns
| Type | Description |
|---|---|
| UInt16 | The unobfuscated UInt16 value. |
Implicit(UInt16 to ProtectedUInt16)
Implicitly wraps a UInt16 in a protected UInt16.
Declaration
public static implicit operator ProtectedUInt16(UInt16 _Value)
Parameters
| Type | Name | Description |
|---|---|---|
| UInt16 | _Value | Value to wrap. |
Returns
| Type | Description |
|---|---|
| ProtectedUInt16 | A protected UInt16 holding the given value. |
Inequality(ProtectedUInt16, ProtectedUInt16)
Returns true when the two protected values represent different numbers.
Declaration
public static bool operator !=(ProtectedUInt16 v1, ProtectedUInt16 v2)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedUInt16 | v1 | First operand. |
| ProtectedUInt16 | v2 | Second operand. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
LessThan(ProtectedUInt16, ProtectedUInt16)
Returns true when the first value is less than the second.
Declaration
public static bool operator <(ProtectedUInt16 v1, ProtectedUInt16 v2)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedUInt16 | v1 | First operand. |
| ProtectedUInt16 | v2 | Second operand. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
LessThanOrEqual(ProtectedUInt16, ProtectedUInt16)
Returns true when the first value is less than or equal to the second.
Declaration
public static bool operator <=(ProtectedUInt16 v1, ProtectedUInt16 v2)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedUInt16 | v1 | First operand. |
| ProtectedUInt16 | v2 | Second operand. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Multiply(ProtectedUInt16, ProtectedUInt16)
Multiplies two protected values.
Declaration
public static ProtectedUInt16 operator *(ProtectedUInt16 v1, ProtectedUInt16 v2)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedUInt16 | v1 | First operand. |
| ProtectedUInt16 | v2 | Second operand. |
Returns
| Type | Description |
|---|---|
| ProtectedUInt16 | The product. |
Subtraction(ProtectedUInt16, ProtectedUInt16)
Subtracts the second protected value from the first.
Declaration
public static ProtectedUInt16 operator -(ProtectedUInt16 v1, ProtectedUInt16 v2)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedUInt16 | v1 | First operand. |
| ProtectedUInt16 | v2 | Second operand. |
Returns
| Type | Description |
|---|---|
| ProtectedUInt16 | The difference. |