From bbf6635e9824ea3376d7f0aec6287476ce7fea93 Mon Sep 17 00:00:00 2001 From: denverquane Date: Sat, 19 Sep 2020 19:30:48 -0600 Subject: [PATCH] Misc bugs (thanks photo) --- AmongUsCapture/DebugConsole.cs | 30 +++++++++++++++--------------- AmongUsCapture/GameMemReader.cs | 1 + AmongUsCapture/PlayerInfo.cs | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/AmongUsCapture/DebugConsole.cs b/AmongUsCapture/DebugConsole.cs index e4b2e58f..e1556d90 100644 --- a/AmongUsCapture/DebugConsole.cs +++ b/AmongUsCapture/DebugConsole.cs @@ -12,21 +12,21 @@ public void Run() GameMemReader.getInstance().GameStateChanged += GameStateChangedHandler; GameMemReader.getInstance().PlayerChanged += PlayerChangedHandler; - //while(true) - //{ - // string command = Console.ReadLine(); - // Console.WriteLine($"Received command: {command}"); - // if (command == "list") - // { - // Console.WriteLine("Player List:"); - // foreach (KeyValuePair kvp in GameMemReader.getInstance().oldPlayerInfos) // thread safety ?? - // { - // string playerName = kvp.Key; - // PlayerInfo pi = kvp.Value; - // Console.WriteLine(kvp.Key); - // } - // } - //} + while (true) + { + string command = Console.ReadLine(); + Console.WriteLine($"Received command: {command}"); + if (command == "list") + { + Console.WriteLine("Player List:"); + foreach (KeyValuePair kvp in GameMemReader.getInstance().oldPlayerInfos) // thread safety ?? + { + string playerName = kvp.Key; + PlayerInfo pi = kvp.Value; + Console.WriteLine(kvp.Key); + } + } + } Thread.Sleep(Timeout.Infinite); } diff --git a/AmongUsCapture/GameMemReader.cs b/AmongUsCapture/GameMemReader.cs index 46ef25c5..0c97e503 100644 --- a/AmongUsCapture/GameMemReader.cs +++ b/AmongUsCapture/GameMemReader.cs @@ -125,6 +125,7 @@ public void RunLoop() { IntPtr playerAddr = ProcessMemory.Read(playerAddrPtr); PlayerInfo pi = ProcessMemory.Read(playerAddr); + if (pi.PlayerName == 0) { continue; } string playerName = pi.GetPlayerName(); newPlayerInfos[playerName] = pi; // add to new playerinfos for comparison later diff --git a/AmongUsCapture/PlayerInfo.cs b/AmongUsCapture/PlayerInfo.cs index bca3ec76..115bc797 100644 --- a/AmongUsCapture/PlayerInfo.cs +++ b/AmongUsCapture/PlayerInfo.cs @@ -7,7 +7,7 @@ namespace AmongUsCapture public struct PlayerInfo { [System.Runtime.InteropServices.FieldOffset(8)] public byte PlayerId; - [System.Runtime.InteropServices.FieldOffset(12)] public int PlayerName; + [System.Runtime.InteropServices.FieldOffset(12)] public uint PlayerName; [System.Runtime.InteropServices.FieldOffset(16)] public byte ColorId; [System.Runtime.InteropServices.FieldOffset(20)] public uint HatId; [System.Runtime.InteropServices.FieldOffset(24)] public uint PetId;