Пример #1
0
 public static void GetCurrentHash()
 {
     try
     {
         string hash = File.ReadAllLines(GetHashFilePath(), Encoding.UTF8)[0];
         currentHash = hash;
     }
     catch (Exception e)
     {
         Helper.Error(e.Message);
         Thread.Sleep(10000);
         throw;
     }
 }
Пример #2
0
        public static void Set(Process game)
        {
            try
            {
                string[] lines = File.ReadAllLines(GetHashFile(game), Encoding.UTF8);
                gameHash = lines[0];

                if (targets[gameHash].Length == 0)
                {
                    Helper.Error("Current game version not supported!");
                    Helper.Error("Closing NSC in 10 seconds.");
                    Thread.Sleep(10000);
                    Process.GetCurrentProcess().Kill();
                }
            }
            catch (Exception e)
            {
                Helper.Error(e.Message);
                Helper.Error("Closing NSC in 10 seconds.");
                Thread.Sleep(10000);
                throw;
            }
        }
Пример #3
0
        private static void ReadXML(string fileName)   // Reads XML and fills data dictionary
        {
            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load(fileName);
            }
            catch (Exception e)
            {
                Helper.Error(e.Message);
                Thread.Sleep(10000);
                throw;
            }

            XmlNodeList Nodes = doc.DocumentElement.SelectNodes("/Release/Data");

            foreach (XmlNode node in Nodes)
            {
                string        hash    = "";
                List <string> targets = new List <string>();

                for (int i = 0; i < node.ChildNodes.Count; i++)
                {
                    if (i == 0)
                    {
                        hash = node.ChildNodes[i].InnerText;
                    }
                    else
                    {
                        targets.Add(node.ChildNodes[i].InnerText);
                    }
                }
                data.Add(hash, targets);
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            // hooked Restart function to CancelKeyPress event
            Console.CancelKeyPress += new ConsoleCancelEventHandler(RestartApp);

            if (!File.Exists(listFile)) // check if seedlist.txt exists
            {
                string[] lines = { "1234567890:Test Seed" };
                File.Create(listFile).Close();
                File.WriteAllLines(listFile, lines);
            }

            Helper.DrawBanner();

            if (!Seedlist.GetList(listFile)) // get seed from list
            {
                Console.Write(Environment.NewLine);
                Console.Write("Enter Seed> ");
                Console.ForegroundColor = ConsoleColor.White;
                uint.TryParse(Console.ReadLine(), out seed);
                Console.Write(Environment.NewLine);
            }

            if (seed <= 0)  // game stucks on title screen if the seed is less or equal zero
            {
                Helper.Error("Seed invalid! Make sure it's in a range of 1 to 4294967295.");
                seed = Helper.RandomSeed();
                Helper.WriteLine("Generated random seed: " + seed);
                Console.Write(Environment.NewLine);
            }

Restart:

            if (restart)
            {
                Helper.DrawBanner();
            }

            Console.ForegroundColor = ConsoleColor.DarkCyan;
            Console.WriteLine("Waiting for noita.exe");

            // checks if noita.exe is running
            bool tryAgain;

            do
            {
                tryAgain = false;


                while (game == null)
                {
                    System.Threading.Thread.Sleep(50);
                    if (Process.GetProcessesByName(gameName).Length > 0)
                    {
                        game = Process.GetProcessesByName(gameName)[0];
                        Console.WriteLine("noita.exe is running");
                        Console.Write(Environment.NewLine);
                    }
                }

                // checks current Noita release and sets 'release' variable
                Release.Set(game);

                //do this in try, because at early game init, the WaitForInputIdle
                //  if the window isn't open yet
                try
                {
                    // writes seed to given memory address for the correct version
                    if (game.WaitForInputIdle())
                    {
                        ChangeSeed(Release.Targets);
                    }
                    Helper.WriteLine("Seed changed to: " + seed);
                    Console.WriteLine("Idle until Noita restarts.");
                }
                catch (Exception e)
                {
                    game     = null;
                    tryAgain = true;
                }

                if (game != null)
                {
                    game.WaitForExit();
                }
                game = null;
            } while (tryAgain);


            restart = true;
            goto Restart;
        }
Пример #5
0
        static void Main(string[] args)
        {
            // hooked restart function to CancelKeyPress event
            Console.CancelKeyPress += new ConsoleCancelEventHandler(RestartApp);
            Console.Title           = "NoitaSeedChanger";

            if (!File.Exists(listFile)) // check if seedlist.txt exists
            {
                string[] lines = { "1234567890:Test Seed" };
                File.Create(listFile).Close();
                File.WriteAllLines(listFile, lines);
            }

            Helper.DrawBanner();

            if (!Seedlist.GetList(listFile)) // get seed from list
            {
                Console.Write(Environment.NewLine);
                Console.Write("Enter Seed> ");
                Console.ForegroundColor = ConsoleColor.White;
                uint.TryParse(Console.ReadLine(), out seed);
                Console.Write(Environment.NewLine);
            }

            if (seed <= 0)  // game stucks on title screen if the seed is less or equal zero
            {
                Helper.Error("Seed invalid! Make sure it's in a range of 1 to 4294967295.");
                seed = Helper.RandomSeed();
                Helper.WriteLine("Generated random seed: " + seed);
                Console.Write(Environment.NewLine);
            }
            Console.Title = "NoitaSeedChanger - Seed: " + seed;

            while (true)
            {
                if (repeat)
                {
                    Helper.DrawBanner();
                }

                Console.ForegroundColor = ConsoleColor.DarkCyan;
                Console.WriteLine("Waiting for noita.exe");

                // checks if noita.exe is running
                while (game == null)
                {
                    Thread.Sleep(100);
                    if (Process.GetProcessesByName(gameName).Length > 0)
                    {
                        game = Process.GetProcessesByName(gameName)[0];
                        Console.WriteLine("noita.exe is running");
                        Console.Write(Environment.NewLine);
                    }
                }

                // checks current Noita release on the first run and gets memory targets
                if (!repeat)
                {
                    Release.Init();
                }

                // writes seed to given memory address for the correct release version
                if (game.WaitForInputIdle())
                {
                    try
                    {
                        if (Release.currentTargets.Count > 0)
                        {
                            Memory.ChangeSeed(game.Handle, seed, Release.currentTargets);
                        }
                        else
                        {
                            Helper.Error("NSC seem to be outdated. Check for the latest release or read the compatibility section in the Readme.txt");
                            Thread.Sleep(10000);
                            Process.GetCurrentProcess().Kill();
                        }
                    }
                    catch (Exception e)
                    {
                        Helper.Error(e.Message);
                        Thread.Sleep(10000);
                        throw;
                    }
                }
                Helper.WriteLine("Seed changed to: " + seed);
                Console.WriteLine("Idle until Noita restarts.");

                game.WaitForExit();
                game = null;

                repeat = true;
            }
        }