Skip to content

Commit

Permalink
Fix R2RDump generic signature parsing (#33825)
Browse files Browse the repository at this point in the history
The signature parsing wasn't handling module overrides correctly. For
generic type parameters, the current module needs to be reset to the
outer module.
  • Loading branch information
janvorli committed Mar 20, 2020
1 parent 35df31c commit 8db7154
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,23 @@ private SignatureDecoder(IAssemblyResolver options, MetadataReader metadataReade
_contextReader = contextReader;
}

/// <summary>
/// Construct the signature decoder by storing the image byte array and offset within the array.
/// This variant uses the outer global metadata reader
/// </summary>
/// <param name="options">Dump options and paths</param>
/// <param name="signature">Signature to parse</param>
/// <param name="offset">Signature offset within the signature byte array</param>
/// <param name="contextReader">Top-level signature context reader</param>
private SignatureDecoder(IAssemblyResolver options, byte[] signature, int offset, ReadyToRunReader contextReader)
{
_metadataReader = contextReader.GetGlobalMetadataReader();
_options = options;
_image = signature;
_offset = offset;
_contextReader = contextReader;
}

/// <summary>
/// Read a single byte from the signature stream and advances the current offset.
/// </summary>
Expand Down Expand Up @@ -996,7 +1013,9 @@ private void ParseType(StringBuilder builder)
break;

case CorElementType.ELEMENT_TYPE_GENERICINST:
ParseGenericTypeInstance(builder);
SignatureDecoder outerTypeDecoder = new SignatureDecoder(_options, _image, _offset, _contextReader);
outerTypeDecoder.ParseGenericTypeInstance(builder);
_offset = outerTypeDecoder._offset;
break;

case CorElementType.ELEMENT_TYPE_TYPEDBYREF:
Expand Down

0 comments on commit 8db7154

Please sign in to comment.