diff --git a/InfoIcDump/Dumper.cs b/InfoIcDump/Dumper.cs index 6a374cf..747ca08 100644 --- a/InfoIcDump/Dumper.cs +++ b/InfoIcDump/Dumper.cs @@ -22,14 +22,14 @@ private struct Options { public bool DumpInfoic; public bool DumpInfoic2; - public bool DumpInfoicT76; + public bool DumpInfoic76; public bool TL866; public bool T48; public bool T56; public bool T76; public string InfoicPath; public string Infoic2Path; - public string InfoicT76Path; + public string Infoic76Path; public string ConfigsPath; public string OutPath; public bool Memory; @@ -48,7 +48,7 @@ private struct Options private readonly SortedDictionary config_csv_list; private readonly Infoic infoic; - public Dumper(string InfoicPath, string Infoic2Path, string InfoicT76Path, string ConfigsPath) + public Dumper(string InfoicPath, string Infoic2Path, string Infoic76Path, string ConfigsPath) { // Open the configs.csv file config_csv_list = []; @@ -75,7 +75,7 @@ public Dumper(string InfoicPath, string Infoic2Path, string InfoicT76Path, strin Console.WriteLine("configs.csv not found."); } - infoic = new(InfoicPath, Infoic2Path, InfoicT76Path); + infoic = new(InfoicPath, Infoic2Path, Infoic76Path); } @@ -85,19 +85,19 @@ private static void PrintUsage() "InfoIc Dumper usage:" + Environment.NewLine + "--infoic-path Specify infoic.dll path" + Environment.NewLine + "--infoic2-path Specify infoic2plus.dll path" + Environment.NewLine + - "--infoicT76-path Specify infoicT76.dll path" + Environment.NewLine + + "--infoic76-path Specify infoic76.dll path" + Environment.NewLine + "--configs-path Specify configs.csv file path" + Environment.NewLine + "--output-dir Specify the dump output directory" + Environment.NewLine + "--keep-duplicates Don't remove duplicates" + Environment.NewLine + "--no-sorting Don't sort devices by type" + Environment.NewLine + "--no-group Don't group devices" + Environment.NewLine + "--no-infoic Don't dump infoic.dll" + Environment.NewLine + - "--no-infoic2 Don't dump infoic2plus.dll" + Environment.NewLine + - "--no-infoict76 Don't dump infoicT76.dll" + Environment.NewLine + + "--no--infoic2 Don't dump infoic76.dll" + Environment.NewLine + + "--no--infoic76 Don't dump infoic2plus.dll" + Environment.NewLine + "--no-tl866 Don't dump TL866II+ entries" + Environment.NewLine + - "--no-t48 Don't dump T48 entries" + Environment.NewLine + - "--no-t56 Don't dump T56 entries" + Environment.NewLine + - "--no-t76 Don't dump T76 entries" + Environment.NewLine + + "--no-T48 Don't dump T48 entries" + Environment.NewLine + + "--no-T56 Don't dump T56 entries" + Environment.NewLine + + "--no-T76 Don't dump T76 entries" + Environment.NewLine + "--no-memory Don't dump EPROM/EEPROM/FLASH devices" + Environment.NewLine + "--no-mcu Don't dump MCU/MPU devices" + Environment.NewLine + "--no-pld Don't dump PLD/CPLD devices" + Environment.NewLine + @@ -126,8 +126,8 @@ private static bool ParseArgs(string[] args, ref Options options) options.DumpInfoic2 = false; break; - case "--no-infoict76": - options.DumpInfoicT76 = false; + case "--no-infoic76": + options.DumpInfoic76 = false; break; case "--no-tl866": @@ -204,11 +204,11 @@ private static bool ParseArgs(string[] args, ref Options options) } return false; - case "--infoicT76-path": + case "--infoic76-path": if (i + 1 < args.Length) { i++; - options.InfoicT76Path = args[i]; + options.Infoic76Path = args[i]; continue; } return false; @@ -255,10 +255,10 @@ static int Main(string[] args) { DumpInfoic = true, DumpInfoic2 = true, - DumpInfoicT76 = true, + DumpInfoic76 = true, InfoicPath = StartupPath + "InfoIC.dll", Infoic2Path = StartupPath + "InfoIC2Plus.dll", - InfoicT76Path = StartupPath + "InfoICT76.dll", + Infoic76Path = StartupPath + "InfoICT76.dll", ConfigsPath = StartupPath + "configs.csv", OutPath = StartupPath + "output" + Path.DirectorySeparatorChar, TL866 = true, @@ -293,7 +293,7 @@ static int Main(string[] args) return -1; } - if (!options.DumpInfoic && !options.DumpInfoic2 && !options.DumpInfoicT76) + if (!options.DumpInfoic && !options.DumpInfoic2 && !options.DumpInfoic76) { Console.WriteLine("Nothing to dump."); return -1; @@ -301,9 +301,9 @@ static int Main(string[] args) if (!options.DumpInfoic) { options.InfoicPath = string.Empty; } if (!options.DumpInfoic2) { options.Infoic2Path = string.Empty; } - if (!options.DumpInfoicT76) { options.InfoicT76Path = string.Empty; } + if (!options.DumpInfoic76) { options.Infoic76Path = string.Empty; } - Dumper dumper = new(options.InfoicPath, options.Infoic2Path, options.InfoicT76Path, options.ConfigsPath); + Dumper dumper = new(options.InfoicPath, options.Infoic2Path, options.Infoic76Path, options.ConfigsPath); return (dumper.BeginDump(ref options)); } @@ -334,19 +334,19 @@ private int BeginDump(ref Options options) } } - if (options.DumpInfoicT76) + if (options.DumpInfoic76) { - if (options.DumpInfoicT76 && infoic.InfoIcT76Loaded) + if (options.DumpInfoic76 && infoic.InfoIc76Loaded) { - Console.WriteLine("InfoIcT76.dll loaded. Total devices:{0}", infoic.InfoIcT76NumDevices); + Console.WriteLine("InfoIc76.dll loaded. Total devices:{0}", infoic.InfoIc76NumDevices); } else { - Console.WriteLine("InfoIcT76.dll not found."); + Console.WriteLine("InfoIc76.dll not found."); } } - if (!infoic.InfoIcLoaded && !infoic.InfoIc2Loaded && !infoic.InfoIcT76Loaded) + if (!infoic.InfoIcLoaded && !infoic.InfoIc2Loaded && !infoic.InfoIc76Loaded) { Console.WriteLine("{0}No modules to dump, the program will exit now.", Environment.NewLine); return -1; @@ -378,17 +378,17 @@ private int BeginDump(ref Options options) // Create the root xml XElement xml_root = new("infoic"); - // Dump the infoicT76.dll - if (infoic.InfoIcT76Loaded && options.DumpInfoicT76) + // Dump the infoic76.dll + if (infoic.InfoIc76Loaded && options.DumpInfoic76) { filter = []; total = []; device_count = 0; - XElement[] elements = DumpDatabase(ref options, DB_TYPE.INFOICT76, ref filter, ref total, ref device_count); + XElement[] elements = DumpDatabase(ref options, DB_TYPE.INFOIC76, ref filter, ref total, ref device_count); XElement database = new("database"); - database.Add(new XAttribute("type", "INFOICT76"), elements); + database.Add(new XAttribute("type", "INFOIC76"), elements); xml_root.Add(database); - if (!WriteLogs(options.OutPath, filter, "filterT76.txt", total, "logT76.txt", device_count)) { return -1; } + if (!WriteLogs(options.OutPath, filter, "filter76.txt", total, "log76.txt", device_count)) { return -1; } } // Dump the infoic2plus.dll @@ -535,8 +535,8 @@ private bool CompareDevice(DevStruct d1, DevStruct d2) } else { - db_name = "InfoIcT76.dll"; - num_mfc = infoic.InfoIcT76Manufacturers; + db_name = "InfoIc76.dll"; + num_mfc = infoic.InfoIc76Manufacturers; } Console.WriteLine("{0}{1} dump started.", Environment.NewLine, db_name); @@ -560,14 +560,8 @@ private bool CompareDevice(DevStruct d1, DevStruct d2) (Devstruct.Category == (uint)CHIP_TYPE.SRAM && !options.Sram) || (Devstruct.Category == (uint)CHIP_TYPE.NAND && !options.Nand) || (Devstruct.Category == (uint)CHIP_TYPE.EMMC && !options.Emmc) || - (Devstruct.Category == (uint)CHIP_TYPE.VGA && !options.Vga) || - ((Devstruct.Opts8 & PROG_MASK) == TL866II_FLAG && !options.TL866) || - ((Devstruct.Opts8 & PROG_MASK) == T48_FLAG && !options.T48) || - ((Devstruct.Opts8 & PROG_MASK) == T56_FLAG && !options.T56) || - ((Devstruct.Opts8 & PROG_MASK) == T76_FLAG && !options.T76)){ - Console.WriteLine("{0} removed.{1}", Devstruct.Name, Environment.NewLine); - continue; - } + (Devstruct.Category == (uint)CHIP_TYPE.VGA && !options.Vga)) + continue; //Remove spaces and bad characters Devstruct.Name = Devstruct.Name.Replace(" ", "").Replace(",", ";"). diff --git a/InfoIcDump/Infoic.cs b/InfoIcDump/Infoic.cs index 160c010..9117e3a 100644 --- a/InfoIcDump/Infoic.cs +++ b/InfoIcDump/Infoic.cs @@ -14,11 +14,11 @@ internal class Infoic public static extern IntPtr GetProcAddress(IntPtr module, string proc); // Function pointers delegates - private delegate void DGetMfcStruT76(uint manufacturer, ref MfcStruct mfstruct); - private delegate void DGetIcStruT76(uint manufacturer, uint device_index, ref InfoIc2Struct devstruct); - private delegate uint DGetIcMFCT76(string search, uint[] manufacturer_array, uint type, uint mask); - private delegate uint DGetIcListT76(string search, uint[] ic_array, uint manufacturer, uint type, uint mask); - private delegate uint DGetDllInfoT76(ref uint dll_version, ref uint num_mfcs, uint version); + private delegate void DGetMfcStru76(uint manufacturer, ref MfcStruct mfstruct); + private delegate void DGetIcStru76(uint manufacturer, uint device_index, ref InfoIc2Struct devstruct); + private delegate uint DGetIcMFC76(string search, uint[] manufacturer_array, uint type, uint mask); + private delegate uint DGetIcList76(string search, uint[] ic_array, uint manufacturer, uint type, uint mask); + private delegate uint DGetDllInfo76(ref uint dll_version, ref uint num_mfcs, uint version); private delegate void DGetMfcStru2(uint manufacturer, ref MfcStruct mfstruct); private delegate void DGetIcStru2(uint manufacturer, uint device_index, ref InfoIc2Struct devstruct); @@ -44,11 +44,11 @@ internal class Infoic private readonly DGetIcList2? GetIcList2; private readonly DGetDllInfo2? GetDllInfo2; - private readonly DGetMfcStruT76? GetMfcStructT76; - private readonly DGetIcStruT76? GetIcStructT76; - private readonly DGetIcMFCT76? GetIcMFCT76; - private readonly DGetIcListT76? GetIcListT76; - private readonly DGetDllInfoT76? GetDllInfoT76; + private readonly DGetMfcStru76? GetMfcStruct76; + private readonly DGetIcStru76? GetIcStruct76; + private readonly DGetIcMFC76? GetIcMFC76; + private readonly DGetIcList76? GetIcList76; + private readonly DGetDllInfo76? GetDllInfo76; public struct DevStruct @@ -144,40 +144,37 @@ private struct MfcStruct public uint Count; } - public static readonly uint T56_FLAG = 0x10000000; - public static readonly uint TL866II_FLAG = 0x20000000; - public static readonly uint T48_FLAG = 0x40000000; - public static readonly uint T76_FLAG = 0x80000000; - public static readonly uint PROG_MASK = T56_FLAG | TL866II_FLAG | T48_FLAG | T76_FLAG; - + public static readonly uint T56_MASK = 0x10000000; + public static readonly uint T48_MASK = 0x40000000; + public static readonly uint TL866II_MASK = 0x20000000; public static readonly uint SMT_FLAG = 0x80000000; public static readonly uint PLCC_FLAG = 0x40000000; public static readonly uint ERASE_FLAG = 0x20; public enum CHIP_TYPE : uint { MEMORY = 1, MPU, PLD, SRAM, LOGIC, NAND, EMMC, VGA } - public enum DB_TYPE { INFOIC, INFOIC2, INFOICT76 } + public enum DB_TYPE { INFOIC, INFOIC2, INFOIC76 } private readonly IntPtr HInfoIc = IntPtr.Zero; private readonly IntPtr HInfoIc2 = IntPtr.Zero; - private readonly IntPtr HInfoIcT76 = IntPtr.Zero; + private readonly IntPtr HInfoIc76 = IntPtr.Zero; private readonly uint InfoicDeviceCount; private readonly uint Infoic2DeviceCount; - private readonly uint InfoicT76DeviceCount; + private readonly uint Infoic76DeviceCount; private readonly uint InfoicManufCount; private readonly uint Infoic2ManufCount; - private readonly uint InfoicT76ManufCount; + private readonly uint Infoic76ManufCount; public bool InfoIcLoaded { get => HInfoIc != IntPtr.Zero; } public bool InfoIc2Loaded { get => HInfoIc2 != IntPtr.Zero; } - public bool InfoIcT76Loaded { get => HInfoIcT76 != IntPtr.Zero; } + public bool InfoIc76Loaded { get => HInfoIc76 != IntPtr.Zero; } public uint InfoIcNumDevices { get => InfoicDeviceCount; } public uint InfoIc2NumDevices { get => Infoic2DeviceCount; } - public uint InfoIcT76NumDevices { get => InfoicT76DeviceCount; } + public uint InfoIc76NumDevices { get => Infoic76DeviceCount; } public uint InfoIcManufacturers { get => InfoicManufCount; } public uint InfoIc2Manufacturers { get => Infoic2ManufCount; } - public uint InfoIcT76Manufacturers { get => InfoicT76ManufCount; } + public uint InfoIc76Manufacturers { get => Infoic76ManufCount; } private static IntPtr GetProc(ref IntPtr handle, string name) @@ -192,12 +189,12 @@ private static IntPtr GetProc(ref IntPtr handle, string name) } // Class constructor - public Infoic(string InfoicPath, string Infoic2Path, string InfoicT76Path) + public Infoic(string InfoicPath, string Infoic2Path, string Infoic76Path) { // Try to load modules if (InfoicPath != string.Empty) { HInfoIc = LoadLibrary(InfoicPath); } if (Infoic2Path != string.Empty) { HInfoIc2 = LoadLibrary(Infoic2Path); } - if (InfoicT76Path != string.Empty) { HInfoIcT76 = LoadLibrary(InfoicT76Path); } + if (Infoic76Path != string.Empty) { HInfoIc76 = LoadLibrary(Infoic76Path); } IntPtr ProcAddress; @@ -261,33 +258,33 @@ public Infoic(string InfoicPath, string Infoic2Path, string InfoicT76Path) } } - if (HInfoIcT76 != IntPtr.Zero) + if (HInfoIc76 != IntPtr.Zero) { - ProcAddress = GetProc(ref HInfoIcT76, "GetMfcStru"); + ProcAddress = GetProc(ref HInfoIc76, "GetMfcStru"); if (ProcAddress == IntPtr.Zero) { return; } - GetMfcStructT76 = (DGetMfcStruT76)Marshal.GetDelegateForFunctionPointer(ProcAddress, typeof(DGetMfcStruT76)); + GetMfcStruct76 = (DGetMfcStru76)Marshal.GetDelegateForFunctionPointer(ProcAddress, typeof(DGetMfcStru76)); - ProcAddress = GetProc(ref HInfoIcT76, "GetIcStru"); + ProcAddress = GetProc(ref HInfoIc76, "GetIcStru"); if (ProcAddress == IntPtr.Zero) { return; } - GetIcStructT76 = (DGetIcStruT76)Marshal.GetDelegateForFunctionPointer(ProcAddress, typeof(DGetIcStruT76)); + GetIcStruct76 = (DGetIcStru76)Marshal.GetDelegateForFunctionPointer(ProcAddress, typeof(DGetIcStru76)); - ProcAddress = GetProc(ref HInfoIcT76, "GetIcMFC"); + ProcAddress = GetProc(ref HInfoIc76, "GetIcMFC"); if (ProcAddress == IntPtr.Zero) { return; } - GetIcMFCT76 = (DGetIcMFCT76)Marshal.GetDelegateForFunctionPointer(ProcAddress, typeof(DGetIcMFCT76)); + GetIcMFC76 = (DGetIcMFC76)Marshal.GetDelegateForFunctionPointer(ProcAddress, typeof(DGetIcMFC76)); - ProcAddress = GetProc(ref HInfoIcT76, "GetIcList"); + ProcAddress = GetProc(ref HInfoIc76, "GetIcList"); if (ProcAddress == IntPtr.Zero) { return; } - GetIcListT76 = (DGetIcListT76)Marshal.GetDelegateForFunctionPointer(ProcAddress, typeof(DGetIcListT76)); + GetIcList76 = (DGetIcList76)Marshal.GetDelegateForFunctionPointer(ProcAddress, typeof(DGetIcList76)); - ProcAddress = GetProc(ref HInfoIcT76, "GetDllInfo"); + ProcAddress = GetProc(ref HInfoIc76, "GetDllInfo"); if (ProcAddress == IntPtr.Zero) { return; } - GetDllInfoT76 = (DGetDllInfoT76)Marshal.GetDelegateForFunctionPointer(ProcAddress, typeof(DGetDllInfoT76)); + GetDllInfo76 = (DGetDllInfo76)Marshal.GetDelegateForFunctionPointer(ProcAddress, typeof(DGetDllInfo76)); - InfoicT76DeviceCount = GetDeviceCount(ref InfoicT76ManufCount, DB_TYPE.INFOICT76); - if (InfoicT76DeviceCount == 0) + Infoic76DeviceCount = GetDeviceCount(ref Infoic76ManufCount, DB_TYPE.INFOIC76); + if (Infoic76DeviceCount == 0) { - FreeLibrary(HInfoIcT76); - HInfoIcT76 = IntPtr.Zero; + FreeLibrary(HInfoIc76); + HInfoIc76 = IntPtr.Zero; } } } @@ -310,9 +307,9 @@ private void GetMfc(uint manufacturer, ref MfcStruct mfcstruct, DB_TYPE type) } else { - if (GetMfcStructT76 is not null) + if (GetMfcStruct76 is not null) { - GetMfcStructT76(manufacturer, ref mfcstruct); + GetMfcStruct76(manufacturer, ref mfcstruct); } } @@ -391,10 +388,10 @@ public DevStruct GetDevice(uint manufacturer, uint index, DB_TYPE type) } else { - if (GetIcStructT76 is null) { return devstruct; } + if (GetIcStruct76 is null) { return devstruct; } InfoIc2Struct device = new(); device.Name = string.Empty; - GetIcStructT76(manufacturer, index, ref device); + GetIcStruct76(manufacturer, index, ref device); devstruct.ProtocolId = device.ProtocolId; devstruct.Opts8 = device.Opts8; devstruct.Category = device.Category; @@ -447,8 +444,8 @@ private uint GetDeviceCount(ref uint manuf_count, DB_TYPE type) } else { - if (GetDllInfoT76 is null) { return 0; } - GetDllInfoT76(ref dll_version, ref manuf_count, 0); + if (GetDllInfo76 is null) { return 0; } + GetDllInfo76(ref dll_version, ref manuf_count, 0); if (manuf_count < 170) { return 0; } } @@ -467,10 +464,10 @@ private uint GetDeviceCount(ref uint manuf_count, DB_TYPE type) if (GetMfcStruct2 is null) { return 0; } GetMfcStruct2(i, ref mfcstruct); } - else if (type == DB_TYPE.INFOICT76) + else if (type == DB_TYPE.INFOIC76) { - if (GetMfcStructT76 is null) { return 0; } - GetMfcStructT76(i, ref mfcstruct); + if (GetMfcStruct76 is null) { return 0; } + GetMfcStruct76(i, ref mfcstruct); } count += mfcstruct.Count; } diff --git a/InfoIcDump/InfoicDump.exe b/InfoIcDump/InfoicDump.exe old mode 100644 new mode 100755 index 14d9739..bf0b449 Binary files a/InfoIcDump/InfoicDump.exe and b/InfoIcDump/InfoicDump.exe differ