예제 #1
0
        void UpdateName(ProcessMemoryAccessor accessor)
        {
            if (accessor == null)
            {
                throw new ArgumentNullException("accessor");
            }

            string name = null;

            if (version != null && version.ContainsVariable(CharacterNameKey))
            {
                Debug.WriteLine($"Updating character name (pid={accessor.ProcessId})...");

                Stream stream = null;
                try
                {
                    stream = accessor.GetStream();
                    using (var reader = new BinaryReader(stream, Encoding.ASCII))
                    {
                        stream = null;

                        var nameVariable = version.GetVariable(CharacterNameKey);
                        nameVariable.TryReadString(reader, out name);
                    }
                }
                finally { stream?.Dispose(); }

                Debug.WriteLine($"CharacterName = {name}");
            }

            if (!string.IsNullOrWhiteSpace(name))
            {
                Name = name;
            }
        }