Example #1
0
 public ConflictCheckerForm(IList <AsmPatch> patchList, FreeSpaceMode mode)
 {
     InitializeComponent();
     this.origPatchList     = patchList;
     this.conflictPatchData = ConflictHelper.CheckConflicts(patchList, mode);
     FindPatchColors(this.conflictPatchData.PatchList);
     ShowPatches(this.conflictPatchData);
 }
Example #2
0
        public static PatchResult PatchPSV(string filename, List <AsmPatch> asmPatches, ASMEncoding.ASMEncodingUtility asmUtility)
        {
            ConflictResolveResult conflictResolveResult = ConflictHelper.ResolveConflicts(asmPatches, asmUtility);

            asmPatches = conflictResolveResult.Patches;

            List <PatchedByteArray> patches = new List <PatchedByteArray>();

            foreach (AsmPatch asmPatch in asmPatches)
            {
                asmPatch.Update(asmUtility);
                foreach (PatchedByteArray innerPatch in asmPatch)
                {
                    patches.Add(innerPatch);
                }
            }

            PatchPsxSaveStateResult patchResult;

            using (BinaryReader reader = new BinaryReader(File.Open(filename, FileMode.Open)))
            {
                patchResult = PatcherLib.Iso.PsxIso.PatchPsxSaveState(reader, patches);
            }

            StringBuilder sbResultMessage = new StringBuilder();

            sbResultMessage.AppendLine("Complete!");
            sbResultMessage.AppendLine();

            if (!string.IsNullOrEmpty(conflictResolveResult.Message))
            {
                sbResultMessage.AppendLine(conflictResolveResult.Message);
                sbResultMessage.AppendLine();
            }

            if (patchResult.UnsupportedFiles.Count > 0)
            {
                sbResultMessage.AppendLine("Files not supported for savestate patching:");
                foreach (PsxIso.Sectors sector in patchResult.UnsupportedFiles)
                {
                    sbResultMessage.AppendFormat("\t{0}{1}", PsxIso.GetSectorName(sector), Environment.NewLine);
                }
                sbResultMessage.AppendLine();
            }
            if (patchResult.AbsentFiles.Count > 0)
            {
                sbResultMessage.AppendLine("Files not present in savestate:");
                foreach (PsxIso.Sectors sector in patchResult.AbsentFiles)
                {
                    sbResultMessage.AppendFormat("\t{0}{1}", PsxIso.GetSectorName(sector), Environment.NewLine);
                }
                sbResultMessage.AppendLine();
            }

            return(new PatchResult(true, sbResultMessage.ToString()));
        }
Example #3
0
        public static PatchResult PatchISO(string filename, List <AsmPatch> asmPatches, ASMEncoding.ASMEncodingUtility asmUtility)
        {
            ConflictResolveResult conflictResolveResult = ConflictHelper.ResolveConflicts(asmPatches, asmUtility);

            asmPatches = conflictResolveResult.Patches;
            string conflictResolveMessage = conflictResolveResult.Message;

            List <PatchedByteArray> patches = new List <PatchedByteArray>();

            foreach (AsmPatch asmPatch in asmPatches)
            {
                asmPatch.Update(asmUtility);
                foreach (PatchedByteArray innerPatch in asmPatch)
                {
                    patches.Add(innerPatch);

                    if ((asmUtility.EncodingMode == ASMEncodingMode.PSP) && (innerPatch.Sector == (int)PspIso.Sectors.PSP_GAME_SYSDIR_BOOT_BIN))
                    {
                        patches.Add(innerPatch.GetCopyForSector(PspIso.Sectors.PSP_GAME_SYSDIR_EBOOT_BIN));
                    }
                }
            }

            using (Stream file = File.Open(filename, FileMode.Open, FileAccess.ReadWrite, FileShare.Read))
            {
                if (asmUtility.EncodingMode == ASMEncoding.ASMEncodingMode.PSX)
                {
                    PsxIso.PatchPsxIso(file, patches);
                }
                else if (asmUtility.EncodingMode == ASMEncoding.ASMEncodingMode.PSP)
                {
                    PspIso.PatchISO(file, patches);
                }
            }

            StringBuilder sbResultMessage = new StringBuilder();

            sbResultMessage.AppendLine("Complete!");
            sbResultMessage.AppendLine();

            if (!string.IsNullOrEmpty(conflictResolveMessage))
            {
                sbResultMessage.AppendLine(conflictResolveMessage);
                sbResultMessage.AppendLine();
            }

            // DEBUG
            //File.WriteAllText("./output.xml", PatchXmlReader.CreatePatchXML(patches), Encoding.UTF8);

            return(new PatchResult(true, sbResultMessage.ToString()));
        }