Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use ECMA standard names for MethodSpec (0x2B) meta table and columns #65

Closed
mike-hunhoff opened this issue Dec 12, 2022 · 1 comment
Closed

Comments

@mike-hunhoff
Copy link
Contributor

From ECMA 335 I.22.29 MethodSpec: 0x2B:

The MethodSpec table has the following columns:

  • Method (an index into the MethodDef or MemberRef table, specifying to which
    generic method this row refers; that is, which generic method this row is an
    instantiation of; more precisely, a MethodDefOrRef (§II.24.2.6) coded index)
  • Instantiation (an index into the Blob heap (§II.23.2.15), holding the signature of
    this instantiation)

The MethodSpec table records the signature of an instantiated generic method.
Each unique instantiation of a generic method (i.e., a combination of Method and Instantiation) shall be
represented by a single row in the table

Using ECMA's standard naming would help make it easier to read code that leverages dnfile to parse MethodSpec:

dnfile/src/dnfile/mdtable.py

Lines 1988 to 2025 in 498f6c6

class GenericMethodRowStruct(RowStruct):
Unknown1_CodedIndex: int
Unknown2_BlobIndex: int
class GenericMethodRow(MDTableRow):
Unknown1: codedindex.MethodDefOrRef
Unknown2: bytes
_struct_class = GenericMethodRowStruct
_struct_codedindexes = {
"Unknown1_CodedIndex": ("Unknown1", codedindex.MethodDefOrRef),
}
_struct_blobs = {
"Unknown2_BlobIndex": "Unknown2",
}
def _compute_format(self):
unknown1_size = self._clr_coded_index_struct_size(
codedindex.MethodDefOrRef.tag_bits,
codedindex.MethodDefOrRef.table_names,
)
blob_ind_size = checked_offset_format(self._blob_offsz)
return (
"CLR_METADATA_TABLE_GENERICMETHOD",
(
unknown1_size + ",Unknown1_CodedIndex",
blob_ind_size + ",Unknown2_BlobIndex",
),
)
class GenericMethod(ClrMetaDataTable[GenericMethodRow]):
name = "GenericMethod"
number = 43
_row_class = GenericMethodRow

@malwarefrank
Copy link
Owner

Thanks for the heads-up. Should be a quick fix. The sources I copied those names from are different from ECMA 335.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants