14 [__DynamicallyInvokable]
17 private const int LMEM_FIXED = 0;
19 private const int LMEM_MOVEABLE = 2;
21 private const long HIWORDMASK = -65536
L;
23 private static Guid IID_IUnknown =
new Guid(
"00000000-0000-0000-C000-000000000046");
31 private const string s_strConvertedTypeInfoAssemblyName =
"InteropDynamicTypes";
33 private const string s_strConvertedTypeInfoAssemblyTitle =
"Interop Dynamic Types";
35 private const string s_strConvertedTypeInfoAssemblyDesc =
"Type dynamically generated from ITypeInfo's";
37 private const string s_strConvertedTypeInfoNameSpace =
"InteropDynamicTypes";
39 internal static readonly
Guid ManagedNameGuid =
new Guid(
"{0F21F359-AB84-41E8-9A78-36D110E6D2F9}");
41 private static bool IsWin32Atom(
IntPtr ptr)
44 return (num & -65536) == 0;
47 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
48 private static bool IsNotWin32Atom(
IntPtr ptr)
51 return (num & -65536) != 0;
55 private static extern int GetSystemMaxDBCSCharSize();
71 if (Win32Native.lstrlenA(ptr) == 0)
75 return new string((sbyte*)(
void*)ptr);
95 return new string((sbyte*)(
void*)ptr, 0, len);
113 return new string((
char*)(
void*)ptr, 0, len);
138 if (IsWin32Atom(ptr))
142 return new string((
char*)(
void*)ptr);
159 public static int SizeOf(
object structure)
161 if (structure ==
null)
165 return SizeOfHelper(structure.GetType(), throwIfNotMarshalable:
true);
175 return SizeOf((
object)structure);
189 if (!(t is RuntimeType))
197 return SizeOfHelper(t, throwIfNotMarshalable:
true);
208 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.MayFail)]
209 internal static uint AlignedSizeOf<T>() where T : struct
211 uint num = SizeOfType(typeof(T));
212 if (num == 1 || num == 2)
220 return AlignedSizeOfType(typeof(T));
224 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
225 internal static extern uint SizeOfType(Type type);
228 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
229 private static extern uint AlignedSizeOfType(Type type);
232 [SecuritySafeCritical]
233 internal static extern int SizeOfHelper(Type t,
bool throwIfNotMarshalable);
252 RtFieldInfo rtFieldInfo = field as RtFieldInfo;
253 if (rtFieldInfo ==
null)
257 return OffsetOfHelper(rtFieldInfo);
270 private static extern IntPtr OffsetOfHelper(IRuntimeFieldInfo f);
301 public static void Copy(
int[] source,
int startIndex,
IntPtr destination,
int length)
303 CopyToNative(source, startIndex, destination, length);
316 public static void Copy(
char[] source,
int startIndex,
IntPtr destination,
int length)
318 CopyToNative(source, startIndex, destination, length);
331 public static void Copy(
short[] source,
int startIndex,
IntPtr destination,
int length)
333 CopyToNative(source, startIndex, destination, length);
346 public static void Copy(
long[] source,
int startIndex,
IntPtr destination,
int length)
348 CopyToNative(source, startIndex, destination, length);
361 public static void Copy(
float[] source,
int startIndex,
IntPtr destination,
int length)
363 CopyToNative(source, startIndex, destination, length);
376 public static void Copy(
double[] source,
int startIndex,
IntPtr destination,
int length)
378 CopyToNative(source, startIndex, destination, length);
391 public static void Copy(
byte[] source,
int startIndex,
IntPtr destination,
int length)
393 CopyToNative(source, startIndex, destination, length);
406 CopyToNative(source, startIndex, destination, length);
410 private static extern void CopyToNative(
object source,
int startIndex,
IntPtr destination,
int length);
420 public static void Copy(
IntPtr source,
int[] destination,
int startIndex,
int length)
422 CopyToManaged(source, destination, startIndex, length);
433 public static void Copy(
IntPtr source,
char[] destination,
int startIndex,
int length)
435 CopyToManaged(source, destination, startIndex, length);
446 public static void Copy(
IntPtr source,
short[] destination,
int startIndex,
int length)
448 CopyToManaged(source, destination, startIndex, length);
459 public static void Copy(
IntPtr source,
long[] destination,
int startIndex,
int length)
461 CopyToManaged(source, destination, startIndex, length);
472 public static void Copy(
IntPtr source,
float[] destination,
int startIndex,
int length)
474 CopyToManaged(source, destination, startIndex, length);
485 public static void Copy(
IntPtr source,
double[] destination,
int startIndex,
int length)
487 CopyToManaged(source, destination, startIndex, length);
498 public static void Copy(
IntPtr source,
byte[] destination,
int startIndex,
int length)
500 CopyToManaged(source, destination, startIndex, length);
513 CopyToManaged(source, destination, startIndex, length);
517 private static extern void CopyToManaged(
IntPtr source,
object destination,
int startIndex,
int length);
526 [DllImport(
"mscoree.dll", EntryPoint =
"ND_RU1")]
527 [SuppressUnmanagedCodeSecurity]
541 byte* ptr2 = (
byte*)(
void*)ptr + ofs;
570 [DllImport(
"mscoree.dll", EntryPoint =
"ND_RI2")]
571 [SuppressUnmanagedCodeSecurity]
585 byte* ptr2 = (
byte*)(
void*)ptr + ofs;
586 if (((
int)ptr2 & 1) == 0)
588 return *(
short*)ptr2;
590 short result =
default(
short);
591 byte* ptr3 = (
byte*)(&result);
622 [DllImport(
"mscoree.dll", EntryPoint =
"ND_RI4")]
623 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
624 [SuppressUnmanagedCodeSecurity]
634 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
639 byte* ptr2 = (
byte*)(
void*)ptr + ofs;
640 if (((
int)ptr2 & 3) == 0)
644 int result =
default(
int);
645 byte* ptr3 = (
byte*)(&result);
666 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
680 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
692 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
706 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
719 [DllImport(
"mscoree.dll", EntryPoint =
"ND_RI8")]
720 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
721 [SuppressUnmanagedCodeSecurity]
735 byte* ptr2 = (
byte*)(
void*)ptr + ofs;
736 if (((
int)ptr2 & 7) == 0)
740 long result =
default(
long);
741 byte* ptr3 = (
byte*)(&result);
766 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
782 byte* ptr2 = (
byte*)(
void*)ptr + ofs;
798 [DllImport(
"mscoree.dll", EntryPoint =
"ND_WU1")]
799 [SuppressUnmanagedCodeSecurity]
801 public static extern void WriteByte([In] [Out] [MarshalAs(
UnmanagedType.AsAny)]
object ptr,
int ofs,
byte val);
826 byte* ptr2 = (
byte*)(
void*)ptr + ofs;
827 if (((
int)ptr2 & 1) == 0)
833 byte* ptr3 = (
byte*)(&val);
851 [DllImport(
"mscoree.dll", EntryPoint =
"ND_WI2")]
852 [SuppressUnmanagedCodeSecurity]
854 public static extern void WriteInt16([In] [Out] [MarshalAs(
UnmanagedType.AsAny)]
object ptr,
int ofs,
short val);
888 public static void WriteInt16([In] [Out]
object ptr,
int ofs,
char val)
916 byte* ptr2 = (
byte*)(
void*)ptr + ofs;
917 if (((
int)ptr2 & 3) == 0)
923 byte* ptr3 = (
byte*)(&val);
943 [DllImport(
"mscoree.dll", EntryPoint =
"ND_WI4")]
944 [SuppressUnmanagedCodeSecurity]
946 public static extern void WriteInt32([In] [Out] [MarshalAs(
UnmanagedType.AsAny)]
object ptr,
int ofs,
int val);
1008 byte* ptr2 = (
byte*)(
void*)ptr + ofs;
1009 if (((
int)ptr2 & 7) == 0)
1015 byte* ptr3 = (
byte*)(&val);
1039 [DllImport(
"mscoree.dll", EntryPoint =
"ND_WI8")]
1040 [SuppressUnmanagedCodeSecurity]
1042 public static extern void WriteInt64([In] [Out] [MarshalAs(
UnmanagedType.AsAny)]
object ptr,
int ofs,
long val);
1061 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
1065 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
1066 internal static extern void SetLastWin32Error(
int error);
1071 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
1075 if ((lastWin32Error & 2147483648u) == 2147483648u)
1077 return lastWin32Error;
1079 return (lastWin32Error & 0xFFFF) | -2147024896;
1093 RuntimeMethodInfo runtimeMethodInfo = m as RuntimeMethodInfo;
1094 if (runtimeMethodInfo ==
null)
1098 InternalPrelink(runtimeMethodInfo);
1102 [SuppressUnmanagedCodeSecurity]
1104 private static extern void InternalPrelink(IRuntimeMethodInfo m);
1117 if (methods !=
null)
1119 for (
int i = 0; i < methods.Length; i++)
1138 RuntimeMethodInfo runtimeMethodInfo = m as RuntimeMethodInfo;
1139 if (runtimeMethodInfo ==
null)
1143 return InternalNumParamBytes(runtimeMethodInfo);
1147 [SuppressUnmanagedCodeSecurity]
1149 private static extern int InternalNumParamBytes(IRuntimeMethodInfo m);
1174 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.MayFail)]
1200 PtrToStructureHelper(ptr, structure, allowValueClasses:
false);
1232 if (structureType ==
null)
1241 if (runtimeType ==
null)
1245 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
1246 object obj = runtimeType.CreateInstanceDefaultCtor(publicOnly:
false, skipCheckThis:
false, fillCache:
false, ref stackMark);
1247 PtrToStructureHelper(ptr, obj, allowValueClasses:
true);
1264 private static extern void PtrToStructureHelper(
IntPtr ptr,
object structure,
bool allowValueClasses);
1298 RuntimeModule runtimeModule = m as RuntimeModule;
1299 if (runtimeModule ==
null)
1302 if (moduleBuilder !=
null)
1304 runtimeModule = moduleBuilder.InternalModule;
1307 if (runtimeModule ==
null)
1316 [SuppressUnmanagedCodeSecurity]
1317 [SuppressUnmanagedCodeSecurity]
1327 ThrowExceptionForHRInternal(errorCode,
IntPtr.
Zero);
1340 ThrowExceptionForHRInternal(errorCode, errorInfo);
1345 internal static extern void ThrowExceptionForHRInternal(
int errorCode,
IntPtr errorInfo);
1355 return GetExceptionForHRInternal(errorCode,
IntPtr.
Zero);
1369 return GetExceptionForHRInternal(errorCode, errorInfo);
1375 internal static extern Exception GetExceptionForHRInternal(
int errorCode,
IntPtr errorInfo);
1386 internal static extern int GetHRForException_WinRT(
Exception e);
1395 [Obsolete(
"The GetUnmanagedThunkForManagedMethodPtr method has been deprecated and will be removed in a future release.",
false)]
1405 [Obsolete(
"The GetManagedThunkForUnmanagedMethodPtr method has been deprecated and will be removed in a future release.",
false)]
1413 [Obsolete(
"The GetThreadFromFiberCookie method has been deprecated. Use the hosting API to perform this operation.",
false)]
1420 return InternalGetThreadFromFiberCookie(cookie);
1424 private static extern Thread InternalGetThreadFromFiberCookie(
int cookie);
1431 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.MayFail)]
1435 IntPtr intPtr = Win32Native.LocalAlloc_NoSafeHandle(0, sizetdwBytes);
1448 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.MayFail)]
1457 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
1460 if (IsNotWin32Atom(hglobal) &&
IntPtr.
Zero != Win32Native.LocalFree(hglobal))
1474 IntPtr intPtr = Win32Native.LocalReAlloc(pv, cb, 2);
1500 IntPtr intPtr = Win32Native.LocalAlloc_NoSafeHandle(0, sizetdwBytes);
1505 s.ConvertToAnsi((
byte*)(
void*)intPtr, num, fBestFit:
false, fThrowOnUnmappableChar:
false);
1521 int num = (s.Length + 1) * 2;
1527 IntPtr intPtr = Win32Native.LocalAlloc_NoSafeHandle(0, sizetdwBytes);
1532 fixed (
char* smem = s)
1534 string.wstrcpy((
char*)(
void*)intPtr, smem, s.Length + 1);
1553 [Obsolete(
"Use System.Runtime.InteropServices.Marshal.GetTypeLibName(ITypeLib pTLB) instead. http://go.microsoft.com/fwlink/?linkid=14202&ID=0000011.",
false)]
1566 if (typelib ==
null)
1570 string strName =
null;
1571 string strDocString =
null;
1572 int dwHelpContext = 0;
1573 string strHelpFile =
null;
1574 typelib.
GetDocumentation(-1, out strName, out strDocString, out dwHelpContext, out strHelpFile);
1579 internal static string GetTypeLibNameInternal(
ITypeLib typelib)
1581 if (typelib ==
null)
1586 if (typeLib !=
null)
1588 Guid guid = ManagedNameGuid;
1598 if (pVarVal !=
null && pVarVal.GetType() == typeof(
string))
1600 string text = (string)pVarVal;
1604 text = text.Substring(0, text.Length - 4);
1608 text = text.Substring(0, text.Length - 4);
1620 [Obsolete(
"Use System.Runtime.InteropServices.Marshal.GetTypeLibGuid(ITypeLib pTLB) instead. http://go.microsoft.com/fwlink/?linkid=14202&ID=0000011.",
false)]
1633 FCallGetTypeLibGuid(ref result, typelib);
1638 private static extern void FCallGetTypeLibGuid(ref
Guid result,
ITypeLib pTLB);
1644 [Obsolete(
"Use System.Runtime.InteropServices.Marshal.GetTypeLibLcid(ITypeLib pTLB) instead. http://go.microsoft.com/fwlink/?linkid=14202&ID=0000011.",
false)]
1658 internal static extern void GetTypeLibVersion(
ITypeLib typeLibrary, out
int major, out
int minor);
1664 FCallGetTypeInfoGuid(ref result, typeInfo);
1669 private static extern void FCallGetTypeInfoGuid(ref
Guid result,
ITypeInfo typeInfo);
1683 RuntimeAssembly runtimeAssembly =
asm as RuntimeAssembly;
1684 if (runtimeAssembly ==
null)
1689 FCallGetTypeLibGuidForAssembly(ref result, runtimeAssembly);
1694 private static extern void FCallGetTypeLibGuidForAssembly(ref
Guid result, RuntimeAssembly
asm);
1697 private static extern void _GetTypeLibVersionForAssembly(RuntimeAssembly inputAssembly, out
int majorVersion, out
int minorVersion);
1708 if (inputAssembly ==
null)
1712 RuntimeAssembly runtimeAssembly = inputAssembly as RuntimeAssembly;
1713 if (runtimeAssembly ==
null)
1717 _GetTypeLibVersionForAssembly(runtimeAssembly, out majorVersion, out minorVersion);
1724 [Obsolete(
"Use System.Runtime.InteropServices.Marshal.GetTypeInfoName(ITypeInfo pTLB) instead. http://go.microsoft.com/fwlink/?linkid=14202&ID=0000011.",
false)]
1737 if (typeInfo ==
null)
1741 string strName =
null;
1742 string strDocString =
null;
1743 int dwHelpContext = 0;
1744 string strHelpFile =
null;
1745 typeInfo.
GetDocumentation(-1, out strName, out strDocString, out dwHelpContext, out strHelpFile);
1750 internal static string GetTypeInfoNameInternal(
ITypeInfo typeInfo, out
bool hasManagedName)
1752 if (typeInfo ==
null)
1757 if (typeInfo2 !=
null)
1759 Guid guid = ManagedNameGuid;
1769 if (pVarVal !=
null && pVarVal.GetType() == typeof(
string))
1771 hasManagedName =
true;
1772 return (
string)pVarVal;
1775 hasManagedName =
false;
1780 internal static string GetManagedTypeInfoNameInternal(
ITypeLib typeLib,
ITypeInfo typeInfo)
1782 bool hasManagedName;
1783 string typeInfoNameInternal = GetTypeInfoNameInternal(typeInfo, out hasManagedName);
1786 return typeInfoNameInternal;
1788 return GetTypeLibNameInternal(typeLib) +
"." + typeInfoNameInternal;
1792 private static extern Type GetLoadedTypeForGUID(ref Guid guid);
1811 Guid guid = GetTypeInfoGuid(typeInfo);
1812 type = GetLoadedTypeForGUID(ref guid);
1828 string fullName = assemblyNameFromTypelib.
FullName;
1830 int num = assemblies.Length;
1831 for (
int i = 0; i < num; i++)
1833 if (
string.Compare(assemblies[i].FullName, fullName,
StringComparison.Ordinal) == 0)
1835 assembly = assemblies[i];
1838 if (assembly ==
null)
1843 type = assembly.GetType(GetManagedTypeInfoNameInternal(ppTLB, typeInfo), throwOnError:
true, ignoreCase:
false);
1851 type = typeof(
object);
1860 [SecuritySafeCritical]
1863 return RuntimeType.GetTypeFromCLSIDImpl(clsid,
null, throwOnError:
false);
1881 [__DynamicallyInvokable]
1884 return GetIUnknownForObjectNative(o, onlyInContext:
false);
1893 return GetIUnknownForObjectNative(o, onlyInContext:
true);
1897 private static extern IntPtr GetIUnknownForObjectNative(
object o,
bool onlyInContext);
1900 internal static extern IntPtr GetRawIUnknownForComObjectNoAddRef(
object o);
1908 [__DynamicallyInvokable]
1911 return GetIDispatchForObjectNative(o, onlyInContext:
false);
1924 return GetIDispatchForObjectNative(o, onlyInContext:
true);
1928 private static extern IntPtr GetIDispatchForObjectNative(
object o,
bool onlyInContext);
1940 return GetComInterfaceForObjectNative(o,
T, onlyInContext:
false, fEnalbeCustomizedQueryInterface:
true);
1969 return GetComInterfaceForObjectNative(o,
T, onlyInContext:
false, fEnalbeCustomizedQueryInterface);
1986 return GetComInterfaceForObjectNative(o, t, onlyInContext:
true, fEnalbeCustomizedQueryInterface:
true);
1990 private static extern IntPtr GetComInterfaceForObjectNative(
object o,
Type t,
bool onlyInContext,
bool fEnalbeCustomizedQueryInterface);
1997 [__DynamicallyInvokable]
2060 [SecuritySafeCritical]
2070 IntPtr intPtr = Win32Native.CoTaskMemAlloc(
new UIntPtr((uint)cb));
2090 int num = (s.Length + 1) * 2;
2095 IntPtr intPtr = Win32Native.CoTaskMemAlloc(
new UIntPtr((uint)num));
2100 fixed (
char* smem = s)
2102 string.wstrcpy((
char*)(
void*)intPtr, smem, s.Length + 1);
2135 IntPtr intPtr = Win32Native.CoTaskMemAlloc(
new UIntPtr((uint)num));
2140 s.ConvertToAnsi((
byte*)(
void*)intPtr, num, fBestFit:
false, fThrowOnUnmappableChar:
false);
2149 if (IsNotWin32Atom(ptr))
2151 Win32Native.CoTaskMemFree(ptr);
2163 IntPtr intPtr = Win32Native.CoTaskMemRealloc(pv,
new UIntPtr((uint)cb));
2181 __ComObject _ComObject =
null;
2184 _ComObject = (__ComObject)o;
2190 return _ComObject.ReleaseSelf();
2194 internal static extern int InternalReleaseComObject(
object o);
2210 __ComObject _ComObject =
null;
2213 _ComObject = (__ComObject)o;
2219 _ComObject.FinalReleaseSelf();
2224 internal static extern void InternalFinalReleaseComObject(
object o);
2247 __ComObject _ComObject =
null;
2250 _ComObject = (__ComObject)obj;
2256 if (obj.GetType().IsWindowsRuntimeObject)
2260 return _ComObject.GetData(key);
2286 __ComObject _ComObject =
null;
2289 _ComObject = (__ComObject)obj;
2295 if (obj.GetType().IsWindowsRuntimeObject)
2299 return _ComObject.SetData(key, data);
2327 if (t.IsWindowsRuntimeObject)
2335 if (!o.GetType().IsCOMObject)
2339 if (o.GetType().IsWindowsRuntimeObject)
2343 if (o.GetType() == t)
2350 obj = InternalCreateWrapperOfType(o, t);
2377 private static extern object InternalCreateWrapperOfType(
object o,
Type t);
2381 [Obsolete(
"This API did not perform any operation and will be removed in future versions of the CLR.",
false)]
2391 [SecuritySafeCritical]
2415 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
2421 [__DynamicallyInvokable]
2424 if (IsNotWin32Atom(ptr))
2426 Win32Native.SysFreeString(ptr);
2436 [__DynamicallyInvokable]
2443 if (s.Length + 1 < s.Length)
2447 IntPtr intPtr = Win32Native.SysAllocStringLen(s, s.Length);
2461 [__DynamicallyInvokable]
2532 if (objectsForNativeVariants !=
null)
2534 array =
new T[objectsForNativeVariants.Length];
2535 Array.
Copy(objectsForNativeVariants, array, objectsForNativeVariants.Length);
2579 if (!(m is RuntimeMethodInfo))
2591 return InternalGetComSlotForMethodInfo((IRuntimeMethodInfo)m);
2595 private static extern int InternalGetComSlotForMethodInfo(IRuntimeMethodInfo m);
2604 FCallGenerateGuidForType(ref result, type);
2609 private static extern void FCallGenerateGuidForType(ref
Guid result,
Type type);
2636 for (
int i = 0; i < customAttributes.
Count; i++)
2641 string text = (string)constructorArguments[0].Value;
2644 text =
string.Empty;
2659 object ppvResult =
null;
2661 CreateBindCtx(0u, out ppbc);
2663 MkParseDisplayName(ppbc, monikerName, out uint _, out ppmk);
2664 BindMoniker(ppmk, 0u, ref IID_IUnknown, out ppvResult);
2675 object ppunk =
null;
2679 CLSIDFromProgIDEx(progID, out clsid);
2683 CLSIDFromProgID(progID, out clsid);
2689 [DllImport(
"ole32.dll", PreserveSig =
false)]
2690 [SuppressUnmanagedCodeSecurity]
2692 private static extern void CLSIDFromProgIDEx([MarshalAs(
UnmanagedType.LPWStr)]
string progId, out
Guid clsid);
2694 [DllImport(
"ole32.dll", PreserveSig =
false)]
2695 [SuppressUnmanagedCodeSecurity]
2697 private static extern void CLSIDFromProgID([MarshalAs(
UnmanagedType.LPWStr)]
string progId, out
Guid clsid);
2699 [DllImport(
"ole32.dll", PreserveSig =
false)]
2700 [SuppressUnmanagedCodeSecurity]
2702 private static extern void CreateBindCtx(uint reserved, out
IBindCtx ppbc);
2704 [DllImport(
"ole32.dll", PreserveSig =
false)]
2705 [SuppressUnmanagedCodeSecurity]
2707 private static extern void MkParseDisplayName(
IBindCtx pbc, [MarshalAs(
UnmanagedType.LPWStr)]
string szUserName, out uint pchEaten, out
IMoniker ppmk);
2709 [DllImport(
"ole32.dll", PreserveSig =
false)]
2710 [SuppressUnmanagedCodeSecurity]
2712 private static extern void BindMoniker(
IMoniker pmk, uint grfOpt, ref
Guid iidResult, [MarshalAs(
UnmanagedType.Interface)] out
object ppvResult);
2714 [DllImport(
"oleaut32.dll", PreserveSig =
false)]
2715 [SuppressUnmanagedCodeSecurity]
2720 internal static extern bool InternalSwitchCCW(
object oldtp,
object newtp);
2723 internal static extern object InternalWrapIUnknownWithComObject(
IntPtr i);
2726 private static IntPtr LoadLicenseManager()
2728 Assembly assembly =
Assembly.
Load(
"System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
2729 Type type = assembly.GetType(
"System.ComponentModel.LicenseManager");
2747 internal static extern void InitializeWrapperForWinRT(
object o, ref
IntPtr pUnk);
2751 internal static extern void InitializeManagedWinRTFactoryObject(
object o, RuntimeType runtimeClassType);
2755 internal static extern object GetNativeActivationFactory(
Type type);
2759 [SuppressUnmanagedCodeSecurity]
2760 private static extern void _GetInspectableIids(ObjectHandleOnStack obj, ObjectHandleOnStack guids);
2763 internal static Guid[] GetInspectableIids(
object obj)
2766 __ComObject o2 = obj as __ComObject;
2769 _GetInspectableIids(JitHelpers.GetObjectHandleOnStack(ref o2), JitHelpers.GetObjectHandleOnStack(ref o));
2776 [SuppressUnmanagedCodeSecurity]
2777 private static extern void _GetCachedWinRTTypeByIid(ObjectHandleOnStack appDomainObj, Guid iid, out IntPtr rthHandle);
2780 internal static Type GetCachedWinRTTypeByIid(AppDomain ad, Guid iid)
2782 _GetCachedWinRTTypeByIid(JitHelpers.GetObjectHandleOnStack(ref ad), iid, out IntPtr rthHandle);
2783 return Type.GetTypeFromHandleUnsafe(rthHandle);
2788 [SuppressUnmanagedCodeSecurity]
2789 private static extern void _GetCachedWinRTTypes(ObjectHandleOnStack appDomainObj, ref
int epoch, ObjectHandleOnStack winrtTypes);
2792 internal static Type[] GetCachedWinRTTypes(AppDomain ad, ref
int epoch)
2795 _GetCachedWinRTTypes(JitHelpers.GetObjectHandleOnStack(ref ad), ref epoch, JitHelpers.GetObjectHandleOnStack(ref o));
2797 for (
int i = 0; i < o.Length; i++)
2799 array[i] =
Type.GetTypeFromHandleUnsafe(o[i]);
2805 internal static Type[] GetCachedWinRTTypes(AppDomain ad)
2808 return GetCachedWinRTTypes(ad, ref epoch);
2828 if (t as RuntimeType ==
null)
2841 return GetDelegateForFunctionPointerInternal(ptr, t);
2857 internal static extern Delegate GetDelegateForFunctionPointerInternal(
IntPtr ptr,
Type t);
2867 if ((
object)d ==
null)
2871 return GetFunctionPointerForDelegateInternal(d);
2886 internal static extern IntPtr GetFunctionPointerForDelegateInternal(
Delegate d);
2917 return s.ToAnsiStr(allocateFromHeap:
false);
2933 return s.ToUniStr(allocateFromHeap:
false);
2941 Win32Native.ZeroMemory(s, (
UIntPtr)(Win32Native.SysStringLen(s) * 2));
2950 Win32Native.ZeroMemory(s, (
UIntPtr)(ulong)Win32Native.lstrlenA(s));
2959 Win32Native.ZeroMemory(s, (
UIntPtr)(ulong)(Win32Native.lstrlenW(s) * 2));
2976 return s.ToAnsiStr(allocateFromHeap:
true);
2992 return s.ToUniStr(allocateFromHeap:
true);
3000 Win32Native.ZeroMemory(s, (
UIntPtr)(ulong)Win32Native.lstrlenA(s));
3009 Win32Native.ZeroMemory(s, (
UIntPtr)(ulong)(Win32Native.lstrlenW(s) * 2));
static readonly int SystemMaxDBCSCharSize
Represents the maximum size of a double byte character set (DBCS) size, in bytes, for the current ope...
Obtains information about the attributes of a member and provides access to member metadata.
abstract Type BaseType
Gets the type from which the current T:System.Type directly inherits.
A platform-specific type that is used to represent a pointer or a handle.
Performs reflection on a module.
Provides the managed definition of the Component Automation ITypeInfo interface.
static void PrelinkAll(Type c)
Performs a pre-link check for all methods on a class.
abstract FieldInfo GetField(string name, BindingFlags bindingAttr)
Searches for the specified field, using the specified binding constraints.
static unsafe void WriteInt64(IntPtr ptr, int ofs, long val)
Writes a 64-bit signed integer value to unmanaged memory at a specified offset.
static unsafe void WriteByte(IntPtr ptr, int ofs, byte val)
Writes a single byte value to unmanaged memory at a specified offset.
static long ReadInt64(IntPtr ptr)
Reads a 64-bit signed integer from unmanaged memory.
bool IsVisible
Gets a value indicating whether the T:System.Type can be accessed by code outside the assembly.
static int ReadInt32([In] [MarshalAs(UnmanagedType.AsAny)] object ptr, int ofs)
Reads a 32-bit signed integer at a given offset from unmanaged memory.
static bool IsComObject(object o)
Indicates whether a specified object represents a COM object.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
static void ReleaseThreadCache()
Releases the thread cache.
The exception that is thrown when there is an attempt to dereference a null object reference.
static IntPtr GetHINSTANCE(Module m)
Returns the instance handle (HINSTANCE) for the specified module.
static IntPtr ReAllocHGlobal(IntPtr pv, IntPtr cb)
Resizes a block of memory previously allocated with M:System.Runtime.InteropServices....
static T [] GetObjectsForNativeVariants< T >(IntPtr aSrcNativeVariant, int cVars)
[Supported in the .NET Framework 4.5.1 and later versions] Converts an array of COM VARIANTs to an ar...
static string GetTypeInfoName(UCOMITypeInfo pTI)
Retrieves the name of the type represented by an ITypeInfo object.
static void WriteIntPtr([In] [Out] [MarshalAs(UnmanagedType.AsAny)] object ptr, int ofs, IntPtr val)
Writes a processor native sized integer value to unmanaged memory.
virtual RuntimeTypeHandle TypeHandle
Gets the handle for the current T:System.Type.
static unsafe IntPtr StringToHGlobalUni(string s)
Copies the contents of a managed T:System.String into unmanaged memory.
static int ReleaseComObject(object o)
Decrements the reference count of the Runtime Callable Wrapper (RCW) associated with the specified CO...
static bool AreComObjectsAvailableForCleanup()
Indicates whether runtime callable wrappers (RCWs) from any context are available for cleanup.
abstract Type DeclaringType
Gets the class that declares this member.
static void FreeHGlobal(IntPtr hglobal)
Frees memory previously allocated from the unmanaged memory of the process.
static void FreeCoTaskMem(IntPtr ptr)
Frees a block of memory allocated by the unmanaged COM task memory allocator.
void GetCustData(ref Guid guid, out object pVarVal)
Gets the custom data.
static int GetHRForException(Exception e)
Converts the specified exception to an HRESULT.
static int SizeOf< T >()
[Supported in the .NET Framework 4.5.1 and later versions] Returns the size of an unmanaged type in b...
static Assembly Load(string assemblyString)
Loads an assembly given the long form of its name.
Discovers the attributes of a method and provides access to method metadata.
The exception that is thrown when there is an attempt to read or write protected memory.
static IntPtr OffsetOf(Type t, string fieldName)
Returns the field offset of the unmanaged form of the managed class.
static string GetTypeLibName(UCOMITypeLib pTLB)
Retrieves the name of a type library.
abstract string FullName
Gets the fully qualified name of the type, including its namespace but not its assembly.
CustomQueryInterfaceMode
Indicates whether the M:System.Runtime.InteropServices.Marshal.GetComInterfaceForObject(System....
static Exception GetExceptionForHR(int errorCode, IntPtr errorInfo)
Converts the specified HRESULT error code to a corresponding T:System.Exception object,...
static IntPtr SecureStringToCoTaskMemUnicode(SecureString s)
Copies the contents of a managed T:System.Security.SecureString object to a block of memory allocated...
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
static void ChangeWrapperHandleStrength(object otp, bool fIsWeak)
Changes the strength of an object's COM Callable Wrapper (CCW) handle.
static Guid GetTypeLibGuid(UCOMITypeLib pTLB)
Retrieves the library identifier (LIBID) of a type library.
static void GetNativeVariantForObject< T >(T obj, IntPtr pDstNativeVariant)
[Supported in the .NET Framework 4.5.1 and later versions] Converts an object of a specified type to ...
static void WriteByte(IntPtr ptr, byte val)
Writes a single byte value to unmanaged memory.
static IntPtr SecureStringToGlobalAllocUnicode(SecureString s)
Copies the contents of a managed T:System.Security.SecureString object into unmanaged memory.
static void Copy(IntPtr source, long[] destination, int startIndex, int length)
Copies data from an unmanaged memory pointer to a managed 64-bit signed integer array.
bool IsImport
Gets a value indicating whether the T:System.Type has a T:System.Runtime.InteropServices....
static IntPtr GetComInterfaceForObject(object o, Type T, CustomQueryInterfaceMode mode)
Returns a pointer to an IUnknown interface that represents the specified interface on the specified o...
static int ReadInt32(IntPtr ptr)
Reads a 32-bit signed integer from unmanaged memory.
static IntPtr GetFunctionPointerForDelegate< TDelegate >(TDelegate d)
[Supported in the .NET Framework 4.5.1 and later versions] Converts a delegate of a specified type to...
bool IsInterface
Gets a value indicating whether the T:System.Type is an interface; that is, not a class or a value ty...
static void WriteInt16(IntPtr ptr, char val)
Writes a character as a 16-bit integer value to unmanaged memory.
static object GetActiveObject(string progID)
Obtains a running instance of the specified object from the running object table (ROT).
static int QueryInterface(IntPtr pUnk, ref Guid iid, out IntPtr ppv)
Requests a pointer to a specified interface from a COM object.
Represents a multicast delegate; that is, a delegate that can have more than one element in its invoc...
Discovers the attributes of a field and provides access to field metadata.
static unsafe string PtrToStringUni(IntPtr ptr)
Allocates a managed T:System.String and copies all characters up to the first null character from an ...
static int NumParamBytes(MethodInfo m)
Calculates the number of bytes in unmanaged memory that are required to hold the parameters for the s...
BindingFlags
Specifies flags that control binding and the way in which the search for members and types is conduct...
static Type GetTypeFromCLSID(Guid clsid)
Returns the type associated with the specified class identifier (CLSID).
static void Copy(IntPtr[] source, int startIndex, IntPtr destination, int length)
Copies data from a one-dimensional, managed T:System.IntPtr array to an unmanaged memory pointer.
static int Release(IntPtr pUnk)
Decrements the reference count on the specified interface.
The exception that is thrown when the value of an argument is outside the allowable range of values a...
Provides access to custom attribute data for assemblies, modules, types, members and parameters that ...
The exception that is thrown for invalid casting or explicit conversion.
unsafe long ToInt64()
Converts the value of this instance to a 64-bit signed integer.
static int SizeOf(object structure)
Returns the unmanaged size of an object in bytes.
static IntPtr CreateAggregatedObject(IntPtr pOuter, object o)
Aggregates a managed object with the specified COM object.
static string GetTypeLibName(ITypeLib typelib)
Retrieves the name of a type library.
static IntPtr GetFunctionPointerForDelegate(Delegate d)
Converts a delegate into a function pointer that is callable from unmanaged code.
static IntPtr ReadIntPtr(IntPtr ptr)
Reads a processor native-sized integer from unmanaged memory.
abstract Type UnderlyingSystemType
Indicates the type provided by the common language runtime that represents this type.
static string GenerateProgIdForType(Type type)
Returns a programmatic identifier (ProgID) for the specified type.
AssemblyNameFlags
Provides information about an T:System.Reflection.Assembly reference.
static void CleanupUnusedObjectsInCurrentContext()
Notifies the runtime to clean up all Runtime Callable Wrappers (RCWs) allocated in the current contex...
static int GetHRForLastWin32Error()
Returns the HRESULT corresponding to the last error incurred by Win32 code executed using T:System....
virtual bool IsGenericType
Gets a value indicating whether the current type is a generic type.
static IList< CustomAttributeData > GetCustomAttributes(MemberInfo target)
Returns a list of T:System.Reflection.CustomAttributeData objects representing data about the attribu...
static void ZeroFreeCoTaskMemAnsi(IntPtr s)
Frees an unmanaged string pointer that was allocated using the M:System.Runtime.InteropServices....
AssemblyBuilder ConvertTypeLibToAssembly([MarshalAs(UnmanagedType.Interface)] object typeLib, string asmFileName, int flags, ITypeLibImporterNotifySink notifySink, byte[] publicKey, StrongNameKeyPair keyPair, bool unsafeInterfaces)
Converts a COM type library to an assembly.
static IntPtr GetExceptionPointers()
Retrieves a computer-independent description of an exception, and information about the state that ex...
static void WriteInt16(IntPtr ptr, short val)
Writes a 16-bit integer value to unmanaged memory.
static void Copy(IntPtr source, char[] destination, int startIndex, int length)
Copies data from an unmanaged memory pointer to a managed character array.
static void ZeroFreeGlobalAllocAnsi(IntPtr s)
Frees an unmanaged string pointer that was allocated using the M:System.Runtime.InteropServices....
The exception that is thrown when an unrecognized HRESULT is returned from a COM method call.
static Type GetTypeForITypeInfo(IntPtr piTypeInfo)
Converts an unmanaged ITypeInfo object into a managed T:System.Type object.
static int AddRef(IntPtr pUnk)
Increments the reference count on the specified interface.
static byte ReadByte([In] [MarshalAs(UnmanagedType.AsAny)] object ptr, int ofs)
Reads a single byte at a given offset (or index) from unmanaged memory.
static object PtrToStructure(IntPtr ptr, Type structureType)
Marshals data from an unmanaged block of memory to a newly allocated managed object of the specified ...
static void ZeroFreeBSTR(IntPtr s)
Frees a BSTR pointer that was allocated using the M:System.Runtime.InteropServices....
static IntPtr GetComInterfaceForObjectInContext(object o, Type t)
Returns an interface pointer that represents the specified interface for an object,...
IntPtr Value
Gets a handle to the type represented by this instance.
Use T:System.Runtime.InteropServices.ComTypes.ITypeInfo instead.
static IntPtr ReadIntPtr(IntPtr ptr, int ofs)
Reads a processor native sized integer at a given offset from unmanaged memory.
static unsafe int ReadInt32(IntPtr ptr, int ofs)
Reads a 32-bit signed integer at a given offset from unmanaged memory.
static IntPtr GetITypeInfoForType(Type t)
Returns a T:System.Runtime.InteropServices.ComTypes.ITypeInfo interface from a managed type.
static void Copy(IntPtr source, byte[] destination, int startIndex, int length)
Copies data from an unmanaged memory pointer to a managed 8-bit unsigned integer array.
static long ReadInt64([In] [MarshalAs(UnmanagedType.AsAny)] object ptr, int ofs)
Reads a 64-bit signed integer at a given offset from unmanaged memory.
static string GetTypeInfoName(ITypeInfo typeInfo)
Retrieves the name of the type represented by an ITypeInfo object.
static unsafe void WriteInt16(IntPtr ptr, int ofs, short val)
Writes a 16-bit signed integer value into unmanaged memory at a specified offset.
static bool SetComObjectData(object obj, object key, object data)
Sets data referenced by the specified key in the specified COM object.
Cer
Specifies a method's behavior when called within a constrained execution region.
static IntPtr StringToBSTR(string s)
Allocates a BSTR and copies the contents of a managed T:System.String into it.
static void WriteInt64(IntPtr ptr, long val)
Writes a 64-bit signed integer value to unmanaged memory.
static IntPtr SecureStringToCoTaskMemAnsi(SecureString s)
Copies the contents of a managed T:System.Security.SecureString object to a block of memory allocated...
static object GetObjectForNativeVariant(IntPtr pSrcNativeVariant)
Converts a COM VARIANT to an object.
static MemberInfo GetMethodInfoForComSlot(Type t, int slot, ref ComMemberType memberType)
Retrieves a T:System.Reflection.MemberInfo object for the specified virtual function table (v-table o...
static void Copy(IntPtr source, double[] destination, int startIndex, int length)
Copies data from an unmanaged memory pointer to a managed double-precision floating-point number arra...
static void ThrowExceptionForHR(int errorCode, IntPtr errorInfo)
Throws an exception with a specific failure HRESULT, based on the specified IErrorInfo interface.
Attribute can be applied to a constructor.
Provides information about, and means to manipulate, the current environment and platform....
static IntPtr SecureStringToGlobalAllocAnsi(SecureString s)
Copies the contents of a managed T:System.Security.SecureString into unmanaged memory,...
Represents a globally unique identifier (GUID).To browse the .NET Framework source code for this type...
void GetDocumentation(int index, out string strName, out string strDocString, out int dwHelpContext, out string strHelpFile)
Retrieves the documentation string, the complete Help file name and path, and the context ID for the ...
static Guid GetTypeLibGuidForAssembly(Assembly asm)
Retrieves the library identifier (LIBID) that is assigned to a type library when it was exported from...
static IntPtr AllocCoTaskMem(int cb)
Allocates a block of memory of specified size from the COM task memory allocator.
MethodInfo [] GetMethods()
Returns all the public methods of the current T:System.Type.
static unsafe void WriteInt32(IntPtr ptr, int ofs, int val)
Writes a 32-bit signed integer value into unmanaged memory at a specified offset.
Provides a set of services for registering and unregistering managed assemblies for use from COM.
static void Copy(int[] source, int startIndex, IntPtr destination, int length)
Copies data from a one-dimensional, managed 32-bit signed integer array to an unmanaged memory pointe...
static object CreateWrapperOfType(object o, Type t)
Wraps the specified COM object in an object of the specified type.
static bool IsTypeVisibleFromCom(Type t)
Indicates whether a type is visible to COM clients.
static int SizeOf(Type t)
Returns the size of an unmanaged type in bytes.
static T GetObjectForNativeVariant< T >(IntPtr pSrcNativeVariant)
[Supported in the .NET Framework 4.5.1 and later versions] Converts a COM VARIANT to an object of a s...
static object GetComObjectData(object obj, object key)
Retrieves data that is referenced by the specified key from the specified COM object.
static int GetEndComSlot(Type t)
Retrieves the last slot in the virtual function table (v-table or VTBL) of a type when exposed to COM...
static int GetExceptionCode()
Retrieves a code that identifies the type of the exception that occurred.
static IntPtr StringToCoTaskMemAuto(string s)
Copies the contents of a managed T:System.String to a block of memory allocated from the unmanaged CO...
UnmanagedType
Identifies how to marshal parameters or fields to unmanaged code.
static object [] GetObjectsForNativeVariants(IntPtr aSrcNativeVariant, int cVars)
Converts an array of COM VARIANTs to an array of objects.
static void ZeroFreeGlobalAllocUnicode(IntPtr s)
Frees an unmanaged string pointer that was allocated using the M:System.Runtime.InteropServices....
static unsafe IntPtr StringToCoTaskMemAnsi(string s)
Copies the contents of a managed T:System.String to a block of memory allocated from the unmanaged CO...
static IntPtr AllocHGlobal(int cb)
Allocates memory from the unmanaged memory of the process by using the specified number of bytes.
static int GetComSlotForMethodInfo(MemberInfo m)
Retrieves the virtual function table (v-table or VTBL) slot for a specified T:System....
static void WriteInt32(IntPtr ptr, int val)
Writes a 32-bit signed integer value to unmanaged memory.
Defines and represents a module in a dynamic assembly.
static void StructureToPtr(object structure, IntPtr ptr, bool fDeleteOld)
Marshals data from a managed object to an unmanaged block of memory.
static Delegate GetDelegateForFunctionPointer(IntPtr ptr, Type t)
Converts an unmanaged function pointer to a delegate.
static void ThrowExceptionForHR(int errorCode)
Throws an exception with a specific failure HRESULT value.
static void Copy(IntPtr source, IntPtr[] destination, int startIndex, int length)
Copies data from an unmanaged memory pointer to a managed T:System.IntPtr array.
static Guid GenerateGuidForType(Type type)
Returns the globally unique identifier (GUID) for the specified type, or generates a GUID using the a...
static IntPtr GetManagedThunkForUnmanagedMethodPtr(IntPtr pfnMethodToWrap, IntPtr pbSignature, int cbSignature)
Gets a pointer to a runtime-generated function that marshals a call from managed to unmanaged code.
static IntPtr GetIDispatchForObjectInContext(object o)
Returns an IDispatch interface pointer from a managed object, if the caller is in the same context as...
static IntPtr ReAllocCoTaskMem(IntPtr pv, int cb)
Resizes a block of memory previously allocated with M:System.Runtime.InteropServices....
Represents text that should be kept confidential, such as by deleting it from computer memory when no...
static TDelegate GetDelegateForFunctionPointer< TDelegate >(IntPtr ptr)
[Supported in the .NET Framework 4.5.1 and later versions] Converts an unmanaged function pointer to ...
static object GetTypedObjectForIUnknown(IntPtr pUnk, Type t)
Returns a managed object of a specified type that represents a COM object.
Represents an assembly, which is a reusable, versionable, and self-describing building block of a com...
A platform-specific type that is used to represent a pointer or a handle.
static string PtrToStringAuto(IntPtr ptr, int len)
Allocates a managed T:System.String and copies the specified number of characters from a string store...
static void Copy(float[] source, int startIndex, IntPtr destination, int length)
Copies data from a one-dimensional, managed single-precision floating-point number array to an unmana...
void GetCustData(ref Guid guid, out object pVarVal)
Gets the custom data.
static void DestroyStructure(IntPtr ptr, Type structuretype)
Frees all substructures that the specified unmanaged memory block points to.
static Guid GetTypeLibGuid(ITypeLib typelib)
Retrieves the library identifier (LIBID) of a type library.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Represents a delegate, which is a data structure that refers to a static method or to a class instanc...
The exception that is thrown when there is not enough memory to continue the execution of a program.
Represents type declarations: class types, interface types, array types, value types,...
static IntPtr GetComInterfaceForObject< T, TInterface >(T o)
[Supported in the .NET Framework 4.5.1 and later versions] Returns a pointer to an IUnknown interface...
Provides a collection of methods for allocating unmanaged memory, copying unmanaged memory blocks,...
static int FinalReleaseComObject(object o)
Releases all references to a Runtime Callable Wrapper (RCW) by setting its reference count to 0.
Assembly [] GetAssemblies()
Gets the assemblies that have been loaded into the execution context of this application domain.
static unsafe long ReadInt64(IntPtr ptr, int ofs)
Reads a 64-bit signed integer at a given offset from unmanaged memory.
static void Copy(IntPtr source, float[] destination, int startIndex, int length)
Copies data from an unmanaged memory pointer to a managed single-precision floating-point number arra...
bool IsCOMObject
Gets a value indicating whether the T:System.Type is a COM object.
Provides the managed definition of the IBindCtx interface.
MethodImplOptions
Defines the details of how a method is implemented.
static IntPtr SecureStringToBSTR(SecureString s)
Allocates an unmanaged binary string (BSTR) and copies the contents of a managed T:System....
static AppDomain GetDomain()
Returns the current domain in which the current thread is running.
static byte ReadByte(IntPtr ptr)
Reads a single byte from unmanaged memory.
static void WriteInt16([In] [Out] object ptr, int ofs, char val)
Writes a 16-bit signed integer value to unmanaged memory at a specified offset.
Provides the managed definition of the IMoniker interface, with COM functionality from IPersist and I...
CharSet
Dictates which character set marshaled strings should use.
static void FreeBSTR(IntPtr ptr)
Frees a BSTR using the COM SysFreeString function.
static void Prelink(MethodInfo m)
Executes one-time method setup tasks without calling the method.
static unsafe IntPtr StringToCoTaskMemUni(string s)
Copies the contents of a managed T:System.String to a block of memory allocated from the unmanaged CO...
static void Copy(IntPtr source, int[] destination, int startIndex, int length)
Copies data from an unmanaged memory pointer to a managed 32-bit signed integer array.
Describes an assembly's unique identity in full.
static void Copy(long[] source, int startIndex, IntPtr destination, int length)
Copies data from a one-dimensional, managed 64-bit signed integer array to an unmanaged memory pointe...
static int GetTypeLibLcid(UCOMITypeLib pTLB)
Retrieves the LCID of a type library.
Represents a collection of objects that can be individually accessed by index.
static string PtrToStringAuto(IntPtr ptr)
Allocates a managed T:System.String and copies all characters up to the first null character from a s...
The exception that is thrown when one of the arguments provided to a method is not valid.
static void Copy(short[] source, int startIndex, IntPtr destination, int length)
Copies data from a one-dimensional, managed 16-bit signed integer array to an unmanaged memory pointe...
static readonly int SystemDefaultCharSize
Represents the default character size on the system; the default is 2 for Unicode systems and 1 for A...
static int Size
Gets the size of this instance.
static void StructureToPtr< T >(T structure, IntPtr ptr, bool fDeleteOld)
[Supported in the .NET Framework 4.5.1 and later versions] Marshals data from a managed object of a s...
static void Copy(Array sourceArray, Array destinationArray, int length)
Copies a range of elements from an T:System.Array starting at the first element and pastes them into ...
int Count
Gets the number of elements contained in the T:System.Collections.Generic.ICollection`1.
void GetDocumentation(int index, out string strName, out string strDocString, out int dwHelpContext, out string strHelpFile)
Retrieves the library's documentation string, the complete Help file name and path,...
static unsafe string PtrToStringUni(IntPtr ptr, int len)
Allocates a managed T:System.String and copies a specified number of characters from an unmanaged Uni...
static Exception GetExceptionForHR(int errorCode)
Converts the specified HRESULT error code to a corresponding T:System.Exception object.
static unsafe IntPtr StringToHGlobalAnsi(string s)
Copies the contents of a managed T:System.String into unmanaged memory, converting into ANSI format a...
static void ZeroFreeCoTaskMemUnicode(IntPtr s)
Frees an unmanaged string pointer that was allocated using the M:System.Runtime.InteropServices....
static void PtrToStructure(IntPtr ptr, object structure)
Marshals data from an unmanaged block of memory to a managed object.
static TWrapper CreateWrapperOfType< T, TWrapper >(T o)
[Supported in the .NET Framework 4.5.1 and later versions] Wraps the specified COM object in an objec...
static IntPtr CreateAggregatedObject< T >(IntPtr pOuter, T o)
[Supported in the .NET Framework 4.5.1 and later versions] Aggregates a managed object of the specifi...
Represents errors that occur during application execution.To browse the .NET Framework source code fo...
void GetContainingTypeLib(out ITypeLib ppTLB, out int pIndex)
Retrieves the type library that contains this type description and its index within that type library...
TypeLibImporterFlags
Indicates how an assembly should be produced.
ComMemberType
Describes the type of a COM member.
static readonly IntPtr Zero
A read-only field that represents a pointer or handle that has been initialized to zero.
static unsafe string PtrToStringAnsi(IntPtr ptr, int len)
Allocates a managed T:System.String, copies a specified number of characters from an unmanaged ANSI s...
static short ReadInt16([In] [MarshalAs(UnmanagedType.AsAny)] object ptr, int ofs)
Reads a 16-bit signed integer at a given offset from unmanaged memory.
static IntPtr OffsetOf< T >(string fieldName)
[Supported in the .NET Framework 4.5.1 and later versions] Returns the field offset of the unmanaged ...
static void Copy(IntPtr source, short[] destination, int startIndex, int length)
Copies data from an unmanaged memory pointer to a managed 16-bit signed integer array.
Use T:System.Runtime.InteropServices.ComTypes.ITypeLib instead.
static string PtrToStringBSTR(IntPtr ptr)
Allocates a managed T:System.String and copies a binary string (BSTR) stored in unmanaged memory into...
Provides the managed definition of the ITypeInfo2 interface.
static void Copy(char[] source, int startIndex, IntPtr destination, int length)
Copies data from a one-dimensional, managed character array to an unmanaged memory pointer.
static IntPtr StringToHGlobalAuto(string s)
Copies the contents of a managed T:System.String into unmanaged memory, converting into ANSI format i...
static IntPtr AllocHGlobal(IntPtr cb)
Allocates memory from the unmanaged memory of the process by using the pointer to the specified numbe...
static void GetNativeVariantForObject(object obj, IntPtr pDstNativeVariant)
Converts an object to a COM VARIANT.
static IntPtr GetIDispatchForObject(object o)
Returns an IDispatch interface from a managed object.
static void WriteInt16(IntPtr ptr, int ofs, char val)
Writes a 16-bit signed integer value to unmanaged memory at a specified offset.
Consistency
Specifies a reliability contract.
static IntPtr GetComInterfaceForObject(object o, Type T)
Returns a pointer to an IUnknown interface that represents the specified interface on the specified o...
static IntPtr GetIUnknownForObject(object o)
Returns an IUnknown interface from a managed object.
Provides a set of services that convert a managed assembly to a COM type library and vice versa.
static void Copy(byte[] source, int startIndex, IntPtr destination, int length)
Copies data from a one-dimensional, managed 8-bit unsigned integer array to an unmanaged memory point...
static Thread GetThreadFromFiberCookie(int cookie)
Converts a fiber cookie into the corresponding T:System.Threading.Thread instance.
static void PtrToStructure< T >(IntPtr ptr, T structure)
[Supported in the .NET Framework 4.5.1 and later versions] Marshals data from an unmanaged block of m...
Provides a managed definition of the ITypeLib2 interface.
Allows the user to specify the ProgID of a class.
static int GetLastWin32Error()
Returns the error code returned by the last unmanaged function that was called using platform invoke ...
static unsafe string PtrToStringAnsi(IntPtr ptr)
Copies all characters up to the first null character from an unmanaged ANSI string to a managed T:Sys...
static void WriteIntPtr(IntPtr ptr, int ofs, IntPtr val)
Writes a processor native-sized integer value to unmanaged memory at a specified offset.
static int GetStartComSlot(Type t)
Gets the first slot in the virtual function table (v-table or VTBL) that contains user-defined method...
static IntPtr UnsafeAddrOfPinnedArrayElement< T >(T[] arr, int index)
[Supported in the .NET Framework 4.5.1 and later versions] Gets the address of the element at the spe...
static void DestroyStructure< T >(IntPtr ptr)
[Supported in the .NET Framework 4.5.1 and later versions] Frees all substructures of a specified typ...
static void WriteIntPtr(IntPtr ptr, IntPtr val)
Writes a processor native sized integer value into unmanaged memory.
static void GetTypeLibVersionForAssembly(Assembly inputAssembly, out int majorVersion, out int minorVersion)
Retrieves the version number of a type library that will be exported from the specified assembly.
static IntPtr UnsafeAddrOfPinnedArrayElement(Array arr, int index)
Gets the address of the element at the specified index inside the specified array.
Provides the managed definition of the ITypeLib interface.
static IntPtr GetUnmanagedThunkForManagedMethodPtr(IntPtr pfnMethodToWrap, IntPtr pbSignature, int cbSignature)
Gets a pointer to a runtime-generated function that marshals a call from unmanaged to managed code.
static unsafe short ReadInt16(IntPtr ptr, int ofs)
Reads a 16-bit signed integer at a given offset from unmanaged memory.
static object GetObjectForIUnknown(IntPtr pUnk)
Returns an instance of a type that represents a COM object by a pointer to its IUnknown interface.
static object BindToMoniker(string monikerName)
Gets an interface pointer identified by the specified moniker.
static IntPtr GetIUnknownForObjectInContext(object o)
Returns an IUnknown interface from a managed object, if the caller is in the same context as that obj...
string FullName
Gets the full name of the assembly, also known as the display name.
static short ReadInt16(IntPtr ptr)
Reads a 16-bit signed integer from unmanaged memory.
static object GetUniqueObjectForIUnknown(IntPtr unknown)
Creates a unique Runtime Callable Wrapper (RCW) object for a given IUnknown interface.
static void Copy(double[] source, int startIndex, IntPtr destination, int length)
Copies data from a one-dimensional, managed double-precision floating-point number array to an unmana...
static IntPtr ReadIntPtr([In] [MarshalAs(UnmanagedType.AsAny)] object ptr, int ofs)
Reads a processor native sized integer from unmanaged memory.
static unsafe byte ReadByte(IntPtr ptr, int ofs)
Reads a single byte at a given offset (or index) from unmanaged memory.
Creates and controls a thread, sets its priority, and gets its status.