Documente online.
Zona de administrare documente. Fisierele tale
Am uitat parola x Creaza cont nou
 HomeExploreaza
upload
Upload




Assembly Manifest Specification

technical


Common Language Runtime

Assembly Manifest Specification

This document defines the schema for assembly metadata (the assembly 'manifest').



Table of Contents

Introduction to Assembly Manifest Specification

Overview of the Logical Model

Assembly

Files

Reference Resolution

ExportedTypes

Resources

Extensibility

Manifest API

IMetaDataAssemblyEmit

IMetaDataAssemblyImport

Data Type Definitions

Enumerations

Structures

TypeDefs

Constants

Introduction to Assembly Manifest Specification

This document defines the schema for assembly metadata (the assembly 'manifest'). The document contains:

An overview of the logical model.

A description of the extensibility scheme, and related metadata.

Definitions of the interfaces via which manifests can be defined and consumed.

Examples.

Potential extensions to the model post-prerelease, and open issues, are defined in the Appendices.

Overview of the Logical Model

From the outside looking in, an assembly is a collection of exported items. For the prerelease, this collection can include managed types (classes and interfaces), and resources of the assembly (e.g. bitmaps, .jpgs, .res fil 17417d318r es). In the future, this will include additional types of items (e.g. win32 modules).

Items are exported by logical name, and the assembly provides the name scope for the items (including managed classes). From the inside, an assembly is:

A collection of physical files that are owned by the assembly;

A collection of public (exported) and private (internal to the assembly) items. It is the assembly that determines what items are to be exposed outside of the assembly and what items are accessible only within the current assembly scope. It is the assembly that controls how a reference to an item, public or private, is mapped onto the bits that implement the item. For types in particular, the assembly may also supply Common Language Runtime configuration information for the items.

A collection of references to other assemblies. The references are resolved by assembly cache services, based upon metadata defined on the reference, and external policy.

Assembly

Every assembly has a name and a version number, where the name is a simple, friendly textual name. An assembly may also have a 'shared name', that is based upon public & private crypotography key pairs generated by the originator of the assembly. An assembly with a shared name will:

Have an Originator, set to a public key generated by the originator of the assembly.

Contain a SharedName, consisting of the hash of the file containing the manifest - encrypted with the corresponding private key of the originator .

The full name and version of the assembly then consists of:

Originator (Public Key) + Name + Version

For example:

Public Key of Microsoft + "Word" + 6.0.0.0

The use of shared names:

provides names uniqueness;

provides name security, ensuring that no other party could create an assembly named:

Public Key of Microsoft + "Word" + 7.0.0.0

without also knowing the private key used by Microsoft.

An assembly with only a simple name would have Originator equal to Null.

Each assembly also defines additional metadata, specifying any locale (language), processor, and OS that it is specific to. Hence name and version alone do not provide a unique identifier. For example, we may have two assemblies:

Public Key of Microsoft + "Word" + 6.0.0.0 + En + x86 + NT

Public Key of Microsoft + "Word" + 6.0.0.0 + Fr + x86 + NT

The only guaranteed unique identifier for an assembly is its hash value.

In V1, the OS and processor are not used in the binding process. They are kept for informational use only.

The full meta data for an assembly consists of:

The Common Language Runtime has a set of search algorithms for finding assemblies at runtime. If an assembly will be probed for on disk (i.e not installed in the global assembly cache), the Common Language Runtime will append a file extension to the "Name" of the assembly and look for a file of that name. As a result, assembly names should only contain characters that are legal in DOS file names. The extensions that are appended are ".dll" and ".exe". The complete rules describing how the runtime locates assemblies are described in the .NET Framework SDK under "How the Common Language Runtime Locates Assemblies".

_cor_How_COM__Locates_Assemblies

Hash Algorithm

Assembly manifests contain hashes of each file contained in the assembly and of each dependent assembly's manifest (see "Files" and "Reference Resolution" below). The algorithm used to create these hashes may be customized by the creator of the assembly. The valid hash algorithms are those understood by the Crypto API - see wincrypt.h for a complete list.

Version

The version consists of

MajorVersion

MinorVersion

BuildNumber

RevisionNumber

The convention is that the version number should be monotonic, in order to aid the application of policy. Whilst in a distributed development environment such conventions might not be enforced, they should be adopted prior to deployment. There is no explicit rule about whether there can be gaps in the numbers (e.g. "2.4.0.0" -> "2.6.0.0"). There is no defined length for each part. The version number is used by the Common Language Runtime to support versioned references between assemblies and to support side by side.

Culture, Processor, OS

An assembly will define the culture that it supports. An assembly can also specify culture independence, indicating that it contains the resources for the default culture.

An assembly will also define the processor(s) and OS(s) that it supports (or indicate processor/OS independence). The processor and OS details defined for an assembly state that the assembly will execute on the stated platform. It does not necessarily mean that the assembly will not execute on other platforms. For example, an x86/NT4 assembly may run on Alpha under Windows 2000. Hence the details specified for the assembly do not necessarily block installation.

Ideally, the OS requirements would be represented in terms of a reference to the assembly that defined the OS. This has not been done to avoid a dependency on defining such assemblies for all OSs (including legacy), and to save translating the details returned from the OS (e.g. via GetVersionEx) into the names of such assemblies. However, it is envisaged that other runtime dependencies (e.g. on the runtime) would be expressed using assembly references.

NOTE: The Processor and OS information is not used by the CLR in V1 - it is purely for informational purposes.

Assembly Custom Attributes

There are several custom attributes in the System.Reflection namespace that can be used to add additional information about the assembly. For example, you can enter a Title, a Description and so on. See the reference pages for System.Reflection for more information.

Flags

The AssemblyFlags property defines whether all the items of the assembly are listed explicitly, or whether the items contained in the files are treated as being listed implicitly (see 'ExportedTypes' and 'Resources' below).

The AssemblyFlags of an assembly also define the compatibility of it with other versions of the same assembly, indicating if it cannot execute side-by-side with other versions (e.g. due to conflicts over a device driver). An assembly can be defined as non side-by-side within the following scopes:

Application Domain: The assembly cannot execute with other versions if they are executing in the same application domain.

Process: The assembly cannot execute with other versions if they are executing in the same process.

Machine: The assembly cannot execute with other versions if they are executing on the same machine.

If no compatibility flags are set, the assembly is side-by-side compatible in all scopes.

The assembly cannot be more specific with regard to exactly which previous versions it isn't side-by-side compatible with. Hence if the VersionCompatibility flags are set it means the assembly is non side-by-side with all known versions - if not set, it means it is side-by-side with all known versions.

Some of the VersionCompatibility scopes will directly influence the Assembly Resolver binding service. Incompatibility within an Application Domain can be managed simply by setting application level binding policies correctly. Tools may use this property to assist the developer/administrator in defining policy that does not introduce incompatible versions.

Note: In V1, these side by side flags are not enforced at runtime - they are for informational use only.

Files

A manifest may contain a list of constituent files that are part of the assembly.

Information recorded for each such file is its file name and the hash of the file as it existed at the time the assembly was built. All files within an assembly are hashed using the same algorithm, as defined on the assembly. The file names recorded in this table are unqualified names, i.e they contain no path information, but they must include the file extension - the class loader cannot load modules that don't have file extensions. The Common Language Runtime class loader assumes all files in the assembly are in the same directory.

The list of files does not include the file (e.g. the PE) in which the metadata is contained. If you are emitting manifests using IMetadataAssemblyEmit, do not create a File table entry for the file containing the manifest. The integrity of the containing file will be validated by other means (e.g. by a standard signature).

Reference Resolution

For all references (e.g., to load a class, or to obtain a bitmap through GetResource) made in the scope of the current assembly, the assembly governs how the reference is resolved. There are three cases of interest:

A requestor (e.g. a module) in the current assembly scope could make a request for another item that's scoped in the same assembly scope. In this case, the current assembly supplies the rules for how to locate the bits to load.

A requestor in the current assembly scope could make a request for an item that's scoped in another assembly. In this case, the current assembly supplies binding rules used by the Common Language Runtime/services for locating the referenced assembly, but defers to that assembly to supply the rules for how to locate the bits to load. The items of the referenced assembly generally need not be listed in the items table of the current assembly.

A request comes in from outside the current assembly scope for an item that the assembly had exported outside of the assembly. In this case, the current assembly might "own" the item and supply the rules for how to locate the bits to load or it might forward the request to another assembly on which it depends.

To support the assembly-based resolution scenarios requires:

A declaration of items made public from the assembly, if any.

Information about how to map requests for both exported and internal (private) items to the appropriate bits to load, or how to forward the reference to another assembly.

Information about referenced assemblies.

Information about execution location.

An assembly manifest may explicitly declare all of these, as depicted by:

Items

Items of interest are managed types (classes and interfaces), and resources of the assembly (e.g. bitmaps, .jpgs, .res files). The different types of items are defined as separate collections (ExportedTypes and Resources). The ExportedTypes listed in the manifest are only those types that are visible outside the assembly. For each item, the manifest defines:

The name by which the item is known to requestors (class name, for example);

The visibility scope (defined as flags), and ;

The rules governing how requests for the item are to be resolved: either file location information, the identity of another assembly to which the request will be forwarded, or the parent type if the item is a nested type. Items which are found in files within the assembly may also carry any additional information required to index into the target file, for purposes of optimization. For example, for managed classes or interfaces, the ExportedTypeID property holds the reference into the typedef table within the target module. The nature of this information will vary depending upon the type of the item.

Additional details specific to the different types of item are described in sections 'ExportedTypes' and 'Resources' below.

Requests for items in referenced assemblies will be qualified by the name of that assembly (or more accurately, by some index into the assembly reference table). The resolution therefore involves:

resolving to the assembly reference using the qualifier;

binding from the assembly reference to a particular assembly (using the Assembly Resolver);

resolving the item name within the assembly that was bound to.

Referenced Assemblies

The manifest will contain a list of other assemblies that are (statically) referenced by the assembly. Each assembly reference records the originator (public key), name, and meta data (version, locale etc.) of the referenced assembly, based on the assembly referenced at the time of build, and as will be passed to the Assembly Resolver. For compactness, generally only the hash of the originator will be held (hashed using SHA-1). To retain the security offered by strong names, even in the event of SHA-1 becoming broken, references can optionally contain the full originator.

The assembly reference may also include a hash of the referenced assembly, to enable validation of exactly which bits were referenced at the time of build, even in the event of incorrect management of names and version numbers. In V1, these hashes are not validated at runtime, and are used only for informational purposes in Admin tools.

Note than any locations for the codebase(s) of the referenced assembly are (if required) provided external to the manifest.

ExportedTypes

The ExportedType table only contains entries for those types that are visible outside the assembly. Furthermore, the public types defined in the module (through TypeDefs) containing the manifest are not repeated in the ExportedType table in order to save space. ExportedTypes are only emitted for types that are to be exposed from the assembly and whose definition (TypeDef) is in a module other than the one containing the manifest. Each ExportedType includes a reference into the typedef table within the target module.

Resources

In addition to the standard information defined for items within assemblies, each Resource may provide:

The MIME Type of the resource.

An offset to the beginning of the resource within the file that implements it. Additional information, e.g. the length of the resource, might be contained within the resource itself.

Resources such as .resources files are defined at the granularity of the file. For example, each item such as a string within a .resources file would not be listed as a separate resource. Instead the client requests the resource, and then makes calls to the appropriate resource manager who controls individual items within the resource. Multiple resource files might be packaged up into the PE. The list of resources defined in the manifest would be unchanged, except for requiring the additional offset information in order to index into the PE correctly. Details of how resources are laid out in PE files can be found in "Resources in Managed Code" in the .NET Framework SDK._cor_Localizable_Resources_in_Managed_Code

Visibility, and any future addition of configuration overrides, is similarly defined at the level of a resource.

If the AssemblyFlags property has ImplicitResources set, then the Resources collection must be empty. Instead, the collection of resources is derived from the collection of files as follows:

Files (excluding PEs) are treated as assembly-private resources.

Each resource is considered 'bound' to the file in which it was discovered.

The ResourceFlags property defines the visibility outside the assembly.

Resource Localization

Note: In V1, the manifest does not support the concept of "Resource Localization". That's not to say we don't support localization of assemblies, but rather that each assembly may contain resources for a single locale (not for multiple locales).

The resources within an assembly will often be localized for different locales. The Common Language Runtime will provide two different options for how such localized resources can be packaged:

Use of satellite assemblies: Multiple, locale specific, satellite assemblies are produced, each containing the resources localized to a single locale. In addition, the main, parent assembly might contain the resources for the default locale, that will be used if a more appropriate locale cannot be found. A naming convention will be adopted to name the satellite assemblies based on the parent assembly (e.g. <ParentAssemblyName>.resources). This naming convention will be adopted by tools building satellites, and used by the resource loader. The parent assembly will not contain explicit assembly references to the satellites. This means that an assembly that is not localized could later be localized, without requiring change/redeployment of the parent assembly.

Multiple localized resources in a single assembly: Multiple, localized resources are simply contained within the main assembly.

The metadata supports both these options, optimized towards the recommended use of satellite assemblies. Where multiple localized resources are contained in a single assembly, the Resource table is populated with the resource for the default locale, and a second LocalizedResource table is populated with the details of the localization of those resources to other locales. Each localized resource may have its own file (and offset within that file), but they all share the same name, MIMEType, visibility etc.

For example, considering an assembly "MyEditor", with a private resource "UIStrings", localized for En (the default), Fr and Ge:

Use of Satellite assemblies:

The assembly "MyEditor" has Null AssemblyLocale. It contains a single row in the resource table with name "UIString", Visibility= "Private", MIMEType = ".." . As the assembly contains the default resource, the resource Locale is "En", and points to the file+offset of the En resource. The LocalizedResource table is empty.

The satellite assembly "MyEditor.Resources" has AssemblyLocale = "Fr". It contains a single row in the resource table with name "UIString", Visibility= "Public", MIMEType = ".." . The resource Locale is null (meaning same as assembly), and points to the file+offset of the Fr resource.

A second satellite assembly "MyEditor.Resources" has AssemblyLocale = "Ge" (similar to the Fr satellite)

"MyEditor" will not contain any assembly reference to the satellite assemblies - there is an implied reference to "MyEditor.Resources", as this will be the naming convention for satellites.

Multiple localized resources in a single assembly:

The assembly "MyEditor" still has Null AssemblyLocale. It still contains a single row in the resource table with name "UIString", Visibility= "Private", MIMEType = ".." This points to the default resource, hence the resource Locale is "En", and points to the file+offset of the En resource.

The LocalizedResource table has two rows, with locales "Fr" & "Ge", each pointing to the file+offset of the appropriate localized resource.

Extensibility

The assembly metadata will be extensible, using the same extensibility scheme as module level metadata (see the specification of custom attributes in the Metadata API_cor_Metadata_Emit_Import___Interface_Specification spec).

Manifest API

This section defines the interfaces via which the contents of a manifest are accessed.

A client of this interface will also use IMetaDataEmit for extensibility methods, and for basic methods such as Save (see the Metadata API spec. Also, the manifest API does not contain methods to validate the SharedName of an assembly. These are provided by the .NET Framework security apis.

The method descriptions indicate which parameters are required, with all other parameters being nullable. How nulls are represented will differ for different data types:

strings, pointers: standard null value;

ULONG, DWORD, USHORT: -1 (or 0x00 for flags)

tokens: nil token (see "Metadata Emit/Import specification").

IMetaDataAssemblyEmit

IMetaDataAssemblyEmit : IUnknown

DefineAssembly

This method creates an Assembly data structure, defining details of the entire assembly, including the identifier. Only one assembly can be defined within a manifest.

A set of functions to assist in generating shared names are provided. These are detailed in the Shared Name Specification in the .NET Framework SDK.

The hash algorithm to use for hashing the files. Only a small set of hash algorithms might be supported by the implementation.

Parameter

Type

i/o

Description

pbPublicKey

void * (const)

in

The public key identifying the originator of the assembly. The Public Key is null if the assembly does not have a strong name. The full public key is held (1024 or 2048 bits in size).

cbPublicKey

ULONG

in

Count of bytes in the Public Key blob.

uHashAlgId

ULONG

in

The hash algorithm to use to hash the files within the assembly (as used by crypto API function CryptCreateHash - see ALG_ID). If Null, then SHA-1 is implied.

szName

LPCWSTR

in

Name of the assembly. This is the simple, human-readable text name.

The parameter is required.

The length of an assembly name cannot exceed 1024 characters.

pMetaData

ASSEMBLY
METADATA *
(const)

in


Assembly Metadata (version, locale platform etc.). The parameter is required.

dwAssemblyFlags

DWORD

in

Describes various attributes of the assembly (see enum AssemblyFlags).

pmda

mdAssembly *

out

Returned Assembly token.

Return code

S_OK or error.

SetAssemblyProps

This method allows the caller to modify the properties of an assembly record created with DefineAssembly.

Parameter

Type

i/o

Description

pma

mdAssembly

in

The token obtained from calling DefineAssembly.

pbPublicKey

Void * (const)

The public key identifying the originator of the assembly. The public key is null if the assembly does not have a strong name. The full public key is held (1024 or 2048 bits in size).

cbPublicKey

ULONG

in

Count of bytes in the public key blob.

uHashAlgId

ULONG

in

The hash algorithm to use to hash the files within the assembly (as used by crypto API function CryptCreateHash - see ALG_ID). If Null, then SHA-1 is implied.

szName

LPCWSTR

in

Name of the assembly. This is the simple, human-readable text name.

The parameter is required.

pMetaData

ASSEMBLY
METADATA *
(const)

in


Assembly Metadata (version, culture platform etc.).

dwAssemblyFlags

DWORD

in

Describes various attributes of the assembly (see enum AssemblyFlags).

Return code

S_OK or error.

DefineAssemblyRef

This method creates an AssemblyRef data structure. One AssemblyRef is defined for each assembly that this assembly (statically) references. Each AssemblyRef records the originator (public key), name, and meta data of the referenced assembly as at the time of build.

The details recorded against the assembly reference are based upon the assembly referenced at the time of build. At runtime, these details are passed to the Assembly Resolver, along with an indication that they represent the "as built" information. The Assembly Resolver will then apply policy. Hence a reference to locale "En" will invariably be interpreted as requiring the locale suitable for the current environment, but the information that the assembly was built against "En" may be used in some cases (e.g. upon failing to find a locale more suitable for the current environment). The assembly can not express more exact policy, except by making dynamic references.

Parameter

Type

i/o

Description

pbPublicKeyOrToken

void * (const)

in

The public key identifying the originator of the assembly being referenced. Generally this is then hashed internally (using SHA-1), and the hash of the public key is persisted (160 bits in size), merely to save space. If the flag FullOriginator is set, then the full originator is stored. The strong name helper function StrongNameTokenFromAssembly can be used to get the hash of the public key to pass as this parameter. See the Shared Name Specification in the .NET Framework SDK._cor_Strong_Assembly_Names

cbPublicKeyOrToken

ULONG

in

Count of bytes in the Public Key blob.

szName

LPCWSTR

in

Name of the assembly being referenced. The parameter is required.

pMetaData

ASSEMBLY
METADATA *
(const)

in

Assembly Metadata (version, locale platform etc.) from which to form bind parameters. This should be simply set to the metadata pulled from the referenced assembly. The parameter is required.

pbHashValue

void * (const)

in

Hash of the referenced assembly. This value is optional and is not used by the CLR is V1.

cbHashValue

ULONG

in

Count of bytes in the Hash Blob.

dwAssemblyRefFlags

DWORD

in

Describes various attributes of the assembly ref (see section ) _cor_enum_assemblyrefflags

pmdar

mdAssemblyRef*

out

Returned AssemblyRef token.

Return code

S_OK or error.

DefineFile

This method creates a File data structure. One file is defined for each file that was a part of the assembly at the time the assembly was built (not including the file containing the metadata).

Each File must have a unique Name within the assembly.

Parameter

Type

i/o

Description

szName

LPCWSTR

in

File name. The name includes the file path, relative to the assembly. The parameter is required.

pbHashValue

void * (const)

in

Hash of the file. The file is hashed using the algorithm passed to DefineAssembly.

cbHashValue

ULONG

in

Count of bytes in the Hash Blob.

dwFileFlags

DWORD

in

Describes various attributes of the file (see enum FileFlags).

pmdf

mdFile *

out

Returned File token.

Return code

S_OK or error.

DefineExportedType

This method creates an ExportedType data structure. As described above, one ExportedType is defined for each type (class or interface) that is to be exposed from the assembly and whose implementation is in a module other than the one containing the manifest.

Each ExportedType must have a unique Name within the assembly.

Parameter

Type

i/o

Description

szName

LPCWSTR

in

Name of the ExportedType. The parameter is required. For V1, the name of the ExportedType must exactly match the name given in the TypeDef for the type.

szDescription

LPCWSTR

in

Description of the ExportedType.

tkImplementation

mdToken

in

The token describing where this type is implemented. This value may either be an mdFile (if the type is implemented in a different file within this assembly), and mdAssemblyRef (if the type is in a different assembly), or another mdExportedType (if the type is nested within some other type). If the type is in the same file as the manifest and is not a nested type, the value of this parameter should be mdFileNil.

tkTypeDef

mdToken

in

The token for the entry in the typedef table within the file that implements the type, for optimization purposes.

Only relevant when the ComType is implemented within a file within the assembly

dwExportedTypeFlags

DWORD

in

Describes various attributes of the ExportedType (see enum CorTypeAttr in CorHdr.h).

pmdct

mdExportedType *

out

Returned ExportedType token.

Return code

S_OK or error.

DefineManifestResource

This method creates a ManifestResource data structure. One ManifestResource is defined for each resource that is implemented in one of the files of the assembly (the resource table entry then points to the file in which to find the resource).

Each ManifestResource must have a unique Name within the assembly.

Parameter

Type

i/o

Description

szName

LPCWSTR

in

Name of the Resource. The parameter is required.

szDescription

LPCWSTR

in

Description of the resource.

tkImplementation

mdToken

in

The token for the file or assemblyref that provides the resource. Null is taken to mean the file in which the metadata is embedded

dwOffset

DWORD

in

An offset to the beginning of the resource within the resource blob in the file containing the resource. For resources in standalone files, this will always be 0. If the resource is embedded in a PE, this is an offset from the beginning of the resource blob - the resource blob starts at the location specified in the "Resources" entry or the Cor Header.

dwResourceFlags

DWORD

in

Describes various attributes of the resource (see enum ManifestResourceFlags).

pmdmr

mdManifest
Resource*

out

Returned Resource token.

Return code

S_OK or error.

IMetaDataAssemblyImport

IMetaDataAssemblyImport : IUnknown

GetAssemblyProps

This method returns all the properties of a given assembly.

Parameter

Type

i/o

Description

mda

mdAssembly

in

The assembly for which to get the properties (required).

ppbPublicKey

void ** (const)

out

Pointer to the PublicKey blob.

pcbPublicKey

ULONG *

out

Count of bytes in the PublicKey Blob.

uHashAlgId

ULONG

out

The hash algorithm used to hash the files in the assembly.

szName

LPWSTR

out

Buffer to fill with name.

cchName

ULONG

in

Size of buffer in wide chars (required).

pchName

ULONG *

out

Actual # of wide chars in name.

pMetaData

ASSEMBLY
METADATA *

out

Assembly MetaData.

pdwAssemblyFlags

DWORD *

out

Flags.

Return code

S_OK or error.

GetAssemblyRefProps

This method returns all the properties of a given AssemblyRef.

Parameter

Type

i/o

Description

mdar

mdAssemblyRef

in

The AssemblyRef for which to get the properties. The parameter is required (required).

ppbPublicKeyOrToken

void ** (const)

out

Pointer to the PublicKey blob. This is the hash of the PublicKey of the assembly being referenced (using the SHA-1 algorithm), unless the flag FullOriginator is set.

pcbPublicKeyOrToken

ULONG *

out

Count of bytes in the PublicKey Blob.

szName

LPWSTR

out

Buffer to fill with name.

cchName

ULONG

in

Size of buffer in wide chars (required).

pchName

ULONG *

out

Actual # of wide chars in name.

pMetaData

ASSEMBLY
METADATA *

out

Assembly MetaData.

ppbHashValue

void ** (const)

out

Pointer to the Hash Blob.

pcbHashValue

ULONG *

out

Count of bytes in the Hash Blob.

pdwAssemblyRef
Flags

DWORD *

out

Flags.

Return code

S_OK or error.

GetFileProps

This method returns all the properties of a given File.

Parameter

Type

i/o

Description

mdf

mdFile

in

The File for which to get the properties. The parameter is required (required).

szName

LPWSTR

out

Buffer to fill with name.

cchName

ULONG

in

Size of buffer in wide chars (required).

pchName

ULONG *

out

Actual # of wide chars in name.

ppbHashValue

void ** (const)

out

Pointer to the Hash Value Blob.

pcbHashValue

ULONG *

out

Count of bytes in the Hash Value Blob.

pdwFileFlags

DWORD *

out

Flags.

Return code

S_OK or error.

GetExportedTypeProps

This method returns all the properties of a given ExportedType.

Parameter

Type

i/o

Description

mdct

mdExportedType

in

The ExportedType for which to get the properties (required).

szName

LPWSTR

out

Buffer to fill with name.

cchName

ULONG

in

Size of buffer in wide chars (required).

pchName

ULONG *

out

Actual # of wide chars in name.

ptkImplementation

mdToken *

out

mdFile or mdAssemblyRef or mdExportedType that provides the ExportedType.

ptkTypeDef

mdTypeDef *

out

TypeDef token within the file.

pdwExportedTypeFlags

DWORD *

out

Flags.

Return code

S_OK or error.

GetManifestResourceProps

This method returns all the properties of a given Resource.

Parameter

Type

i/o

Description

mdmr

mdManifest
Resource

in

The Resource for which to get the properties (required).

szName

LPWSTR

out

Buffer to fill with name.

cchName

ULONG

in

Size of buffer in wide chars (required).

pchName

ULONG *

out

Actual # of wide chars in name.

ptkImplementation

mdToken *

out

mdFile or mdAssemblyRef that provides the Resource.

pdwOffset

DWORD *

out

Offset to the beginning of the resource within the file.

pdwResourceFlags

DWORD *

out

Flags.

Return code

S_OK or error.

EnumAssemblyRefs

This method returns an enumeration of all AssemblyRefs.

Parameter

Type

i/o

Description

phEnum

HCORENUM *

in/
out

Pointer to the enum (required).

rAssemblyRefs[]

mdAssemblyRef

out

Put AssemblyRefs here.

cMax

ULONG

in

Max AssemblyRefs to put (required).

pcTokens

ULONG *

out

Put # put here.

Return code

S_OK or error.

EnumFiles

This method returns an enumeration of all Files.

Parameter

Type

i/o

Description

phEnum

HCORENUM *

in/
out

Pointer to the enum (required).

rFiles[]

mdFile

out

Put Files here.

cMax

ULONG

in

Max Files to put (required).

pcTokens

ULONG *

out

Put # put here.

Return code

S_OK or error.

EnumExportedTypes

This method returns an enumeration of all ExportedTypes.

Parameter

Type

i/o

Description

phEnum

HCORENUM *

in/
out

Pointer to the enum (required).

rExportedTypes[]

mdComType

out

Put ExportedTypes here.

cMax

ULONG

in

Max ExportedTypes to put (required).

pcTokens

ULONG *

out

Put # put here.

Return code

S_OK or error.

EnumManifestResources

This method returns an enumeration of all Resources.

Parameter

Type

i/o

Description

phEnum

HCORENUM *

in/
out

Pointer to the enum (required).

rManifestResources[]

mdManifest
Resource

out

Put Resources here.

cMax

ULONG

in

Max Resources to put (required).

pcTokens

ULONG *

out

Put # put here.

Return code

S_OK or error.

GetAssemblyFromScope

This method returns the assembly for the current scope.

Parameter

Type

i/o

Description

ptkAssembly

mdAssembly *

out

Put token here.

Return code

S_OK or error.

FindExportedTypeByName

This method returns a ExportedType given it's name.

Parameter

Type

i/o

Description

szName

LPCWSTR

in

Name of the ExportedType (required).

mdtExportedType

mdExportedType

In

ExportedType for the enclosing class. mdExportedTypeNil if the requested type is not a nested type.

ptkExportedType

mdExportedType *

out

Put the ExportedType token here.

Return code

S_OK or error.

FindManifestResourceByName

This method returns a ManifestResource given it's name.

Parameter

Type

i/o

Description

szName

LPCWSTR

in

Name of the Resource (required).

ptkManifestResource

mdManifest
Resource *

out

Put the Resource token here.

Return code

S_OK or error.

CloseEnum

This method closes the given enumerator.

Parameter

Type

i/o

Description

hEnum

HCORENUM

in

Enum to be closed (required).

Return

void

FindAssembliesByName

Given an assembly name, this API finds the assembly by following the standard rules for resolving assembly references (see "How the Runtime Locates Assemblies" in the SDK Guide for a detailed description of these rules).

This API requires the Common Language Runtime to be initialized in the process in order to invoke the assembly resolution logic. As a result, you must call CoInitializeEE(COINITEE_DEFAULT) before using FindAssembliesByName and CoUninitializeCor() after the final call is made.

FindAssembliesByName returns an IMetadataImport pointer to the file containing the assembly manifest for the assembly name that is passed in. The scenario where this API would commonly be used is by a compiler attempting to find a referenced assembly at compile time.

If the given assembly name isn't fully specified (for example, doesn't include a version), then multiple assemblies may be returned.

FindAssembliesByName allows the caller to configure various aspects of the Assembly Resolver context such as application base and private search path.

Parameter

Type

i/o

Description

szAppBase

LPCWSTR

in

The root directory from which to probe for the given assembly. This parameter is optional. If not specified, FindAssembliesByName will only look in the global assembly cache for the assembly.

szPrivateBin

LPCWSTR

In

A list of semicolon delimited subdirectories (for example, "bin;bin2") under szAppBase in which to probe for the assembly. These directories are probed in addition to those in the default probing rules. This parameter is optional.

szAssemblyName

LPCWSTR

In

The name of the assembly to find. The format of this string is defined in the class reference page for System.Reflection.AssemblyName. This parameter is required.

ppIUnk[]

IUnknown *

out

An array of IUknowns in which to put the IMetadataAssemblyImport interface pointers.

cMax

ULONG

In

The number of interface pointers the above array can hold.

pcAssemblies

ULONG *

Out

The number of interface pointers returned.

Return

S_OK or error

Data Type Definitions

Enumerations

This sections describes the various flag values. Note that macros are also defined to ease access to the members of the flags (see CorHdr.h).

AssemblyFlags

Describes various attributes of the assembly. Values x0010 to x0070 are reserved for describing side-by-side compatibility with other versions of the assembly. If none of these three bits are set, then the assembly is side by side compatible.

Constant

Value

Description

afImplicitExportedTypes

0x0001

The exported type definitions are implicit within the files making up the assembly, and not explicitly listed in the ExportedType table. Note - for V1, this value is always assumed to be set.

afImplicitResources

0x0002

The resource definitions are implicit within the files making up the assembly, and not explicitly listed in the Resource table. Note - for V1, this value is always assumed to be set.

afNonSideBySideAppDomain

0x0010

The assembly cannot execute with other versions if they are executing in the same application domain.

afNonSideBySideProcess

0x0020

The assembly cannot execute with other versions if they are executing in the same process.

afNonSideBySideMachine

0x0030

The assembly cannot execute with other versions if they are executing on the same machine.

AssemblyRefFlags

Constant

Value

Description

arfFullOriginator

0x0001

The assembly reference holds the full (unhashed) originator.

ManifestResourceFlags

Constant

Value

Description

mrPublic

0x0001

The resource is exported from the assembly.

mrPrivate

0x0002

The resource is private to the assembly.

FileFlags

Constant

Value

Description

ffIsWriteable

0x0001

The file is writeable post-build.

ffContainsNoMetadata

0x0002

The file does not contain metadata.

Structures

ASSEMBLYMETADATA

Defines a structure containing the assembly metadata defining identity (version, locale, processor etc.).

The version number is broken in Major, Minor, Revision and Build. The parts are the separated constituents of the two DWORDS that represent file version numbers.

Type

Member

Description

USHORT

usMajorVersion

Major Version Number (cannot be Null). If all the bits of the number are set, this portion of the version number is interpreted as "not-specified".

USHORT

usMinorVersion

Minor Version Number (cannot be Null). If all the bits of the number are set, this portion of the version number is interpreted as "not-specified".

USHORT

usRevisionNumber

Revision Number (cannot be Null). If all the bits of the number are set, this portion of the version number is interpreted as "not-specified".

USHORT

usBuildNumber

Build Number (cannot be Null). If all the bits of the number are set, this portion of the version number is interpreted as "not-specified".

LPWSTR

szLocale

A list of Locales, one for each locale supported by the assembly. A Null array indicates locale independence. The locale is identified using rfc1766 names. Multiple locales are separated by semi-colons. However, for V1, only one locale is supported.

ULONG

cbLocale

Size of the buffer in wide chars[in/out]

DWORD *

rdwProcessor[]

An array of Processors, one for each processor supported by the assembly. A Null array indicates processor independence. The processor is identified using the constants defining the type (CPU) of the machine (from winnt.h). These are the values as used for the Machine within the COFF header of the PE (see section 'Constants' below).

ULONG

ulProcessor

Size of the processor array/Actual # of entries filled in. [in/out]

OSINFO *

rOS[]

An array of OSINFO structures, one for each OS supported by the assembly. A Null array indicates OS independence.

ULONG

ulOS

Size of the OSINFO array/Actual # of entries filled in. [in/out]

OSINFO

Defines a structure describing the OS requirements. Based on the OSVERSIONINFOEX structure, as returned by the GetVersionEx function.

Type

Member

Description

DWORD

dwOSPlatformId

Operating system platform (Windows 3.1, Win95 or Win98, NT) (see OS Platform constants). Cannot be Null.

DWORD

dwOSMajorVersion

OS Major Version (null indicates any).

DWORD

dwOSMinorVersion

OS Minor Version (null indicates any).

TypeDefs

ALG_ID

Hash algorithm id (defined in wincrypt.h), defining constants for hash algorithms (MD5, SHA etc).

typedef unsigned int ALG_ID

Token definitions

typedef __int32 mdAssembly; // assembly token

typedef __int32 mdAssemblyRef; // assembly reference token

typedef __int32 mdFile; // file token

typedef __int32 mdExportedType; // exportedtype token

Constants

Processor

Constants defining the type (CPU) of the machine are defined in winnt.h. See:

#define PROCESSOR_INTEL_386 386

#define PROCESSOR_INTEL_486 486

#define PROCESSOR_INTEL_PENTIUM 586

#define PROCESSOR_INTEL_IA64 2200

#define PROCESSOR_MIPS_R4000 4000 // incl R4101 & R3910 for Windows CE

#define PROCESSOR_ALPHA_21064 21064

#define PROCESSOR_PPC_601 601

#define PROCESSOR_PPC_603 603

#define PROCESSOR_PPC_604 604

#define PROCESSOR_PPC_620 620

#define PROCESSOR_HITACHI_SH3 10003 // Windows CE

#define PROCESSOR_HITACHI_SH3E 10004 // Windows CE

#define PROCESSOR_HITACHI_SH4 10005 // Windows CE

#define PROCESSOR_MOTOROLA_821 821 // Windows CE

#define PROCESSOR_SHx_SH3 103 // Windows CE

#define PROCESSOR_SHx_SH4 104 // Windows CE

#define PROCESSOR_STRONGARM 2577 // Windows CE - 0xA11

#define PROCESSOR_ARM720 1824 // Windows CE - 0x720

#define PROCESSOR_ARM820 2080 // Windows CE - 0x820

#define PROCESSOR_ARM920 2336 // Windows CE - 0x920

#define PROCESSOR_ARM_7TDMI 70001 // Windows CE

#define PROCESSOR_OPTIL 0x494f // MSIL

OS Platform

Constants defining the OS Platform. These are the values as used for operating system platform

in OSVERSIONINFOEX, as returned by GetVersionEx (see "MSDN OSVERSIONINFOEX_cor_MSDN_osversioninfoex")

Constant

Value

Description

VER_PLATFORM_WIN32s

x0000

Win32s on Windows 3.1.

VER_PLATFORM_WIN32_WINDOWS

x0001

Win32 on Windows 95 or Windows 98.

VER_PLATFORM_WIN32_NT

x0010

Win32 on Windows NT.



Whilst the StrongName is logically part of the manifest, it might be stored in a separate section of the PE

Note that the diagrams occasionally summarize sets of properties into a single property, and separate out some logically distinct properties that are actually encoded as flags. The section 'Manifest API' provides the full detail.


Document Info


Accesari: 2409
Apreciat: hand-up

Comenteaza documentul:

Nu esti inregistrat
Trebuie sa fii utilizator inregistrat pentru a putea comenta


Creaza cont nou

A fost util?

Daca documentul a fost util si crezi ca merita
sa adaugi un link catre el la tine in site


in pagina web a site-ului tau.




eCoduri.com - coduri postale, contabile, CAEN sau bancare

Politica de confidentialitate | Termenii si conditii de utilizare




Copyright © Contact (SCRIGROUP Int. 2024 )