Esempio n. 1
0
        public void Run()
        {
            //Clear output / create output files
            ClearOutput();

            Logger.Log("Waiting for rocksmith");

            if (config.customsForgeSettings.Enabled)
            {
                customsForgeHandler = new CustomsForgeHandler(cache as SQLiteCache);
            }

            //Loop infinitely trying to find rocksmith process
            while (true)
            {
                var processes = Process.GetProcessesByName("Rocksmith2014");

                //Sleep for 1 second if no processes found
                if (processes.Length == 0)
                {
                    Thread.Sleep(1000);
                    continue;
                }

                //Select the first rocksmith process and open a handle
                rsProcess = processes[0];

                if (rsProcess.HasExited || !rsProcess.Responding)
                {
                    Thread.Sleep(1000);
                    continue;
                }

                break;
            }

            Logger.Log("Rocksmith found! Sniffing...");

            //Check rocksmith executable hash to make sure its the correct version
            string hash = PSARCUtil.GetFileHash(new FileInfo(rsProcess.MainModule.FileName));

            Logger.Log($"Rocksmith executable hash: {hash}");

            if (!hash.Equals("GxT+/TXLpUFys+Cysek8zg=="))
            {
                Logger.LogError("Executable hash does not match expected hash, make sure you have the correct version");
                Logger.Log("Press any key to exit");
                Console.ReadKey();
                Environment.Exit(0);
            }

            //Initialize file handle reader and memory reader
            Sniffer sniffer = new Sniffer(rsProcess, cache, config.snifferSettings);

            //Listen for events
            sniffer.OnSongChanged   += Sniffer_OnCurrentSongChanged;
            sniffer.OnMemoryReadout += Sniffer_OnMemoryReadout;

            //Add RPC event listeners
            if (config.rpcSettings.enabled)
            {
                rpcHandler = new DiscordRPCHandler(sniffer);
            }

            if (config.lastFMSettings.Enabled)
            {
                lastFMHandler = new LastFMHandler(sniffer);
            }

            //Inform AddonService
            if (config.addonSettings.enableAddons && addonService != null)
            {
                addonService.SetSniffer(sniffer);
            }

            while (true)
            {
                if (rsProcess == null || rsProcess.HasExited)
                {
                    break;
                }

                OutputDetails();

                //GOTTA GO FAST
                Thread.Sleep(1000);

                if (random.Next(100) == 0)
                {
                    Console.WriteLine("*sniff sniff*");
                }
            }

            sniffer.Stop();

            //Clean up as best as we can
            rsProcess.Dispose();
            rsProcess = null;

            rpcHandler?.Dispose();
            rpcHandler = null;

            lastFMHandler?.Dispose();
            lastFMHandler = null;

            customsForgeHandler = null;

            Logger.Log("This is rather unfortunate, the Rocksmith2014 process has vanished :/");
        }
Esempio n. 2
0
        public void Run()
        {
            //Clear output / create output files
            ClearOutput();

            Logger.Log("Waiting for rocksmith");

            //Loop infinitely trying to find rocksmith process
            while (true)
            {
                var processes = Process.GetProcessesByName("Rocksmith2014");

                //Sleep for 1 second if no processes found
                if (processes.Length == 0)
                {
                    Thread.Sleep(1000);
                    continue;
                }

                //Select the first rocksmith process and open a handle
                rsProcess = processes[0];

                if (rsProcess.HasExited || !rsProcess.Responding)
                {
                    Thread.Sleep(1000);
                    continue;
                }

                break;
            }

            Logger.Log("Rocksmith found! Sniffing...");

            //Initialize file handle reader and memory reader
            Sniffer sniffer = new Sniffer(rsProcess, cache, config.snifferSettings);

            //Listen for events
            sniffer.OnSongChanged   += Sniffer_OnCurrentSongChanged;
            sniffer.OnMemoryReadout += Sniffer_OnMemoryReadout;

            //Add RPC event listeners
            if (config.rpcSettings.enabled)
            {
                rpcHandler = new DiscordRPCHandler(sniffer);
            }

            //Inform AddonService
            if (config.addonSettings.enableAddons && addonService != null)
            {
                addonService.SetSniffer(sniffer);
            }

            while (true)
            {
                if (rsProcess == null || rsProcess.HasExited)
                {
                    break;
                }

                OutputDetails();

                //GOTTA GO FAST
                Thread.Sleep(1000);

                if (random.Next(100) == 0)
                {
                    Console.WriteLine("*sniff sniff*");
                }
            }

            sniffer.Stop();

            //Clean up as best as we can
            rsProcess.Dispose();
            rsProcess = null;

            rpcHandler?.Dispose();
            rpcHandler = null;

            Logger.Log("This is rather unfortunate, the Rocksmith2014 process has vanished :/");
        }