• Hello
Search Results for

    Show / Hide Table of Contents

    Struct ProtectedDecimal

    Drop-in replacement for System.Decimal that stores the value as its raw System.Decimal.GetBits(System.Decimal) int array and uses a System.Double honeypot to report tampering to the .

    Implements
    IProtected
    IDisposable
    ISerializationCallbackReceiver
    Namespace: GUPS.AntiCheat.Protected
    Assembly: cs.temp.dll.dll
    Syntax
    public struct ProtectedDecimal
    Remarks

    The honeypot is stored as a System.Double, so integrity checks for decimal values that fall outside System.Double's precision range may yield false positives.

    Constructors

    ProtectedDecimal(Decimal)

    Initializes a new protected decimal with the specified value.

    Declaration
    public ProtectedDecimal(decimal _Value = 0M)
    Parameters
    Type Name Description
    System.Decimal _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 decimal Value { get; set; }
    Property Value
    Type Description
    System.Decimal
    Remarks

    Reading the value runs an integrity check; if the honeypot has been tampered with, the is notified.

    Methods

    CheckIntegrity()

    Returns true when the honeypot still matches the stored value (compared as System.Double).

    Declaration
    public bool CheckIntegrity()
    Returns
    Type Description
    System.Boolean

    true if the value is intact; otherwise false.

    Dispose()

    Clears the stored bit array.

    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

    true if equal; otherwise false.

    Overrides
    System.ValueType.Equals(System.Object)

    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
    System.ValueType.GetHashCode()

    Obfuscate()

    Re-stores the current value (kept for interface symmetry; no secret is rerolled for the decimal variant).

    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
    System.ValueType.ToString()

    Operators

    Equality(ProtectedDecimal, ProtectedDecimal)

    Returns true when both protected values represent the same number.

    Declaration
    public static bool operator ==(ProtectedDecimal v1, ProtectedDecimal v2)
    Parameters
    Type Name Description
    ProtectedDecimal v1

    First operand.

    ProtectedDecimal v2

    Second operand.

    Returns
    Type Description
    System.Boolean

    true if equal; otherwise false.

    GreaterThan(ProtectedDecimal, ProtectedDecimal)

    Returns true when the first value is greater than the second.

    Declaration
    public static bool operator>(ProtectedDecimal v1, ProtectedDecimal v2)
    Parameters
    Type Name Description
    ProtectedDecimal v1

    First operand.

    ProtectedDecimal v2

    Second operand.

    Returns
    Type Description
    System.Boolean

    true if v1 > v2; otherwise false.

    GreaterThanOrEqual(ProtectedDecimal, ProtectedDecimal)

    Returns true when the first value is greater than or equal to the second.

    Declaration
    public static bool operator >=(ProtectedDecimal v1, ProtectedDecimal v2)
    Parameters
    Type Name Description
    ProtectedDecimal v1

    First operand.

    ProtectedDecimal v2

    Second operand.

    Returns
    Type Description
    System.Boolean

    true if v1 >= v2; otherwise false.

    Implicit(ProtectedDecimal to ProtectedDouble)

    Implicitly converts a protected decimal to a ProtectedDouble.

    Declaration
    public static implicit operator ProtectedDouble(ProtectedDecimal _Value)
    Parameters
    Type Name Description
    ProtectedDecimal _Value

    Protected decimal to convert.

    Returns
    Type Description
    ProtectedDouble

    A protected double holding the converted value.

    Implicit(ProtectedDecimal to ProtectedFloat)

    Implicitly converts a protected decimal to a ProtectedFloat (narrows).

    Declaration
    public static implicit operator ProtectedFloat(ProtectedDecimal _Value)
    Parameters
    Type Name Description
    ProtectedDecimal _Value

    Protected decimal to convert.

    Returns
    Type Description
    ProtectedFloat

    A protected float holding the narrowed value.

    Implicit(ProtectedDecimal to ProtectedInt16)

    Implicitly converts a protected decimal to a ProtectedInt16 (truncates).

    Declaration
    public static implicit operator ProtectedInt16(ProtectedDecimal _Value)
    Parameters
    Type Name Description
    ProtectedDecimal _Value

    Protected decimal to convert.

    Returns
    Type Description
    ProtectedInt16

    A protected Int16 holding the truncated value.

    Implicit(ProtectedDecimal to ProtectedInt32)

    Implicitly converts a protected decimal to a ProtectedInt32 (truncates).

    Declaration
    public static implicit operator ProtectedInt32(ProtectedDecimal _Value)
    Parameters
    Type Name Description
    ProtectedDecimal _Value

    Protected decimal to convert.

    Returns
    Type Description
    ProtectedInt32

    A protected Int32 holding the truncated value.

    Implicit(ProtectedDecimal to ProtectedInt64)

    Implicitly converts a protected decimal to a ProtectedInt64 (truncates).

    Declaration
    public static implicit operator ProtectedInt64(ProtectedDecimal _Value)
    Parameters
    Type Name Description
    ProtectedDecimal _Value

    Protected decimal to convert.

    Returns
    Type Description
    ProtectedInt64

    A protected Int64 holding the truncated value.

    Implicit(ProtectedDecimal to Decimal)

    Implicitly unwraps a protected decimal to its decimal value.

    Declaration
    public static implicit operator decimal (ProtectedDecimal _Value)
    Parameters
    Type Name Description
    ProtectedDecimal _Value

    Protected decimal to unwrap.

    Returns
    Type Description
    System.Decimal

    The unobfuscated decimal value.

    Implicit(ProtectedDouble to ProtectedDecimal)

    Implicitly converts a ProtectedDouble to a protected decimal.

    Declaration
    public static implicit operator ProtectedDecimal(ProtectedDouble _Value)
    Parameters
    Type Name Description
    ProtectedDouble _Value

    Protected double to convert.

    Returns
    Type Description
    ProtectedDecimal

    A protected decimal holding the converted value.

    Implicit(ProtectedFloat to ProtectedDecimal)

    Implicitly converts a ProtectedFloat to a protected decimal.

    Declaration
    public static implicit operator ProtectedDecimal(ProtectedFloat _Value)
    Parameters
    Type Name Description
    ProtectedFloat _Value

    Protected float to convert.

    Returns
    Type Description
    ProtectedDecimal

    A protected decimal holding the converted value.

    Implicit(ProtectedInt16 to ProtectedDecimal)

    Implicitly converts a ProtectedInt16 to a protected decimal.

    Declaration
    public static implicit operator ProtectedDecimal(ProtectedInt16 _Value)
    Parameters
    Type Name Description
    ProtectedInt16 _Value

    Protected Int16 to convert.

    Returns
    Type Description
    ProtectedDecimal

    A protected decimal holding the converted value.

    Implicit(ProtectedInt32 to ProtectedDecimal)

    Implicitly converts a ProtectedInt32 to a protected decimal.

    Declaration
    public static implicit operator ProtectedDecimal(ProtectedInt32 _Value)
    Parameters
    Type Name Description
    ProtectedInt32 _Value

    Protected Int32 to convert.

    Returns
    Type Description
    ProtectedDecimal

    A protected decimal holding the converted value.

    Implicit(ProtectedInt64 to ProtectedDecimal)

    Implicitly converts a ProtectedInt64 to a protected decimal.

    Declaration
    public static implicit operator ProtectedDecimal(ProtectedInt64 _Value)
    Parameters
    Type Name Description
    ProtectedInt64 _Value

    Protected Int64 to convert.

    Returns
    Type Description
    ProtectedDecimal

    A protected decimal holding the converted value.

    Implicit(Decimal to ProtectedDecimal)

    Implicitly wraps a decimal in a protected decimal.

    Declaration
    public static implicit operator ProtectedDecimal(decimal _Value)
    Parameters
    Type Name Description
    System.Decimal _Value

    Value to wrap.

    Returns
    Type Description
    ProtectedDecimal

    A protected decimal holding the given value.

    Inequality(ProtectedDecimal, ProtectedDecimal)

    Returns true when the two protected values represent different numbers.

    Declaration
    public static bool operator !=(ProtectedDecimal v1, ProtectedDecimal v2)
    Parameters
    Type Name Description
    ProtectedDecimal v1

    First operand.

    ProtectedDecimal v2

    Second operand.

    Returns
    Type Description
    System.Boolean

    true if not equal; otherwise false.

    LessThan(ProtectedDecimal, ProtectedDecimal)

    Returns true when the first value is less than the second.

    Declaration
    public static bool operator <(ProtectedDecimal v1, ProtectedDecimal v2)
    Parameters
    Type Name Description
    ProtectedDecimal v1

    First operand.

    ProtectedDecimal v2

    Second operand.

    Returns
    Type Description
    System.Boolean

    true if v1 < v2; otherwise false.

    LessThanOrEqual(ProtectedDecimal, ProtectedDecimal)

    Returns true when the first value is less than or equal to the second.

    Declaration
    public static bool operator <=(ProtectedDecimal v1, ProtectedDecimal v2)
    Parameters
    Type Name Description
    ProtectedDecimal v1

    First operand.

    ProtectedDecimal v2

    Second operand.

    Returns
    Type Description
    System.Boolean

    true if v1 <= v2; otherwise false.

    Implements

    IProtected
    IDisposable
    ISerializationCallbackReceiver

    See Also

    ProtectedInt32
    In This Article
    Back to top GuardingPearSoftware documentation