Пример #1
0
        private void buttonOpen_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            bool   bResult = false;
            string sResult = "Error: Unknown";

            if (File.Exists(textBoxSCO.Text) == false)
            {
                MessageBox.Show(String.Format(sError, "Error: File not found."), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            bResult = SCO.openSCO(textBoxSCO.Text);
            if (bResult == false)
            {
                MessageBox.Show(String.Format(sError, "Error: Opening SCO file failed."), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            sResult = SCO.getSCOType();
            if (sResult.StartsWith("Error:"))
            {
                MessageBox.Show(String.Format(sError, sResult), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                labelSCOType.Text = sResult;
            }

            if (SCO.isEncrypted == true)
            {
                sResult = SCO.getHeaderSectionDec();
                if (sResult.StartsWith("Error:"))
                {
                    MessageBox.Show(String.Format(sError, sResult), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                labelAction.Text = "Decode";
            }
            else
            {
                sResult = SCO.getHeaderSectionEnc();
                if (sResult.StartsWith("Error:"))
                {
                    MessageBox.Show(String.Format(sError, sResult), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                labelAction.Text = "Encode";
            }

            sResult = SCO.getCodeSize();
            if (sResult.StartsWith("Error:"))
            {
                MessageBox.Show(String.Format(sError, sResult), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                labelCodeSize.Text = sResult;
            }

            if (Convert.ToInt32(SCO.getCodeSize().Replace("bytes", "").Trim()) > 50000)
            {
                radioButtonBasic.Checked = true;
            }
            else
            {
                radioButtonAdvanced.Checked = true;
            }

            sResult = SCO.getGlobalCount();
            if (sResult.StartsWith("Error:"))
            {
                MessageBox.Show(String.Format(sError, sResult), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                labelGlobals.Text = sResult;
            }

            sResult = SCO.getPublicCount();
            if (sResult.StartsWith("Error:"))
            {
                MessageBox.Show(String.Format(sError, sResult), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                labelPublics.Text = sResult;
            }

            sResult = SCO.getCodeFlags();
            if (sResult.StartsWith("Error:"))
            {
                MessageBox.Show(String.Format(sError, sResult), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                labelFlags.Text = sResult;
            }

            sResult = SCO.getSignature();
            if (sResult.StartsWith("Error:"))
            {
                MessageBox.Show(String.Format(sError, sResult), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                labelSignature.Text = sResult;
            }

            if (sResult.Contains("GTA IV") == false)
            {
                radioButtonNew.Checked = true;
            }
            else
            {
                radioButtonOld.Checked = true;
            }

            if (SCO.isEncrypted == true)
            {
                sResult = SCO.getCodeSectionDec();
                if (sResult.StartsWith("Error:"))
                {
                    MessageBox.Show(String.Format(sError, sResult), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                sResult = SCO.getGlobalSectionDec();
                if (sResult.StartsWith("Error:"))
                {
                    MessageBox.Show(String.Format(sError, sResult), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                sResult = SCO.getPublicSectionDec();
                if (sResult.StartsWith("Error:"))
                {
                    MessageBox.Show(String.Format(sError, sResult), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                sResult = SCO.getCodeSectionEnc();
                if (sResult.StartsWith("Error:"))
                {
                    MessageBox.Show(String.Format(sError, sResult), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                sResult = SCO.getGlobalSectionEnc();
                if (sResult.StartsWith("Error:"))
                {
                    MessageBox.Show(String.Format(sError, sResult), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                sResult = SCO.getPublicSectionEnc();
                if (sResult.StartsWith("Error:"))
                {
                    MessageBox.Show(String.Format(sError, sResult), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            bResult = SCO.closeSCO();
            if (bResult == false)
            {
                MessageBox.Show(String.Format(sError, "Error: Closing SCO file failed."), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            label2.Enabled             = true;
            textBoxTargetSCO.Enabled   = true;
            buttonBrowseTarget.Enabled = true;
            buttonProcess.Enabled      = true;
            checkBoxSelf.Enabled       = true;
            groupBox.Enabled           = true;

            buttonOpen.Enabled   = false;
            buttonBrowse.Enabled = false;
            buttonClose.Enabled  = true;
            textBoxSCO.ReadOnly  = true;

            textBoxTargetSCO.Enabled   = !checkBoxSelf.Checked;
            buttonBrowseTarget.Enabled = !checkBoxSelf.Checked;

            if (SCO.isEncrypted == true)
            {
                textBoxTargetSCO.Text = textBoxSCO.Text.Replace(".sco", " - Decoded.sco");
            }
            else
            {
                textBoxTargetSCO.Text = textBoxSCO.Text.Replace(".sco", " - Encoded.sco");
            }

            Cursor.Current = Cursors.Default;
        }
Пример #2
0
        private void backgroundWorkerAll_DoWork(object sender, DoWorkEventArgs e)
        {
            int i = filenr; string sResult = ""; bool bResult = true;

            bResult = SCO.openSCO(listBox.Items[i].ToString());
            if (bResult == false)
            {
                multiError += "\n" + listBox.Items[i].ToString() + ": Opening SCO file failed."; return;
            }

            sResult = "";

            sResult = SCO.getSCOType(); if (sResult.StartsWith("Error:") == true)
            {
                multiError += "\n" + listBox.Items[i].ToString() + sResult.Replace("Error", ""); return;
            }
            if (SCO.isEncrypted == true)
            {
                sResult = SCO.getHeaderSectionDec(); if (sResult.StartsWith("Error:") == true)
                {
                    multiError += "\n" + listBox.Items[i].ToString() + sResult.Replace("Error", ""); return;
                }
            }
            else
            {
                sResult = SCO.getHeaderSectionEnc(); if (sResult.StartsWith("Error:") == true)
                {
                    multiError += "\n" + listBox.Items[i].ToString() + sResult.Replace("Error", ""); return;
                }
            }
            sResult = SCO.getCodeSize(); if (sResult.StartsWith("Error:") == true)
            {
                multiError += "\n" + listBox.Items[i].ToString() + sResult.Replace("Error", ""); return;
            }
            sResult = SCO.getGlobalCount(); if (sResult.StartsWith("Error:") == true)
            {
                multiError += "\n" + listBox.Items[i].ToString() + sResult.Replace("Error", ""); return;
            }
            sResult = SCO.getPublicCount(); if (sResult.StartsWith("Error:") == true)
            {
                multiError += "\n" + listBox.Items[i].ToString() + sResult.Replace("Error", ""); return;
            }
            sResult = SCO.getCodeFlags(); if (sResult.StartsWith("Error:") == true)
            {
                multiError += "\n" + listBox.Items[i].ToString() + sResult.Replace("Error", ""); return;
            }
            sResult = SCO.getSignature(); if (sResult.StartsWith("Error:") == true)
            {
                multiError += "\n" + listBox.Items[i].ToString() + sResult.Replace("Error", ""); return;
            }
            if (SCO.isEncrypted == true)
            {
                sResult = SCO.getCodeSectionDec(); if (sResult.StartsWith("Error:") == true)
                {
                    multiError += "\n" + listBox.Items[i].ToString() + sResult.Replace("Error", ""); return;
                }
                sResult = SCO.getGlobalSectionDec(); if (sResult.StartsWith("Error:") == true)
                {
                    multiError += "\n" + listBox.Items[i].ToString() + sResult.Replace("Error", ""); return;
                }
                sResult = SCO.getPublicSectionDec(); if (sResult.StartsWith("Error:") == true)
                {
                    multiError += "\n" + listBox.Items[i].ToString() + sResult.Replace("Error", ""); return;
                }
            }
            else
            {
                sResult = SCO.getCodeSectionEnc(); if (sResult.StartsWith("Error:") == true)
                {
                    multiError += "\n" + listBox.Items[i].ToString() + sResult.Replace("Error", ""); return;
                }
                sResult = SCO.getGlobalSectionEnc(); if (sResult.StartsWith("Error:") == true)
                {
                    multiError += "\n" + listBox.Items[i].ToString() + sResult.Replace("Error", ""); return;
                }
                sResult = SCO.getPublicSectionEnc(); if (sResult.StartsWith("Error:") == true)
                {
                    multiError += "\n" + listBox.Items[i].ToString() + sResult.Replace("Error", ""); return;
                }
            }
            bResult = SCO.closeSCO(); if (sResult.StartsWith("Error:") == true)
            {
                multiError += "\n" + listBox.Items[i].ToString() + sResult.Replace("Error", ""); return;
            }
            if (SCO.isEncrypted == true)
            {
                if (checkBoxSelfAll.Checked == true)
                {
                    sResult = SCO.saveFileDec(listBox.Items[i].ToString());
                }
                else
                {
                    sResult = SCO.saveFileDec(textBoxDir.Text + "\\" + Path.GetFileName(listBox.Items[i].ToString()));
                }
            }
            else
            {
                if (checkBoxSelfAll.Checked == true)
                {
                    sResult = SCO.saveFileEnc(listBox.Items[i].ToString());
                }
                else
                {
                    sResult = SCO.saveFileEnc(textBoxDir.Text + "\\" + Path.GetFileName(listBox.Items[i].ToString()));
                }
            }
            if (sResult.StartsWith("Error:") == true)
            {
                multiError += "\n" + listBox.Items[i].ToString() + sResult.Replace("Error", ""); return;
            }
        }