示例#1
0
 public VisitorListHelper(CrossBot bot)
 {
     BotRunner       = bot;
     Connection      = BotRunner.SwitchConnection;
     Config          = BotRunner.Config;
     LastVisitorDiff = new VisitorDifference(Visitors);
 }
示例#2
0
        public static async Task <string> GetVersionAsync(this ISwitchConnectionAsync connection, CancellationToken token)
        {
            var gvbytes = Encoding.ASCII.GetBytes("getVersion\r\n");

            byte[] socketReturn = await connection.ReadRaw(gvbytes, 9, token).ConfigureAwait(false);

            string version = Encoding.UTF8.GetString(socketReturn).TrimEnd('\0').TrimEnd('\n');

            return(version);
        }
 protected SwitchRoutineExecutor(IConsoleBotManaged <IConsoleConnection, IConsoleConnectionAsync> cfg) : base(cfg)
 {
     UseCRLF = cfg.GetInnerConfig() is ISwitchConnectionConfig {
         UseCRLF : true
     };
     if (Connection is not ISwitchConnectionAsync connect)
     {
         throw new System.Exception("Not a valid switch connection");
     }
     SwitchConnection = connect;
 }
示例#4
0
        public static async Task <ulong> GetPointerAddressFromExpression(ISwitchConnectionAsync sw, string pointerExpression, CancellationToken token)
        {
            // Regex pattern to get operators and offsets from pointer expression.
            const string pattern = @"(\+|\-)([A-Fa-f0-9]+)";
            Regex        regex   = new(pattern);
            Match        match   = regex.Match(pointerExpression);

            // Get first offset from pointer expression and read address at that offset from main start.
            var ofs     = Convert.ToUInt64(match.Groups[2].Value, 16);
            var address = BitConverter.ToUInt64(await sw.ReadBytesMainAsync(ofs, 0x8, token).ConfigureAwait(false), 0);

            match = match.NextMatch();

            // Matches the rest of the operators and offsets in the pointer expression.
            while (match.Success)
            {
                // Get operator and offset from match.
                string opp = match.Groups[1].Value;
                ofs = Convert.ToUInt64(match.Groups[2].Value, 16);

                // Add or subtract the offset from the current stored address based on operator in front of offset.
                switch (opp)
                {
                case "+":
                    address += ofs;
                    break;

                case "-":
                    address -= ofs;
                    break;
                }

                // Attempt another match and if successful read bytes at address and store the new address.
                match = match.NextMatch();
                if (!match.Success)
                {
                    continue;
                }

                byte[] bytes = await sw.ReadBytesAbsoluteAsync(address, 0x8, token).ConfigureAwait(false);

                address = BitConverter.ToUInt64(bytes, 0);
            }

            return(address);
        }
示例#5
0
 protected PlayerViewState(SwitchRoutineExecutor <BotConfig> con)
 {
     Executor   = con;
     Connection = (ISwitchConnectionAsync)con.Connection;
 }
 protected RoutineExecutor(IConsoleBotManaged <IConsoleConnection, IConsoleConnectionAsync> cfg)
 {
     Config           = (T)cfg;
     Connection       = cfg.CreateAsynchronous();
     SwitchConnection = (ISwitchConnectionAsync)Connection;
 }
 public DodoPositionHelper(CrossBot bot)
 {
     BotRunner  = bot;
     Connection = BotRunner.SwitchConnection;
     Config     = BotRunner.Config;
 }
示例#8
0
 public static async Task SetFreezePauseState(this ISwitchConnectionAsync connection, bool pause, CancellationToken token)
 {
     var cmd = Encoding.ASCII.GetBytes(pause ? "freezePause\r\n" : "freezeUnpause\r\n");
     await connection.SendRaw(cmd, token).ConfigureAwait(false);
 }
 public PocketInjectorAsync(ISwitchConnectionAsync bot, uint writeOffset)
 {
     Bot         = bot;
     WriteOffset = writeOffset;
 }