Discussion of the Rotor Shared Source CLI implementation wrote:
> You need to get the field's signature and decode this signature. In
> the
> simplest case (public Bar Field) the signature will be:
> {CALLCONV_FIELD,E_T_CLASS,<compressed token of Bar>} Or
> {CALLCONV_FIELD,E_T_VALUETYPE,<compressed token of Bar>}
>
> For calling convention and element type encoding, see CorHdr.h
>
> For token compression/decompression functions see Cor.h


Thanks to all who replied and got me on the right track. I ended up with
something like this:

    ULONG size;
    PCCOR_SIGNATURE sig = pInternalImport->GetSigOfFieldDef(fd, &size);

    SigPointer sigptr(sig);
    _ASSERTE(sigptr.GetData() == IMAGE_CEE_CS_CALLCONV_FIELD);

    CorElementType corType = (CorElementType)sigptr.GetData();

    if (corType == ELEMENT_TYPE_CLASS)
    {
        mdTypeDef type = sigptr.GetToken();
        return IsReferenceCounted(pInternalImport, type);
    }
    else
        return S_FALSE;

Is this a good way of doing it, or are there some caveats here?

--
Arild

AnkhSVN: http://ankhsvn.tigris.org
Blog: http://ankhsvn.com/blog
IRC: irc://irc.freenode.net/ankhsvn

"The problem in the world today is communication. Too much
communication." -- Homer Simpson

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to