public AppSettingBox() { this.Font = new Font(SystemFonts.MenuFont.FontFamily, 10F); mliConfigDir.AddCtrs(new Control[] { cmbConfigDir, btnConfigDir }); mliBackup.AddCtrs(new Control[] { chkBackup, btnBackupDir }); mliUpdate.AddCtrs(new Control[] { cmbUpdate, lblUpdate }); mliRepo.AddCtr(cmbRepo); mliProtect.AddCtr(chkProtect); mliEngine.AddCtr(cmbEngine); mliWinXSortable.AddCtr(chkWinXSortable); mliShowFilePath.AddCtr(chkShowFilePath); mliOpenMoreRegedit.AddCtr(chkOpenMoreRegedit); mliHideDisabledItems.AddCtr(chkHideDisabledItems); mliHideSysStoreItems.AddCtr(chkHideSysStoreItems); cmbConfigDir.AutosizeDropDownWidth(); cmbEngine.AutosizeDropDownWidth(); cmbRepo.AutosizeDropDownWidth(); MyToolTip.SetToolTip(cmbConfigDir, AppString.Tip.ConfigPath); MyToolTip.SetToolTip(btnConfigDir, AppString.Menu.FileLocation); MyToolTip.SetToolTip(btnBackupDir, AppString.Menu.FileLocation); cmbRepo.Items.AddRange(new[] { "Github", "Gitee" }); cmbConfigDir.Items.AddRange(new[] { AppString.Other.AppDataDir, AppString.Other.AppDir }); cmbEngine.Items.AddRange(new[] { "Bing", "Baidu", "Google", "DuckDuckGo", "DogeDoge", "Sogou", "360", AppString.Other.CustomEngine }); cmbUpdate.Items.AddRange(new[] { AppString.Other.OnceAWeek, AppString.Other.OnceAMonth, AppString.Other.OnceASeason, AppString.Other.NeverCheck }); lblUpdate.Click += (sender, e) => Updater.Update(true); this.VisibleChanged += (sender, e) => this.Enabled = this.Visible; btnConfigDir.MouseDown += (sender, e) => ExternalProgram.JumpExplorer(AppConfig.ConfigDir); btnBackupDir.MouseDown += (sender, e) => ExternalProgram.JumpExplorer(AppConfig.BackupDir); cmbRepo.SelectionChangeCommitted += (sender, e) => AppConfig.RequestUseGithub = cmbRepo.SelectedIndex == 0; chkBackup.MouseDown += (sender, e) => AppConfig.AutoBackup = chkBackup.Checked = !chkBackup.Checked; chkProtect.MouseDown += (sender, e) => AppConfig.ProtectOpenItem = chkProtect.Checked = !chkProtect.Checked; chkWinXSortable.MouseDown += (sender, e) => AppConfig.WinXSortable = chkWinXSortable.Checked = !chkWinXSortable.Checked; chkOpenMoreRegedit.MouseDown += (sender, e) => AppConfig.OpenMoreRegedit = chkOpenMoreRegedit.Checked = !chkOpenMoreRegedit.Checked; chkHideDisabledItems.MouseDown += (sender, e) => AppConfig.HideDisabledItems = chkHideDisabledItems.Checked = !chkHideDisabledItems.Checked; chkHideSysStoreItems.MouseDown += (sender, e) => AppConfig.HideSysStoreItems = chkHideSysStoreItems.Checked = !chkHideSysStoreItems.Checked; cmbConfigDir.SelectionChangeCommitted += (sender, e) => { string newPath = (cmbConfigDir.SelectedIndex == 0) ? AppConfig.AppDataConfigDir : AppConfig.AppConfigDir; if (newPath == AppConfig.ConfigDir) { return; } if (MessageBoxEx.Show(AppString.Message.RestartApp, MessageBoxButtons.OKCancel) != DialogResult.OK) { cmbConfigDir.SelectedIndex = AppConfig.SaveToAppDir ? 1 : 0; } else { DirectoryEx.CopyTo(AppConfig.ConfigDir, newPath); Directory.Delete(AppConfig.ConfigDir, true); SingleInstance.Restart(); } }; cmbEngine.SelectionChangeCommitted += (sender, e) => { if (cmbEngine.SelectedIndex < cmbEngine.Items.Count - 1) { AppConfig.EngineUrl = AppConfig.EngineUrls[cmbEngine.SelectedIndex]; } else { using (InputDialog dlg = new InputDialog { Title = AppString.Other.SetCustomEngine }) { dlg.Text = AppConfig.EngineUrl; if (dlg.ShowDialog() == DialogResult.OK) { AppConfig.EngineUrl = dlg.Text; } string url = AppConfig.EngineUrl; for (int i = 0; i < AppConfig.EngineUrls.Length; i++) { if (url.Equals(AppConfig.EngineUrls[i])) { cmbEngine.SelectedIndex = i; break; } } } } }; cmbUpdate.SelectionChangeCommitted += (sender, e) => { int day = 30; switch (cmbUpdate.SelectedIndex) { case 0: day = 7; break; case 2: day = 90; break; case 3: day = -1; break; } AppConfig.UpdateFrequency = day; }; chkShowFilePath.MouseDown += (sender, e) => { chkShowFilePath.Checked = !chkShowFilePath.Checked; if (MessageBoxEx.Show(AppString.Message.RestartApp, MessageBoxButtons.OKCancel) == DialogResult.OK) { AppConfig.ShowFilePath = chkShowFilePath.Checked; SingleInstance.Restart(); } else { chkShowFilePath.Checked = !chkShowFilePath.Checked; } }; }
/// <summary> /// Compiles the project with the current settings. /// </summary> public override void Compile() { try { // Validate required files & directories Helper.ValidateFiles ( ApplicationBase.Path, @"FASM\FASM.exe", @"FASM\INCLUDE\", @"Stub\pe32\" ); if (Errors.HasErrors) { return; } // Copy source files to intermediate directory DirectoryEx.CopyTo(Path.Combine(ApplicationBase.Path, @"Stub\pe32"), IntermediateDirectorySource); // Validate required source files Helper.ValidateFiles ( IntermediateDirectorySource, "Stub.asm", "Stage2.asm", @"Obfuscator\nop.txt", @"Obfuscator\nop_minimal.txt", @"Obfuscator\register.txt", @"Resources\default.manifest", @"Resources\elevated.manifest" ); if (Errors.HasErrors) { return; } // Validate that RunPE uses valid 32-bit PE files Helper.ValidateRunPEBitness(32); if (Errors.HasErrors) { return; } // Preprocess files AssemblyPreprocessor.PreprocessDirectory(IntermediateDirectorySource, false); // Compile stage2 CompileStage2(); if (Errors.HasErrors) { return; } // Assemble stage2 AssembleStage2(); if (Errors.HasErrors) { return; } // Compile stub CompileStub(); if (Errors.HasErrors) { return; } // Assemble stub AssembleStub(); } catch (ErrorException ex) { Errors.Add(ErrorSource.Compiler, ErrorSeverity.Error, ex.Message, ex.Details); } catch (Exception ex) { Errors.Add(ErrorSource.Compiler, ErrorSeverity.Error, "Unhandled " + ex.GetType() + " while compiling project.", ex.GetFullStackTrace()); } }
public AppSettingBox() { this.Font = new Font(SystemFonts.MenuFont.FontFamily, 10F); mliConfigDir.AddCtrs(new Control[] { cmbConfigDir, btnConfigDir }); mliBackup.AddCtrs(new Control[] { chkBackup, btnBackupDir }); mliUpdate.AddCtrs(new Control[] { lblGitee, lblGithub, lblUpdate }); mliProtect.AddCtr(chkProtect); mliEngine.AddCtr(cmbEngine); mliWinXSortable.AddCtr(chkWinXSortable); mliShowFilePath.AddCtr(chkShowFilePath); mliOpenMoreRegedit.AddCtr(chkOpenMoreRegedit); mliHideDisabledItems.AddCtr(chkHideDisabledItems); cmbConfigDir.AutosizeDropDownWidth(); cmbEngine.AutosizeDropDownWidth(); MyToolTip.SetToolTip(cmbConfigDir, AppString.Tip.ConfigPath); MyToolTip.SetToolTip(btnConfigDir, AppString.Other.OpenConfigDir); MyToolTip.SetToolTip(btnBackupDir, AppString.Other.OpenBackupDir); MyToolTip.SetToolTip(mliUpdate, AppString.Tip.CheckUpdate + Environment.NewLine + AppString.Tip.LastCheckUpdateTime + AppConfig.LastCheckUpdateTime.ToLongDateString()); cmbConfigDir.Items.AddRange(new[] { AppString.Other.AppDataDir, AppString.Other.AppDir }); cmbEngine.Items.AddRange(new[] { "Baidu", "Bing", "Google", "DogeDoge", "Sogou", "360", AppString.Other.CustomEngine }); btnConfigDir.MouseDown += (sender, e) => ExternalProgram.JumpExplorer(AppConfig.ConfigDir); btnBackupDir.MouseDown += (sender, e) => ExternalProgram.JumpExplorer(AppConfig.BackupDir); lblGithub.Click += (sender, e) => ExternalProgram.OpenUrl(GithubUrl); lblGitee.Click += (sender, e) => ExternalProgram.OpenUrl(GiteeUrl); lblUpdate.Click += (sender, e) => { if (!Updater.CheckUpdate()) { MessageBoxEx.Show(AppString.MessageBox.NoUpdateDetected); } }; cmbConfigDir.SelectionChangeCommitted += (sender, e) => { string newPath = (cmbConfigDir.SelectedIndex == 0) ? AppConfig.AppDataConfigDir : AppConfig.AppConfigDir; if (newPath == AppConfig.ConfigDir) { return; } if (MessageBoxEx.Show(AppString.MessageBox.RestartApp, MessageBoxButtons.OKCancel) != DialogResult.OK) { cmbConfigDir.SelectedIndex = AppConfig.SaveToAppDir ? 1 : 0; } else { DirectoryEx.CopyTo(AppConfig.ConfigDir, newPath); Directory.Delete(AppConfig.ConfigDir, true); SingleInstance.Restart(true); } }; cmbEngine.SelectionChangeCommitted += (sender, e) => { if (cmbEngine.SelectedIndex < cmbEngine.Items.Count - 1) { AppConfig.EngineUrl = AppConfig.EngineUrls[cmbEngine.SelectedIndex]; } else { using (InputDialog dlg = new InputDialog { Title = AppString.Other.SetCustomEngine }) { dlg.Text = AppConfig.EngineUrl; if (dlg.ShowDialog() == DialogResult.OK) { AppConfig.EngineUrl = dlg.Text; } string url = AppConfig.EngineUrl; for (int i = 0; i < AppConfig.EngineUrls.Length; i++) { if (url.Equals(AppConfig.EngineUrls[i])) { cmbEngine.SelectedIndex = i; break; } } } } }; chkBackup.MouseDown += (sender, e) => AppConfig.AutoBackup = chkBackup.Checked = !chkBackup.Checked; chkProtect.MouseDown += (sender, e) => AppConfig.ProtectOpenItem = chkProtect.Checked = !chkProtect.Checked; chkWinXSortable.MouseDown += (sender, e) => AppConfig.WinXSortable = chkWinXSortable.Checked = !chkWinXSortable.Checked; chkOpenMoreRegedit.MouseDown += (sender, e) => AppConfig.OpenMoreRegedit = chkOpenMoreRegedit.Checked = !chkOpenMoreRegedit.Checked; chkHideDisabledItems.MouseDown += (sender, e) => AppConfig.HideDisabledItems = chkHideDisabledItems.Checked = !chkHideDisabledItems.Checked; chkShowFilePath.MouseDown += (sender, e) => { chkShowFilePath.Checked = !chkShowFilePath.Checked; if (MessageBoxEx.Show(AppString.MessageBox.RestartApp, MessageBoxButtons.OKCancel) == DialogResult.OK) { AppConfig.ShowFilePath = chkShowFilePath.Checked; SingleInstance.Restart(true); } else { chkShowFilePath.Checked = !chkShowFilePath.Checked; } }; }