diff --git a/DS3ConnectionInfo/App.config b/DS3ConnectionInfo/App.config index 362897a..ec5eee0 100644 --- a/DS3ConnectionInfo/App.config +++ b/DS3ConnectionInfo/App.config @@ -133,6 +133,12 @@ + + 250 + + + False + diff --git a/DS3ConnectionInfo/DS3Interop.cs b/DS3ConnectionInfo/DS3Interop.cs index 2dfe7a4..35e4d43 100644 --- a/DS3ConnectionInfo/DS3Interop.cs +++ b/DS3ConnectionInfo/DS3Interop.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.Globalization; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using DS3ConnectionInfo.WinAPI; @@ -35,20 +36,96 @@ public enum NetStatus } /// - /// BaseB (WorldChrMan) address + /// Ways of joining a DS3 online session. /// - public const long BaseB = 0x144768E78; + public enum JoinMethod + { + None, + Arena, + Convenant, + RedEyeOrb, + WhiteSign, + RedSign + } + + private static readonly JoinMethod[] invTypeToJoinMethod = new JoinMethod[22] + { + JoinMethod.None, + JoinMethod.WhiteSign, + JoinMethod.RedSign, + JoinMethod.RedEyeOrb, + JoinMethod.WhiteSign, + JoinMethod.None, // 5 Missing from TGA list + JoinMethod.Convenant, + JoinMethod.Convenant, + JoinMethod.None, // (Guardian of Rosaria) + JoinMethod.Convenant, + JoinMethod.Convenant, + JoinMethod.None, // (Avatar) + JoinMethod.Arena, + JoinMethod.None, // (Umbasa White) + JoinMethod.WhiteSign, + JoinMethod.RedSign, + JoinMethod.RedSign, + JoinMethod.RedEyeOrb, + JoinMethod.RedEyeOrb, + JoinMethod.None, // (Force Join Session) + JoinMethod.None, // (Red Hunter) + JoinMethod.Convenant + }; + + public struct SpEffect + { + public int id; + public float durationLeft; + public float duration; + public float interval; + } + + [StructLayout(LayoutKind.Explicit)] + private struct SpEffectInternal + { + [FieldOffset(0x00)] + public float durationLeft; + [FieldOffset(0x04)] + public float duration; + [FieldOffset(0x08)] + public float interval; + [FieldOffset(0x60)] + public int id; + [FieldOffset(0x78)] + public long ptrNext; + public SpEffect ToSpEffect() + { + return new SpEffect { id = id, duration = duration, durationLeft = durationLeft, interval = interval }; + } + } /// - /// SprjSessionManager address + /// BaseA (Game) address /// - public const long SprjSession = 0x144780990; + public const long BaseA = 0x144740178; + + /// + /// BaseB (WorldChrMan) address + /// + public const long BaseB = 0x144768E78; /// /// BaseC (GameOptionMan) address /// public const long BaseC = 0x144743AB0; + /// + /// FRPGNet address + /// + public const long BaseE = 0x14473FD08; + + /// + /// SprjSessionManager address + /// + public const long SprjSession = 0x144780990; + /// /// DS3.exe Base Address /// @@ -127,8 +204,6 @@ public static bool TryAttach() if (pArr.Length == 0) return false; Process = pArr[0]; - for (int i = 1; i < pArr.Length; i++) pArr[i].Dispose(); - ProcHandle = Kernel32.OpenProcess(ProcessAccessFlags.AllAccess, false, Process.Id); if (ProcHandle == IntPtr.Zero) Detach(); return ProcHandle != IntPtr.Zero; @@ -212,5 +287,33 @@ public static bool IsMyWorld() { return MemoryManager.ReadGenericPtr(ProcHandle, BaseC, 0xB1E) == 1; } + + public static IEnumerable ActiveSpEffects() + { + long addrNext = MemoryManager.ReadGenericPtr(ProcHandle, BaseA, 0x10, 0x920, 0x8); + + while (addrNext != 0) + { + SpEffectInternal fx = MemoryManager.ReadGeneric(ProcHandle, addrNext); + addrNext = fx.ptrNext; + yield return fx.ToSpEffect(); + } + } + + public static bool IsSearchingInvasion() + { + foreach (SpEffect fx in ActiveSpEffects()) + { + if (fx.id == 9200) return true; + } + return false; + } + + public static JoinMethod GetJoinMethod() + { + int invType = MemoryManager.ReadGenericPtr(ProcHandle, BaseC, 0xC54); + if (invType > 0 || invType < -21) return JoinMethod.None; + else return invTypeToJoinMethod[-invType]; + } } } diff --git a/DS3ConnectionInfo/MainWindow.xaml b/DS3ConnectionInfo/MainWindow.xaml index 1af5a9f..5322d38 100644 --- a/DS3ConnectionInfo/MainWindow.xaml +++ b/DS3ConnectionInfo/MainWindow.xaml @@ -23,7 +23,14 @@ - + + + + + + + + @@ -89,8 +96,8 @@ + + + + + + + + + + + @@ -148,16 +160,21 @@ - + + - - + + + + + Slot Char. Name Team @@ -170,11 +187,11 @@ Late Packet % Location - -