Do not fill NE resources if there are no entries in resource table.

This commit is contained in:
2017-10-16 17:25:08 +01:00
parent d99421901c
commit 2241458e7e
4 changed files with 58 additions and 41 deletions

View File

@@ -62,6 +62,8 @@ namespace exeinfo
{
recognized = true;
Console.Write(neExe.GetInfo());
if (neExe.Versions != null)
{
foreach (NE.Version vers in neExe.Versions)
{
Console.WriteLine("\tVersion resource {0}:", vers.Name);
@@ -106,6 +108,7 @@ namespace exeinfo
}
}
}
}
if (!recognized)
Console.WriteLine("Executable format not recognized");

View File

@@ -206,6 +206,7 @@ namespace libexeinfo
}
types.Add(type);
System.Console.WriteLine("{0}", stream.Position);
}
table.types = types.ToArray();

View File

@@ -70,12 +70,18 @@ namespace libexeinfo
Marshal.Copy(buffer, 0, hdrPtr, buffer.Length);
Header = (NEHeader)Marshal.PtrToStructure(hdrPtr, typeof(NEHeader));
Marshal.FreeHGlobal(hdrPtr);
IsNE = Header.signature == Signature;
if(Header.signature == Signature)
{
IsNE = true;
if (Header.resource_entries > 0)
{
Resources = GetResources(BaseStream, BaseExecutable.Header.new_offset, Header.resource_table_offset);
Versions = GetVersions().ToArray();
}
}
}
}
}
/// <summary>
/// Initializes a new instance of the <see cref="T:libexeinfo.NE"/> class.
@@ -97,12 +103,18 @@ namespace libexeinfo
Marshal.Copy(buffer, 0, hdrPtr, buffer.Length);
Header = (NEHeader)Marshal.PtrToStructure(hdrPtr, typeof(NEHeader));
Marshal.FreeHGlobal(hdrPtr);
IsNE = Header.signature == Signature;
if (Header.signature == Signature)
{
IsNE = true;
if (Header.resource_entries > 0)
{
Resources = GetResources(BaseStream, BaseExecutable.Header.new_offset, Header.resource_table_offset);
Versions = GetVersions().ToArray();
}
}
}
}
}
/// <summary>
/// Identifies if the specified executable is a Microsoft New Executable

View File

@@ -19,6 +19,7 @@
<Description>Library to get information about executable files.</Description>
<PackageProjectUrl>https://github.com/claunia/libexeinfo</PackageProjectUrl>
<ReleaseVersion>0.2</ReleaseVersion>
<PackageTags>executable MZ NE exe</PackageTags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>