예제 #1
0
 public Reader(MemoryHandler memoryHandler)
 {
     Scanner              = memoryHandler.Scanner;
     MemoryHandler        = memoryHandler;
     MemoryHandler.Reader = this;
     _chatLogReader       = new ChatLogReader(memoryHandler);
 }
예제 #2
0
파일: Reader.cs 프로젝트: qitana/sharlayan
        public Reader(MemoryHandler memoryHandler)
        {
            this._memoryHandler = memoryHandler;

            this._chatLogReader = new ChatLogReader(this._memoryHandler);

            this._chatLogWorkerDelegate = new ChatLogWorkerDelegate();
            this._monsterWorkerDelegate = new MonsterWorkerDelegate();
            this._npcWorkerDelegate     = new NPCWorkerDelegate();
            this._partyWorkerDelegate   = new PartyWorkerDelegate();
            this._pcWorkerDelegate      = new PCWorkerDelegate();

            this._actorItemResolver   = new ActorItemResolver(this._memoryHandler, this._pcWorkerDelegate, this._npcWorkerDelegate, this._monsterWorkerDelegate);
            this._playerInfoResolver  = new PlayerInfoResolver(this._memoryHandler);
            this._partyMemberResolver = new PartyMemberResolver(this._memoryHandler, this._pcWorkerDelegate, this._npcWorkerDelegate, this._monsterWorkerDelegate);
            this._jobResourceResolver = new JobResourceResolver(this._memoryHandler);
        }
예제 #3
0
        public static async Task <ChatLogResult> GetChatLog(int previousArrayIndex = 0, int previousOffset = 0)
        {
            var result = new ChatLogResult();

            if (!CanGetChatLog() || !MemoryHandler.Instance.IsAttached)
            {
                return(result);
            }

            ChatLogReader.PreviousArrayIndex = previousArrayIndex;
            ChatLogReader.PreviousOffset     = previousOffset;

            var chatPointerMap = (IntPtr)Scanner.Instance.Locations[Signatures.ChatLogKey];

            if (chatPointerMap.ToInt64() <= 20)
            {
                return(result);
            }

            List <List <byte> > buffered = new List <List <byte> >();

            try {
                ChatLogReader.Indexes.Clear();
                ChatLogReader.ChatLogPointers = new ChatLogPointers {
                    LineCount        = (uint)MemoryHandler.Instance.GetPlatformUInt(chatPointerMap),
                    OffsetArrayStart = MemoryHandler.Instance.GetPlatformUInt(chatPointerMap, MemoryHandler.Instance.Structures.ChatLogPointers.OffsetArrayStart),
                    OffsetArrayPos   = MemoryHandler.Instance.GetPlatformUInt(chatPointerMap, MemoryHandler.Instance.Structures.ChatLogPointers.OffsetArrayPos),
                    OffsetArrayEnd   = MemoryHandler.Instance.GetPlatformUInt(chatPointerMap, MemoryHandler.Instance.Structures.ChatLogPointers.OffsetArrayEnd),
                    LogStart         = MemoryHandler.Instance.GetPlatformUInt(chatPointerMap, MemoryHandler.Instance.Structures.ChatLogPointers.LogStart),
                    LogNext          = MemoryHandler.Instance.GetPlatformUInt(chatPointerMap, MemoryHandler.Instance.Structures.ChatLogPointers.LogNext),
                    LogEnd           = MemoryHandler.Instance.GetPlatformUInt(chatPointerMap, MemoryHandler.Instance.Structures.ChatLogPointers.LogEnd)
                };

                ChatLogReader.EnsureArrayIndexes();

                var currentArrayIndex = (ChatLogReader.ChatLogPointers.OffsetArrayPos - ChatLogReader.ChatLogPointers.OffsetArrayStart) / 4;
                if (ChatLogReader.ChatLogFirstRun)
                {
                    ChatLogReader.ChatLogFirstRun    = false;
                    ChatLogReader.PreviousOffset     = ChatLogReader.Indexes[(int)currentArrayIndex - 1];
                    ChatLogReader.PreviousArrayIndex = (int)currentArrayIndex - 1;
                }
                else
                {
                    if (currentArrayIndex < ChatLogReader.PreviousArrayIndex)
                    {
                        buffered.AddRange(ChatLogReader.ResolveEntries(ChatLogReader.PreviousArrayIndex, 1000));
                        ChatLogReader.PreviousOffset     = 0;
                        ChatLogReader.PreviousArrayIndex = 0;
                    }

                    if (ChatLogReader.PreviousArrayIndex < currentArrayIndex)
                    {
                        buffered.AddRange(ChatLogReader.ResolveEntries(ChatLogReader.PreviousArrayIndex, (int)currentArrayIndex));
                    }

                    ChatLogReader.PreviousArrayIndex = (int)currentArrayIndex;
                }
            }
            catch (Exception ex) {
                MemoryHandler.Instance.RaiseException(Logger, ex, true);
            }

            foreach (List <byte> bytes in buffered.Where(b => b.Count > 0))
            {
                try {
                    ChatLogItem chatLogEntry = ChatEntry.Process(bytes.ToArray());
                    if (Regex.IsMatch(chatLogEntry.Combined, @"[\w\d]{4}::?.+"))
                    {
                        result.ChatLogItems.Add(chatLogEntry);
                    }
                }
                catch (Exception ex) {
                    MemoryHandler.Instance.RaiseException(Logger, ex, true);
                }
            }

            result.PreviousArrayIndex = ChatLogReader.PreviousArrayIndex;
            result.PreviousOffset     = ChatLogReader.PreviousOffset;

            return(result);
        }