예제 #1
0
 public void SetApp(StubApp app)
 {
     this.App = app;
     StopProcess();
     if (app != null)
     {
         if (!string.IsNullOrEmpty(app.Name))
         {
             btnProcessTitle.Text = app.Name;
         }
         else
         {
             btnProcessTitle.Text = Path.GetFileNameWithoutExtension(app.Path);
         }
         toolTip1.SetToolTip(btnProcessTitle, btnProcessTitle.Text + "\n" + app.Path + "\n" + app.Args);
         process              = new ProcessPlus(app.Path, app.Args);
         process.OnExitEvent += delegate(string path, string arg, bool error) {
             UpdateStatus();
             if (OnProcessExit != null)
             {
                 OnProcessExit(this, path, arg, error);
             }
         };
     }
 }
예제 #2
0
        /// <summary>
        ///     Disables the memorySharp patch.
        /// </summary>
        public void Disable(bool disableDueToRules)
        {
            if (IgnoreRules && disableDueToRules)
            {
                return;
            }

            DisabledDueToRules = disableDueToRules;

            ProcessPlus.Write(Address, OriginalBytes);
            IsEnabled = false;
        }
예제 #3
0
        /// <summary>
        ///     Enables the memorySharp patch.
        /// </summary>
        public void Enable(bool disableDueToRules)
        {
            if (disableDueToRules && DisabledDueToRules)
            {
                DisabledDueToRules = false;
                ProcessPlus.Write(Address, PatchBytes);
                IsEnabled = true;
            }

            else
            {
                if (DisabledDueToRules)
                {
                    return;
                }

                ProcessPlus.Write(Address, PatchBytes);
                IsEnabled = true;
            }
        }
예제 #4
0
 /// <summary>
 ///     States if the Patch is enabled.
 /// </summary>
 /// <returns>
 ///     <c>true</c>
 ///     if this instance is enabled; otherwise, <c>false</c>
 ///     .
 /// </returns>
 public bool CheckIfEnabled()
 {
     return(ProcessPlus.Read(Address, PatchBytes.Length).SequenceEqual(PatchBytes));
 }
예제 #5
0
        async private Task GenerateH(string FilePath, string OutputFolder)
        {
            SystemService ss         = SM.Get <SystemService>();
            String        FileName   = ss.GetFileName(FilePath);
            String        FileNameWE = ss.GetFileNameWithoutExtension(FilePath);

            if (FileName == "asc126.bmp")
            {
                //file caratteri
                Bitmap           b    = new Bitmap(FilePath);
                asc126_generator g    = new asc126_generator();
                byte[]           bits = g.convertToByteArray(b);

                String outS = "const unsigned char ASC_DATA[] = {\r\n";
                for (int i = 0; i < bits.Length; i++)
                {
                    outS += "0x" + bits[i].ToHexString(true) + ", ";
                    if (i % 12 == 11)
                    {
                        outS += "\r\n";
                    }
                }
                outS += "};";
                String OutFile = ss.CombinePaths(OutputFolder, "asc126.h");
                ss.Write(OutFile, outS, false);
            }
            else if (FileName == "_text_palette.png")
            {
                //file caratteri
                Bitmap b = new Bitmap(FilePath);
                text_palette_generator      tpg = new text_palette_generator();
                Dictionary <string, string> d   = tpg.convert(b);


                String outS = "\r\n";
                foreach (KeyValuePair <String, String> kp in d)
                {
                    outS += "u16 " + kp.Key + " = " + kp.Value + ";\r\n";
                }

                String OutFile = ss.CombinePaths(OutputFolder, "_text_palette.h");
                ss.Write(OutFile, outS, false);
            }
            else if (FileName.EndsWith(".png"))     //TODO: implemento controlli per nomi corretti???
            {
                //file immagini

                //TODO: con grit vado a convertire il file
                ProcessPlus pp = new ProcessPlus(GritPath, "\"" + FilePath + "\" -gB16 -gu8 -gb -ftc");
                pp.WorkingDirectory = OutputFolder;
                pp.CreateNoWindow   = true;
                pp.Async            = false;
                pp.WaitForExit      = true;
                await pp.Start();

                string OutFileWithoutExtension = ss.CombinePaths(OutputFolder, ss.GetFileNameWithoutExtension(FileName));
                ss.DeleteSecure(OutFileWithoutExtension + ".h");                                 //tengo solo il .c
                ss.Rename(OutFileWithoutExtension + ".c", OutFileWithoutExtension + ".h");       //lo converto in .h

                if (!ss.FileExist(OutFileWithoutExtension + ".h"))
                {
                    return;
                }

                String Cont = ss.Read(OutFileWithoutExtension + ".h");
                Cont = Cont.Replace(FileNameWE + "Bitmap", "gImage_" + FileNameWE);
                ss.Write(OutFileWithoutExtension + ".h", Cont, false);
                //cambio il nome della variabile
            }
            else
            {
                //file non convertibile
            }
        }