本文整理汇总了C#中CallingConvention类的典型用法代码示例。如果您正苦于以下问题:C# CallingConvention类的具体用法?C# CallingConvention怎么用?C# CallingConvention使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CallingConvention类属于命名空间,在下文中一共展示了CallingConvention类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ToString
internal static string ToString(CallingConvention flags) {
var sb = new StringBuilder();
switch (flags & CallingConvention.Mask) {
case CallingConvention.Default: sb.Append("Default"); break;
case CallingConvention.C: sb.Append("C"); break;
case CallingConvention.StdCall: sb.Append("StdCall"); break;
case CallingConvention.ThisCall: sb.Append("ThisCall"); break;
case CallingConvention.FastCall: sb.Append("FastCall"); break;
case CallingConvention.VarArg: sb.Append("VarArg"); break;
case CallingConvention.Field: sb.Append("Field"); break;
case CallingConvention.LocalSig: sb.Append("LocalSig"); break;
case CallingConvention.Property: sb.Append("Property"); break;
case CallingConvention.Unmanaged: sb.Append("Unmanaged"); break;
case CallingConvention.GenericInst: sb.Append("GenericInst"); break;
case CallingConvention.NativeVarArg: sb.Append("NativeVarArg"); break;
default: sb.Append(string.Format("CC_UNKNOWN_0x{0:X}", (int)(flags & CallingConvention.Mask))); break;
}
if ((flags & CallingConvention.Generic) != 0)
sb.Append(" | Generic");
if ((flags & CallingConvention.HasThis) != 0)
sb.Append(" | HasThis");
if ((flags & CallingConvention.ExplicitThis) != 0)
sb.Append(" | ExplicitThis");
if ((flags & CallingConvention.ReservedByCLR) != 0)
sb.Append(" | ReservedByCLR");
return sb.ToString();
}
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:33,代码来源:CallingConvention.cs
示例2: JitAction
public JitAction(
CallingConvention callingConvention = CallingConvention.Default,
FunctionHints hints = FunctionHints.None,
CodeGenerator codeGenerator = null)
: base(callingConvention, hints, codeGenerator)
{
}
开发者ID:modulexcite,项目名称:nasmjit,代码行数:7,代码来源:JitAction.cs
示例3: UnmanagedCalliDescriptor
internal UnmanagedCalliDescriptor(CallingConvention unmanagedCallConv, Type returnType, Type[] parameterTypes)
: base()
{
this.Value = string.Format(CultureInfo.CurrentCulture, "unmanaged {0} {1}({2})",
unmanagedCallConv.ToString().ToLower(CultureInfo.CurrentCulture),
new TypeDescriptor(returnType).Value,
string.Join(", ", CalliDescriptor.GetArguments(parameterTypes).ToArray()));
}
开发者ID:JasonBock,项目名称:EmitDebugging,代码行数:8,代码来源:UnmanagedCalliDescriptor.cs
示例4: __StandAloneMethodSig
internal __StandAloneMethodSig(bool unmanaged, CallingConvention unmanagedCallingConvention, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type[] optionalParameterTypes)
{
this.unmanaged = unmanaged;
this.unmanagedCallingConvention = unmanagedCallingConvention;
this.callingConvention = callingConvention;
this.returnType = returnType;
this.parameterTypes = parameterTypes;
this.optionalParameterTypes = optionalParameterTypes;
}
开发者ID:koush,项目名称:mono,代码行数:9,代码来源:StandAloneMethodSig.cs
示例5: SignatureHelper
private SignatureHelper(Module mod, IntPtr context, IntPtr sig)
{
this.mod = mod;
this.context = context;
this.sig = sig;
this.numArgs = 0;
this.callConv = (CallingConvention)0;
this.field = false;
this.bytesOffset = -1;
((ModuleBuilder)mod).assembly.AddDetach(this);
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:11,代码来源:SignatureHelper.cs
示例6: CompilerFunctionCall
public CompilerFunctionCall(Compiler compiler, CompilerFunction caller, Operand target, CallingConvention callingConvention, VariableType[] arguments, VariableType returnValue)
: base(compiler)
{
Contract.Requires(arguments != null);
_caller = caller;
_target = target;
_functionPrototype = new FunctionDeclaration(callingConvention, arguments, returnValue);
if (arguments != null && arguments.Length > 0)
_args = new Operand[arguments.Length];
}
开发者ID:modulexcite,项目名称:nasmjit,代码行数:12,代码来源:CompilerFunctionCall.cs
示例7: FunctionDeclaration
internal FunctionDeclaration(CallingConvention callingConvention, VariableType[] arguments, VariableType returnValue)
{
Contract.Requires(arguments != null);
if (callingConvention == CallingConvention.Default)
callingConvention = CallingConventionInfo.DefaultCallingConvention;
_callingConvention = callingConvention;
if (arguments.Length > 32)
throw new ArgumentException();
SetPrototype(arguments, returnValue);
}
开发者ID:modulexcite,项目名称:nasmjit,代码行数:13,代码来源:FunctionDeclaration.cs
示例8: DynamicDllFunctionInvoke
public static object DynamicDllFunctionInvoke(
string dllPath,
string entryPoint,
MethodAttributes methodAttr,
CallingConvention nativeCallConv,
CharSet nativeCharSet,
Type returnType,
Type[] parameterTypes,
object[] parameterValues
)
{
string dllName = Path.GetFileNameWithoutExtension(dllPath);
// ����һ����̬����(assembly)��ģ��(module)
AssemblyName assemblyName = new AssemblyName();
assemblyName.Name = string.Format("A{0}{1}",
dllName,
Guid.NewGuid().ToString( "N" )
);
AssemblyBuilder dynamicAssembly =
AppDomain.CurrentDomain.DefineDynamicAssembly(
assemblyName, AssemblyBuilderAccess.Run);
ModuleBuilder dynamicModule =
dynamicAssembly.DefineDynamicModule(
string.Format("M{0}{1}",
dllName,
Guid.NewGuid().ToString("N"))
);
// ʹ��ָ������Ϣ����ƽ̨����ǩ��
MethodBuilder dynamicMethod =
dynamicModule.DefinePInvokeMethod(
entryPoint,
dllPath,
methodAttr,
CallingConventions.Standard,
returnType,
parameterTypes,
nativeCallConv,
nativeCharSet
);
// ��������
dynamicModule.CreateGlobalFunctions();
// ���ƽ̨���õķ���
MethodInfo methodInfo =
dynamicModule.GetMethod(entryPoint, parameterTypes);
// ���÷��йܺ�������÷��صĽ��
object result = methodInfo.Invoke(null, parameterValues);
return result;
}
开发者ID:zhaohengyi,项目名称:dotNet_PInvoke,代码行数:51,代码来源:DynamicPInvokeViaEmit.cs
示例9: MethodDesc
public unsafe MethodDesc(string name, string dll, string entryPoint, FUNCDESC funcdesc, string[] argumentNames, Func<uint, TypeDesc> typeFactory)
{
string tmpl = "___overloaded000";
if ((name.Length > tmpl.Length) && (name.IndexOf("___overloaded") == (name.Length - tmpl.Length)))
name = name.Substring(0, name.Length - tmpl.Length);
Name = EscapMethodName(name);
Dll = dll;
EntryPoint = entryPoint;
Offset = funcdesc.oVft;
ReturnValue = new ParameterDesc(funcdesc.elemdescFunc, string.Empty, typeFactory, 0, false, null);
List<ParameterDesc> parameters = new List<ParameterDesc>();
for (int i = 0; i < funcdesc.cParams; i++)
parameters.Add(new ParameterDesc(funcdesc.lprgelemdescParam[i], (i < argumentNames.Length) ? argumentNames[i] : "__arg" + i, typeFactory, 0, false, null));
Parameters = parameters.AsReadOnly();
//if (funcdesc.cParamsOpt != 0)
// throw new Exception("Variable number of optional parameters is not supported");
//if (funcdesc.invkind != INVOKEKIND.INVOKE_FUNC)
// throw new Exception("Only functions are currently supported");
if (funcdesc.cScodes >= 1)
throw new Exception("Only one return value is supported");
switch (funcdesc.callconv)
{
case System.Runtime.InteropServices.ComTypes.CALLCONV.CC_CDECL:
Convention = CallingConvention.Cdecl;
break;
case System.Runtime.InteropServices.ComTypes.CALLCONV.CC_STDCALL:
Convention = CallingConvention.StdCall;
break;
default:
throw new Exception("Calling convention " + funcdesc.callconv + " is not supported");
}
switch (funcdesc.funckind)
{
case FUNCKIND.FUNC_DISPATCH:
case FUNCKIND.FUNC_VIRTUAL:
case FUNCKIND.FUNC_PUREVIRTUAL:
case FUNCKIND.FUNC_NONVIRTUAL:
case FUNCKIND.FUNC_STATIC:
break;
default:
throw new Exception("Function kind " + funcdesc.funckind + " is not supported");
}
}
开发者ID:tablesmit,项目名称:NRegFreeCom,代码行数:49,代码来源:MethodDesc.cs
示例10: MethodSignature
public MethodSignature(
bool hasThis,
bool explicitThis,
CallingConvention callingConvention,
int genericParamCount,
IReadOnlyList<Parameter> parameters,
Type retType
)
{
m_hasThis = hasThis;
m_explicitThis = explicitThis;
m_callingConvention = callingConvention.CheckDefined("callingConvention");
m_genericParamCount = genericParamCount.CheckGTE(0, "genericParamCount");
m_parameters = parameters.CheckNotNull("parameters");
m_retType = retType.CheckNotNull("retType");
}
开发者ID:scottwis,项目名称:tiny,代码行数:16,代码来源:MethodSignature.cs
示例11: DLLExportAttribute
public DLLExportAttribute(string exportName,CallingConvention callingConvention)
{
ExportName = exportName;
switch(callingConvention)
{
case CallingConvention.Winapi:
case CallingConvention.StdCall:
Convention = typeof(CallConvStdcall).FullName;
break;
case CallingConvention.FastCall:
Convention = typeof(CallConvFastcall).FullName;
break;
case CallingConvention.ThisCall:
Convention = typeof(CallConvThiscall).FullName;
break;
case CallingConvention.Cdecl:
Convention = typeof(CallConvCdecl).FullName;
break;
default:
throw new NotImplementedException();
}
}
开发者ID:Thaina,项目名称:Librarinth-Web-Client,代码行数:23,代码来源:ExportDllAttribute.cs
示例12: Client
/// <summary>
/// Only constructor.
/// </summary>
/// <param name="ChanKind"></param>
/// <param name="ObjType"></param>
/// <param name="CallConv"></param>
/// <param name="InvKind"></param>
public Client(ChannelKind ChanKind,
Type ObjType,
CallingConvention CallConv,
InvokeKind InvKind,
string Host)
{
m_ChanKind = ChanKind;
m_ObjType = ObjType;
m_CallConv = CallConv;
m_InvKind = InvKind;
m_Host = Host;
}//constructor
开发者ID:ArildF,项目名称:masters,代码行数:19,代码来源:client.cs
示例13: GetOptions
}//Usage()
/// <summary>
/// Gets user options.
/// </summary>
private static void GetOptions()
{
GetChannel:
Console.Write("\nHttp (h), TCP (t) or both (b) using threads? ");
string Reply = Console.ReadLine();
switch (Reply.ToLower())
{
case "b":
m_ChanKind = ChannelKind.Both;
break;
case "h":
m_ChanKind = ChannelKind.Http;
break;
case "t":
m_ChanKind = ChannelKind.TCP;
break;
default:
Console.WriteLine("Invalid option, please try again.");
goto GetChannel;
}//switch
GetConvention:
Console.Write("\nBy ref (r) or by val (v)? ");
Reply = Console.ReadLine();
switch (Reply.ToLower())
{
case "r":
m_CallConv = CallingConvention.ByRef;
break;
case "v":
m_CallConv = CallingConvention.ByVal;
break;
default:
Console.WriteLine("Invalid option, please try again.");
goto GetConvention;
}//switch
GetInvoke:
Console.Write("\nSerial (s) or async (a)? ");
Reply = Console.ReadLine();
switch (Reply.ToLower())
{
case "a":
m_InvKind = InvokeKind.Async;
break;
case "s":
m_InvKind = InvokeKind.Sequential;
break;
default:
Console.WriteLine("Invalid option, please try again.");
goto GetInvoke;
}//switch
//Setup the correct Type object to pass to the Client object for object creation.
switch (m_CallConv)
{
case CallingConvention.ByRef:
m_ObjType = Type.GetType("RemotingSamples.HelloServerByRef,remotingshared");
break;
case CallingConvention.ByVal:
m_ObjType = Type.GetType("RemotingSamples.HelloServerByVal,remotingshared");
break;
default:
throw new System.InvalidOperationException("Invalid Calling Convention in Main()");
}//switch
Console.WriteLine();
return;
}//GetOptions()
开发者ID:ArildF,项目名称:masters,代码行数:73,代码来源:client.cs
示例14: UnmanagedFunctionPointerAttribute
public UnmanagedFunctionPointerAttribute(CallingConvention callingConvention)
{
this.call_conv = callingConvention;
}
开发者ID:davidleon,项目名称:MOSA-Project,代码行数:4,代码来源:Core.cs
示例15: UnmanagedFunctionPointerAttribute
public UnmanagedFunctionPointerAttribute(CallingConvention callingConvention)
{
_callingConvention = callingConvention;
}
开发者ID:niemyjski,项目名称:corert,代码行数:4,代码来源:UnmanagedFunctionPointerAttribute.cs
示例16: DefinePInvokeMethodHelperNoLock
[System.Security.SecurityCritical] // auto-generated
private MethodBuilder DefinePInvokeMethodHelperNoLock(
String name, String dllName, String importName, MethodAttributes attributes, CallingConventions callingConvention,
Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers,
CallingConvention nativeCallConv, CharSet nativeCharSet)
{
if (name == null)
throw new ArgumentNullException("name");
if (name.Length == 0)
throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
if (dllName == null)
throw new ArgumentNullException("dllName");
if (dllName.Length == 0)
throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "dllName");
if (importName == null)
throw new ArgumentNullException("importName");
if (importName.Length == 0)
throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "importName");
if ((attributes & MethodAttributes.Abstract) != 0)
throw new ArgumentException(Environment.GetResourceString("Argument_BadPInvokeMethod"));
Contract.EndContractBlock();
if ((m_iAttr & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Interface)
throw new ArgumentException(Environment.GetResourceString("Argument_BadPInvokeOnInterface"));
ThrowIfCreated();
attributes = attributes | MethodAttributes.PinvokeImpl;
MethodBuilder method = new MethodBuilder(name, attributes, callingConvention,
returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers,
parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers,
m_module, this, false);
//The signature grabbing code has to be up here or the signature won't be finished
//and our equals check won't work.
int sigLength;
byte[] sigBytes = method.GetMethodSignature().InternalGetSignature(out sigLength);
if (m_listMethods.Contains(method))
{
throw new ArgumentException(Environment.GetResourceString("Argument_MethodRedefined"));
}
m_listMethods.Add(method);
MethodToken token = method.GetToken();
int linkFlags = 0;
switch(nativeCallConv)
{
case CallingConvention.Winapi:
linkFlags =(int)PInvokeMap.CallConvWinapi;
break;
case CallingConvention.Cdecl:
linkFlags =(int)PInvokeMap.CallConvCdecl;
break;
case CallingConvention.StdCall:
linkFlags =(int)PInvokeMap.CallConvStdcall;
break;
case CallingConvention.ThisCall:
linkFlags =(int)PInvokeMap.CallConvThiscall;
break;
case CallingConvention.FastCall:
linkFlags =(int)PInvokeMap.CallConvFastcall;
break;
}
switch(nativeCharSet)
{
case CharSet.None:
linkFlags |=(int)PInvokeMap.CharSetNotSpec;
break;
case CharSet.Ansi:
linkFlags |=(int)PInvokeMap.CharSetAnsi;
break;
case CharSet.Unicode:
linkFlags |=(int)PInvokeMap.CharSetUnicode;
break;
case CharSet.Auto:
linkFlags |=(int)PInvokeMap.CharSetAuto;
break;
}
SetPInvokeData(m_module.GetNativeHandle(),
dllName,
importName,
token.Token,
linkFlags);
method.SetToken(token);
return method;
}
开发者ID:uQr,项目名称:referencesource,代码行数:97,代码来源:typebuilder.cs
示例17: DefinePInvokeMethodHelper
[System.Security.SecurityCritical] // auto-generated
private MethodBuilder DefinePInvokeMethodHelper(
String name, String dllName, String importName, MethodAttributes attributes, CallingConventions callingConvention,
Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers,
CallingConvention nativeCallConv, CharSet nativeCharSet)
{
CheckContext(returnType);
CheckContext(returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes);
CheckContext(parameterTypeRequiredCustomModifiers);
CheckContext(parameterTypeOptionalCustomModifiers);
AppDomain.CheckDefinePInvokeSupported();
lock (SyncRoot)
{
return DefinePInvokeMethodHelperNoLock(name, dllName, importName, attributes, callingConvention,
returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers,
parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers,
nativeCallConv, nativeCharSet);
}
}
开发者ID:uQr,项目名称:referencesource,代码行数:22,代码来源:typebuilder.cs
示例18: EmitCalli
public virtual void EmitCalli(OpCode opcode, CallingConvention unmanagedCallConv, Type returnType, Type[] parameterTypes)
{
int stackchange = 0;
int cParams = 0;
int i;
SignatureHelper sig;
ModuleBuilder modBuilder = (ModuleBuilder) m_methodBuilder.Module;
if (parameterTypes != null)
{
cParams = parameterTypes.Length;
}
sig = SignatureHelper.GetMethodSigHelper(
modBuilder,
unmanagedCallConv,
returnType);
if (parameterTypes != null)
{
for (i = 0; i < cParams; i++)
{
sig.AddArgument(parameterTypes[i]);
}
}
// If there is a non-void return type, push one.
if (returnType != typeof(void))
stackchange++;
// Pop off arguments if any.
if (parameterTypes != null)
stackchange -= cParams;
// Pop the native function pointer.
stackchange--;
UpdateStackSize(OpCodes.Calli, stackchange);
EnsureCapacity(7);
Emit(OpCodes.Calli);
RecordTokenFixup();
PutInteger4(modBuilder.GetSignatureToken(sig).Token);
}
开发者ID:uQr,项目名称:referencesource,代码行数:44,代码来源:ilgenerator.cs
示例19: DefinePInvokeMethodNoLock
[System.Security.SecurityCritical] // auto-generated
#endif
private MethodBuilder DefinePInvokeMethodNoLock(String name, String dllName, String entryName, MethodAttributes attributes,
CallingConventions callingConvention, Type returnType, Type[] parameterTypes, CallingConvention nativeCallConv,
CharSet nativeCharSet)
{
//Global methods must be static.
if ((attributes & MethodAttributes.Static) == 0)
{
throw new ArgumentException(Environment.GetResourceString("Argument_GlobalFunctionHasToBeStatic"));
}
Contract.Ensures(Contract.Result<MethodBuilder>() != null);
Contract.EndContractBlock();
CheckContext(returnType);
CheckContext(parameterTypes);
m_moduleData.m_fHasGlobal = true;
return m_moduleData.m_globalTypeBuilder.DefinePInvokeMethod(name, dllName, entryName, attributes, callingConvention, returnType, parameterTypes, nativeCallConv, nativeCharSet);
}
开发者ID:crummel,项目名称:dotnet_coreclr,代码行数:20,代码来源:ModuleBuilder.cs
示例20: DefinePInvokeMethod
[System.Security.SecurityCritical] // auto-generated
#endif
public MethodBuilder DefinePInvokeMethod(String name, String dllName, String entryName, MethodAttributes attributes,
CallingConventions callingConvention, Type returnType, Type[] parameterTypes, CallingConvention nativeCallConv,
CharSet nativeCharSet)
{
Contract.Ensures(Contract.Result<MethodBuilder>() != null);
lock(SyncRoot)
{
return DefinePInvokeMethodNoLock(name, dllName, entryName, attributes, callingConvention,
returnType, parameterTypes, nativeCallConv, nativeCharSet);
}
}
开发者ID:crummel,项目名称:dotnet_coreclr,代码行数:14,代码来源:ModuleBuilder.cs
注:本文中的CallingConvention类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论