private void Iso2God_Partial(bool Crop, IsoEntry iso, string ID) { FileStream stream; GDF gdf; Console.WriteLine("+ Examining ISO image..."); try { stream = new FileStream(iso.Path, FileMode.Open, FileAccess.Read, FileShare.Read); } catch (Exception) { Console.WriteLine("- Cannot access the ISO image because it is being accessed by another application."); return; } try { gdf = new GDF(stream); } catch (Exception exception) { Console.WriteLine("- Error while parsing GDF: " + exception.Message); return; } ulong num = 0L; if (Crop) { num = (((ulong)iso.Size) - gdf.RootOffset) - (((ulong)iso.Size) - (gdf.LastOffset + gdf.RootOffset)); } else { num = ((ulong)iso.Size) - gdf.RootOffset; } uint blocksReq = (uint)Math.Ceiling(num / ((double)blockSize)); uint partsReq = (uint)Math.Ceiling(blocksReq / ((double)blockPerPart)); ContentType type = (iso.Platform == IsoEntryPlatform.Xbox360) ? ContentType.GamesOnDemand : ContentType.XboxOriginal; string gameTitle = Get360TitleName.getFromDB(ID).ToString(); var invalidChars = new string[] { ":" }; foreach (var i in invalidChars) { gameTitle = gameTitle.Replace(i, " "); } Console.WriteLine(gameTitle); object[] objArray = { iso.Destination, gameTitle, Path.DirectorySeparatorChar, "0000", ((uint)type).ToString("X02"), Path.DirectorySeparatorChar }; string path = string.Concat(objArray) + ((uniqueName != null) ? uniqueName : iso.ID.TitleID) + ".data"; if (Directory.Exists(path)) { Directory.Delete(path, true); } Directory.CreateDirectory(path); Console.WriteLine("+ Beginning ISO conversion..."); Start = DateTime.Now; stream.Seek((long)gdf.RootOffset, SeekOrigin.Begin); writeParts(stream, path, partsReq, blocksReq); Console.WriteLine("+ Calculating Master Hash Table chain..."); byte[] lastMhtHash = new byte[20]; uint lastPartSize = 0; calcMhtHashChain(path, partsReq, out lastPartSize, out lastMhtHash); ulong num6 = 0xa290L; ulong num7 = blockSize * num6; ulong sizeParts = lastPartSize + ((partsReq - 1) * num7); Console.WriteLine("+ Creating LIVE header..."); createConHeader(path.Substring(0, path.Length - 5), iso, blocksReq, 0, partsReq, sizeParts, lastMhtHash); stream.Close(); stream.Dispose(); gdf.Dispose(); Finish = DateTime.Now; TimeSpan span = Finish - Start; Console.WriteLine("+ Done!"); Console.WriteLine("+ Finished in " + span.Minutes + "m" + span.Seconds + "s. GOD package written to: " + path); GC.Collect(); }
private void Iso2God_Partial(object sender, DoWorkEventArgs e, bool Crop, IsoEntry iso) { FileStream stream; GDF gdf; base.ReportProgress((int)this.progress, "Examining ISO image..."); try { stream = new FileStream(iso.Path, FileMode.Open, FileAccess.Read, FileShare.Read); } catch (Exception) { base.ReportProgress(0, "Cannot access the ISO image because it is being accessed by another application."); return; } try { gdf = new GDF(stream); } catch (Exception exception) { base.ReportProgress(0, "Error while parsing GDF: " + exception.Message); return; } ulong num = 0L; if (Crop) { num = (((ulong)iso.Size) - gdf.RootOffset) - (((ulong)iso.Size) - (gdf.LastOffset + gdf.RootOffset)); } else { num = ((ulong)iso.Size) - gdf.RootOffset; } uint blocksReq = (uint)Math.Ceiling((double)(((double)num) / ((double)this.blockSize))); uint partsReq = (uint)Math.Ceiling((double)(((double)blocksReq) / ((double)this.blockPerPart))); ContentType type = (iso.Platform == IsoEntryPlatform.Xbox360) ? ContentType.GamesOnDemand : ContentType.XboxOriginal; object[] objArray = new object[] { iso.Destination, iso.ID.TitleID, Path.DirectorySeparatorChar, "0000", ((uint)type).ToString("X02"), Path.DirectorySeparatorChar }; string path = string.Concat(objArray) + ((this.uniqueName != null) ? this.uniqueName : iso.ID.TitleID) + ".data"; if (Directory.Exists(path)) { Directory.Delete(path, true); } Directory.CreateDirectory(path); base.ReportProgress((int)this.progress, "Beginning ISO conversion..."); stream.Seek((long)gdf.RootOffset, SeekOrigin.Begin); this.writeParts(stream, path, iso, partsReq, blocksReq); base.ReportProgress((int)this.progress, "Calculating Master Hash Table chain..."); byte[] lastMhtHash = new byte[20]; uint lastPartSize = 0; this.calcMhtHashChain(path, partsReq, out lastPartSize, out lastMhtHash); ulong num6 = 0xa290L; ulong num7 = this.blockSize * num6; ulong sizeParts = lastPartSize + ((partsReq - 1) * num7); base.ReportProgress(0x5f, "Creating LIVE header..."); this.createConHeader(path.Substring(0, path.Length - 5), iso, blocksReq, 0, partsReq, sizeParts, lastMhtHash); stream.Close(); stream.Dispose(); gdf.Dispose(); if ((iso.Padding.Type == IsoEntryPaddingRemoval.Full) && !iso.Padding.KeepIso) { try { File.Delete(iso.Path); } catch (Exception) { base.ReportProgress(0x5f, "Unable to delete ISO temporary image."); } } this.Finish = DateTime.Now; TimeSpan span = (TimeSpan)(this.Finish - this.Start); base.ReportProgress(100, "Done!"); e.Result = "Finished in " + span.Minutes.ToString() + "m" + span.Seconds.ToString() + "s. GOD package written to: " + path; GC.Collect(); }