├── .gitignore
├── XSFHeader.bin
├── Microsoft.WindowsAPICodePack.dll
├── Microsoft.WindowsAPICodePack.Shell.dll
├── app.config
├── Properties
├── Settings.settings
├── Settings.Designer.cs
├── AssemblyInfo.cs
├── Resources.Designer.cs
└── Resources.resx
├── README.md
├── God2Iso.sln
├── Program.cs
├── Form1.resx
├── God2Iso.csproj
├── Form1.Designer.cs
├── LICENSE.md
└── Form1.cs
/.gitignore:
--------------------------------------------------------------------------------
1 | .vs
2 | bin
3 | obj
4 |
--------------------------------------------------------------------------------
/XSFHeader.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raburton/god2iso/HEAD/XSFHeader.bin
--------------------------------------------------------------------------------
/Microsoft.WindowsAPICodePack.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raburton/god2iso/HEAD/Microsoft.WindowsAPICodePack.dll
--------------------------------------------------------------------------------
/Microsoft.WindowsAPICodePack.Shell.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raburton/god2iso/HEAD/Microsoft.WindowsAPICodePack.Shell.dll
--------------------------------------------------------------------------------
/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # God2Iso
2 |
3 |
4 |
5 | This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
6 |
7 | ## v1.0.5
8 |
9 | ***What's new?***
10 |
11 | - God2Iso is now open source, licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
12 | - Adjusted copyright text to reflect Github repository and new licensing.
13 | - Added assembly description.
14 | - Use Path.Combine for better linux support (thanks to Megan Leet).
15 | - This verison tagged (somewhat late) and binary version uploaded as requested.
16 |
17 | ## v1.0.4
18 |
19 | ***What's new?***
20 |
21 | - Handle updating sector offsets for directory tables which span multiple sectors
22 |
--------------------------------------------------------------------------------
/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace God2Iso.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.7.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/God2Iso.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "God2Iso", "God2Iso.csproj", "{6519E1C2-DACD-401D-BA3A-13260B11DF17}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Debug|x86 = Debug|x86
10 | Release|Any CPU = Release|Any CPU
11 | Release|x86 = Release|x86
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {6519E1C2-DACD-401D-BA3A-13260B11DF17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {6519E1C2-DACD-401D-BA3A-13260B11DF17}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {6519E1C2-DACD-401D-BA3A-13260B11DF17}.Debug|x86.ActiveCfg = Debug|x86
17 | {6519E1C2-DACD-401D-BA3A-13260B11DF17}.Debug|x86.Build.0 = Debug|x86
18 | {6519E1C2-DACD-401D-BA3A-13260B11DF17}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {6519E1C2-DACD-401D-BA3A-13260B11DF17}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {6519E1C2-DACD-401D-BA3A-13260B11DF17}.Release|x86.ActiveCfg = Release|x86
21 | {6519E1C2-DACD-401D-BA3A-13260B11DF17}.Release|x86.Build.0 = Release|x86
22 | EndGlobalSection
23 | GlobalSection(SolutionProperties) = preSolution
24 | HideSolutionNode = FALSE
25 | EndGlobalSection
26 | EndGlobal
27 |
--------------------------------------------------------------------------------
/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("God2Iso")]
9 | [assembly: AssemblyDescription("Program to convert Xbox 360 Games on Demand (GOD) containers to ISO")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("rab (richardaburton@gmail.com)")]
12 | [assembly: AssemblyProduct("God2Iso")]
13 | [assembly: AssemblyCopyright("Copyright © rab (richardaburton@gmail.com) 2010-2023")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("e28f677d-3e2b-4a7c-8555-cc899c50a138")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | [assembly: AssemblyVersion("1.0.5.0")]
33 | [assembly: AssemblyFileVersion("1.0.5.0")]
34 |
--------------------------------------------------------------------------------
/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Windows.Forms;
4 | using System.Reflection;
5 | using System.IO;
6 |
7 | namespace God2Iso {
8 | static class Program {
9 |
10 | private static Dictionary assemblies = new Dictionary();
11 |
12 | ///
13 | /// The main entry point for the application.
14 | ///
15 | [STAThread]
16 | static void Main() {
17 | AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(AssemblyResolv);
18 | Application.EnableVisualStyles();
19 | Application.SetCompatibleTextRenderingDefault(false);
20 | Application.Run(new Form1());
21 | }
22 |
23 | private static Assembly AssemblyResolv(object sender, ResolveEventArgs args) {
24 | if (assemblies.ContainsKey(args.Name)) {
25 | return assemblies[args.Name];
26 | } else {
27 | Assembly executingAssembly = Assembly.GetExecutingAssembly();
28 | string[] resources = executingAssembly.GetManifestResourceNames();
29 | foreach (string resource in resources) {
30 | if (resource.EndsWith(".dll")) {
31 | Stream manifestResourceStream = executingAssembly.GetManifestResourceStream(resource);
32 | byte[] buffer = new byte[manifestResourceStream.Length];
33 | manifestResourceStream.Read(buffer, 0, buffer.Length);
34 | try {
35 | Assembly assembly = Assembly.Load(buffer);
36 | if (assembly.FullName.Equals(args.Name)) {
37 | assemblies.Add(assembly.FullName, assembly);
38 | return assembly;
39 | }
40 | } catch (Exception) { }
41 | }
42 | }
43 | }
44 | return null;
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace God2Iso.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("God2Iso.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized resource of type System.Byte[].
65 | ///
66 | internal static byte[] XSFHeader {
67 | get {
68 | object obj = ResourceManager.GetObject("XSFHeader", resourceCulture);
69 | return ((byte[])(obj));
70 | }
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | 17, 17
122 |
123 |
--------------------------------------------------------------------------------
/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\xsfheader.bin;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
123 |
124 |
--------------------------------------------------------------------------------
/God2Iso.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.50727
7 | 2.0
8 | {6519E1C2-DACD-401D-BA3A-13260B11DF17}
9 | WinExe
10 | Properties
11 | God2Iso
12 | God2Iso
13 | God2Iso.Program
14 |
15 |
16 | 3.5
17 |
18 |
19 | v3.5
20 |
21 | publish\
22 | true
23 | Disk
24 | false
25 | Foreground
26 | 7
27 | Days
28 | false
29 | false
30 | true
31 | 0
32 | 1.0.0.%2a
33 | false
34 | false
35 | true
36 |
37 |
38 | true
39 | full
40 | false
41 | bin\Debug\
42 | DEBUG;TRACE
43 | prompt
44 | 4
45 | AllRules.ruleset
46 |
47 |
48 | pdbonly
49 | true
50 | bin\Release\
51 | TRACE
52 | prompt
53 | 4
54 | AllRules.ruleset
55 |
56 |
57 | true
58 | bin\x86\Debug\
59 | DEBUG;TRACE
60 | full
61 | x86
62 | prompt
63 | AllRules.ruleset
64 |
65 |
66 | bin\x86\Release\
67 | TRACE
68 | true
69 | pdbonly
70 | x86
71 | prompt
72 | AllRules.ruleset
73 |
74 |
75 |
76 | False
77 | .\Microsoft.WindowsAPICodePack.dll
78 |
79 |
80 | False
81 | .\Microsoft.WindowsAPICodePack.Shell.dll
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 | Form
94 |
95 |
96 | Form1.cs
97 |
98 |
99 |
100 |
101 | Designer
102 | Form1.cs
103 |
104 |
105 | ResXFileCodeGenerator
106 | Resources.Designer.cs
107 | Designer
108 |
109 |
110 | True
111 | Resources.resx
112 | True
113 |
114 |
115 |
116 | SettingsSingleFileGenerator
117 | Settings.Designer.cs
118 |
119 |
120 |
121 | True
122 | Settings.settings
123 | True
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 | False
135 | .NET Framework 3.5 SP1 Client Profile
136 | false
137 |
138 |
139 | False
140 | .NET Framework 3.5 SP1
141 | true
142 |
143 |
144 | False
145 | Windows Installer 3.1
146 | true
147 |
148 |
149 |
150 |
157 |
--------------------------------------------------------------------------------
/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace God2Iso {
2 | partial class Form1 {
3 | ///
4 | /// Required designer variable.
5 | ///
6 | private System.ComponentModel.IContainer components = null;
7 |
8 | ///
9 | /// Clean up any resources being used.
10 | ///
11 | /// true if managed resources should be disposed; otherwise, false.
12 | protected override void Dispose(bool disposing) {
13 | if (disposing && (components != null)) {
14 | components.Dispose();
15 | }
16 | base.Dispose(disposing);
17 | }
18 |
19 | #region Windows Form Designer generated code
20 |
21 | ///
22 | /// Required method for Designer support - do not modify
23 | /// the contents of this method with the code editor.
24 | ///
25 | private void InitializeComponent() {
26 | this.textOutput = new System.Windows.Forms.TextBox();
27 | this.buttonAdd = new System.Windows.Forms.Button();
28 | this.buttonBrowse = new System.Windows.Forms.Button();
29 | this.buttonGo = new System.Windows.Forms.Button();
30 | this.listPackages = new System.Windows.Forms.ListBox();
31 | this.labelOutput = new System.Windows.Forms.Label();
32 | this.labelDirectories = new System.Windows.Forms.Label();
33 | this.buttonRemove = new System.Windows.Forms.Button();
34 | this.backgroundWorker = new System.ComponentModel.BackgroundWorker();
35 | this.buttonClear = new System.Windows.Forms.Button();
36 | this.progressTotal = new System.Windows.Forms.ProgressBar();
37 | this.progressIso = new System.Windows.Forms.ProgressBar();
38 | this.labelIsoProg = new System.Windows.Forms.Label();
39 | this.label1 = new System.Windows.Forms.Label();
40 | this.cbFix = new System.Windows.Forms.CheckBox();
41 | this.buttonAbout = new System.Windows.Forms.Button();
42 | this.textBox1 = new System.Windows.Forms.TextBox();
43 | this.SuspendLayout();
44 | //
45 | // textOutput
46 | //
47 | this.textOutput.Location = new System.Drawing.Point(12, 131);
48 | this.textOutput.Name = "textOutput";
49 | this.textOutput.Size = new System.Drawing.Size(353, 20);
50 | this.textOutput.TabIndex = 1;
51 | this.textOutput.Text = "D:\\";
52 | //
53 | // buttonAdd
54 | //
55 | this.buttonAdd.Location = new System.Drawing.Point(371, 30);
56 | this.buttonAdd.Name = "buttonAdd";
57 | this.buttonAdd.Size = new System.Drawing.Size(75, 23);
58 | this.buttonAdd.TabIndex = 2;
59 | this.buttonAdd.Text = "Add...";
60 | this.buttonAdd.UseVisualStyleBackColor = true;
61 | this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
62 | //
63 | // buttonBrowse
64 | //
65 | this.buttonBrowse.Location = new System.Drawing.Point(371, 129);
66 | this.buttonBrowse.Name = "buttonBrowse";
67 | this.buttonBrowse.Size = new System.Drawing.Size(75, 23);
68 | this.buttonBrowse.TabIndex = 3;
69 | this.buttonBrowse.Text = "Browse...";
70 | this.buttonBrowse.UseVisualStyleBackColor = true;
71 | this.buttonBrowse.Click += new System.EventHandler(this.buttonBrowse_Click);
72 | //
73 | // buttonGo
74 | //
75 | this.buttonGo.Location = new System.Drawing.Point(192, 187);
76 | this.buttonGo.Name = "buttonGo";
77 | this.buttonGo.Size = new System.Drawing.Size(75, 23);
78 | this.buttonGo.TabIndex = 4;
79 | this.buttonGo.Text = "Go!";
80 | this.buttonGo.UseVisualStyleBackColor = true;
81 | this.buttonGo.Click += new System.EventHandler(this.buttonGo_Click);
82 | //
83 | // listPackages
84 | //
85 | this.listPackages.FormattingEnabled = true;
86 | this.listPackages.Location = new System.Drawing.Point(12, 30);
87 | this.listPackages.Name = "listPackages";
88 | this.listPackages.Size = new System.Drawing.Size(353, 82);
89 | this.listPackages.TabIndex = 5;
90 | this.listPackages.SelectedIndexChanged += new System.EventHandler(this.listPackages_SelectedIndexChanged);
91 | //
92 | // labelOutput
93 | //
94 | this.labelOutput.AutoSize = true;
95 | this.labelOutput.Location = new System.Drawing.Point(9, 115);
96 | this.labelOutput.Name = "labelOutput";
97 | this.labelOutput.Size = new System.Drawing.Size(85, 13);
98 | this.labelOutput.TabIndex = 6;
99 | this.labelOutput.Text = "Output directory:";
100 | //
101 | // labelDirectories
102 | //
103 | this.labelDirectories.AutoSize = true;
104 | this.labelDirectories.Location = new System.Drawing.Point(9, 14);
105 | this.labelDirectories.Name = "labelDirectories";
106 | this.labelDirectories.Size = new System.Drawing.Size(80, 13);
107 | this.labelDirectories.TabIndex = 7;
108 | this.labelDirectories.Text = "God packages:";
109 | //
110 | // buttonRemove
111 | //
112 | this.buttonRemove.Enabled = false;
113 | this.buttonRemove.Location = new System.Drawing.Point(371, 59);
114 | this.buttonRemove.Name = "buttonRemove";
115 | this.buttonRemove.Size = new System.Drawing.Size(75, 23);
116 | this.buttonRemove.TabIndex = 8;
117 | this.buttonRemove.Text = "Remove";
118 | this.buttonRemove.UseVisualStyleBackColor = true;
119 | this.buttonRemove.Click += new System.EventHandler(this.buttonRemove_Click);
120 | //
121 | // backgroundWorker
122 | //
123 | this.backgroundWorker.WorkerReportsProgress = true;
124 | this.backgroundWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker_DoWork);
125 | this.backgroundWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker_RunWorkerCompleted);
126 | this.backgroundWorker.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.backgroundWorker_ProgressChanged);
127 | //
128 | // buttonClear
129 | //
130 | this.buttonClear.Location = new System.Drawing.Point(371, 88);
131 | this.buttonClear.Name = "buttonClear";
132 | this.buttonClear.Size = new System.Drawing.Size(75, 23);
133 | this.buttonClear.TabIndex = 9;
134 | this.buttonClear.Text = "Clear";
135 | this.buttonClear.UseVisualStyleBackColor = true;
136 | this.buttonClear.Click += new System.EventHandler(this.buttonClear_Click);
137 | //
138 | // progressTotal
139 | //
140 | this.progressTotal.Location = new System.Drawing.Point(12, 280);
141 | this.progressTotal.Name = "progressTotal";
142 | this.progressTotal.Size = new System.Drawing.Size(434, 23);
143 | this.progressTotal.Step = 1;
144 | this.progressTotal.TabIndex = 10;
145 | //
146 | // progressIso
147 | //
148 | this.progressIso.Location = new System.Drawing.Point(12, 238);
149 | this.progressIso.Name = "progressIso";
150 | this.progressIso.Size = new System.Drawing.Size(434, 23);
151 | this.progressIso.Step = 1;
152 | this.progressIso.TabIndex = 11;
153 | //
154 | // labelIsoProg
155 | //
156 | this.labelIsoProg.AutoSize = true;
157 | this.labelIsoProg.Location = new System.Drawing.Point(9, 222);
158 | this.labelIsoProg.Name = "labelIsoProg";
159 | this.labelIsoProg.Size = new System.Drawing.Size(67, 13);
160 | this.labelIsoProg.TabIndex = 12;
161 | this.labelIsoProg.Text = "Iso progress:";
162 | //
163 | // label1
164 | //
165 | this.label1.AutoSize = true;
166 | this.label1.Location = new System.Drawing.Point(9, 264);
167 | this.label1.Name = "label1";
168 | this.label1.Size = new System.Drawing.Size(77, 13);
169 | this.label1.TabIndex = 13;
170 | this.label1.Text = "Total progress:";
171 | //
172 | // cbFix
173 | //
174 | this.cbFix.AutoSize = true;
175 | this.cbFix.Location = new System.Drawing.Point(12, 157);
176 | this.cbFix.Name = "cbFix";
177 | this.cbFix.Size = new System.Drawing.Size(195, 17);
178 | this.cbFix.TabIndex = 15;
179 | this.cbFix.Text = "Fix \"CreateIsoGood\" broken header";
180 | this.cbFix.UseVisualStyleBackColor = true;
181 | //
182 | // buttonAbout
183 | //
184 | this.buttonAbout.Location = new System.Drawing.Point(417, 212);
185 | this.buttonAbout.Name = "buttonAbout";
186 | this.buttonAbout.Size = new System.Drawing.Size(29, 23);
187 | this.buttonAbout.TabIndex = 16;
188 | this.buttonAbout.Text = "(c)";
189 | this.buttonAbout.UseVisualStyleBackColor = true;
190 | this.buttonAbout.Click += new System.EventHandler(this.buttonAbout_Click);
191 | //
192 | // textBox1
193 | //
194 | this.textBox1.Location = new System.Drawing.Point(12, 309);
195 | this.textBox1.Multiline = true;
196 | this.textBox1.Name = "textBox1";
197 | this.textBox1.Size = new System.Drawing.Size(435, 217);
198 | this.textBox1.TabIndex = 17;
199 | //
200 | // Form1
201 | //
202 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
203 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
204 | this.ClientSize = new System.Drawing.Size(459, 539);
205 | this.Controls.Add(this.textBox1);
206 | this.Controls.Add(this.buttonAbout);
207 | this.Controls.Add(this.cbFix);
208 | this.Controls.Add(this.label1);
209 | this.Controls.Add(this.labelIsoProg);
210 | this.Controls.Add(this.progressIso);
211 | this.Controls.Add(this.progressTotal);
212 | this.Controls.Add(this.buttonClear);
213 | this.Controls.Add(this.buttonRemove);
214 | this.Controls.Add(this.labelDirectories);
215 | this.Controls.Add(this.labelOutput);
216 | this.Controls.Add(this.listPackages);
217 | this.Controls.Add(this.buttonGo);
218 | this.Controls.Add(this.buttonBrowse);
219 | this.Controls.Add(this.buttonAdd);
220 | this.Controls.Add(this.textOutput);
221 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
222 | this.MaximizeBox = false;
223 | this.Name = "Form1";
224 | this.Text = "God2Iso vX.X.X";
225 | this.ResumeLayout(false);
226 | this.PerformLayout();
227 |
228 | }
229 |
230 | #endregion
231 |
232 | private System.Windows.Forms.TextBox textOutput;
233 | private System.Windows.Forms.Button buttonAdd;
234 | private System.Windows.Forms.Button buttonBrowse;
235 | private System.Windows.Forms.Button buttonGo;
236 | private System.Windows.Forms.ListBox listPackages;
237 | private System.Windows.Forms.Label labelOutput;
238 | private System.Windows.Forms.Label labelDirectories;
239 | private System.Windows.Forms.Button buttonRemove;
240 | private System.ComponentModel.BackgroundWorker backgroundWorker;
241 | private System.Windows.Forms.Button buttonClear;
242 | private System.Windows.Forms.ProgressBar progressTotal;
243 | private System.Windows.Forms.ProgressBar progressIso;
244 | private System.Windows.Forms.Label labelIsoProg;
245 | private System.Windows.Forms.Label label1;
246 | private System.Windows.Forms.CheckBox cbFix;
247 | private System.Windows.Forms.Button buttonAbout;
248 | private System.Windows.Forms.TextBox textBox1;
249 | }
250 | }
251 |
252 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright (c) rab - richardaburton@gmail.com
2 |
3 | ### Creative Commons Attribution-ShareAlike 4.0 International Public License
4 |
5 | By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
6 |
7 | **Section 1 – Definitions.**
8 |
9 | 1. **Adapted Material** means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
10 | 2. **Adapter's License** means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
11 | 3. **BY-SA Compatible License** means a license listed at [ creativecommons.org/compatiblelicenses](https://creativecommons.org/compatiblelicenses), approved by Creative Commons as essentially the equivalent of this Public License.
12 | 4. **Copyright and Similar Rights** means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section [2(b)(1)-(2)](https://creativecommons.org/licenses/by-sa/4.0/legalcode#s2b) are not Copyright and Similar Rights.
13 | 5. **Effective Technological Measures** means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
14 | 6. **Exceptions and Limitations** means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
15 | 7. **License Elements** means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution and ShareAlike.
16 | 8. **Licensed Material** means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
17 | 9. **Licensed Rights** means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
18 | 10. **Licensor** means the individual(s) or entity(ies) granting rights under this Public License.
19 | 11. **Share** means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
20 | 12. **Sui Generis Database Rights** means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
21 | 13. **You** means the individual or entity exercising the Licensed Rights under this Public License. **Your** has a corresponding meaning.
22 |
23 | **Section 2 – Scope.**
24 |
25 | 1. License grant
26 |
27 | .
28 |
29 | 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
30 |
31 | 1. reproduce and Share the Licensed Material, in whole or in part; and
32 | 2. produce, reproduce, and Share Adapted Material.
33 |
34 | 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
35 |
36 | 3. Term. The term of this Public License is specified in Section [6(a)](https://creativecommons.org/licenses/by-sa/4.0/legalcode#s6a).
37 |
38 | 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section [2(a)(4)](https://creativecommons.org/licenses/by-sa/4.0/legalcode#s2a4) never produces Adapted Material.
39 |
40 | 5. Downstream recipients
41 |
42 | .
43 |
44 | 1. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
45 | 2. Additional offer from the Licensor – Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply.
46 | 3. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
47 |
48 | 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section [3(a)(1)(A)(i)](https://creativecommons.org/licenses/by-sa/4.0/legalcode#s3a1Ai).
49 |
50 | 2. **Other rights**.
51 |
52 | 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
53 | 2. Patent and trademark rights are not licensed under this Public License.
54 | 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties.
55 |
56 | **Section 3 – License Conditions.**
57 |
58 | Your exercise of the Licensed Rights is expressly made subject to the following conditions.
59 |
60 | 1. **Attribution**.
61 |
62 | 1. If You Share the Licensed Material (including in modified form), You must:
63 | 1. retain the following if it is supplied by the Licensor with the Licensed Material:
64 | 1. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
65 | 2. a copyright notice;
66 | 3. a notice that refers to this Public License;
67 | 4. a notice that refers to the disclaimer of warranties;
68 | 5. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
69 | 2. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
70 | 3. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
71 | 2. You may satisfy the conditions in Section [3(a)(1)](https://creativecommons.org/licenses/by-sa/4.0/legalcode#s3a1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
72 | 3. If requested by the Licensor, You must remove any of the information required by Section [3(a)(1)(A)](https://creativecommons.org/licenses/by-sa/4.0/legalcode#s3a1A) to the extent reasonably practicable.
73 |
74 | 2. ShareAlike
75 |
76 | .
77 |
78 | In addition to the conditions in Section [3(a)](https://creativecommons.org/licenses/by-sa/4.0/legalcode#s3a), if You Share Adapted Material You produce, the following conditions also apply.
79 |
80 | 1. The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License.
81 | 2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
82 | 3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.
83 |
84 | **Section 4 – Sui Generis Database Rights.**
85 |
86 | Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
87 |
88 | 1. for the avoidance of doubt, Section [2(a)(1)](https://creativecommons.org/licenses/by-sa/4.0/legalcode#s2a1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database;
89 | 2. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section [3(b)](https://creativecommons.org/licenses/by-sa/4.0/legalcode#s3b); and
90 | 3. You must comply with the conditions in Section [3(a)](https://creativecommons.org/licenses/by-sa/4.0/legalcode#s3a) if You Share all or a substantial portion of the contents of the database.
91 |
92 | For the avoidance of doubt, this Section [4](https://creativecommons.org/licenses/by-sa/4.0/legalcode#s4) supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
93 |
94 | **Section 5 – Disclaimer of Warranties and Limitation of Liability.**
95 |
96 | 1. **Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.**
97 | 2. **To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.**
98 |
99 | 1. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
100 |
101 | **Section 6 – Term and Termination.**
102 |
103 | 1. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
104 |
105 | 2. Where Your right to use the Licensed Material has terminated under Section [6(a)](https://creativecommons.org/licenses/by-sa/4.0/legalcode#s6a), it reinstates:
106 |
107 | 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
108 | 2. upon express reinstatement by the Licensor.
109 |
110 | For the avoidance of doubt, this Section
111 |
112 | 6(b)
113 |
114 | does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
115 |
116 | 3. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
117 |
118 | 4. Sections [1](https://creativecommons.org/licenses/by-sa/4.0/legalcode#s1), [5](https://creativecommons.org/licenses/by-sa/4.0/legalcode#s5), [6](https://creativecommons.org/licenses/by-sa/4.0/legalcode#s6), [7](https://creativecommons.org/licenses/by-sa/4.0/legalcode#s7), and [8](https://creativecommons.org/licenses/by-sa/4.0/legalcode#s8) survive termination of this Public License.
119 |
120 | **Section 7 – Other Terms and Conditions.**
121 |
122 | 1. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
123 | 2. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
124 |
125 | **Section 8 – Interpretation.**
126 |
127 | 1. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
128 | 2. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
129 | 3. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
130 | 4. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
--------------------------------------------------------------------------------
/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Text;
7 | using System.Windows.Forms;
8 | using System.IO;
9 | using Microsoft.WindowsAPICodePack.Taskbar;
10 | using System.Management;
11 | using System.Reflection;
12 |
13 | namespace God2Iso {
14 |
15 | public partial class Form1 : Form {
16 |
17 | public Form1() {
18 | InitializeComponent();
19 | try {
20 | windowsTaskbar = TaskbarManager.Instance;
21 | } catch (Exception) { }
22 | Text = GetAppName();
23 | }
24 |
25 | private string lastPath = null;
26 | private TaskbarManager windowsTaskbar = null;
27 |
28 | private void buttonAdd_Click(object sender, EventArgs e) {
29 | OpenFileDialog browser = new OpenFileDialog();
30 | browser.CheckFileExists = true;
31 | if (lastPath != null && Directory.Exists(lastPath)) browser.InitialDirectory = lastPath;
32 | if (browser.ShowDialog() == DialogResult.OK) {
33 | string path = Path.Combine(browser.FileName + ".data", "Data0000");
34 | if (listPackages.Items.Contains(browser.FileName)) {
35 | MessageBox.Show("God package already already in the list.", "God2Iso", MessageBoxButtons.OK, MessageBoxIcon.Error);
36 | } else if (File.Exists(path)) {
37 | listPackages.Items.Add(browser.FileName);
38 | lastPath = Path.GetDirectoryName(browser.FileName);
39 | } else {
40 | MessageBox.Show("Could not find associated data file: " + path, "God2Iso", MessageBoxButtons.OK, MessageBoxIcon.Error);
41 | }
42 | }
43 | }
44 |
45 | private void buttonBrowse_Click(object sender, EventArgs e) {
46 | FolderBrowserDialog browser = new FolderBrowserDialog();
47 | browser.ShowNewFolderButton = true;
48 | browser.Description = "Select an output folder for the iso...";
49 | if (Directory.Exists(textOutput.Text)) browser.SelectedPath = textOutput.Text;
50 | if (browser.ShowDialog() == DialogResult.OK) {
51 | textOutput.Text = browser.SelectedPath;
52 | }
53 | }
54 |
55 | private void buttonGo_Click(object sender, EventArgs e) {
56 | try {
57 | if (listPackages.Items.Count < 1) {
58 | MessageBox.Show("No God packages specified.", "God2Iso", MessageBoxButtons.OK, MessageBoxIcon.Error);
59 | return;
60 | }
61 | if (textOutput.Text.Length < 1) {
62 | MessageBox.Show("You must specify an output directory.", "God2Iso", MessageBoxButtons.OK, MessageBoxIcon.Error);
63 | return;
64 | }
65 | if (!Directory.Exists(textOutput.Text)) {
66 | MessageBox.Show("Output directory does not exist.", "God2Iso", MessageBoxButtons.OK, MessageBoxIcon.Error);
67 | return;
68 | }
69 |
70 | progressIso.Value = 0;
71 | progressTotal.Value = 0;
72 | listPackages.SelectedIndex = -1;
73 | buttonAdd.Enabled = false;
74 | buttonGo.Enabled = false;
75 | buttonBrowse.Enabled = false;
76 | buttonClear.Enabled = false;
77 | listPackages.Enabled = false;
78 | textOutput.Enabled = false;
79 | cbFix.Enabled = false;
80 |
81 | // calculate total number & size of files
82 | int totalFiles = 0;
83 | ulong totalSize = 0;
84 | for (int i = 0; i < listPackages.Items.Count; i++) {
85 | int count = 0;
86 | while (true) {
87 | string path = Path.Combine(((string)listPackages.Items[i]) + ".data", "Data" + count.ToString("D4"));
88 | if (!File.Exists(path)) break;
89 | count++;
90 | FileInfo info = new FileInfo(path);
91 | totalSize += (ulong)info.Length;
92 | }
93 | totalFiles += count;
94 | }
95 |
96 | try {
97 | ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"" + textOutput.Text.Substring(0, 1) + ":\"");
98 | disk.Get();
99 | ulong freeSpace = (ulong)disk["FreeSpace"];
100 | if (totalSize > freeSpace) {
101 | MessageBox.Show("Not enough free space in output directory - need approximately " + FormatSize(totalSize) + '.', "God2Iso", MessageBoxButtons.OK, MessageBoxIcon.Error);
102 | // reset buttons
103 | backgroundWorker_RunWorkerCompleted(null, null);
104 | return;
105 | }
106 | } catch (Exception) { }
107 |
108 | progressTotal.Maximum = totalFiles;
109 | if (windowsTaskbar != null) windowsTaskbar.SetProgressState(TaskbarProgressBarState.Normal);
110 | backgroundWorker.RunWorkerAsync();
111 | } catch (Exception ex) {
112 | textBox1.Text = ex.Message + Environment.NewLine + ex.StackTrace;
113 | }
114 | }
115 |
116 | private string FormatSize(ulong byteCount) {
117 | string size;
118 | if (byteCount >= 1073741824) {
119 | size = String.Format("{0:##.##}", byteCount / 1073741824.0) + " gb";
120 | } else if (byteCount >= 1048576) {
121 | size = String.Format("{0:##.##}", byteCount / 1048576.0) + " mb";
122 | } else if (byteCount >= 1024) {
123 | size = String.Format("{0:##.##}", byteCount / 1024.0) + " kb";
124 | } else {
125 | size = byteCount + " b";
126 | }
127 | return size;
128 | }
129 |
130 | private void listPackages_SelectedIndexChanged(object sender, EventArgs e) {
131 | buttonRemove.Enabled = listPackages.SelectedIndex >= 0;
132 | }
133 |
134 | private void buttonRemove_Click(object sender, EventArgs e) {
135 | int selected = listPackages.SelectedIndex;
136 | if (selected < listPackages.Items.Count - 1) {
137 | listPackages.SelectedIndex = selected + 1;
138 | } else if (listPackages.Items.Count > 1) {
139 | listPackages.SelectedIndex = selected - 1;
140 | }
141 | listPackages.Items.RemoveAt(selected);
142 | }
143 |
144 | private bool HasXSFHeader(string file) {
145 | byte[] buff = new byte[3];
146 |
147 | FileStream data = new FileStream(file, FileMode.Open, FileAccess.Read);
148 | data.Position = 0x2000;
149 | data.Read(buff, 0, buff.Length);
150 | data.Close();
151 |
152 | if (buff[0] != 0x58) return false;
153 | if (buff[1] != 0x53) return false;
154 | if (buff[2] != 0x46) return false;
155 |
156 | return true;
157 | }
158 |
159 | private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) {
160 |
161 | BackgroundWorker worker = sender as BackgroundWorker;
162 |
163 | for (int i = 0; i < listPackages.Items.Count; i++) {
164 |
165 | FileStream iso = null;
166 | FileStream data = null;
167 |
168 | try {
169 |
170 | string baseName = Path.GetFileName((string)listPackages.Items[i]);
171 | string dataPath = (string)listPackages.Items[i] + ".data";
172 |
173 | // count files
174 | int totalFiles;
175 | for (totalFiles = 0; true; totalFiles++) {
176 | string path = Path.Combine(dataPath, "Data" + totalFiles.ToString("D4"));
177 | if (!File.Exists(path)) break;
178 | }
179 | if (totalFiles < 1) return;
180 |
181 | // check for xsf header
182 | bool hasXSF = HasXSFHeader(Path.Combine(dataPath, "Data0000"));
183 |
184 | // open new iso file
185 | iso = new FileStream(Path.Combine(textOutput.Text, baseName + ".iso"), FileMode.Create, FileAccess.ReadWrite);
186 |
187 | // add header, if needed
188 | if (!hasXSF) iso.Write(Properties.Resources.XSFHeader, 0, Properties.Resources.XSFHeader.Length); ;
189 |
190 | // loop through data parts
191 | for (int fileNum = 0; fileNum < totalFiles; fileNum++) {
192 | string path = Path.Combine(dataPath, "Data" + fileNum.ToString("D4"));
193 | data = new FileStream(path, FileMode.Open, FileAccess.Read);
194 | data.Position = 0x2000;
195 | int len = 0;
196 | while (true) {
197 | byte[] buff = new byte[0xcc000];
198 | len = data.Read(buff, 0, buff.Length);
199 | iso.Write(buff, 0, len);
200 | if (len < 0xcc000) break;
201 | len = data.Read(buff, 0, 0x1000);
202 | if (len < 0x1000) break;
203 | }
204 | data.Close();
205 | data = null;
206 | worker.ReportProgress(0, new MyState(fileNum + 1, totalFiles));
207 | }
208 |
209 | if (!hasXSF) {
210 | FixXFSHeader(iso);
211 | FixSectorOffsets(iso, (string)listPackages.Items[i]);
212 | }
213 | if (cbFix.Checked) FixCreateIsoGoodHeader(iso);
214 |
215 | } catch (Exception ex) {
216 | MessageBox.Show(ex.Message, "God2Iso", MessageBoxButtons.OK, MessageBoxIcon.Error);
217 | } finally {
218 | if (iso != null) try { iso.Close(); } catch (Exception) { }
219 | if (data != null) try { data.Close(); } catch (Exception) { }
220 | }
221 | }
222 | }
223 |
224 | private void FixSectorOffsets(FileStream iso, string godPath) {
225 |
226 | int sector, size, offset;
227 | byte[] buffer;
228 | Queue directories = new Queue();
229 |
230 | buffer = File.ReadAllBytes(godPath);
231 | // offset type?
232 | if ((buffer[0x391] & 0x40) != 0x40) return;
233 | // calculate the offset
234 | offset = BitConverter.ToInt32(buffer, 0x395);
235 | if (offset == 0) return;
236 | offset *= 2;
237 | offset -= 34;
238 |
239 | buffer = new byte[4];
240 | iso.Position = 0x10014;
241 | iso.Read(buffer, 0, 4);
242 | sector = BitConverter.ToInt32(buffer, 0);
243 | if (sector > 0) {
244 | sector -= offset;
245 | byte[] corrected = BitConverter.GetBytes(sector);
246 | iso.Position -= 4;
247 | iso.Write(corrected, 0, 4);
248 | iso.Read(buffer, 0, 4);
249 | size = BitConverter.ToInt32(buffer, 0);
250 | directories.Enqueue(new DirEntry(sector, size));
251 | }
252 |
253 | while (directories.Count > 0) {
254 |
255 | DirEntry dirEntry = directories.Dequeue();
256 | iso.Position = dirEntry.StartPos();
257 |
258 | while ((iso.Position + 4) < dirEntry.EndPos()) {
259 | // crossed a sector boundary?
260 | if ((iso.Position + 4) / 2048L > iso.Position / 2048L) {
261 | iso.Position += 2048L - (iso.Position % 2048L);
262 | }
263 | // read subtrees
264 | iso.Read(buffer, 0, 4);
265 | if (buffer[0] == 0xff && buffer[1] == 0xff && buffer[2] == 0xff && buffer[3] == 0xff) {
266 | // another sector to process?
267 | if (dirEntry.EndPos() - iso.Position > 2048) {
268 | iso.Position += 2048L - (iso.Position % 2048L);
269 | continue;
270 | }
271 | break;
272 | }
273 |
274 | // read sector
275 | iso.Read(buffer, 0, 4);
276 | sector = BitConverter.ToInt32(buffer, 0);
277 | if (sector > 0) {
278 | sector -= offset;
279 | byte[] corrected = BitConverter.GetBytes(sector);
280 | iso.Position -= 4;
281 | iso.Write(corrected, 0, 4);
282 | }
283 |
284 | // get size
285 | iso.Read(buffer, 0, 4);
286 | size = BitConverter.ToInt32(buffer, 0);
287 |
288 | // get attributes
289 | iso.Read(buffer, 0, 1);
290 |
291 | // if directory add to list of tables to process
292 | if ((buffer[0] & 0x10) == 0x10) directories.Enqueue(new DirEntry(sector, size));
293 |
294 | // get filename length
295 | iso.Read(buffer, 0, 1);
296 | // skip it
297 | iso.Position += buffer[0];
298 |
299 | // skip padding
300 | if ((14 + buffer[0]) % 4 > 0) iso.Position += 4 - ((14 + buffer[0]) % 4);
301 | }
302 | }
303 | }
304 |
305 | private void FixCreateIsoGoodHeader(FileStream iso) {
306 | byte[] bytes = new byte[8];
307 | iso.Position = 8;
308 | iso.Read(bytes, 0, 8);
309 | if (BitConverter.ToInt64(bytes, 0) == 2587648L) {
310 | iso.Position = 0;
311 | iso.Write(Properties.Resources.XSFHeader, 0, Properties.Resources.XSFHeader.Length);
312 | FixXFSHeader(iso);
313 | }
314 | }
315 |
316 | private void FixXFSHeader(FileStream iso) {
317 | byte[] bytes;
318 |
319 | iso.Position = 8;
320 | bytes = BitConverter.GetBytes(iso.Length - 0x400);
321 | iso.Write(bytes, 0, bytes.Length);
322 |
323 | iso.Position = 0x8050;
324 | bytes = BitConverter.GetBytes((uint)(iso.Length / 2048));
325 | iso.Write(bytes, 0, bytes.Length);
326 | for (int i = bytes.Length - 1; i >= 0; i--) {
327 | iso.WriteByte(bytes[i]);
328 | }
329 |
330 | iso.Position = 0x7a69;
331 | bytes = Encoding.ASCII.GetBytes(GetAppName());
332 | iso.Write(bytes, 0, bytes.Length);
333 | }
334 |
335 | private string GetAppName() {
336 | string s = "God2Iso v" + Assembly.GetExecutingAssembly().GetName().Version.ToString();
337 | return s.Substring(0, s.Length - 2);
338 | }
339 |
340 | private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
341 | if (windowsTaskbar != null) windowsTaskbar.SetProgressState(TaskbarProgressBarState.NoProgress);
342 | buttonAdd.Enabled = true;
343 | buttonGo.Enabled = true;
344 | buttonBrowse.Enabled = true;
345 | buttonClear.Enabled = true;
346 | listPackages.Enabled = true;
347 | textOutput.Enabled = true;
348 | cbFix.Enabled = true;
349 | }
350 |
351 | private void buttonClear_Click(object sender, EventArgs e) {
352 | listPackages.SelectedIndex = -1;
353 | listPackages.Items.Clear();
354 | }
355 |
356 | private void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) {
357 | MyState state = (MyState)e.UserState;
358 | progressIso.Value = state.file;
359 | progressIso.Maximum = state.files;
360 | progressTotal.PerformStep();
361 | if (windowsTaskbar != null) windowsTaskbar.SetProgressValue(progressTotal.Value, progressTotal.Maximum);
362 | }
363 |
364 | private class MyState {
365 | public int file;
366 | public int files;
367 | public MyState(int file, int files) {
368 | this.file = file;
369 | this.files = files;
370 | }
371 | }
372 |
373 | private class DirEntry {
374 | public int sector;
375 | public int length;
376 | public DirEntry(int sector, int length) {
377 | this.sector = sector;
378 | this.length = length;
379 | }
380 | public long StartPos() {
381 | return sector * 2048L;
382 | }
383 | public long EndPos() {
384 | return (sector * 2048L) + length;
385 | }
386 | }
387 |
388 | private void buttonAbout_Click(object sender, EventArgs e) {
389 | MessageBox.Show("Copyright (c) 2010-2021 richardaburton@gmail.com" + Environment.NewLine
390 | + "This program is licensed under https://creativecommons.org/licenses/by-sa/4.0/" + Environment.NewLine
391 | + "Find this project on Github: https://github.com/raburton/god2iso/" + Environment.NewLine
392 | , "God2Iso", MessageBoxButtons.OK, MessageBoxIcon.Information);
393 | }
394 |
395 | }
396 |
397 | }
398 |
--------------------------------------------------------------------------------