A CustomAttributeContainer is associated with
each loaded assembly. It contains a list of
CustomAttributeDescriptors. The CustomAttributeDescriptor
holds information about an attribute and looks as follows:
class
CustomAttributeDescriptor
{
public:
std::string name; // name of custom attribute
Byte *data; // data
size_t sz; // size of data
};
CustomAttributeContainers will never be constructed by a user in
this version of the library.
Two accessors exist to locate an attribute. They use
a class defined by PEFile.h which gives information about
the attribute.
Lookup is used to get the CustomAttributeDescriptor data.
In case you don't need to know the data or want to see if
specific data exists, the Has function may be used.
const
std::vector<CustomAttributeDescriptor *>&
Lookup(CustomAttribute *attribute) const;
bool
Has(CustomAttribute &attribute, std::string name,
Byte *data = nullptr, size_t sz = 0) const;
Note that on load DotNetPELib will automatically check to see if
SystemParamArrayAttribute is set for the last parameter in any
parameter list, and if so set the VARARG flag in the associated
MethodSignature.
The reverse direction works as well; the attribute will be set
for managed methods if the Method flags in include 'vararg'.