mirror of
https://github.com/PredatH0r/ChanSort.git
synced 2026-05-07 06:16:41 +02:00
- added support for a Hisense HIS_SVL.BIN variant with different data layout (LTDN50K220)
- upgrade to DevExpress 23.1 - incomplete TechniSat support
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{A5C22199-1C51-4265-89CA-A7183F1BDB8B}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ChanSort.Loader.TechniSat</RootNamespace>
|
||||
<AssemblyName>ChanSort.Loader.TechniSat</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="TechniSatCrypt.cs" />
|
||||
<Compile Include="TechniSatPlugin.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TechniSatSerializer.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ChanSort.Api\ChanSort.Api.csproj">
|
||||
<Project>{dccffa08-472b-4d17-bb90-8f513fc01392}</Project>
|
||||
<Name>ChanSort.Api</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
36
source/ChanSort.Loader.TechniSat/Properties/AssemblyInfo.cs
Normal file
36
source/ChanSort.Loader.TechniSat/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ChanSort.Loader.TechniSat")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ChanSort.Loader.TechniSat")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("a5c22199-1c51-4265-89ca-a7183f1bdb8b")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
100
source/ChanSort.Loader.TechniSat/TechniSatCrypt.cs
Normal file
100
source/ChanSort.Loader.TechniSat/TechniSatCrypt.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace ChanSort.Loader.TechniSat;
|
||||
|
||||
internal class TechniSatCrypt
|
||||
{
|
||||
internal static readonly Encoding Encoding = Encoding.GetEncoding(1252);
|
||||
|
||||
private const uint InitSeed = 0xAC15FF4B;
|
||||
private const uint Polynomial = 0x80000062;
|
||||
|
||||
#region Decrypt()
|
||||
public static string CdpDecrypt(byte[] data)
|
||||
{
|
||||
uint state = InitSeed;
|
||||
|
||||
var sb = new StringBuilder(data.Length);
|
||||
foreach (var b in data)
|
||||
{
|
||||
var o = 0;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
if ((state & 0x01) != 0)
|
||||
{
|
||||
state = (state ^ Polynomial) >> 1 | 0x80000000;
|
||||
o ^= 1 << i;
|
||||
}
|
||||
else
|
||||
state >>= 1;
|
||||
}
|
||||
|
||||
o ^= b;
|
||||
if (o == 0)
|
||||
state = InitSeed;
|
||||
|
||||
sb.Append((char)o);
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Encrypt()
|
||||
public static byte[] CdpEncrypt(string text)
|
||||
{
|
||||
uint state = InitSeed;
|
||||
|
||||
var strm = new MemoryStream(text.Length);
|
||||
foreach (var b in Encoding.GetBytes(text))
|
||||
{
|
||||
var o = 0;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
if ((state & 0x01) != 0)
|
||||
{
|
||||
state = (state ^ Polynomial) >> 1 | 0x80000000;
|
||||
o ^= 1 << i;
|
||||
}
|
||||
else
|
||||
state >>= 1;
|
||||
}
|
||||
|
||||
strm.WriteByte((byte)(o ^ b));
|
||||
|
||||
if (b == 0)
|
||||
state = InitSeed;
|
||||
}
|
||||
|
||||
var data = new byte[strm.Length];
|
||||
Array.Copy(strm.GetBuffer(), data, strm.Length);
|
||||
return data;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#if false
|
||||
static void Main()
|
||||
{
|
||||
var file = @"C:\Sources\ChanSort\TestFiles\TestFiles_Div\TechniSat\thenicnic\database.cdp";
|
||||
var original = File.ReadAllBytes(file);
|
||||
|
||||
var decrypted = CdpDecrypt(original);
|
||||
File.WriteAllText($"{file}.txt", decrypted.Replace("\0", ""), encoding);
|
||||
|
||||
var reencrypted = CdpEncrypt(decrypted);
|
||||
File.WriteAllBytes($"{file}.enc", reencrypted);
|
||||
|
||||
// validate that decrypt + encrypt produces the original data
|
||||
if (reencrypted.Length != original.Length)
|
||||
throw new Exception("Incorrect file length");
|
||||
for (int i = 0; i < original.Length; i++)
|
||||
{
|
||||
if (reencrypted[i] != original[i])
|
||||
throw new Exception("Data corrupted at index " + i);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
15
source/ChanSort.Loader.TechniSat/TechniSatPlugin.cs
Normal file
15
source/ChanSort.Loader.TechniSat/TechniSatPlugin.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using ChanSort.Api;
|
||||
|
||||
namespace ChanSort.Loader.TechniSat;
|
||||
|
||||
public class TechniSatPlugin : ISerializerPlugin
|
||||
{
|
||||
public string DllName { get; set; }
|
||||
public string PluginName => "TechniSat";
|
||||
public string FileFilter => "*.cdp;*.csv";
|
||||
|
||||
public SerializerBase CreateSerializer(string inputFile)
|
||||
{
|
||||
return new TechniSatSerializer(inputFile);
|
||||
}
|
||||
}
|
||||
44
source/ChanSort.Loader.TechniSat/TechniSatSerializer.cs
Normal file
44
source/ChanSort.Loader.TechniSat/TechniSatSerializer.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ChanSort.Api;
|
||||
|
||||
namespace ChanSort.Loader.TechniSat;
|
||||
|
||||
internal class TechniSatSerializer : SerializerBase
|
||||
{
|
||||
private string decryptedFilePath;
|
||||
|
||||
public TechniSatSerializer(string inputFile) : base(inputFile)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
decryptedFilePath = Path.GetExtension(this.FileName).ToLowerInvariant() == ".cdp" ? DecryptFile(this.FileName) : this.FileName;
|
||||
|
||||
var lines = File.ReadAllLines(decryptedFilePath);
|
||||
foreach (var line in lines)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private string DecryptFile(string inputFile)
|
||||
{
|
||||
var data = File.ReadAllBytes(inputFile);
|
||||
var decrypted = TechniSatCrypt.CdpDecrypt(data);
|
||||
var csvPath = Path.Combine(Path.GetDirectoryName(inputFile), Path.GetFileNameWithoutExtension(inputFile)) + ".csv";
|
||||
File.WriteAllText(csvPath, decrypted.Replace("\0", ""), TechniSatCrypt.Encoding);
|
||||
return csvPath;
|
||||
}
|
||||
|
||||
public override void Save()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user