PERWAPI.PEReader.ReadMethSig C# (CSharp) Méthode

ReadMethSig() private méthode

private ReadMethSig ( Method currMeth, bool firstByteRead ) : MethSig
currMeth Method
firstByteRead bool
Résultat MethSig
        private MethSig ReadMethSig(Method currMeth, bool firstByteRead)
        {
            //Class currClass = null;
            //if (currMeth != null) currClass = (Class)currMeth.GetParent();
            MethSig meth = new MethSig(null);
            if (!firstByteRead) {
                byte firstByte = blob.ReadByte();
                if (firstByte == Field.FieldTag)
                    return null;
                meth.callConv =(CallConv)firstByte;
            }
            if ((meth.callConv & CallConv.Generic) != 0){
                meth.numGenPars = blob.ReadCompressedNum();
                if (currMeth is MethodRef) {
                    ((MethodRef)currMeth).MakeGenericPars(meth.numGenPars);
                } //else if (currMeth is MethodDef) {
                //GetGenericParams((MethodDef)currMeth);
                //}
            }
            uint parCount = blob.ReadCompressedNum();
            if (Diag.DiagOn) Console.WriteLine("Method sig has " + parCount + " parameters");
            meth.retType = GetBlobType();//currClass,currMeth);
            if (meth.retType == null)
                System.Diagnostics.Debug.Assert(meth.retType != null);
            int optParStart = -1;
            ArrayList pTypes = new ArrayList();
            for (int i=0; i < parCount; i++) {
                Type pType = GetBlobType();//currClass,currMeth);
                if (pType == sentinel) {
                    optParStart = i;
                    pType = GetBlobType();//currClass,currMeth);
                }
                if (Diag.DiagOn) if (pType == null) Console.WriteLine("Param type is null");
                pTypes.Add(pType);
            }
            if (optParStart > -1) {
                meth.numPars = (uint)optParStart;
                meth.numOptPars = parCount - meth.numPars;
                meth.optParTypes = new Type[meth.numOptPars];
                for (int i=0; i < meth.numOptPars; i++) {
                    meth.optParTypes[i] = (Type)pTypes[i+optParStart];
                }
            } else
                meth.numPars = parCount;
            meth.parTypes = new Type[meth.numPars];
            for (int i=0; i < meth.numPars; i++) {
                meth.parTypes[i] = (Type)pTypes[i];
            }
            return meth;
        }

Same methods

PEReader::ReadMethSig ( Method thisMeth, string name, uint blobIx ) : MethSig
PEReader::ReadMethSig ( Method thisMeth, uint blobIx ) : MethSig

Usage Example

Exemple #1
0
 internal override sealed void Resolve(PEReader buff)
 {
     MethSig mSig = buff.ReadMethSig(null,sigIx);
     callConv = mSig.callConv;
     retType = mSig.retType;
     parTypes = mSig.parTypes;
     if (parTypes != null) numPars = (uint)parTypes.Length;
     optParTypes = mSig.optParTypes;
     if (optParTypes != null) numOptPars = (uint)optParTypes.Length;
 }
All Usage Examples Of PERWAPI.PEReader::ReadMethSig