static public bool DataMatch(Resource x32Res, Resource x64Res) { if ((x32Res == null) || (x64Res == null)) { return(false); } if (x32Res == x64Res) { return(true); } if (!ResourceHeader.DataMatch(x32Res.Header, x64Res.Header)) { return(false); } if ((x32Res.RawData == null) || (x64Res.RawData == null)) { return(false); } if (x32Res.RawData.Length != x64Res.RawData.Length) { return(false); } for (var ctr = 0; ctr < x32Res.RawData.Length; ++ctr) { if (x32Res.RawData[ctr] != x64Res.RawData[ctr]) { return(false); } } return(true); }
public static Resource CreateFromHeader(ResourceHeader header) { var data = ResourceReader.GetBinary(header.ResourceID); var rawData = data; if (encryptionKey != null) { try { using (var alg = new AesCryptoServiceProvider { Key = encryptionKey }) { var iv = new byte[BitConverter.ToInt32(rawData, 0)]; Array.Copy(rawData, sizeof(int), iv, 0, iv.Length); alg.IV = iv; using (var decryptor = alg.CreateDecryptor()) rawData = decryptor.TransformFinalBlock(rawData, sizeof(int) + iv.Length, rawData.Length - sizeof(int) - iv.Length); } } catch { throw new Exception("Failed to decrypt; password invalid."); } } using (var ms = new MemoryStream()) { using (var gz = new GZipStream(new MemoryStream(rawData), CompressionMode.Decompress)) gz.CopyTo(ms); rawData = ms.ToArray(); } return(new Resource { Header = header, Data = data, RawData = rawData, }); }
static public bool DataMatch(ResourceHeader x32Res, ResourceHeader x64Res) { if ((x32Res == null) || (x64Res == null)) { return(false); } if (x32Res == x64Res) { return(true); } if (x32Res.FileType != x64Res.FileType) { return(false); } if (x32Res.SHA1 != x64Res.SHA1) { return(false); } return(true); }
public static Config FromBytes(byte[] data) { using (var ms = new MemoryStream(data)) using (var reader = new BinaryReader(ms, Encoding.UTF8, true)) { var config = new Config(); config.X32Start = reader.ReadString(); config.X64Start = reader.ReadString(); config.CanExtract = reader.ReadBoolean(); config.NGen = reader.ReadBoolean(); config.Password = reader.ReadBoolean() ? "prompt" : null; config.ResourceHeaders.Clear(); var resourceHeaderCount = reader.ReadInt32(); for (var ctr = 0; ctr < resourceHeaderCount; ++ctr) { config.ResourceHeaders.Add(ResourceHeader.FromBytes(reader.ReadBytes(reader.ReadInt32()))); } return(config); } }