Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@628 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
70 changed files with 6076 additions and 0 deletions
@ -0,0 +1,6 @@ |
|||||||
|
Microsoft Visual Studio Solution File, Format Version 9.00 |
||||||
|
# SharpDevelop 2.0.0.568 |
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpAssembly", "Project\ICSharpCode.SharpAssembly.csproj", "{C70406A5-25B5-4A2B-898A-B1338652F7F0}" |
||||||
|
EndProject |
||||||
|
Global |
||||||
|
EndGlobal |
||||||
@ -0,0 +1,38 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System.Reflection; |
||||||
|
using System.Runtime.CompilerServices; |
||||||
|
|
||||||
|
// Information about this assembly is defined by the following
|
||||||
|
// attributes.
|
||||||
|
//
|
||||||
|
// change them to the information which is associated with the assembly
|
||||||
|
// you compile.
|
||||||
|
|
||||||
|
[assembly: AssemblyTitle("ICSharpCode.SharpAssembly")] |
||||||
|
[assembly: AssemblyDescription("CLI Assembly Reader library")] |
||||||
|
[assembly: AssemblyConfiguration("")] |
||||||
|
[assembly: AssemblyCompany("www.icsharpcode.net")] |
||||||
|
[assembly: AssemblyProduct("")] |
||||||
|
[assembly: AssemblyCopyright("(C) 2003 by Mike Krueger released as GPL")] |
||||||
|
[assembly: AssemblyTrademark("")] |
||||||
|
[assembly: AssemblyCulture("")] |
||||||
|
|
||||||
|
// The assembly version has following format :
|
||||||
|
//
|
||||||
|
// Major.Minor.Build.Revision
|
||||||
|
//
|
||||||
|
// You can specify all values by your own or you can build default build and revision
|
||||||
|
// numbers with the '*' character (the default):
|
||||||
|
|
||||||
|
[assembly: AssemblyVersion("1.1.0.2094")] |
||||||
|
|
||||||
|
// The following attributes specify the key for the sign of your assembly. See the
|
||||||
|
// .NET Framework documentation for more information about signing.
|
||||||
|
// This is not required, if you don't want signing let these attributes like they're.
|
||||||
|
[assembly: AssemblyDelaySign(false)] |
||||||
@ -0,0 +1,29 @@ |
|||||||
|
SharpAssembly 1.0 |
||||||
|
----------------- |
||||||
|
|
||||||
|
This is the first release of my Assembly reading library. |
||||||
|
I was tired of the System.Reflection capabilities (locking assemblies, |
||||||
|
app domain troubles no access to method body IL stream etc.) therefore |
||||||
|
I've decided to do it on my own. |
||||||
|
|
||||||
|
And here it is ... my first release of the library. I assume that you |
||||||
|
should play a bit with it and read following docs: |
||||||
|
|
||||||
|
Tool Developers Guide/docs/Partition I Architecture.doc |
||||||
|
Tool Developers Guide/docs/Partition II Metadata.doc |
||||||
|
Tool Developers Guide/docs/Partition III CIL.doc |
||||||
|
|
||||||
|
These can be found inside the SDK distribution. |
||||||
|
|
||||||
|
Feel free to send comments/suggestions/code changes to: |
||||||
|
mike@icsharpcode.net |
||||||
|
|
||||||
|
Building |
||||||
|
-------- |
||||||
|
You need SharpDevelop to build this library. You can get it from: |
||||||
|
www.icsharpcode.net/OpenSource/SD |
||||||
|
|
||||||
|
License |
||||||
|
------- |
||||||
|
Released under GNU LGPL see lgpl.txt for details |
||||||
|
(or http://www.gnu.org/licenses/lgpl.html) |
||||||
@ -0,0 +1,115 @@ |
|||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||||
|
<PropertyGroup> |
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||||
|
<SchemaVersion>2.0</SchemaVersion> |
||||||
|
<ProjectGuid>{C70406A5-25B5-4A2B-898A-B1338652F7F0}</ProjectGuid> |
||||||
|
<RootNamespace>NewProject</RootNamespace> |
||||||
|
<AssemblyName>ICSharpCode.SharpAssembly</AssemblyName> |
||||||
|
<OutputType>Library</OutputType> |
||||||
|
<WarningLevel>4</WarningLevel> |
||||||
|
<NoStdLib>False</NoStdLib> |
||||||
|
<NoConfig>False</NoConfig> |
||||||
|
<RunPostBuildEvent>OnSuccessfulBuild</RunPostBuildEvent> |
||||||
|
<DebugType>None</DebugType> |
||||||
|
<RegisterForComInterop>False</RegisterForComInterop> |
||||||
|
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||||
|
<BaseAddress>4194304</BaseAddress> |
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget> |
||||||
|
<FileAlignment>4096</FileAlignment> |
||||||
|
<SignAssembly>True</SignAssembly> |
||||||
|
<AssemblyOriginatorKeyFile>ICSharpCode.SharpAssembly.key</AssemblyOriginatorKeyFile> |
||||||
|
<DelaySign>False</DelaySign> |
||||||
|
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||||
|
<DebugSymbols>false</DebugSymbols> |
||||||
|
<Optimize>True</Optimize> |
||||||
|
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||||
|
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||||
|
<OutputPath>..\..\..\..\bin\</OutputPath> |
||||||
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||||
|
<DebugSymbols>False</DebugSymbols> |
||||||
|
<Optimize>True</Optimize> |
||||||
|
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||||
|
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||||
|
<OutputPath>..\..\..\..\..\bin\</OutputPath> |
||||||
|
<TreatWarningsAsErrors>True</TreatWarningsAsErrors> |
||||||
|
</PropertyGroup> |
||||||
|
<ItemGroup> |
||||||
|
<Reference Include="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> |
||||||
|
<Reference Include="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> |
||||||
|
<Reference Include="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<Compile Include="Configuration\AssemblyInfo.cs" /> |
||||||
|
<Compile Include="Src\Metadata\MethodBody.cs" /> |
||||||
|
<Compile Include="Src\Metadata\AssemblyMetaData.cs" /> |
||||||
|
<Compile Include="Src\Metadata\MetadataTable.cs" /> |
||||||
|
<Compile Include="Src\PE\StreamHeader.cs" /> |
||||||
|
<Compile Include="Src\PE\CLIHeader.cs" /> |
||||||
|
<Compile Include="Src\PE\DataDirectories.cs" /> |
||||||
|
<Compile Include="Src\PE\IAT.cs" /> |
||||||
|
<Compile Include="Src\PE\ImportTable.cs" /> |
||||||
|
<Compile Include="Src\PE\NameTable.cs" /> |
||||||
|
<Compile Include="Src\PE\NTSpecificFields.cs" /> |
||||||
|
<Compile Include="Src\PE\PEFileHeader.cs" /> |
||||||
|
<Compile Include="Src\PE\SectionTable.cs" /> |
||||||
|
<Compile Include="Src\PE\StandardFields.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\TypeSpec.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\AbstractRow.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\Assembly.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\AssemblyOS.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\AssemblyProcessor.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\AssemblyRef.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\AssemblyRefOS.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\AssemblyRefProcessor.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\ClassLayout.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\CodedIndex.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\Constant.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\CustomAttribute.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\DeclSecurity.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\ENCLog.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\ENCMap.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\Event.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\EventMap.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\EventPtr.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\ExportedType.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\Field.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\FieldLayout.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\FieldMarshal.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\FieldPtr.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\FieldRVA.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\File.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\ImplMap.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\InterfaceImpl.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\ManifestResource.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\MemberRef.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\Method.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\MethodImpl.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\MethodPtr.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\MethodSemantics.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\Module.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\ModuleRef.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\NestedClass.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\Param.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\ParamPtr.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\Property.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\PropertyMap.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\PropertyPtr.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\StandAloneSig.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\TypeDef.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Rows\TypeRef.cs" /> |
||||||
|
<Compile Include="Src\AssemblyMetadataTables.cs" /> |
||||||
|
<Compile Include="Src\AssemblyNameNotFoundException.cs" /> |
||||||
|
<Compile Include="Src\AssemblyReader.cs" /> |
||||||
|
<Compile Include="Src\FusionNative.cs" /> |
||||||
|
<Compile Include="Src\SharpAssembly.cs" /> |
||||||
|
<Compile Include="Src\SharpAssemblyName.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Signatures\CallingConventions.cs" /> |
||||||
|
<Compile Include="Src\Metadata\Signatures\DataTypes.cs" /> |
||||||
|
</ItemGroup> |
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||||
|
</Project> |
||||||
Binary file not shown.
@ -0,0 +1,223 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.SharpAssembly.Metadata; |
||||||
|
using ICSharpCode.SharpAssembly.Metadata.Rows; |
||||||
|
using MDRows = ICSharpCode.SharpAssembly.Metadata.Rows; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Assembly |
||||||
|
{ |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Contains shortcuts to commonly used tables
|
||||||
|
/// </summary>
|
||||||
|
public class MetadataTables : object { |
||||||
|
|
||||||
|
AssemblyReader reader; |
||||||
|
|
||||||
|
public MetadataTables(AssemblyReader Reader) { |
||||||
|
reader = Reader; |
||||||
|
} |
||||||
|
|
||||||
|
// Shortcuts for commonly used tables
|
||||||
|
|
||||||
|
public MDRows.Assembly[] Assembly { |
||||||
|
get { |
||||||
|
return (MDRows.Assembly[])reader.MetadataTable.Tables[MDRows.Assembly.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public AssemblyRef[] AssemblyRef { |
||||||
|
get { |
||||||
|
return (AssemblyRef[])reader.MetadataTable.Tables[MDRows.AssemblyRef.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public ClassLayout[] ClassLayout { |
||||||
|
get { |
||||||
|
return (ClassLayout[])reader.MetadataTable.Tables[MDRows.ClassLayout.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public Constant[] Constant { |
||||||
|
get { |
||||||
|
return (Constant[])reader.MetadataTable.Tables[MDRows.Constant.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public CustomAttribute[] CustomAttribute { |
||||||
|
get { |
||||||
|
return (CustomAttribute[])reader.MetadataTable.Tables[MDRows.CustomAttribute.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public DeclSecurity[] DeclSecurity { |
||||||
|
get { |
||||||
|
return (DeclSecurity[])reader.MetadataTable.Tables[MDRows.DeclSecurity.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public Event[] Event { |
||||||
|
get { |
||||||
|
return (Event[])reader.MetadataTable.Tables[MDRows.Event.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public EventMap[] EventMap { |
||||||
|
get { |
||||||
|
return (EventMap[])reader.MetadataTable.Tables[MDRows.EventMap.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public EventPtr[] EventPtr { |
||||||
|
get { |
||||||
|
return (EventPtr[])reader.MetadataTable.Tables[MDRows.EventPtr.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
/* |
||||||
|
public ExportedType[] ExportedType { |
||||||
|
get { |
||||||
|
return (ExportedType[])reader.MetadataTable.Tables[MDRows.ExportedType.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
*/ |
||||||
|
public Field[] Field { |
||||||
|
get { |
||||||
|
return (Field[])reader.MetadataTable.Tables[MDRows.Field.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public FieldLayout[] FieldLayout { |
||||||
|
get { |
||||||
|
return (FieldLayout[])reader.MetadataTable.Tables[MDRows.FieldLayout.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
/* |
||||||
|
public FieldMarshal[] FieldMarshal { |
||||||
|
get { |
||||||
|
return (FieldMarshal[])reader.MetadataTable.Tables[MDRows.FieldMarshal.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
*/ |
||||||
|
public FieldRVA[] FieldRVA { |
||||||
|
get { |
||||||
|
return (FieldRVA[])reader.MetadataTable.Tables[MDRows.FieldRVA.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public MDRows.File[] File { |
||||||
|
get { |
||||||
|
return (MDRows.File[])reader.MetadataTable.Tables[MDRows.File.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public ImplMap[] ImplMap { |
||||||
|
get { |
||||||
|
return (ImplMap[])reader.MetadataTable.Tables[MDRows.ImplMap.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public InterfaceImpl[] InterfaceImpl { |
||||||
|
get { |
||||||
|
return (InterfaceImpl[])reader.MetadataTable.Tables[MDRows.InterfaceImpl.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public ManifestResource[] ManifestResource { |
||||||
|
get { |
||||||
|
return (ManifestResource[])reader.MetadataTable.Tables[MDRows.ManifestResource.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public MemberRef[] MemberRef { |
||||||
|
get { |
||||||
|
return (MemberRef[])reader.MetadataTable.Tables[MDRows.MemberRef.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public Method[] Method { |
||||||
|
get { |
||||||
|
return (Method[])reader.MetadataTable.Tables[MDRows.Method.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public MethodImpl[] MethodImpl { |
||||||
|
get { |
||||||
|
return (MethodImpl[])reader.MetadataTable.Tables[MDRows.MethodImpl.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public MethodSemantics[] MethodSemantics { |
||||||
|
get { |
||||||
|
return (MethodSemantics[])reader.MetadataTable.Tables[MDRows.MethodSemantics.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
/* |
||||||
|
public MDRows.Module[] Module { |
||||||
|
get { |
||||||
|
return (MDRows.Module[])reader.MetadataTable.Tables[MDRows.MDRows.Module.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public ModuleRef[] ModuleRefTable { |
||||||
|
get { |
||||||
|
return (ModuleRef[])reader.MetadataTable.Tables[MDRows.ModuleRef.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
*/ |
||||||
|
public NestedClass[] NestedClass { |
||||||
|
get { |
||||||
|
return (NestedClass[])reader.MetadataTable.Tables[MDRows.NestedClass.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public Param[] Param { |
||||||
|
get { |
||||||
|
return (Param[])reader.MetadataTable.Tables[MDRows.Param.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public Property[] Property { |
||||||
|
get { |
||||||
|
return (Property[])reader.MetadataTable.Tables[MDRows.Property.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public PropertyMap[] PropertyMap { |
||||||
|
get { |
||||||
|
return (PropertyMap[])reader.MetadataTable.Tables[MDRows.PropertyMap.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public StandAloneSig[] StandAloneSig { |
||||||
|
get { |
||||||
|
return (StandAloneSig[])reader.MetadataTable.Tables[MDRows.StandAloneSig.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public TypeDef[] TypeDef { |
||||||
|
get { |
||||||
|
return (TypeDef[])reader.MetadataTable.Tables[MDRows.TypeDef.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public TypeRef[] TypeRef { |
||||||
|
get { |
||||||
|
return (TypeRef[])reader.MetadataTable.Tables[MDRows.TypeRef.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public TypeSpec[] TypeSpec { |
||||||
|
get { |
||||||
|
return (TypeSpec[])reader.MetadataTable.Tables[MDRows.TypeSpec.TABLE_ID]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,21 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Assembly |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Is thrown when the given assembly name could not be found.
|
||||||
|
/// </summary>
|
||||||
|
public class AssemblyNameNotFoundException : Exception |
||||||
|
{ |
||||||
|
public AssemblyNameNotFoundException(string name) : base("Could not find assembly named " + name + " in the Global Assembly Cache.") |
||||||
|
{ |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,294 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections; |
||||||
|
//using System.Collections.Specialized;
|
||||||
|
using System.Reflection; |
||||||
|
using System.IO; |
||||||
|
using ICSharpCode.SharpAssembly.Metadata.Rows; |
||||||
|
using ICSharpCode.SharpAssembly.Metadata; |
||||||
|
using ICSharpCode.SharpAssembly.PE; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Assembly { |
||||||
|
|
||||||
|
public class AssemblyReader |
||||||
|
{ |
||||||
|
PEFileHeader header; |
||||||
|
CLIHeader cliHeader; |
||||||
|
SectionTable[] sections; |
||||||
|
MetadataTable metadataTable = new MetadataTable(); |
||||||
|
|
||||||
|
byte[] stringHeap; |
||||||
|
byte[] userStringHeap; |
||||||
|
byte[] guidHeap; |
||||||
|
byte[] blobHeap; |
||||||
|
byte[] rawSectionData; |
||||||
|
|
||||||
|
string filename; |
||||||
|
|
||||||
|
public PEFileHeader PEHeader { |
||||||
|
get { |
||||||
|
return header; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public CLIHeader CliHeader { |
||||||
|
get { |
||||||
|
return cliHeader; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string FileName { |
||||||
|
get { |
||||||
|
return filename; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public MetadataTable MetadataTable { |
||||||
|
get { |
||||||
|
return metadataTable; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public byte[] StringHeap { |
||||||
|
get { |
||||||
|
return stringHeap; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public byte[] UserStringHeap { |
||||||
|
get { |
||||||
|
return userStringHeap; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public byte[] GuidHeap { |
||||||
|
get { |
||||||
|
return guidHeap; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public byte[] BlobHeap { |
||||||
|
get { |
||||||
|
return blobHeap; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public byte[] RawSectionData { |
||||||
|
get { |
||||||
|
return rawSectionData; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static int GetCompressedInt(byte[] heap, ref uint index) |
||||||
|
{ |
||||||
|
if (index < 0 || index >= heap.Length) { |
||||||
|
return -1; |
||||||
|
} |
||||||
|
int first = heap[index++]; |
||||||
|
switch (first & 0xC0) { |
||||||
|
case 0xC0: |
||||||
|
first &= ~0xC0; |
||||||
|
return first << 24 | heap[index++] << 16 | heap[index++] << 8 | heap[index++]; |
||||||
|
case 0x80: |
||||||
|
first &= ~0x80; |
||||||
|
return first << 8 | heap[index++]; |
||||||
|
default: |
||||||
|
return first; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public int LoadBlob(ref uint index) |
||||||
|
{ |
||||||
|
return GetCompressedInt(blobHeap, ref index); |
||||||
|
} |
||||||
|
|
||||||
|
public byte[] GetBlobFromHeap(uint index) |
||||||
|
{ |
||||||
|
if (index < 0 || index >= blobHeap.Length) { |
||||||
|
return new byte[0]; |
||||||
|
} |
||||||
|
int length = LoadBlob(ref index); |
||||||
|
|
||||||
|
byte[] dest = new byte[length]; |
||||||
|
Array.Copy(blobHeap, index, dest, 0, length); |
||||||
|
|
||||||
|
return dest; |
||||||
|
} |
||||||
|
|
||||||
|
public string GetUserStringFromHeap(uint index) |
||||||
|
{ |
||||||
|
if (index < 0 || index >= userStringHeap.Length) { |
||||||
|
return ""; |
||||||
|
} |
||||||
|
|
||||||
|
int length = GetCompressedInt(userStringHeap, ref index); |
||||||
|
|
||||||
|
return System.Text.Encoding.Unicode.GetString(userStringHeap, (int)index, length); |
||||||
|
} |
||||||
|
|
||||||
|
public string GetStringFromHeap(uint index) |
||||||
|
{ |
||||||
|
if (index < 0 || index >= stringHeap.Length) { |
||||||
|
return ""; |
||||||
|
} |
||||||
|
|
||||||
|
uint endIndex = index; |
||||||
|
while (endIndex < stringHeap.Length && stringHeap[endIndex] != 0) { |
||||||
|
++endIndex; |
||||||
|
} |
||||||
|
|
||||||
|
return System.Text.Encoding.UTF8.GetString(stringHeap, (int)index, (int)(endIndex - index)); |
||||||
|
} |
||||||
|
|
||||||
|
public uint LookupRVA(uint address) |
||||||
|
{ |
||||||
|
foreach (SectionTable section in sections) { |
||||||
|
if (section.VirtualAddress <= address && address <= section.VirtualAddress + section.VirtualSize) { |
||||||
|
return section.PointerToRawData + address - section.VirtualAddress; |
||||||
|
} |
||||||
|
} |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
public Stream OpenStream(uint rva) |
||||||
|
{ |
||||||
|
uint offset = LookupRVA(rva); |
||||||
|
MemoryStream ms = new MemoryStream(rawSectionData); |
||||||
|
ms.Seek(offset, SeekOrigin.Begin); |
||||||
|
return ms; |
||||||
|
} |
||||||
|
|
||||||
|
public ICSharpCode.SharpAssembly.Metadata.Rows.MethodBody LoadMethodBody(uint rva) |
||||||
|
{ |
||||||
|
BinaryReader binaryReader = new BinaryReader(OpenStream(rva)); |
||||||
|
ICSharpCode.SharpAssembly.Metadata.Rows.MethodBody body = new ICSharpCode.SharpAssembly.Metadata.Rows.MethodBody(); |
||||||
|
body.Load(binaryReader); |
||||||
|
binaryReader.Close(); |
||||||
|
return body; |
||||||
|
} |
||||||
|
|
||||||
|
public void Load(string fileName) |
||||||
|
{ |
||||||
|
Stream fs = System.IO.File.OpenRead(fileName); |
||||||
|
fs.Seek(0x3c, SeekOrigin.Begin); |
||||||
|
BinaryReader binaryReaderSO = new BinaryReader(fs); |
||||||
|
long signature_offset = binaryReaderSO.ReadInt32(); |
||||||
|
|
||||||
|
fs.Seek(signature_offset, SeekOrigin.Begin); |
||||||
|
|
||||||
|
filename = fileName; |
||||||
|
|
||||||
|
BinaryReader binaryReader = new BinaryReader(fs); |
||||||
|
|
||||||
|
header = new PEFileHeader(); |
||||||
|
header.LoadFrom(binaryReader); |
||||||
|
|
||||||
|
sections = new SectionTable[header.NumberOfSections]; |
||||||
|
for (int i = 0; i < header.NumberOfSections; ++i) { |
||||||
|
sections[i] = new SectionTable(); |
||||||
|
sections[i].LoadFrom(binaryReader); |
||||||
|
} |
||||||
|
|
||||||
|
uint rawDataSize = 0; |
||||||
|
for (int i = 0; i < header.NumberOfSections; ++i) { |
||||||
|
rawDataSize += sections[i].SizeOfRawData; |
||||||
|
} |
||||||
|
|
||||||
|
// read all sections to a memory buffer and relocate all pointer in the sections
|
||||||
|
// to raw data indices in the buffer
|
||||||
|
rawSectionData = new byte[rawDataSize]; |
||||||
|
int curOffset = 0; |
||||||
|
for (int i = 0; i < header.NumberOfSections; ++i) { |
||||||
|
fs.Seek((int)sections[i].PointerToRawData, SeekOrigin.Begin); |
||||||
|
fs.Read(rawSectionData, curOffset, (int)sections[i].SizeOfRawData); |
||||||
|
sections[i].PointerToRawData = (uint)curOffset; |
||||||
|
curOffset += (int)sections[i].SizeOfRawData; |
||||||
|
} |
||||||
|
binaryReader.Close(); |
||||||
|
binaryReaderSO.Close(); |
||||||
|
fs.Close(); |
||||||
|
|
||||||
|
fs = new MemoryStream(rawSectionData); |
||||||
|
binaryReader = new BinaryReader(fs); |
||||||
|
|
||||||
|
uint cliHeaderPos = LookupRVA(header.DataDirectories.CliHeader); |
||||||
|
fs.Seek((int)cliHeaderPos, SeekOrigin.Begin); |
||||||
|
cliHeader = new CLIHeader(); |
||||||
|
cliHeader.LoadFrom(binaryReader); |
||||||
|
|
||||||
|
uint metaDataPos = LookupRVA(cliHeader.MetaData); |
||||||
|
fs.Seek((int)metaDataPos, SeekOrigin.Begin); |
||||||
|
AssemblyMetadata met = new AssemblyMetadata(); |
||||||
|
met.LoadFrom(binaryReader); |
||||||
|
|
||||||
|
foreach (StreamHeader streamHeader in met.StreamHeaders) { |
||||||
|
uint offset = LookupRVA(cliHeader.MetaData + streamHeader.Offset); |
||||||
|
fs.Seek((int)offset, SeekOrigin.Begin); |
||||||
|
switch (streamHeader.Name) { |
||||||
|
case "#~": |
||||||
|
case "#-": |
||||||
|
metadataTable.LoadFrom(binaryReader); |
||||||
|
break; |
||||||
|
case "#Strings": |
||||||
|
stringHeap = new byte[streamHeader.Size]; |
||||||
|
fs.Read(stringHeap, 0, stringHeap.Length); |
||||||
|
break; |
||||||
|
case "#US": |
||||||
|
userStringHeap = new byte[streamHeader.Size]; |
||||||
|
fs.Read(userStringHeap, 0, userStringHeap.Length); |
||||||
|
break; |
||||||
|
case "#GUID": |
||||||
|
guidHeap = new byte[streamHeader.Size]; |
||||||
|
fs.Read(guidHeap, 0, guidHeap.Length); |
||||||
|
break; |
||||||
|
case "#Blob": |
||||||
|
blobHeap = new byte[streamHeader.Size]; |
||||||
|
fs.Read(blobHeap, 0, blobHeap.Length); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public int GetCodedIndexTable(CodedIndex index, ref uint val) |
||||||
|
{ |
||||||
|
int bits = 0; |
||||||
|
|
||||||
|
switch (index) { |
||||||
|
case CodedIndex.HasConstant: |
||||||
|
case CodedIndex.TypeDefOrRef: |
||||||
|
case CodedIndex.HasDeclSecurity: |
||||||
|
case CodedIndex.Implementation: |
||||||
|
case CodedIndex.ResolutionScope: |
||||||
|
bits = 2; |
||||||
|
break; |
||||||
|
case CodedIndex.HasCustomAttribute: |
||||||
|
bits = 5; |
||||||
|
break; |
||||||
|
case CodedIndex.HasFieldMarshall: |
||||||
|
case CodedIndex.HasSemantics: |
||||||
|
case CodedIndex.MethodDefOrRef: |
||||||
|
case CodedIndex.MemberForwarded: |
||||||
|
bits = 1; |
||||||
|
break; |
||||||
|
case CodedIndex.MemberRefParent: |
||||||
|
case CodedIndex.CustomAttributeType: |
||||||
|
bits = 3; |
||||||
|
break; |
||||||
|
} |
||||||
|
|
||||||
|
uint origval = val; |
||||||
|
val = origval >> bits; |
||||||
|
|
||||||
|
return (int)(origval & ((int)Math.Pow(2, bits) - 1)); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,419 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Text; |
||||||
|
using System.Runtime.InteropServices; |
||||||
|
|
||||||
|
namespace MSjogren.Fusion.Native |
||||||
|
{ |
||||||
|
[Flags] |
||||||
|
enum ASM_CACHE_FLAGS |
||||||
|
{ |
||||||
|
ASM_CACHE_ZAP = 0x1, |
||||||
|
ASM_CACHE_GAC = 0x2, |
||||||
|
ASM_CACHE_DOWNLOAD = 0x4 |
||||||
|
} |
||||||
|
|
||||||
|
[Flags] |
||||||
|
enum ASM_DISPLAY_FLAGS |
||||||
|
{ |
||||||
|
VERSION = 0x1, |
||||||
|
CULTURE = 0x2, |
||||||
|
PUBLIC_KEY_TOKEN = 0x4, |
||||||
|
PUBLIC_KEY = 0x8, |
||||||
|
CUSTOM = 0x10, |
||||||
|
PROCESSORARCHITECTURE = 0x20, |
||||||
|
LANGUAGEID = 0x40 |
||||||
|
} |
||||||
|
|
||||||
|
[Flags] |
||||||
|
enum ASM_CMP_FLAGS |
||||||
|
{ |
||||||
|
NAME = 0x1, |
||||||
|
MAJOR_VERSION = 0x2, |
||||||
|
MINOR_VERSION = 0x4, |
||||||
|
BUILD_NUMBER = 0x8, |
||||||
|
REVISION_NUMBER = 0x10, |
||||||
|
PUBLIC_KEY_TOKEN = 0x20, |
||||||
|
CULTURE = 0x40, |
||||||
|
CUSTOM = 0x80, |
||||||
|
ALL = NAME | MAJOR_VERSION | MINOR_VERSION | |
||||||
|
REVISION_NUMBER | BUILD_NUMBER | |
||||||
|
PUBLIC_KEY_TOKEN | CULTURE | CUSTOM, |
||||||
|
DEFAULT = 0x100 |
||||||
|
} |
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] |
||||||
|
struct FUSION_INSTALL_REFERENCE |
||||||
|
{ |
||||||
|
public uint cbSize; |
||||||
|
public uint dwFlags; |
||||||
|
public Guid guidScheme; |
||||||
|
public string szIdentifier; |
||||||
|
public string szNonCannonicalData; |
||||||
|
} |
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] |
||||||
|
struct ASSEMBLY_INFO |
||||||
|
{ |
||||||
|
public uint cbAssemblyInfo; |
||||||
|
public uint dwAssemblyFlags; |
||||||
|
public ulong uliAssemblySizeInKB; |
||||||
|
public string pszCurrentAssemblyPathBuf; |
||||||
|
public uint cchBuf; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[ |
||||||
|
ComImport(), |
||||||
|
Guid("E707DCDE-D1CD-11D2-BAB9-00C04F8ECEAE"), |
||||||
|
InterfaceType(ComInterfaceType.InterfaceIsIUnknown) |
||||||
|
] |
||||||
|
interface IAssemblyCache |
||||||
|
{ |
||||||
|
[PreserveSig()] |
||||||
|
int UninstallAssembly( |
||||||
|
uint dwFlags, |
||||||
|
[MarshalAs(UnmanagedType.LPWStr)] string pszAssemblyName, |
||||||
|
[MarshalAs(UnmanagedType.LPArray)] FUSION_INSTALL_REFERENCE[] pRefData, |
||||||
|
out uint pulDisposition); |
||||||
|
|
||||||
|
[PreserveSig()] |
||||||
|
int QueryAssemblyInfo( |
||||||
|
uint dwFlags, |
||||||
|
[MarshalAs(UnmanagedType.LPWStr)] string pszAssemblyName, |
||||||
|
ref ASSEMBLY_INFO pAsmInfo); |
||||||
|
|
||||||
|
[PreserveSig()] |
||||||
|
int CreateAssemblyCacheItem( |
||||||
|
uint dwFlags, |
||||||
|
IntPtr pvReserved, |
||||||
|
out IAssemblyCacheItem ppAsmItem, |
||||||
|
[MarshalAs(UnmanagedType.LPWStr)] string pszAssemblyName); |
||||||
|
|
||||||
|
[PreserveSig()] |
||||||
|
int CreateAssemblyScavenger( |
||||||
|
[MarshalAs(UnmanagedType.IUnknown)] out object ppAsmScavenger); |
||||||
|
|
||||||
|
[PreserveSig()] |
||||||
|
int InstallAssembly( |
||||||
|
uint dwFlags, |
||||||
|
[MarshalAs(UnmanagedType.LPWStr)] string pszManifestFilePath, |
||||||
|
[MarshalAs(UnmanagedType.LPArray)] FUSION_INSTALL_REFERENCE[] pRefData); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[ |
||||||
|
ComImport(), |
||||||
|
Guid("9E3AAEB4-D1CD-11D2-BAB9-00C04F8ECEAE"), |
||||||
|
InterfaceType(ComInterfaceType.InterfaceIsIUnknown) |
||||||
|
] |
||||||
|
interface IAssemblyCacheItem |
||||||
|
{ |
||||||
|
void CreateStream( |
||||||
|
uint dwFlags, |
||||||
|
[MarshalAs(UnmanagedType.LPWStr)] string pszStreamName, |
||||||
|
uint dwFormat, |
||||||
|
uint dwFormatFlags, |
||||||
|
out UCOMIStream ppIStream, |
||||||
|
ref long puliMaxSize); |
||||||
|
|
||||||
|
void Commit( |
||||||
|
uint dwFlags, |
||||||
|
out long pulDisposition); |
||||||
|
|
||||||
|
void AbortItem(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
enum ASM_NAME |
||||||
|
{ |
||||||
|
PUBLIC_KEY = 0, // byte[]
|
||||||
|
PUBLIC_KEY_TOKEN, // byte[8]
|
||||||
|
HASH_VALUE, |
||||||
|
NAME, // LPWSTR
|
||||||
|
MAJOR_VERSION, // ushort
|
||||||
|
MINOR_VERSION, // ushort
|
||||||
|
BUILD_NUMBER, // ushort
|
||||||
|
REVISION_NUMBER, // ushort
|
||||||
|
CULTURE, // LPWSTR
|
||||||
|
PROCESSOR_ID_ARRAY, |
||||||
|
OSINFO_ARRAY, |
||||||
|
HASH_ALGID, |
||||||
|
ALIAS, |
||||||
|
CODEBASE_URL, // LPWSTR
|
||||||
|
CODEBASE_LASTMOD, // FILETIME
|
||||||
|
NULL_PUBLIC_KEY, |
||||||
|
NULL_PUBLIC_KEY_TOKEN, |
||||||
|
CUSTOM, // LPWSTR; ZAP string for NGEN assemblies
|
||||||
|
NULL_CUSTOM, |
||||||
|
MVID, // byte[16] / Guid
|
||||||
|
//MAX_PARAMS
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[ |
||||||
|
ComImport(), |
||||||
|
Guid("CD193BC0-B4BC-11D2-9833-00C04FC31D2E"), |
||||||
|
InterfaceType(ComInterfaceType.InterfaceIsIUnknown) |
||||||
|
] |
||||||
|
interface IAssemblyName |
||||||
|
{ |
||||||
|
[PreserveSig()] |
||||||
|
int SetProperty( |
||||||
|
ASM_NAME PropertyId, |
||||||
|
IntPtr pvProperty, |
||||||
|
uint cbProperty); |
||||||
|
|
||||||
|
[PreserveSig()] |
||||||
|
int GetProperty( |
||||||
|
ASM_NAME PropertyId, |
||||||
|
IntPtr pvProperty, |
||||||
|
ref uint pcbProperty); |
||||||
|
|
||||||
|
[PreserveSig()] |
||||||
|
int Finalize(); |
||||||
|
|
||||||
|
[PreserveSig()] |
||||||
|
int GetDisplayName( |
||||||
|
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder szDisplayName, |
||||||
|
ref uint pccDisplayName, |
||||||
|
ASM_DISPLAY_FLAGS dwDisplayFlags); |
||||||
|
|
||||||
|
[PreserveSig()] |
||||||
|
int BindToObject( |
||||||
|
ref Guid refIID, |
||||||
|
[MarshalAs(UnmanagedType.IUnknown)] object pUnkSink, |
||||||
|
[MarshalAs(UnmanagedType.IUnknown)] object pUnkContext, // IApplicationContext
|
||||||
|
[MarshalAs(UnmanagedType.LPWStr)] string szCodeBase, |
||||||
|
long llFlags, |
||||||
|
IntPtr pvReserved, |
||||||
|
uint cbReserved, |
||||||
|
out IntPtr ppv); |
||||||
|
|
||||||
|
[PreserveSig()] |
||||||
|
int GetName( |
||||||
|
ref uint lpcwBuffer, |
||||||
|
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pwzName); |
||||||
|
|
||||||
|
[PreserveSig()] |
||||||
|
int GetVersion( |
||||||
|
out uint pdwVersionHi, |
||||||
|
out uint pdwVersionLow); |
||||||
|
|
||||||
|
[PreserveSig()] |
||||||
|
int IsEqual( |
||||||
|
IAssemblyName pName, |
||||||
|
ASM_CMP_FLAGS dwCmpFlags); |
||||||
|
|
||||||
|
[PreserveSig()] |
||||||
|
int Clone( |
||||||
|
out IAssemblyName pName); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[ |
||||||
|
ComImport(), |
||||||
|
Guid("21B8916C-F28E-11D2-A473-00C04F8EF448"), |
||||||
|
InterfaceType(ComInterfaceType.InterfaceIsIUnknown) |
||||||
|
] |
||||||
|
interface IAssemblyEnum |
||||||
|
{ |
||||||
|
[PreserveSig()] |
||||||
|
int GetNextAssembly( |
||||||
|
IntPtr pvReserved, |
||||||
|
out IAssemblyName ppName, |
||||||
|
uint dwFlags); |
||||||
|
|
||||||
|
[PreserveSig()] |
||||||
|
int Reset(); |
||||||
|
|
||||||
|
[PreserveSig()] |
||||||
|
int Clone( |
||||||
|
out IAssemblyEnum ppEnum); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[ |
||||||
|
ComImport(), |
||||||
|
Guid("1D23DF4D-A1E2-4B8B-93D6-6EA3DC285A54"), |
||||||
|
InterfaceType(ComInterfaceType.InterfaceIsIUnknown) |
||||||
|
] |
||||||
|
interface IHistoryReader |
||||||
|
{ |
||||||
|
[PreserveSig()] |
||||||
|
int GetFilePath( |
||||||
|
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzFilePath, |
||||||
|
ref uint pdwSize); |
||||||
|
|
||||||
|
[PreserveSig()] |
||||||
|
int GetApplicationName( |
||||||
|
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzAppName, |
||||||
|
ref uint pdwSize); |
||||||
|
|
||||||
|
[PreserveSig()] |
||||||
|
int GetEXEModulePath( |
||||||
|
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzExePath, |
||||||
|
ref uint pdwSize); |
||||||
|
|
||||||
|
void GetNumActivations( |
||||||
|
out uint pdwNumActivations); |
||||||
|
|
||||||
|
void GetActivationDate( |
||||||
|
uint dwIdx, // One-based!
|
||||||
|
out long /* FILETIME */ pftDate); |
||||||
|
|
||||||
|
[PreserveSig()] |
||||||
|
int GetRunTimeVersion( |
||||||
|
ref long /* FILETIME */ pftActivationDate, |
||||||
|
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzRunTimeVersion, |
||||||
|
ref uint pdwSize); |
||||||
|
|
||||||
|
void GetNumAssemblies( |
||||||
|
ref long /* FILETIME */ pftActivationDate, |
||||||
|
out uint pdwNumAsms); |
||||||
|
|
||||||
|
void GetHistoryAssembly( |
||||||
|
ref long /* FILETIME */ pftActivationDate, |
||||||
|
uint dwIdx, // One-based!
|
||||||
|
[MarshalAs(UnmanagedType.IUnknown)] out object ppHistAsm); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[ |
||||||
|
ComImport(), |
||||||
|
Guid("582dac66-e678-449f-aba6-6faaec8a9394"), |
||||||
|
InterfaceType(ComInterfaceType.InterfaceIsIUnknown) |
||||||
|
] |
||||||
|
interface IInstallReferenceItem |
||||||
|
{ |
||||||
|
[PreserveSig()] |
||||||
|
int GetReference( |
||||||
|
out IntPtr ppRefData, // FUSION_INSTALL_REFERENCE**
|
||||||
|
uint dwFlags, |
||||||
|
IntPtr pvReserved); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[ |
||||||
|
ComImport(), |
||||||
|
Guid("56b1a988-7c0c-4aa2-8639-c3eb5a90226f"), |
||||||
|
InterfaceType(ComInterfaceType.InterfaceIsIUnknown) |
||||||
|
] |
||||||
|
interface IInstallReferenceEnum |
||||||
|
{ |
||||||
|
[PreserveSig()] |
||||||
|
int GetNextInstallReferenceItem( |
||||||
|
out IInstallReferenceItem ppRefItem, |
||||||
|
uint dwFlags, |
||||||
|
IntPtr pvReserved); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class FusionApi |
||||||
|
{ |
||||||
|
// Install reference scheme identifiers
|
||||||
|
public static readonly Guid FUSION_REFCOUNT_UNINSTALL_SUBKEY_GUID = new Guid("8cedc215-ac4b-488b-93c0-a50a49cb2fb8"); |
||||||
|
public static readonly Guid FUSION_REFCOUNT_FILEPATH_GUID = new Guid("b02f9d65-fb77-4f7a-afa5-b391309f11c9"); |
||||||
|
public static readonly Guid FUSION_REFCOUNT_OPAQUE_STRING_GUID = new Guid("2ec93463-b0c3-45e1-8364-327e96aea856"); |
||||||
|
public static readonly Guid FUSION_REFCOUNT_MSI_GUID = new Guid("25df0fc1-7f97-4070-add7-4b13bbfd7cb8"); |
||||||
|
|
||||||
|
const uint IASSEMBLYCACHE_INSTALL_FLAG_REFRESH = 0x00000001; |
||||||
|
const uint IASSEMBLYCACHE_INSTALL_FLAG_FORCE_REFRESH = 0x00000002; |
||||||
|
|
||||||
|
const uint IASSEMBLYCACHE_UNINSTALL_DISPOSITION_UNINSTALLED = 1; |
||||||
|
const uint IASSEMBLYCACHE_UNINSTALL_DISPOSITION_STILL_IN_USE = 2; |
||||||
|
const uint IASSEMBLYCACHE_UNINSTALL_DISPOSITION_ALREADY_UNINSTALLED = 3; |
||||||
|
const uint IASSEMBLYCACHE_UNINSTALL_DISPOSITION_DELETE_PENDING = 4; |
||||||
|
const uint IASSEMBLYCACHE_UNINSTALL_DISPOSITION_HAS_INSTALL_REFERENCES = 5; |
||||||
|
const uint IASSEMBLYCACHE_UNINSTALL_DISPOSITION_REFERENCE_NOT_FOUND = 6; |
||||||
|
|
||||||
|
|
||||||
|
[DllImport("fusion.dll", CharSet=CharSet.Unicode, PreserveSig=false)] |
||||||
|
public static extern void GetCachePath( |
||||||
|
ASM_CACHE_FLAGS dwCacheFlags, |
||||||
|
[MarshalAs(UnmanagedType.LPWStr)] StringBuilder pwzCachePath, |
||||||
|
ref uint pcchPath); |
||||||
|
|
||||||
|
[DllImport("fusion.dll", PreserveSig=false)] |
||||||
|
public static extern void CreateAssemblyCache( |
||||||
|
out IAssemblyCache ppAsmCache, |
||||||
|
uint dwReserved); |
||||||
|
|
||||||
|
[DllImport("fusion.dll", PreserveSig=false)] |
||||||
|
public static extern void CreateAssemblyEnum( |
||||||
|
out IAssemblyEnum ppEnum, |
||||||
|
IntPtr pUnkReserved, |
||||||
|
IAssemblyName pName, |
||||||
|
ASM_CACHE_FLAGS dwFlags, |
||||||
|
IntPtr pvReserved); |
||||||
|
|
||||||
|
[DllImport("fusion.dll", CharSet=CharSet.Unicode, PreserveSig=false)] |
||||||
|
public static extern void CreateAssemblyNameObject( |
||||||
|
out IAssemblyName ppName, |
||||||
|
string szAssemblyName, |
||||||
|
uint dwFlags, |
||||||
|
IntPtr pvReserved); |
||||||
|
|
||||||
|
[DllImport("fusion.dll", PreserveSig=false)] |
||||||
|
public static extern void CreateInstallReferenceEnum( |
||||||
|
out IInstallReferenceEnum ppRefEnum, |
||||||
|
IAssemblyName pName, |
||||||
|
uint dwFlags, |
||||||
|
IntPtr pvReserved); |
||||||
|
|
||||||
|
|
||||||
|
[DllImport("fusion.dll", CharSet=CharSet.Unicode, PreserveSig=false)] |
||||||
|
public static extern void CreateHistoryReader( |
||||||
|
string wzFilePath, |
||||||
|
out IHistoryReader ppHistReader); |
||||||
|
|
||||||
|
// Retrieves the path of the ApplicationHistory folder, typically
|
||||||
|
// Documents and Settings\<user>\Local Settings\Application Data\ApplicationHistory
|
||||||
|
// containing .ini files that can be read with IHistoryReader.
|
||||||
|
// pwdSize appears to be the offset of the last backslash in the returned
|
||||||
|
// string after the call.
|
||||||
|
[DllImport("fusion.dll", CharSet=CharSet.Unicode, PreserveSig=false)] |
||||||
|
public static extern void GetHistoryFileDirectory( |
||||||
|
[MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzDir, |
||||||
|
ref uint pdwSize); |
||||||
|
|
||||||
|
[DllImport("fusion.dll", CharSet=CharSet.Unicode, PreserveSig=false)] |
||||||
|
public static extern void LookupHistoryAssembly( |
||||||
|
string pwzFilePath, |
||||||
|
ref FILETIME pftActivationDate, |
||||||
|
string pwzAsmName, |
||||||
|
string pwzPublicKeyToken, |
||||||
|
string wzCulture, |
||||||
|
string pwzVerRef, |
||||||
|
out IntPtr pHistAsm); // IHistoryAssembly
|
||||||
|
|
||||||
|
[DllImport("fusion.dll", PreserveSig=false)] |
||||||
|
public static extern void NukeDownloadedCache(); |
||||||
|
|
||||||
|
[DllImport("fusion.dll", PreserveSig=false)] |
||||||
|
public static extern void CreateApplicationContext( |
||||||
|
IAssemblyName pName, |
||||||
|
out IntPtr ppCtx); // IApplicationContext
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Brings up the .NET Applicaion Restore wizard
|
||||||
|
// Returns S_OK, 0x80131075 (App not run) or 0x80131087 (Fix failed)
|
||||||
|
//
|
||||||
|
[DllImport("shfusion.dll", CharSet=CharSet.Unicode)] |
||||||
|
public static extern uint PolicyManager( |
||||||
|
IntPtr hWndParent, |
||||||
|
string pwzFullyQualifiedAppPath, |
||||||
|
string pwzAppName, |
||||||
|
int dwFlags); |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,118 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
using ICSharpCode.SharpAssembly.PE; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata |
||||||
|
{ |
||||||
|
|
||||||
|
public class AssemblyMetadata |
||||||
|
{ |
||||||
|
const uint MAGIC_SIGN = 0x424A5342; |
||||||
|
ushort majorVersion; |
||||||
|
ushort minorVersion; |
||||||
|
uint reserved; |
||||||
|
uint length; |
||||||
|
string versionString; |
||||||
|
ushort flags; |
||||||
|
ushort numerOfStreams; |
||||||
|
|
||||||
|
StreamHeader[] streamHeaders; |
||||||
|
|
||||||
|
public ushort MajorVersion { |
||||||
|
get { |
||||||
|
return majorVersion; |
||||||
|
} |
||||||
|
set { |
||||||
|
majorVersion = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public ushort MinorVersion { |
||||||
|
get { |
||||||
|
return minorVersion; |
||||||
|
} |
||||||
|
set { |
||||||
|
minorVersion = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Reserved { |
||||||
|
get { |
||||||
|
return reserved; |
||||||
|
} |
||||||
|
set { |
||||||
|
reserved = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Length { |
||||||
|
get { |
||||||
|
return length; |
||||||
|
} |
||||||
|
set { |
||||||
|
length = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public string VersionString { |
||||||
|
get { |
||||||
|
return versionString; |
||||||
|
} |
||||||
|
set { |
||||||
|
versionString = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public ushort Flags { |
||||||
|
get { |
||||||
|
return flags; |
||||||
|
} |
||||||
|
set { |
||||||
|
flags = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public ushort NumerOfStreams { |
||||||
|
get { |
||||||
|
return numerOfStreams; |
||||||
|
} |
||||||
|
set { |
||||||
|
numerOfStreams = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public StreamHeader[] StreamHeaders { |
||||||
|
get { |
||||||
|
return streamHeaders; |
||||||
|
} |
||||||
|
set { |
||||||
|
streamHeaders = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public void LoadFrom(BinaryReader binaryReader) |
||||||
|
{ |
||||||
|
uint signature = binaryReader.ReadUInt32(); |
||||||
|
if (signature != MAGIC_SIGN) { |
||||||
|
Console.WriteLine("WARNING signature != MAGIC_SIGN "); |
||||||
|
} |
||||||
|
|
||||||
|
majorVersion = binaryReader.ReadUInt16(); |
||||||
|
minorVersion = binaryReader.ReadUInt16(); |
||||||
|
reserved = binaryReader.ReadUInt32(); |
||||||
|
length = binaryReader.ReadUInt32(); |
||||||
|
byte[] versionStringBytes = new byte[length]; |
||||||
|
binaryReader.Read(versionStringBytes, 0, (int)length); |
||||||
|
versionString = System.Text.Encoding.UTF8.GetString(versionStringBytes); |
||||||
|
flags = binaryReader.ReadUInt16(); |
||||||
|
numerOfStreams = binaryReader.ReadUInt16(); |
||||||
|
streamHeaders = new StreamHeader[numerOfStreams]; |
||||||
|
for (int i = 0; i < numerOfStreams; ++i) { |
||||||
|
streamHeaders[i] = new StreamHeader(); |
||||||
|
streamHeaders[i].LoadFrom(binaryReader); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,236 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Reflection; |
||||||
|
using System.Collections; |
||||||
|
using System.IO; |
||||||
|
using ICSharpCode.SharpAssembly.Metadata.Rows; |
||||||
|
using MDRows = ICSharpCode.SharpAssembly.Metadata.Rows; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata |
||||||
|
{ |
||||||
|
|
||||||
|
public class MetadataTable |
||||||
|
{ |
||||||
|
uint reserved; |
||||||
|
byte majorVersion; |
||||||
|
byte minorVersion; |
||||||
|
byte heapSizes; |
||||||
|
ulong valid; |
||||||
|
ulong sorted; |
||||||
|
uint[] rows; |
||||||
|
|
||||||
|
Hashtable tableIndices = new Hashtable(); |
||||||
|
Hashtable tables = new Hashtable(); |
||||||
|
|
||||||
|
// map TABLE_ID to index in rows
|
||||||
|
public Hashtable TableIndices { |
||||||
|
get { |
||||||
|
return tableIndices; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public Hashtable Tables { |
||||||
|
get { |
||||||
|
return tables; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint Reserved { |
||||||
|
get { |
||||||
|
return reserved; |
||||||
|
} |
||||||
|
set { |
||||||
|
reserved = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public byte MajorVersion { |
||||||
|
get { |
||||||
|
return majorVersion; |
||||||
|
} |
||||||
|
set { |
||||||
|
majorVersion = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public byte MinorVersion { |
||||||
|
get { |
||||||
|
return minorVersion; |
||||||
|
} |
||||||
|
set { |
||||||
|
minorVersion = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public byte HeapSizes { |
||||||
|
get { |
||||||
|
return heapSizes; |
||||||
|
} |
||||||
|
set { |
||||||
|
heapSizes = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public ulong Valid { |
||||||
|
get { |
||||||
|
return valid; |
||||||
|
} |
||||||
|
set { |
||||||
|
valid = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public ulong Sorted { |
||||||
|
get { |
||||||
|
return sorted; |
||||||
|
} |
||||||
|
set { |
||||||
|
sorted = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint[] Rows { |
||||||
|
get { |
||||||
|
return rows; |
||||||
|
} |
||||||
|
set { |
||||||
|
rows = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool FourByteStringIndices { |
||||||
|
get { |
||||||
|
return (heapSizes & 1) == 1; |
||||||
|
} |
||||||
|
} |
||||||
|
public bool FourByteGUIDIndices { |
||||||
|
get { |
||||||
|
return (heapSizes & 2) == 2; |
||||||
|
} |
||||||
|
} |
||||||
|
public bool FourByteBlobIndices { |
||||||
|
get { |
||||||
|
return (heapSizes & 4) == 4; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public AbstractRow[] LoadTable(BinaryReader binaryReader, Type tableType, uint count) |
||||||
|
{ |
||||||
|
// rows start at 1, as the indices in the metadata do
|
||||||
|
AbstractRow[] array = (AbstractRow[])Array.CreateInstance(tableType, count+1); |
||||||
|
for (int i = 1; i <= count; ++i) { |
||||||
|
array[i] = (AbstractRow)tableType.Assembly.CreateInstance(tableType.FullName); |
||||||
|
array[i].BinaryReader = binaryReader; |
||||||
|
array[i].MetadataTable = this; |
||||||
|
array[i].LoadRow(); |
||||||
|
} |
||||||
|
return array; |
||||||
|
} |
||||||
|
|
||||||
|
public uint GetRowCount(int tableID) |
||||||
|
{ |
||||||
|
object index = tableIndices[tableID]; |
||||||
|
if (index is uint) { |
||||||
|
return rows[(uint)index]; |
||||||
|
} |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
public uint GetMultipleRowCount(params int[] tableID) |
||||||
|
{ |
||||||
|
uint count = 0; |
||||||
|
foreach (int id in tableID) { |
||||||
|
object index = tableIndices[id]; |
||||||
|
if (index != null) { |
||||||
|
count += rows[(uint)index]; |
||||||
|
} |
||||||
|
} |
||||||
|
return count; |
||||||
|
} |
||||||
|
|
||||||
|
public uint GetMaxRowCount(params int[] tableID) |
||||||
|
{ |
||||||
|
uint maxcount = 0; |
||||||
|
foreach (int id in tableID) { |
||||||
|
object index = tableIndices[id]; |
||||||
|
if (index is uint) { |
||||||
|
uint count = rows[(uint)index]; |
||||||
|
if (count > maxcount) maxcount = count; |
||||||
|
} |
||||||
|
} |
||||||
|
return maxcount; |
||||||
|
} |
||||||
|
|
||||||
|
static int GetTableID(Type type) |
||||||
|
{ |
||||||
|
return (int)type.InvokeMember("TABLE_ID", |
||||||
|
BindingFlags.Static | |
||||||
|
BindingFlags.Public | |
||||||
|
BindingFlags.Instance | |
||||||
|
BindingFlags.GetField, null, null, null); |
||||||
|
} |
||||||
|
|
||||||
|
public void LoadFrom(BinaryReader binaryReader) |
||||||
|
{ |
||||||
|
reserved = binaryReader.ReadUInt32(); |
||||||
|
majorVersion = binaryReader.ReadByte(); |
||||||
|
minorVersion = binaryReader.ReadByte(); |
||||||
|
heapSizes = binaryReader.ReadByte(); |
||||||
|
reserved = binaryReader.ReadByte(); |
||||||
|
valid = binaryReader.ReadUInt64(); |
||||||
|
sorted = binaryReader.ReadUInt64(); |
||||||
|
rows = new uint[CalculateNumberOfRows()]; |
||||||
|
for (int i = 0; i < rows.Length; ++i) { |
||||||
|
rows[i] = binaryReader.ReadUInt32(); |
||||||
|
} |
||||||
|
|
||||||
|
ArrayList types = new ArrayList(); |
||||||
|
// ArrayList allTypes = new ArrayList();
|
||||||
|
foreach (Type type in typeof(AbstractRow).Assembly.GetTypes()) { |
||||||
|
if (type.IsSubclassOf(typeof(AbstractRow))) { |
||||||
|
// allTypes.Add(type);
|
||||||
|
ulong tableBit = (ulong)1 << GetTableID(type); |
||||||
|
if ((valid & tableBit) == tableBit) { |
||||||
|
types.Add(type); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
// allTypes.Sort(new TypeComparer());
|
||||||
|
// foreach (Type type in allTypes) {
|
||||||
|
// Console.WriteLine(GetTableID(type) + " -- " + type.Name);
|
||||||
|
// }
|
||||||
|
|
||||||
|
types.Sort(new TypeComparer()); |
||||||
|
|
||||||
|
for (int i = 0; i < types.Count; ++i) { |
||||||
|
tableIndices[GetTableID((Type)types[i])] = (uint)i; |
||||||
|
} |
||||||
|
|
||||||
|
foreach (Type type in types) { |
||||||
|
int id = GetTableID(type); |
||||||
|
Tables[id] = LoadTable(binaryReader, type, rows[(uint)tableIndices[id]]); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
int CalculateNumberOfRows() |
||||||
|
{ |
||||||
|
int rows = 0; |
||||||
|
ulong v = valid; |
||||||
|
for (int i = 0; i < 64; ++i) { |
||||||
|
rows += (int)(v & 1); |
||||||
|
v /= 2; |
||||||
|
} |
||||||
|
return rows; |
||||||
|
} |
||||||
|
|
||||||
|
class TypeComparer : IComparer |
||||||
|
{ |
||||||
|
public int Compare(object o1, object o2) |
||||||
|
{ |
||||||
|
return GetTableID((Type)o1).CompareTo(GetTableID((Type)o2)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,107 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows |
||||||
|
{ |
||||||
|
|
||||||
|
public class MethodBody |
||||||
|
{ |
||||||
|
public const byte CorILMethod_Fat = 0x3; |
||||||
|
public const byte CorILMethod_TinyFormat = 0x2; |
||||||
|
public const byte CorILMethod_MoreSects = 0x8; |
||||||
|
public const byte CorILMethod_InitLocals = 0x10; |
||||||
|
|
||||||
|
uint flags = 0; |
||||||
|
uint headerSize = 0; |
||||||
|
ushort maxStack = 8; |
||||||
|
uint codeSize = 0; |
||||||
|
uint localVarSigTok = 0; |
||||||
|
|
||||||
|
byte[] methodData; |
||||||
|
|
||||||
|
public uint Flags { |
||||||
|
get { |
||||||
|
return flags; |
||||||
|
} |
||||||
|
set { |
||||||
|
flags = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint HeaderSize { |
||||||
|
get { |
||||||
|
return headerSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
headerSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public ushort MaxStack { |
||||||
|
get { |
||||||
|
return maxStack; |
||||||
|
} |
||||||
|
set { |
||||||
|
maxStack = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint CodeSize { |
||||||
|
get { |
||||||
|
return codeSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
codeSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint LocalVarSigTok { |
||||||
|
get { |
||||||
|
return localVarSigTok; |
||||||
|
} |
||||||
|
set { |
||||||
|
localVarSigTok = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public byte[] MethodData { |
||||||
|
get { |
||||||
|
return methodData; |
||||||
|
} |
||||||
|
set { |
||||||
|
methodData = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public void Load(BinaryReader reader) |
||||||
|
{ |
||||||
|
byte flagByte = reader.ReadByte(); |
||||||
|
Console.Write("flagByte : " + flagByte.ToString("X")); |
||||||
|
|
||||||
|
switch (flagByte & 0x03) { |
||||||
|
case CorILMethod_Fat: |
||||||
|
byte nextByte = reader.ReadByte(); |
||||||
|
Console.WriteLine(" nextByte : " + nextByte.ToString("X")); |
||||||
|
|
||||||
|
flags = (uint)(flagByte & ((nextByte & 0x0F) << 8)); |
||||||
|
headerSize = (uint)(nextByte >> 4); |
||||||
|
maxStack = reader.ReadUInt16(); |
||||||
|
codeSize = reader.ReadUInt32(); |
||||||
|
localVarSigTok = reader.ReadUInt32(); |
||||||
|
// TODO : CorILMethod_MoreSects
|
||||||
|
break; |
||||||
|
case CorILMethod_TinyFormat: |
||||||
|
flags = (uint)flagByte & 0x03; |
||||||
|
codeSize = (uint)flagByte >> 2; |
||||||
|
break; |
||||||
|
default: |
||||||
|
throw new System.NotSupportedException("not supported method body flag " + flagByte); |
||||||
|
} |
||||||
|
methodData = new byte[codeSize]; |
||||||
|
reader.Read(methodData, 0, (int)codeSize); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,148 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public abstract class AbstractRow |
||||||
|
{ |
||||||
|
protected BinaryReader binaryReader; |
||||||
|
protected MetadataTable metadataTable; |
||||||
|
|
||||||
|
public BinaryReader BinaryReader { |
||||||
|
get { |
||||||
|
return binaryReader; |
||||||
|
} |
||||||
|
set { |
||||||
|
binaryReader = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public MetadataTable MetadataTable { |
||||||
|
get { |
||||||
|
return metadataTable; |
||||||
|
} |
||||||
|
set { |
||||||
|
metadataTable = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected bool BaseIsFlagSet(uint flags, uint flag, uint flag_mask) |
||||||
|
{ |
||||||
|
return ((flags & flag_mask) == flag); |
||||||
|
} |
||||||
|
|
||||||
|
protected bool BaseIsFlagSet(uint flags, uint flag) |
||||||
|
{ |
||||||
|
return ((flags & flag) == flag); |
||||||
|
} |
||||||
|
|
||||||
|
protected uint ReadCodedIndex(CodedIndex codedIndex) |
||||||
|
{ |
||||||
|
uint number = 0; |
||||||
|
int bits = 0; |
||||||
|
switch (codedIndex) { |
||||||
|
case CodedIndex.TypeDefOrRef: |
||||||
|
number = metadataTable.GetMaxRowCount(TypeDef.TABLE_ID, TypeRef.TABLE_ID, TypeSpec.TABLE_ID); |
||||||
|
bits = 2; |
||||||
|
break; |
||||||
|
case CodedIndex.HasConstant: |
||||||
|
number = metadataTable.GetMaxRowCount(Field.TABLE_ID, Param.TABLE_ID, Property.TABLE_ID); |
||||||
|
bits = 2; |
||||||
|
break; |
||||||
|
case CodedIndex.HasCustomAttribute: |
||||||
|
number = metadataTable.GetMaxRowCount(Method.TABLE_ID, Field.TABLE_ID, TypeRef.TABLE_ID, |
||||||
|
TypeDef.TABLE_ID, Param.TABLE_ID, InterfaceImpl.TABLE_ID, |
||||||
|
MemberRef.TABLE_ID, Module.TABLE_ID, DeclSecurity.TABLE_ID, |
||||||
|
Property.TABLE_ID, Event.TABLE_ID, StandAloneSig.TABLE_ID, |
||||||
|
ModuleRef.TABLE_ID, TypeSpec.TABLE_ID, Assembly.TABLE_ID, |
||||||
|
AssemblyRef.TABLE_ID, File.TABLE_ID, ExportedType.TABLE_ID, |
||||||
|
ManifestResource.TABLE_ID); |
||||||
|
bits = 5; |
||||||
|
break; |
||||||
|
case CodedIndex.HasFieldMarshall: |
||||||
|
number = metadataTable.GetMaxRowCount(Field.TABLE_ID, Param.TABLE_ID); |
||||||
|
bits = 1; |
||||||
|
break; |
||||||
|
case CodedIndex.HasDeclSecurity: |
||||||
|
number = metadataTable.GetMaxRowCount(TypeDef.TABLE_ID, Method.TABLE_ID, Assembly.TABLE_ID); |
||||||
|
bits = 2; |
||||||
|
break; |
||||||
|
case CodedIndex.MemberRefParent: |
||||||
|
number = metadataTable.GetMaxRowCount(TypeDef.TABLE_ID, TypeRef.TABLE_ID, ModuleRef.TABLE_ID, Method.TABLE_ID, TypeSpec.TABLE_ID); |
||||||
|
bits = 3; |
||||||
|
break; |
||||||
|
case CodedIndex.HasSemantics: |
||||||
|
number = metadataTable.GetMaxRowCount(Event.TABLE_ID, Property.TABLE_ID); |
||||||
|
bits = 1; |
||||||
|
break; |
||||||
|
case CodedIndex.MethodDefOrRef: |
||||||
|
number = metadataTable.GetMaxRowCount(Method.TABLE_ID, MemberRef.TABLE_ID); |
||||||
|
bits = 1; |
||||||
|
break; |
||||||
|
case CodedIndex.MemberForwarded: |
||||||
|
number = metadataTable.GetMaxRowCount(Field.TABLE_ID, Method.TABLE_ID); |
||||||
|
bits = 1; |
||||||
|
break; |
||||||
|
case CodedIndex.Implementation: |
||||||
|
number = metadataTable.GetMaxRowCount(File.TABLE_ID, AssemblyRef.TABLE_ID, ExportedType.TABLE_ID); |
||||||
|
bits = 2; |
||||||
|
break; |
||||||
|
case CodedIndex.CustomAttributeType: |
||||||
|
//number = metadataTable.GetMaxRowCount(TypeRef.TABLE_ID, TypeDef.TABLE_ID, Method.TABLE_ID, MemberRef.TABLE_ID/* TODO : , String ? */);
|
||||||
|
number = metadataTable.GetMaxRowCount(Method.TABLE_ID, MemberRef.TABLE_ID); |
||||||
|
bits = 3; |
||||||
|
break; |
||||||
|
case CodedIndex.ResolutionScope: |
||||||
|
number = metadataTable.GetMaxRowCount(Module.TABLE_ID, ModuleRef.TABLE_ID, AssemblyRef.TABLE_ID, TypeRef.TABLE_ID); |
||||||
|
bits = 2; |
||||||
|
break; |
||||||
|
} |
||||||
|
if (number > 1 << (16 - bits)) { |
||||||
|
return binaryReader.ReadUInt32(); |
||||||
|
} |
||||||
|
return binaryReader.ReadUInt16(); |
||||||
|
} |
||||||
|
|
||||||
|
protected uint ReadSimpleIndex(int tableID) |
||||||
|
{ |
||||||
|
uint rowCount = metadataTable.GetRowCount(tableID); |
||||||
|
if (rowCount >= (1 << 16)) { |
||||||
|
return binaryReader.ReadUInt32(); |
||||||
|
} |
||||||
|
return binaryReader.ReadUInt16(); |
||||||
|
} |
||||||
|
|
||||||
|
protected uint LoadStringIndex() |
||||||
|
{ |
||||||
|
if (metadataTable.FourByteStringIndices) { |
||||||
|
return binaryReader.ReadUInt32(); |
||||||
|
} |
||||||
|
return binaryReader.ReadUInt16(); |
||||||
|
} |
||||||
|
|
||||||
|
protected uint LoadBlobIndex() |
||||||
|
{ |
||||||
|
if (metadataTable.FourByteBlobIndices) { |
||||||
|
return binaryReader.ReadUInt32(); |
||||||
|
} |
||||||
|
return binaryReader.ReadUInt16(); |
||||||
|
} |
||||||
|
|
||||||
|
protected uint LoadGUIDIndex() |
||||||
|
{ |
||||||
|
if (metadataTable.FourByteGUIDIndices) { |
||||||
|
return binaryReader.ReadUInt32(); |
||||||
|
} |
||||||
|
return binaryReader.ReadUInt16(); |
||||||
|
} |
||||||
|
|
||||||
|
public abstract void LoadRow(); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,114 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class Assembly : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x20; |
||||||
|
|
||||||
|
uint hashAlgID; |
||||||
|
ushort majorVersion; |
||||||
|
ushort minorVersion; |
||||||
|
ushort buildNumber; |
||||||
|
ushort revisionNumber; |
||||||
|
uint flags; |
||||||
|
|
||||||
|
uint publicKey; // index into the BLOB heap
|
||||||
|
uint name; // index into the string heap
|
||||||
|
uint culture; // index into the string heap
|
||||||
|
|
||||||
|
public uint HashAlgID { |
||||||
|
get { |
||||||
|
return hashAlgID; |
||||||
|
} |
||||||
|
set { |
||||||
|
hashAlgID = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public ushort MajorVersion { |
||||||
|
get { |
||||||
|
return majorVersion; |
||||||
|
} |
||||||
|
set { |
||||||
|
majorVersion = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public ushort MinorVersion { |
||||||
|
get { |
||||||
|
return minorVersion; |
||||||
|
} |
||||||
|
set { |
||||||
|
minorVersion = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public ushort BuildNumber { |
||||||
|
get { |
||||||
|
return buildNumber; |
||||||
|
} |
||||||
|
set { |
||||||
|
buildNumber = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public ushort RevisionNumber { |
||||||
|
get { |
||||||
|
return revisionNumber; |
||||||
|
} |
||||||
|
set { |
||||||
|
revisionNumber = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Flags { |
||||||
|
get { |
||||||
|
return flags; |
||||||
|
} |
||||||
|
set { |
||||||
|
flags = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint PublicKey { |
||||||
|
get { |
||||||
|
return publicKey; |
||||||
|
} |
||||||
|
set { |
||||||
|
publicKey = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Name { |
||||||
|
get { |
||||||
|
return name; |
||||||
|
} |
||||||
|
set { |
||||||
|
name = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Culture { |
||||||
|
get { |
||||||
|
return culture; |
||||||
|
} |
||||||
|
set { |
||||||
|
culture = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
hashAlgID = binaryReader.ReadUInt32(); |
||||||
|
majorVersion = binaryReader.ReadUInt16(); |
||||||
|
minorVersion = binaryReader.ReadUInt16(); |
||||||
|
buildNumber = binaryReader.ReadUInt16(); |
||||||
|
revisionNumber = binaryReader.ReadUInt16(); |
||||||
|
flags = binaryReader.ReadUInt32(); |
||||||
|
publicKey = LoadBlobIndex(); |
||||||
|
name = LoadStringIndex(); |
||||||
|
culture = LoadStringIndex(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,55 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class AssemblyOS : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x22; |
||||||
|
|
||||||
|
|
||||||
|
uint osPlatformID; |
||||||
|
uint osMajorVersion; |
||||||
|
uint osMinorVersion; |
||||||
|
|
||||||
|
public uint OSPlatformID { |
||||||
|
get { |
||||||
|
return osPlatformID; |
||||||
|
} |
||||||
|
set { |
||||||
|
osPlatformID = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint OSMajorVersion { |
||||||
|
get { |
||||||
|
return osMajorVersion; |
||||||
|
} |
||||||
|
set { |
||||||
|
osMajorVersion = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint OSMinorVersion { |
||||||
|
get { |
||||||
|
return osMinorVersion; |
||||||
|
} |
||||||
|
set { |
||||||
|
osMinorVersion = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
osPlatformID = binaryReader.ReadUInt32(); |
||||||
|
osMajorVersion = binaryReader.ReadUInt32(); |
||||||
|
osMinorVersion = binaryReader.ReadUInt32(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,33 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class AssemblyProcessor : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x21; |
||||||
|
|
||||||
|
uint processor; |
||||||
|
|
||||||
|
public uint Processor { |
||||||
|
get { |
||||||
|
return processor; |
||||||
|
} |
||||||
|
set { |
||||||
|
processor = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
processor = binaryReader.ReadUInt32(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,116 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class AssemblyRef : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x23; |
||||||
|
|
||||||
|
ushort major; |
||||||
|
ushort minor; |
||||||
|
ushort build; |
||||||
|
ushort revision; |
||||||
|
uint flags; |
||||||
|
uint publicKeyOrToken; // index into Blob heap
|
||||||
|
uint name; // index into String heap
|
||||||
|
uint culture; // index into String heap
|
||||||
|
uint hashValue; // index into Blob heap
|
||||||
|
|
||||||
|
public ushort Major { |
||||||
|
get { |
||||||
|
return major; |
||||||
|
} |
||||||
|
set { |
||||||
|
major = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public ushort Minor { |
||||||
|
get { |
||||||
|
return minor; |
||||||
|
} |
||||||
|
set { |
||||||
|
minor = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public ushort Build { |
||||||
|
get { |
||||||
|
return build; |
||||||
|
} |
||||||
|
set { |
||||||
|
build = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public ushort Revision { |
||||||
|
get { |
||||||
|
return revision; |
||||||
|
} |
||||||
|
set { |
||||||
|
revision = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint Flags { |
||||||
|
get { |
||||||
|
return flags; |
||||||
|
} |
||||||
|
set { |
||||||
|
flags = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint PublicKeyOrToken { |
||||||
|
get { |
||||||
|
return publicKeyOrToken; |
||||||
|
} |
||||||
|
set { |
||||||
|
publicKeyOrToken = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Name { |
||||||
|
get { |
||||||
|
return name; |
||||||
|
} |
||||||
|
set { |
||||||
|
name = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Culture { |
||||||
|
get { |
||||||
|
return culture; |
||||||
|
} |
||||||
|
set { |
||||||
|
culture = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint HashValue { |
||||||
|
get { |
||||||
|
return hashValue; |
||||||
|
} |
||||||
|
set { |
||||||
|
hashValue = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
major = binaryReader.ReadUInt16(); |
||||||
|
minor = binaryReader.ReadUInt16(); |
||||||
|
build = binaryReader.ReadUInt16(); |
||||||
|
revision = binaryReader.ReadUInt16(); |
||||||
|
flags = binaryReader.ReadUInt32(); |
||||||
|
publicKeyOrToken = LoadBlobIndex(); |
||||||
|
name = LoadStringIndex(); |
||||||
|
culture = LoadStringIndex(); |
||||||
|
hashValue = LoadBlobIndex(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,63 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class AssemblyRefOS : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x25; |
||||||
|
|
||||||
|
uint osPlatformID; |
||||||
|
uint osMajorVersion; |
||||||
|
uint osMinorVersion; |
||||||
|
uint assemblyRefIndex; // index into the AssemblyRef table
|
||||||
|
|
||||||
|
public uint OSPlatformID { |
||||||
|
get { |
||||||
|
return osPlatformID; |
||||||
|
} |
||||||
|
set { |
||||||
|
osPlatformID = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint OSMajorVersion { |
||||||
|
get { |
||||||
|
return osMajorVersion; |
||||||
|
} |
||||||
|
set { |
||||||
|
osMajorVersion = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint OSMinorVersion { |
||||||
|
get { |
||||||
|
return osMinorVersion; |
||||||
|
} |
||||||
|
set { |
||||||
|
osMinorVersion = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint AssemblyRefIndex { |
||||||
|
get { |
||||||
|
return assemblyRefIndex; |
||||||
|
} |
||||||
|
set { |
||||||
|
assemblyRefIndex = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
osPlatformID = binaryReader.ReadUInt32(); |
||||||
|
osMajorVersion = binaryReader.ReadUInt32(); |
||||||
|
osMinorVersion = binaryReader.ReadUInt32(); |
||||||
|
assemblyRefIndex = ReadSimpleIndex(AssemblyRef.TABLE_ID); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,43 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class AssemblyRefProcessor : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x24; |
||||||
|
|
||||||
|
uint processor; |
||||||
|
uint assemblyRefIndex; // index into the AssemblyRef table
|
||||||
|
|
||||||
|
public uint Processor { |
||||||
|
get { |
||||||
|
return processor; |
||||||
|
} |
||||||
|
set { |
||||||
|
processor = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint AssemblyRefIndex { |
||||||
|
get { |
||||||
|
return assemblyRefIndex; |
||||||
|
} |
||||||
|
set { |
||||||
|
assemblyRefIndex = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
processor = binaryReader.ReadUInt32(); |
||||||
|
assemblyRefIndex = ReadSimpleIndex(AssemblyRef.TABLE_ID); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,54 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class ClassLayout : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x0F; |
||||||
|
|
||||||
|
ushort packingSize; |
||||||
|
uint classSize; |
||||||
|
uint parent; // index into TypeDef table
|
||||||
|
|
||||||
|
public ushort PackingSize { |
||||||
|
get { |
||||||
|
return packingSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
packingSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint ClassSize { |
||||||
|
get { |
||||||
|
return classSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
classSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Parent { |
||||||
|
get { |
||||||
|
return parent; |
||||||
|
} |
||||||
|
set { |
||||||
|
parent = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
packingSize = binaryReader.ReadUInt16(); |
||||||
|
classSize = binaryReader.ReadUInt32(); |
||||||
|
parent = ReadSimpleIndex(TypeDef.TABLE_ID); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,24 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public enum CodedIndex { |
||||||
|
TypeDefOrRef, |
||||||
|
HasConstant, |
||||||
|
HasCustomAttribute, |
||||||
|
HasFieldMarshall, |
||||||
|
HasDeclSecurity, |
||||||
|
MemberRefParent, |
||||||
|
HasSemantics, |
||||||
|
MethodDefOrRef, |
||||||
|
MemberForwarded, |
||||||
|
Implementation, |
||||||
|
CustomAttributeType, |
||||||
|
ResolutionScope |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,57 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class Constant : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x0B; |
||||||
|
|
||||||
|
byte type; // a 1 byte constant, followed by a 1-byte padding zero
|
||||||
|
uint parent; // index into the Param or Field or Property table; more precisely, a HasConst coded index
|
||||||
|
uint val; // index into Blob heap
|
||||||
|
|
||||||
|
public byte Type { |
||||||
|
get { |
||||||
|
return type; |
||||||
|
} |
||||||
|
set { |
||||||
|
type = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Parent { |
||||||
|
get { |
||||||
|
return parent; |
||||||
|
} |
||||||
|
set { |
||||||
|
parent = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Val { |
||||||
|
get { |
||||||
|
return val; |
||||||
|
} |
||||||
|
set { |
||||||
|
val = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
type = binaryReader.ReadByte(); |
||||||
|
byte paddingZero = binaryReader.ReadByte(); |
||||||
|
// if (paddingZero != 0) {
|
||||||
|
// Console.WriteLine("padding zero != 0");
|
||||||
|
// }
|
||||||
|
parent = ReadCodedIndex(CodedIndex.HasConstant); |
||||||
|
val = LoadBlobIndex(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,55 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class CustomAttribute : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x0C; |
||||||
|
|
||||||
|
uint parent; // index into any metadata table, except the CustomAttribute table itself; more precisely, a HasCustomAttribute coded index
|
||||||
|
uint type; // index into the Method or MemberRef table; more precisely, a CustomAttributeType coded index
|
||||||
|
uint val; // index into Blob heap
|
||||||
|
|
||||||
|
public uint Parent { |
||||||
|
get { |
||||||
|
return parent; |
||||||
|
} |
||||||
|
set { |
||||||
|
parent = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint Type { |
||||||
|
get { |
||||||
|
return type; |
||||||
|
} |
||||||
|
set { |
||||||
|
type = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint Val { |
||||||
|
get { |
||||||
|
return val; |
||||||
|
} |
||||||
|
set { |
||||||
|
val = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
parent = ReadCodedIndex(CodedIndex.HasCustomAttribute); |
||||||
|
type = ReadCodedIndex(CodedIndex.CustomAttributeType); |
||||||
|
val = LoadBlobIndex(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,54 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class DeclSecurity : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x0E; |
||||||
|
|
||||||
|
|
||||||
|
ushort action; |
||||||
|
uint parent; // index into the TypeDef, Method or Assembly table; more precisely, a HasDeclSecurity coded index
|
||||||
|
uint permissionSet; // index into Blob heap
|
||||||
|
|
||||||
|
public ushort Action { |
||||||
|
get { |
||||||
|
return action; |
||||||
|
} |
||||||
|
set { |
||||||
|
action = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Parent { |
||||||
|
get { |
||||||
|
return parent; |
||||||
|
} |
||||||
|
set { |
||||||
|
parent = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint PermissionSet { |
||||||
|
get { |
||||||
|
return permissionSet; |
||||||
|
} |
||||||
|
set { |
||||||
|
permissionSet = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
action = binaryReader.ReadUInt16(); |
||||||
|
parent = ReadCodedIndex(CodedIndex.HasDeclSecurity); |
||||||
|
permissionSet = LoadBlobIndex(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,43 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class ENCLog : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x1E; |
||||||
|
|
||||||
|
uint token; |
||||||
|
uint funcCode; |
||||||
|
|
||||||
|
public uint Token { |
||||||
|
get { |
||||||
|
return token; |
||||||
|
} |
||||||
|
set { |
||||||
|
token = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint FuncCode { |
||||||
|
get { |
||||||
|
return funcCode; |
||||||
|
} |
||||||
|
set { |
||||||
|
funcCode = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
token = binaryReader.ReadUInt32(); |
||||||
|
funcCode = binaryReader.ReadUInt32(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,33 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class ENCMap : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x1F; |
||||||
|
|
||||||
|
uint token; |
||||||
|
|
||||||
|
public uint Token { |
||||||
|
get { |
||||||
|
return token; |
||||||
|
} |
||||||
|
set { |
||||||
|
token = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
token = binaryReader.ReadUInt32(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,57 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class Event : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x14; |
||||||
|
|
||||||
|
public static readonly ushort FLAG_SPECIALNAME = 0x0200; |
||||||
|
public static readonly ushort FLAG_RTSPECIALNAME = 0x0400; |
||||||
|
|
||||||
|
ushort eventFlags; |
||||||
|
uint name; // index into String heap
|
||||||
|
uint eventType; // index into TypeDef, TypeRef or TypeSpec tables; more precisely, a TypeDefOrRef coded index
|
||||||
|
|
||||||
|
public ushort EventFlags { |
||||||
|
get { |
||||||
|
return eventFlags; |
||||||
|
} |
||||||
|
set { |
||||||
|
eventFlags = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint Name { |
||||||
|
get { |
||||||
|
return name; |
||||||
|
} |
||||||
|
set { |
||||||
|
name = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint EventType { |
||||||
|
get { |
||||||
|
return eventType; |
||||||
|
} |
||||||
|
set { |
||||||
|
eventType = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
eventFlags = binaryReader.ReadUInt16(); |
||||||
|
name = LoadStringIndex(); |
||||||
|
eventType = ReadCodedIndex(CodedIndex.TypeDefOrRef); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,44 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class EventMap : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x12; |
||||||
|
|
||||||
|
uint parent; // index into the TypeDef table
|
||||||
|
uint eventList; // index into Event table
|
||||||
|
|
||||||
|
public uint Parent { |
||||||
|
get { |
||||||
|
return parent; |
||||||
|
} |
||||||
|
set { |
||||||
|
parent = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint EventList { |
||||||
|
get { |
||||||
|
return eventList; |
||||||
|
} |
||||||
|
set { |
||||||
|
eventList = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
parent = ReadSimpleIndex(TypeDef.TABLE_ID); |
||||||
|
eventList = ReadSimpleIndex(Event.TABLE_ID); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,33 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class EventPtr : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 19; |
||||||
|
|
||||||
|
uint eventPtr; |
||||||
|
|
||||||
|
public uint Event { |
||||||
|
get { |
||||||
|
return eventPtr; |
||||||
|
} |
||||||
|
set { |
||||||
|
eventPtr = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
eventPtr = ReadSimpleIndex(ICSharpCode.SharpAssembly.Metadata.Rows.Event.TABLE_ID); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,76 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class ExportedType : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x27; |
||||||
|
|
||||||
|
uint flags; |
||||||
|
uint typeDefId; // 4 byte index into a TypeDef table of another module in this Assembly
|
||||||
|
uint typeName; // index into the String heap
|
||||||
|
uint typeNamespace; // index into the String heap
|
||||||
|
uint implementation; // index see 21.14
|
||||||
|
|
||||||
|
public uint Flags { |
||||||
|
get { |
||||||
|
return flags; |
||||||
|
} |
||||||
|
set { |
||||||
|
flags = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint TypeDefId { |
||||||
|
get { |
||||||
|
return typeDefId; |
||||||
|
} |
||||||
|
set { |
||||||
|
typeDefId = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint TypeName { |
||||||
|
get { |
||||||
|
return typeName; |
||||||
|
} |
||||||
|
set { |
||||||
|
typeName = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint TypeNamespace { |
||||||
|
get { |
||||||
|
return typeNamespace; |
||||||
|
} |
||||||
|
set { |
||||||
|
typeNamespace = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Implementation { |
||||||
|
get { |
||||||
|
return implementation; |
||||||
|
} |
||||||
|
set { |
||||||
|
implementation = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
flags = binaryReader.ReadUInt32(); |
||||||
|
typeDefId = binaryReader.ReadUInt32(); |
||||||
|
typeName = LoadStringIndex(); |
||||||
|
typeNamespace = LoadStringIndex(); |
||||||
|
|
||||||
|
// todo 32 bit indices ?
|
||||||
|
implementation = binaryReader.ReadUInt16(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,84 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class Field : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x04; |
||||||
|
|
||||||
|
public static readonly ushort FLAG_FIELDACCESSMASK = 0x0007; |
||||||
|
public static readonly ushort FLAG_COMPILERCONTROLLED = 0x0000; |
||||||
|
public static readonly ushort FLAG_PRIVATE = 0x0001; |
||||||
|
public static readonly ushort FLAG_FAMANDASSEM = 0x0002; |
||||||
|
public static readonly ushort FLAG_ASSEMBLY = 0x0003; |
||||||
|
public static readonly ushort FLAG_FAMILY = 0x0004; |
||||||
|
public static readonly ushort FLAG_FAMORASSEM = 0x0005; |
||||||
|
public static readonly ushort FLAG_PUBLIC = 0x0006; |
||||||
|
public static readonly ushort FLAG_STATIC = 0x0010; |
||||||
|
public static readonly ushort FLAG_INITONLY = 0x0020; |
||||||
|
public static readonly ushort FLAG_LITERAL = 0x0040; |
||||||
|
public static readonly ushort FLAG_NOTSERIALIZED = 0x0080; |
||||||
|
public static readonly ushort FLAG_SPECIALNAME = 0x0200; |
||||||
|
public static readonly ushort FLAG_PINVOKEIMPL = 0x2000; |
||||||
|
public static readonly ushort FLAG_RTSPECIALNAME = 0x0400; |
||||||
|
public static readonly ushort FLAG_HASFIELDMARSHAL = 0x1000; |
||||||
|
public static readonly ushort FLAG_HASDEFAULT = 0x8000; |
||||||
|
public static readonly ushort FLAG_HASFIELDRVA = 0x0100; |
||||||
|
|
||||||
|
ushort flags; |
||||||
|
uint name; // index into String heap
|
||||||
|
uint signature; // index into Blob heap
|
||||||
|
|
||||||
|
public ushort Flags { |
||||||
|
get { |
||||||
|
return flags; |
||||||
|
} |
||||||
|
set { |
||||||
|
flags = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint Name { |
||||||
|
get { |
||||||
|
return name; |
||||||
|
} |
||||||
|
set { |
||||||
|
name = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint Signature { |
||||||
|
get { |
||||||
|
return signature; |
||||||
|
} |
||||||
|
set { |
||||||
|
signature = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool IsFlagSet(uint flag) |
||||||
|
{ |
||||||
|
return base.BaseIsFlagSet(this.flags, flag); |
||||||
|
} |
||||||
|
|
||||||
|
public bool IsMaskedFlagSet(uint flag, uint flag_mask) |
||||||
|
{ |
||||||
|
return base.BaseIsFlagSet(this.flags, flag, flag_mask); |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
flags = binaryReader.ReadUInt16(); |
||||||
|
name = LoadStringIndex(); |
||||||
|
signature = LoadBlobIndex(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,44 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class FieldLayout : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x10; |
||||||
|
|
||||||
|
|
||||||
|
uint offset; |
||||||
|
uint field; // index into the field table
|
||||||
|
|
||||||
|
public uint Offset { |
||||||
|
get { |
||||||
|
return offset; |
||||||
|
} |
||||||
|
set { |
||||||
|
offset = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint FieldIndex { |
||||||
|
get { |
||||||
|
return field; |
||||||
|
} |
||||||
|
set { |
||||||
|
field = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
offset = binaryReader.ReadUInt32(); |
||||||
|
field = ReadSimpleIndex(Field.TABLE_ID); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,44 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class FieldMarshal : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x0D; |
||||||
|
|
||||||
|
uint parent; // index into Field or Param table; more precisely, a HasFieldMarshal coded index
|
||||||
|
uint nativeType; // index into the Blob heap
|
||||||
|
|
||||||
|
public uint Parent { |
||||||
|
get { |
||||||
|
return parent; |
||||||
|
} |
||||||
|
set { |
||||||
|
parent = value; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
public uint NativeType { |
||||||
|
get { |
||||||
|
return nativeType; |
||||||
|
} |
||||||
|
set { |
||||||
|
nativeType = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
parent = ReadCodedIndex(CodedIndex.HasFieldMarshall); |
||||||
|
nativeType = LoadBlobIndex(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,33 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class FieldPtr : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x03; |
||||||
|
|
||||||
|
uint field; |
||||||
|
|
||||||
|
public uint Field { |
||||||
|
get { |
||||||
|
return field; |
||||||
|
} |
||||||
|
set { |
||||||
|
field = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
field = ReadSimpleIndex(ICSharpCode.SharpAssembly.Metadata.Rows.Field.TABLE_ID); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,44 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class FieldRVA : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x1D; |
||||||
|
|
||||||
|
uint rva; |
||||||
|
uint field; // index into Field table
|
||||||
|
|
||||||
|
public uint RVA { |
||||||
|
get { |
||||||
|
return rva; |
||||||
|
} |
||||||
|
set { |
||||||
|
rva = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint FieldIndex { |
||||||
|
get { |
||||||
|
return field; |
||||||
|
} |
||||||
|
set { |
||||||
|
field = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
rva = binaryReader.ReadUInt32(); |
||||||
|
field = ReadSimpleIndex(Field.TABLE_ID); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,56 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class File : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x26; |
||||||
|
|
||||||
|
public static readonly uint FLAG_CONTAINSMETADATA = 0x0000; |
||||||
|
public static readonly uint FLAG_CONTAINSNOMETADATA = 0x0001; |
||||||
|
|
||||||
|
uint flags; |
||||||
|
uint name; // index into String heap
|
||||||
|
uint hashValue; // index into Blob heap
|
||||||
|
|
||||||
|
public uint Flags { |
||||||
|
get { |
||||||
|
return flags; |
||||||
|
} |
||||||
|
set { |
||||||
|
flags = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Name { |
||||||
|
get { |
||||||
|
return name; |
||||||
|
} |
||||||
|
set { |
||||||
|
name = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint HashValue { |
||||||
|
get { |
||||||
|
return hashValue; |
||||||
|
} |
||||||
|
set { |
||||||
|
hashValue = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
flags = binaryReader.ReadUInt32(); |
||||||
|
name = LoadStringIndex(); |
||||||
|
hashValue = LoadBlobIndex(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,80 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class ImplMap : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x1C; |
||||||
|
|
||||||
|
public static readonly ushort FLAG_NOMANGLE = 0x0001; |
||||||
|
public static readonly ushort FLAG_CHARSETMASK = 0x0006; |
||||||
|
public static readonly ushort FLAG_CHARSETNOTSPEC = 0x0000; |
||||||
|
public static readonly ushort FLAG_CHARSETANSI = 0x0002; |
||||||
|
public static readonly ushort FLAG_CHARSETUNICODE = 0x0004; |
||||||
|
public static readonly ushort FLAG_CHARSETAUTO = 0x0006; |
||||||
|
public static readonly ushort FLAG_SUPPORTSLASTERROR = 0x0040; |
||||||
|
public static readonly ushort FLAG_CALLCONVMASK = 0x0700; |
||||||
|
public static readonly ushort FLAG_CALLCONVWINAPI = 0x0100; |
||||||
|
public static readonly ushort FLAG_CALLCONVCDECL = 0x0200; |
||||||
|
public static readonly ushort FLAG_CALLCONVSTDCALL = 0x0300; |
||||||
|
public static readonly ushort FLAG_CALLCONVTHISCALL = 0x0400; |
||||||
|
public static readonly ushort FLAG_CALLCONVFASTCALL = 0x0500; |
||||||
|
|
||||||
|
ushort mappingFlags; |
||||||
|
uint memberForwarded; // index into the Field or Method table; more precisely, a MemberForwarded coded index.
|
||||||
|
uint importName; // index into the String heap
|
||||||
|
uint importScope; // index into the ModuleRef table
|
||||||
|
|
||||||
|
public ushort MappingFlags { |
||||||
|
get { |
||||||
|
return mappingFlags; |
||||||
|
} |
||||||
|
set { |
||||||
|
mappingFlags = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint MemberForwarded { |
||||||
|
get { |
||||||
|
return memberForwarded; |
||||||
|
} |
||||||
|
set { |
||||||
|
memberForwarded = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint ImportName { |
||||||
|
get { |
||||||
|
return importName; |
||||||
|
} |
||||||
|
set { |
||||||
|
importName = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint ImportScope { |
||||||
|
get { |
||||||
|
return importScope; |
||||||
|
} |
||||||
|
set { |
||||||
|
importScope = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
mappingFlags = binaryReader.ReadUInt16(); |
||||||
|
memberForwarded = ReadCodedIndex(CodedIndex.MemberForwarded); |
||||||
|
importName = LoadStringIndex(); |
||||||
|
importScope = ReadSimpleIndex(ModuleRef.TABLE_ID); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,45 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class InterfaceImpl : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x09; |
||||||
|
|
||||||
|
uint myClass; // index into the TypeDef table
|
||||||
|
uint myInterface; // index into the TypeDef, TypeRef or TypeSpec table; more precisely, a TypeDefOrRef coded index
|
||||||
|
|
||||||
|
public uint Class { |
||||||
|
get { |
||||||
|
return myClass; |
||||||
|
} |
||||||
|
set { |
||||||
|
myClass = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint Interface { |
||||||
|
get { |
||||||
|
return myInterface; |
||||||
|
} |
||||||
|
set { |
||||||
|
myInterface = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
myClass = ReadSimpleIndex(TypeDef.TABLE_ID); |
||||||
|
myInterface = ReadCodedIndex(CodedIndex.TypeDefOrRef); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,70 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class ManifestResource : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x28; |
||||||
|
|
||||||
|
public static readonly uint FLAG_VISIBILITYMASK = 0x0007; |
||||||
|
public static readonly uint FLAG_PUBLIC = 0x0001; |
||||||
|
public static readonly uint FLAG_PRIVATE = 0x0002; |
||||||
|
|
||||||
|
uint offset; |
||||||
|
uint flags; |
||||||
|
uint name; // index into String heap
|
||||||
|
uint implementation; // index into File table, or AssemblyRef table, or null; more precisely, an Implementation coded index
|
||||||
|
|
||||||
|
public uint Offset { |
||||||
|
get { |
||||||
|
return offset; |
||||||
|
} |
||||||
|
set { |
||||||
|
offset = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint Flags { |
||||||
|
get { |
||||||
|
return flags; |
||||||
|
} |
||||||
|
set { |
||||||
|
flags = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint Name { |
||||||
|
get { |
||||||
|
return name; |
||||||
|
} |
||||||
|
set { |
||||||
|
name = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint Implementation { |
||||||
|
get { |
||||||
|
return implementation; |
||||||
|
} |
||||||
|
set { |
||||||
|
implementation = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
offset = binaryReader.ReadUInt32(); |
||||||
|
flags = binaryReader.ReadUInt32(); |
||||||
|
name = LoadStringIndex(); |
||||||
|
implementation = ReadCodedIndex(CodedIndex.Implementation); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,54 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class MemberRef : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x0A; |
||||||
|
|
||||||
|
uint myClass; // index into the TypeRef, ModuleRef, Method, TypeSpec or TypeDef tables; more precisely, a MemberRefParent coded index
|
||||||
|
uint name; // index into String heap
|
||||||
|
uint signature; // index into Blob heap
|
||||||
|
|
||||||
|
public uint Class { |
||||||
|
get { |
||||||
|
return myClass; |
||||||
|
} |
||||||
|
set { |
||||||
|
myClass = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Name { |
||||||
|
get { |
||||||
|
return name; |
||||||
|
} |
||||||
|
set { |
||||||
|
name = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Signature { |
||||||
|
get { |
||||||
|
return signature; |
||||||
|
} |
||||||
|
set { |
||||||
|
signature = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
myClass = ReadCodedIndex(CodedIndex.MemberRefParent); |
||||||
|
name = LoadStringIndex(); |
||||||
|
signature = LoadBlobIndex(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,142 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class Method : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x06; |
||||||
|
|
||||||
|
public static readonly ushort FLAG_MEMBERACCESSMASK = 0X0007; |
||||||
|
public static readonly ushort FLAG_COMPILERCONTROLLED = 0X0000; |
||||||
|
public static readonly ushort FLAG_PRIVATE = 0X0001; |
||||||
|
public static readonly ushort FLAG_FAMANDASSEM = 0X0002; |
||||||
|
public static readonly ushort FLAG_ASSEM = 0X0003; |
||||||
|
public static readonly ushort FLAG_FAMILY = 0X0004; |
||||||
|
public static readonly ushort FLAG_FAMORASSEM = 0X0005; |
||||||
|
public static readonly ushort FLAG_PUBLIC = 0X0006; |
||||||
|
public static readonly ushort FLAG_STATIC = 0X0010; |
||||||
|
public static readonly ushort FLAG_FINAL = 0X0020; |
||||||
|
public static readonly ushort FLAG_VIRTUAL = 0X0040; |
||||||
|
public static readonly ushort FLAG_HIDEBYSIG = 0X0080; |
||||||
|
public static readonly ushort FLAG_VTABLELAYOUTMASK = 0X0100; |
||||||
|
public static readonly ushort FLAG_REUSESLOT = 0X0000; |
||||||
|
public static readonly ushort FLAG_NEWSLOT = 0X0100; |
||||||
|
public static readonly ushort FLAG_ABSTRACT = 0X0400; |
||||||
|
public static readonly ushort FLAG_SPECIALNAME = 0X0800; |
||||||
|
public static readonly ushort FLAG_PINVOKEIMPL = 0X2000; |
||||||
|
public static readonly ushort FLAG_UNMANAGEDEXPORT = 0X0008; |
||||||
|
public static readonly ushort FLAG_RTSPECIALNAME = 0X1000; |
||||||
|
public static readonly ushort FLAG_HASSECURITY = 0X4000; |
||||||
|
public static readonly ushort FLAG_REQUIRESECOBJECT = 0X8000; |
||||||
|
|
||||||
|
public static readonly ushort IMPLFLAG_CODETYPEMASK = 0X0003; |
||||||
|
public static readonly ushort IMPLFLAG_IL = 0X0000; |
||||||
|
public static readonly ushort IMPLFLAG_NATIVE = 0X0001; |
||||||
|
public static readonly ushort IMPLFLAG_OPTIL = 0X0002; |
||||||
|
public static readonly ushort IMPLFLAG_RUNTIME = 0X0003; |
||||||
|
public static readonly ushort IMPLFLAG_MANAGEDMASK = 0X0004; |
||||||
|
public static readonly ushort IMPLFLAG_UNMANAGED = 0X0004; |
||||||
|
public static readonly ushort IMPLFLAG_MANAGED = 0X0000; |
||||||
|
public static readonly ushort IMPLFLAG_FORWARDREF = 0X0010; |
||||||
|
public static readonly ushort IMPLFLAG_PRESERVESIG = 0X0080; |
||||||
|
public static readonly ushort IMPLFLAG_INTERNALCALL = 0X1000; |
||||||
|
public static readonly ushort IMPLFLAG_SYNCHRONIZED = 0X0020; |
||||||
|
public static readonly ushort IMPLFLAG_NOINLINING = 0X0008; |
||||||
|
public static readonly ushort IMPLFLAG_MAXMETHODIMPLVAL = 0XFFFF; |
||||||
|
|
||||||
|
uint rva; |
||||||
|
ushort implFlags; |
||||||
|
ushort flags; |
||||||
|
uint name; // index into String heap
|
||||||
|
uint signature; // index into Blob heap
|
||||||
|
uint paramList; // index into Param table
|
||||||
|
|
||||||
|
public uint RVA { |
||||||
|
get { |
||||||
|
return rva; |
||||||
|
} |
||||||
|
set { |
||||||
|
rva = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public ushort ImplFlags { |
||||||
|
get { |
||||||
|
return implFlags; |
||||||
|
} |
||||||
|
set { |
||||||
|
implFlags = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public ushort Flags { |
||||||
|
get { |
||||||
|
return flags; |
||||||
|
} |
||||||
|
set { |
||||||
|
flags = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint Name { |
||||||
|
get { |
||||||
|
return name; |
||||||
|
} |
||||||
|
set { |
||||||
|
name = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint Signature { |
||||||
|
get { |
||||||
|
return signature; |
||||||
|
} |
||||||
|
set { |
||||||
|
signature = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint ParamList { |
||||||
|
get { |
||||||
|
return paramList; |
||||||
|
} |
||||||
|
set { |
||||||
|
paramList = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool IsFlagSet(uint flag) |
||||||
|
{ |
||||||
|
return base.BaseIsFlagSet(this.flags, flag); |
||||||
|
} |
||||||
|
|
||||||
|
public bool IsMaskedFlagSet(uint flag, uint flag_mask) |
||||||
|
{ |
||||||
|
return base.BaseIsFlagSet(this.flags, flag, flag_mask); |
||||||
|
} |
||||||
|
|
||||||
|
public bool IsImplFlagSet(uint flag) |
||||||
|
{ |
||||||
|
return base.BaseIsFlagSet(this.implFlags, flag); |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
rva = binaryReader.ReadUInt32(); |
||||||
|
implFlags = binaryReader.ReadUInt16(); |
||||||
|
flags = binaryReader.ReadUInt16(); |
||||||
|
name = LoadStringIndex(); |
||||||
|
signature = LoadBlobIndex(); |
||||||
|
|
||||||
|
paramList = ReadSimpleIndex(Param.TABLE_ID); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,53 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class MethodImpl : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x19; |
||||||
|
|
||||||
|
uint myClass; // index into TypeDef table
|
||||||
|
uint methodBody; // index into Method or MemberRef table; more precisely, a MethodDefOrRef coded index
|
||||||
|
uint methodDeclaration; // index into Method or MemberRef table; more precisely, a MethodDefOrRef coded index
|
||||||
|
|
||||||
|
public uint MyClass { |
||||||
|
get { |
||||||
|
return myClass; |
||||||
|
} |
||||||
|
set { |
||||||
|
myClass = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint MethodBody { |
||||||
|
get { |
||||||
|
return methodBody; |
||||||
|
} |
||||||
|
set { |
||||||
|
methodBody = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint MethodDeclaration { |
||||||
|
get { |
||||||
|
return methodDeclaration; |
||||||
|
} |
||||||
|
set { |
||||||
|
methodDeclaration = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
myClass = ReadSimpleIndex(TypeDef.TABLE_ID); |
||||||
|
methodBody = ReadCodedIndex(CodedIndex.MethodDefOrRef); |
||||||
|
methodDeclaration = ReadCodedIndex(CodedIndex.MethodDefOrRef); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,33 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class MethodPtr : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x05; |
||||||
|
|
||||||
|
uint method; |
||||||
|
|
||||||
|
public uint Method { |
||||||
|
get { |
||||||
|
return method; |
||||||
|
} |
||||||
|
set { |
||||||
|
method = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
method = ReadSimpleIndex(ICSharpCode.SharpAssembly.Metadata.Rows.Method.TABLE_ID); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,63 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class MethodSemantics : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x18; |
||||||
|
|
||||||
|
public static readonly ushort SEM_SETTER = 0x0001; |
||||||
|
public static readonly ushort SEM_GETTER = 0x0002; |
||||||
|
public static readonly ushort SEM_OTHER = 0x0004; |
||||||
|
public static readonly ushort SEM_ADDON = 0x0008; |
||||||
|
public static readonly ushort SEM_REMOVEON = 0x0010; |
||||||
|
public static readonly ushort SEM_FIRE = 0x0020; |
||||||
|
|
||||||
|
ushort semantics; |
||||||
|
uint method; // index into the Method table
|
||||||
|
uint association; // index into the Event or Property table; more precisely, a HasSemantics coded index
|
||||||
|
|
||||||
|
public ushort Semantics { |
||||||
|
get { |
||||||
|
return semantics; |
||||||
|
} |
||||||
|
set { |
||||||
|
semantics = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint Method { |
||||||
|
get { |
||||||
|
return method; |
||||||
|
} |
||||||
|
set { |
||||||
|
method = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint Association { |
||||||
|
get { |
||||||
|
return association; |
||||||
|
} |
||||||
|
set { |
||||||
|
association = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
semantics = binaryReader.ReadUInt16(); |
||||||
|
method = ReadSimpleIndex(ICSharpCode.SharpAssembly.Metadata.Rows.Method.TABLE_ID); |
||||||
|
association = ReadCodedIndex(CodedIndex.HasSemantics); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,74 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class Module : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x00; |
||||||
|
|
||||||
|
ushort generation; |
||||||
|
uint name; // index into String heap
|
||||||
|
uint mvid; // index into Guid heap
|
||||||
|
uint encid; // index into Guid heap, reserved, shall be zero
|
||||||
|
uint encbaseid; // index into Guid heap, reserved, shall be zero
|
||||||
|
|
||||||
|
public ushort Generation { |
||||||
|
get { |
||||||
|
return generation; |
||||||
|
} |
||||||
|
set { |
||||||
|
generation = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Name { |
||||||
|
get { |
||||||
|
return name; |
||||||
|
} |
||||||
|
set { |
||||||
|
name = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Mvid { |
||||||
|
get { |
||||||
|
return mvid; |
||||||
|
} |
||||||
|
set { |
||||||
|
mvid = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Encid { |
||||||
|
get { |
||||||
|
return encid; |
||||||
|
} |
||||||
|
set { |
||||||
|
encid = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Encbaseid { |
||||||
|
get { |
||||||
|
return encbaseid; |
||||||
|
} |
||||||
|
set { |
||||||
|
encbaseid = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
generation = binaryReader.ReadUInt16(); |
||||||
|
name = LoadStringIndex(); |
||||||
|
mvid = LoadGUIDIndex(); |
||||||
|
encid = LoadGUIDIndex(); |
||||||
|
encbaseid = LoadGUIDIndex(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,33 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class ModuleRef : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x1A; |
||||||
|
|
||||||
|
uint name; // index into String heap
|
||||||
|
|
||||||
|
public uint Name { |
||||||
|
get { |
||||||
|
return name; |
||||||
|
} |
||||||
|
set { |
||||||
|
name = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
name = LoadStringIndex(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,43 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class NestedClass : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x29; |
||||||
|
|
||||||
|
uint nestedClass; // index into the TypeDef table
|
||||||
|
uint enclosingClass; // index into the TypeDef table
|
||||||
|
|
||||||
|
public uint NestedClassIndex { |
||||||
|
get { |
||||||
|
return nestedClass; |
||||||
|
} |
||||||
|
set { |
||||||
|
nestedClass = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint EnclosingClass { |
||||||
|
get { |
||||||
|
return enclosingClass; |
||||||
|
} |
||||||
|
set { |
||||||
|
enclosingClass = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
nestedClass = ReadSimpleIndex(TypeDef.TABLE_ID); |
||||||
|
enclosingClass = ReadSimpleIndex(TypeDef.TABLE_ID); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,67 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class Param : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x08; |
||||||
|
|
||||||
|
public static readonly ushort FLAG_IN = 0x0001; |
||||||
|
public static readonly ushort FLAG_OUT = 0x0002; |
||||||
|
public static readonly ushort FLAG_OPTIONAL = 0x0004; |
||||||
|
public static readonly ushort FLAG_HASDEFAULT = 0x1000; |
||||||
|
public static readonly ushort FLAG_HASFIELDMARSHAL = 0x2000; |
||||||
|
public static readonly ushort FLAG_UNUSED = 0xcfe0; |
||||||
|
|
||||||
|
ushort flags; |
||||||
|
ushort sequence; |
||||||
|
uint name; // index into String heap
|
||||||
|
|
||||||
|
public ushort Flags { |
||||||
|
get { |
||||||
|
return flags; |
||||||
|
} |
||||||
|
set { |
||||||
|
flags = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public ushort Sequence { |
||||||
|
get { |
||||||
|
return sequence; |
||||||
|
} |
||||||
|
set { |
||||||
|
sequence = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint Name { |
||||||
|
get { |
||||||
|
return name; |
||||||
|
} |
||||||
|
set { |
||||||
|
name = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool IsFlagSet(uint flag) |
||||||
|
{ |
||||||
|
return base.BaseIsFlagSet(this.flags, flag); |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
flags = binaryReader.ReadUInt16(); |
||||||
|
sequence = binaryReader.ReadUInt16(); |
||||||
|
name = LoadStringIndex(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,33 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class ParamPtr : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x07; |
||||||
|
|
||||||
|
uint param; |
||||||
|
|
||||||
|
public uint Param { |
||||||
|
get { |
||||||
|
return param; |
||||||
|
} |
||||||
|
set { |
||||||
|
param = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
param = ReadSimpleIndex(ICSharpCode.SharpAssembly.Metadata.Rows.Param.TABLE_ID); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,65 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class Property : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x17; |
||||||
|
|
||||||
|
public static readonly ushort FLAG_SPECIALNAME = 0x0200; |
||||||
|
public static readonly ushort FLAG_RTSPECIALNAME = 0x0400; |
||||||
|
public static readonly ushort FLAG_HASDEFAULT = 0x1000; |
||||||
|
public static readonly ushort FLAG_UNUSED = 0xe9ff; |
||||||
|
|
||||||
|
ushort flags; |
||||||
|
uint name; // index into String heap
|
||||||
|
uint type; // index into Blob heap
|
||||||
|
|
||||||
|
public ushort Flags { |
||||||
|
get { |
||||||
|
return flags; |
||||||
|
} |
||||||
|
set { |
||||||
|
flags = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint Name { |
||||||
|
get { |
||||||
|
return name; |
||||||
|
} |
||||||
|
set { |
||||||
|
name = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint Type { |
||||||
|
get { |
||||||
|
return type; |
||||||
|
} |
||||||
|
set { |
||||||
|
type = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool IsFlagSet(uint flag) |
||||||
|
{ |
||||||
|
return base.BaseIsFlagSet(this.flags, flag); |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
flags = binaryReader.ReadUInt16(); |
||||||
|
name = LoadStringIndex(); |
||||||
|
type = LoadBlobIndex(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,44 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class PropertyMap : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x15; |
||||||
|
|
||||||
|
uint parent; // index into the TypeDef table
|
||||||
|
uint propertyList; // index into Property table
|
||||||
|
|
||||||
|
public uint Parent { |
||||||
|
get { |
||||||
|
return parent; |
||||||
|
} |
||||||
|
set { |
||||||
|
parent = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint PropertyList { |
||||||
|
get { |
||||||
|
return propertyList; |
||||||
|
} |
||||||
|
set { |
||||||
|
propertyList = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
parent = ReadSimpleIndex(TypeDef.TABLE_ID); |
||||||
|
propertyList = ReadSimpleIndex(Property.TABLE_ID); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,33 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class PropertyPtr : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 22; |
||||||
|
|
||||||
|
uint property; |
||||||
|
|
||||||
|
public uint Property { |
||||||
|
get { |
||||||
|
return property; |
||||||
|
} |
||||||
|
set { |
||||||
|
property = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
property = ReadSimpleIndex(ICSharpCode.SharpAssembly.Metadata.Rows.Property.TABLE_ID); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,34 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class StandAloneSig : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x11; |
||||||
|
|
||||||
|
uint signature; // index into the Blob heap
|
||||||
|
|
||||||
|
public uint Signature { |
||||||
|
get { |
||||||
|
return signature; |
||||||
|
} |
||||||
|
set { |
||||||
|
signature = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
signature = LoadBlobIndex(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,137 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class TypeDef : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x02; |
||||||
|
|
||||||
|
// Visibility attributes
|
||||||
|
public static readonly uint FLAG_VISIBILITYMASK = 0x00000007; |
||||||
|
public static readonly uint FLAG_NOTPUBLIC = 0x00000000; |
||||||
|
public static readonly uint FLAG_PUBLIC = 0x00000001; |
||||||
|
public static readonly uint FLAG_NESTEDPUBLIC = 0x00000002; |
||||||
|
public static readonly uint FLAG_NESTEDPRIVATE = 0x00000003; |
||||||
|
public static readonly uint FLAG_NESTEDFAMILY = 0x00000004; |
||||||
|
public static readonly uint FLAG_NESTEDASSEMBLY = 0x00000005; |
||||||
|
public static readonly uint FLAG_NESTEDFAMANDASSEM = 0x00000006; |
||||||
|
public static readonly uint FLAG_NESTEDFAMORASSEM = 0x00000007; |
||||||
|
|
||||||
|
//Class layout attributes
|
||||||
|
public static readonly uint FLAG_LAYOUTMASK = 0x00000018; |
||||||
|
public static readonly uint FLAG_AUTOLAYOUT = 0x00000000; |
||||||
|
public static readonly uint FLAG_SEQUENTIALLAYOUT = 0x00000008; |
||||||
|
public static readonly uint FLAG_EXPLICITLAYOUT = 0x00000010; |
||||||
|
|
||||||
|
//Class semantics attributes
|
||||||
|
public static readonly uint FLAG_CLASSSEMANTICSMASK = 0x00000020; |
||||||
|
public static readonly uint FLAG_CLASS = 0x00000000; |
||||||
|
public static readonly uint FLAG_INTERFACE = 0x00000020; |
||||||
|
|
||||||
|
// Special semantics in addition to class semantics
|
||||||
|
public static readonly uint FLAG_ABSTRACT = 0x00000080; |
||||||
|
public static readonly uint FLAG_SEALED = 0x00000100; |
||||||
|
public static readonly uint FLAG_SPECIALNAME = 0x00000400; |
||||||
|
|
||||||
|
// Implementation Attributes
|
||||||
|
public static readonly uint FLAG_IMPORT = 0x00001000; |
||||||
|
public static readonly uint FLAG_SERIALIZABLE = 0x00002000; |
||||||
|
|
||||||
|
//String formatting Attributes
|
||||||
|
public static readonly uint FLAG_STRINGFORMATMASK = 0x00030000; |
||||||
|
public static readonly uint FLAG_ANSICLASS = 0x00000000; |
||||||
|
public static readonly uint FLAG_UNICODECLASS = 0x00010000; |
||||||
|
public static readonly uint FLAG_AUTOCLASS = 0x00020000; |
||||||
|
|
||||||
|
//Class Initialization Attributes
|
||||||
|
public static readonly uint FLAG_BEFOREFIELDINIT = 0x00100000; |
||||||
|
|
||||||
|
//Additional Flags
|
||||||
|
public static readonly uint FLAG_RTSPECIALNAME = 0x00000800; |
||||||
|
public static readonly uint FLAG_HASSECURITY = 0x00040000; |
||||||
|
|
||||||
|
uint flags; |
||||||
|
uint name; |
||||||
|
uint nSpace; |
||||||
|
uint extends; // index into TypeDef, TypeRef or TypeSpec table; more precisely, a TypeDefOrRef coded index
|
||||||
|
uint fieldList; // index into Field table; it marks the first of a continguous run of Fields owned by this Type
|
||||||
|
uint methodList; // index into Method table; it marks the first of a continguous run of Methods owned by this Type
|
||||||
|
|
||||||
|
public uint Flags { |
||||||
|
get { |
||||||
|
return flags; |
||||||
|
} |
||||||
|
set { |
||||||
|
flags = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Name { |
||||||
|
get { |
||||||
|
return name; |
||||||
|
} |
||||||
|
set { |
||||||
|
name = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint NSpace { |
||||||
|
get { |
||||||
|
return nSpace; |
||||||
|
} |
||||||
|
set { |
||||||
|
nSpace = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Extends { |
||||||
|
get { |
||||||
|
return extends; |
||||||
|
} |
||||||
|
set { |
||||||
|
extends = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint FieldList { |
||||||
|
get { |
||||||
|
return fieldList; |
||||||
|
} |
||||||
|
set { |
||||||
|
fieldList = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint MethodList { |
||||||
|
get { |
||||||
|
return methodList; |
||||||
|
} |
||||||
|
set { |
||||||
|
methodList = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool IsFlagSet(uint flag) |
||||||
|
{ |
||||||
|
return base.BaseIsFlagSet(this.flags, flag); |
||||||
|
} |
||||||
|
|
||||||
|
public bool IsMaskedFlagSet(uint flag, uint flag_mask) |
||||||
|
{ |
||||||
|
return base.BaseIsFlagSet(this.flags, flag, flag_mask); |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
flags = binaryReader.ReadUInt32(); |
||||||
|
name = LoadStringIndex(); |
||||||
|
nSpace = LoadStringIndex(); |
||||||
|
extends = ReadCodedIndex(CodedIndex.TypeDefOrRef); |
||||||
|
fieldList = ReadSimpleIndex(Field.TABLE_ID); |
||||||
|
methodList = ReadSimpleIndex(Method.TABLE_ID); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,55 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class TypeRef : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x01; |
||||||
|
|
||||||
|
uint resolutionScope; // index into Module, ModuleRef, AssemblyRef or TypeRef tables, or null; more precisely, a ResolutionScope coded index
|
||||||
|
uint name; |
||||||
|
uint nspace; |
||||||
|
|
||||||
|
public uint ResolutionScope { |
||||||
|
get { |
||||||
|
return resolutionScope; |
||||||
|
} |
||||||
|
set { |
||||||
|
resolutionScope = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint Name { |
||||||
|
get { |
||||||
|
return name; |
||||||
|
} |
||||||
|
set { |
||||||
|
name = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint Nspace { |
||||||
|
get { |
||||||
|
return nspace; |
||||||
|
} |
||||||
|
set { |
||||||
|
nspace = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
resolutionScope = ReadCodedIndex(CodedIndex.ResolutionScope); |
||||||
|
name = LoadStringIndex(); |
||||||
|
nspace = LoadStringIndex(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,33 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata.Rows { |
||||||
|
|
||||||
|
public class TypeSpec : AbstractRow |
||||||
|
{ |
||||||
|
public static readonly int TABLE_ID = 0x1B; |
||||||
|
|
||||||
|
uint signature; // index into the Blob heap
|
||||||
|
|
||||||
|
public uint Signature { |
||||||
|
get { |
||||||
|
return signature; |
||||||
|
} |
||||||
|
set { |
||||||
|
signature = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadRow() |
||||||
|
{ |
||||||
|
signature = LoadBlobIndex(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,31 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata |
||||||
|
{ |
||||||
|
public enum CallingConvention : uint |
||||||
|
{ |
||||||
|
Default = 0x00, |
||||||
|
|
||||||
|
Cdecl = 0x01, |
||||||
|
Stdcall = 0x02, |
||||||
|
Thiscall = 0x03, |
||||||
|
Fastcall = 0x04, |
||||||
|
|
||||||
|
VarArg = 0x05, |
||||||
|
Field = 0x06, |
||||||
|
LocalSig = 0x07, |
||||||
|
Property = 0x08, |
||||||
|
UnMngd = 0x09, |
||||||
|
|
||||||
|
HasThis = 0x20, |
||||||
|
ExplicitThis = 0x40 |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,53 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Metadata |
||||||
|
{ |
||||||
|
public enum DataType |
||||||
|
{ |
||||||
|
End = 0x00, |
||||||
|
Void = 0x01, |
||||||
|
Boolean = 0x02, |
||||||
|
Char = 0x03, |
||||||
|
SByte = 0x04, |
||||||
|
Byte = 0x05, |
||||||
|
Int16 = 0x06, |
||||||
|
UInt16 = 0x07, |
||||||
|
Int32 = 0x08, |
||||||
|
UInt32 = 0x09, |
||||||
|
Int64 = 0x0A, |
||||||
|
UInt64 = 0x0B, |
||||||
|
Single = 0x0C, |
||||||
|
Double = 0x0D, |
||||||
|
|
||||||
|
String = 0x0E, |
||||||
|
Ptr = 0x0F, |
||||||
|
ByRef = 0x10, |
||||||
|
ValueType = 0x11, |
||||||
|
Class = 0x12, |
||||||
|
Array = 0x14, |
||||||
|
|
||||||
|
TypeReference = 0x16, |
||||||
|
IntPtr = 0x18, |
||||||
|
UIntPtr = 0x19, |
||||||
|
FnPtr = 0x1B, |
||||||
|
Object = 0x1C, |
||||||
|
SZArray = 0x1D, |
||||||
|
|
||||||
|
CModReq = 0x1F, |
||||||
|
CModOpt = 0x20, |
||||||
|
Internal = 0x21, |
||||||
|
|
||||||
|
Modifier = 0x40, |
||||||
|
Sentinel = 0x41, |
||||||
|
Pinned = 0x45 |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,167 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.PE { |
||||||
|
|
||||||
|
public class CLIHeader |
||||||
|
{ |
||||||
|
uint cb; |
||||||
|
ushort majorRuntimeVersion; |
||||||
|
ushort minorRuntimeVersion; |
||||||
|
uint metaData; |
||||||
|
uint metaDataSize; |
||||||
|
uint flags; |
||||||
|
uint entryPointToken; |
||||||
|
uint resources; |
||||||
|
uint resourcesSize; |
||||||
|
ulong strongNameSignature; |
||||||
|
ulong codeManagerTable; |
||||||
|
ulong vTableFixups; |
||||||
|
ulong exportAddressTableJumps; |
||||||
|
ulong managedNativeHeader; |
||||||
|
|
||||||
|
const uint COMIMAGE_FLAGS_ILONLY = 0x01; |
||||||
|
const uint COMIMAGE_FLAGS_32BITREQUIRED = 0x02; |
||||||
|
const uint COMIMAGE_FLAGS_STRONGNAMESIGNED = 0x08; |
||||||
|
const uint COMIMAGE_FLAGS_TRACKDEBUGDATA = 0x010000; |
||||||
|
|
||||||
|
public uint Cb { |
||||||
|
get { |
||||||
|
return cb; |
||||||
|
} |
||||||
|
set { |
||||||
|
cb = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public ushort MajorRuntimeVersion { |
||||||
|
get { |
||||||
|
return majorRuntimeVersion; |
||||||
|
} |
||||||
|
set { |
||||||
|
majorRuntimeVersion = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public ushort MinorRuntimeVersion { |
||||||
|
get { |
||||||
|
return minorRuntimeVersion; |
||||||
|
} |
||||||
|
set { |
||||||
|
minorRuntimeVersion = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint MetaData { |
||||||
|
get { |
||||||
|
return metaData; |
||||||
|
} |
||||||
|
set { |
||||||
|
metaData = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint MetaDataSize { |
||||||
|
get { |
||||||
|
return metaDataSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
metaDataSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Flags { |
||||||
|
get { |
||||||
|
return flags; |
||||||
|
} |
||||||
|
set { |
||||||
|
flags = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint EntryPointToken { |
||||||
|
get { |
||||||
|
return entryPointToken; |
||||||
|
} |
||||||
|
set { |
||||||
|
entryPointToken = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Resources { |
||||||
|
get { |
||||||
|
return resources; |
||||||
|
} |
||||||
|
set { |
||||||
|
resources = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint ResourcesSize { |
||||||
|
get { |
||||||
|
return resourcesSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
resourcesSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public ulong StrongNameSignature { |
||||||
|
get { |
||||||
|
return strongNameSignature; |
||||||
|
} |
||||||
|
set { |
||||||
|
strongNameSignature = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public ulong CodeManagerTable { |
||||||
|
get { |
||||||
|
return codeManagerTable; |
||||||
|
} |
||||||
|
set { |
||||||
|
codeManagerTable = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public ulong VTableFixups { |
||||||
|
get { |
||||||
|
return vTableFixups; |
||||||
|
} |
||||||
|
set { |
||||||
|
vTableFixups = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public ulong ExportAddressTableJumps { |
||||||
|
get { |
||||||
|
return exportAddressTableJumps; |
||||||
|
} |
||||||
|
set { |
||||||
|
exportAddressTableJumps = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public ulong ManagedNativeHeader { |
||||||
|
get { |
||||||
|
return managedNativeHeader; |
||||||
|
} |
||||||
|
set { |
||||||
|
managedNativeHeader = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public void LoadFrom(BinaryReader binaryReader) |
||||||
|
{ |
||||||
|
cb = binaryReader.ReadUInt32(); |
||||||
|
majorRuntimeVersion = binaryReader.ReadUInt16(); |
||||||
|
minorRuntimeVersion = binaryReader.ReadUInt16(); |
||||||
|
metaData = binaryReader.ReadUInt32(); |
||||||
|
metaDataSize = binaryReader.ReadUInt32(); |
||||||
|
flags = binaryReader.ReadUInt32(); |
||||||
|
entryPointToken = binaryReader.ReadUInt32(); |
||||||
|
resources = binaryReader.ReadUInt32(); |
||||||
|
resourcesSize = binaryReader.ReadUInt32(); |
||||||
|
strongNameSignature = binaryReader.ReadUInt64(); |
||||||
|
codeManagerTable = binaryReader.ReadUInt64(); |
||||||
|
vTableFixups = binaryReader.ReadUInt64(); |
||||||
|
exportAddressTableJumps = binaryReader.ReadUInt64(); |
||||||
|
managedNativeHeader = binaryReader.ReadUInt64(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,356 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.PE { |
||||||
|
|
||||||
|
public class DataDirectories |
||||||
|
{ |
||||||
|
uint exportTable; |
||||||
|
uint exportTableSize; |
||||||
|
uint importTable; |
||||||
|
uint importTableSize; |
||||||
|
uint resourceTable; |
||||||
|
uint resourceTableSize; |
||||||
|
uint exceptionTable; |
||||||
|
uint exceptionTableSize; |
||||||
|
uint certificateTable; |
||||||
|
uint certificateTableSize; |
||||||
|
uint baseRelocationTable; |
||||||
|
uint baseRelocationTableSize; |
||||||
|
uint debugTable; |
||||||
|
uint debugTableSize; |
||||||
|
uint copyrightTable; |
||||||
|
uint copyrightTableSize; |
||||||
|
uint globalPtr; |
||||||
|
uint globalPtrSize; |
||||||
|
uint tlsTable; |
||||||
|
uint tlsTableSize; |
||||||
|
uint loadConfigTable; |
||||||
|
uint loadConfigTableSize; |
||||||
|
uint boundImport; |
||||||
|
uint boundImportSize; |
||||||
|
uint iAT; |
||||||
|
uint iATSize; |
||||||
|
uint delayImportDescriptor; |
||||||
|
uint delayImportDescriptorSize; |
||||||
|
uint cliHeader; |
||||||
|
uint cliHeaderSize; |
||||||
|
uint reserved; |
||||||
|
uint reservedSize; |
||||||
|
|
||||||
|
public uint ExportTable { |
||||||
|
get { |
||||||
|
return exportTable; |
||||||
|
} |
||||||
|
set { |
||||||
|
exportTable = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint ExportTableSize { |
||||||
|
get { |
||||||
|
return exportTableSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
exportTableSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint ImportTable { |
||||||
|
get { |
||||||
|
return importTable; |
||||||
|
} |
||||||
|
set { |
||||||
|
importTable = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint ImportTableSize { |
||||||
|
get { |
||||||
|
return importTableSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
importTableSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint ResourceTable { |
||||||
|
get { |
||||||
|
return resourceTable; |
||||||
|
} |
||||||
|
set { |
||||||
|
resourceTable = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint ResourceTableSize { |
||||||
|
get { |
||||||
|
return resourceTableSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
resourceTableSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint ExceptionTable { |
||||||
|
get { |
||||||
|
return exceptionTable; |
||||||
|
} |
||||||
|
set { |
||||||
|
exceptionTable = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint ExceptionTableSize { |
||||||
|
get { |
||||||
|
return exceptionTableSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
exceptionTableSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint CertificateTable { |
||||||
|
get { |
||||||
|
return certificateTable; |
||||||
|
} |
||||||
|
set { |
||||||
|
certificateTable = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint CertificateTableSize { |
||||||
|
get { |
||||||
|
return certificateTableSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
certificateTableSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint BaseRelocationTable { |
||||||
|
get { |
||||||
|
return baseRelocationTable; |
||||||
|
} |
||||||
|
set { |
||||||
|
baseRelocationTable = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint BaseRelocationTableSize { |
||||||
|
get { |
||||||
|
return baseRelocationTableSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
baseRelocationTableSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint DebugTable { |
||||||
|
get { |
||||||
|
return debugTable; |
||||||
|
} |
||||||
|
set { |
||||||
|
debugTable = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint DebugTableSize { |
||||||
|
get { |
||||||
|
return debugTableSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
debugTableSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint CopyrightTable { |
||||||
|
get { |
||||||
|
return copyrightTable; |
||||||
|
} |
||||||
|
set { |
||||||
|
copyrightTable = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint CopyrightTableSize { |
||||||
|
get { |
||||||
|
return copyrightTableSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
copyrightTableSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint GlobalPtr { |
||||||
|
get { |
||||||
|
return globalPtr; |
||||||
|
} |
||||||
|
set { |
||||||
|
globalPtr = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint GlobalPtrSize { |
||||||
|
get { |
||||||
|
return globalPtrSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
globalPtrSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint TlsTable { |
||||||
|
get { |
||||||
|
return tlsTable; |
||||||
|
} |
||||||
|
set { |
||||||
|
tlsTable = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint TlsTableSize { |
||||||
|
get { |
||||||
|
return tlsTableSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
tlsTableSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint LoadConfigTable { |
||||||
|
get { |
||||||
|
return loadConfigTable; |
||||||
|
} |
||||||
|
set { |
||||||
|
loadConfigTable = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint LoadConfigTableSize { |
||||||
|
get { |
||||||
|
return loadConfigTableSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
loadConfigTableSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint BoundImport { |
||||||
|
get { |
||||||
|
return boundImport; |
||||||
|
} |
||||||
|
set { |
||||||
|
boundImport = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint BoundImportSize { |
||||||
|
get { |
||||||
|
return boundImportSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
boundImportSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint IAT { |
||||||
|
get { |
||||||
|
return iAT; |
||||||
|
} |
||||||
|
set { |
||||||
|
iAT = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint IATSize { |
||||||
|
get { |
||||||
|
return iATSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
iATSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint DelayImportDescriptor { |
||||||
|
get { |
||||||
|
return delayImportDescriptor; |
||||||
|
} |
||||||
|
set { |
||||||
|
delayImportDescriptor = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint DelayImportDescriptorSize { |
||||||
|
get { |
||||||
|
return delayImportDescriptorSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
delayImportDescriptorSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint CliHeader { |
||||||
|
get { |
||||||
|
return cliHeader; |
||||||
|
} |
||||||
|
set { |
||||||
|
cliHeader = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint CliHeaderSize { |
||||||
|
get { |
||||||
|
return cliHeaderSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
cliHeaderSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Reserved { |
||||||
|
get { |
||||||
|
return reserved; |
||||||
|
} |
||||||
|
set { |
||||||
|
reserved = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint ReservedSize { |
||||||
|
get { |
||||||
|
return reservedSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
reservedSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void LoadFrom(BinaryReader binaryReader) |
||||||
|
{ |
||||||
|
exportTable = binaryReader.ReadUInt32(); |
||||||
|
exportTableSize = binaryReader.ReadUInt32(); |
||||||
|
|
||||||
|
importTable = binaryReader.ReadUInt32(); |
||||||
|
importTableSize = binaryReader.ReadUInt32(); |
||||||
|
|
||||||
|
resourceTable = binaryReader.ReadUInt32(); |
||||||
|
resourceTableSize = binaryReader.ReadUInt32(); |
||||||
|
|
||||||
|
exceptionTable = binaryReader.ReadUInt32(); |
||||||
|
exceptionTableSize = binaryReader.ReadUInt32(); |
||||||
|
|
||||||
|
certificateTable = binaryReader.ReadUInt32(); |
||||||
|
certificateTableSize = binaryReader.ReadUInt32(); |
||||||
|
|
||||||
|
baseRelocationTable = binaryReader.ReadUInt32(); |
||||||
|
baseRelocationTableSize = binaryReader.ReadUInt32(); |
||||||
|
|
||||||
|
debugTable = binaryReader.ReadUInt32(); |
||||||
|
debugTableSize = binaryReader.ReadUInt32(); |
||||||
|
|
||||||
|
copyrightTable = binaryReader.ReadUInt32(); |
||||||
|
copyrightTableSize = binaryReader.ReadUInt32(); |
||||||
|
|
||||||
|
globalPtr = binaryReader.ReadUInt32(); |
||||||
|
globalPtrSize = binaryReader.ReadUInt32(); |
||||||
|
|
||||||
|
tlsTable = binaryReader.ReadUInt32(); |
||||||
|
tlsTableSize = binaryReader.ReadUInt32(); |
||||||
|
|
||||||
|
loadConfigTable = binaryReader.ReadUInt32(); |
||||||
|
loadConfigTableSize = binaryReader.ReadUInt32(); |
||||||
|
|
||||||
|
boundImport = binaryReader.ReadUInt32(); |
||||||
|
boundImportSize = binaryReader.ReadUInt32(); |
||||||
|
|
||||||
|
iAT = binaryReader.ReadUInt32(); |
||||||
|
iATSize = binaryReader.ReadUInt32(); |
||||||
|
|
||||||
|
delayImportDescriptor = binaryReader.ReadUInt32(); |
||||||
|
delayImportDescriptorSize = binaryReader.ReadUInt32(); |
||||||
|
|
||||||
|
cliHeader = binaryReader.ReadUInt32(); |
||||||
|
cliHeaderSize = binaryReader.ReadUInt32(); |
||||||
|
|
||||||
|
reserved = binaryReader.ReadUInt32(); |
||||||
|
reservedSize = binaryReader.ReadUInt32(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,42 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.PE { |
||||||
|
|
||||||
|
public class IAT |
||||||
|
{ |
||||||
|
uint nameTableRVA; |
||||||
|
uint empty; |
||||||
|
|
||||||
|
public uint NameTableRVA { |
||||||
|
get { |
||||||
|
return nameTableRVA; |
||||||
|
} |
||||||
|
set { |
||||||
|
nameTableRVA = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public uint Empty { |
||||||
|
get { |
||||||
|
return empty; |
||||||
|
} |
||||||
|
set { |
||||||
|
empty = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public void LoadFrom(BinaryReader binaryReader) |
||||||
|
{ |
||||||
|
nameTableRVA = binaryReader.ReadUInt32(); |
||||||
|
empty = binaryReader.ReadUInt32(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,34 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.PE { |
||||||
|
|
||||||
|
public class ImportTable |
||||||
|
{ |
||||||
|
const int UNUSED_SIZE = 20; |
||||||
|
|
||||||
|
uint importLookupTable = 0; |
||||||
|
uint dateTimeStamp = 0; |
||||||
|
uint forwarderChain = 0; |
||||||
|
uint importTableName = 0; |
||||||
|
uint importAddressTable = 0; |
||||||
|
byte[] unused = new byte[UNUSED_SIZE]; |
||||||
|
|
||||||
|
public void LoadFrom(BinaryReader binaryReader) |
||||||
|
{ |
||||||
|
importLookupTable = binaryReader.ReadUInt32(); |
||||||
|
dateTimeStamp = binaryReader.ReadUInt32(); |
||||||
|
forwarderChain = binaryReader.ReadUInt32(); |
||||||
|
importTableName = binaryReader.ReadUInt32(); |
||||||
|
importAddressTable = binaryReader.ReadUInt32(); |
||||||
|
binaryReader.Read(unused, 0, UNUSED_SIZE); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,45 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.PE { |
||||||
|
|
||||||
|
public class NTSpecificFields |
||||||
|
{ |
||||||
|
const uint IMAGE_BASE = 0x400000; |
||||||
|
const uint SECTION_ALIGNMENT = 0x2000; |
||||||
|
|
||||||
|
// uint fileAlignment; // either 0x200 or 0x1000
|
||||||
|
// ushort osMajor;
|
||||||
|
// ushort osMinor;
|
||||||
|
// ushort userMajor;
|
||||||
|
// ushort userMinor;
|
||||||
|
// ushort subSysMajor;
|
||||||
|
// ushort subSysMinor;
|
||||||
|
// uint reserved;
|
||||||
|
// uint imageSize;
|
||||||
|
// uint headerSize;
|
||||||
|
// uint fileChecksum;
|
||||||
|
// ushort subSystem;
|
||||||
|
// ushort dllFlags;
|
||||||
|
// uint stackReserveSize;
|
||||||
|
// uint stackCommitSize;
|
||||||
|
// uint heapReserveSize;
|
||||||
|
// uint heapCommitSize;
|
||||||
|
// uint loaderFlags;
|
||||||
|
// uint numberOfDataDirectories;
|
||||||
|
|
||||||
|
public void LoadFrom(BinaryReader binaryReader) |
||||||
|
{ |
||||||
|
// TODO
|
||||||
|
byte[] buffer = new byte[68]; |
||||||
|
binaryReader.Read(buffer, 0, 68); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,50 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.PE { |
||||||
|
|
||||||
|
public class NameTable |
||||||
|
{ |
||||||
|
ushort hint; |
||||||
|
string name; |
||||||
|
|
||||||
|
public ushort Hint { |
||||||
|
get { |
||||||
|
return hint; |
||||||
|
} |
||||||
|
set { |
||||||
|
hint = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string Name { |
||||||
|
get { |
||||||
|
return name; |
||||||
|
} |
||||||
|
set { |
||||||
|
name = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void LoadFrom(BinaryReader binaryReader) |
||||||
|
{ |
||||||
|
hint = binaryReader.ReadUInt16(); |
||||||
|
|
||||||
|
name = String.Empty; |
||||||
|
byte b = binaryReader.ReadByte(); |
||||||
|
while (b != 0) { |
||||||
|
name += (char)b; |
||||||
|
b = binaryReader.ReadByte(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,145 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Diagnostics; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.PE { |
||||||
|
|
||||||
|
public class PEFileHeader |
||||||
|
{ |
||||||
|
const ushort machineSign = 0x14C; |
||||||
|
const ushort IMAGE_FILE_DLL = 0x2000; |
||||||
|
|
||||||
|
ushort numberOfSections; |
||||||
|
uint time; |
||||||
|
uint ptrToSymbolTable; |
||||||
|
uint numerOfSymbols; |
||||||
|
ushort optionalHeaderSize; |
||||||
|
ushort characteristics; |
||||||
|
|
||||||
|
// optional header:
|
||||||
|
StandardFields standardFields = new StandardFields(); |
||||||
|
NTSpecificFields ntSpecificFields = new NTSpecificFields(); |
||||||
|
DataDirectories dataDirectories = new DataDirectories(); |
||||||
|
|
||||||
|
public ushort NumberOfSections { |
||||||
|
get { |
||||||
|
return numberOfSections; |
||||||
|
} |
||||||
|
set { |
||||||
|
numberOfSections = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint Time { |
||||||
|
get { |
||||||
|
return time; |
||||||
|
} |
||||||
|
set { |
||||||
|
time = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint PtrToSymbolTable { |
||||||
|
get { |
||||||
|
return ptrToSymbolTable; |
||||||
|
} |
||||||
|
set { |
||||||
|
ptrToSymbolTable = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint NumerOfSymbols { |
||||||
|
get { |
||||||
|
return numerOfSymbols; |
||||||
|
} |
||||||
|
set { |
||||||
|
numerOfSymbols = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public ushort OptionalHeaderSize { |
||||||
|
get { |
||||||
|
return optionalHeaderSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
optionalHeaderSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool IsDLL { |
||||||
|
get { |
||||||
|
return (characteristics & IMAGE_FILE_DLL) == IMAGE_FILE_DLL; |
||||||
|
} |
||||||
|
set { |
||||||
|
if (value) { |
||||||
|
characteristics |= IMAGE_FILE_DLL; |
||||||
|
} else { |
||||||
|
characteristics = (ushort)(characteristics & ~IMAGE_FILE_DLL); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public StandardFields StandardFields { |
||||||
|
get { |
||||||
|
return standardFields; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public NTSpecificFields NtSpecificFields { |
||||||
|
get { |
||||||
|
return ntSpecificFields; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public DataDirectories DataDirectories { |
||||||
|
get { |
||||||
|
return dataDirectories; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public void LoadFrom(BinaryReader binaryReader) |
||||||
|
{ |
||||||
|
// pe signature (always PE\0\0)
|
||||||
|
byte[] signature = new byte[4]; |
||||||
|
binaryReader.Read(signature, 0, 4); |
||||||
|
if (signature[0] != (byte)'P' && signature[1] != (byte)'E' && signature[2] != 0 && signature[3] != 0) { |
||||||
|
Console.WriteLine("NO PE FILE"); |
||||||
|
return; |
||||||
|
} |
||||||
|
ushort machine = binaryReader.ReadUInt16(); |
||||||
|
|
||||||
|
if (machine != machineSign) { |
||||||
|
Console.WriteLine("Wrong machine : " + machineSign); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
numberOfSections = binaryReader.ReadUInt16(); |
||||||
|
time = binaryReader.ReadUInt32(); |
||||||
|
|
||||||
|
ptrToSymbolTable = binaryReader.ReadUInt32(); |
||||||
|
if (ptrToSymbolTable != 0) { |
||||||
|
Console.WriteLine("warning: ptrToSymbolTable != 0"); |
||||||
|
} |
||||||
|
|
||||||
|
numerOfSymbols = binaryReader.ReadUInt32(); |
||||||
|
if (numerOfSymbols != 0) { |
||||||
|
Console.WriteLine("warning: numerOfSymbols != 0"); |
||||||
|
} |
||||||
|
|
||||||
|
optionalHeaderSize = binaryReader.ReadUInt16(); |
||||||
|
characteristics = binaryReader.ReadUInt16(); |
||||||
|
|
||||||
|
standardFields.LoadFrom(binaryReader); |
||||||
|
ntSpecificFields.LoadFrom(binaryReader); |
||||||
|
dataDirectories.LoadFrom(binaryReader); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,215 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.PE { |
||||||
|
|
||||||
|
public class SectionTable |
||||||
|
{ |
||||||
|
const int NAME_LEN = 8; |
||||||
|
|
||||||
|
const uint IMAGE_SCN_CNT_CODE = 0x20; |
||||||
|
const uint IMAGE_SCN_CNT_INITIALIZED_DATA = 0x40; |
||||||
|
const uint IMAGE_SCN_CNT_UNINITIALIZED_DATA = 0x80; |
||||||
|
const uint IMAGE_SCN_MEM_EXECUTE = 0x20000000; |
||||||
|
const uint IMAGE_SCN_MEM_READ = 0x40000000; |
||||||
|
const uint IMAGE_SCN_MEM_WRITE = 0x80000000; |
||||||
|
|
||||||
|
byte[] name = new byte[NAME_LEN]; |
||||||
|
uint virtualSize = 0; |
||||||
|
uint virtualAddress = 0; |
||||||
|
uint sizeOfRawData = 0; |
||||||
|
uint pointerToRawData = 0; |
||||||
|
uint pointerToRelocations = 0; |
||||||
|
uint pointerToLinenumbers = 0; |
||||||
|
uint numberOfRelocations = 0; |
||||||
|
uint numberOfLinenumbers = 0; |
||||||
|
uint characteristics = 0; |
||||||
|
|
||||||
|
public string Name { |
||||||
|
get { |
||||||
|
return System.Text.Encoding.ASCII.GetString(name); |
||||||
|
} |
||||||
|
set { |
||||||
|
byte[] nameBytes = System.Text.Encoding.ASCII.GetBytes(value); |
||||||
|
name = new byte[NAME_LEN]; |
||||||
|
for (int i = 0; i < NAME_LEN; ++i) { |
||||||
|
name[i] = 0; |
||||||
|
} |
||||||
|
Array.Copy(nameBytes, 0, name, 0, Math.Min(NAME_LEN, nameBytes.Length)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public uint VirtualSize { |
||||||
|
get { |
||||||
|
return virtualSize; |
||||||
|
} |
||||||
|
set { |
||||||
|
virtualSize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint VirtualAddress { |
||||||
|
get { |
||||||
|
return virtualAddress; |
||||||
|
} |
||||||
|
set { |
||||||
|
virtualAddress = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint SizeOfRawData { |
||||||
|
get { |
||||||
|
return sizeOfRawData; |
||||||
|
} |
||||||
|
set { |
||||||
|
sizeOfRawData = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint PointerToRawData { |
||||||
|
get { |
||||||
|
return pointerToRawData; |
||||||
|
} |
||||||
|
set { |
||||||
|
pointerToRawData = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint PointerToRelocations { |
||||||
|
get { |
||||||
|
return pointerToRelocations; |
||||||
|
} |
||||||
|
set { |
||||||
|
pointerToRelocations = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint PointerToLinenumbers { |
||||||
|
get { |
||||||
|
return pointerToLinenumbers; |
||||||
|
} |
||||||
|
set { |
||||||
|
pointerToLinenumbers = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint NumberOfRelocations { |
||||||
|
get { |
||||||
|
return numberOfRelocations; |
||||||
|
} |
||||||
|
set { |
||||||
|
numberOfRelocations = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint NumberOfLinenumbers { |
||||||
|
get { |
||||||
|
return numberOfLinenumbers; |
||||||
|
} |
||||||
|
set { |
||||||
|
numberOfLinenumbers = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// characteristics
|
||||||
|
public bool ContainsExecutableCode { |
||||||
|
get { |
||||||
|
return (characteristics & IMAGE_SCN_CNT_CODE) == IMAGE_SCN_CNT_CODE; |
||||||
|
} |
||||||
|
set { |
||||||
|
if (value) { |
||||||
|
characteristics |= IMAGE_SCN_CNT_CODE; |
||||||
|
} else { |
||||||
|
characteristics &= ~IMAGE_SCN_CNT_CODE; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool ContainsInitializedData { |
||||||
|
get { |
||||||
|
return (characteristics & IMAGE_SCN_CNT_INITIALIZED_DATA) == IMAGE_SCN_CNT_INITIALIZED_DATA; |
||||||
|
} |
||||||
|
set { |
||||||
|
if (value) { |
||||||
|
characteristics |= IMAGE_SCN_CNT_INITIALIZED_DATA; |
||||||
|
} else { |
||||||
|
characteristics &= ~IMAGE_SCN_CNT_INITIALIZED_DATA; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool ContainsUninitializedData { |
||||||
|
get { |
||||||
|
return (characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA) == IMAGE_SCN_CNT_UNINITIALIZED_DATA; |
||||||
|
} |
||||||
|
set { |
||||||
|
if (value) { |
||||||
|
characteristics |= IMAGE_SCN_CNT_UNINITIALIZED_DATA; |
||||||
|
} else { |
||||||
|
characteristics &= ~IMAGE_SCN_CNT_UNINITIALIZED_DATA; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool SectionCanBeExecutedAsCode { |
||||||
|
get { |
||||||
|
return (characteristics & IMAGE_SCN_MEM_EXECUTE) == IMAGE_SCN_MEM_EXECUTE; |
||||||
|
} |
||||||
|
set { |
||||||
|
if (value) { |
||||||
|
characteristics |= IMAGE_SCN_MEM_EXECUTE; |
||||||
|
} else { |
||||||
|
characteristics &= ~IMAGE_SCN_MEM_EXECUTE; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool SectionCanBeRead { |
||||||
|
get { |
||||||
|
return (characteristics & IMAGE_SCN_MEM_READ) == IMAGE_SCN_MEM_READ; |
||||||
|
} |
||||||
|
set { |
||||||
|
if (value) { |
||||||
|
characteristics |= IMAGE_SCN_MEM_READ; |
||||||
|
} else { |
||||||
|
characteristics &= ~IMAGE_SCN_MEM_READ; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool SectionCanWrittenTo { |
||||||
|
get { |
||||||
|
return (characteristics & IMAGE_SCN_MEM_WRITE) == IMAGE_SCN_MEM_WRITE; |
||||||
|
} |
||||||
|
set { |
||||||
|
if (value) { |
||||||
|
characteristics |= IMAGE_SCN_MEM_WRITE; |
||||||
|
} else { |
||||||
|
characteristics &= ~IMAGE_SCN_MEM_WRITE; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void LoadFrom(BinaryReader binaryReader) |
||||||
|
{ |
||||||
|
binaryReader.Read(name, 0, NAME_LEN); |
||||||
|
virtualSize = binaryReader.ReadUInt32(); |
||||||
|
virtualAddress = binaryReader.ReadUInt32(); |
||||||
|
sizeOfRawData = binaryReader.ReadUInt32(); |
||||||
|
pointerToRawData = binaryReader.ReadUInt32(); |
||||||
|
pointerToRelocations = binaryReader.ReadUInt32(); |
||||||
|
pointerToLinenumbers = binaryReader.ReadUInt32(); |
||||||
|
numberOfRelocations = binaryReader.ReadUInt16(); |
||||||
|
numberOfLinenumbers = binaryReader.ReadUInt16(); |
||||||
|
characteristics = binaryReader.ReadUInt32(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,46 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Diagnostics; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.PE { |
||||||
|
|
||||||
|
public class StandardFields |
||||||
|
{ |
||||||
|
const ushort MAGIC = 0x10B; |
||||||
|
|
||||||
|
byte lMajor; |
||||||
|
byte lMinor; |
||||||
|
uint codeSize; |
||||||
|
uint initializedDataSize; |
||||||
|
uint uninitializedDataSize; |
||||||
|
uint entryPointRVA; |
||||||
|
uint baseOfCode; |
||||||
|
uint baseOfData; |
||||||
|
|
||||||
|
public void LoadFrom(BinaryReader binaryReader) |
||||||
|
{ |
||||||
|
ushort magic = binaryReader.ReadUInt16(); |
||||||
|
if (magic != MAGIC) { |
||||||
|
Console.WriteLine("Warning OptionalHeader.StandardFields != " + MAGIC + " was " + magic); |
||||||
|
} |
||||||
|
lMajor = binaryReader.ReadByte(); |
||||||
|
Debug.Assert(lMajor == 6 || lMajor == 7); |
||||||
|
lMinor = binaryReader.ReadByte(); |
||||||
|
Debug.Assert(lMinor == 0 || lMinor == 10); |
||||||
|
codeSize = binaryReader.ReadUInt32(); |
||||||
|
initializedDataSize = binaryReader.ReadUInt32(); |
||||||
|
uninitializedDataSize = binaryReader.ReadUInt32(); |
||||||
|
entryPointRVA = binaryReader.ReadUInt32(); |
||||||
|
baseOfCode = binaryReader.ReadUInt32(); |
||||||
|
baseOfData = binaryReader.ReadUInt32(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,66 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.PE { |
||||||
|
|
||||||
|
public class StreamHeader |
||||||
|
{ |
||||||
|
uint offset; |
||||||
|
uint size; |
||||||
|
string name; |
||||||
|
|
||||||
|
public uint Offset { |
||||||
|
get { |
||||||
|
return offset; |
||||||
|
} |
||||||
|
set { |
||||||
|
offset = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public uint Size { |
||||||
|
get { |
||||||
|
return size; |
||||||
|
} |
||||||
|
set { |
||||||
|
size = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string Name { |
||||||
|
get { |
||||||
|
return name; |
||||||
|
} |
||||||
|
set { |
||||||
|
name = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void LoadFrom(BinaryReader binaryReader) |
||||||
|
{ |
||||||
|
offset = binaryReader.ReadUInt32(); |
||||||
|
size = binaryReader.ReadUInt32(); |
||||||
|
int bytesRead = 1; |
||||||
|
byte b = binaryReader.ReadByte(); |
||||||
|
while (b != 0) { |
||||||
|
name += (char)b; |
||||||
|
b = binaryReader.ReadByte(); |
||||||
|
++bytesRead; |
||||||
|
} |
||||||
|
// name is filled to 4 byte blocks
|
||||||
|
int filler = bytesRead % 4 == 0 ? 0 : 4 - (bytesRead % 4); |
||||||
|
for (int i = 0; i < filler; ++i) { |
||||||
|
binaryReader.ReadByte(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,39 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.SharpAssembly.Metadata; |
||||||
|
using ICSharpCode.SharpAssembly.Metadata.Rows; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpAssembly.Assembly |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// imitates Reflection.AssemblyName, but has less functionality
|
||||||
|
/// </summary>
|
||||||
|
public class SharpAssemblyName : object |
||||||
|
{ |
||||||
|
public string Name; |
||||||
|
public uint Flags; |
||||||
|
public string Culture; |
||||||
|
public Version Version; |
||||||
|
public byte[] PublicKey; |
||||||
|
public int RefId; |
||||||
|
|
||||||
|
public string FullName { |
||||||
|
get { |
||||||
|
string cult = (Culture == "" ? "neutral" : Culture); |
||||||
|
|
||||||
|
return Name + ", Version=" + Version.ToString() + ", Culture=" + cult; |
||||||
|
// + ", PublicKeyToken=" + PublicKey.ToString();
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public SharpAssemblyName() |
||||||
|
{ |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue