private void RowColumnError(int row, string column)
 {
     MessageBox.Show(this,
                     L10n._("Invalid / missing value in row {0}, column {1}.", row, column),
                     L10n._("Error"),
                     MessageBoxButtons.OK,
                     MessageBoxIcon.Error);
 }
Esempio n. 2
0
 public AfxError(int code, string title = null, string description = null, string solution = null, Exception innerException = null)
     : base(L10n._("AfxError"), innerException)
 {
     m_Code        = code;
     m_Title       = title;
     m_Description = description;
     m_Solution    = solution;
 }
Esempio n. 3
0
        private static string GetHookPath(bool isProcess64Bit)
        {
            if (isProcess64Bit)
            {
                throw new System.ApplicationException(L10n._("64 Bit CS:GO is not supported."));
            }

            return(System.Windows.Forms.Application.StartupPath + "\\AfxHookSource.dll");
        }
 private void buttonCheck_Click(object sender, EventArgs e)
 {
     if (GetColors())
     {
         MessageBox.Show(
             L10n._("No Errors"),
             L10n._("Check passed"),
             MessageBoxButtons.OK,
             MessageBoxIcon.Information);
     }
 }
Esempio n. 5
0
        static Loader()
        {
            IntPtr hKernel32Dll = GetModuleHandle("Kernel32.dll");

            if (IntPtr.Zero == hKernel32Dll)
            {
                throw new ApplicationException(L10n._("Can not get Kernel32.dll handle."));
            }

            m_HasIsWow64Process = IntPtr.Zero != GetProcAddress(hKernel32Dll, "IsWow64Process");
        }
        private bool GetColors()
        {
            m_Colors.Clear();

            for (int i = 0; i < dataGridViewColors.Rows.Count; ++i)
            {
                if (dataGridViewColors.Rows[i].IsNewRow)
                {
                    continue;
                }

                HlaeCommentedColor src;
                HlaeWeightedColor  dst;
                if (!GetRowColor(dataGridViewColors.Rows[i], out src, out dst))
                {
                    return(false);
                }

                if (m_Colors.ContainsKey(src))
                {
                    int idx = 0;
                    foreach (KeyValuePair <HlaeCommentedColor, HlaeWeightedColor> kvp in m_Colors)
                    {
                        if (kvp.Key.Equals(src))
                        {
                            MessageBox.Show(this,
                                            L10n._("Duplicate source color in row {0} (of row {1}).", i, idx),
                                            L10n._("Error"),
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Error);
                        }
                        ++idx;
                    }

                    return(false);
                }

                m_Colors.Add(src, dst);
            }

            if (m_Colors.Count <= 0)
            {
                MessageBox.Show(this,
                                L10n._("Color map must not be empty."),
                                L10n._("Error"),
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

                return(false);
            }

            return(true);
        }
Esempio n. 7
0
        private static bool IsProcess64Bit(IntPtr hProcess)
        {
            if (!m_HasIsWow64Process)
            {
                return(Environment.Is64BitOperatingSystem);
            }

            bool wow64Process;

            if (!IsWow64Process(hProcess, out wow64Process))
            {
                throw new ApplicationException(L10n._("IsWow64Process failed, error code: {0}", Marshal.GetLastWin32Error()));
            }

            return(!(wow64Process || !Environment.Is64BitOperatingSystem));
        }
 private void SaveToFile()
 {
     if (colorLutTools != null && colorLutTools.IsValid())
     {
         if (DialogResult.OK == saveFileDialog.ShowDialog(this))
         {
             if (!colorLutTools.SaveToFile(saveFileDialog.FileName))
             {
                 MessageBox.Show(this,
                                 L10n._("Saving to \"{0}\" failed.", saveFileDialog.FileName),
                                 L10n._("Error"),
                                 MessageBoxButtons.OK,
                                 MessageBoxIcon.Error);
             }
         }
     }
 }
        private void buttonGenerateLut_Click(object sender, EventArgs e)
        {
            if (!GetColors())
            {
                return;
            }

            UpdateAxis();

            suspendPreview = true;

            comboX.SelectedIndex   = 0;
            comboY.SelectedIndex   = 1;
            trackZ.Value           = 0;
            trackW.Value           = 0;
            drawMode.SelectedIndex = 0;

            if (preview.Image != null)
            {
                preview.Image.Dispose();
                preview.Image = null;
            }
            if (previewBitmap != null)
            {
                preview.Image = null;
                previewBitmap.Dispose();
            }
            previewBitmap = new Bitmap((int)resR.Value, (int)resG.Value);
            preview.Image = new Bitmap(preview.Width, preview.Height);

            if (null == colorLutTools)
            {
                colorLutTools = new AfxCppCli.ColorLutTools();
            }

            if (!colorLutTools.New(
                    (uint)resR.Value,
                    (uint)resG.Value,
                    (uint)resB.Value,
                    (uint)resA.Value
                    ))
            {
                MessageBox.Show(this,
                                L10n._("Error when creating / re-sizing color map."),
                                L10n._("Error"),
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

                colorLutTools.Dispose();
                colorLutTools = null;
            }

            if (null != colorLutTools && !colorLutTools.IteratePut(Iterate))
            {
                MessageBox.Show(this,
                                L10n._("Iteration aborted."),
                                L10n._("Error"),
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

                colorLutTools.Dispose();
                colorLutTools = null;
            }

            trackZ.Value = 255;
            trackW.Value = 255;

            suspendPreview = false;

            UpdatePreview();

            if (null != colorLutTools && colorLutTools.IsValid())
            {
                SaveToFile();
            }
        }
        public AfxRgbaLutVoronoiGenerator()
        {
            InitializeComponent();
            this.Icon = Program.Icon;

            this.Text                    = L10n._("Voronoi Color Lookup Table");
            this.tabMap.Text             = L10n._("Color map");
            this.tabGenerate.Text        = L10n._("Generate");
            this.buttonCheck.Text        = L10n._("Check");
            this.buttonCopy.Text         = L10n._("Copy all to clipboard");
            this.buttonPaste.Text        = L10n._("Paste all from clipboard");
            this.colIndex.HeaderText     = L10n._p("Number/Key", "Index");
            this.colComment.HeaderText   = L10n._("Comment");
            this.colDstWeight.HeaderText = L10n._("Weight");
            grpRes.Text                  = L10n._p("image", "Resolution");
            labelMemEstimate.Text        = L10n._p("image", "Memory estimate (Bytes):");
            grpPreview.Text              = L10n._("Preview");
            labelHori.Text               = L10n._("Horizontal:");
            labelVert.Text               = L10n._("Vertical:");
            buttonStart.Text             = L10n._("Generate");
            buttonSave.Text              = L10n._("Save");

            suspendPreview = true;

            m_Colors.Add(new HlaeCommentedColor(224, 175, 86, 0, L10n._p("terrorist", "T")), new HlaeWeightedColor(255, 0, 0, 0, 128f));
            m_Colors.Add(new HlaeCommentedColor(224, 175, 86, 255, L10n._p("terrorist", "T")), new HlaeWeightedColor(255, 0, 0, 255, 128f));
            m_Colors.Add(new HlaeCommentedColor(144, 155, 221, 0, L10n._p("counter-terrorist", "CT")), new HlaeWeightedColor(0, 0, 255, 0, 128f));
            m_Colors.Add(new HlaeCommentedColor(144, 155, 221, 255, L10n._p("counter-terrorist", "CT")), new HlaeWeightedColor(0, 0, 255, 255, 128f));
            m_Colors.Add(new HlaeCommentedColor(0.662745f, 0.647059f, 0.601961f, 0.0f, L10n._p("terrorist / counter-terrorist", "T/CT neutral")), new HlaeWeightedColor(0.656863f, 0.656863f, 0.656863f, 0));
            m_Colors.Add(new HlaeCommentedColor(0.662745f, 0.647059f, 0.601961f, 1.0f, L10n._p("terrorist / counter-terrorist", "T/CT neutral")), new HlaeWeightedColor(0.656863f, 0.656863f, 0.656863f, 1));

            m_Colors.Add(new HlaeCommentedColor(230, 128, 0, 0, L10n._p("terrorist", "T aim")), new HlaeWeightedColor(255, 0, 0, 0, 128f));
            m_Colors.Add(new HlaeCommentedColor(230, 128, 0, 255, L10n._p("terrorist", "T aim")), new HlaeWeightedColor(255, 0, 0, 255, 128f));
            m_Colors.Add(new HlaeCommentedColor(0, 120, 240, 0, L10n._p("counter-terrorist", "CT aim")), new HlaeWeightedColor(0, 0, 255, 0, 128f));
            m_Colors.Add(new HlaeCommentedColor(0, 120, 240, 255, L10n._p("counter-terrorist", "CT aim")), new HlaeWeightedColor(0, 0, 255, 255, 128f));
            m_Colors.Add(new HlaeCommentedColor(0.450980f, 0.486275f, 0.470588f, 0, L10n._p("terrorist / counter-terrorist", "T/CT aim neutral")), new HlaeWeightedColor(0.469281f, 0.469281f, 0.469281f, 0));
            m_Colors.Add(new HlaeCommentedColor(0.450980f, 0.486275f, 0.470588f, 1, L10n._p("terrorist / counter-terrorist", "T/CT aim neutral")), new HlaeWeightedColor(0.469281f, 0.469281f, 0.469281f, 1));

            m_Colors.Add(new HlaeCommentedColor(0, 0, 0, 0), new HlaeWeightedColor(0, 0, 0, 0));
            m_Colors.Add(new HlaeCommentedColor(0, 0, 0, 255), new HlaeWeightedColor(0, 0, 0, 255));
            m_Colors.Add(new HlaeCommentedColor(0, 0, 255, 0), new HlaeWeightedColor(0, 0, 255, 0));
            m_Colors.Add(new HlaeCommentedColor(0, 0, 255, 255), new HlaeWeightedColor(0, 0, 255, 255));
            m_Colors.Add(new HlaeCommentedColor(0, 255, 0, 0), new HlaeWeightedColor(0, 255, 0, 0));
            m_Colors.Add(new HlaeCommentedColor(0, 255, 0, 255), new HlaeWeightedColor(0, 255, 0, 255));
            m_Colors.Add(new HlaeCommentedColor(0, 255, 255, 0), new HlaeWeightedColor(0, 255, 255, 0));
            m_Colors.Add(new HlaeCommentedColor(0, 255, 255, 255), new HlaeWeightedColor(0, 255, 255, 255));
            m_Colors.Add(new HlaeCommentedColor(255, 0, 0, 0), new HlaeWeightedColor(255, 0, 0, 0));
            m_Colors.Add(new HlaeCommentedColor(255, 0, 0, 255), new HlaeWeightedColor(255, 0, 0, 255));
            m_Colors.Add(new HlaeCommentedColor(255, 0, 255, 0), new HlaeWeightedColor(255, 0, 255, 0));
            m_Colors.Add(new HlaeCommentedColor(255, 0, 255, 255), new HlaeWeightedColor(255, 0, 255, 255));
            m_Colors.Add(new HlaeCommentedColor(255, 255, 0, 0), new HlaeWeightedColor(255, 255, 0, 0));
            m_Colors.Add(new HlaeCommentedColor(255, 255, 0, 255), new HlaeWeightedColor(255, 255, 0, 255));
            m_Colors.Add(new HlaeCommentedColor(255, 255, 255, 0), new HlaeWeightedColor(255, 255, 255, 0));
            m_Colors.Add(new HlaeCommentedColor(255, 255, 255, 255), new HlaeWeightedColor(255, 255, 255, 255));

            int idx = 0;

            foreach (KeyValuePair <HlaeCommentedColor, HlaeWeightedColor> kvp in m_Colors)
            {
                StyleRow(dataGridViewColors.Rows[dataGridViewColors.Rows.Add(
                                                     idx,
                                                     ValueToByte(kvp.Key.Color.R),
                                                     ValueToByte(kvp.Key.Color.G),
                                                     ValueToByte(kvp.Key.Color.B),
                                                     ValueToByte(kvp.Key.Color.A),
                                                     kvp.Key.Comment,
                                                     ValueToByte(kvp.Value.Color.R),
                                                     ValueToByte(kvp.Value.Color.G),
                                                     ValueToByte(kvp.Value.Color.B),
                                                     ValueToByte(kvp.Value.Color.A),
                                                     kvp.Value.Weight.ToString()
                                                     )]);

                ++idx;
            }

            drawMode.Items.AddRange(new string[] {
                L10n._p("Image", "Target"),
                L10n._p("Image", "Source"),
                L10n._p("Image", "RGB difference")
            });
            drawMode.SelectedIndex = 0;

            UpdateEstimate();

            suspendPreview = false;

            UpdatePreview();
        }
Esempio n. 11
0
        //
        // Public members:


        //
        // Internal members:

        internal MainForm()
        {
            InitializeComponent();
            this.Icon = Program.Icon;
            this.pictureBoxHelp.Image = SystemIcons.Information.ToBitmap();

            this.Text = L10n._p("Main window", "Half-Life Advanced Effects");

            this.fileToolStripMenuItem.Text          = L10n._p("Main window | menu", "File");
            this.menuLaunchCSGO.Text                 = L10n._p("Main window | menu | File", "Launch CS:GO");
            this.launchGoldSrcToolStripMenuItem.Text = L10n._p("Main window | menu | File", "Launch GoldSrc");
            this.menuExit.Text = L10n._p("Main window | menu | File", "Exit");

            this.viewToolStripMenuItem.Text = L10n._p("Main Window | menu", "View");
            this.menuStatusBar.Text         = L10n._p("Main window | menu | View", "Status Bar");

            this.toolsToolStripMenuItem.Text       = L10n._p("Main window | menu", "Tools");
            this.calculatorsToolStripMenuItem.Text = L10n._p("Main window | menu | Tools", "Calculators");
            this.menuFileSize.Text                = L10n._p("Main window | menu | Tools | Calculators", "File Size");
            this.menuAfxRgbaLut.Text              = L10n._p("Main window | menu | Tools", "Color Lookup Tables");
            this.menuVoronoi.Text                 = L10n._p("Main window | menu | Tools | Color Lookup Tables", "Voronoi");
            this.goldSrcToolStripMenuItem.Text    = L10n._p("Main window | menu | Tools", "GoldSrc");
            this.demoToolsToolStripMenuItem.Text  = L10n._p("Main window | menu | Tools | GoldSrc", "Demo Tools");
            this.skyManagerToolStripMenuItem.Text = L10n._p("Main window | menu | Tools | GoldSrc", "Sky Manager");

            this.developerToolStripMenuItem.Text = L10n._p("Main window | menu | Tools", "Developer");
            this.menuCustomLoader.Text           = L10n._p("Main window | menu | Tools | Developer", "Custom Loader");
            this.menuGuidToClipBoard.Text        = L10n._p("Main window | menu | Tools | Developer", "Own GUID to ClipBoard");
            this.menuNewGuidToClipBoard.Text     = L10n._p("Main window | menu | Tools | Developer", "New GUID to ClipBoard");

            this.helpToolStripMenuItem.Text            = L10n._p("Main window | menu", "Help");
            this.checkForUpdatesToolStripMenuItem.Text = L10n._p("Main window | menu | Help", "Check for Updates");
            this.menuAutoUpdateCheck.Text       = L10n._p("Main window | menu | Help | Check for Updates", "Auto Check");
            this.checkNowToolStripMenuItem.Text = L10n._p("Main window | menu | Help | Check for Updates", "Check Now");
            this.menuAdvancedFxOrg.Text         = L10n._p("Main window | menu | Help", "Official Website");

            this.donateToolStripMenuItem.Text = L10n._p("Main window | menu", "Donate");

            this.checkUpdatesLabel.Text  = L10n._p("Main window | check updates strip", "Check for updates automatically?");
            this.statusLabelAutoYes.Text = L10n._p("Main window | check updates strip", "Yes");
            this.statusLabelAutoNo.Text  = L10n._p("Main window | check updates strip", "No");


            this.statusLabelIgnore.Text = L10n._p("Main window | update status strip", "Ignore");
            this.statusLabelHide.Text   = L10n._p("Main window | update status strip", "OK");
            this.statusLabelUpdate.Text = L10n._p("Main window | update status strip | label", "Update status unknown");

            this.menuContact.Text = L10n._("Contact / Privacy Policy / Imprint (advancedfx.org)");

            this.groupBoxHelp.Text       = L10n._("Help");
            this.labelHelpLanguage.Text  = L10n._("Language:");
            this.labelHelpSelection.Text = L10n._("Selection:");
            {
                HelpEntry officialEnglishSupportPage = new HelpEntry(L10n._("Official support page (English)"), "https://www.advancedfx.org/support/");
                HelpEntry chinesePage = new HelpEntry(L10n._("HLAE Chinese Station"), "https://hlae.site/");

                helpLanguages = new HelpLanguage[] {
                    new HelpLanguage("en", L10n._p("Language", "English (en)"), new HelpEntry[] {
                        officialEnglishSupportPage
                    }),
                    new HelpLanguage("zh-CN", L10n._p("Language", "Chinese (zh-CN)"), new HelpEntry[] {
                        chinesePage
                    })
                };

                this.comboBoxHelpLanguage.Items.AddRange(helpLanguages);

                string ietfLanguageTag          = System.Globalization.CultureInfo.CurrentUICulture.IetfLanguageTag;
                string twoLetterIsoLanguageName = System.Globalization.CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;

                // Select a default language:

                int selectIndex = -1;
                int curIndex    = 0;

                foreach (HelpLanguage helpLanguage in helpLanguages)
                {
                    if (helpLanguage.Code.Equals(ietfLanguageTag))
                    {
                        selectIndex = curIndex;
                        break;
                    }
                    ++curIndex;
                }

                if (selectIndex == -1)
                {
                    curIndex = 0;
                    foreach (HelpLanguage helpLanguage in helpLanguages)
                    {
                        if (helpLanguage.Code.Equals(twoLetterIsoLanguageName))
                        {
                            selectIndex = curIndex;
                            break;
                        }
                        ++curIndex;
                    }
                }

                if (selectIndex == -1 && 0 < helpLanguages.Length)
                {
                    selectIndex = 0;
                }

                if (selectIndex != -1)
                {
                    comboBoxHelpLanguage.SelectedIndex = selectIndex;
                }
            }

            m_UpdateCheckNotification = new UpdateCheckNotificationTarget(this, new UpdateCheckedDelegate(OnUpdateChecked));
        }
Esempio n. 12
0
        //
        // Public members:


        //
        // Internal members:

        internal MainForm()
        {
            InitializeComponent();
            this.Icon = Program.Icon;
            this.pictureBoxHelp.Image      = SystemIcons.Information.ToBitmap();
            this.pictureBoxPathError.Image = SystemIcons.Warning.ToBitmap();

            this.Text = L10n._p("Window title, args: {0} - version", "Half-Life Advanced Effects {0}", System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileVersion);

            this.fileToolStripMenuItem.Text          = L10n._p("Main window | menu", "File");
            this.menuLaunchCSGO.Text                 = L10n._p("Main window | menu | File", "Launch CS:GO");
            this.launchGoldSrcToolStripMenuItem.Text = L10n._p("Main window | menu | File", "Launch GoldSrc");
            this.menuExit.Text = L10n._p("Main window | menu | File", "Exit");

            this.viewToolStripMenuItem.Text = L10n._p("Main Window | menu", "View");
            this.menuStatusBar.Text         = L10n._p("Main window | menu | View", "Status Bar");

            this.toolsToolStripMenuItem.Text       = L10n._p("Main window | menu", "Tools");
            this.calculatorsToolStripMenuItem.Text = L10n._p("Main window | menu | Tools", "Calculators");
            this.menuFileSize.Text                = L10n._p("Main window | menu | Tools | Calculators", "File Size");
            this.menuAfxRgbaLut.Text              = L10n._p("Main window | menu | Tools", "Color Lookup Tables");
            this.menuVoronoi.Text                 = L10n._p("Main window | menu | Tools | Color Lookup Tables", "Voronoi");
            this.goldSrcToolStripMenuItem.Text    = L10n._p("Main window | menu | Tools", "GoldSrc");
            this.demoToolsToolStripMenuItem.Text  = L10n._p("Main window | menu | Tools | GoldSrc", "Demo Tools");
            this.skyManagerToolStripMenuItem.Text = L10n._p("Main window | menu | Tools | GoldSrc", "Sky Manager");

            this.developerToolStripMenuItem.Text = L10n._p("Main window | menu | Tools", "Developer");
            this.menuCustomLoader.Text           = L10n._p("Main window | menu | Tools | Developer", "Custom Loader");
            this.menuGuidToClipBoard.Text        = L10n._p("Main window | menu | Tools | Developer", "Own GUID to ClipBoard");
            this.menuNewGuidToClipBoard.Text     = L10n._p("Main window | menu | Tools | Developer", "New GUID to ClipBoard");

            this.helpToolStripMenuItem.Text            = L10n._p("Main window | menu", "Help");
            this.checkForUpdatesToolStripMenuItem.Text = L10n._p("Main window | menu | Help", "Check for Updates");
            this.menuAutoUpdateCheck.Text       = L10n._p("Main window | menu | Help | Check for Updates", "Auto Check");
            this.checkNowToolStripMenuItem.Text = L10n._p("Main window | menu | Help | Check for Updates", "Check Now");
            this.menuAdvancedFxOrg.Text         = L10n._p("Main window | menu | Help", "Official Website");

            this.donateToolStripMenuItem.Text = L10n._p("Main window | menu", "Donate");

            this.checkUpdatesLabel.Text  = L10n._p("Main window | check updates strip", "Check for updates automatically?");
            this.statusLabelAutoYes.Text = L10n._p("Main window | check updates strip", "Yes");
            this.statusLabelAutoNo.Text  = L10n._p("Main window | check updates strip", "No");


            this.statusLabelIgnore.Text = L10n._p("Main window | update status strip", "Ignore");
            this.statusLabelHide.Text   = L10n._p("Main window | update status strip", "OK");
            this.statusLabelUpdate.Text = L10n._p("Main window | update status strip | label", "Update status unknown");

            this.menuContact.Text = L10n._("Contact / Privacy Policy / Imprint (advancedfx.org)");

            this.groupBoxHelp.Text       = L10n._("Help");
            this.labelHelpLanguage.Text  = L10n._("Language:");
            this.labelHelpSelection.Text = L10n._("Selection:");
            {
                HelpEntry officialEnglishSupportPage = new HelpEntry(L10n._("Official support page (English)"), "https://www.advancedfx.org/support/");
                HelpEntry chinesePage = new HelpEntry(L10n._("HLAE Chinese Station"), "https://hlae.site/");

                helpLanguages = new HelpLanguage[] {
                    new HelpLanguage("en", L10n._p("Language", "English (en)"), new HelpEntry[] {
                        officialEnglishSupportPage
                    }),
                    new HelpLanguage("zh-CN", L10n._p("Language", "Chinese (zh-CN)"), new HelpEntry[] {
                        chinesePage
                    })
                };

                this.comboBoxHelpLanguage.Items.AddRange(helpLanguages);

                string ietfLanguageTag          = System.Globalization.CultureInfo.CurrentUICulture.IetfLanguageTag;
                string twoLetterIsoLanguageName = System.Globalization.CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;

                // Select a default language:

                int selectIndex = -1;
                int curIndex    = 0;

                foreach (HelpLanguage helpLanguage in helpLanguages)
                {
                    if (helpLanguage.Code.Equals(ietfLanguageTag))
                    {
                        selectIndex = curIndex;
                        break;
                    }
                    ++curIndex;
                }

                if (selectIndex == -1)
                {
                    curIndex = 0;
                    foreach (HelpLanguage helpLanguage in helpLanguages)
                    {
                        if (helpLanguage.Code.Equals(twoLetterIsoLanguageName))
                        {
                            selectIndex = curIndex;
                            break;
                        }
                        ++curIndex;
                    }
                }

                if (selectIndex == -1 && 0 < helpLanguages.Length)
                {
                    selectIndex = 0;
                }

                if (selectIndex != -1)
                {
                    comboBoxHelpLanguage.SelectedIndex = selectIndex;
                }
            }

            bool bHlaePathOk = System.Text.RegularExpressions.Regex.IsMatch(Program.BaseDir, "^\\p{IsBasicLatin}*$");

            this.groupBoxPathError.Visible = !bHlaePathOk;
            this.groupBoxPathError.Enabled = !bHlaePathOk;
            this.groupBoxPathError.Text    = L10n._("HLAE path error");
            this.labelHlaePath.Text        = L10n._("HLAE path:");
            this.textBoxHlaePath.Text      = Program.BaseDir;
            this.labelHlaePathError.Text   = L10n._("Warning: Your HLAE path shown above contains non-basic latin characters (meaning characters outside the 7-bit ASCII range), which will lead to multiple problems in-game if not fixed!");

            m_UpdateCheckNotification = new UpdateCheckNotificationTarget(this, new UpdateCheckedDelegate(OnUpdateChecked));
        }
Esempio n. 13
0
        public static bool Load(IEnumerable <GetHookPathDelegate> getHookPathCollection, string programPath, string cmdLine, string environment = null, bool showErrorMessage = true)
        {
            try
            {
                string programOptions   = "\"" + programPath + "\" " + cmdLine;
                string programDirectory = System.IO.Path.GetDirectoryName(programPath);

                PROCESS_INFORMATION processInfo = new PROCESS_INFORMATION();

                STARTUPINFOW startupInfo = new STARTUPINFOW();
                startupInfo.cb = (UInt32)Marshal.SizeOf(startupInfo);

                if (!CreateProcessW(
                        programPath
                        , programOptions
                        , null
                        , null
                        , true // inherit handles
                        ,      //CREATE_DEFAULT_ERROR_MODE|
                        CREATE_NEW_PROCESS_GROUP |
                        DETACHED_PROCESS |
                        CREATE_SUSPENDED
                        //DEBUG_ONLY_THIS_PROCESS|
                        //DEBUG_PROCESS				// we want to catch debug event's (sadly also of childs)
                        | CREATE_UNICODE_ENVIRONMENT
                        , environment
                        , programDirectory
                        , ref startupInfo
                        , out processInfo)
                    )
                {
                    throw HlaeErrors.LoaderCreateProcessException(Marshal.GetLastWin32Error());
                }

                try
                {
                    bool isProcess64Bit = IsProcess64Bit(processInfo.hProcess);

                    foreach (GetHookPathDelegate getHookPath in getHookPathCollection)
                    {
                        string hookPath = getHookPath(isProcess64Bit);

                        using (System.Diagnostics.Process injector = new System.Diagnostics.Process())
                        {
                            injector.StartInfo.UseShellExecute        = false;
                            injector.StartInfo.FileName               = System.AppDomain.CurrentDomain.BaseDirectory + (isProcess64Bit ? "\\x64" : "") + "\\injector.exe";
                            injector.StartInfo.CreateNoWindow         = true;
                            injector.StartInfo.RedirectStandardInput  = true;
                            injector.StartInfo.RedirectStandardOutput = true;

                            try
                            {
                                injector.Start();
                            }
                            catch (Exception e)
                            {
                                throw HlaeErrors.InjectorStartException(
                                          injector.StartInfo.FileName,
                                          e
                                          );
                            }

                            AfxError error = null;

                            IFormatter formatter = new advancedfx.injector.interop.Formatter();

                            using (Stream injectorIn = injector.StandardInput.BaseStream)
                            {
                                using (Stream injectorOut = injector.StandardOutput.BaseStream)
                                {
                                    advancedfx.injector.interop.InjectMessage injectMessage = new advancedfx.injector.interop.InjectMessage();
                                    injectMessage.ProcessId = processInfo.dwProcessId;
                                    injectMessage.DllPath   = hookPath;

                                    formatter.Serialize(injectorIn, injectMessage);
                                    injectorIn.Flush();

                                    bool injectorExit = false;

                                    while (!injectorExit)
                                    {
                                        advancedfx.injector.interop.ProcessMessage m = (advancedfx.injector.interop.ProcessMessage)formatter.Deserialize(injectorOut);

                                        switch (m)
                                        {
                                        case advancedfx.injector.interop.ExceptionError exceptionError:
                                            if (null == error)
                                            {
                                                error = HlaeErrors.Unknown;
                                            }
                                            break;

                                        case advancedfx.injector.interop.OpenProcessError openProcessError:
                                            if (null == error)
                                            {
                                                error = HlaeErrors.OpenProcessFailed;
                                            }
                                            break;

                                        case advancedfx.injector.interop.VirtualAllocExArgDllDirError virtualAllocExArgDllDirError:
                                            if (null == error)
                                            {
                                                error = HlaeErrors.VirtualAllocExReadWriteFailed;
                                            }
                                            break;

                                        case advancedfx.injector.interop.VirtualAllocExArgDllFilePathError virtualAllocExArgDllFilePathError:
                                            if (null == error)
                                            {
                                                error = HlaeErrors.VirtualAllocExReadWriteFailed;
                                            }
                                            break;

                                        case advancedfx.injector.interop.GetImageError getImageError:
                                            if (null == error)
                                            {
                                                error = HlaeErrors.GetImageFailed;
                                            }
                                            break;

                                        case advancedfx.injector.interop.VirtualAllocExImageError virtualAllocExImageError:
                                            if (null == error)
                                            {
                                                error = HlaeErrors.VirtualAllocExReadWriteExecuteFailed;
                                            }
                                            break;

                                        case advancedfx.injector.interop.WriteProcessMemoryArgDllDirError writeProcessMemoryArgDllDirError:
                                            if (null == error)
                                            {
                                                error = HlaeErrors.WriteProcessMemoryFailed;
                                            }
                                            break;

                                        case advancedfx.injector.interop.WriteProcessMemoryArgDllFilePathError writeProcessMemoryArgDllFilePathError:
                                            if (null == error)
                                            {
                                                error = HlaeErrors.WriteProcessMemoryFailed;
                                            }
                                            break;

                                        case advancedfx.injector.interop.WriteProcessMemoryImageError writeProcessMemoryImageError:
                                            if (null == error)
                                            {
                                                error = HlaeErrors.WriteProcessMemoryFailed;
                                            }
                                            break;

                                        case advancedfx.injector.interop.FlushInstructionCacheError flushInstructionCacheError:
                                            if (null == error)
                                            {
                                                error = HlaeErrors.FlushInstructionCacheFailed;
                                            }
                                            break;

                                        case advancedfx.injector.interop.CreateRemoteThreadError createRemoteThreadError:
                                            if (null == error)
                                            {
                                                error = HlaeErrors.CreateRemoteThreadFailed;
                                            }
                                            break;

                                        case advancedfx.injector.interop.ContinueWaitingQuestion contineWaitingQuestion:
                                        {
                                            advancedfx.injector.interop.ContinueWaiting r = new advancedfx.injector.interop.ContinueWaiting();
                                            r.Response = DialogResult.Yes == MessageBox.Show(L10n._("Image injection problem.\nContinue waiting?"), L10n._("injector Warning"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                                            formatter.Serialize(injectorIn, r);
                                            injectorIn.Flush();
                                        }
                                        break;

                                        case advancedfx.injector.interop.TerminateThreadError terminateThreadError:
                                            // ignore for now
                                            break;

                                        case advancedfx.injector.interop.GetExitCodeThreadError getExitCodeThreadError:
                                            // ignore for now
                                            break;

                                        case advancedfx.injector.interop.InvalidExitCodeError invalidExitCodeError:
                                            if (null == error)
                                            {
                                                error = InjectorErrors.AfxHookUnknown;
                                            }
                                            break;

                                        case advancedfx.injector.interop.KnownExitCodeError knownExitCodeError:
                                            if (null == error)
                                            {
                                                error = InjectorErrors.Instance.GetById((int)knownExitCodeError.ThreadExitCode);
                                            }
                                            break;

                                        case advancedfx.injector.interop.CloseHandleThreadError closeHandleError:
                                            // ignore for now
                                            break;

                                        case advancedfx.injector.interop.VirtualFreeExImageError virtualFreeExImageError:
                                            // ignore for now
                                            break;

                                        case advancedfx.injector.interop.VirtualFreeExArgFilePathError virtualFreeExArgFilePathError:
                                            // ignore for now
                                            break;

                                        case advancedfx.injector.interop.VirtualFreeExArgDllDirError virtualFreeExArgDllDirError:
                                            // ignore for now
                                            break;

                                        case advancedfx.injector.interop.CloseHandleProcessError closeHandleProcessError:
                                            // ignore for now
                                            break;

                                        case advancedfx.injector.interop.InjectResponse injectResponse:
                                            bool injectorOk = injectResponse.Response;
                                            injector.WaitForExit();
                                            if (!injectorOk)
                                            {
                                                throw null == error ? HlaeErrors.Unknown : error;
                                            }
                                            injectorExit = true;
                                            break;

                                        default:
                                            throw HlaeErrors.Unknown;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                finally
                {
                    System.Threading.Thread.Sleep(2000);

                    ResumeThread(processInfo.hThread);

                    CloseHandle(processInfo.hThread);
                    CloseHandle(processInfo.hProcess);
                }
            }
            catch (AfxError e)
            {
                if (showErrorMessage)
                {
                    using (ErrorDialogue frm = new ErrorDialogue())
                    {
                        frm.Error = e;
                        frm.ShowDialog();
                    }
                }

                return(false);
            }
            catch (Exception e)
            {
                if (showErrorMessage)
                {
                    using (ErrorDialogue frm = new ErrorDialogue())
                    {
                        frm.Error = HlaeErrors.LoaderException(e);
                        frm.ShowDialog();
                    }
                }

                return(false);
            }

            return(true);
        }
Esempio n. 14
0
        public static bool RunLauncherDialog(IWin32Window dialogOwner)
        {
            bool bOk;

            using (LauncherForm frm = new LauncherForm())
            {
                frm.Icon          = Program.Icon;
                frm.ShowInTaskbar = false;

                CfgLauncher cfg = new CfgLauncher();

                cfg.CopyFrom(GlobalConfig.Instance.Settings.Launcher);

                frm.ReadFromConfig(cfg);

                if (DialogResult.OK == frm.ShowDialog(dialogOwner))
                {
                    frm.WriteToConfig(cfg);

                    if (cfg.RememberChanges)
                    {
                        GlobalConfig.Instance.Settings.Launcher.CopyFrom(cfg);
                        GlobalConfig.Instance.BackUp();
                    }

                    bOk = Launch(cfg);

                    if (!bOk)
                    {
                        MessageBox.Show(L10n._p("Launcher dialog", "Launching failed."), L10n._("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    bOk = true;
                }
            }

            return(bOk);
        }