Beispiel #1
0
        private bool SkipFunkyAndCustomModifiers()
        {
            SigParser sigTemp = new SigParser(this);

            if (!sigTemp.SkipAnyVASentinel())
            {
                return(false);
            }


            byte bElementType = 0;

            if (!sigTemp.PeekByte(out bElementType))
            {
                return(false);
            }

            while (ELEMENT_TYPE_CMOD_REQD == bElementType ||
                   ELEMENT_TYPE_CMOD_OPT == bElementType ||
                   ELEMENT_TYPE_MODIFIER == bElementType ||
                   ELEMENT_TYPE_PINNED == bElementType)
            {
                sigTemp.SkipBytes(1);

                int token;
                if (!sigTemp.GetToken(out token))
                {
                    return(false);
                }

                if (!sigTemp.PeekByte(out bElementType))
                {
                    return(false);
                }
            }

            // Following custom modifiers must be an element type value which is less than ELEMENT_TYPE_MAX, or one of the other element types
            // that we support while parsing various signatures
            if (bElementType >= ELEMENT_TYPE_MAX)
            {
                switch (bElementType)
                {
                case ELEMENT_TYPE_PINNED:
                    break;

                default:
                    return(false);
                }
            }

            CopyFrom(sigTemp);
            return(true);
        }// SkipFunkyAndCustomModifiers
Beispiel #2
0
        private bool SkipFunkyAndCustomModifiers()
        {
            SigParser sigTemp = new SigParser(this);
            if (!sigTemp.SkipAnyVASentinel())
                return false;


            byte bElementType = 0;

            if (!sigTemp.PeekByte(out bElementType))
                return false;

            while (ELEMENT_TYPE_CMOD_REQD == bElementType ||
                   ELEMENT_TYPE_CMOD_OPT == bElementType ||
                   ELEMENT_TYPE_MODIFIER == bElementType ||
                   ELEMENT_TYPE_PINNED == bElementType)
            {
                sigTemp.SkipBytes(1);

                int token;
                if (!sigTemp.GetToken(out token))
                    return false;

                if (!sigTemp.PeekByte(out bElementType))
                    return false;
            }

            // Following custom modifiers must be an element type value which is less than ELEMENT_TYPE_MAX, or one of the other element types
            // that we support while parsing various signatures
            if (bElementType >= ELEMENT_TYPE_MAX)
            {
                switch (bElementType)
                {
                    case ELEMENT_TYPE_PINNED:
                        break;
                    default:
                        return false;
                }
            }

            CopyFrom(sigTemp);
            return true;
        }// SkipFunkyAndCustomModifiers
Beispiel #3
0
        private bool PeekElemTypeSize(out int pSize)
        {
            pSize = 0;
            SigParser sigTemp = new SigParser(this);

            if (!sigTemp.SkipAnyVASentinel())
                return false;

            byte bElementType = 0;
            if (!sigTemp.GetByte(out bElementType))
                return false;


            switch (bElementType)
            {
                case ELEMENT_TYPE_I8:
                case ELEMENT_TYPE_U8:
                case ELEMENT_TYPE_R8:
                    pSize = 8;
                    break;

                case ELEMENT_TYPE_I4:
                case ELEMENT_TYPE_U4:
                case ELEMENT_TYPE_R4:
                    pSize = 4;
                    break;

                case ELEMENT_TYPE_I2:
                case ELEMENT_TYPE_U2:
                case ELEMENT_TYPE_CHAR:
                    pSize = 2;
                    break;

                case ELEMENT_TYPE_I1:
                case ELEMENT_TYPE_U1:
                case ELEMENT_TYPE_BOOLEAN:
                    pSize = 1;
                    break;

                case ELEMENT_TYPE_I:
                case ELEMENT_TYPE_U:
                case ELEMENT_TYPE_STRING:
                case ELEMENT_TYPE_PTR:
                case ELEMENT_TYPE_BYREF:
                case ELEMENT_TYPE_CLASS:
                case ELEMENT_TYPE_OBJECT:
                case ELEMENT_TYPE_FNPTR:
                case ELEMENT_TYPE_TYPEDBYREF:
                case ELEMENT_TYPE_ARRAY:
                case ELEMENT_TYPE_SZARRAY:
                    pSize = IntPtr.Size;
                    break;

                case ELEMENT_TYPE_VOID:
                    break;

                case ELEMENT_TYPE_END:
                case ELEMENT_TYPE_CMOD_REQD:
                case ELEMENT_TYPE_CMOD_OPT:
                case ELEMENT_TYPE_VALUETYPE:
                    Debug.Fail("Asked for the size of an element that doesn't have a size!");
                    return false;

                default:
                    Debug.Fail("CorSigGetElementTypeSize given invalid signature to size!");
                    return false;
            }

            return true; ;
        }
Beispiel #4
0
        private bool PeekElemTypeSize(out int pSize)
        {
            pSize = 0;
            SigParser sigTemp = new SigParser(this);

            if (!sigTemp.SkipAnyVASentinel())
            {
                return(false);
            }

            if (!sigTemp.GetByte(out byte bElementType))
            {
                return(false);
            }

            switch (bElementType)
            {
            case ELEMENT_TYPE_I8:
            case ELEMENT_TYPE_U8:
            case ELEMENT_TYPE_R8:
                pSize = 8;
                break;

            case ELEMENT_TYPE_I4:
            case ELEMENT_TYPE_U4:
            case ELEMENT_TYPE_R4:
                pSize = 4;
                break;

            case ELEMENT_TYPE_I2:
            case ELEMENT_TYPE_U2:
            case ELEMENT_TYPE_CHAR:
                pSize = 2;
                break;

            case ELEMENT_TYPE_I1:
            case ELEMENT_TYPE_U1:
            case ELEMENT_TYPE_BOOLEAN:
                pSize = 1;
                break;

            case ELEMENT_TYPE_I:
            case ELEMENT_TYPE_U:
            case ELEMENT_TYPE_STRING:
            case ELEMENT_TYPE_PTR:
            case ELEMENT_TYPE_BYREF:
            case ELEMENT_TYPE_CLASS:
            case ELEMENT_TYPE_OBJECT:
            case ELEMENT_TYPE_FNPTR:
            case ELEMENT_TYPE_TYPEDBYREF:
            case ELEMENT_TYPE_ARRAY:
            case ELEMENT_TYPE_SZARRAY:
                pSize = IntPtr.Size;
                break;

            case ELEMENT_TYPE_VOID:
                break;

            case ELEMENT_TYPE_END:
            case ELEMENT_TYPE_CMOD_REQD:
            case ELEMENT_TYPE_CMOD_OPT:
            case ELEMENT_TYPE_VALUETYPE:
                Debug.Fail("Asked for the size of an element that doesn't have a size!");
                return(false);

            default:
                Debug.Fail("CorSigGetElementTypeSize given invalid signature to size!");
                return(false);
            }

            return(true);

            ;
        }