mirror of
https://github.com/claunia/libexeinfo.git
synced 2025-12-16 19:14:24 +00:00
Do not fill NE resources if there are no entries in resource table.
This commit is contained in:
@@ -62,47 +62,50 @@ namespace exeinfo
|
|||||||
{
|
{
|
||||||
recognized = true;
|
recognized = true;
|
||||||
Console.Write(neExe.GetInfo());
|
Console.Write(neExe.GetInfo());
|
||||||
foreach (NE.Version vers in neExe.Versions)
|
if (neExe.Versions != null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("\tVersion resource {0}:", vers.Name);
|
foreach (NE.Version vers in neExe.Versions)
|
||||||
Console.WriteLine("\t\tFile version: {0}", vers.FileVersion);
|
|
||||||
Console.WriteLine("\t\tProduct version: {0}", vers.ProductVersion);
|
|
||||||
Console.WriteLine("\t\tFile type: {0}", NE.Version.TypeToString(vers.FileType));
|
|
||||||
if (vers.FileType == NE.VersionFileType.VFT_DRV)
|
|
||||||
Console.WriteLine("\t\tFile subtype: {0} driver", NE.Version.DriverToString(vers.FileSubtype));
|
|
||||||
else if (vers.FileType == NE.VersionFileType.VFT_DRV)
|
|
||||||
Console.WriteLine("\t\tFile subtype: {0} font", NE.Version.FontToString(vers.FileSubtype));
|
|
||||||
else if (vers.FileSubtype > 0)
|
|
||||||
Console.WriteLine("\t\tFile subtype: {0}", (uint)vers.FileSubtype);
|
|
||||||
Console.WriteLine("\t\tFile flags: {0}", vers.FileFlags);
|
|
||||||
Console.WriteLine("\t\tFile OS: {0}", NE.Version.OsToString(vers.FileOS));
|
|
||||||
|
|
||||||
foreach (KeyValuePair<string, Dictionary<string, string>> strByLang in vers.StringsByLanguage)
|
|
||||||
{
|
{
|
||||||
string cultureName;
|
Console.WriteLine("\tVersion resource {0}:", vers.Name);
|
||||||
string encodingName;
|
Console.WriteLine("\t\tFile version: {0}", vers.FileVersion);
|
||||||
|
Console.WriteLine("\t\tProduct version: {0}", vers.ProductVersion);
|
||||||
|
Console.WriteLine("\t\tFile type: {0}", NE.Version.TypeToString(vers.FileType));
|
||||||
|
if (vers.FileType == NE.VersionFileType.VFT_DRV)
|
||||||
|
Console.WriteLine("\t\tFile subtype: {0} driver", NE.Version.DriverToString(vers.FileSubtype));
|
||||||
|
else if (vers.FileType == NE.VersionFileType.VFT_DRV)
|
||||||
|
Console.WriteLine("\t\tFile subtype: {0} font", NE.Version.FontToString(vers.FileSubtype));
|
||||||
|
else if (vers.FileSubtype > 0)
|
||||||
|
Console.WriteLine("\t\tFile subtype: {0}", (uint)vers.FileSubtype);
|
||||||
|
Console.WriteLine("\t\tFile flags: {0}", vers.FileFlags);
|
||||||
|
Console.WriteLine("\t\tFile OS: {0}", NE.Version.OsToString(vers.FileOS));
|
||||||
|
|
||||||
try
|
foreach (KeyValuePair<string, Dictionary<string, string>> strByLang in vers.StringsByLanguage)
|
||||||
{
|
{
|
||||||
cultureName = new CultureInfo(Convert.ToInt32(strByLang.Key.Substring(0, 4), 16)).DisplayName;
|
string cultureName;
|
||||||
}
|
string encodingName;
|
||||||
catch
|
|
||||||
{
|
|
||||||
cultureName = string.Format("unsupported culture 0x{0:X4}", Convert.ToInt32(strByLang.Key.Substring(0, 4), 16));
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
encodingName = Encoding.GetEncoding(Convert.ToInt32(strByLang.Key.Substring(4), 16)).EncodingName;
|
cultureName = new CultureInfo(Convert.ToInt32(strByLang.Key.Substring(0, 4), 16)).DisplayName;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
encodingName = string.Format("unsupported encoding 0x{0:X4}", Convert.ToInt32(strByLang.Key.Substring(4), 16));
|
cultureName = string.Format("unsupported culture 0x{0:X4}", Convert.ToInt32(strByLang.Key.Substring(0, 4), 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("\t\tStrings for {0} in codepage {1}:", cultureName, encodingName);
|
try
|
||||||
foreach (KeyValuePair<string, string> strings in strByLang.Value)
|
{
|
||||||
Console.WriteLine("\t\t\t{0}: {1}", strings.Key, strings.Value);
|
encodingName = Encoding.GetEncoding(Convert.ToInt32(strByLang.Key.Substring(4), 16)).EncodingName;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
encodingName = string.Format("unsupported encoding 0x{0:X4}", Convert.ToInt32(strByLang.Key.Substring(4), 16));
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("\t\tStrings for {0} in codepage {1}:", cultureName, encodingName);
|
||||||
|
foreach (KeyValuePair<string, string> strings in strByLang.Value)
|
||||||
|
Console.WriteLine("\t\t\t{0}: {1}", strings.Key, strings.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,6 +206,7 @@ namespace libexeinfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
types.Add(type);
|
types.Add(type);
|
||||||
|
System.Console.WriteLine("{0}", stream.Position);
|
||||||
}
|
}
|
||||||
|
|
||||||
table.types = types.ToArray();
|
table.types = types.ToArray();
|
||||||
|
|||||||
@@ -70,9 +70,15 @@ namespace libexeinfo
|
|||||||
Marshal.Copy(buffer, 0, hdrPtr, buffer.Length);
|
Marshal.Copy(buffer, 0, hdrPtr, buffer.Length);
|
||||||
Header = (NEHeader)Marshal.PtrToStructure(hdrPtr, typeof(NEHeader));
|
Header = (NEHeader)Marshal.PtrToStructure(hdrPtr, typeof(NEHeader));
|
||||||
Marshal.FreeHGlobal(hdrPtr);
|
Marshal.FreeHGlobal(hdrPtr);
|
||||||
IsNE = Header.signature == Signature;
|
if(Header.signature == Signature)
|
||||||
Resources = GetResources(BaseStream, BaseExecutable.Header.new_offset, Header.resource_table_offset);
|
{
|
||||||
Versions = GetVersions().ToArray();
|
IsNE = true;
|
||||||
|
if (Header.resource_entries > 0)
|
||||||
|
{
|
||||||
|
Resources = GetResources(BaseStream, BaseExecutable.Header.new_offset, Header.resource_table_offset);
|
||||||
|
Versions = GetVersions().ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,9 +103,15 @@ namespace libexeinfo
|
|||||||
Marshal.Copy(buffer, 0, hdrPtr, buffer.Length);
|
Marshal.Copy(buffer, 0, hdrPtr, buffer.Length);
|
||||||
Header = (NEHeader)Marshal.PtrToStructure(hdrPtr, typeof(NEHeader));
|
Header = (NEHeader)Marshal.PtrToStructure(hdrPtr, typeof(NEHeader));
|
||||||
Marshal.FreeHGlobal(hdrPtr);
|
Marshal.FreeHGlobal(hdrPtr);
|
||||||
IsNE = Header.signature == Signature;
|
if (Header.signature == Signature)
|
||||||
Resources = GetResources(BaseStream, BaseExecutable.Header.new_offset, Header.resource_table_offset);
|
{
|
||||||
Versions = GetVersions().ToArray();
|
IsNE = true;
|
||||||
|
if (Header.resource_entries > 0)
|
||||||
|
{
|
||||||
|
Resources = GetResources(BaseStream, BaseExecutable.Header.new_offset, Header.resource_table_offset);
|
||||||
|
Versions = GetVersions().ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
<Description>Library to get information about executable files.</Description>
|
<Description>Library to get information about executable files.</Description>
|
||||||
<PackageProjectUrl>https://github.com/claunia/libexeinfo</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/claunia/libexeinfo</PackageProjectUrl>
|
||||||
<ReleaseVersion>0.2</ReleaseVersion>
|
<ReleaseVersion>0.2</ReleaseVersion>
|
||||||
|
<PackageTags>executable MZ NE exe</PackageTags>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
|||||||
Reference in New Issue
Block a user