1 // System.Runtime.InteropServices.Marshal.cs
3 // Sean MacIsaac (macisaac@ximian.com)
4 // Paolo Molaro (lupus@ximian.com)
5 // Dietmar Maurer (dietmar@ximian.com)
6 // Jonathan Chambers (joncham@gmail.com)
8 // (C) 2001-2002 Ximian, Inc.
11 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System.Runtime.CompilerServices;
36 using System.Security;
37 using System.Reflection;
38 using System.Threading;
41 using System.Runtime.ConstrainedExecution;
42 using System.Runtime.InteropServices.ComTypes;
45 namespace System.Runtime.InteropServices
47 [SuppressUnmanagedCodeSecurity ()]
57 public static readonly int SystemMaxDBCSCharSize = 2; // don't know what this is
58 public static readonly int SystemDefaultCharSize;
62 SystemDefaultCharSize = Environment.OSVersion.Platform == PlatformID.Win32NT ? 2 : 1;
69 [MethodImplAttribute (MethodImplOptions.InternalCall)]
70 public extern static int AddRef (IntPtr pUnk);
72 [MethodImplAttribute(MethodImplOptions.InternalCall)]
73 public extern static IntPtr AllocCoTaskMem (int cb);
75 [MethodImplAttribute(MethodImplOptions.InternalCall)]
77 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.MayFail)]
79 public extern static IntPtr AllocHGlobal (IntPtr cb);
82 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.MayFail)]
84 public static IntPtr AllocHGlobal (int cb) {
85 return AllocHGlobal ((IntPtr)cb);
89 public static object BindToMoniker (string monikerName) {
90 throw new NotImplementedException ();
94 public static void ChangeWrapperHandleStrength (object otp, bool fIsWeak) {
95 throw new NotImplementedException ();
98 [MethodImplAttribute(MethodImplOptions.InternalCall)]
99 extern static void copy_to_unmanaged (Array source, int startIndex,
100 IntPtr destination, int length);
102 [MethodImplAttribute(MethodImplOptions.InternalCall)]
103 extern static void copy_from_unmanaged (IntPtr source, int startIndex,
104 Array destination, int length);
106 public static void Copy (byte[] source, int startIndex, IntPtr destination, int length) {
107 copy_to_unmanaged (source, startIndex, destination, length);
110 public static void Copy (char[] source, int startIndex, IntPtr destination, int length) {
111 copy_to_unmanaged (source, startIndex, destination, length);
114 public static void Copy (short[] source, int startIndex, IntPtr destination, int length) {
115 copy_to_unmanaged (source, startIndex, destination, length);
118 public static void Copy (int[] source, int startIndex, IntPtr destination, int length) {
119 copy_to_unmanaged (source, startIndex, destination, length);
122 public static void Copy (long[] source, int startIndex, IntPtr destination, int length) {
123 copy_to_unmanaged (source, startIndex, destination, length);
126 public static void Copy (float[] source, int startIndex, IntPtr destination, int length) {
127 copy_to_unmanaged (source, startIndex, destination, length);
130 public static void Copy (double[] source, int startIndex, IntPtr destination, int length) {
131 copy_to_unmanaged (source, startIndex, destination, length);
134 public static void Copy (IntPtr source, byte[] destination, int startIndex, int length) {
135 copy_from_unmanaged (source, startIndex, destination, length);
138 public static void Copy (IntPtr source, char[] destination, int startIndex, int length) {
139 copy_from_unmanaged (source, startIndex, destination, length);
142 public static void Copy (IntPtr source, short[] destination, int startIndex, int length) {
143 copy_from_unmanaged (source, startIndex, destination, length);
146 public static void Copy (IntPtr source, int[] destination, int startIndex, int length) {
147 copy_from_unmanaged (source, startIndex, destination, length);
150 public static void Copy (IntPtr source, long[] destination, int startIndex, int length) {
151 copy_from_unmanaged (source, startIndex, destination, length);
154 public static void Copy (IntPtr source, float[] destination, int startIndex, int length) {
155 copy_from_unmanaged (source, startIndex, destination, length);
158 public static void Copy (IntPtr source, double[] destination, int startIndex, int length) {
159 copy_from_unmanaged (source, startIndex, destination, length);
162 public static object CreateWrapperOfType (object o, Type t) {
163 __ComObject co = o as __ComObject;
165 throw new ArgumentException ("o must derive from __ComObject", "o");
167 throw new ArgumentNullException ("t");
169 Type[] itfs = o.GetType ().GetInterfaces ();
170 foreach (Type itf in itfs) {
171 if (itf.IsImport && co.GetInterface (itf) == IntPtr.Zero)
172 throw new InvalidCastException ();
175 return ComInteropProxy.GetProxy (co.IUnknown, t).GetTransparentProxy ();
178 [MethodImplAttribute(MethodImplOptions.InternalCall)]
179 public extern static void DestroyStructure (IntPtr ptr, Type structuretype);
181 [MethodImplAttribute(MethodImplOptions.InternalCall)]
182 public extern static void FreeBSTR (IntPtr ptr);
184 [MethodImplAttribute(MethodImplOptions.InternalCall)]
185 public extern static void FreeCoTaskMem (IntPtr ptr);
187 [MethodImplAttribute(MethodImplOptions.InternalCall)]
189 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
191 public extern static void FreeHGlobal (IntPtr hglobal);
195 public static void ZeroFreeBSTR (IntPtr ptr)
197 throw new NotImplementedException ();
201 public static void ZeroFreeCoTaskMemAnsi (IntPtr ptr)
203 throw new NotImplementedException ();
207 public static void ZeroFreeCoTaskMemUnicode (IntPtr ptr)
209 throw new NotImplementedException ();
213 public static void ZeroFreeGlobalAllocAnsi (IntPtr hglobal)
215 throw new NotImplementedException ();
219 public static void ZeroFreeGlobalAllocUnicode (IntPtr hglobal)
221 throw new NotImplementedException ();
226 public static Guid GenerateGuidForType (Type type) {
227 throw new NotImplementedException ();
231 public static string GenerateProgIdForType (Type type) {
232 throw new NotImplementedException ();
236 public static object GetActiveObject (string progID) {
237 throw new NotImplementedException ();
241 public static IntPtr GetComInterfaceForObject (object o, Type T) {
242 __ComObject co = o as __ComObject;
244 throw new NotSupportedException ("Only RCWs are currently supported");
246 IntPtr pUnk = co.GetInterface (T);
253 public static IntPtr GetComInterfaceForObjectInContext (object o, Type t) {
254 throw new NotImplementedException ();
258 public static object GetComObjectData (object obj, object key) {
260 throw new ArgumentNullException ("obj");
262 throw new ArgumentNullException ("key");
264 __ComObject com_object = obj as __ComObject;
265 if (com_object == null)
266 throw new ArgumentException ("obj is not a COM object", "obj");
268 return com_object.Hashtable[key];
271 [MethodImplAttribute(MethodImplOptions.InternalCall)]
272 private extern static int GetComSlotForMethodInfoInternal (MemberInfo m);
274 public static int GetComSlotForMethodInfo (MemberInfo m)
277 throw new ArgumentNullException("m", "Value cannot be null.");
278 if (!(m is MethodInfo))
279 throw new ArgumentException("m", "The MemberInfo must be an interface method.");
280 if (!m.DeclaringType.IsInterface)
281 throw new ArgumentException("m", "The MemberInfo must be an interface method.");
282 return GetComSlotForMethodInfoInternal (m);
286 public static int GetEndComSlot (Type t) {
287 throw new NotImplementedException ();
291 public static int GetExceptionCode() {
292 throw new NotImplementedException ();
296 public static IntPtr GetExceptionPointers() {
297 throw new NotImplementedException ();
301 public static IntPtr GetHINSTANCE (Module m) {
302 throw new NotImplementedException ();
305 [MonoTODO ("SetErrorInfo")]
306 public static int GetHRForException (Exception e) {
311 public static int GetHRForLastWin32Error() {
312 throw new NotImplementedException ();
316 public static IntPtr GetIDispatchForObject (object o)
317 { // only handle case of RCW objects for now
318 __ComObject co = o as __ComObject;
320 IntPtr pUnk = co.IDispatch;
324 throw new NotImplementedException ();
329 public static IntPtr GetIDispatchForObjectInContext (object o) {
330 throw new NotImplementedException ();
335 public static IntPtr GetITypeInfoForType (Type t) {
336 throw new NotImplementedException ();
340 public static IntPtr GetIUnknownForObject (object o) {
341 // only handle case of RCW objects for now
342 __ComObject co = o as __ComObject;
344 IntPtr pUnk = co.IUnknown;
348 throw new NotImplementedException ();
353 public static IntPtr GetIUnknownForObjectInContext (object o) {
354 throw new NotImplementedException ();
358 [MethodImplAttribute(MethodImplOptions.InternalCall)]
360 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
362 public static extern int GetLastWin32Error();
365 public static IntPtr GetManagedThunkForUnmanagedMethodPtr (IntPtr pfnMethodToWrap, IntPtr pbSignature, int cbSignature) {
366 throw new NotImplementedException ();
370 public static MemberInfo GetMethodInfoForComSlot (Type t, int slot, ref ComMemberType memberType) {
371 throw new NotImplementedException ();
374 public static void GetNativeVariantForObject (object obj, IntPtr pDstNativeVariant) {
375 Variant vt = new Variant();
377 Marshal.StructureToPtr(vt, pDstNativeVariant, false);
380 public static object GetObjectForIUnknown (IntPtr pUnk) {
381 ComInteropProxy proxy = ComInteropProxy.GetProxy (pUnk, typeof(__ComObject));
382 return proxy.GetTransparentProxy ();
385 public static object GetObjectForNativeVariant (IntPtr pSrcNativeVariant) {
386 Variant vt = (Variant)Marshal.PtrToStructure(pSrcNativeVariant, typeof(Variant));
387 return vt.GetValue();
391 public static object[] GetObjectsForNativeVariants (IntPtr aSrcNativeVariant, int cVars) {
392 throw new NotImplementedException ();
396 public static int GetStartComSlot (Type t) {
397 throw new NotImplementedException ();
401 public static Thread GetThreadFromFiberCookie (int cookie) {
402 throw new NotImplementedException ();
405 public static object GetTypedObjectForIUnknown (IntPtr pUnk, Type t)
407 ComInteropProxy proxy = new ComInteropProxy (pUnk, t);
408 __ComObject co = (__ComObject)proxy.GetTransparentProxy ();
409 foreach (Type itf in t.GetInterfaces ()) {
410 if ((itf.Attributes & TypeAttributes.Import) == TypeAttributes.Import) {
411 if (co.GetInterface (itf) == IntPtr.Zero)
419 public static Type GetTypeForITypeInfo (IntPtr piTypeInfo) {
420 throw new NotImplementedException ();
427 public static string GetTypeInfoName (UCOMITypeInfo pTI) {
428 throw new NotImplementedException ();
435 public static Guid GetTypeLibGuid (UCOMITypeLib pTLB) {
436 throw new NotImplementedException ();
441 public static Guid GetTypeLibGuid (ITypeLib typelib) {
442 throw new NotImplementedException ();
447 public static Guid GetTypeLibGuidForAssembly (Assembly asm) {
448 throw new NotImplementedException ();
455 public static int GetTypeLibLcid (UCOMITypeLib pTLB) {
456 throw new NotImplementedException ();
461 public static int GetTypeLibLcid (ITypeLib typelib) {
462 throw new NotImplementedException ();
470 public static string GetTypeLibName (UCOMITypeLib pTLB) {
471 throw new NotImplementedException ();
476 public static string GetTypeLibName (ITypeLib typelib)
478 throw new NotImplementedException ();
482 public static void GetTypeLibVersionForAssembly (Assembly inputAssembly, out int majorVersion, out int minorVersion) {
483 throw new NotImplementedException ();
488 public static IntPtr GetUnmanagedThunkForManagedMethodPtr (IntPtr pfnMethodToWrap, IntPtr pbSignature, int cbSignature) {
489 throw new NotImplementedException ();
492 public static bool IsComObject (object o) {
493 Type t = o.GetType ();
494 object[] attrs = t.GetCustomAttributes (typeof (ComImportAttribute), true);
495 return (attrs != null && attrs.Length > 0);
499 public static bool IsTypeVisibleFromCom (Type t) {
500 throw new NotImplementedException ();
504 public static int NumParamBytes (MethodInfo m) {
505 throw new NotImplementedException ();
508 [MethodImplAttribute(MethodImplOptions.InternalCall)]
509 public extern static IntPtr OffsetOf (Type t, string fieldName);
511 [MethodImplAttribute(MethodImplOptions.InternalCall)]
512 public extern static void Prelink (MethodInfo m);
514 [MethodImplAttribute(MethodImplOptions.InternalCall)]
515 public extern static void PrelinkAll (Type c);
517 [MethodImplAttribute(MethodImplOptions.InternalCall)]
518 public extern static string PtrToStringAnsi (IntPtr ptr);
520 [MethodImplAttribute(MethodImplOptions.InternalCall)]
521 public extern static string PtrToStringAnsi (IntPtr ptr, int len);
523 public static string PtrToStringAuto (IntPtr ptr)
525 return SystemDefaultCharSize == 2
526 ? PtrToStringUni (ptr) : PtrToStringAnsi (ptr);
529 public static string PtrToStringAuto (IntPtr ptr, int len)
531 return SystemDefaultCharSize == 2
532 ? PtrToStringUni (ptr, len) : PtrToStringAnsi (ptr, len);
535 [MethodImplAttribute(MethodImplOptions.InternalCall)]
536 public extern static string PtrToStringUni (IntPtr ptr);
538 [MethodImplAttribute(MethodImplOptions.InternalCall)]
539 public extern static string PtrToStringUni (IntPtr ptr, int len);
541 [MethodImplAttribute(MethodImplOptions.InternalCall)]
542 public extern static string PtrToStringBSTR (IntPtr ptr);
544 [MethodImplAttribute(MethodImplOptions.InternalCall)]
545 public extern static void PtrToStructure (IntPtr ptr, object structure);
547 [MethodImplAttribute(MethodImplOptions.InternalCall)]
548 public extern static object PtrToStructure (IntPtr ptr, Type structureType);
550 [MethodImplAttribute (MethodImplOptions.InternalCall)]
551 public extern static int QueryInterface (IntPtr pUnk, ref Guid iid, out IntPtr ppv);
553 public static byte ReadByte (IntPtr ptr) {
554 return ReadByte (ptr, 0);
557 [MethodImplAttribute(MethodImplOptions.InternalCall)]
558 public extern static byte ReadByte (IntPtr ptr, int ofs);
561 public static byte ReadByte ([In, MarshalAs (UnmanagedType.AsAny)] object ptr, int ofs) {
562 throw new NotImplementedException ();
565 public static short ReadInt16 (IntPtr ptr) {
566 return ReadInt16 (ptr, 0);
569 [MethodImplAttribute(MethodImplOptions.InternalCall)]
570 public extern static short ReadInt16 (IntPtr ptr, int ofs);
573 public static short ReadInt16 ([In, MarshalAs(UnmanagedType.AsAny)] object ptr, int ofs) {
574 throw new NotImplementedException ();
578 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
580 public static int ReadInt32 (IntPtr ptr) {
581 return ReadInt32 (ptr, 0);
585 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
587 [MethodImplAttribute(MethodImplOptions.InternalCall)]
588 public extern static int ReadInt32 (IntPtr ptr, int ofs);
591 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
594 public static int ReadInt32 ([In, MarshalAs(UnmanagedType.AsAny)] object ptr, int ofs) {
595 throw new NotImplementedException ();
599 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
601 public static long ReadInt64 (IntPtr ptr) {
602 return ReadInt64 (ptr, 0);
606 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
608 [MethodImplAttribute(MethodImplOptions.InternalCall)]
609 public extern static long ReadInt64 (IntPtr ptr, int ofs);
612 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
615 public static long ReadInt64 ([In, MarshalAs (UnmanagedType.AsAny)] object ptr, int ofs) {
616 throw new NotImplementedException ();
620 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
622 public static IntPtr ReadIntPtr (IntPtr ptr) {
623 return ReadIntPtr (ptr, 0);
627 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
629 [MethodImplAttribute(MethodImplOptions.InternalCall)]
630 public extern static IntPtr ReadIntPtr (IntPtr ptr, int ofs);
633 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
636 public static IntPtr ReadIntPtr ([In, MarshalAs (UnmanagedType.AsAny)] object ptr, int ofs) {
637 throw new NotImplementedException ();
641 public static IntPtr ReAllocCoTaskMem (IntPtr pv, int cb) {
642 throw new NotImplementedException ();
645 [MethodImplAttribute(MethodImplOptions.InternalCall)]
646 public extern static IntPtr ReAllocHGlobal (IntPtr pv, IntPtr cb);
649 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
651 [MethodImplAttribute (MethodImplOptions.InternalCall)]
652 public extern static int Release (IntPtr pUnk);
654 public static int ReleaseComObject (object o) {
656 throw new ArgumentException ("o");
657 __ComObject co = o as __ComObject;
659 throw new ArgumentException ("o");
660 return ComInteropProxy.ReleaseComObject (co);
667 public static void ReleaseThreadCache() {
668 throw new NotImplementedException ();
671 public static bool SetComObjectData (object obj, object key, object data) {
673 throw new ArgumentNullException ("obj");
675 throw new ArgumentNullException ("key");
677 __ComObject com_object = obj as __ComObject;
678 if (com_object == null)
679 throw new ArgumentException ("obj is not a COM object", "obj");
681 com_object.Hashtable[key] = data;
685 public static int SizeOf (object structure) {
686 return SizeOf (structure.GetType ());
689 [MethodImplAttribute(MethodImplOptions.InternalCall)]
690 public extern static int SizeOf (Type t);
692 [MethodImplAttribute(MethodImplOptions.InternalCall)]
693 public extern static IntPtr StringToBSTR (string s);
695 public static IntPtr StringToCoTaskMemAnsi (string s) {
696 int length = s.Length + 1;
697 IntPtr ctm = AllocCoTaskMem (length);
699 byte[] asBytes = new byte[length];
700 for (int i = 0; i < s.Length; i++)
701 asBytes[i] = (byte)s[i];
702 asBytes[s.Length] = 0;
704 copy_to_unmanaged (asBytes, 0, ctm, length);
709 public static IntPtr StringToCoTaskMemAuto (string s) {
710 throw new NotImplementedException ();
713 public static IntPtr StringToCoTaskMemUni (string s) {
714 int length = s.Length + 1;
715 IntPtr ctm = AllocCoTaskMem (length * 2);
717 char[] asChars = new char[length];
718 s.CopyTo (0, asChars, 0, s.Length);
719 asChars[s.Length] = '\0';
721 copy_to_unmanaged (asChars, 0, ctm, length);
725 [MethodImplAttribute(MethodImplOptions.InternalCall)]
726 public extern static IntPtr StringToHGlobalAnsi (string s);
728 public static IntPtr StringToHGlobalAuto (string s)
730 return SystemDefaultCharSize == 2
731 ? StringToHGlobalUni (s) : StringToHGlobalAnsi (s);
734 [MethodImplAttribute(MethodImplOptions.InternalCall)]
735 public extern static IntPtr StringToHGlobalUni (string s);
739 public static IntPtr SecureStringToBSTR (SecureString s)
742 throw new ArgumentNullException ("s");
743 throw new NotSupportedException ();
747 public static IntPtr SecureStringToCoTaskMemAnsi (SecureString s)
750 throw new ArgumentNullException ("s");
751 throw new NotSupportedException ();
755 public static IntPtr SecureStringToCoTaskMemUnicode (SecureString s)
758 throw new ArgumentNullException ("s");
759 throw new NotSupportedException ();
763 public static IntPtr SecureStringToGlobalAllocAnsi (SecureString s)
766 throw new ArgumentNullException ("s");
767 throw new NotSupportedException ();
771 public static IntPtr SecureStringToGlobalAllocUnicode (SecureString s)
774 throw new ArgumentNullException ("s");
775 throw new NotSupportedException ();
780 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.MayFail)]
782 [MethodImplAttribute(MethodImplOptions.InternalCall)]
783 public extern static void StructureToPtr (object structure, IntPtr ptr, bool fDeleteOld);
785 public static void ThrowExceptionForHR (int errorCode) {
787 throw new COMException ("", errorCode);
791 public static void ThrowExceptionForHR (int errorCode, IntPtr errorInfo) {
792 throw new NotImplementedException ();
795 [MethodImplAttribute(MethodImplOptions.InternalCall)]
796 public extern static IntPtr UnsafeAddrOfPinnedArrayElement (Array arr, int index);
798 public static void WriteByte (IntPtr ptr, byte val) {
799 WriteByte (ptr, 0, val);
802 [MethodImplAttribute(MethodImplOptions.InternalCall)]
803 public extern static void WriteByte (IntPtr ptr, int ofs, byte val);
806 public static void WriteByte ([In, Out, MarshalAs (UnmanagedType.AsAny)] object ptr, int ofs, byte val) {
807 throw new NotImplementedException ();
810 public static void WriteInt16 (IntPtr ptr, short val) {
811 WriteInt16 (ptr, 0, val);
814 [MethodImplAttribute(MethodImplOptions.InternalCall)]
815 public extern static void WriteInt16 (IntPtr ptr, int ofs, short val);
818 public static void WriteInt16 ([In, Out, MarshalAs (UnmanagedType.AsAny)] object ptr, int ofs, short val) {
819 throw new NotImplementedException ();
822 public static void WriteInt16 (IntPtr ptr, char val) {
823 WriteInt16 (ptr, 0, val);
827 [MethodImplAttribute(MethodImplOptions.InternalCall)]
828 public extern static void WriteInt16 (IntPtr ptr, int ofs, char val);
831 public static void WriteInt16([In, Out] object ptr, int ofs, char val) {
832 throw new NotImplementedException ();
835 public static void WriteInt32 (IntPtr ptr, int val) {
836 WriteInt32 (ptr, 0, val);
839 [MethodImplAttribute(MethodImplOptions.InternalCall)]
840 public extern static void WriteInt32 (IntPtr ptr, int ofs, int val);
843 public static void WriteInt32([In, Out, MarshalAs(UnmanagedType.AsAny)] object ptr, int ofs, int val) {
844 throw new NotImplementedException ();
847 public static void WriteInt64 (IntPtr ptr, long val) {
848 WriteInt64 (ptr, 0, val);
851 [MethodImplAttribute(MethodImplOptions.InternalCall)]
852 public extern static void WriteInt64 (IntPtr ptr, int ofs, long val);
855 public static void WriteInt64 ([In, Out, MarshalAs (UnmanagedType.AsAny)] object ptr, int ofs, long val) {
856 throw new NotImplementedException ();
859 public static void WriteIntPtr (IntPtr ptr, IntPtr val) {
860 WriteIntPtr (ptr, 0, val);
863 [MethodImplAttribute(MethodImplOptions.InternalCall)]
864 public extern static void WriteIntPtr (IntPtr ptr, int ofs, IntPtr val);
867 public static void WriteIntPtr([In, Out, MarshalAs(UnmanagedType.AsAny)] object ptr, int ofs, IntPtr val) {
868 throw new NotImplementedException ();
873 public static int FinalReleaseComObject (object o) {
874 throw new NotImplementedException ();
878 public static Exception GetExceptionForHR (int errorCode) {
879 throw new NotImplementedException ();
883 public static Exception GetExceptionForHR (int errorCode, IntPtr errorInfo) {
884 throw new NotImplementedException ();
887 [MethodImplAttribute(MethodImplOptions.InternalCall)]
888 private static extern Delegate GetDelegateForFunctionPointerInternal (IntPtr ptr, Type t);
890 public static Delegate GetDelegateForFunctionPointer (IntPtr ptr, Type t) {
891 if (!t.IsSubclassOf (typeof (MulticastDelegate)) || (t == typeof (MulticastDelegate)))
892 throw new ArgumentException ("Type is not a delegate", "t");
893 if (ptr == IntPtr.Zero)
894 throw new ArgumentNullException ("ptr");
896 return GetDelegateForFunctionPointerInternal (ptr, t);
899 [MethodImplAttribute(MethodImplOptions.InternalCall)]
900 private static extern IntPtr GetFunctionPointerForDelegateInternal (Delegate d);
902 public static IntPtr GetFunctionPointerForDelegate (Delegate d) {
904 throw new ArgumentNullException ("d");
906 return GetFunctionPointerForDelegateInternal (d);