mirror of
https://github.com/claunia/libexeinfo.git
synced 2025-12-16 19:14:24 +00:00
Make NE non-static.
This commit is contained in:
@@ -36,11 +36,9 @@ namespace exeinfo
|
||||
{
|
||||
class MainClass
|
||||
{
|
||||
static libexeinfo.NE.Header neHdr;
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
if(args.Length != 1)
|
||||
if (args.Length != 1)
|
||||
{
|
||||
Console.WriteLine("exeinfo version 0.1 © 2017 Natalia Portillo");
|
||||
Console.WriteLine("Usage: exeinfo file.exe");
|
||||
@@ -52,83 +50,65 @@ namespace exeinfo
|
||||
bool recognized = false;
|
||||
|
||||
MZ mzExe = new MZ(exeFs);
|
||||
NE neExe = new NE(exeFs);
|
||||
|
||||
if(mzExe.IsMZ)
|
||||
if (mzExe.IsMZ)
|
||||
{
|
||||
recognized = true;
|
||||
Console.Write(mzExe.GetInfo());
|
||||
}
|
||||
|
||||
if (mzExe.Header.new_offset < exeFs.Length)
|
||||
if (neExe.IsNE)
|
||||
{
|
||||
recognized = true;
|
||||
Console.Write(neExe.GetInfo());
|
||||
foreach (NE.Version vers in neExe.Versions)
|
||||
{
|
||||
exeFs.Seek(mzExe.Header.new_offset, SeekOrigin.Begin);
|
||||
Console.WriteLine("\tVersion resource {0}:", vers.Name);
|
||||
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));
|
||||
|
||||
byte[] buffer = new byte[Marshal.SizeOf(typeof(libexeinfo.NE.Header))];
|
||||
exeFs.Read(buffer, 0, buffer.Length);
|
||||
IntPtr hdrPtr = Marshal.AllocHGlobal(buffer.Length);
|
||||
Marshal.Copy(buffer, 0, hdrPtr, buffer.Length);
|
||||
neHdr = (libexeinfo.NE.Header)Marshal.PtrToStructure(hdrPtr, typeof(libexeinfo.NE.Header));
|
||||
Marshal.FreeHGlobal(hdrPtr);
|
||||
|
||||
if (neHdr.signature == libexeinfo.NE.Signature)
|
||||
foreach (KeyValuePair<string, Dictionary<string, string>> strByLang in vers.StringsByLanguage)
|
||||
{
|
||||
Console.Write(libexeinfo.NE.GetInfo(neHdr));
|
||||
libexeinfo.NE.ResourceTable resources = libexeinfo.NE.GetResources(exeFs, mzExe.Header.new_offset, neHdr.resource_table_offset);
|
||||
foreach(libexeinfo.NE.ResourceType type in resources.types)
|
||||
string cultureName;
|
||||
string encodingName;
|
||||
|
||||
try
|
||||
{
|
||||
if((type.id & 0x7FFF) == (int)libexeinfo.NE.ResourceTypes.RT_VERSION)
|
||||
{
|
||||
foreach(libexeinfo.NE.Resource resource in type.resources)
|
||||
{
|
||||
libexeinfo.NE.Version vers = new libexeinfo.NE.Version(resource.data);
|
||||
Console.WriteLine("\tVersion resource {0}:", resource.name);
|
||||
Console.WriteLine("\t\tFile version: {0}", vers.FileVersion);
|
||||
Console.WriteLine("\t\tProduct version: {0}", vers.ProductVersion);
|
||||
Console.WriteLine("\t\tFile type: {0}", libexeinfo.NE.Version.TypeToString(vers.FileType));
|
||||
if(vers.FileType == libexeinfo.NE.VersionFileType.VFT_DRV)
|
||||
Console.WriteLine("\t\tFile subtype: {0} driver", libexeinfo.NE.Version.DriverToString(vers.FileSubtype));
|
||||
else if (vers.FileType == libexeinfo.NE.VersionFileType.VFT_DRV)
|
||||
Console.WriteLine("\t\tFile subtype: {0} font", libexeinfo.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}", libexeinfo.NE.Version.OsToString(vers.FileOS));
|
||||
|
||||
foreach (KeyValuePair<string, Dictionary<string, string>> strByLang in vers.StringsByLanguage)
|
||||
{
|
||||
string cultureName;
|
||||
string encodingName;
|
||||
|
||||
try
|
||||
{
|
||||
cultureName = new CultureInfo(Convert.ToInt32(strByLang.Key.Substring(0, 4), 16)).DisplayName;
|
||||
}
|
||||
catch
|
||||
{
|
||||
cultureName = string.Format("unsupported culture 0x{0:X4}", Convert.ToInt32(strByLang.Key.Substring(0, 4), 16));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
cultureName = new CultureInfo(Convert.ToInt32(strByLang.Key.Substring(0, 4), 16)).DisplayName;
|
||||
}
|
||||
catch
|
||||
{
|
||||
cultureName = string.Format("unsupported culture 0x{0:X4}", Convert.ToInt32(strByLang.Key.Substring(0, 4), 16));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!recognized)
|
||||
Console.WriteLine("Executalbe format not recognized");
|
||||
}
|
||||
Console.WriteLine("Executable format not recognized");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user