/// <summary>Called when the trainer needs to be detached from the game's process.</summary>
        private void DetachFromGame()
        {
            // Detach from the target process
            if (GameMemoryIO.IsAttached())
            {
                // If the game's process is still running, all cheats must be disabled
                if (GameMemoryIO.TargetProcess.HasExited == false)
                {
                    foreach (ECheat curCheat in Enum.GetValues(typeof(ECheat)))
                    {
                        SetCheatEnabled(curCheat, false);
                    }
                }

                // Release injected memory, cleanup and detach
                GameMemoryInjector.ResetAllocatedMemoryData();
                GameMemoryIO.DetachFromProcess();
            }

            // Reset all of the values of the DependencyProperty objects which represent injected variables
            foreach (KeyValuePair <DependencyProperty, EVariable> curPair in sm_dependencyPropertyToInjectedVariable)
            {
                // Retrieve the initial value of the injected variable
                DependencyProperty varDepProp = curPair.Key;
                EVariable          varID      = curPair.Value;

                FieldInfo enumeratorInfo           = typeof(EVariable).GetField(varID.ToString());
                VariableDefinitionAttribute varDef = enumeratorInfo.GetCustomAttribute <VariableDefinitionAttribute>();

                // Reset the variable back to its initial value
                this.SetValue(varDepProp, varDef.InitialValue);
            }
        }
        /// <summary>
        /// Registers a DependencyProperty which is associated to a given injected variable of the trainer.
        /// The default value and type for the property is retrieved from the associated injected variable.
        /// </summary>
        /// <param name="propertyName">The name of the DependencyProperty to be registered.</param>
        /// <param name="varID">The injected variable to be associated with the DependencyProperty.</param>
        /// <returns>Returns a DependencyProperty representing the injected variable.</returns>
        private static DependencyProperty RegisterInjectedVariableDependencyProperty(string propertyName, EVariable varID)
        {
            // Retrieve information about the variable
            MemberInfo enumeratorInfo          = typeof(EVariable).GetField(varID.ToString());
            VariableDefinitionAttribute varDef = enumeratorInfo.GetCustomAttribute <VariableDefinitionAttribute>();
            Object defaultVarValue             = varDef.InitialValue;
            Type   varType = varDef.InitialValue.GetType();

            // Register the DependencyProperty
            DependencyProperty newDepProperty = DependencyProperty.Register(propertyName, varType, typeof(MainWindow),
                                                                            new PropertyMetadata(defaultVarValue, InjectedVariableValueChanged));

            sm_dependencyPropertyToInjectedVariable.Add(newDepProperty, varID);
            return(newDepProperty);
        }