Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetDllImportCustomAttribute()

static DllImportAttribute System.Reflection.PseudoCustomAttribute.GetDllImportCustomAttribute ( RuntimeMethodInfo method)
inlinestaticprivate

Definition at line 216 of file PseudoCustomAttribute.cs.

217 {
218 if ((method.Attributes & MethodAttributes.PinvokeImpl) == 0)
219 {
220 return null;
221 }
222 MetadataImport metadataImport = ModuleHandle.GetMetadataImport(method.Module.ModuleHandle.GetRuntimeModule());
223 int metadataToken = method.MetadataToken;
224 metadataImport.GetPInvokeMap(metadataToken, out var attributes, out var importName, out var importDll);
225 CharSet charSet = CharSet.None;
226 switch (attributes & PInvokeAttributes.CharSetMask)
227 {
228 case PInvokeAttributes.CharSetNotSpec:
229 charSet = CharSet.None;
230 break;
231 case PInvokeAttributes.CharSetAnsi:
232 charSet = CharSet.Ansi;
233 break;
234 case PInvokeAttributes.CharSetUnicode:
235 charSet = CharSet.Unicode;
236 break;
237 case PInvokeAttributes.CharSetMask:
238 charSet = CharSet.Auto;
239 break;
240 }
242 switch (attributes & PInvokeAttributes.CallConvMask)
243 {
244 case PInvokeAttributes.CallConvWinapi:
246 break;
247 case PInvokeAttributes.CallConvCdecl:
249 break;
250 case PInvokeAttributes.CallConvStdcall:
252 break;
253 case PInvokeAttributes.CallConvThiscall:
255 break;
256 case PInvokeAttributes.CallConvFastcall:
258 break;
259 }
261 dllImportAttribute.EntryPoint = importName;
262 dllImportAttribute.CharSet = charSet;
263 dllImportAttribute.SetLastError = (attributes & PInvokeAttributes.SupportsLastError) != 0;
264 dllImportAttribute.ExactSpelling = (attributes & PInvokeAttributes.NoMangle) != 0;
265 dllImportAttribute.PreserveSig = (method.GetMethodImplementationFlags() & MethodImplAttributes.PreserveSig) != 0;
266 dllImportAttribute.CallingConvention = callingConvention;
267 dllImportAttribute.BestFitMapping = (attributes & PInvokeAttributes.BestFitMask) == PInvokeAttributes.BestFitEnabled;
268 dllImportAttribute.ThrowOnUnmappableChar = (attributes & PInvokeAttributes.ThrowOnUnmappableCharMask) == PInvokeAttributes.ThrowOnUnmappableCharEnabled;
269 return dllImportAttribute;
270 }

References System.ModuleHandle.GetMetadataImport().

Referenced by System.Reflection.PseudoCustomAttribute.GetCustomAttributes().