Exemple #1
0
        internal static void launchProperly()
        {
            BackgroundWorker gameWaitWorker = new BackgroundWorker();

            gameWaitWorker.DoWork += (object sender, DoWorkEventArgs e) =>
            {
                Thread.Sleep(1000);
                Console.WriteLine("Waiting for game...");
                string Btd5Dir = SteamUtils.GetGameDir(SteamUtils.BTD5AppID, SteamUtils.BTD5Name);
                Logger.Log("BOOT DEBUG: Install Dir: " + Btd5Dir);
                RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\Valve\\Steam\\Apps\\306020");
                if ((int)key.GetValue("Installed") < 1)
                {
                    Logger.Log("BTD5 isnt installed, according to steam.");
                }
                else
                {
                    //string btd5Exe = Btd5Dir + "\\BTD5-Win.exe";
                    string btd5Exe = @"C:\Users\ben\source\repos\InjectionTest\Debug\Payload.dll";

                    byte[] btd5bin = File.ReadAllBytes(btd5Exe);
                    unsafe
                    {
                        fixed(byte *pBin = btd5bin)
                        {
                            PE.DumpExportsFromFile32(pBin);
                        }
                    }
                }
                try
                {
                    while (true)
                    {
                        if ((int)key.GetValue("Running") > 0)
                        {
                            Program.memlib.OpenProcess("BTD5-Win");
                            Program.afterGameLoad(Program.memlib.theProc);
                            break;
                        }
                        else
                        {
                            Process.Start("steam://rungameid/306020");
                            Thread.Sleep(5000);
                        }
                    }
                }
                catch (Exception)
                {
                    Logger.Log("An exception occoured when starting, hooking or checking if the game is running. This could mean you dont have BTD5 installed via steam or there is a bug.");
                }
            };
            gameWaitWorker.RunWorkerAsync();
        }
        private void OpenBTD5Dir_Button_Click(object sender, RoutedEventArgs e)
        {
            string gameDir = SteamUtils.GetGameDir(GameType.BTD5);

            SteamUtils.GetGameDir(GameType.BTD5);
            if (!Guard.IsStringValid(gameDir))
            {
                Log.Output("Error! Failed to find BTD5 Directory");
                return;
            }

            Log.Output("Opening BTD5 directory");
            Process.Start(gameDir);
        }
Exemple #3
0
        private void BTDBHandling()
        {
            if (!String.IsNullOrEmpty(battlesPass))
            {
                ProjPass_TextBox.Text = battlesPass;
                return;
            }

            string gameDir = SteamUtils.GetGameDir(GameType.BTDB);

            if (String.IsNullOrEmpty(gameDir))
            {
                return;
            }

            string jetPath = "";

            foreach (var item in new DirectoryInfo(gameDir + "\\Assets").GetFiles("*.jet", SearchOption.TopDirectoryOnly))
            {
                if (item.Name.ToLower() != "data.jet")
                {
                    continue;
                }

                jetPath = item.FullName;
            }

            if (String.IsNullOrEmpty(jetPath))
            {
                return;
            }

            Zip    btdb = new Zip(jetPath);
            string pass = btdb.TryGetPassword();

            if (String.IsNullOrEmpty(pass))
            {
                return;
            }

            battlesPass           = pass;
            ProjPass_TextBox.Text = pass;
        }
Exemple #4
0
 public static string AutoDetectGameDir(GameType gameType)
 {
     return(SteamUtils.GetGameDir(gameType));
 }
        public MainWindow()
        {
            string currentDirectory = AppDomain.CurrentDomain.BaseDirectory;

            //%USERPROFILE%\AppData\LocalLow
            launcherConfig.configDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\Appdata\\LocalLow\\BloonsModLauncher";

            if (!(Directory.Exists(launcherConfig.configDir)))
            {
                Directory.CreateDirectory(launcherConfig.configDir);
            }


            launcherConfig.btd6Dir = SteamUtils.GetGameDir(SteamUtils.BTD6AppID, SteamUtils.BTD6Name);
            launcherConfig.modDir  = launcherConfig.btd6Dir + "\\mods";

            if (!(Directory.Exists(launcherConfig.modDir)))
            {
                Directory.CreateDirectory(launcherConfig.modDir);
            }

            //
            // Mod file structure is as follows:
            //
            // +-- Mods
            // |    +-- ModName
            // |    |    +-- ModName.dll
            // |    |    +-- ModName.btd6modinfo (Json)
            // |
            // |    +-- ModName2
            // |    |   +-- ModName2.dll
            // |    |   +-- ModName2.btd6modinfo (Json)
            // |
            // ...
            //
            // Why not just use .json?
            // To allow mod creators to use .json files without confusing the launcher.
            //
            InitializeComponent();

            string[] modDirs = Directory.GetFiles(launcherConfig.btd6Dir, "*.btd6modinfo", SearchOption.AllDirectories);


            List <ModInfo> ModList = new List <ModInfo>();
            ModInfo        modinfo = null;

            for (int i = 0; i < modDirs.Length; i++)
            {
                string json = File.ReadAllText(modDirs[i]);

                modinfo = JsonConvert.DeserializeObject <ModInfo>(json);

                if (modinfo != null)
                {
                    ModList.Add(modinfo);
                }
            }

            for (int i = 0; i < ModList.Count; i++)
            {
                addMod(ModList[i]);
            }
        }
Exemple #6
0
        private void OnFinishedLoading()
        {
            Log.Output("Welcome to BTD6 Mod Manager!");

            string tdloaderDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\TD Loader";

            UserData.MainProgramExePath = Environment.CurrentDirectory + "\\BTD6 Mod Manager.exe";
            UserData.MainProgramName    = "BTD6 Mod Manager";
            UserData.MainSettingsDir    = tdloaderDir;
            UserData.UserDataFilePath   = tdloaderDir + "\\userdata.json";

            /*BgThread.AddToQueue(() =>
             * {
             *  UserData.LoadUserData();
             *  UserData.SaveUserData();
             * });*/

            if (TempSettings.Instance.IsNewUser)
            {
                var diag = MessageBox.Show("Would you like to see a tutorial on how to use this mod manager?", "Open tutorial?", MessageBoxButton.YesNo);
                if (diag == MessageBoxResult.Yes)
                {
                    Windows.WebBrowser browser = new Windows.WebBrowser("How to use this Mod Manager");
                    browser.Show();
                    browser.GoToURL("https://youtu.be/RyB5MyMpOlE?t=613");
                }
                else
                {
                    MessageBox.Show("Okay. If you want to see it later, just click on the \"Help\" at the top of the mod manager," +
                                    " then click \"How to use Mod Manager\"");
                }
                TempSettings.Instance.IsNewUser = false;
                TempSettings.Instance.SaveSettings();
            }

            BgThread.AddToQueue(() =>
            {
                string btd6ExePath = SteamUtils.GetGameDir(GameType.BTD6) + "\\" + GameInfo.GetGame(GameType.BTD6).EXEName;
                FileInfo btd6File  = new FileInfo(btd6ExePath);

                while (true)
                {
                    if (BTD_Backend.Natives.Windows.IsProgramRunning(btd6File, out Process proc))
                    {
                        Launch_Button.Dispatcher.BeginInvoke((Action)(() =>
                        {
                            if (Launch_Button.Content != "Inject")
                            {
                                Launch_Button.Content = "Inject";
                            }
                        }));
                    }
                    else
                    {
                        Launch_Button.Dispatcher.BeginInvoke((Action)(() =>
                        {
                            if (Launch_Button.Content != "Launch")
                            {
                                Launch_Button.Content = "Launch";
                            }
                        }));
                    }
                    Thread.Sleep(500);
                }
            });
        }