示例#1
0
        public override void ReadSignature()
        {
            uint data;
            uint dataLength = NuGenSignatureCompression.CorSigUncompressData(signatureBlob, out data);

            CallingConvention = (CorCallingConvention)data;
            NuGenHelperFunctions.StepIntPtr(ref signatureBlob, dataLength);
            uint paramCount = 0;

            if (CallingConvention != CorCallingConvention.IMAGE_CEE_CS_CALLCONV_FIELD)
            {
                dataLength = NuGenSignatureCompression.CorSigUncompressData(signatureBlob, out paramCount);
                NuGenHelperFunctions.StepIntPtr(ref signatureBlob, dataLength);

                if ((CallingConvention & CorCallingConvention.IMAGE_CEE_CS_CALLCONV_GENERIC) == CorCallingConvention.IMAGE_CEE_CS_CALLCONV_GENERIC)
                {
                    dataLength = NuGenSignatureCompression.CorSigUncompressData(signatureBlob, out paramCount);
                    NuGenHelperFunctions.StepIntPtr(ref signatureBlob, dataLength);
                }
            }

            ReturnType = ReadSignatureItem(ref signatureBlob);

            if (paramCount > 0)
            {
                Parameters = new List <NuGenBaseSignatureItem>();
            }

            int paramIndex = 0;

            while (paramIndex < paramCount)
            {
                dataLength = NuGenSignatureCompression.CorSigUncompressData(signatureBlob, out data);
                CorElementType elementType = (CorElementType)data;

                if (elementType == CorElementType.ELEMENT_TYPE_SENTINEL)
                {
                    SentinelFound = true;
                    NuGenHelperFunctions.StepIntPtr(ref signatureBlob, dataLength);
                }

                if (SentinelFound)
                {
                    if (VarargParameters == null)
                    {
                        VarargParameters = new List <NuGenBaseSignatureItem>();
                    }

                    NuGenBaseSignatureItem signatureItem = ReadSignatureItem(ref signatureBlob);
                    VarargParameters.Add(signatureItem);
                }
                else
                {
                    NuGenBaseSignatureItem signatureItem = ReadSignatureItem(ref signatureBlob);
                    Parameters.Add(signatureItem);
                }

                paramIndex++;
            }
        }
示例#2
0
        private void ReadStandAloneMethodSignature(ref IntPtr signatureBlob)
        {
            uint paramCount = 0;

            if (CallingConvention == CorCallingConvention.IMAGE_CEE_CS_CALLCONV_HASTHIS)
            {
                uint data;
                NuGenHelperFunctions.StepIntPtr(ref signatureBlob, NuGenSignatureCompression.CorSigUncompressData(signatureBlob, out data));
                CorCallingConvention explicitThis = (CorCallingConvention)data;

                if (explicitThis == CorCallingConvention.IMAGE_CEE_CS_CALLCONV_EXPLICITTHIS)
                {
                    CallingConvention |= CorCallingConvention.IMAGE_CEE_CS_CALLCONV_EXPLICITTHIS;
                }
                else
                {
                    paramCount = data;
                }
            }
            else
            {
                NuGenHelperFunctions.StepIntPtr(ref signatureBlob, NuGenSignatureCompression.CorSigUncompressData(signatureBlob, out paramCount));
            }

            ReturnType = ReadSignatureItem(ref signatureBlob);

            if (paramCount > 0)
            {
                Parameters = new List <NuGenBaseSignatureItem>();

                int paramIndex = 0;
                while (paramIndex < paramCount)
                {
                    uint data;
                    NuGenSignatureCompression.CorSigUncompressData(signatureBlob, out data);
                    CorElementType elementType = (CorElementType)data;

                    if (elementType == CorElementType.ELEMENT_TYPE_SENTINEL)
                    {
                        throw new NotImplementedException("Sentinel found.");
                    }

                    if (SentinelFound)
                    {
                        if (VarargParameters == null)
                        {
                            VarargParameters = new List <NuGenBaseSignatureItem>();
                        }

                        VarargParameters.Add(ReadSignatureItem(ref signatureBlob));
                    }
                    else
                    {
                        Parameters.Add(ReadSignatureItem(ref signatureBlob));
                    }
                    paramIndex++;
                }
            }
        }