use crate::error::Result;
use crate::reader::Reader;
use crate::tables::{CodedIndex, CodedIndexKind, TableContext};
use crate::writer::Writer;
#[derive(Debug, Clone, Default)]
pub struct ModuleRow {
pub generation: u16,
pub name: u32,
pub mvid: u32,
pub enc_id: u32,
pub enc_base_id: u32,
}
impl ModuleRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
Ok(Self {
generation: reader.read_u16()?,
name: reader.read_index(ctx.wide_string_indices())?,
mvid: reader.read_index(ctx.wide_guid_indices())?,
enc_id: reader.read_index(ctx.wide_guid_indices())?,
enc_base_id: reader.read_index(ctx.wide_guid_indices())?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
writer.write_u16(self.generation);
writer.write_index(self.name, ctx.wide_string_indices());
writer.write_index(self.mvid, ctx.wide_guid_indices());
writer.write_index(self.enc_id, ctx.wide_guid_indices());
writer.write_index(self.enc_base_id, ctx.wide_guid_indices());
}
}
#[derive(Debug, Clone, Default)]
pub struct TypeRefRow {
pub resolution_scope: CodedIndex,
pub type_name: u32,
pub type_namespace: u32,
}
#[derive(Debug, Clone, Default)]
pub struct FieldPtrRow {
pub field: u32,
}
impl FieldPtrRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
use crate::tables::TableId;
Ok(Self {
field: reader.read_index(ctx.wide_table_index(TableId::Field))?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
use crate::tables::TableId;
writer.write_index(self.field, ctx.wide_table_index(TableId::Field));
}
}
#[derive(Debug, Clone, Default)]
pub struct MethodPtrRow {
pub method: u32,
}
impl MethodPtrRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
use crate::tables::TableId;
Ok(Self {
method: reader.read_index(ctx.wide_table_index(TableId::MethodDef))?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
use crate::tables::TableId;
writer.write_index(self.method, ctx.wide_table_index(TableId::MethodDef));
}
}
#[derive(Debug, Clone, Default)]
pub struct ParamPtrRow {
pub param: u32,
}
impl ParamPtrRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
use crate::tables::TableId;
Ok(Self {
param: reader.read_index(ctx.wide_table_index(TableId::Param))?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
use crate::tables::TableId;
writer.write_index(self.param, ctx.wide_table_index(TableId::Param));
}
}
#[derive(Debug, Clone, Default)]
pub struct EventPtrRow {
pub event: u32,
}
impl EventPtrRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
use crate::tables::TableId;
Ok(Self {
event: reader.read_index(ctx.wide_table_index(TableId::Event))?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
use crate::tables::TableId;
writer.write_index(self.event, ctx.wide_table_index(TableId::Event));
}
}
#[derive(Debug, Clone, Default)]
pub struct PropertyPtrRow {
pub property: u32,
}
impl PropertyPtrRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
use crate::tables::TableId;
Ok(Self {
property: reader.read_index(ctx.wide_table_index(TableId::Property))?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
use crate::tables::TableId;
writer.write_index(self.property, ctx.wide_table_index(TableId::Property));
}
}
impl TypeRefRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
let wide = ctx.wide_coded_index(CodedIndexKind::ResolutionScope);
Ok(Self {
resolution_scope: CodedIndex::decode(
CodedIndexKind::ResolutionScope,
reader.read_index(wide)?,
),
type_name: reader.read_index(ctx.wide_string_indices())?,
type_namespace: reader.read_index(ctx.wide_string_indices())?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
let wide = ctx.wide_coded_index(CodedIndexKind::ResolutionScope);
writer.write_index(
self.resolution_scope
.encode(CodedIndexKind::ResolutionScope),
wide,
);
writer.write_index(self.type_name, ctx.wide_string_indices());
writer.write_index(self.type_namespace, ctx.wide_string_indices());
}
}
#[derive(Debug, Clone, Default)]
pub struct TypeDefRow {
pub flags: u32,
pub type_name: u32,
pub type_namespace: u32,
pub extends: CodedIndex,
pub field_list: u32,
pub method_list: u32,
}
impl TypeDefRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
use crate::tables::TableId;
Ok(Self {
flags: reader.read_u32()?,
type_name: reader.read_index(ctx.wide_string_indices())?,
type_namespace: reader.read_index(ctx.wide_string_indices())?,
extends: CodedIndex::decode(
CodedIndexKind::TypeDefOrRef,
reader.read_index(ctx.wide_coded_index(CodedIndexKind::TypeDefOrRef))?,
),
field_list: reader.read_index(ctx.wide_table_index(TableId::Field))?,
method_list: reader.read_index(ctx.wide_table_index(TableId::MethodDef))?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
use crate::tables::TableId;
writer.write_u32(self.flags);
writer.write_index(self.type_name, ctx.wide_string_indices());
writer.write_index(self.type_namespace, ctx.wide_string_indices());
writer.write_index(
self.extends.encode(CodedIndexKind::TypeDefOrRef),
ctx.wide_coded_index(CodedIndexKind::TypeDefOrRef),
);
writer.write_index(self.field_list, ctx.wide_table_index(TableId::Field));
writer.write_index(self.method_list, ctx.wide_table_index(TableId::MethodDef));
}
}
#[derive(Debug, Clone, Default)]
pub struct FieldRow {
pub flags: u16,
pub name: u32,
pub signature: u32,
}
impl FieldRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
Ok(Self {
flags: reader.read_u16()?,
name: reader.read_index(ctx.wide_string_indices())?,
signature: reader.read_index(ctx.wide_blob_indices())?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
writer.write_u16(self.flags);
writer.write_index(self.name, ctx.wide_string_indices());
writer.write_index(self.signature, ctx.wide_blob_indices());
}
}
#[derive(Debug, Clone, Default)]
pub struct MethodDefRow {
pub rva: u32,
pub impl_flags: u16,
pub flags: u16,
pub name: u32,
pub signature: u32,
pub param_list: u32,
}
impl MethodDefRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
use crate::tables::TableId;
Ok(Self {
rva: reader.read_u32()?,
impl_flags: reader.read_u16()?,
flags: reader.read_u16()?,
name: reader.read_index(ctx.wide_string_indices())?,
signature: reader.read_index(ctx.wide_blob_indices())?,
param_list: reader.read_index(ctx.wide_table_index(TableId::Param))?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
use crate::tables::TableId;
writer.write_u32(self.rva);
writer.write_u16(self.impl_flags);
writer.write_u16(self.flags);
writer.write_index(self.name, ctx.wide_string_indices());
writer.write_index(self.signature, ctx.wide_blob_indices());
writer.write_index(self.param_list, ctx.wide_table_index(TableId::Param));
}
}
#[derive(Debug, Clone, Default)]
pub struct ParamRow {
pub flags: u16,
pub sequence: u16,
pub name: u32,
}
impl ParamRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
Ok(Self {
flags: reader.read_u16()?,
sequence: reader.read_u16()?,
name: reader.read_index(ctx.wide_string_indices())?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
writer.write_u16(self.flags);
writer.write_u16(self.sequence);
writer.write_index(self.name, ctx.wide_string_indices());
}
}
#[derive(Debug, Clone, Default)]
pub struct MemberRefRow {
pub class: CodedIndex,
pub name: u32,
pub signature: u32,
}
impl MemberRefRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
Ok(Self {
class: CodedIndex::decode(
CodedIndexKind::MemberRefParent,
reader.read_index(ctx.wide_coded_index(CodedIndexKind::MemberRefParent))?,
),
name: reader.read_index(ctx.wide_string_indices())?,
signature: reader.read_index(ctx.wide_blob_indices())?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
writer.write_index(
self.class.encode(CodedIndexKind::MemberRefParent),
ctx.wide_coded_index(CodedIndexKind::MemberRefParent),
);
writer.write_index(self.name, ctx.wide_string_indices());
writer.write_index(self.signature, ctx.wide_blob_indices());
}
}
#[derive(Debug, Clone, Default)]
pub struct CustomAttributeRow {
pub parent: CodedIndex,
pub attr_type: CodedIndex,
pub value: u32,
}
impl CustomAttributeRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
Ok(Self {
parent: CodedIndex::decode(
CodedIndexKind::HasCustomAttribute,
reader.read_index(ctx.wide_coded_index(CodedIndexKind::HasCustomAttribute))?,
),
attr_type: CodedIndex::decode(
CodedIndexKind::CustomAttributeType,
reader.read_index(ctx.wide_coded_index(CodedIndexKind::CustomAttributeType))?,
),
value: reader.read_index(ctx.wide_blob_indices())?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
writer.write_index(
self.parent.encode(CodedIndexKind::HasCustomAttribute),
ctx.wide_coded_index(CodedIndexKind::HasCustomAttribute),
);
writer.write_index(
self.attr_type.encode(CodedIndexKind::CustomAttributeType),
ctx.wide_coded_index(CodedIndexKind::CustomAttributeType),
);
writer.write_index(self.value, ctx.wide_blob_indices());
}
}
#[derive(Debug, Clone, Default)]
pub struct AssemblyRow {
pub hash_alg_id: u32,
pub major_version: u16,
pub minor_version: u16,
pub build_number: u16,
pub revision_number: u16,
pub flags: u32,
pub public_key: u32,
pub name: u32,
pub culture: u32,
}
impl AssemblyRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
Ok(Self {
hash_alg_id: reader.read_u32()?,
major_version: reader.read_u16()?,
minor_version: reader.read_u16()?,
build_number: reader.read_u16()?,
revision_number: reader.read_u16()?,
flags: reader.read_u32()?,
public_key: reader.read_index(ctx.wide_blob_indices())?,
name: reader.read_index(ctx.wide_string_indices())?,
culture: reader.read_index(ctx.wide_string_indices())?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
writer.write_u32(self.hash_alg_id);
writer.write_u16(self.major_version);
writer.write_u16(self.minor_version);
writer.write_u16(self.build_number);
writer.write_u16(self.revision_number);
writer.write_u32(self.flags);
writer.write_index(self.public_key, ctx.wide_blob_indices());
writer.write_index(self.name, ctx.wide_string_indices());
writer.write_index(self.culture, ctx.wide_string_indices());
}
}
#[derive(Debug, Clone, Default)]
pub struct AssemblyRefRow {
pub major_version: u16,
pub minor_version: u16,
pub build_number: u16,
pub revision_number: u16,
pub flags: u32,
pub public_key_or_token: u32,
pub name: u32,
pub culture: u32,
pub hash_value: u32,
}
impl AssemblyRefRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
Ok(Self {
major_version: reader.read_u16()?,
minor_version: reader.read_u16()?,
build_number: reader.read_u16()?,
revision_number: reader.read_u16()?,
flags: reader.read_u32()?,
public_key_or_token: reader.read_index(ctx.wide_blob_indices())?,
name: reader.read_index(ctx.wide_string_indices())?,
culture: reader.read_index(ctx.wide_string_indices())?,
hash_value: reader.read_index(ctx.wide_blob_indices())?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
writer.write_u16(self.major_version);
writer.write_u16(self.minor_version);
writer.write_u16(self.build_number);
writer.write_u16(self.revision_number);
writer.write_u32(self.flags);
writer.write_index(self.public_key_or_token, ctx.wide_blob_indices());
writer.write_index(self.name, ctx.wide_string_indices());
writer.write_index(self.culture, ctx.wide_string_indices());
writer.write_index(self.hash_value, ctx.wide_blob_indices());
}
}
#[derive(Debug, Clone, Default)]
pub struct InterfaceImplRow {
pub class: u32,
pub interface: CodedIndex,
}
impl InterfaceImplRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
use crate::tables::TableId;
Ok(Self {
class: reader.read_index(ctx.wide_table_index(TableId::TypeDef))?,
interface: CodedIndex::decode(
CodedIndexKind::TypeDefOrRef,
reader.read_index(ctx.wide_coded_index(CodedIndexKind::TypeDefOrRef))?,
),
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
use crate::tables::TableId;
writer.write_index(self.class, ctx.wide_table_index(TableId::TypeDef));
writer.write_index(
self.interface.encode(CodedIndexKind::TypeDefOrRef),
ctx.wide_coded_index(CodedIndexKind::TypeDefOrRef),
);
}
}
#[derive(Debug, Clone, Default)]
pub struct ConstantRow {
pub constant_type: u8,
pub padding: u8,
pub parent: CodedIndex,
pub value: u32,
}
impl ConstantRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
Ok(Self {
constant_type: reader.read_u8()?,
padding: reader.read_u8()?,
parent: CodedIndex::decode(
CodedIndexKind::HasConstant,
reader.read_index(ctx.wide_coded_index(CodedIndexKind::HasConstant))?,
),
value: reader.read_index(ctx.wide_blob_indices())?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
writer.write_u8(self.constant_type);
writer.write_u8(self.padding);
writer.write_index(
self.parent.encode(CodedIndexKind::HasConstant),
ctx.wide_coded_index(CodedIndexKind::HasConstant),
);
writer.write_index(self.value, ctx.wide_blob_indices());
}
}
#[derive(Debug, Clone, Default)]
pub struct FieldMarshalRow {
pub parent: CodedIndex,
pub native_type: u32,
}
impl FieldMarshalRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
Ok(Self {
parent: CodedIndex::decode(
CodedIndexKind::HasFieldMarshal,
reader.read_index(ctx.wide_coded_index(CodedIndexKind::HasFieldMarshal))?,
),
native_type: reader.read_index(ctx.wide_blob_indices())?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
writer.write_index(
self.parent.encode(CodedIndexKind::HasFieldMarshal),
ctx.wide_coded_index(CodedIndexKind::HasFieldMarshal),
);
writer.write_index(self.native_type, ctx.wide_blob_indices());
}
}
#[derive(Debug, Clone, Default)]
pub struct DeclSecurityRow {
pub action: u16,
pub parent: CodedIndex,
pub permission_set: u32,
}
impl DeclSecurityRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
Ok(Self {
action: reader.read_u16()?,
parent: CodedIndex::decode(
CodedIndexKind::HasDeclSecurity,
reader.read_index(ctx.wide_coded_index(CodedIndexKind::HasDeclSecurity))?,
),
permission_set: reader.read_index(ctx.wide_blob_indices())?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
writer.write_u16(self.action);
writer.write_index(
self.parent.encode(CodedIndexKind::HasDeclSecurity),
ctx.wide_coded_index(CodedIndexKind::HasDeclSecurity),
);
writer.write_index(self.permission_set, ctx.wide_blob_indices());
}
}
#[derive(Debug, Clone, Default)]
pub struct ClassLayoutRow {
pub packing_size: u16,
pub class_size: u32,
pub parent: u32,
}
impl ClassLayoutRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
use crate::tables::TableId;
Ok(Self {
packing_size: reader.read_u16()?,
class_size: reader.read_u32()?,
parent: reader.read_index(ctx.wide_table_index(TableId::TypeDef))?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
use crate::tables::TableId;
writer.write_u16(self.packing_size);
writer.write_u32(self.class_size);
writer.write_index(self.parent, ctx.wide_table_index(TableId::TypeDef));
}
}
#[derive(Debug, Clone, Default)]
pub struct FieldLayoutRow {
pub offset: u32,
pub field: u32,
}
impl FieldLayoutRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
use crate::tables::TableId;
Ok(Self {
offset: reader.read_u32()?,
field: reader.read_index(ctx.wide_table_index(TableId::Field))?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
use crate::tables::TableId;
writer.write_u32(self.offset);
writer.write_index(self.field, ctx.wide_table_index(TableId::Field));
}
}
#[derive(Debug, Clone, Default)]
pub struct StandAloneSigRow {
pub signature: u32,
}
impl StandAloneSigRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
Ok(Self {
signature: reader.read_index(ctx.wide_blob_indices())?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
writer.write_index(self.signature, ctx.wide_blob_indices());
}
}
#[derive(Debug, Clone, Default)]
pub struct EventMapRow {
pub parent: u32,
pub event_list: u32,
}
impl EventMapRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
use crate::tables::TableId;
Ok(Self {
parent: reader.read_index(ctx.wide_table_index(TableId::TypeDef))?,
event_list: reader.read_index(ctx.wide_table_index(TableId::Event))?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
use crate::tables::TableId;
writer.write_index(self.parent, ctx.wide_table_index(TableId::TypeDef));
writer.write_index(self.event_list, ctx.wide_table_index(TableId::Event));
}
}
#[derive(Debug, Clone, Default)]
pub struct EventRow {
pub event_flags: u16,
pub name: u32,
pub event_type: CodedIndex,
}
impl EventRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
Ok(Self {
event_flags: reader.read_u16()?,
name: reader.read_index(ctx.wide_string_indices())?,
event_type: CodedIndex::decode(
CodedIndexKind::TypeDefOrRef,
reader.read_index(ctx.wide_coded_index(CodedIndexKind::TypeDefOrRef))?,
),
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
writer.write_u16(self.event_flags);
writer.write_index(self.name, ctx.wide_string_indices());
writer.write_index(
self.event_type.encode(CodedIndexKind::TypeDefOrRef),
ctx.wide_coded_index(CodedIndexKind::TypeDefOrRef),
);
}
}
#[derive(Debug, Clone, Default)]
pub struct PropertyMapRow {
pub parent: u32,
pub property_list: u32,
}
impl PropertyMapRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
use crate::tables::TableId;
Ok(Self {
parent: reader.read_index(ctx.wide_table_index(TableId::TypeDef))?,
property_list: reader.read_index(ctx.wide_table_index(TableId::Property))?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
use crate::tables::TableId;
writer.write_index(self.parent, ctx.wide_table_index(TableId::TypeDef));
writer.write_index(self.property_list, ctx.wide_table_index(TableId::Property));
}
}
#[derive(Debug, Clone, Default)]
pub struct PropertyRow {
pub flags: u16,
pub name: u32,
pub property_type: u32,
}
impl PropertyRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
Ok(Self {
flags: reader.read_u16()?,
name: reader.read_index(ctx.wide_string_indices())?,
property_type: reader.read_index(ctx.wide_blob_indices())?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
writer.write_u16(self.flags);
writer.write_index(self.name, ctx.wide_string_indices());
writer.write_index(self.property_type, ctx.wide_blob_indices());
}
}
#[derive(Debug, Clone, Default)]
pub struct MethodSemanticsRow {
pub semantics: u16,
pub method: u32,
pub association: CodedIndex,
}
impl MethodSemanticsRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
use crate::tables::TableId;
Ok(Self {
semantics: reader.read_u16()?,
method: reader.read_index(ctx.wide_table_index(TableId::MethodDef))?,
association: CodedIndex::decode(
CodedIndexKind::HasSemantics,
reader.read_index(ctx.wide_coded_index(CodedIndexKind::HasSemantics))?,
),
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
use crate::tables::TableId;
writer.write_u16(self.semantics);
writer.write_index(self.method, ctx.wide_table_index(TableId::MethodDef));
writer.write_index(
self.association.encode(CodedIndexKind::HasSemantics),
ctx.wide_coded_index(CodedIndexKind::HasSemantics),
);
}
}
#[derive(Debug, Clone, Default)]
pub struct MethodImplRow {
pub class: u32,
pub method_body: CodedIndex,
pub method_declaration: CodedIndex,
}
impl MethodImplRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
use crate::tables::TableId;
Ok(Self {
class: reader.read_index(ctx.wide_table_index(TableId::TypeDef))?,
method_body: CodedIndex::decode(
CodedIndexKind::MethodDefOrRef,
reader.read_index(ctx.wide_coded_index(CodedIndexKind::MethodDefOrRef))?,
),
method_declaration: CodedIndex::decode(
CodedIndexKind::MethodDefOrRef,
reader.read_index(ctx.wide_coded_index(CodedIndexKind::MethodDefOrRef))?,
),
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
use crate::tables::TableId;
writer.write_index(self.class, ctx.wide_table_index(TableId::TypeDef));
writer.write_index(
self.method_body.encode(CodedIndexKind::MethodDefOrRef),
ctx.wide_coded_index(CodedIndexKind::MethodDefOrRef),
);
writer.write_index(
self.method_declaration
.encode(CodedIndexKind::MethodDefOrRef),
ctx.wide_coded_index(CodedIndexKind::MethodDefOrRef),
);
}
}
#[derive(Debug, Clone, Default)]
pub struct ModuleRefRow {
pub name: u32,
}
impl ModuleRefRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
Ok(Self {
name: reader.read_index(ctx.wide_string_indices())?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
writer.write_index(self.name, ctx.wide_string_indices());
}
}
#[derive(Debug, Clone, Default)]
pub struct TypeSpecRow {
pub signature: u32,
}
impl TypeSpecRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
Ok(Self {
signature: reader.read_index(ctx.wide_blob_indices())?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
writer.write_index(self.signature, ctx.wide_blob_indices());
}
}
#[derive(Debug, Clone, Default)]
pub struct ImplMapRow {
pub mapping_flags: u16,
pub member_forwarded: CodedIndex,
pub import_name: u32,
pub import_scope: u32,
}
impl ImplMapRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
use crate::tables::TableId;
Ok(Self {
mapping_flags: reader.read_u16()?,
member_forwarded: CodedIndex::decode(
CodedIndexKind::MemberForwarded,
reader.read_index(ctx.wide_coded_index(CodedIndexKind::MemberForwarded))?,
),
import_name: reader.read_index(ctx.wide_string_indices())?,
import_scope: reader.read_index(ctx.wide_table_index(TableId::ModuleRef))?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
use crate::tables::TableId;
writer.write_u16(self.mapping_flags);
writer.write_index(
self.member_forwarded
.encode(CodedIndexKind::MemberForwarded),
ctx.wide_coded_index(CodedIndexKind::MemberForwarded),
);
writer.write_index(self.import_name, ctx.wide_string_indices());
writer.write_index(self.import_scope, ctx.wide_table_index(TableId::ModuleRef));
}
}
#[derive(Debug, Clone, Default)]
pub struct FieldRvaRow {
pub rva: u32,
pub field: u32,
}
impl FieldRvaRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
use crate::tables::TableId;
Ok(Self {
rva: reader.read_u32()?,
field: reader.read_index(ctx.wide_table_index(TableId::Field))?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
use crate::tables::TableId;
writer.write_u32(self.rva);
writer.write_index(self.field, ctx.wide_table_index(TableId::Field));
}
}
#[derive(Debug, Clone, Default)]
pub struct EncLogRow {
pub token: u32,
pub func_code: u32,
}
impl EncLogRow {
pub fn parse(reader: &mut Reader<'_>, _ctx: &TableContext) -> Result<Self> {
Ok(Self {
token: reader.read_u32()?,
func_code: reader.read_u32()?,
})
}
pub fn write(&self, writer: &mut Writer, _ctx: &TableContext) {
writer.write_u32(self.token);
writer.write_u32(self.func_code);
}
}
#[derive(Debug, Clone, Default)]
pub struct EncMapRow {
pub token: u32,
}
impl EncMapRow {
pub fn parse(reader: &mut Reader<'_>, _ctx: &TableContext) -> Result<Self> {
Ok(Self {
token: reader.read_u32()?,
})
}
pub fn write(&self, writer: &mut Writer, _ctx: &TableContext) {
writer.write_u32(self.token);
}
}
#[derive(Debug, Clone, Default)]
pub struct NestedClassRow {
pub nested_class: u32,
pub enclosing_class: u32,
}
impl NestedClassRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
use crate::tables::TableId;
Ok(Self {
nested_class: reader.read_index(ctx.wide_table_index(TableId::TypeDef))?,
enclosing_class: reader.read_index(ctx.wide_table_index(TableId::TypeDef))?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
use crate::tables::TableId;
writer.write_index(self.nested_class, ctx.wide_table_index(TableId::TypeDef));
writer.write_index(self.enclosing_class, ctx.wide_table_index(TableId::TypeDef));
}
}
#[derive(Debug, Clone, Default)]
pub struct GenericParamRow {
pub number: u16,
pub flags: u16,
pub owner: CodedIndex,
pub name: u32,
}
impl GenericParamRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
Ok(Self {
number: reader.read_u16()?,
flags: reader.read_u16()?,
owner: CodedIndex::decode(
CodedIndexKind::TypeOrMethodDef,
reader.read_index(ctx.wide_coded_index(CodedIndexKind::TypeOrMethodDef))?,
),
name: reader.read_index(ctx.wide_string_indices())?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
writer.write_u16(self.number);
writer.write_u16(self.flags);
writer.write_index(
self.owner.encode(CodedIndexKind::TypeOrMethodDef),
ctx.wide_coded_index(CodedIndexKind::TypeOrMethodDef),
);
writer.write_index(self.name, ctx.wide_string_indices());
}
}
#[derive(Debug, Clone, Default)]
pub struct MethodSpecRow {
pub method: CodedIndex,
pub instantiation: u32,
}
impl MethodSpecRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
Ok(Self {
method: CodedIndex::decode(
CodedIndexKind::MethodDefOrRef,
reader.read_index(ctx.wide_coded_index(CodedIndexKind::MethodDefOrRef))?,
),
instantiation: reader.read_index(ctx.wide_blob_indices())?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
writer.write_index(
self.method.encode(CodedIndexKind::MethodDefOrRef),
ctx.wide_coded_index(CodedIndexKind::MethodDefOrRef),
);
writer.write_index(self.instantiation, ctx.wide_blob_indices());
}
}
#[derive(Debug, Clone, Default)]
pub struct GenericParamConstraintRow {
pub owner: u32,
pub constraint: CodedIndex,
}
impl GenericParamConstraintRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
use crate::tables::TableId;
Ok(Self {
owner: reader.read_index(ctx.wide_table_index(TableId::GenericParam))?,
constraint: CodedIndex::decode(
CodedIndexKind::TypeDefOrRef,
reader.read_index(ctx.wide_coded_index(CodedIndexKind::TypeDefOrRef))?,
),
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
use crate::tables::TableId;
writer.write_index(self.owner, ctx.wide_table_index(TableId::GenericParam));
writer.write_index(
self.constraint.encode(CodedIndexKind::TypeDefOrRef),
ctx.wide_coded_index(CodedIndexKind::TypeDefOrRef),
);
}
}
#[derive(Debug, Clone, Default)]
pub struct AssemblyProcessorRow {
pub processor: u32,
}
impl AssemblyProcessorRow {
pub fn parse(reader: &mut Reader<'_>, _ctx: &TableContext) -> Result<Self> {
Ok(Self {
processor: reader.read_u32()?,
})
}
pub fn write(&self, writer: &mut Writer, _ctx: &TableContext) {
writer.write_u32(self.processor);
}
}
#[derive(Debug, Clone, Default)]
pub struct AssemblyOsRow {
pub os_platform_id: u32,
pub os_major_version: u32,
pub os_minor_version: u32,
}
impl AssemblyOsRow {
pub fn parse(reader: &mut Reader<'_>, _ctx: &TableContext) -> Result<Self> {
Ok(Self {
os_platform_id: reader.read_u32()?,
os_major_version: reader.read_u32()?,
os_minor_version: reader.read_u32()?,
})
}
pub fn write(&self, writer: &mut Writer, _ctx: &TableContext) {
writer.write_u32(self.os_platform_id);
writer.write_u32(self.os_major_version);
writer.write_u32(self.os_minor_version);
}
}
#[derive(Debug, Clone, Default)]
pub struct AssemblyRefProcessorRow {
pub processor: u32,
pub assembly_ref: u32,
}
impl AssemblyRefProcessorRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
use crate::tables::TableId;
Ok(Self {
processor: reader.read_u32()?,
assembly_ref: reader.read_index(ctx.wide_table_index(TableId::AssemblyRef))?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
use crate::tables::TableId;
writer.write_u32(self.processor);
writer.write_index(
self.assembly_ref,
ctx.wide_table_index(TableId::AssemblyRef),
);
}
}
#[derive(Debug, Clone, Default)]
pub struct AssemblyRefOsRow {
pub os_platform_id: u32,
pub os_major_version: u32,
pub os_minor_version: u32,
pub assembly_ref: u32,
}
impl AssemblyRefOsRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
use crate::tables::TableId;
Ok(Self {
os_platform_id: reader.read_u32()?,
os_major_version: reader.read_u32()?,
os_minor_version: reader.read_u32()?,
assembly_ref: reader.read_index(ctx.wide_table_index(TableId::AssemblyRef))?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
use crate::tables::TableId;
writer.write_u32(self.os_platform_id);
writer.write_u32(self.os_major_version);
writer.write_u32(self.os_minor_version);
writer.write_index(
self.assembly_ref,
ctx.wide_table_index(TableId::AssemblyRef),
);
}
}
#[derive(Debug, Clone, Default)]
pub struct FileRow {
pub flags: u32,
pub name: u32,
pub hash_value: u32,
}
impl FileRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
Ok(Self {
flags: reader.read_u32()?,
name: reader.read_index(ctx.wide_string_indices())?,
hash_value: reader.read_index(ctx.wide_blob_indices())?,
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
writer.write_u32(self.flags);
writer.write_index(self.name, ctx.wide_string_indices());
writer.write_index(self.hash_value, ctx.wide_blob_indices());
}
}
#[derive(Debug, Clone, Default)]
pub struct ExportedTypeRow {
pub flags: u32,
pub type_def_id: u32,
pub type_name: u32,
pub type_namespace: u32,
pub implementation: CodedIndex,
}
impl ExportedTypeRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
Ok(Self {
flags: reader.read_u32()?,
type_def_id: reader.read_u32()?,
type_name: reader.read_index(ctx.wide_string_indices())?,
type_namespace: reader.read_index(ctx.wide_string_indices())?,
implementation: CodedIndex::decode(
CodedIndexKind::Implementation,
reader.read_index(ctx.wide_coded_index(CodedIndexKind::Implementation))?,
),
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
writer.write_u32(self.flags);
writer.write_u32(self.type_def_id);
writer.write_index(self.type_name, ctx.wide_string_indices());
writer.write_index(self.type_namespace, ctx.wide_string_indices());
writer.write_index(
self.implementation.encode(CodedIndexKind::Implementation),
ctx.wide_coded_index(CodedIndexKind::Implementation),
);
}
}
#[derive(Debug, Clone, Default)]
pub struct ManifestResourceRow {
pub offset: u32,
pub flags: u32,
pub name: u32,
pub implementation: CodedIndex,
}
impl ManifestResourceRow {
pub fn parse(reader: &mut Reader<'_>, ctx: &TableContext) -> Result<Self> {
Ok(Self {
offset: reader.read_u32()?,
flags: reader.read_u32()?,
name: reader.read_index(ctx.wide_string_indices())?,
implementation: CodedIndex::decode(
CodedIndexKind::Implementation,
reader.read_index(ctx.wide_coded_index(CodedIndexKind::Implementation))?,
),
})
}
pub fn write(&self, writer: &mut Writer, ctx: &TableContext) {
writer.write_u32(self.offset);
writer.write_u32(self.flags);
writer.write_index(self.name, ctx.wide_string_indices());
writer.write_index(
self.implementation.encode(CodedIndexKind::Implementation),
ctx.wide_coded_index(CodedIndexKind::Implementation),
);
}
}