public FunctionSignature(IABI abi, Type returnType, Type[] parameterTypes, MethodCallingConvention callingConvention, PInvokeInfo pinvoke) { ReturnType = new FunctionParameterType(abi, returnType); ParameterTypes = new FunctionParameterType[parameterTypes.Length]; for (int index = 0; index < parameterTypes.Length; index++) ParameterTypes[index] = new FunctionParameterType(abi, parameterTypes[index]); CallingConvention = callingConvention; PInvokeInfo = pinvoke; }
public virtual void VisitPInvokeInfo(PInvokeInfo pinvk) { }
public override void VisitPInvokeInfo(PInvokeInfo pinvk) { ImplMapTable imTable = m_tableWriter.GetImplMapTable (); ImplMapRow imRow = m_rowWriter.CreateImplMapRow ( pinvk.Attributes, new MetadataToken (TokenType.Method, GetRidFor (pinvk.Method)), m_mdWriter.AddString (pinvk.EntryPoint), GetRidFor (pinvk.Module)); imTable.Rows.Add (imRow); }
private void MapPInvokeInfo(MethodBase method, MethodDefinition method_definition) { var attributes = method.GetCustomAttributes(typeof(DllImportAttribute), inherit: false); if (attributes.Length == 0) return; var import = (DllImportAttribute)attributes[0]; var info = new PInvokeInfo(0, import.EntryPoint, ModuleReferenceFor(import.Value)) { IsBestFitEnabled = import.BestFitMapping, IsThrowOnUnmappableCharEnabled = import.ThrowOnUnmappableChar, SupportsLastError = import.SetLastError, IsNoMangle = import.ExactSpelling, }; switch (import.CallingConvention) { case CallingConvention.Cdecl: info.IsCallConvCdecl = true; break; case CallingConvention.FastCall: info.IsCallConvFastcall = true; break; case CallingConvention.StdCall: info.IsCallConvStdCall = true; break; case CallingConvention.ThisCall: info.IsCallConvThiscall = true; break; case CallingConvention.Winapi: info.IsCallConvWinapi = true; break; } switch (import.CharSet) { case CharSet.Ansi: info.IsCharSetAnsi = true; break; case CharSet.Auto: info.IsCharSetAuto = true; break; case CharSet.None: info.IsCharSetNotSpec = true; break; case CharSet.Unicode: info.IsCharSetUnicode = true; break; } method_definition.PInvokeInfo = info; }
public void VisitPInvokeInfo(PInvokeInfo pinvk) { }
private string GetPInvokeName(PInvokeInfo pii, bool includeModuleName) { if(regexPInvokeEntryOrdinal.IsMatch(pii.EntryPoint)) { return String.Format("{0}_{1}", Path.GetFileNameWithoutExtension(pii.Module.Name), pii.EntryPoint.Replace("#", "")); } if (includeModuleName) { return String.Format("{0}_{1}", Path.GetFileNameWithoutExtension(pii.Module.Name), pii.EntryPoint); } return pii.EntryPoint; }