Refactor class names.

This commit is contained in:
2017-10-16 14:22:26 +01:00
parent b13a4a95d8
commit 5545471b79
9 changed files with 590 additions and 578 deletions

View File

@@ -33,10 +33,10 @@ namespace exeinfo
mzHdr = (libexeinfo.MZ.Header)Marshal.PtrToStructure(hdrPtr, typeof(libexeinfo.MZ.Header));
Marshal.FreeHGlobal(hdrPtr);
if(mzHdr.signature == libexeinfo.MZ.Consts.Signature)
if(mzHdr.signature == libexeinfo.MZ.Signature)
{
recognized = true;
libexeinfo.MZ.Info.PrintInfo(mzHdr);
libexeinfo.MZ.PrintInfo(mzHdr);
if (mzHdr.new_offset < exeFs.Length)
{
@@ -49,10 +49,10 @@ namespace exeinfo
neHdr = (libexeinfo.NE.Header)Marshal.PtrToStructure(hdrPtr, typeof(libexeinfo.NE.Header));
Marshal.FreeHGlobal(hdrPtr);
if (neHdr.signature == libexeinfo.NE.Consts.Signature)
if (neHdr.signature == libexeinfo.NE.Signature)
{
libexeinfo.NE.Info.PrintInfo(neHdr);
libexeinfo.NE.ResourceTable resources = libexeinfo.NE.Info.GetResources(exeFs, mzHdr.new_offset, neHdr.resource_table_offset);
libexeinfo.NE.PrintInfo(neHdr);
libexeinfo.NE.ResourceTable resources = libexeinfo.NE.GetResources(exeFs, mzHdr.new_offset, neHdr.resource_table_offset);
foreach(libexeinfo.NE.ResourceType type in resources.types)
{
if((type.id & 0x7FFF) == (int)libexeinfo.NE.ResourceTypes.RT_VERSION)

View File

@@ -1,7 +1,7 @@
using System;
namespace libexeinfo.MZ
namespace libexeinfo
{
public class Consts
public partial class MZ
{
public const ushort Signature = 0x5A4D;
}

View File

@@ -1,7 +1,7 @@
using System;
namespace libexeinfo.MZ
namespace libexeinfo
{
public class Info
public partial class MZ
{
public static void PrintInfo(Header header)
{

View File

@@ -1,7 +1,9 @@
using System.Runtime.InteropServices;
namespace libexeinfo.MZ
namespace libexeinfo
{
public partial class MZ
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct Header
{
@@ -29,9 +31,10 @@ namespace libexeinfo.MZ
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct RelocationTableEntry
public struct RelocationTableEntry
{
public ushort offset;
public ushort segment;
}
}
}

View File

@@ -1,11 +1,11 @@
using System;
using System.ComponentModel;
namespace libexeinfo.NE
namespace libexeinfo
{
public static class Consts
public partial class NE
{
public const ushort Signature = 0x454E;
public static readonly string FixedFileInfo = "VS_VERSION_INFO";
public static readonly string FixedFileInfoSig = "VS_VERSION_INFO";
public static readonly string StringFileInfo = "StringFileInfo";
public static string IdToName(ushort id)

View File

@@ -1,6 +1,8 @@
using System;
namespace libexeinfo.NE
namespace libexeinfo
{
public partial class NE
{
[Flags]
public enum ProgramFlags : byte
{
@@ -157,4 +159,5 @@ namespace libexeinfo.NE
VFT2_FONT_TRUETYPE = 0x00000003,
VFT2_FONT_VECTOR = 0x00000002,
}
}
}

View File

@@ -3,9 +3,9 @@ using System.Collections.Generic;
using System.IO;
using System.Text;
namespace libexeinfo.NE
namespace libexeinfo
{
public class Info
public partial class NE
{
public static void PrintInfo(Header header)
{
@@ -190,7 +190,7 @@ namespace libexeinfo.NE
table.types[t].name = Encoding.ASCII.GetString(str);
}
else
table.types[t].name = Consts.IdToName(table.types[t].id);
table.types[t].name = IdToName(table.types[t].id);
for (int r = 0; r < table.types[t].resources.Length; r++)
{

View File

@@ -1,8 +1,10 @@
using System;
using System.Runtime.InteropServices;
namespace libexeinfo.NE
namespace libexeinfo
{
public partial class NE
{
[StructLayout(LayoutKind.Sequential/*, Pack = 2*/)]
public struct Header
{
@@ -96,4 +98,5 @@ namespace libexeinfo.NE
public uint dwFileDateMS;
public uint dwFileDateLS;
}
}
}

View File

@@ -4,8 +4,10 @@ using System.IO;
using System.Runtime.InteropServices;
using System.Text;
namespace libexeinfo.NE
namespace libexeinfo
{
public partial class NE
{
public class Version
{
public Dictionary<string, Dictionary<string, string>> StringsByLanguage { get; }
@@ -130,7 +132,7 @@ namespace libexeinfo.NE
void DecodeNode(VersionNode node, string parent, string grandparent)
{
if (node.szName == Consts.FixedFileInfo)
if (node.szName == FixedFileInfoSig)
{
IntPtr infoPtr = Marshal.AllocHGlobal(node.cbData);
Marshal.Copy(node.rgbData, 0, infoPtr, node.cbData);
@@ -148,13 +150,13 @@ namespace libexeinfo.NE
fileDate = DateTime.FromFileTime(info.dwFileDateMS * 0x100000000 + info.dwFileDateLS);
}
if (parent == Consts.StringFileInfo)
if (parent == StringFileInfo)
{
Dictionary<string, string> strings = new Dictionary<string, string>();
StringsByLanguage.Add(node.szName, strings);
}
if (grandparent == Consts.StringFileInfo)
if (grandparent == StringFileInfo)
{
if (StringsByLanguage.TryGetValue(parent, out Dictionary<string, string> strings))
{
@@ -313,4 +315,5 @@ namespace libexeinfo.NE
}
}
}
}
}