📄 jclmetadata.pas
字号:
{**************************************************************************************************}
{ }
{ Project JEDI Code Library (JCL) }
{ }
{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); }
{ you may not use this file except in compliance with the License. You may obtain a copy of the }
{ License at http://www.mozilla.org/MPL/ }
{ }
{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF }
{ ANY KIND, either express or implied. See the License for the specific language governing rights }
{ and limitations under the License. }
{ }
{ The Original Code is JclMetadata.pas. }
{ }
{ The Initial Developer of the Original Code is Flier Lu (<flier_lu att yahoo dott com dott cn>). }
{ Portions created by Flier Lu are Copyright (C) Flier Lu. All Rights Reserved. }
{ }
{ Contributors: }
{ Flier Lu (flier) }
{ Robert Marquardt (marquardt) }
{ Olivier Sannier (obones) }
{ }
{**************************************************************************************************}
{ }
{ Microsoft .Net framework Clr information support routines and classes. }
{ }
{ Unit owner: Flier Lu }
{ }
{**************************************************************************************************}
// Last modified: $Date: 2005/03/08 08:33:22 $
// For history see end of file
unit JclMetadata;
{$I jcl.inc}
interface
uses
{$IFDEF MSWINDOWS}
Windows,
{$ENDIF MSWINDOWS}
Classes, SysUtils,
{$IFDEF RTL130_UP}
Contnrs,
{$ENDIF RTL130_UP}
JclBase, JclClr, JclFileUtils, JclPeImage, JclSysUtils;
type
TJclClrElementType = (etEnd, etVoid, etBoolean, etChar,
etI1, etU1, etI2, etU2, etI4, etU4, etI8, etU8, etR4, etR8, etString,
etPtr, etByRef, etValueType, etClass, etArray, etTypedByRef,
etI, etU, etFnPtr, etObject, etSzArray, etCModReqd, etCModOpt,
etInternal, etMax, etModifier, etSentinel, etPinned);
TJclClrTableModuleRow = class(TJclClrTableRow)
private
FGeneration: Word;
FNameOffset: DWORD;
FMvidIdx: DWORD;
FEncIdIdx: DWORD;
FEncBaseIdIdx: DWORD;
function GetMvid: TGUID;
function GetName: WideString;
function GetEncBaseId: TGUID;
function GetEncId: TGUID;
protected
constructor Create(const ATable: TJclClrTable); override;
public
function DumpIL: string; override;
function HasEncId: Boolean;
function HasEncBaseId: Boolean;
property Generation: Word read FGeneration;
property NameOffset: DWORD read FNameOffset;
property MvidIdx: DWORD read FMvidIdx;
property EncIdIdx: DWORD read FEncIdIdx;
property EncBaseIdIdx: DWORD read FEncBaseIdIdx;
property Name: WideString read GetName;
property Mvid: TGUID read GetMvid;
property EncId: TGUID read GetEncId;
property EncBaseId: TGUID read GetEncBaseId;
end;
TJclClrTableModule = class(TJclClrTable, ITableCanDumpIL)
private
function GetRow(const Idx: Integer): TJclClrTableModuleRow;
protected
class function TableRowClass: TJclClrTableRowClass; override;
public
property Rows[const Idx: Integer]: TJclClrTableModuleRow read GetRow; default;
end;
TJclClrTableModuleRefRow = class(TJclClrTableRow)
private
FNameOffset: DWORD;
function GetName: WideString;
protected
constructor Create(const ATable: TJclClrTable); override;
public
function DumpIL: string; override;
property NameOffset: DWORD read FNameOffset;
property Name: WideString read GetName;
end;
TJclClrTableModuleRef = class(TJclClrTable, ITableCanDumpIL)
private
function GetRow(const Idx: Integer): TJclClrTableModuleRefRow;
protected
class function TableRowClass: TJclClrTableRowClass; override;
public
property Rows[const Idx: Integer]: TJclClrTableModuleRefRow read GetRow; default;
end;
TJclClrAssemblyFlag =
(cafPublicKey, cafCompatibilityMask, cafSideBySideCompatible,
cafNonSideBySideAppDomain, cafNonSideBySideProcess,
cafNonSideBySideMachine, cafEnableJITcompileTracking,
cafDisableJITcompileOptimizer);
TJclClrAssemblyFlags = set of TJclClrAssemblyFlag;
TJclClrTableAssemblyRow = class(TJclClrTableRow)
private
FCultureOffset: DWORD;
FPublicKeyOffset: DWORD;
FHashAlgId: DWORD;
FNameOffset: DWORD;
FMajorVersion: Word;
FBuildNumber: Word;
FRevisionNumber: Word;
FMinorVersion: Word;
FFlagMask: DWORD;
function GetCulture: WideString;
function GetName: WideString;
function GetPublicKey: TJclClrBlobRecord;
function GetVersion: string;
function GetFlags: TJclClrAssemblyFlags;
protected
constructor Create(const ATable: TJclClrTable); override;
public
function DumpIL: string; override;
class function AssemblyFlags(const Flags: TJclClrAssemblyFlags): DWORD; overload;
class function AssemblyFlags(const Flags: DWORD): TJclClrAssemblyFlags; overload;
property HashAlgId: DWORD read FHashAlgId;
property MajorVersion: Word read FMajorVersion;
property MinorVersion: Word read FMinorVersion;
property BuildNumber: Word read FBuildNumber;
property RevisionNumber: Word read FRevisionNumber;
property FlagMask: DWORD read FFlagMask;
property PublicKeyOffset: DWORD read FPublicKeyOffset;
property NameOffset: DWORD read FNameOffset;
property CultureOffset: DWORD read FCultureOffset;
property PublicKey: TJclClrBlobRecord read GetPublicKey;
property Name: WideString read GetName;
property Culture: WideString read GetCulture;
property Version: string read GetVersion;
property Flags: TJclClrAssemblyFlags read GetFlags;
end;
TJclClrTableAssembly = class(TJclClrTable, ITableCanDumpIL)
private
function GetRow(const Idx: Integer): TJclClrTableAssemblyRow;
protected
class function TableRowClass: TJclClrTableRowClass; override;
public
property Rows[const Idx: Integer]: TJclClrTableAssemblyRow read GetRow; default;
end;
TJclClrTableAssemblyOSRow = class(TJclClrTableRow)
private
FPlatformID: DWORD;
FMajorVersion: DWORD;
FMinorVersion: DWORD;
function GetVersion: string;
protected
constructor Create(const ATable: TJclClrTable); override;
public
property PlatformID: DWORD read FPlatformID;
property MajorVersion: DWORD read FMajorVersion;
property MinorVersion: DWORD read FMinorVersion;
property Version: string read GetVersion;
end;
TJclClrTableAssemblyOS = class(TJclClrTable)
private
function GetRow(const Idx: Integer): TJclClrTableAssemblyOSRow;
protected
class function TableRowClass: TJclClrTableRowClass; override;
public
property Rows[const Idx: Integer]: TJclClrTableAssemblyOSRow read GetRow; default;
end;
TJclClrTableAssemblyProcessorRow = class(TJclClrTableRow)
private
FProcessor: DWORD;
protected
constructor Create(const ATable: TJclClrTable); override;
public
property Processor: DWORD read FProcessor;
end;
TJclClrTableAssemblyProcessor = class(TJclClrTable)
private
function GetRow(const Idx: Integer): TJclClrTableAssemblyProcessorRow;
protected
class function TableRowClass: TJclClrTableRowClass; override;
public
property Rows[const Idx: Integer]: TJclClrTableAssemblyProcessorRow read GetRow; default;
end;
TJclClrTableAssemblyRefRow = class(TJclClrTableRow)
private
FCultureOffset: DWORD;
FNameOffset: DWORD;
FPublicKeyOrTokenOffset: DWORD;
FHashValueOffset: DWORD;
FMajorVersion: Word;
FRevisionNumber: Word;
FBuildNumber: Word;
FMinorVersion: Word;
FFlagMask: DWORD;
function GetCulture: WideString;
function GetHashValue: TJclClrBlobRecord;
function GetName: WideString;
function GetPublicKeyOrToken: TJclClrBlobRecord;
function GetVersion: string;
function GetFlags: TJclClrAssemblyFlags;
protected
constructor Create(const ATable: TJclClrTable); override;
public
function DumpIL: string; override;
property MajorVersion: Word read FMajorVersion;
property MinorVersion: Word read FMinorVersion;
property BuildNumber: Word read FBuildNumber;
property RevisionNumber: Word read FRevisionNumber;
property FlagMask: DWORD read FFlagMask;
property PublicKeyOrTokenOffset: DWORD read FPublicKeyOrTokenOffset;
property NameOffset: DWORD read FNameOffset;
property CultureOffset: DWORD read FCultureOffset;
property HashValueOffset: DWORD read FHashValueOffset;
property PublicKeyOrToken: TJclClrBlobRecord read GetPublicKeyOrToken;
property Name: WideString read GetName;
property Culture: WideString read GetCulture;
property Version: string read GetVersion;
property HashValue: TJclClrBlobRecord read GetHashValue;
property Flags: TJclClrAssemblyFlags read GetFlags;
end;
TJclClrTableAssemblyRef = class(TJclClrTable, ITableCanDumpIL)
private
function GetRow(const Idx: Integer): TJclClrTableAssemblyRefRow;
protected
class function TableRowClass: TJclClrTableRowClass; override;
public
property Rows[const Idx: Integer]: TJclClrTableAssemblyRefRow read GetRow; default;
end;
TJclClrTableAssemblyRefOSRow = class(TJclClrTableAssemblyOSRow)
private
FAssemblyRefIdx: DWORD;
function GetAssemblyRef: TJclClrTableAssemblyRefRow;
protected
constructor Create(const ATable: TJclClrTable); override;
public
property AssemblyRefIdx: DWORD read FAssemblyRefIdx;
property AssemblyRef: TJclClrTableAssemblyRefRow read GetAssemblyRef;
end;
TJclClrTableAssemblyRefOS = class(TJclClrTableAssemblyOS)
private
function GetRow(const Idx: Integer): TJclClrTableAssemblyRefOSRow;
protected
class function TableRowClass: TJclClrTableRowClass; override;
public
property Rows[const Idx: Integer]: TJclClrTableAssemblyRefOSRow read GetRow; default;
end;
TJclClrTableAssemblyRefProcessorRow = class(TJclClrTableAssemblyProcessorRow)
private
FAssemblyRefIdx: DWORD;
function GetAssemblyRef: TJclClrTableAssemblyRefRow;
protected
constructor Create(const ATable: TJclClrTable); override;
public
property AssemblyRefIdx: DWORD read FAssemblyRefIdx;
property AssemblyRef: TJclClrTableAssemblyRefRow read GetAssemblyRef;
end;
TJclClrTableAssemblyRefProcessor = class(TJclClrTableAssemblyProcessor)
private
function GetRow(const Idx: Integer): TJclClrTableAssemblyRefProcessorRow;
protected
class function TableRowClass: TJclClrTableRowClass; override;
public
property Rows[const Idx: Integer]: TJclClrTableAssemblyRefProcessorRow read GetRow; default;
end;
TJclClrTableClassLayoutRow = class(TJclClrTableRow)
private
FClassSize: DWORD;
FParentIdx: DWORD;
FPackingSize: Word;
protected
constructor Create(const ATable: TJclClrTable); override;
public
property PackingSize: Word read FPackingSize;
property ClassSize: DWORD read FClassSize;
property ParentIdx: DWORD read FParentIdx;
end;
TJclClrTableClassLayout = class(TJclClrTable)
private
function GetRow(const Idx: Integer): TJclClrTableClassLayoutRow;
protected
class function TableRowClass: TJclClrTableRowClass; override;
public
property Rows[const Idx: Integer]: TJclClrTableClassLayoutRow read GetRow; default;
end;
TJclClrTableConstantRow = class(TJclClrTableRow)
private
FKind: Byte;
FParentIdx: DWORD;
FValueOffset: DWORD;
function GetElementType: TJclClrElementType;
function GetParent: TJclClrTableRow;
function GetValue: TJclClrBlobRecord;
protected
constructor Create(const ATable: TJclClrTable); override;
public
function DumpIL: string; override;
property Kind: Byte read FKind;
property ParentIdx: DWORD read FParentIdx;
property ValueOffset: DWORD read FValueOffset;
property ElementType: TJclClrElementType read GetElementType;
property Parent: TJclClrTableRow read GetParent;
property Value: TJclClrBlobRecord read GetValue;
end;
TJclClrTableConstant = class(TJclClrTable)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -