Added Executable plugin for Universal Editor 4
This commit is contained in:
parent
4e9e3aaf98
commit
5d4b771210
@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UniversalEditor.ObjectModels.Executable;
|
||||
using UniversalEditor.ObjectModels.FileSystem;
|
||||
|
||||
namespace UniversalEditor.Converters
|
||||
{
|
||||
public class ExecutableToFileSystemConverter : Converter
|
||||
{
|
||||
private static ConverterReference _cr = null;
|
||||
public override ConverterReference MakeReference()
|
||||
{
|
||||
if (_cr == null)
|
||||
{
|
||||
_cr = base.MakeReference();
|
||||
_cr.Capabilities.Add(typeof(FileSystemObjectModel), typeof(ExecutableObjectModel));
|
||||
_cr.Capabilities.Add(typeof(ExecutableObjectModel), typeof(FileSystemObjectModel));
|
||||
}
|
||||
return _cr;
|
||||
}
|
||||
public override void Convert(ObjectModel from, ObjectModel to)
|
||||
{
|
||||
if (from is ExecutableObjectModel && to is FileSystemObjectModel)
|
||||
{
|
||||
ExecutableObjectModel exe = (from as ExecutableObjectModel);
|
||||
FileSystemObjectModel fsom = (to as FileSystemObjectModel);
|
||||
foreach (ExecutableSection section in exe.Sections)
|
||||
{
|
||||
fsom.Files.Add(section.Name, section.Data);
|
||||
}
|
||||
|
||||
// TODO: load resources (?)
|
||||
return;
|
||||
}
|
||||
else if (from is FileSystemObjectModel && to is ExecutableObjectModel)
|
||||
{
|
||||
FileSystemObjectModel fsom = (from as FileSystemObjectModel);
|
||||
ExecutableObjectModel exe = (to as ExecutableObjectModel);
|
||||
|
||||
foreach (File file in fsom.Files)
|
||||
{
|
||||
ExecutableSection section = new ExecutableSection();
|
||||
section.Name = file.Name;
|
||||
section.Data = file.GetDataAsByteArray();
|
||||
exe.Sections.Add(section);
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new ObjectModelNotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.DataFormats.Executable.ELF
|
||||
{
|
||||
public enum ELFCapacity : byte
|
||||
{
|
||||
elfInvalid = 0,
|
||||
elf32Bit = 1,
|
||||
elf64Bit = 2
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,238 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using UniversalEditor.IO;
|
||||
using UniversalEditor.ObjectModels.Executable;
|
||||
using UniversalEditor.ObjectModels.FileSystem;
|
||||
|
||||
namespace UniversalEditor.DataFormats.Executable.ELF
|
||||
{
|
||||
public class ELFDataFormat : DataFormat
|
||||
{
|
||||
private const byte EV_CURRENT = 1;
|
||||
|
||||
private static DataFormatReference _dfr = null;
|
||||
public override DataFormatReference MakeReference()
|
||||
{
|
||||
if (_dfr == null)
|
||||
{
|
||||
_dfr = base.MakeReference();
|
||||
_dfr.Capabilities.Add(typeof(ExecutableObjectModel), DataFormatCapabilities.All);
|
||||
_dfr.Filters.Add("Executable and Linkable Format", new byte?[][] { new byte?[] { (byte)0x7F, (byte)'E', (byte)'L', (byte)'F' } }, new string[] { "*.elf" });
|
||||
}
|
||||
return _dfr;
|
||||
}
|
||||
|
||||
private ELFCapacity mvarCapacity = ELFCapacity.elf32Bit;
|
||||
public ELFCapacity Capacity { get { return mvarCapacity; } set { mvarCapacity = value; } }
|
||||
|
||||
private ELFEncoding mvarEncoding = ELFEncoding.TwosComplementLSB;
|
||||
public ELFEncoding Encoding { get { return mvarEncoding; } set { mvarEncoding = value; } }
|
||||
|
||||
private ELFMachine mvarMachine = ELFMachine.None;
|
||||
/// <summary>
|
||||
/// Specifies the required architecture for the executable file.
|
||||
/// </summary>
|
||||
public ELFMachine Machine { get { return mvarMachine; } set { mvarMachine = value; } }
|
||||
|
||||
private ELFObjectFileType mvarObjectFileType = ELFObjectFileType.None;
|
||||
/// <summary>
|
||||
/// Identifies the object file type.
|
||||
/// </summary>
|
||||
public ELFObjectFileType ObjectFileType { get { return mvarObjectFileType; } set { mvarObjectFileType = value; } }
|
||||
|
||||
private byte mvarFormatVersion = EV_CURRENT;
|
||||
public byte FormatVersion { get { return mvarFormatVersion; } set { mvarFormatVersion = value; } }
|
||||
|
||||
/*
|
||||
Elf32_Addr = Unsigned 4 byte program address
|
||||
Elf32_Half = Unsigned 2 byte integer
|
||||
Elf32_Off = Unsigned 4 byte file offset
|
||||
Elf32_Sword = Signed 4 byte integer
|
||||
Elf32_Word = Unsigned 4 byte integer
|
||||
unsigned char = Unsigned 1 byte integer
|
||||
*/
|
||||
|
||||
private struct ELFSectionEntry
|
||||
{
|
||||
public string name;
|
||||
/// <summary>
|
||||
/// This member specifies the name of the section. Its value is an index into
|
||||
/// the section header string table section, giving the location of a
|
||||
/// null-terminated string.
|
||||
/// </summary>
|
||||
public uint nameindex;
|
||||
/// <summary>
|
||||
/// This member categorizes the section’s contents and semantics. Section types
|
||||
/// and their descriptions appear below.
|
||||
/// </summary>
|
||||
public ELFSectionType type;
|
||||
/// <summary>
|
||||
/// Sections support 1-bit flags that describe miscellaneous attributes.
|
||||
/// </summary>
|
||||
public ELFSectionFlags flags;
|
||||
/// <summary>
|
||||
/// If the section will appear in the memory image of a process, this member
|
||||
/// gives the address at which the section’s first byte should reside.
|
||||
/// Otherwise, the member contains 0.
|
||||
/// </summary>
|
||||
public uint addr;
|
||||
/// <summary>
|
||||
/// This member’s value gives the byte offset from the beginning of the file
|
||||
/// to the first byte in the section. One section type, SHT_NOBITS described
|
||||
/// below, occupies no space in the file, and its sh_offset member locates
|
||||
/// the conceptual placement in the file.
|
||||
/// </summary>
|
||||
public uint offset;
|
||||
/// <summary>
|
||||
/// This member gives the section’s size in bytes. Unless the section type is
|
||||
/// SHT_NOBITS, the section occupies sh_size bytes in the file. A section of
|
||||
/// type SHT_NOBITS may have a non-zero size, but it occupies no space in the
|
||||
/// file.
|
||||
/// </summary>
|
||||
public uint size;
|
||||
/// <summary>
|
||||
/// This member holds a section header table index link, whose interpretation
|
||||
/// depends on the section type. A table below describes the values.
|
||||
/// </summary>
|
||||
public uint link;
|
||||
/// <summary>
|
||||
/// This member holds extra information, whose interpretation depends on the
|
||||
/// section type. A table below describes the values.
|
||||
/// </summary>
|
||||
public uint info;
|
||||
/// <summary>
|
||||
/// Some sections have address alignment constraints. For example, if a
|
||||
/// section holds a doubleword, the system must ensure doubleword alignment
|
||||
/// for the entire section. That is, the value of sh_addr must be congruent
|
||||
/// to 0, modulo the value of sh_addralign. Currently, only 0 and positive
|
||||
/// integral powers of two are allowed. Values 0 and 1 mean the section has
|
||||
/// no alignment constraints.
|
||||
/// </summary>
|
||||
public uint addralign;
|
||||
/// <summary>
|
||||
/// Some sections hold a table of fixed-size entries, such as a symbol table.
|
||||
/// For such a section, this member gives the size in bytes of each entry.
|
||||
/// The member contains 0 if the section does not hold a table of fixed-size
|
||||
/// entries.
|
||||
/// </summary>
|
||||
public uint entsize;
|
||||
}
|
||||
|
||||
protected override void LoadInternal(ref ObjectModel objectModel)
|
||||
{
|
||||
ExecutableObjectModel exe = (objectModel as ExecutableObjectModel);
|
||||
if (exe == null) throw new ObjectModelNotSupportedException();
|
||||
|
||||
Reader br = base.Accessor.Reader;
|
||||
long baseoffset = br.Accessor.Position;
|
||||
|
||||
#region Header
|
||||
#region e_ident
|
||||
{
|
||||
byte signature1 = br.ReadByte();
|
||||
string signature2 = br.ReadFixedLengthString(3);
|
||||
if (signature1 != 0x7F || signature2 != "ELF") throw new InvalidDataFormatException("File does not begin with 0x7F, \"ELF\"");
|
||||
|
||||
mvarCapacity = (ELFCapacity)br.ReadByte();
|
||||
mvarEncoding = (ELFEncoding)br.ReadByte();
|
||||
mvarFormatVersion = br.ReadByte();
|
||||
byte[] padding = br.ReadBytes(8);
|
||||
byte nident = br.ReadByte(); // should be 16
|
||||
// if (nident != 16) throw new InvalidDataFormatException("n_ident is not equal to 16");
|
||||
}
|
||||
#endregion
|
||||
mvarObjectFileType = (ELFObjectFileType)br.ReadUInt16();
|
||||
mvarMachine = (ELFMachine)br.ReadUInt16();
|
||||
uint e_version = br.ReadUInt32();
|
||||
|
||||
// This member gives the virtual address to which the system first transfers
|
||||
// control, thus starting the process. If the file has no associated entry
|
||||
// point, this member holds zero.
|
||||
uint e_entry = br.ReadUInt32();
|
||||
|
||||
// This member holds the program header table’s file offset in bytes. If the
|
||||
// file has no program header table, this member holds zero.
|
||||
uint e_phoff = br.ReadUInt32();
|
||||
|
||||
// This member holds the section header table’s file offset in bytes. If the
|
||||
// file has no section header table, this member holds zero.
|
||||
uint e_shoff = br.ReadUInt32();
|
||||
|
||||
// This member holds processor-specific flags associated with the file. Flag
|
||||
// names take the form EF_machine_flag. See "Machine Information" for flag
|
||||
// definitions.
|
||||
uint e_flags = br.ReadUInt32();
|
||||
|
||||
// This member holds the ELF header’s size in bytes.
|
||||
ushort e_ehsize = br.ReadUInt16();
|
||||
|
||||
// This member holds the size in bytes of one entry in the file’s program
|
||||
// header table; all entries are the same size.
|
||||
ushort e_phentsize = br.ReadUInt16();
|
||||
|
||||
// This member holds the number of entries in the program header table. Thus
|
||||
// the product of e_phentsize and e_phnum gives the table’s size in bytes. If a
|
||||
// file has no program header table, e_phnum holds the value zero.
|
||||
ushort e_phnum = br.ReadUInt16();
|
||||
|
||||
// This member holds a section header’s size in bytes. A section header is one
|
||||
// entry in the section header table; all entries are the same size.
|
||||
ushort e_shentsize = br.ReadUInt16();
|
||||
|
||||
// This member holds the number of entries in the section header table. Thus
|
||||
// the product of e_shentsize and e_shnum gives the section header table's size
|
||||
// in bytes. If a file has no section header table, e_shnum holds the value
|
||||
// zero.
|
||||
ushort e_shnum = br.ReadUInt16();
|
||||
|
||||
// This member holds the section header table index of the entry associated with
|
||||
// the section name string table. If the file has no section name string table,
|
||||
// this member holds the value SHN_UNDEF.
|
||||
ushort e_shstrndx = br.ReadUInt16();
|
||||
#endregion
|
||||
#region Section Table
|
||||
br.Accessor.Position = baseoffset + e_shoff;
|
||||
List<ELFSectionEntry> sections = new List<ELFSectionEntry>();
|
||||
for (ushort i = 0; i < e_shnum; i++)
|
||||
{
|
||||
ELFSectionEntry sh = new ELFSectionEntry();
|
||||
sh.nameindex = br.ReadUInt32();
|
||||
sh.type = (ELFSectionType)br.ReadUInt32();
|
||||
sh.flags = (ELFSectionFlags)br.ReadUInt32();
|
||||
sh.addr = br.ReadUInt32();
|
||||
sh.offset = br.ReadUInt32();
|
||||
sh.size = br.ReadUInt32();
|
||||
sh.link = br.ReadUInt32();
|
||||
sh.info = br.ReadUInt32();
|
||||
sh.addralign = br.ReadUInt32();
|
||||
sh.entsize = br.ReadUInt32();
|
||||
sections.Add(sh);
|
||||
}
|
||||
#endregion
|
||||
|
||||
// find the section header string table
|
||||
if (e_shstrndx > 0)
|
||||
{
|
||||
ELFSectionEntry shstr = sections[e_shstrndx];
|
||||
long pos = br.Accessor.Position;
|
||||
long stroffset = baseoffset + shstr.offset;
|
||||
for (int i = 0; i < sections.Count; i++)
|
||||
{
|
||||
ELFSectionEntry entry = sections[i];
|
||||
br.Accessor.Position = stroffset + entry.nameindex;
|
||||
entry.name = br.ReadNullTerminatedString();
|
||||
sections[i] = entry;
|
||||
}
|
||||
br.Accessor.Position = pos;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SaveInternal(ObjectModel objectModel)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.DataFormats.Executable.ELF
|
||||
{
|
||||
public enum ELFEncoding
|
||||
{
|
||||
None = 0,
|
||||
TwosComplementLSB = 1,
|
||||
TwosComplementMSB = 2
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.DataFormats.Executable.ELF
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the required architecture for the executable file.
|
||||
/// </summary>
|
||||
public enum ELFMachine : ushort
|
||||
{
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// AT&T WE 32100
|
||||
/// </summary>
|
||||
M32 = 1,
|
||||
/// <summary>
|
||||
/// SPARC
|
||||
/// </summary>
|
||||
SPARC = 2,
|
||||
/// <summary>
|
||||
/// Intel 80386
|
||||
/// </summary>
|
||||
Intel80386 = 3,
|
||||
/// <summary>
|
||||
/// Motorola 68K
|
||||
/// </summary>
|
||||
Motorola68000 = 4,
|
||||
/// <summary>
|
||||
/// Motorola 88K
|
||||
/// </summary>
|
||||
Motorola88000 = 5,
|
||||
/// <summary>
|
||||
/// Intel 80860
|
||||
/// </summary>
|
||||
Intel80860 = 7,
|
||||
/// <summary>
|
||||
/// MIPS RS3000
|
||||
/// </summary>
|
||||
MIPS = 8
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.DataFormats.Executable.ELF
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies the object file type.
|
||||
/// </summary>
|
||||
public enum ELFObjectFileType : ushort
|
||||
{
|
||||
/// <summary>
|
||||
/// No file type
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// Relocatable file
|
||||
/// </summary>
|
||||
Relocatable = 1,
|
||||
/// <summary>
|
||||
/// Executable file
|
||||
/// </summary>
|
||||
Executable = 2,
|
||||
/// <summary>
|
||||
/// Shared object file
|
||||
/// </summary>
|
||||
SharedObject = 3,
|
||||
/// <summary>
|
||||
/// Core file
|
||||
/// </summary>
|
||||
Core = 4,
|
||||
/// <summary>
|
||||
/// Processor-specific
|
||||
/// </summary>
|
||||
ProcessorSpecificFF00 = 0xFF00,
|
||||
/// <summary>
|
||||
/// Processor-specific
|
||||
/// </summary>
|
||||
ProcessorSpecificFFFF = 0xFFFF
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.DataFormats.Executable.ELF
|
||||
{
|
||||
[Flags()]
|
||||
public enum ELFSectionFlags : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// The section contains data that should be writable during process execution.
|
||||
/// </summary>
|
||||
Writable = 0x1,
|
||||
/// <summary>
|
||||
/// The section occupies memory during process execution. Some control sections do
|
||||
/// not reside in the memory image of an object file; this attribute is off for
|
||||
/// those sections.
|
||||
/// </summary>
|
||||
Allocated = 0x2,
|
||||
/// <summary>
|
||||
/// The section contains executable machine instructions.
|
||||
/// </summary>
|
||||
Executable = 0x4,
|
||||
/// <summary>
|
||||
/// All bits included in this mask are reserved for processor-specific semantics.
|
||||
/// </summary>
|
||||
ProcessorSpecificMask = 0xF0000000
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.DataFormats.Executable.ELF
|
||||
{
|
||||
public enum ELFSectionType : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// This value marks the section header as inactive; it does not have an associated
|
||||
/// section. Other members of the section header have undefined values.
|
||||
/// </summary>
|
||||
Null = 0,
|
||||
/// <summary>
|
||||
/// The section holds information defined by the program, whose format and meaning
|
||||
/// are determined solely by the program.
|
||||
/// </summary>
|
||||
ProgramSpecific = 1,
|
||||
/// <summary>
|
||||
/// These sections hold a symbol table. Currently, an object file may have only one
|
||||
/// section of each type, but this restriction may be relaxed in the future.
|
||||
/// Typically, SHT_SYMTAB provides symbols for link editing, though it may also be
|
||||
/// used for dynamic linking. As a complete symbol table, it may contain many
|
||||
/// symbols unnecessary for dynamic linking. Consequently, an object file may also
|
||||
/// contain a SHT_DYNSYM section, which holds a minimal set of dynamic linking
|
||||
/// symbols, to save space.
|
||||
/// </summary>
|
||||
SymbolTable = 2,
|
||||
/// <summary>
|
||||
/// The section holds a string table. An object file may have multiple string table
|
||||
/// sections.
|
||||
/// </summary>
|
||||
StringTable = 3,
|
||||
/// <summary>
|
||||
/// The section holds relocation entries with explicit addends, such as type
|
||||
/// Elf32_Rela for the 32-bit class of object files. An object file may have
|
||||
/// multiple relocation sections.
|
||||
/// </summary>
|
||||
RelocationWithExplicitAddends = 4,
|
||||
/// <summary>
|
||||
/// The section holds a symbol hash table. All objects participating in dynamic
|
||||
/// linking must contain a symbol hash table. Currently, an object file may have
|
||||
/// only one hash table, but this restriction may be relaxed in the future.
|
||||
/// </summary>
|
||||
SymbolHashTable = 5,
|
||||
/// <summary>
|
||||
/// The section holds information for dynamic linking. Currently, an object file
|
||||
/// may have only one dynamic section, but this restriction may be relaxed in the
|
||||
/// future.
|
||||
/// </summary>
|
||||
DynamicLinking = 6,
|
||||
/// <summary>
|
||||
/// The section holds information that marks the file in some way.
|
||||
/// </summary>
|
||||
Note = 7,
|
||||
/// <summary>
|
||||
/// A section of this type occupies no space in the file but otherwise resembles
|
||||
/// SHT_PROGBITS. Although this section contains no bytes, the sh_offset member
|
||||
/// contains the conceptual file offset.
|
||||
/// </summary>
|
||||
NoBits = 8,
|
||||
/// <summary>
|
||||
/// The section holds relocation entries without explicit addends, such as type
|
||||
/// Elf32_Rel for the 32-bit class of object files. An object file may have multiple
|
||||
/// relocation sections.
|
||||
/// </summary>
|
||||
Relocation = 9,
|
||||
/// <summary>
|
||||
/// This section type is reserved but has unspecified semantics. Programs that
|
||||
/// contain a section of this type do not conform to the ABI.
|
||||
/// </summary>
|
||||
ShLib = 10,
|
||||
/// <summary>
|
||||
/// These sections hold a symbol table. Currently, an object file may have only one
|
||||
/// section of each type, but this restriction may be relaxed in the future.
|
||||
/// Typically, SHT_SYMTAB provides symbols for link editing, though it may also be
|
||||
/// used for dynamic linking. As a complete symbol table, it may contain many
|
||||
/// symbols unnecessary for dynamic linking. Consequently, an object file may also
|
||||
/// contain a SHT_DYNSYM section, which holds a minimal set of dynamic linking
|
||||
/// symbols, to save space.
|
||||
/// </summary>
|
||||
DynamicSymbolTable = 11,
|
||||
/// <summary>
|
||||
/// Values in this inclusive range are reserved for processor-specific semantics.
|
||||
/// </summary>
|
||||
ProcessorSpecificLo = 0x70000000,
|
||||
/// <summary>
|
||||
/// Values in this inclusive range are reserved for processor-specific semantics.
|
||||
/// </summary>
|
||||
ProcessorSpecificHi = 0x7FFFFFFF,
|
||||
/// <summary>
|
||||
/// This value specifies the lower bound of the range of indexes reserved for
|
||||
/// application programs.
|
||||
/// </summary>
|
||||
UserSpecificLo = 0x80000000,
|
||||
/// <summary>
|
||||
/// This value specifies the upper bound of the range of indexes reserved for
|
||||
/// application programs. Section types between SHT_LOUSER and SHT_HIUSER may be
|
||||
/// used by the application, without conflicting with current or future
|
||||
/// system-defined section types.
|
||||
/// </summary>
|
||||
UserSpecificHi = 0xFFFFFFFF
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.DataFormats.Executable.ELF
|
||||
{
|
||||
public enum ELFSpecialSectionIndex
|
||||
{
|
||||
Undefined = 0,
|
||||
ReservedLo = 0xFF00,
|
||||
ProcLo = 0xFF00,
|
||||
ProcHigh = 0xFF1F,
|
||||
Abs = 0xFFF1,
|
||||
Common = 0xFFF2,
|
||||
ReservedHigh = 0xFFFF
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Executable
|
||||
{
|
||||
/// <summary>
|
||||
/// A set of bit flags indicating attributes of the file.
|
||||
/// </summary>
|
||||
[Flags()]
|
||||
public enum ExecutableCharacteristics : ushort
|
||||
{
|
||||
/// <summary>
|
||||
/// No characteristics defined.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// Relocation information stripped from a file.
|
||||
/// </summary>
|
||||
RelocationInformationStripped = 0x0001,
|
||||
/// <summary>
|
||||
/// The file is executable.
|
||||
/// </summary>
|
||||
ExecutableImage = 0x0002,
|
||||
/// <summary>
|
||||
/// Line numbers stripped from file.
|
||||
/// </summary>
|
||||
LineNumbersStripped = 0x0004,
|
||||
/// <summary>
|
||||
/// Local symbols stripped from file.
|
||||
/// </summary>
|
||||
LocalSymbolsStripped = 0x0008,
|
||||
/// <summary>
|
||||
/// Lets the OS aggressively trim the working set.
|
||||
/// </summary>
|
||||
AggressiveWorkingSetTrim = 0x0010,
|
||||
/// <summary>
|
||||
/// Lets the OS aggressively trim the working set.
|
||||
/// </summary>
|
||||
MinimalObject = 0x0010,
|
||||
/// <summary>
|
||||
/// The application can handle addresses greater than two gigabytes.
|
||||
/// </summary>
|
||||
UpdateObject = 0x0020,
|
||||
/// <summary>
|
||||
/// The application can handle addresses greater than two gigabytes.
|
||||
/// </summary>
|
||||
LargeAddressAware = 0x0020,
|
||||
/// <summary>
|
||||
/// This requires a 32-bit word machine.
|
||||
/// </summary>
|
||||
Require32BitWord = 0x0100,
|
||||
/// <summary>
|
||||
/// Debug information is stripped to a .DBG file.
|
||||
/// </summary>
|
||||
DebugStripped = 0x0200,
|
||||
/// <summary>
|
||||
/// If the image is on removable media, copy to and run from the swap file.
|
||||
/// </summary>
|
||||
RemovableRunFromSwap = 0x0400,
|
||||
/// <summary>
|
||||
/// If the image is on a network, copy to and run from the swap file.
|
||||
/// </summary>
|
||||
NetworkRunFromSwap = 0x0800,
|
||||
/// <summary>
|
||||
/// File is a system file.
|
||||
/// </summary>
|
||||
IsSystemFile = 0x1000,
|
||||
/// <summary>
|
||||
/// File is a DLL.
|
||||
/// </summary>
|
||||
IsDynamicLinkLibrary = 0x2000,
|
||||
/// <summary>
|
||||
/// The file should only be run on single-processor machines.
|
||||
/// </summary>
|
||||
UniprocessorOnly = 0x4000,
|
||||
/// <summary>
|
||||
/// Bytes of machine word are reversed
|
||||
/// </summary>
|
||||
ReverseByteOrder = 0x8000
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Executable
|
||||
{
|
||||
public class ExecutableFunctionCall : ICloneable
|
||||
{
|
||||
public class ExecutableFunctionCallCollection
|
||||
: System.Collections.ObjectModel.Collection<ExecutableFunctionCall>
|
||||
{
|
||||
}
|
||||
|
||||
private string mvarLibraryName = String.Empty;
|
||||
public string LibraryName { get { return mvarLibraryName; } set { mvarLibraryName = value; } }
|
||||
|
||||
private string mvarFunctionName = String.Empty;
|
||||
public string FunctionName { get { return mvarFunctionName; } set { mvarFunctionName = value; } }
|
||||
|
||||
private List<object> mvarParameterValues = new List<object>();
|
||||
public List<object> ParameterValues { get { return mvarParameterValues; } }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append(mvarLibraryName);
|
||||
sb.Append("!");
|
||||
sb.Append(mvarFunctionName);
|
||||
sb.Append("(");
|
||||
foreach (object obj in mvarParameterValues)
|
||||
{
|
||||
if (obj is string) sb.Append("\"");
|
||||
sb.Append(obj.ToString());
|
||||
if (obj is string) sb.Append("\"");
|
||||
if (mvarParameterValues.IndexOf(obj) < mvarParameterValues.Count - 1) sb.Append(", ");
|
||||
}
|
||||
sb.Append(");");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
ExecutableFunctionCall clone = new ExecutableFunctionCall();
|
||||
clone.FunctionName = mvarFunctionName;
|
||||
clone.LibraryName = mvarLibraryName;
|
||||
foreach (object obj in mvarParameterValues)
|
||||
{
|
||||
clone.ParameterValues.Add(obj);
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Executable
|
||||
{
|
||||
public enum ExecutableInstructionOpcode : byte
|
||||
{
|
||||
Add = 0,
|
||||
Move = 0x89,
|
||||
Push0 = 0x50,
|
||||
Push1 = 0x51,
|
||||
Push2 = 0x52,
|
||||
Push3 = 0x53, // pushl EBP
|
||||
Push4 = 0x54,
|
||||
Push5 = 0x55,
|
||||
Push6 = 0x56,
|
||||
Push7 = 0x57,
|
||||
PushWord = 0x68,
|
||||
PushByte = 0x6A,
|
||||
Nop = 0x90,
|
||||
Call = 0xFF
|
||||
}
|
||||
public abstract class ExecutableInstruction
|
||||
{
|
||||
public class ExecutableInstructionCollection
|
||||
: System.Collections.ObjectModel.Collection<ExecutableInstruction>
|
||||
{
|
||||
}
|
||||
|
||||
public abstract ExecutableInstructionOpcode OpCode { get; }
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Executable
|
||||
{
|
||||
[Flags()]
|
||||
public enum ExecutableLibraryCharacteristics : ushort
|
||||
{
|
||||
/// <summary>
|
||||
/// No library characteristics have been specified.
|
||||
/// </summary>
|
||||
None = 0x0000,
|
||||
/// <summary>
|
||||
/// Call when DLL is first loaded into a process's address space.
|
||||
/// </summary>
|
||||
CallUponLoad = 0x0001,
|
||||
/// <summary>
|
||||
/// Call when a thread terminates.
|
||||
/// </summary>
|
||||
CallUponThreadTerminate = 0x0002,
|
||||
/// <summary>
|
||||
/// Call when a thread starts up.
|
||||
/// </summary>
|
||||
CallUponThreadStart = 0x0004,
|
||||
/// <summary>
|
||||
/// Call when DLL exits.
|
||||
/// </summary>
|
||||
CallUponLibraryExit = 0x0008,
|
||||
/// <summary>
|
||||
/// The DLL can be relocated at load time.
|
||||
/// </summary>
|
||||
DynamicBase = 0x0040,
|
||||
/// <summary>
|
||||
/// Code integrity checks are forced. If you set this flag and a section contains only
|
||||
/// uninitialized data, set the PointerToRawData member of IMAGE_SECTION_HEADER for that
|
||||
/// section to zero; otherwise, the image will fail to load because the digital signature
|
||||
/// cannot be verified.
|
||||
/// </summary>
|
||||
ForceCodeIntegrityChecks = 0x0080,
|
||||
/// <summary>
|
||||
/// The image is compatible with data execution prevention (DEP), the NX bit.
|
||||
/// </summary>
|
||||
DataExecutionPreventionCompatible = 0x0100,
|
||||
/// <summary>
|
||||
/// The image is isolation aware, but should not be isolated.
|
||||
/// </summary>
|
||||
NoIsolation = 0x0200,
|
||||
/// <summary>
|
||||
/// The image does not use structured exception handling (SEH). No handlers can be called in
|
||||
/// this image.
|
||||
/// </summary>
|
||||
NoStructuredExceptionHandling = 0x0400,
|
||||
/// <summary>
|
||||
/// Do not bind the image.
|
||||
/// </summary>
|
||||
NoBinding = 0x0800,
|
||||
/// <summary>
|
||||
/// Reserved.
|
||||
/// </summary>
|
||||
Reserved4096 = 0x1000,
|
||||
/// <summary>
|
||||
/// A WDM driver.
|
||||
/// </summary>
|
||||
WDMDriver = 0x2000,
|
||||
/// <summary>
|
||||
/// Reserved.
|
||||
/// </summary>
|
||||
Reserved16384 = 0x4000,
|
||||
/// <summary>
|
||||
/// The image is terminal server aware.
|
||||
/// </summary>
|
||||
TerminalServerAware = 0x8000
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Executable
|
||||
{
|
||||
public class ExecutableLibraryReference : ICloneable
|
||||
{
|
||||
public class ExecutableLibraryReferenceCollection
|
||||
: System.Collections.ObjectModel.Collection<ExecutableLibraryReference>
|
||||
{
|
||||
public ExecutableLibraryReference Add(int libraryID, int minVer, int numberOfTimesIncluded)
|
||||
{
|
||||
ExecutableLibraryReference r = new ExecutableLibraryReference();
|
||||
r.ProductID = libraryID;
|
||||
r.MinimumVersion = minVer;
|
||||
r.Count = numberOfTimesIncluded;
|
||||
base.Add(r);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
private int mvarProductID = 0;
|
||||
public int ProductID { get { return mvarProductID; } set { mvarProductID = value; } }
|
||||
|
||||
private int mvarMinimumVersion = 0;
|
||||
public int MinimumVersion { get { return mvarMinimumVersion; } set { mvarMinimumVersion = value; } }
|
||||
|
||||
private int mvarCount = 0;
|
||||
public int Count { get { return mvarCount; } set { mvarCount = value; } }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Product ID: " + mvarProductID.ToString() + ", minimum version " + mvarMinimumVersion.ToString() + ", count: " + mvarCount.ToString();
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
ExecutableLibraryReference clone = new ExecutableLibraryReference();
|
||||
clone.Count = mvarCount;
|
||||
clone.MinimumVersion = mvarMinimumVersion;
|
||||
clone.ProductID = mvarProductID;
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Executable
|
||||
{
|
||||
/// <summary>
|
||||
/// Fields relating to debugging support
|
||||
/// </summary>
|
||||
public enum ExecutableLoaderFlags
|
||||
{
|
||||
/// <summary>
|
||||
/// No loader flags have been defined.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// Invoke a breakpoint instruction before starting the process.
|
||||
/// </summary>
|
||||
BreakBeforeStart = 1,
|
||||
/// <summary>
|
||||
/// Invoke a debugger on the process after it's been loaded.
|
||||
/// </summary>
|
||||
DebugAfterLoad = 2
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Executable
|
||||
{
|
||||
/// <summary>
|
||||
/// The target CPU for this executable.
|
||||
/// </summary>
|
||||
public enum ExecutableMachine : ushort
|
||||
{
|
||||
/// <summary>
|
||||
/// Machine type unknown
|
||||
/// </summary>
|
||||
Unknown = 0,
|
||||
/// <summary>
|
||||
/// Intel 386 (i386) 32-bit machine
|
||||
/// </summary>
|
||||
Intel386 = 0x014C,
|
||||
/// <summary>
|
||||
/// Intel 860
|
||||
/// </summary>
|
||||
Intel860 = 0x014D,
|
||||
/// <summary>
|
||||
/// MIPS little-endian, 0540 big-endian
|
||||
/// </summary>
|
||||
R3000 = 0x0162,
|
||||
/// <summary>
|
||||
/// MIPS little-endian
|
||||
/// </summary>
|
||||
R4000 = 0x0166,
|
||||
/// <summary>
|
||||
/// MIPS little-endian
|
||||
/// </summary>
|
||||
R10000 = 0x0168,
|
||||
/// <summary>
|
||||
/// Alpha_AXP 32-bit
|
||||
/// </summary>
|
||||
AlphaAXP32 = 0x0184,
|
||||
/// <summary>
|
||||
/// IBM PowerPC Little-Endian
|
||||
/// </summary>
|
||||
PowerPCLittleEndian = 0x01F0,
|
||||
/// <summary>
|
||||
/// IBM PowerPC Big-Endian
|
||||
/// </summary>
|
||||
PowerPCBigEndian = 0x01F2,
|
||||
/// <summary>
|
||||
/// SH3 little-endian
|
||||
/// </summary>
|
||||
SH3 = 0x01A2,
|
||||
/// <summary>
|
||||
/// SH3E little-endian
|
||||
/// </summary>
|
||||
SH3E = 0x01A4,
|
||||
/// <summary>
|
||||
/// SH4 little-endian
|
||||
/// </summary>
|
||||
SH4 = 0x01A6,
|
||||
/// <summary>
|
||||
/// ARM little-endian
|
||||
/// </summary>
|
||||
ARM = 0x01C0,
|
||||
/// <summary>
|
||||
/// Thumb
|
||||
/// </summary>
|
||||
Thumb = 0x01C2,
|
||||
/// <summary>
|
||||
/// Intel 64 (ia64) Itanium 64-bit machine
|
||||
/// </summary>
|
||||
Intel64Bit = 0x0200,
|
||||
/// <summary>
|
||||
/// MIPS
|
||||
/// </summary>
|
||||
MIPS16 = 0x0266,
|
||||
/// <summary>
|
||||
/// Alpha_AXP 64-bit
|
||||
/// </summary>
|
||||
AlphaAXP64 = 0x0284,
|
||||
/// <summary>
|
||||
/// MIPS
|
||||
/// </summary>
|
||||
MIPSFPU = 0x0366,
|
||||
/// <summary>
|
||||
/// MIPS
|
||||
/// </summary>
|
||||
MIPSFPU16 = 0x0466,
|
||||
/// <summary>
|
||||
/// AMD64 64-bit machine
|
||||
/// </summary>
|
||||
AMD64 = 0x8664,
|
||||
/// <summary>
|
||||
/// CEF
|
||||
/// </summary>
|
||||
CEF = 0xC0EF
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Executable
|
||||
{
|
||||
public class ExecutableObjectModel : ObjectModel
|
||||
{
|
||||
private ExecutableSection.ExecutableSectionCollection mvarSections = new ExecutableSection.ExecutableSectionCollection();
|
||||
public ExecutableSection.ExecutableSectionCollection Sections { get { return mvarSections; } }
|
||||
|
||||
private ExecutableLibraryReference.ExecutableLibraryReferenceCollection mvarLibraryReferences = new ExecutableLibraryReference.ExecutableLibraryReferenceCollection();
|
||||
public ExecutableLibraryReference.ExecutableLibraryReferenceCollection LibraryReferences { get { return mvarLibraryReferences; } }
|
||||
|
||||
private ExecutableMachine mvarTargetMachineType = ExecutableMachine.Unknown;
|
||||
public ExecutableMachine TargetMachineType { get { return mvarTargetMachineType; } set { mvarTargetMachineType = value; } }
|
||||
|
||||
private ExecutableFunctionCall.ExecutableFunctionCallCollection mvarFunctionCalls = new ExecutableFunctionCall.ExecutableFunctionCallCollection();
|
||||
public ExecutableFunctionCall.ExecutableFunctionCallCollection FunctionCalls { get { return mvarFunctionCalls; } }
|
||||
|
||||
#region Object Model Methods
|
||||
public override void Clear()
|
||||
{
|
||||
mvarSections.Clear();
|
||||
mvarLibraryReferences.Clear();
|
||||
mvarTargetMachineType = ExecutableMachine.Unknown;
|
||||
mvarCharacteristics = ExecutableCharacteristics.None;
|
||||
mvarLibraryCharacteristics = ExecutableLibraryCharacteristics.None;
|
||||
mvarRelativeVirtualAddresses.Clear();
|
||||
mvarInstructions.Clear();
|
||||
mvarFunctionCalls.Clear();
|
||||
mvarSubsystem = ExecutableSubsystem.Unknown;
|
||||
mvarTimestamp = DateTime.Now;
|
||||
}
|
||||
public override void CopyTo(ObjectModel where)
|
||||
{
|
||||
ExecutableObjectModel clone = (where as ExecutableObjectModel);
|
||||
foreach (ExecutableSection sect in mvarSections)
|
||||
{
|
||||
clone.Sections.Add(sect.Clone() as ExecutableSection);
|
||||
}
|
||||
foreach (ExecutableLibraryReference lref in mvarLibraryReferences)
|
||||
{
|
||||
clone.LibraryReferences.Add(lref.Clone() as ExecutableLibraryReference);
|
||||
}
|
||||
clone.TargetMachineType = mvarTargetMachineType;
|
||||
clone.Characteristics = mvarCharacteristics;
|
||||
clone.LibraryCharacteristics = mvarLibraryCharacteristics;
|
||||
foreach (ExecutableRelativeVirtualAddress rva in mvarRelativeVirtualAddresses)
|
||||
{
|
||||
clone.RelativeVirtualAddresses.Add(rva.Clone() as ExecutableRelativeVirtualAddress);
|
||||
}
|
||||
foreach (ExecutableFunctionCall func in mvarFunctionCalls)
|
||||
{
|
||||
clone.FunctionCalls.Add(func.Clone() as ExecutableFunctionCall);
|
||||
}
|
||||
clone.Subsystem = mvarSubsystem;
|
||||
clone.Timestamp = mvarTimestamp;
|
||||
}
|
||||
public override ObjectModelReference MakeReference()
|
||||
{
|
||||
ObjectModelReference omr = base.MakeReference();
|
||||
omr.Title = "Executable";
|
||||
omr.Path = new string[] { "Software Development", "Executable" };
|
||||
return omr;
|
||||
}
|
||||
#endregion
|
||||
|
||||
private ExecutableCharacteristics mvarCharacteristics = ExecutableCharacteristics.None;
|
||||
public ExecutableCharacteristics Characteristics { get { return mvarCharacteristics; } set { mvarCharacteristics = value; } }
|
||||
|
||||
private ExecutableLibraryCharacteristics mvarLibraryCharacteristics = ExecutableLibraryCharacteristics.None;
|
||||
public ExecutableLibraryCharacteristics LibraryCharacteristics { get { return mvarLibraryCharacteristics; } set { mvarLibraryCharacteristics = value; } }
|
||||
|
||||
private ExecutableLoaderFlags mvarLoaderFlags = ExecutableLoaderFlags.None;
|
||||
public ExecutableLoaderFlags LoaderFlags { get { return mvarLoaderFlags; } set { mvarLoaderFlags = value; } }
|
||||
|
||||
private ExecutableSubsystem mvarSubsystem = ExecutableSubsystem.Unknown;
|
||||
public ExecutableSubsystem Subsystem { get { return mvarSubsystem; } set { mvarSubsystem = value; } }
|
||||
|
||||
private DateTime mvarTimestamp = DateTime.Now;
|
||||
public DateTime Timestamp { get { return mvarTimestamp; } set { mvarTimestamp = value; } }
|
||||
|
||||
private ExecutableRelativeVirtualAddress.ExecutableRelativeVirtualAddressCollection mvarRelativeVirtualAddresses = new ExecutableRelativeVirtualAddress.ExecutableRelativeVirtualAddressCollection();
|
||||
public ExecutableRelativeVirtualAddress.ExecutableRelativeVirtualAddressCollection RelativeVirtualAddresses { get { return mvarRelativeVirtualAddresses; } }
|
||||
|
||||
private ExecutableInstruction.ExecutableInstructionCollection mvarInstructions = new ExecutableInstruction.ExecutableInstructionCollection();
|
||||
public ExecutableInstruction.ExecutableInstructionCollection Instructions { get { return mvarInstructions; } }
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Executable
|
||||
{
|
||||
public class ExecutableRelativeVirtualAddress : ICloneable
|
||||
{
|
||||
public class ExecutableRelativeVirtualAddressCollection
|
||||
: System.Collections.ObjectModel.Collection<ExecutableRelativeVirtualAddress>
|
||||
{
|
||||
}
|
||||
|
||||
private ushort mvarDataDirectoryVirtualAddress = 0;
|
||||
public ushort DataDirectoryVirtualAddress { get { return mvarDataDirectoryVirtualAddress; } set { mvarDataDirectoryVirtualAddress = value; } }
|
||||
|
||||
private ushort mvarDataDirectorySize = 0;
|
||||
public ushort DataDirectorySize { get { return mvarDataDirectorySize; } set { mvarDataDirectorySize = value; } }
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
ExecutableRelativeVirtualAddress rva = new ExecutableRelativeVirtualAddress();
|
||||
rva.DataDirectorySize = mvarDataDirectorySize;
|
||||
rva.DataDirectoryVirtualAddress = mvarDataDirectoryVirtualAddress;
|
||||
return rva;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Executable
|
||||
{
|
||||
public enum ExecutableResourceType
|
||||
{
|
||||
Custom = -1,
|
||||
// NewResource = 0x2000,
|
||||
// Error = 0x7fff,
|
||||
Cursor = 1,
|
||||
Bitmap =2,
|
||||
Icon = 3,
|
||||
Menu = 4,
|
||||
Dialog = 5,
|
||||
String =6,
|
||||
FontDir = 7,
|
||||
Font = 8,
|
||||
Accelerator = 9,
|
||||
RCData = 10,
|
||||
MessageTable = 11,
|
||||
GroupCursor = 12,
|
||||
GroupIcon = 14,
|
||||
Version = 16 // ,
|
||||
// NewBitmap = (Bitmap | NewResource),
|
||||
// NewMenu = (Menu | NewResource),
|
||||
// NewDialog = (Dialog | NewResource)
|
||||
}
|
||||
public abstract class ExecutableResourceBlock : ICloneable
|
||||
{
|
||||
public class ExecutableResourceBlockCollection
|
||||
: System.Collections.ObjectModel.Collection<ExecutableResourceBlock>
|
||||
{
|
||||
}
|
||||
|
||||
public abstract ExecutableResourceType Type { get; }
|
||||
|
||||
private int mvarID = 0;
|
||||
public int ID { get { return mvarID; } set { mvarID = value; } }
|
||||
|
||||
private string mvarName = String.Empty;
|
||||
public string Name { get { return mvarName; } set { mvarName = value; } }
|
||||
|
||||
public abstract object Clone();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,153 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Executable
|
||||
{
|
||||
public class ExecutableSection : ICloneable
|
||||
{
|
||||
public class ExecutableSectionCollection
|
||||
: System.Collections.ObjectModel.Collection<ExecutableSection>
|
||||
{
|
||||
private Dictionary<string, ExecutableSection> sectionsByName = new Dictionary<string, ExecutableSection>();
|
||||
|
||||
public ExecutableSection Add(string name, byte[] data)
|
||||
{
|
||||
ExecutableSection section = new ExecutableSection();
|
||||
section.Name = name;
|
||||
section.Data = data;
|
||||
Add(section);
|
||||
return section;
|
||||
}
|
||||
|
||||
public ExecutableSection this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (sectionsByName.ContainsKey(name))
|
||||
{
|
||||
return sectionsByName[name];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Contains(string name)
|
||||
{
|
||||
return sectionsByName.ContainsKey(name);
|
||||
}
|
||||
public bool Remove(string name)
|
||||
{
|
||||
ExecutableSection sect = this[name];
|
||||
if (sect != null)
|
||||
{
|
||||
Remove(sect);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
internal void UpdateSectionName(ExecutableSection item, string oldName)
|
||||
{
|
||||
sectionsByName.Remove(oldName);
|
||||
sectionsByName.Add(item.Name, item);
|
||||
}
|
||||
|
||||
protected override void InsertItem(int index, ExecutableSection item)
|
||||
{
|
||||
base.InsertItem(index, item);
|
||||
item.mvarParent = this;
|
||||
if (!sectionsByName.ContainsKey(item.Name))
|
||||
{
|
||||
sectionsByName.Add(item.Name, item);
|
||||
}
|
||||
}
|
||||
protected override void RemoveItem(int index)
|
||||
{
|
||||
string name = this[index].Name;
|
||||
if (sectionsByName.ContainsKey(name))
|
||||
{
|
||||
sectionsByName.Remove(name);
|
||||
}
|
||||
this[index].mvarParent = null;
|
||||
base.RemoveItem(index);
|
||||
}
|
||||
|
||||
|
||||
public void SaveAll(string Path)
|
||||
{
|
||||
foreach (ExecutableSection sect in this)
|
||||
{
|
||||
string FileName = Path + "_" + sect.Name;
|
||||
sect.Save(FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ExecutableSectionCollection mvarParent = null;
|
||||
|
||||
private string mvarName = String.Empty;
|
||||
public string Name
|
||||
{
|
||||
get { return mvarName; }
|
||||
set
|
||||
{
|
||||
string oldName = mvarName;
|
||||
mvarName = value;
|
||||
if (mvarParent != null)
|
||||
{
|
||||
mvarParent.UpdateSectionName(this, oldName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] mvarData = new byte[0];
|
||||
public byte[] Data { get { return mvarData; } set { mvarData = value; } }
|
||||
|
||||
private long mvarPhysicalAddress = 0;
|
||||
public long PhysicalAddress { get { return mvarPhysicalAddress; } set { mvarPhysicalAddress = value; } }
|
||||
|
||||
private long mvarVirtualAddress = 0;
|
||||
public long VirtualAddress { get { return mvarVirtualAddress; } set { mvarVirtualAddress = value; } }
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
ExecutableSection clone = new ExecutableSection();
|
||||
clone.Name = mvarName;
|
||||
clone.Data = (mvarData.Clone() as byte[]);
|
||||
return clone;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return mvarName + " (" + mvarCharacteristics.ToString() + "; " + mvarData.Length + " bytes)";
|
||||
}
|
||||
|
||||
private ExecutableSectionCharacteristics mvarCharacteristics = ExecutableSectionCharacteristics.None;
|
||||
public ExecutableSectionCharacteristics Characteristics { get { return mvarCharacteristics; } set { mvarCharacteristics = value; } }
|
||||
|
||||
public void Load(string FileName)
|
||||
{
|
||||
mvarData = System.IO.File.ReadAllBytes(FileName);
|
||||
}
|
||||
public void Save(string FileName)
|
||||
{
|
||||
System.IO.File.WriteAllBytes(FileName, mvarData);
|
||||
}
|
||||
|
||||
private uint mvarVirtualSize = 0;
|
||||
public uint VirtualSize { get { return mvarVirtualSize; } set { mvarVirtualSize = value; } }
|
||||
|
||||
private uint mvarRelocationOffset = 0;
|
||||
public uint RelocationOffset { get { return mvarRelocationOffset; } set { mvarRelocationOffset = value; } }
|
||||
|
||||
private uint mvarLineNumberOffset = 0;
|
||||
public uint LineNumberOffset { get { return mvarLineNumberOffset; } set { mvarLineNumberOffset = value; } }
|
||||
|
||||
private ushort mvarRelocationCount = 0;
|
||||
public ushort RelocationCount { get { return mvarRelocationCount; } set { mvarRelocationCount = value; } }
|
||||
|
||||
private ushort mvarLineNumberCount = 0;
|
||||
public ushort LineNumberCount { get { return mvarLineNumberCount; } set { mvarLineNumberCount = value; } }
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Executable
|
||||
{
|
||||
[Flags()]
|
||||
public enum ExecutableSectionCharacteristics : uint
|
||||
{
|
||||
None = 0x00000000,
|
||||
/// <summary>
|
||||
/// Reserved.
|
||||
/// </summary>
|
||||
TypeNoPad = 0x00000008,
|
||||
/// <summary>
|
||||
/// Section contains code.
|
||||
/// </summary>
|
||||
ContainsCode = 0x00000020,
|
||||
/// <summary>
|
||||
/// Section contains initialized data.
|
||||
/// </summary>
|
||||
ContainsInitializedData = 0x00000040,
|
||||
/// <summary>
|
||||
/// Section contains uninitialized data.
|
||||
/// </summary>
|
||||
ContainsUninitializedData = 0x00000080,
|
||||
/// <summary>
|
||||
/// Reserved.
|
||||
/// </summary>
|
||||
LinkOther = 0x00000100,
|
||||
/// <summary>
|
||||
/// Section contains comments or some other type of information.
|
||||
/// </summary>
|
||||
LinkInformation = 0x00000200,
|
||||
/// <summary>
|
||||
/// Section contents will not become part of image.
|
||||
/// </summary>
|
||||
LinkRemove = 0x00000800,
|
||||
/// <summary>
|
||||
/// Section contents comdat.
|
||||
/// </summary>
|
||||
LinkComdat = 0x00001000,
|
||||
/// <summary>
|
||||
/// Reset speculative exceptions handling bits in the TLB entries for this section.
|
||||
/// </summary>
|
||||
ResetSpeculativeExceptions = 0x00004000,
|
||||
/// <summary>
|
||||
/// Section content can be accessed relative to GP
|
||||
/// </summary>
|
||||
GPRelative = 0x00008000,
|
||||
MemoryFarData = 0x00008000,
|
||||
MemoryPurgeable = 0x00020000,
|
||||
Memory16Bit = 0x00020000,
|
||||
MemoryLocked = 0x00040000,
|
||||
MemoryPreload = 0x00080000,
|
||||
Align1Byte = 0x00100000,
|
||||
Align2Bytes = 0x00200000,
|
||||
Align4Bytes = 0x00300000,
|
||||
Align8Bytes = 0x00400000,
|
||||
/// <summary>
|
||||
/// Default alignment if no others are specified.
|
||||
/// </summary>
|
||||
Align16Bytes = 0x00500000,
|
||||
Align32Bytes = 0x00600000,
|
||||
Align64Bytes = 0x00700000,
|
||||
Align128Bytes = 0x00800000,
|
||||
Align256Bytes = 0x00900000,
|
||||
Align512Bytes = 0x00A00000,
|
||||
Align1024Bytes = 0x00B00000,
|
||||
Align2048Bytes = 0x00C00000,
|
||||
Align4096Bytes = 0x00D00000,
|
||||
Align8192Bytes = 0x00E00000,
|
||||
AlignMask = 0x00F00000,
|
||||
/// <summary>
|
||||
/// Section contains extended relocations.
|
||||
/// </summary>
|
||||
LinkExtendedRelocations = 0x01000000,
|
||||
/// <summary>
|
||||
/// Section can be discarded.
|
||||
/// </summary>
|
||||
MemoryDiscardable = 0x02000000,
|
||||
/// <summary>
|
||||
/// Section is not cachable.
|
||||
/// </summary>
|
||||
MemoryNotCached = 0x04000000,
|
||||
/// <summary>
|
||||
/// Section is not pageable.
|
||||
/// </summary>
|
||||
MemoryNotPaged = 0x08000000,
|
||||
/// <summary>
|
||||
/// Section is shareable.
|
||||
/// </summary>
|
||||
MemoryShared = 0x10000000,
|
||||
/// <summary>
|
||||
/// Section is executable.
|
||||
/// </summary>
|
||||
MemoryExecutable = 0x20000000,
|
||||
/// <summary>
|
||||
/// Section is readable.
|
||||
/// </summary>
|
||||
MemoryReadable = 0x40000000,
|
||||
/// <summary>
|
||||
/// Section is writeable.
|
||||
/// </summary>
|
||||
MemoryWritable = 0x80000000
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Executable
|
||||
{
|
||||
public enum ExecutableSubsystem : ushort
|
||||
{
|
||||
/// <summary>
|
||||
/// Unknown subsystem.
|
||||
/// </summary>
|
||||
Unknown = 0,
|
||||
/// <summary>
|
||||
/// No subsystem required (device drivers and native system processes).
|
||||
/// </summary>
|
||||
Native = 1,
|
||||
/// <summary>
|
||||
/// Windows graphical user interface (GUI) subsystem.
|
||||
/// </summary>
|
||||
WindowsGUI = 2,
|
||||
/// <summary>
|
||||
/// Windows character-mode user interface (CUI) subsystem.
|
||||
/// </summary>
|
||||
WindowsCUI = 3,
|
||||
/// <summary>
|
||||
/// OS/2 character-mode user interface (CUI) subsystem.
|
||||
/// </summary>
|
||||
OS2CUI = 5,
|
||||
/// <summary>
|
||||
/// POSIX character-mode user interface (CUI) subsystem.
|
||||
/// </summary>
|
||||
PosixCUI = 7,
|
||||
/// <summary>
|
||||
/// Windows CE system.
|
||||
/// </summary>
|
||||
WindowsCEGUI = 9,
|
||||
/// <summary>
|
||||
/// Extensible Firmware Interface (EFI) application.
|
||||
/// </summary>
|
||||
EFIApplication = 10,
|
||||
/// <summary>
|
||||
/// EFI driver with boot services.
|
||||
/// </summary>
|
||||
EFIBootServiceDriver = 11,
|
||||
/// <summary>
|
||||
/// EFI driver with run-time services.
|
||||
/// </summary>
|
||||
EFIRuntimeServiceDriver = 12,
|
||||
/// <summary>
|
||||
/// EFI ROM image.
|
||||
/// </summary>
|
||||
EFIROMImage = 13,
|
||||
/// <summary>
|
||||
/// Xbox system.
|
||||
/// </summary>
|
||||
Xbox = 14,
|
||||
/// <summary>
|
||||
/// Boot application
|
||||
/// </summary>
|
||||
WindowsBootApplication = 16
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Executable.Instructions
|
||||
{
|
||||
public class ExecutableInstructionCall<T> : ExecutableInstruction where T : struct, IComparable, IComparable<T>, IConvertible, IEquatable<T>, IFormattable
|
||||
{
|
||||
public override ExecutableInstructionOpcode OpCode
|
||||
{
|
||||
get { return ExecutableInstructionOpcode.Call; }
|
||||
}
|
||||
|
||||
private byte mvarExtra = 0;
|
||||
public byte Extra { get { return mvarExtra; } set { mvarExtra = value; } }
|
||||
|
||||
private T mvarAddress = default(T);
|
||||
/// <summary>
|
||||
/// The address of the next instruction to execute.
|
||||
/// </summary>
|
||||
public T Address { get { return mvarAddress; } set { mvarAddress = value; } }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "CALL 0x" + mvarAddress.ToString("X", null).PadLeft(2, '0');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Executable.Instructions
|
||||
{
|
||||
public class ExecutableInstructionPush<T> : ExecutableInstruction where T : struct, IComparable, IComparable<T>, IConvertible, IEquatable<T>, IFormattable
|
||||
{
|
||||
public override ExecutableInstructionOpcode OpCode
|
||||
{
|
||||
get { return ExecutableInstructionOpcode.PushByte; }
|
||||
}
|
||||
|
||||
private T mvarValue = default(T);
|
||||
/// <summary>
|
||||
/// The value to push onto the stack.
|
||||
/// </summary>
|
||||
public T Value { get { return mvarValue; } set { mvarValue = value; } }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "PUSH imm" + (System.Runtime.InteropServices.Marshal.SizeOf(mvarValue) * 8).ToString() + " 0x" + mvarValue.ToString("X", null).PadLeft(2, '0');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Executable.ResourceBlocks
|
||||
{
|
||||
public class CustomResourceBlock : ExecutableResourceBlock
|
||||
{
|
||||
private ExecutableResourceType mvarType = ExecutableResourceType.Custom;
|
||||
public override ExecutableResourceType Type
|
||||
{
|
||||
get { return mvarType; }
|
||||
}
|
||||
|
||||
private byte[] mvarData = new byte[0];
|
||||
public byte[] Data { get { return mvarData; } set { mvarData = value; } }
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
CustomResourceBlock clone = new CustomResourceBlock();
|
||||
clone.Data = (mvarData.Clone() as byte[]);
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Executable.ResourceBlocks
|
||||
{
|
||||
public class IconResourceBlock : ExecutableResourceBlock
|
||||
{
|
||||
public override ExecutableResourceType Type
|
||||
{
|
||||
get { return ExecutableResourceType.Icon; }
|
||||
}
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,361 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Executable.ResourceBlocks
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the general type of file.
|
||||
/// </summary>
|
||||
[Flags()]
|
||||
public enum VersionFileType : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// The file type is unknown to Windows.
|
||||
/// </summary>
|
||||
Unknown = 0x00000000,
|
||||
/// <summary>
|
||||
/// The file contains an application.
|
||||
/// </summary>
|
||||
Application = 0x00000001,
|
||||
/// <summary>
|
||||
/// The file contains a dynamic-link library (DLL).
|
||||
/// </summary>
|
||||
DynamicLinkLibrary = 0x00000002,
|
||||
/// <summary>
|
||||
/// The file contains a device driver. If dwFileType is VFT_DRV, dwFileSubtype contains a more specific description of the driver.
|
||||
/// </summary>
|
||||
DeviceDriver = 0x00000003,
|
||||
/// <summary>
|
||||
/// The file contains a font. If dwFileType is VFT_FONT, dwFileSubtype contains a more specific description of the font file.
|
||||
/// </summary>
|
||||
Font = 0x00000004,
|
||||
/// <summary>
|
||||
/// The file contains a virtual device driver.
|
||||
/// </summary>
|
||||
VirtualDeviceDriver = 0x00000005,
|
||||
/// <summary>
|
||||
/// Unknown purpose.
|
||||
/// </summary>
|
||||
Reserved = 0x00000006,
|
||||
/// <summary>
|
||||
/// The file contains a static-link library.
|
||||
/// </summary>
|
||||
StaticLibrary = 0x00000007
|
||||
}
|
||||
/// <summary>
|
||||
/// Specifies the function of the file. The possible values depend on the value of
|
||||
/// <see cref="FileType" />. If <see cref="FileType" /> is
|
||||
/// <see cref="VersionFileType.VirtualDeviceDriver" />, contains the virtual device identifier
|
||||
/// included in the virtual device control block.
|
||||
/// </summary>
|
||||
[Flags()]
|
||||
public enum VersionFileSubType : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// The driver or font type is unknown by Windows.
|
||||
/// </summary>
|
||||
Unknown = 0x00000000,
|
||||
/// <summary>
|
||||
/// The file contains a printer driver or a raster font.
|
||||
/// </summary>
|
||||
DriverPrinter = 0x00000001,
|
||||
/// <summary>
|
||||
/// The file contains a keyboard driver or a vector font.
|
||||
/// </summary>
|
||||
DriverKeyboard = 0x00000002,
|
||||
/// <summary>
|
||||
/// The file contains a language driver or a TrueType font.
|
||||
/// </summary>
|
||||
DriverLanguage = 0x00000003,
|
||||
/// <summary>
|
||||
/// The file contains a display driver.
|
||||
/// </summary>
|
||||
DriverDisplay = 0x00000004,
|
||||
/// <summary>
|
||||
/// The file contains a mouse driver.
|
||||
/// </summary>
|
||||
DriverMouse = 0x00000005,
|
||||
/// <summary>
|
||||
/// The file contains a network driver.
|
||||
/// </summary>
|
||||
DriverNetwork = 0x00000006,
|
||||
/// <summary>
|
||||
/// The file contains a system driver.
|
||||
/// </summary>
|
||||
DriverSystem = 0x00000007,
|
||||
/// <summary>
|
||||
/// The file contains an installable driver.
|
||||
/// </summary>
|
||||
DriverInstallable = 0x00000008,
|
||||
/// <summary>
|
||||
/// The file contains a sound driver.
|
||||
/// </summary>
|
||||
DriverSound = 0x00000009,
|
||||
/// <summary>
|
||||
/// The file contains a communications driver.
|
||||
/// </summary>
|
||||
DriverCommunications = 0x0000000A,
|
||||
/// <summary>
|
||||
/// The file contains an input method driver.
|
||||
/// </summary>
|
||||
DriverInputMethod = 0x0000000B,
|
||||
/// <summary>
|
||||
/// The file contains a versioned printer driver.
|
||||
/// </summary>
|
||||
DriverPrinterVersioned = 0x0000000C,
|
||||
/// <summary>
|
||||
/// The file contains a printer driver or a raster font.
|
||||
/// </summary>
|
||||
FontRaster = 0x00000001,
|
||||
/// <summary>
|
||||
/// The file contains a keyboard driver or a vector font.
|
||||
/// </summary>
|
||||
FontVector = 0x00000002,
|
||||
/// <summary>
|
||||
/// The file contains a language driver or a TrueType font.
|
||||
/// </summary>
|
||||
FontTrueType = 0x00000003
|
||||
}
|
||||
/// <summary>
|
||||
/// Specifies the operating system for which this file was designed.
|
||||
/// </summary>
|
||||
[Flags()]
|
||||
public enum VersionOperatingSystem : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// The operating system for which the file was designed is unknown to Windows.
|
||||
/// </summary>
|
||||
Unknown = 0x00000000,
|
||||
/// <summary>
|
||||
/// The file was designed for MS-DOS.
|
||||
/// </summary>
|
||||
DOS = 0x00010000,
|
||||
/// <summary>
|
||||
/// The file was designed for Windows NT.
|
||||
/// </summary>
|
||||
WindowsNT = 0x00040000,
|
||||
/// <summary>
|
||||
/// The file was designed for 16-bit Windows.
|
||||
/// </summary>
|
||||
Windows16 = 0x00000001,
|
||||
/// <summary>
|
||||
/// The file was designed for the Win32 API.
|
||||
/// </summary>
|
||||
Windows32 = 0x00000004,
|
||||
/// <summary>
|
||||
/// The file was designed for 16-bit OS/2.
|
||||
/// </summary>
|
||||
OS216 = 0x00020000,
|
||||
/// <summary>
|
||||
/// The file was designed for 32-bit OS/2.
|
||||
/// </summary>
|
||||
OS232 = 0x00030000,
|
||||
/// <summary>
|
||||
/// The file was designed for 16-bit Presentation Manager.
|
||||
/// </summary>
|
||||
PresentationManager16 = 0x00000002,
|
||||
/// <summary>
|
||||
/// The file was designed for 32-bit Presentation Manager.
|
||||
/// </summary>
|
||||
PresentationManager32 = 0x00000003
|
||||
}
|
||||
/// <summary>
|
||||
/// Contains a bitmask that specifies the Boolean attributes of the file.
|
||||
/// </summary>
|
||||
[Flags()]
|
||||
public enum VersionFileAttributes : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// The file has no version flags set.
|
||||
/// </summary>
|
||||
None = 0x00,
|
||||
/// <summary>
|
||||
/// The file contains debugging information or is compiled with debugging features enabled.
|
||||
/// </summary>
|
||||
DebugMode = 0x01,
|
||||
/// <summary>
|
||||
/// The file has been modified and is not identical to the original shipping file of the same
|
||||
/// version number.
|
||||
/// </summary>
|
||||
Patched = 0x04,
|
||||
/// <summary>
|
||||
/// The file is a development version, not a commercially released product.
|
||||
/// </summary>
|
||||
PreRelease = 0x02,
|
||||
/// <summary>
|
||||
/// The file was not built using standard release procedures. If this flag is set, the
|
||||
/// StringFileInfo structure should contain a PrivateBuild entry.
|
||||
/// </summary>
|
||||
PrivateBuild = 0x08,
|
||||
/// <summary>
|
||||
/// The file's version structure was created dynamically; therefore, some of the members in
|
||||
/// this structure may be empty or incorrect. This flag should never be set in a file's
|
||||
/// VS_VERSION_INFO data.
|
||||
/// </summary>
|
||||
InformationInferred = 0x10,
|
||||
/// <summary>
|
||||
/// The file was built by the original company using standard release procedures but is a variation
|
||||
/// of the normal file of the same version number. If this flag is set, the StringFileInfo structure
|
||||
/// should contain a SpecialBuild entry.
|
||||
/// </summary>
|
||||
SpecialBuild = 0x20
|
||||
}
|
||||
|
||||
public abstract class VersionResourceChildBlock
|
||||
{
|
||||
public class VersionResourceChildBlockCollection
|
||||
: System.Collections.ObjectModel.Collection<VersionResourceChildBlock>
|
||||
{
|
||||
}
|
||||
}
|
||||
public class VersionResourceFixedFileInfoBlock
|
||||
{
|
||||
private bool mvarEnabled = true;
|
||||
public bool Enabled { get { return mvarEnabled; } set { mvarEnabled = value; } }
|
||||
|
||||
private Version mvarStructureVersion = new Version();
|
||||
public Version StructureVersion { get { return mvarStructureVersion; } set { mvarStructureVersion = value; } }
|
||||
|
||||
private Version mvarFileVersion = new Version();
|
||||
public Version FileVersion { get { return mvarFileVersion; } set { mvarFileVersion = value; } }
|
||||
|
||||
private Version mvarProductVersion = new Version();
|
||||
public Version ProductVersion { get { return mvarProductVersion; } set { mvarProductVersion = value; } }
|
||||
|
||||
private VersionFileAttributes mvarFileAttributes = VersionFileAttributes.None;
|
||||
/// <summary>
|
||||
/// Contains a bitmask that specifies the Boolean attributes of the file.
|
||||
/// </summary>
|
||||
public VersionFileAttributes FileAttributes { get { return mvarFileAttributes; } set { mvarFileAttributes = value; } }
|
||||
|
||||
private VersionFileAttributes mvarValidFileAttributes = VersionFileAttributes.None;
|
||||
/// <summary>
|
||||
/// Contains a bitmask that specifies the valid Boolean attributes of the file. An attribute is valid only if it was defined when the file was created.
|
||||
/// </summary>
|
||||
public VersionFileAttributes ValidFileAttributes { get { return mvarValidFileAttributes; } set { mvarValidFileAttributes = value; } }
|
||||
|
||||
private VersionOperatingSystem mvarOperatingSystem = VersionOperatingSystem.Unknown;
|
||||
/// <summary>
|
||||
/// Specifies the operating system for which this file was designed.
|
||||
/// </summary>
|
||||
public VersionOperatingSystem OperatingSystem { get { return mvarOperatingSystem; } set { mvarOperatingSystem = value; } }
|
||||
|
||||
private VersionFileType mvarFileType = VersionFileType.Unknown;
|
||||
/// <summary>
|
||||
/// Specifies the general type of file.
|
||||
/// </summary>
|
||||
public VersionFileType FileType { get { return mvarFileType; } set { mvarFileType = value; } }
|
||||
|
||||
private VersionFileSubType mvarFileSubType = VersionFileSubType.Unknown;
|
||||
/// <summary>
|
||||
/// Specifies the function of the file. The possible values depend on the value of
|
||||
/// <see cref="FileType" />. If <see cref="FileType" /> is
|
||||
/// <see cref="VersionFileType.VirtualDeviceDriver" />, contains the virtual device identifier
|
||||
/// included in the virtual device control block.
|
||||
/// </summary>
|
||||
public VersionFileSubType FileSubType { get { return mvarFileSubType; } set { mvarFileSubType = value; } }
|
||||
|
||||
private DateTime mvarFileDate = DateTime.Now;
|
||||
public DateTime FileDate { get { return mvarFileDate; } set { mvarFileDate = value; } }
|
||||
}
|
||||
|
||||
public class VersionResourceStringFileInfoBlockLanguage
|
||||
{
|
||||
public class VersionResourceStringFileInfoBlockEntryCollection
|
||||
: System.Collections.ObjectModel.Collection<VersionResourceStringFileInfoBlockLanguage>
|
||||
{
|
||||
}
|
||||
|
||||
private int mvarLanguageID = 0;
|
||||
public int LanguageID { get { return mvarLanguageID; } set { mvarLanguageID = value; } }
|
||||
|
||||
private VersionResourceStringTableEntry.VersionResourceStringTableEntryCollection mvarStringTableEntries = new VersionResourceStringTableEntry.VersionResourceStringTableEntryCollection();
|
||||
public VersionResourceStringTableEntry.VersionResourceStringTableEntryCollection StringTableEntries { get { return mvarStringTableEntries; } }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "0x" + mvarLanguageID.ToString("x");
|
||||
}
|
||||
}
|
||||
public class VersionResourceStringTableEntry
|
||||
{
|
||||
public class VersionResourceStringTableEntryCollection
|
||||
: System.Collections.ObjectModel.Collection<VersionResourceStringTableEntry>
|
||||
{
|
||||
}
|
||||
|
||||
private string mvarName = String.Empty;
|
||||
public string Name { get { return mvarName; } set { mvarName = value; } }
|
||||
|
||||
private string mvarValue = String.Empty;
|
||||
public string Value { get { return mvarValue; } set { mvarValue = value; } }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return mvarName + ": \"" + mvarValue + "\"";
|
||||
}
|
||||
}
|
||||
|
||||
public class VersionResourceStringFileInfoBlock : VersionResourceChildBlock
|
||||
{
|
||||
private VersionResourceStringFileInfoBlockLanguage.VersionResourceStringFileInfoBlockEntryCollection mvarEntries = new VersionResourceStringFileInfoBlockLanguage.VersionResourceStringFileInfoBlockEntryCollection();
|
||||
public VersionResourceStringFileInfoBlockLanguage.VersionResourceStringFileInfoBlockEntryCollection Entries { get { return mvarEntries; } }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "StringFileInfo";
|
||||
}
|
||||
}
|
||||
|
||||
public class VersionResourceVarFileInfoBlockEntry
|
||||
{
|
||||
public class VersionResourceVarFileInfoBlockEntryCollection
|
||||
: System.Collections.ObjectModel.Collection<VersionResourceVarFileInfoBlockEntry>
|
||||
{
|
||||
}
|
||||
|
||||
private List<int> mvarValues = new List<int>();
|
||||
public List<int> Values { get { return mvarValues; } }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Translation";
|
||||
}
|
||||
}
|
||||
public class VersionResourceVarFileInfoBlock : VersionResourceChildBlock
|
||||
{
|
||||
private VersionResourceVarFileInfoBlockEntry.VersionResourceVarFileInfoBlockEntryCollection mvarEntries = new VersionResourceVarFileInfoBlockEntry.VersionResourceVarFileInfoBlockEntryCollection();
|
||||
public VersionResourceVarFileInfoBlockEntry.VersionResourceVarFileInfoBlockEntryCollection Entries { get { return mvarEntries; } }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "VarFileInfo";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a Version resource in an executable file (VS_VERSION_INFO on Windows).
|
||||
/// </summary>
|
||||
public class VersionResourceBlock : ExecutableResourceBlock
|
||||
{
|
||||
private ExecutableResourceType mvarType = ExecutableResourceType.Version;
|
||||
public override ExecutableResourceType Type
|
||||
{
|
||||
get { return mvarType; }
|
||||
}
|
||||
|
||||
private VersionResourceFixedFileInfoBlock mvarFixedFileInfo = new VersionResourceFixedFileInfoBlock();
|
||||
public VersionResourceFixedFileInfoBlock FixedFileInfo { get { return mvarFixedFileInfo; } }
|
||||
|
||||
private VersionResourceChildBlock.VersionResourceChildBlockCollection mvarChildBlocks = new VersionResourceChildBlock.VersionResourceChildBlockCollection();
|
||||
public VersionResourceChildBlock.VersionResourceChildBlockCollection ChildBlocks { get { return mvarChildBlocks; } }
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
VersionResourceBlock clone = new VersionResourceBlock();
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("UniversalEditor.Plugins.Executable")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("City of Orlando")]
|
||||
[assembly: AssemblyProduct("UniversalEditor.Plugins.Executable")]
|
||||
[assembly: AssemblyCopyright("Copyright © City of Orlando 2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("8fe9f020-8602-426c-b05e-7edabe3f3dd0")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{791A36F8-5D96-452B-89D2-78BA74596A1E}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>UniversalEditor</RootNamespace>
|
||||
<AssemblyName>UniversalEditor.Plugins.Executable</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\Output\Debug\Plugins\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\Output\Release\Plugins\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DataFormats\Executable\ELF\ELFCapacity.cs" />
|
||||
<Compile Include="DataFormats\Executable\ELF\ELFDataFormat.cs" />
|
||||
<Compile Include="DataFormats\Executable\ELF\ELFEncoding.cs" />
|
||||
<Compile Include="DataFormats\Executable\ELF\ELFMachine.cs" />
|
||||
<Compile Include="DataFormats\Executable\ELF\ELFObjectFileType.cs" />
|
||||
<Compile Include="DataFormats\Executable\ELF\ELFSectionFlags.cs" />
|
||||
<Compile Include="DataFormats\Executable\ELF\ELFSectionType.cs" />
|
||||
<Compile Include="DataFormats\Executable\ELF\ELFSpecialSectionIndex.cs" />
|
||||
<Compile Include="ObjectModels\Executable\ExecutableCharacteristics.cs" />
|
||||
<Compile Include="ObjectModels\Executable\ExecutableFunctionCall.cs" />
|
||||
<Compile Include="ObjectModels\Executable\ExecutableInstruction.cs" />
|
||||
<Compile Include="ObjectModels\Executable\ExecutableLibraryCharacteristics.cs" />
|
||||
<Compile Include="ObjectModels\Executable\ExecutableLibraryReference.cs" />
|
||||
<Compile Include="ObjectModels\Executable\ExecutableLoaderFlags.cs" />
|
||||
<Compile Include="ObjectModels\Executable\ExecutableMachine.cs" />
|
||||
<Compile Include="ObjectModels\Executable\ExecutableObjectModel.cs" />
|
||||
<Compile Include="ObjectModels\Executable\ExecutableRelativeVirtualAddress.cs" />
|
||||
<Compile Include="ObjectModels\Executable\ExecutableSection.cs" />
|
||||
<Compile Include="ObjectModels\Executable\ExecutableSectionCharacteristics.cs" />
|
||||
<Compile Include="ObjectModels\Executable\ExecutableSubsystem.cs" />
|
||||
<Compile Include="ObjectModels\Executable\Instructions\ExecutableInstructionCall.cs" />
|
||||
<Compile Include="ObjectModels\Executable\Instructions\ExecutableInstructionPush.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Libraries\UniversalEditor.Core\UniversalEditor.Core.csproj">
|
||||
<Project>{a92d520b-ffa3-4464-8cf6-474d18959e03}</Project>
|
||||
<Name>UniversalEditor.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\UniversalEditor.Essential\UniversalEditor.Essential.csproj">
|
||||
<Project>{30467e5c-05bc-4856-aadc-13906ef4cadd}</Project>
|
||||
<Name>UniversalEditor.Essential</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
Loading…
x
Reference in New Issue
Block a user