Struct ProtectedDouble
Drop-in replacement for System.Double that obfuscates the value in memory (via a GUPS.AntiCheat.Protected.ULongDouble reinterpret cast) and reports tampering to the
Implements
Namespace: GUPS.AntiCheat.Protected
Assembly: cs.temp.dll.dll
Syntax
public struct ProtectedDouble
Constructors
ProtectedDouble(Double)
Initializes a new protected double with the specified value.
Declaration
public ProtectedDouble(double value = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | 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 double Value { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
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, scratch union and 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 obfuscated bit pattern.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 | Hash code based on the stored obfuscated bits (does not unobfuscate). |
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(ProtectedDouble, ProtectedDouble)
Adds two protected values.
Declaration
public static ProtectedDouble operator +(ProtectedDouble v1, ProtectedDouble v2)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedDouble | v1 | First operand. |
| ProtectedDouble | v2 | Second operand. |
Returns
| Type | Description |
|---|---|
| ProtectedDouble | The sum. |
Division(ProtectedDouble, ProtectedDouble)
Divides the first protected value by the second.
Declaration
public static ProtectedDouble operator /(ProtectedDouble v1, ProtectedDouble v2)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedDouble | v1 | First operand. |
| ProtectedDouble | v2 | Second operand. |
Returns
| Type | Description |
|---|---|
| ProtectedDouble | The quotient. |
Equality(ProtectedDouble, ProtectedDouble)
Returns true when both protected values represent the same number.
Declaration
public static bool operator ==(ProtectedDouble v1, ProtectedDouble v2)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedDouble | v1 | First operand. |
| ProtectedDouble | v2 | Second operand. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Remarks
Uses direct System.Double equality and is therefore subject to the usual floating-point precision caveats.
GreaterThan(ProtectedDouble, ProtectedDouble)
Returns true when the first value is greater than the second.
Declaration
public static bool operator>(ProtectedDouble v1, ProtectedDouble v2)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedDouble | v1 | First operand. |
| ProtectedDouble | v2 | Second operand. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
GreaterThanOrEqual(ProtectedDouble, ProtectedDouble)
Returns true when the first value is greater than or equal to the second.
Declaration
public static bool operator >=(ProtectedDouble v1, ProtectedDouble v2)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedDouble | v1 | First operand. |
| ProtectedDouble | v2 | Second operand. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Implicit(ProtectedDouble to ProtectedFloat)
Implicitly converts a protected double to a ProtectedFloat (narrows).
Declaration
public static implicit operator ProtectedFloat(ProtectedDouble _Value)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedDouble | _Value | Protected double to convert. |
Returns
| Type | Description |
|---|---|
| ProtectedFloat | A protected float holding the narrowed value. |
Implicit(ProtectedDouble to ProtectedInt16)
Implicitly converts a protected double to a ProtectedInt16 (truncates).
Declaration
public static implicit operator ProtectedInt16(ProtectedDouble _Value)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedDouble | _Value | Protected double to convert. |
Returns
| Type | Description |
|---|---|
| ProtectedInt16 | A protected Int16 holding the truncated value. |
Implicit(ProtectedDouble to ProtectedInt32)
Implicitly converts a protected double to a ProtectedInt32 (truncates).
Declaration
public static implicit operator ProtectedInt32(ProtectedDouble _Value)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedDouble | _Value | Protected double to convert. |
Returns
| Type | Description |
|---|---|
| ProtectedInt32 | A protected Int32 holding the truncated value. |
Implicit(ProtectedDouble to ProtectedInt64)
Implicitly converts a protected double to a ProtectedInt64 (truncates).
Declaration
public static implicit operator ProtectedInt64(ProtectedDouble _Value)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedDouble | _Value | Protected double to convert. |
Returns
| Type | Description |
|---|---|
| ProtectedInt64 | A protected Int64 holding the truncated value. |
Implicit(ProtectedDouble to Double)
Implicitly unwraps a protected double to its double value.
Declaration
public static implicit operator double (ProtectedDouble _Value)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedDouble | _Value | Protected double to unwrap. |
Returns
| Type | Description |
|---|---|
| System.Double | The unobfuscated double value. |
Implicit(ProtectedFloat to ProtectedDouble)
Implicitly converts a ProtectedFloat to a protected double.
Declaration
public static implicit operator ProtectedDouble(ProtectedFloat _Value)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedFloat | _Value | Protected float to convert. |
Returns
| Type | Description |
|---|---|
| ProtectedDouble | A protected double holding the widened value. |
Implicit(ProtectedInt16 to ProtectedDouble)
Implicitly converts a ProtectedInt16 to a protected double.
Declaration
public static implicit operator ProtectedDouble(ProtectedInt16 _Value)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedInt16 | _Value | Protected Int16 to convert. |
Returns
| Type | Description |
|---|---|
| ProtectedDouble | A protected double holding the converted value. |
Implicit(ProtectedInt32 to ProtectedDouble)
Implicitly converts a ProtectedInt32 to a protected double.
Declaration
public static implicit operator ProtectedDouble(ProtectedInt32 _Value)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedInt32 | _Value | Protected Int32 to convert. |
Returns
| Type | Description |
|---|---|
| ProtectedDouble | A protected double holding the converted value. |
Implicit(ProtectedInt64 to ProtectedDouble)
Implicitly converts a ProtectedInt64 to a protected double.
Declaration
public static implicit operator ProtectedDouble(ProtectedInt64 _Value)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedInt64 | _Value | Protected Int64 to convert. |
Returns
| Type | Description |
|---|---|
| ProtectedDouble | A protected double holding the converted value. |
Implicit(Double to ProtectedDouble)
Implicitly wraps a double in a protected double.
Declaration
public static implicit operator ProtectedDouble(double _Value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | _Value | Value to wrap. |
Returns
| Type | Description |
|---|---|
| ProtectedDouble | A protected double holding the given value. |
Inequality(ProtectedDouble, ProtectedDouble)
Returns true when the two protected values represent different numbers.
Declaration
public static bool operator !=(ProtectedDouble v1, ProtectedDouble v2)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedDouble | v1 | First operand. |
| ProtectedDouble | v2 | Second operand. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
LessThan(ProtectedDouble, ProtectedDouble)
Returns true when the first value is less than the second.
Declaration
public static bool operator <(ProtectedDouble v1, ProtectedDouble v2)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedDouble | v1 | First operand. |
| ProtectedDouble | v2 | Second operand. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
LessThanOrEqual(ProtectedDouble, ProtectedDouble)
Returns true when the first value is less than or equal to the second.
Declaration
public static bool operator <=(ProtectedDouble v1, ProtectedDouble v2)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedDouble | v1 | First operand. |
| ProtectedDouble | v2 | Second operand. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Multiply(ProtectedDouble, ProtectedDouble)
Multiplies two protected values.
Declaration
public static ProtectedDouble operator *(ProtectedDouble v1, ProtectedDouble v2)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedDouble | v1 | First operand. |
| ProtectedDouble | v2 | Second operand. |
Returns
| Type | Description |
|---|---|
| ProtectedDouble | The product. |
Subtraction(ProtectedDouble, ProtectedDouble)
Subtracts the second protected value from the first.
Declaration
public static ProtectedDouble operator -(ProtectedDouble v1, ProtectedDouble v2)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtectedDouble | v1 | First operand. |
| ProtectedDouble | v2 | Second operand. |
Returns
| Type | Description |
|---|---|
| ProtectedDouble | The difference. |