public override object GetData(HookProcess process) { var result = new SigPerfData(); int entrySize = 12; int numEntries = 99; byte[] performanceData = process.GetByteArray(baseAddress, entrySize * numEntries); for (int i = 0; i < numEntries; i++) { int offset = (i * entrySize); float animation = BitConverter.TryToSingle(performanceData, offset + 0); byte id = performanceData[offset + 4]; byte unknown1 = performanceData[offset + 5]; byte variant = performanceData[offset + 6]; // Animation (hand to left or right) byte type = performanceData[offset + 7]; byte status = performanceData[offset + 8]; byte instrument = performanceData[offset + 9]; int unknown2 = BitConverter.TryToInt16(performanceData, offset + 10); if (id >= 0 && id <= 99) { PerformanceData item = new PerformanceData(); item.Animation = animation; item.Unknown1 = (byte)unknown1; item.Id = (byte)id; item.Variant = (byte)variant; item.Type = (byte)type; item.Status = (Performance.Status)status; item.Instrument = (Performance.Instrument)instrument; if (!result.Performances.ContainsKey(id)) { result.Performances[id] = item; } } } return(result); }
public override object GetData(HookProcess process) { if (baseAddress.ToInt64() <= 6496) { return(null); } if (!Offsets.ContainsKey("SourceSize") || !Offsets.ContainsKey("EntityCount")) { Console.WriteLine("Couldn't find basic"); return(null); } if (!Offsets.ContainsKey("ID") || !Offsets.ContainsKey("Type")) { Console.WriteLine("Couldn't find player basic"); return(null); } var data = new SigActorsData(); int sourceSize = (int)Offsets["SourceSize"]; int limit = (int)Offsets["EntityCount"]; int ptrSize = 8; // 64 bit byte[] characterAddressMap = process.GetByteArray(baseAddress, ptrSize * limit); //byte[] baseSource = process.GetByteArray(baseAddress, sourceSize); Dictionary <IntPtr, IntPtr> uniqueAddresses = new Dictionary <IntPtr, IntPtr>(); IntPtr firstAddress = IntPtr.Zero; var firstTime = true; for (var i = 0; i < limit; i++) { IntPtr characterAddress = new IntPtr(BitConverter.TryToInt64(characterAddressMap, ptrSize * i)); if (characterAddress == IntPtr.Zero) { continue; } if (firstTime) { firstAddress = characterAddress; firstTime = false; } uniqueAddresses[characterAddress] = characterAddress; } // Add everyone to removed foreach (KeyValuePair <uint, ActorData> kvp in tempActors) { data.removedActors.Add(kvp.Key, new ActorData() { id = kvp.Value.id, }); } foreach (KeyValuePair <IntPtr, IntPtr> kvp in uniqueAddresses) { var characterAddress = new IntPtr(kvp.Value.ToInt64()); byte[] playerSource = process.GetByteArray(characterAddress, sourceSize); ActorData existing = null; ActorData actorData = new ActorData() { id = BitConverter.TryToUInt32(playerSource, Offsets["ID"]), }; bool addActor = false; int type = playerSource[Offsets["Type"]]; if (type == 0x01) // Player { if (data.removedActors.ContainsKey(actorData.id)) { data.removedActors.Remove(actorData.id); tempActors.TryGetValue(actorData.id, out existing); } else { addActor = true; } // Was used for TargetID //var isFirstEntry = kvp.Value.ToInt64() == firstAddress.ToInt64(); if (true) { if (Offsets.TryGetValue("Name", out int nameid)) { actorData.name = process.GetStringFromBytes(playerSource, nameid); } if (Offsets.TryGetValue("PerformanceID", out int perfid)) { actorData.perfid = playerSource[perfid]; } } if (actorData.id != 0) { if (expiringActors.ContainsKey(actorData.id)) { expiringActors.Remove(actorData.id); } } else { // Removed data.addedActors.Remove(actorData.id); continue; } // Only getting memory, no checks? //EnsureMapAndZone(entry); /* * if (isFirstEntry) { * if (targetAddress.ToInt64() > 0) { * byte[] targetInfoSource = MemoryHandler.Instance.GetByteArray(targetAddress, 128); * entry.TargetID = (int)BitConverter.TryToUInt32(targetInfoSource, MemoryHandler.Instance.Structures.ActorItem.ID); * } * } */ // If removed player, just continue if (existing != null) { continue; } if (addActor) { if (!tempActors.ContainsKey(actorData.id)) { tempActors.Add(actorData.id, actorData); } data.addedActors.Add(actorData.id, actorData); } } } // Stale removal? DateTime now = DateTime.Now; TimeSpan staleActorRemovalTime = TimeSpan.FromSeconds(0.25); foreach (KeyValuePair <uint, ActorData> kvp2 in data.removedActors) { if (!expiringActors.ContainsKey(kvp2.Key)) { expiringActors[kvp2.Key] = now + staleActorRemovalTime; } } // check expiring list for stale actors foreach (KeyValuePair <uint, DateTime> kvp2 in expiringActors.ToList()) { if (now > kvp2.Value) { tempActors.Remove(kvp2.Key); expiringActors.Remove(kvp2.Key); } else { data.removedActors.Remove(kvp2.Key); } } data.currentActors = tempActors; return(data); }
private List <byte> ResolveEntry(HookProcess process, int offset, int length) { return(new List <byte>(process.GetByteArray(new IntPtr(ChatLogPointers.LogStart + offset), length - offset))); }