private void LinkData(CLIFile pFile)
		{
			int cursor = 0;
			if (Signature[0] == 0x06) ExpandedFieldSignature = new FieldSig(pFile, Signature, ref cursor);
			else if (Signature[0] == 0x07) ExpandedLocalVarSignature = new LocalVarSig(pFile, Signature, ref cursor);
			else ExpandedMethodSignature = new MethodSig(pFile, Signature, ref cursor);
		}
Example #2
0
		private void LinkData(CLIFile pFile)
		{
			int paramListCount = pFile.ParamTable.Length - ParamListIndex;
			if (TableIndex < (pFile.MethodDefTable.Length - 1)) paramListCount = pFile.MethodDefTable[TableIndex + 1].ParamListIndex - ParamListIndex;
			for (int index = 0; index < paramListCount; ++index) { ParamList.Add(pFile.ParamTable[ParamListIndex + index]); pFile.ParamTable[ParamListIndex + index].ParentMethodDef = this; }

			int cursor = 0;
			ExpandedSignature = new MethodSig(pFile, Signature, ref cursor);
		}
Example #3
0
		public SigType(CLIFile pCLIFile, byte[] pSignature, ref int pCursor)
		{
			CLIFile = pCLIFile;

			ElementType = (SigElementType)pSignature[pCursor++];
			switch (ElementType)
			{
				case SigElementType.Array:
					ArrayType = new SigType(CLIFile, pSignature, ref pCursor);
					ArrayShape = new SigArrayShape(CLIFile, pSignature, ref pCursor);
					break;
				case SigElementType.Class:
					ClassTypeDefOrRefOrSpecToken = CLIFile.ReadCompressedUnsigned(pSignature, ref pCursor);
					break;
				case SigElementType.FunctionPointer:
					FnPtrMethodSig = new MethodSig(CLIFile, pSignature, ref pCursor);
					break;
				case SigElementType.GenericInstantiation:
					{
						GenericInstClass = pSignature[pCursor] == (byte)SigElementType.Class;
						GenericInstValueType = pSignature[pCursor] == (byte)SigElementType.ValueType;
						++pCursor;
						GenericInstTypeDefOrRefOrSpecToken = CLIFile.ReadCompressedUnsigned(pSignature, ref pCursor);
						uint genericInstGenArgCount = CLIFile.ReadCompressedUnsigned(pSignature, ref pCursor);
						GenericInstGenArgs = new List<SigType>((int)genericInstGenArgCount);
						for (uint genericInstGenArgIndex = 0; genericInstGenArgIndex < genericInstGenArgCount; ++genericInstGenArgIndex) GenericInstGenArgs.Add(new SigType(CLIFile, pSignature, ref pCursor));
						break;
					}
				case SigElementType.MethodVar:
					MVarNumber = CLIFile.ReadCompressedUnsigned(pSignature, ref pCursor);
					break;
				case SigElementType.Pointer:
					while (pSignature[pCursor] == (byte)SigElementType.CustomModifier_Required ||
						   pSignature[pCursor] == (byte)SigElementType.CustomModifier_Optional)
					{
						PtrMods.Add(new SigCustomMod(CLIFile, pSignature, ref pCursor));
					}
					if (pSignature[pCursor] == (byte)SigElementType.Void)
					{
						PtrVoid = true;
						++pCursor;
					}
					else PtrType = new SigType(CLIFile, pSignature, ref pCursor);
					break;
				case SigElementType.SingleDimensionArray:
					while (pSignature[pCursor] == (byte)SigElementType.CustomModifier_Required ||
						   pSignature[pCursor] == (byte)SigElementType.CustomModifier_Optional)
					{
						SZArrayMods.Add(new SigCustomMod(CLIFile, pSignature, ref pCursor));
					}
					SZArrayType = new SigType(CLIFile, pSignature, ref pCursor);
					break;
				case SigElementType.ValueType:
					ValueTypeDefOrRefOrSpecToken = CLIFile.ReadCompressedUnsigned(pSignature, ref pCursor);
					break;
				case SigElementType.Var:
					VarNumber = CLIFile.ReadCompressedUnsigned(pSignature, ref pCursor);
					break;

				default: break;
			}
		}
Example #4
0
		public bool CompareSignature(MethodSig pMethodSig)
		{
			bool implicitThis = pMethodSig.HasThis && !pMethodSig.ExplicitThis;
			if ((Parameters.Count - (implicitThis ? 1 : 0)) != pMethodSig.Params.Count) return false;
			if (ReturnType != Assembly.AppDomain.PresolveType(pMethodSig.RetType)) return false;
			for (int index = 0; index < pMethodSig.Params.Count; ++index)
			{
				if (Parameters[index + (implicitThis ? 1 : 0)].Type != Assembly.AppDomain.PresolveType(pMethodSig.Params[index])) return false;
			}
			return true;
		}