Added RelocatableObject data format (incomplete)
This commit is contained in:
parent
38d2f09461
commit
f3644b32f8
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<UniversalEditor Version="4.0">
|
||||
<Associations>
|
||||
<Association>
|
||||
<Filters>
|
||||
<Filter Title="Relocatable Object executable">
|
||||
<FileNameFilters>
|
||||
<FileNameFilter>*.obj</FileNameFilter>
|
||||
</FileNameFilters>
|
||||
</Filter>
|
||||
</Filters>
|
||||
<ObjectModels>
|
||||
<ObjectModel TypeName="UniversalEditor.ObjectModels.Executable.ExecutableObjectModel" />
|
||||
</ObjectModels>
|
||||
<DataFormats>
|
||||
<DataFormat TypeName="UniversalEditor.DataFormats.Executable.RelocatableObject.OBJDataFormat" />
|
||||
</DataFormats>
|
||||
</Association>
|
||||
</Associations>
|
||||
</UniversalEditor>
|
||||
@ -667,6 +667,9 @@
|
||||
<ItemGroup>
|
||||
<Content Include="Extensions\SoftwareDeveloper\Associations\ExecutableObjectModel\MZ.uexml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Extensions\SoftwareDeveloper\Associations\ExecutableObjectModel\RelocatableObject.uexml" />
|
||||
</ItemGroup>
|
||||
<Target Name="Build">
|
||||
<Copy SourceFiles="@(Content)" DestinationFiles="@(Content->'$(OutputPath)%(RelativeDir)%(Filename)%(Extension)')" />
|
||||
</Target>
|
||||
|
||||
@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UniversalEditor.IO;
|
||||
using UniversalEditor.ObjectModels.Executable;
|
||||
|
||||
namespace UniversalEditor.DataFormats.Executable.RelocatableObject
|
||||
{
|
||||
public class OBJDataFormat : DataFormat
|
||||
{
|
||||
private static DataFormatReference _dfr = null;
|
||||
protected override DataFormatReference MakeReferenceInternal()
|
||||
{
|
||||
if (_dfr == null)
|
||||
{
|
||||
_dfr = base.MakeReferenceInternal();
|
||||
_dfr.Capabilities.Add(typeof(ExecutableObjectModel), DataFormatCapabilities.All);
|
||||
}
|
||||
return _dfr;
|
||||
}
|
||||
|
||||
protected override void LoadInternal(ref ObjectModel objectModel)
|
||||
{
|
||||
ExecutableObjectModel exe = (objectModel as ExecutableObjectModel);
|
||||
if (exe == null) throw new ObjectModelNotSupportedException();
|
||||
|
||||
Reader reader = base.Accessor.Reader;
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
OBJRecordType recordType = (OBJRecordType)reader.ReadByte();
|
||||
ushort dataLength = reader.ReadUInt16();
|
||||
byte[] data = reader.ReadBytes(dataLength);
|
||||
byte checksum = reader.ReadByte();
|
||||
|
||||
switch (recordType)
|
||||
{
|
||||
case OBJRecordType.CodeDataText0xA0:
|
||||
case OBJRecordType.CodeDataText0xA1:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case OBJRecordType.Comment:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case OBJRecordType.CommonDataInitialized0xC2:
|
||||
case OBJRecordType.CommonDataInitialized0xC3:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case OBJRecordType.CommonDataUninitialized:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case OBJRecordType.ExternalReference:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case OBJRecordType.ExternalSymbols0x90:
|
||||
case OBJRecordType.ExternalSymbols0x91:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case OBJRecordType.ModuleEnd0x8A:
|
||||
case OBJRecordType.ModuleEnd0x8B:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case OBJRecordType.Relocation0x9C:
|
||||
case OBJRecordType.Relocation0x9D:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case OBJRecordType.Segment0x98:
|
||||
case OBJRecordType.Segment0x99:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case OBJRecordType.SegmentGroup:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SaveInternal(ObjectModel objectModel)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.DataFormats.Executable.RelocatableObject
|
||||
{
|
||||
public enum OBJRecordType : byte
|
||||
{
|
||||
Comment = 0x88,
|
||||
|
||||
ExternalReference = 0x8C,
|
||||
|
||||
ExternalSymbols0x90 = 0x90,
|
||||
ExternalSymbols0x91 = 0x91,
|
||||
|
||||
Segment0x98 = 0x98,
|
||||
Segment0x99 = 0x99,
|
||||
|
||||
SegmentGroup = 0x9A,
|
||||
|
||||
Relocation0x9C = 0x9C,
|
||||
Relocation0x9D = 0x9D,
|
||||
|
||||
CodeDataText0xA0 = 0xA0,
|
||||
CodeDataText0xA1 = 0xA1,
|
||||
|
||||
CommonDataUninitialized = 0xB0,
|
||||
|
||||
CommonDataInitialized0xC2 = 0xC2,
|
||||
CommonDataInitialized0xC3 = 0xC3,
|
||||
|
||||
ModuleEnd0x8A = 0x8A,
|
||||
ModuleEnd0x8B = 0x8B
|
||||
}
|
||||
}
|
||||
@ -60,6 +60,8 @@
|
||||
<Compile Include="DataFormats\Executable\Microsoft\PEOptionalHeader.cs" />
|
||||
<Compile Include="DataFormats\Executable\Microsoft\PESectionCharacteristics.cs" />
|
||||
<Compile Include="DataFormats\Executable\Microsoft\PESectionHeader.cs" />
|
||||
<Compile Include="DataFormats\Executable\RelocatableObject\OBJDataFormat.cs" />
|
||||
<Compile Include="DataFormats\Executable\RelocatableObject\OBJRecordType.cs" />
|
||||
<Compile Include="ObjectModels\Executable\ExecutableCharacteristics.cs" />
|
||||
<Compile Include="ObjectModels\Executable\ExecutableFunctionCall.cs" />
|
||||
<Compile Include="ObjectModels\Executable\ExecutableInstruction.cs" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user