Skip to content

Commit 9e48368

Browse files
committed
Fix "FileProtection" callback, add InnoSetup
The InnoSetup placeholder here will eventually be a way to call to an external library to extract the contents of the installer, similar to how CAB files are handled right now. The code to o so need sto be converted before that can happen, so in the meantime, this adds Inno Steup itself as a "protection" since other protections could be hidden within.
1 parent e0d0722 commit 9e48368

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

BurnOutSharp/ProtectionFind.cs

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ public static class ProtectionFind
5252
/// - The Bongle (http://web.archive.org/web/19990508193708/www.hideseek.com/products.htm)
5353
/// - The Copy-Protected CD (http://web.archive.org/web/19990508193708/www.hideseek.com/products.htm)
5454
/// </remarks>
55-
public static Dictionary<string, string> Scan(string path, IProgress<Progress> progress = null)
55+
public static Dictionary<string, string> Scan(string path, IProgress<FileProtection> progress = null)
5656
{
5757
var protections = new Dictionary<string, string>();
5858

5959
// Checkpoint
60-
progress?.Report(new Progress(null, 0, null));
60+
progress?.Report(new FileProtection(null, 0, null));
6161

6262
// Create mappings for checking against
6363
var mappings = CreateFilenameProtectionMapping();
@@ -79,7 +79,7 @@ public static Dictionary<string, string> Scan(string path, IProgress<Progress> p
7979
protections[path] = protectionname;
8080

8181
// Checkpoint
82-
progress?.Report(new Progress(path, 1, protectionname));
82+
progress?.Report(new FileProtection(path, 1, protectionname));
8383
}
8484
// If we have a directory
8585
else if (Directory.Exists(path))
@@ -127,7 +127,7 @@ public static Dictionary<string, string> Scan(string path, IProgress<Progress> p
127127
protections[file] = protectionname;
128128

129129
// Checkpoint
130-
progress?.Report(new Progress(file, i / files.Length, protectionname));
130+
progress?.Report(new FileProtection(file, i / files.Length, protectionname));
131131
}
132132
}
133133

@@ -193,6 +193,13 @@ private static string ScanInFile(string file)
193193
+ (char)0x00 + "I" + (char)0x00 + "O" + (char)0x00 + "N"))
194194
return "Impulse Reactor " + GetFileVersion(file);
195195

196+
// Inno Setup
197+
if ((position = FileContent.IndexOf("Inno")) == 0x30)
198+
{
199+
// TOOO: Add Inno Setup extraction
200+
return "Inno Setup " + GetInnoSetupVersion(file);
201+
}
202+
196203
// JoWooD X-Prot
197204
if (FileContent.Contains(".ext ")
198205
&& (position = FileContent.IndexOf("kernel32.dll" + (char)0x00 + (char)0x00 + (char)0x00 + "VirtualProtect")) > -1)
@@ -738,6 +745,30 @@ private static string GetCDDVDCopsVersion(string file, int position)
738745
return new string(version);
739746
}
740747

748+
private static string GetInnoSetupVersion(string file)
749+
{
750+
BinaryReader br = new BinaryReader(new StreamReader(file).BaseStream);
751+
br.BaseStream.Seek(0x30, SeekOrigin.Begin);
752+
string signature = new String(br.ReadChars(12));
753+
754+
if (signature == "rDlPtS02" + (char)0x87 + "eVx")
755+
return "1.2.10";
756+
else if (signature == "rDlPtS04" + (char)0x87 + "eVx")
757+
return "4.0.0";
758+
else if (signature == "rDlPtS05" + (char)0x87 + "eVx")
759+
return "4.0.3";
760+
else if (signature == "rDlPtS06" + (char)0x87 + "eVx")
761+
return "4.0.10";
762+
else if (signature == "rDlPtS07" + (char)0x87 + "eVx")
763+
return "4.1.6";
764+
else if (signature == "rDlPtS" + (char)0xcd + (char)0xe6 + (char)0xd7 + "{" + (char)0x0b + "*")
765+
return "5.1.5";
766+
else if (signature == "nS5W7dT" + (char)0x83 + (char)0xaa + (char)0x1b + (char)0x0f + "j")
767+
return "5.1.5";
768+
769+
return string.Empty;
770+
}
771+
741772
private static string GetJoWooDXProt1Version(string file, int position)
742773
{
743774
char[] version = new char[5];

0 commit comments

Comments
 (0)