public ChuniAppPatch(ChuniAppPatchType chuniAppPatchType, int offset, byte[] off, byte[] on) { ChuniAppPatchType = chuniAppPatchType; Offset = offset; On = on; Off = off; }
public ChunAppPatchStatusType FlipChuniAppPatch(ChuniAppPatchType chuniAppPatchType) { if (!Files.TryGetValue(FileType.ChuniApp, out var fileInfo)) { Program.LogError("Executable not found? Please check your bin Folder."); return(ChunAppPatchStatusType.Unknown); } if (!CurrentChuniAppPatches.TryGetValue(chuniAppPatchType, out var chunAppPatchStatusType)) { Program.LogError("Patch not found in Executable?"); return(ChunAppPatchStatusType.Unknown); } if (chunAppPatchStatusType == ChunAppPatchStatusType.Unknown) { Program.LogError("Can't Patch this as status is Unknown."); return(ChunAppPatchStatusType.Unknown); } if (!Settings.ChuniAppPatches.TryGetValue(chuniAppPatchType, out var chuniAppPatches)) { Program.LogError("Patch not found in Settings file."); return(ChunAppPatchStatusType.Unknown); } using (var stream = new FileStream(fileInfo.FullName, FileMode.Open, FileAccess.ReadWrite)) { foreach (var chuniAppPatch in chuniAppPatches) { stream.Position = chuniAppPatch.Offset; if (chunAppPatchStatusType == ChunAppPatchStatusType.On) { stream.Write(chuniAppPatch.Off, 0, chuniAppPatch.Off.Length); } else if (chunAppPatchStatusType == ChunAppPatchStatusType.Off) { stream.Write(chuniAppPatch.On, 0, chuniAppPatch.On.Length); } } } if (chunAppPatchStatusType == ChunAppPatchStatusType.On) { return(ChunAppPatchStatusType.Off); } else if (chunAppPatchStatusType == ChunAppPatchStatusType.Off) { return(ChunAppPatchStatusType.On); } else { return(ChunAppPatchStatusType.Unknown); } }