Exemple #1
0
        public void Run()
        {
            while (true)
            {
                if (!ProcessMemory.IsHooked)
                {
                    if (!ProcessMemory.HookProcess("Among Us"))
                    {
                        Thread.Sleep(1000);
                        continue;
                    }

                    Console.WriteLine("GameMemReader", $"Connected to Among Us process ({ProcessMemory.process.Id}))");


                    // Register handlers for game-state change events.
                    //GameMemReader.getInstance().GameStateChanged += GameStateChangedHandler;
                    //GameMemReader.getInstance().PlayerChanged += PlayerChangedHandler;
                    //GameMemReader.getInstance().JoinedLobby += JoinedLobbyHandler;
                    loadModules();
                }

                GameState state = getGameState();

                handlePlayers(state);

                readChat();

                if (shouldReadLobby)
                {
                    var      gameCode = ProcessMemory.ReadString(ProcessMemory.Read <IntPtr>(GameAssemblyPtr, GameOffsets.GameStartManagerOffset, 0x5c, 0, 0x20, 0x28));
                    string[] split;
                    if (gameCode != null && gameCode.Length > 0 && (split = gameCode.Split('\n')).Length == 2)
                    {
                        PlayRegion region = (PlayRegion)((4 - (ProcessMemory.Read <int>(GameAssemblyPtr, GameOffsets.ServerManagerOffset, 0x5c, 0, 0x10, 0x8, 0x8) & 0b11)) % 3);

                        this.latestLobbyEventArgs = new LobbyEventArgs()
                        {
                            LobbyCode = split[1],
                            Region    = region
                        };
                        shouldReadLobby     = false;
                        shouldTransmitLobby = true; // since this is probably new info
                    }
                }

                if (shouldTransmitLobby)
                {
                    if (this.latestLobbyEventArgs != null)
                    {
                        JoinedLobby?.Invoke(this, this.latestLobbyEventArgs);
                    }
                    shouldTransmitLobby = false;
                }

                Thread.Sleep(250);
            }
        }
Exemple #2
0
 private void JoinedLobbyHandler(object sender, LobbyEventArgs e)
 {
     Console.WriteLine(JsonSerializer.Serialize(e));
 }