mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-29 23:22:32 +00:00
Merge remote-tracking branch 'udb/master'
This commit is contained in:
commit
841467cf9b
5 changed files with 114 additions and 41 deletions
|
@ -247,6 +247,7 @@
|
||||||
<Compile Include="Dehacked\DehackedFrame.cs" />
|
<Compile Include="Dehacked\DehackedFrame.cs" />
|
||||||
<Compile Include="Dehacked\DehackedParser.cs" />
|
<Compile Include="Dehacked\DehackedParser.cs" />
|
||||||
<Compile Include="Dehacked\DehackedThing.cs" />
|
<Compile Include="Dehacked\DehackedThing.cs" />
|
||||||
|
<Compile Include="General\Hasher.cs" />
|
||||||
<Compile Include="General\SHA256Hash.cs" />
|
<Compile Include="General\SHA256Hash.cs" />
|
||||||
<Compile Include="General\ToastManager.cs" />
|
<Compile Include="General\ToastManager.cs" />
|
||||||
<Compile Include="Properties\Resources.Designer.cs">
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
|
|
|
@ -239,6 +239,7 @@
|
||||||
<Compile Include="Data\FileImage.cs" />
|
<Compile Include="Data\FileImage.cs" />
|
||||||
<Compile Include="Data\FlatImage.cs" />
|
<Compile Include="Data\FlatImage.cs" />
|
||||||
<Compile Include="Data\ImageLoadState.cs" />
|
<Compile Include="Data\ImageLoadState.cs" />
|
||||||
|
<Compile Include="General\Hasher.cs" />
|
||||||
<Compile Include="General\SHA256Hash.cs" />
|
<Compile Include="General\SHA256Hash.cs" />
|
||||||
<Compile Include="General\ToastManager.cs" />
|
<Compile Include="General\ToastManager.cs" />
|
||||||
<Compile Include="Properties\Resources.Designer.cs">
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
|
|
|
@ -88,8 +88,8 @@ namespace CodeImp.DoomBuilder
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
static public FileLockCheckResult CheckFile(string path)
|
static public FileLockCheckResult CheckFile(string path)
|
||||||
{
|
{
|
||||||
//mxd. Do it the clunky way? (WinXP)
|
//mxd. Do it the clunky way? (non-Windows)
|
||||||
if(Environment.OSVersion.Version.Major < 6)
|
if(Environment.OSVersion.Platform == PlatformID.Unix)
|
||||||
{
|
{
|
||||||
bool locked = false;
|
bool locked = false;
|
||||||
|
|
||||||
|
|
45
Source/Core/General/Hasher.cs
Normal file
45
Source/Core/General/Hasher.cs
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace CodeImp.DoomBuilder
|
||||||
|
{
|
||||||
|
public static class Hasher<T> where T : HashAlgorithm
|
||||||
|
{
|
||||||
|
// We have to do it this ugly way because we can't directly call the method from the type and the "Create" method is overloaded
|
||||||
|
private static T hasher = (T)typeof(T).GetMethods().SingleOrDefault(m => m.Name == "Create" && m.GetParameters().Length == 0).Invoke(null, null);
|
||||||
|
|
||||||
|
public static string Get(Stream stream)
|
||||||
|
{
|
||||||
|
// Rewind the stream
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
// Check hash
|
||||||
|
byte[] data = hasher.ComputeHash(stream);
|
||||||
|
|
||||||
|
// Rewind the stream again...
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
// Create a new Stringbuilder to collect the bytes and create a string.
|
||||||
|
StringBuilder hash = new StringBuilder();
|
||||||
|
|
||||||
|
// Loop through each byte of the hashed data and format each one as a hexadecimal string.
|
||||||
|
for (int i = 0; i < data.Length; i++) hash.Append(data[i].ToString("x2"));
|
||||||
|
|
||||||
|
return hash.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Computes the MD5 hash of a string.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">The string to compute the MD5 hash of</param>
|
||||||
|
/// <returns>The MD5 hash as a string</returns>
|
||||||
|
public static string Get(string input)
|
||||||
|
{
|
||||||
|
byte[] bytes = hasher.ComputeHash(Encoding.ASCII.GetBytes(input));
|
||||||
|
return string.Concat(Array.ConvertAll(bytes, x => x.ToString("x2")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,6 +20,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -36,51 +37,75 @@ namespace CodeImp.DoomBuilder.IO
|
||||||
// Encoder
|
// Encoder
|
||||||
public static readonly Encoding ENCODING = Encoding.ASCII;
|
public static readonly Encoding ENCODING = Encoding.ASCII;
|
||||||
|
|
||||||
//mxd. Official IWAD MD5 hashes
|
//mxd. Official IWAD SHA1 hashes
|
||||||
|
// Source of hashes: https://github.com/Doom-Utils/iwad-patches
|
||||||
private static readonly HashSet<string> IWAD_HASHES = new HashSet<string>
|
private static readonly HashSet<string> IWAD_HASHES = new HashSet<string>
|
||||||
{
|
{
|
||||||
////// DOOM IWADS //////
|
// Doom 1
|
||||||
"d9153ced9fd5b898b36cc5844e35b520", // DOOM2 1.666g MD5
|
"df0040ccb29cc1622e74ceb3b7793a2304cca2c8", // Doom 1.1
|
||||||
"30e3c2d0350b67bfbf47271970b74b2f", // DOOM2 1.666 MD5
|
"b5f86a559642a2b3bdfb8a75e91c8da97f057fe6", // Doom 1.2
|
||||||
"ea74a47a791fdef2e9f2ea8b8a9da13b", // DOOM2 1.7 MD5
|
"2e89b86859acd9fc1e552f587b710751efcffa8e", // Doom 1.666
|
||||||
"d7a07e5d3f4625074312bc299d7ed33f", // DOOM2 1.7a MD5
|
"2c8212631b37f21ad06d18b5638c733a75e179ff", // Doom 1.8
|
||||||
"c236745bb01d89bbb866c8fed81b6f8c", // DOOM2 1.8 MD5
|
"7742089b4468a736cadb659a7deca3320fe6dcbd", // Doom 1.9
|
||||||
"25e1459ca71d321525f84628f45ca8cd", // DOOM2 1.9 MD5
|
"e5ec79505530e151ff0e6f517f3ce1fd65969c46", // Doom Bfg
|
||||||
"3cb02349b3df649c86290907eed64e7b", // DOOM2 French MD5
|
"a89b39d91122882214c3088b8cd6b308713bd7c2", // Doom Ppc
|
||||||
"c3bea40570c23e511a7ed3ebcd9865f7", // BFG DOOM2 MD5
|
"117015379c529573510be08cf59810aa10bb934e", // Doom Psn
|
||||||
|
"f770111ca9eb6d49aead51fcbd398719b462e64b", // Doom Unity 1.0
|
||||||
|
"08ab2507e1d525c4c06b6df4f6d5862568a6b009", // Doom Unity 1.1
|
||||||
|
"2a8a1ce0f29497a2781b2902c76115fd60d8bbf8", // Doom Unity 1.3
|
||||||
|
"9b07b02ab3c275a6a7570c3f73cc20d63a0e3833", // Doom Ud
|
||||||
|
"37de4510216eb3ce9a835dd939109443375d10c5", // Doom Xbla
|
||||||
|
"1d1d4f69fe14fa255228d8243470678b1b4efdc5", // Doom Xbox
|
||||||
|
|
||||||
"981b03e6d1dc033301aa3095acc437ce", // DOOM 1.1 MD5
|
// Doom 2
|
||||||
"792fd1fea023d61210857089a7c1e351", // DOOM 1.2 MD5
|
"a4ce5128d57cb129fdd1441c12b58245be55c8ce", // Doom2 1.666g
|
||||||
"464e3723a7e7f97039ac9fd057096adb", // DOOM 1.6b MD5
|
"6d559b7ceece4f5ad457415049711992370d520a", // Doom2 1.666
|
||||||
"54978d12de87f162b9bcc011676cb3c0", // DOOM 1.666 MD5
|
"70192b8d5aba65c7e633a7c7bcfe7e3e90640c97", // Doom2 1.7a
|
||||||
"11e1cd216801ea2657723abc86ecb01f", // DOOM 1.8 MD5
|
"78009057420b792eacff482021db6fe13b370dcc", // Doom2 1.7
|
||||||
"1cd63c5ddff1bf8ce844237f580e9cf3", // DOOM 1.9 MD5
|
"79c283b18e61b9a989cfd3e0f19a42ea98fda551", // Doom2 1.8
|
||||||
"fb35c4a5a9fd49ec29ab6e900572c524", // BFG DOOM MD5
|
"d510c877031bbd5f3d198581a2c8651e09b9861f", // Doom2 1.8f
|
||||||
|
"7ec7652fcfce8ddc6e801839291f0e28ef1d5ae7", // Doom2 1.9
|
||||||
|
"a59548125f59f6aa1a41c22f615557d3dd2e85a9", // Doom2 Bfg
|
||||||
|
"f1b6ba94352d53f646b67c01d2da88c5c40e3179", // Doom2 Psn Eur
|
||||||
|
"ca8db908a7c9fbac764f34c148f0bcc78d18553e", // Doom2 Psn Usa
|
||||||
|
"9b39107b5bcfd1f989bcfe46f68dbc1f49222922", // Doom2 Unity 1.0
|
||||||
|
"b723882122e90b61a1d92a11dcfcf9cbf95a407e", // Doom2 Unity 1.1
|
||||||
|
"9574851209c9dfbede56db0dee0660ecd51e6150", // Doom2 Unity 1.3
|
||||||
|
"55e445badd63d8841ebea887910c26c62c7f525e", // Doom2 Xbla
|
||||||
|
"1c91d86cd8a2f3817227986503a6672a5e1613f0", // Doom2 Xbox
|
||||||
|
"b7ba1c68631023ea1aab1d7b9f7f6e9afc508f39", // Doom2 Xbox360bfg
|
||||||
|
"2cda310805397ae44059bbcaed3cd602f4864a82", // Doom2 Zodiac
|
||||||
|
|
||||||
"c4fe9fd920207691a9f493668e0a2083", // ULTIMATE DOOM MD5
|
// Plutonia
|
||||||
|
"90361e2a538d2388506657252ae41aceeb1ba360", // Plutonia 1.9
|
||||||
|
"f131cbe1946d7fddb3caec4aa258c83399c21e60", // Plutonia Anthology
|
||||||
|
"85c3517434135a5886111b324955f9288c01046c", // Plutonia Psn Eur
|
||||||
|
"327f8c41ebd4138354e9fca63cebbbd1b9489749", // Plutonia Psn Usa
|
||||||
|
"54e27b5791fbc5677bf7e83c1de3a92ea3ef935b", // Plutonia Unity 1.0
|
||||||
|
"20fd23ee410c466b263a741bbd53bbef573ab47d", // Plutonia Unity 1.3
|
||||||
|
|
||||||
"75c8cf89566741fa9d22447604053bd7", // PLUTONIA MD5
|
// TNT
|
||||||
"3493be7e1e2588bc9c8b31eab2587a04", // PLUTONIA RARE MD5
|
"9fbc66aedef7fe3bae0986cdb9323d2b8db4c9d3", // Tnt 1.9
|
||||||
|
"4a65c8b960225505187c36040b41a40b152f8f3e", // Tnt Anthology
|
||||||
|
"5066833da047117241cdda05a708b009eb266c91", // Tnt Psn Eur
|
||||||
|
"139e26d801a64b404b8d898defca10227a61867b", // Tnt Psn Usa
|
||||||
|
"503271390606ebded04a2cfaa1a4e249c0313a9d", // Tnt Unity 1.0
|
||||||
|
"ca0f0495a6c2813b49620202774c56560d6d7621", // Tnt Unity 1.3
|
||||||
|
|
||||||
"4e158d9953c79ccf97bd0663244cc6b6", // TNT MD5
|
// Heretic
|
||||||
"1d39e405bf6ee3df69a8d2646c8d5c49", // TNT Fixed MD5
|
"b5a6cc79cde48d97905b44282e82c4c966a23a87", // Heretic 1.0
|
||||||
"be626c12b7c9d94b1dfb9c327566b4ff", // PSN TNT MD5
|
"a54c5d30629976a649119c5ce8babae2ddfb1a60", // Heretic 1.2
|
||||||
|
"f489d479371df32f6d280a0cb23b59a35ba2b833", // Heretic 1.3
|
||||||
|
|
||||||
////// HERETIC IWADS //////
|
// Hexen
|
||||||
"3117e399cdb4298eaa3941625f4b2923", // HERETIC 1.0 MD5
|
"ae797f5fdce845be24a7a24dd5bfc3e762a17bbe", // Hexen Beta
|
||||||
"1e4cb4ef075ad344dd63971637307e04", // HERETIC 1.2 MD5
|
"ac129c4331bf26f0f080c4a56aaa40d64969c98a", // Hexen 1.0
|
||||||
"66d686b1ed6d35ff103f15dbd30e0341", // HERETIC 1.3 MD5
|
"4b53832f0733c1e29e5f1de2428e5475e891af29", // Hexen 1.1
|
||||||
|
"4343fbe5aef905ef6d077a1517a50c919e5cc906", // Hexen Mac
|
||||||
|
|
||||||
////// HEXEN IWADS //////
|
// Strife
|
||||||
"c88a2bb3d783e2ad7b599a8e301e099e", // HEXEN Beta MD5
|
"eb0f3e157b35c34d5a598701f775e789ec85b4ae", // Strife1 1.1
|
||||||
"b2543a03521365261d0a0f74d5dd90f0", // HEXEN 1.0 MD5
|
"64c13b951a845ca7f8081f68138a6181557458d1", // Strife1 1.2
|
||||||
"abb033caf81e26f12a2103e1fa25453f", // HEXEN 1.1 MD5
|
|
||||||
"1077432e2690d390c256ac908b5f4efa", // HEXEN DK 1.0 MD5
|
|
||||||
"78d5898e99e220e4de64edaa0e479593", // HEXEN DK 1.1 MD5
|
|
||||||
|
|
||||||
////// STRIFE IWADS //////
|
|
||||||
"8f2d3a6a289f5d2f2f9c1eec02b47299", // STRIFE 1.0 MD5
|
|
||||||
"2fed2031a5b03892106e0f117f17901f", // STRIFE 1.2 MD5
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -334,8 +359,9 @@ namespace CodeImp.DoomBuilder.IO
|
||||||
{
|
{
|
||||||
// Rewind
|
// Rewind
|
||||||
r.BaseStream.Position = 0;
|
r.BaseStream.Position = 0;
|
||||||
isofficialiwad = IWAD_HASHES.Contains(MD5Hash.Get(r.BaseStream));
|
//isofficialiwad = IWAD_HASHES.Contains(MD5Hash.Get(r.BaseStream));
|
||||||
if(!isreadonly && isofficialiwad) isreadonly = true;
|
isofficialiwad = IWAD_HASHES.Contains(Hasher<SHA1>.Get(r.BaseStream));
|
||||||
|
if (!isreadonly && isofficialiwad) isreadonly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the reader
|
// Close the reader
|
||||||
|
|
Loading…
Reference in a new issue