예제 #1
0
파일: Form1.cs 프로젝트: Jakes625/gtavcsc
        private void openCSCToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog op = new OpenFileDialog();
            op.Title = "Select a GTA V CSC File.";
            if (op.ShowDialog() == DialogResult.OK)
            {
                if (!nativesLoaded) //we need natives before we can open csc.
                    return;

                CSC ScriptFile = new CSC(op.FileName);
                ScriptFile.Read(); //read the file..

                opcodeBox.Text = "";
                nativesList.Items.Clear();
                scriptStringsList.Items.Clear();
                this.Text = "CSCEditor - " + ScriptFile.scriptName;

                for (int i = 0; i < ScriptFile.Natives.Length; i++)
                {
                    nativesList.Items.Add(getNativeName(ScriptFile.Natives[i],natives));
                }

                foreach(string scriptString in ScriptFile.scriptStrings)
                {
                    scriptStringsList.Items.Add(scriptString);
                }

                for (int i = 0; i < 500; i++)
                {
                    string code = "\t" + ScriptFile.codePageData[i].ToString("X");
                    switch (ScriptFile.codePageData[i])
                    {
                        case 0:
                            code = "\tnop";
                            break;

                        case 1:
                            code = "\tiadd";
                            break;

                        case 2:
                            code = "\tisub";
                            break;

                        case 3:
                            code = "\timul";
                            break;

                        case 4:
                            code = "\tidiv";
                            break;

                        case 5:
                            code = "\timod";
                            break;

                        case 6:
                            code = "\tiszero";
                            break;

                        case 7:
                            code = "\tineg";
                            break;

                        case 8:
                            code = "\ticompeq";
                            break;

                        case 45:
                            code = "\tnativeCall";
                            int argCount = ScriptFile.codePageData[i + 1];
                            int retCount = ScriptFile.codePageData[i + 2];

                            byte[] hash = new byte[4];
                            Buffer.BlockCopy(ScriptFile.codePageData, i + 3, hash, 0, 4);
                            Array.Reverse(hash);
                            uint n = BitConverter.ToUInt32(hash, 0);
                            code += ": " + getNativeName(n, natives);

                            break;

                        case 46:
                            code = "{";
                            break;

                        case 47:
                            code = "}";
                            break;
                    }
                    opcodeBox.Text += code + "\n";
                }

            }
            op.Dispose();
        }
예제 #2
0
파일: CSC.cs 프로젝트: Jakes625/gtavcsc
 public CSC(CSC csc)
 {
     //idk yet...
 }