**** Merged from MCS ****
[mono-project.git] / mcs / class / corlib / System.Runtime.InteropServices / Marshal.cs
blob71f7c1eeee02a4df1b19b17068d1ebe9c0f66041
1 // System.Runtime.InteropServices.Marshal.cs
2 //
3 // Sean MacIsaac (macisaac@ximian.com)
4 // Paolo Molaro (lupus@ximian.com)
5 // Dietmar Maurer (dietmar@ximian.com)
6 //
7 // (C) 2001-2002 Ximian, Inc.
9 //
10 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System.Runtime.CompilerServices;
33 using System;
34 using System.Security;
35 using System.Reflection;
36 using System.Threading;
38 #if NET_2_0
39 using System.Runtime.ConstrainedExecution;
40 #endif
42 namespace System.Runtime.InteropServices
44 [SuppressUnmanagedCodeSecurity ()]
45 public
46 #if NET_2_0
47 static
48 #else
49 sealed
50 #endif
51 class Marshal
53 /* fields */
54 public static readonly int SystemMaxDBCSCharSize = 2; // don't know what this is
55 public static readonly int SystemDefaultCharSize = 2;
57 #if !NET_2_0
58 private Marshal () {}
59 #endif
61 [MonoTODO]
62 public static int AddRef (IntPtr pUnk) {
63 throw new NotImplementedException ();
66 [MethodImplAttribute(MethodImplOptions.InternalCall)]
67 public extern static IntPtr AllocCoTaskMem (int cb);
69 [MethodImplAttribute(MethodImplOptions.InternalCall)]
70 public extern static IntPtr AllocHGlobal (IntPtr cb);
72 public static IntPtr AllocHGlobal (int cb) {
73 return AllocHGlobal ((IntPtr)cb);
76 [MonoTODO]
77 public static object BindToMoniker (string monikerName) {
78 throw new NotImplementedException ();
81 [MonoTODO]
82 public static void ChangeWrapperHandleStrength (object otp, bool fIsWeak) {
83 throw new NotImplementedException ();
86 [MethodImplAttribute(MethodImplOptions.InternalCall)]
87 extern static void copy_to_unmanaged (Array source, int startIndex,
88 IntPtr destination, int length);
90 [MethodImplAttribute(MethodImplOptions.InternalCall)]
91 extern static void copy_from_unmanaged (IntPtr source, int startIndex,
92 Array destination, int length);
94 public static void Copy (byte[] source, int startIndex, IntPtr destination, int length) {
95 copy_to_unmanaged (source, startIndex, destination, length);
98 public static void Copy (char[] source, int startIndex, IntPtr destination, int length) {
99 copy_to_unmanaged (source, startIndex, destination, length);
102 public static void Copy (short[] source, int startIndex, IntPtr destination, int length) {
103 copy_to_unmanaged (source, startIndex, destination, length);
106 public static void Copy (int[] source, int startIndex, IntPtr destination, int length) {
107 copy_to_unmanaged (source, startIndex, destination, length);
110 public static void Copy (long[] source, int startIndex, IntPtr destination, int length) {
111 copy_to_unmanaged (source, startIndex, destination, length);
114 public static void Copy (float[] source, int startIndex, IntPtr destination, int length) {
115 copy_to_unmanaged (source, startIndex, destination, length);
118 public static void Copy (double[] source, int startIndex, IntPtr destination, int length) {
119 copy_to_unmanaged (source, startIndex, destination, length);
122 public static void Copy (IntPtr source, byte[] destination, int startIndex, int length) {
123 copy_from_unmanaged (source, startIndex, destination, length);
126 public static void Copy (IntPtr source, char[] destination, int startIndex, int length) {
127 copy_from_unmanaged (source, startIndex, destination, length);
130 public static void Copy (IntPtr source, short[] destination, int startIndex, int length) {
131 copy_from_unmanaged (source, startIndex, destination, length);
134 public static void Copy (IntPtr source, int[] destination, int startIndex, int length) {
135 copy_from_unmanaged (source, startIndex, destination, length);
138 public static void Copy (IntPtr source, long[] destination, int startIndex, int length) {
139 copy_from_unmanaged (source, startIndex, destination, length);
142 public static void Copy (IntPtr source, float[] destination, int startIndex, int length) {
143 copy_from_unmanaged (source, startIndex, destination, length);
146 public static void Copy (IntPtr source, double[] destination, int startIndex, int length) {
147 copy_from_unmanaged (source, startIndex, destination, length);
150 [MonoTODO]
151 public static object CreateWrapperOfType (object o, Type t) {
152 throw new NotImplementedException ();
155 [MethodImplAttribute(MethodImplOptions.InternalCall)]
156 public extern static void DestroyStructure (IntPtr ptr, Type structuretype);
158 [MonoTODO]
159 public static void FreeBSTR (IntPtr ptr) {
160 throw new NotImplementedException ();
163 [MethodImplAttribute(MethodImplOptions.InternalCall)]
164 public extern static void FreeCoTaskMem (IntPtr ptr);
166 [MethodImplAttribute(MethodImplOptions.InternalCall)]
167 public extern static void FreeHGlobal (IntPtr hglobal);
169 #if NET_2_0
170 [MonoTODO]
171 public static void ZeroFreeBSTR (IntPtr ptr) {
172 throw new NotImplementedException ();
175 [MonoTODO]
176 public static void ZeroFreeCoTaskMemAnsi (IntPtr ptr) {
177 throw new NotImplementedException ();
180 [MonoTODO]
181 public static void ZeroFreeCoTaskMemUni (IntPtr ptr) {
182 throw new NotImplementedException ();
185 [MonoTODO]
186 public static void ZeroFreeGlobalAllocAnsi (IntPtr hglobal) {
187 throw new NotImplementedException ();
190 [MonoTODO]
191 public static void ZeroFreeGlobalAllocUni (IntPtr hglobal) {
192 throw new NotImplementedException ();
194 #endif
196 [MonoTODO]
197 public static Guid GenerateGuidForType (Type type) {
198 throw new NotImplementedException ();
201 [MonoTODO]
202 public static string GenerateProgIdForType (Type type) {
203 throw new NotImplementedException ();
206 [MonoTODO]
207 public static object GetActiveObject (string progID) {
208 throw new NotImplementedException ();
211 [MonoTODO]
212 public static IntPtr GetComInterfaceForObject (object o, Type T) {
213 throw new NotImplementedException ();
216 #if NET_2_0
217 [MonoTODO]
218 public static IntPtr GetComInterfaceForObjectInContext (object o, Type t) {
219 throw new NotImplementedException ();
221 #endif
223 [MonoTODO]
224 public static object GetComObjectData (object obj, object key) {
225 throw new NotImplementedException ();
228 [MonoTODO]
229 public static int GetComSlotForMethodInfo (MemberInfo m) {
230 throw new NotImplementedException ();
233 [MonoTODO]
234 public static int GetEndComSlot (Type t) {
235 throw new NotImplementedException ();
238 [MonoTODO]
239 public static int GetExceptionCode() {
240 throw new NotImplementedException ();
243 [MonoTODO]
244 public static IntPtr GetExceptionPointers() {
245 throw new NotImplementedException ();
248 [MonoTODO]
249 public static IntPtr GetHINSTANCE (Module m) {
250 throw new NotImplementedException ();
253 [MonoTODO]
254 public static int GetHRForException (Exception e) {
255 throw new NotImplementedException ();
258 [MonoTODO]
259 public static int GetHRForLastWin32Error() {
260 throw new NotImplementedException ();
263 [MonoTODO]
264 public static IntPtr GetIDispatchForObject (object o) {
265 throw new NotImplementedException ();
268 #if NET_2_0
269 [MonoTODO]
270 public static IntPtr GetIDispatchForObjectInContext (object o) {
271 throw new NotImplementedException ();
273 #endif
275 [MonoTODO]
276 public static IntPtr GetITypeInfoForType (Type t) {
277 throw new NotImplementedException ();
280 [MonoTODO]
281 public static IntPtr GetIUnknownForObject (object o) {
282 throw new NotImplementedException ();
285 #if NET_2_0
286 [MonoTODO]
287 public static IntPtr GetIUnknownForObjectInContext (object o) {
288 throw new NotImplementedException ();
290 #endif
292 [MethodImplAttribute(MethodImplOptions.InternalCall)]
293 public static extern int GetLastWin32Error();
295 [MonoTODO]
296 public static IntPtr GetManagedThunkForUnmanagedMethodPtr (IntPtr pfnMethodToWrap, IntPtr pbSignature, int cbSignature) {
297 throw new NotImplementedException ();
300 [MonoTODO]
301 public static MemberInfo GetMethodInfoForComSlot (Type t, int slot, ref ComMemberType memberType) {
302 throw new NotImplementedException ();
305 [MonoTODO]
306 public static void GetNativeVariantForObject (object obj, IntPtr pDstNativeVariant) {
307 throw new NotImplementedException ();
310 [MonoTODO]
311 public static object GetObjectForIUnknown (IntPtr pUnk) {
312 throw new NotImplementedException ();
315 [MonoTODO]
316 public static object GetObjectForNativeVariant (IntPtr pSrcNativeVariant) {
317 throw new NotImplementedException ();
320 [MonoTODO]
321 public static object[] GetObjectsForNativeVariants (IntPtr aSrcNativeVariant, int cVars) {
322 throw new NotImplementedException ();
325 [MonoTODO]
326 public static int GetStartComSlot (Type t) {
327 throw new NotImplementedException ();
330 [MonoTODO]
331 public static Thread GetThreadFromFiberCookie (int cookie) {
332 throw new NotImplementedException ();
335 [MonoTODO]
336 public static object GetTypedObjectForIUnknown (IntPtr pUnk, Type t) {
337 throw new NotImplementedException ();
340 [MonoTODO]
341 public static Type GetTypeForITypeInfo (IntPtr piTypeInfo) {
342 throw new NotImplementedException ();
345 #if NET_2_0
346 [Obsolete]
347 #endif
348 [MonoTODO]
349 public static string GetTypeInfoName (UCOMITypeInfo pTI) {
350 throw new NotImplementedException ();
353 #if NET_2_0
354 [Obsolete]
355 #endif
356 [MonoTODO]
357 public static Guid GetTypeLibGuid (UCOMITypeLib pTLB) {
358 throw new NotImplementedException ();
361 [MonoTODO]
362 public static Guid GetTypeLibGuidForAssembly (Assembly asm) {
363 throw new NotImplementedException ();
366 #if NET_2_0
367 [Obsolete]
368 #endif
369 [MonoTODO]
370 public static int GetTypeLibLcid (UCOMITypeLib pTLB) {
371 throw new NotImplementedException ();
374 #if NET_2_0
375 [Obsolete]
376 #endif
377 [MonoTODO]
378 public static string GetTypeLibName (UCOMITypeLib pTLB) {
379 throw new NotImplementedException ();
382 #if NET_2_0
383 [MonoTODO]
384 public static void GetTypeLibVersionForAssembly (Assembly inputAssembly, out int majorVersion, out int minorVersion) {
385 throw new NotImplementedException ();
387 #endif
389 [MonoTODO]
390 public static IntPtr GetUnmanagedThunkForManagedMethodPtr (IntPtr pfnMethodToWrap, IntPtr pbSignature, int cbSignature) {
391 throw new NotImplementedException ();
394 [MonoTODO]
395 public static bool IsComObject (object o) {
396 throw new NotImplementedException ();
399 [MonoTODO]
400 public static bool IsTypeVisibleFromCom (Type t) {
401 throw new NotImplementedException ();
404 [MonoTODO]
405 public static int NumParamBytes (MethodInfo m) {
406 throw new NotImplementedException ();
409 [MethodImplAttribute(MethodImplOptions.InternalCall)]
410 public extern static IntPtr OffsetOf (Type t, string fieldName);
412 [MethodImplAttribute(MethodImplOptions.InternalCall)]
413 public extern static void Prelink (MethodInfo m);
415 [MethodImplAttribute(MethodImplOptions.InternalCall)]
416 public extern static void PrelinkAll (Type c);
418 [MethodImplAttribute(MethodImplOptions.InternalCall)]
419 public extern static string PtrToStringAnsi (IntPtr ptr);
421 [MethodImplAttribute(MethodImplOptions.InternalCall)]
422 public extern static string PtrToStringAnsi (IntPtr ptr, int len);
424 [MethodImplAttribute(MethodImplOptions.InternalCall)]
425 public extern static string PtrToStringAuto (IntPtr ptr);
427 [MethodImplAttribute(MethodImplOptions.InternalCall)]
428 public extern static string PtrToStringAuto (IntPtr ptr, int len);
430 [MethodImplAttribute(MethodImplOptions.InternalCall)]
431 public extern static string PtrToStringUni (IntPtr ptr);
433 [MethodImplAttribute(MethodImplOptions.InternalCall)]
434 public extern static string PtrToStringUni (IntPtr ptr, int len);
436 [MethodImplAttribute(MethodImplOptions.InternalCall)]
437 public extern static string PtrToStringBSTR (IntPtr ptr);
439 [MethodImplAttribute(MethodImplOptions.InternalCall)]
440 public extern static void PtrToStructure (IntPtr ptr, object structure);
442 [MethodImplAttribute(MethodImplOptions.InternalCall)]
443 public extern static object PtrToStructure (IntPtr ptr, Type structureType);
445 [MonoTODO]
446 public static int QueryInterface (IntPtr pUnk, ref Guid iid, out IntPtr ppv) {
447 throw new NotImplementedException ();
450 public static byte ReadByte (IntPtr ptr) {
451 return ReadByte (ptr, 0);
454 [MethodImplAttribute(MethodImplOptions.InternalCall)]
455 public extern static byte ReadByte (IntPtr ptr, int ofs);
457 [MonoTODO]
458 public static byte ReadByte ([In, MarshalAs (UnmanagedType.AsAny)] object ptr, int ofs) {
459 throw new NotImplementedException ();
462 public static short ReadInt16 (IntPtr ptr) {
463 return ReadInt16 (ptr, 0);
466 [MethodImplAttribute(MethodImplOptions.InternalCall)]
467 public extern static short ReadInt16 (IntPtr ptr, int ofs);
469 [MonoTODO]
470 public static short ReadInt16 ([In, MarshalAs(UnmanagedType.AsAny)] object ptr, int ofs) {
471 throw new NotImplementedException ();
474 #if NET_2_0
475 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
476 #endif
477 public static int ReadInt32 (IntPtr ptr) {
478 return ReadInt32 (ptr, 0);
481 #if NET_2_0
482 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
483 #endif
484 [MethodImplAttribute(MethodImplOptions.InternalCall)]
485 public extern static int ReadInt32 (IntPtr ptr, int ofs);
487 #if NET_2_0
488 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
489 #endif
490 [MonoTODO]
491 public static int ReadInt32 ([In, MarshalAs(UnmanagedType.AsAny)] object ptr, int ofs) {
492 throw new NotImplementedException ();
495 #if NET_2_0
496 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
497 #endif
498 public static long ReadInt64 (IntPtr ptr) {
499 return ReadInt64 (ptr, 0);
502 #if NET_2_0
503 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
504 #endif
505 [MethodImplAttribute(MethodImplOptions.InternalCall)]
506 public extern static long ReadInt64 (IntPtr ptr, int ofs);
508 #if NET_2_0
509 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
510 #endif
511 [MonoTODO]
512 public static long ReadInt64 ([In, MarshalAs (UnmanagedType.AsAny)] object ptr, int ofs) {
513 throw new NotImplementedException ();
516 #if NET_2_0
517 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
518 #endif
519 public static IntPtr ReadIntPtr (IntPtr ptr) {
520 return ReadIntPtr (ptr, 0);
523 #if NET_2_0
524 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
525 #endif
526 [MethodImplAttribute(MethodImplOptions.InternalCall)]
527 public extern static IntPtr ReadIntPtr (IntPtr ptr, int ofs);
529 #if NET_2_0
530 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
531 #endif
532 [MonoTODO]
533 public static IntPtr ReadIntPtr ([In, MarshalAs (UnmanagedType.AsAny)] object ptr, int ofs) {
534 throw new NotImplementedException ();
537 [MonoTODO]
538 public static IntPtr ReAllocCoTaskMem (IntPtr pv, int cb) {
539 throw new NotImplementedException ();
542 [MethodImplAttribute(MethodImplOptions.InternalCall)]
543 public extern static IntPtr ReAllocHGlobal (IntPtr pv, IntPtr cb);
545 #if NET_2_0
546 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
547 #endif
548 [MonoTODO]
549 public static int Release (IntPtr pUnk) {
550 throw new NotImplementedException ();
553 [MonoTODO]
554 public static int ReleaseComObject (object o) {
555 throw new NotImplementedException ();
558 #if NET_2_0
559 [Obsolete]
560 #endif
561 [MonoTODO]
562 public static void ReleaseThreadCache() {
563 throw new NotImplementedException ();
566 [MonoTODO]
567 public static bool SetComObjectData (object obj, object key, object data) {
568 throw new NotImplementedException ();
571 public static int SizeOf (object structure) {
572 return SizeOf (structure.GetType ());
575 [MethodImplAttribute(MethodImplOptions.InternalCall)]
576 public extern static int SizeOf (Type t);
578 [MonoTODO]
579 public static IntPtr StringToBSTR (string s) {
580 throw new NotImplementedException ();
583 public static IntPtr StringToCoTaskMemAnsi (string s) {
584 int length = s.Length + 1;
585 IntPtr ctm = AllocCoTaskMem (length);
587 byte[] asBytes = new byte[length];
588 for (int i = 0; i < s.Length; i++)
589 asBytes[i] = (byte)s[i];
590 asBytes[s.Length] = 0;
592 copy_to_unmanaged (asBytes, 0, ctm, length);
593 return ctm;
596 [MonoTODO]
597 public static IntPtr StringToCoTaskMemAuto (string s) {
598 throw new NotImplementedException ();
601 public static IntPtr StringToCoTaskMemUni (string s) {
602 int length = s.Length + 1;
603 IntPtr ctm = AllocCoTaskMem (length * 2);
605 char[] asChars = new char[length];
606 s.CopyTo (0, asChars, 0, s.Length);
607 asChars[s.Length] = '\0';
609 copy_to_unmanaged (asChars, 0, ctm, length);
610 return ctm;
613 [MethodImplAttribute(MethodImplOptions.InternalCall)]
614 public extern static IntPtr StringToHGlobalAnsi (string s);
616 [MethodImplAttribute(MethodImplOptions.InternalCall)]
617 public extern static IntPtr StringToHGlobalAuto (string s);
619 [MethodImplAttribute(MethodImplOptions.InternalCall)]
620 public extern static IntPtr StringToHGlobalUni (string s);
622 #if NET_2_0
623 [MonoTODO]
624 public static IntPtr SecureStringToBSTR (SecureString s) {
625 throw new NotImplementedException ();
628 [MonoTODO]
629 public static IntPtr SecureStringToCoTaskMemAnsi (SecureString s) {
630 throw new NotImplementedException ();
633 [MonoTODO]
634 public static IntPtr SecureStringToCoTaskMemUni (SecureString s) {
635 throw new NotImplementedException ();
638 [MonoTODO]
639 public static IntPtr SecureStringToGlobalAllocAnsi (SecureString s) {
640 throw new NotImplementedException ();
643 [MonoTODO]
644 public static IntPtr SecureStringToGlobalAllocUni (SecureString s) {
645 throw new NotImplementedException ();
647 #endif
649 #if NET_2_0
650 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.MayFail)]
651 #endif
652 [MethodImplAttribute(MethodImplOptions.InternalCall)]
653 public extern static void StructureToPtr (object structure, IntPtr ptr, bool fDeleteOld);
655 [MonoTODO]
656 public static void ThrowExceptionForHR (int errorCode) {
657 throw new NotImplementedException ();
660 [MonoTODO]
661 public static void ThrowExceptionForHR (int errorCode, IntPtr errorInfo) {
662 throw new NotImplementedException ();
665 [MethodImplAttribute(MethodImplOptions.InternalCall)]
666 public extern static IntPtr UnsafeAddrOfPinnedArrayElement (Array arr, int index);
668 public static void WriteByte (IntPtr ptr, byte val) {
669 WriteByte (ptr, 0, val);
672 [MethodImplAttribute(MethodImplOptions.InternalCall)]
673 public extern static void WriteByte (IntPtr ptr, int ofs, byte val);
675 [MonoTODO]
676 public static void WriteByte ([In, Out, MarshalAs (UnmanagedType.AsAny)] object ptr, int ofs, byte val) {
677 throw new NotImplementedException ();
680 public static void WriteInt16 (IntPtr ptr, short val) {
681 WriteInt16 (ptr, 0, val);
684 [MethodImplAttribute(MethodImplOptions.InternalCall)]
685 public extern static void WriteInt16 (IntPtr ptr, int ofs, short val);
687 [MonoTODO]
688 public static void WriteInt16 ([In, Out, MarshalAs (UnmanagedType.AsAny)] object ptr, int ofs, short val) {
689 throw new NotImplementedException ();
692 public static void WriteInt16 (IntPtr ptr, char val) {
693 WriteInt16 (ptr, 0, val);
696 [MonoTODO]
697 [MethodImplAttribute(MethodImplOptions.InternalCall)]
698 public extern static void WriteInt16 (IntPtr ptr, int ofs, char val);
700 [MonoTODO]
701 public static void WriteInt16([In, Out, MarshalAs(UnmanagedType.AsAny)] object ptr, int ofs, char val) {
702 throw new NotImplementedException ();
705 public static void WriteInt32 (IntPtr ptr, int val) {
706 WriteInt32 (ptr, 0, val);
709 [MethodImplAttribute(MethodImplOptions.InternalCall)]
710 public extern static void WriteInt32 (IntPtr ptr, int ofs, int val);
712 [MonoTODO]
713 public static void WriteInt32([In, Out, MarshalAs(UnmanagedType.AsAny)] object ptr, int ofs, int val) {
714 throw new NotImplementedException ();
717 public static void WriteInt64 (IntPtr ptr, long val) {
718 WriteInt64 (ptr, 0, val);
721 [MethodImplAttribute(MethodImplOptions.InternalCall)]
722 public extern static void WriteInt64 (IntPtr ptr, int ofs, long val);
724 [MonoTODO]
725 public static void WriteInt64 ([In, Out, MarshalAs (UnmanagedType.AsAny)] object ptr, int ofs, long val) {
726 throw new NotImplementedException ();
729 public static void WriteIntPtr (IntPtr ptr, IntPtr val) {
730 WriteIntPtr (ptr, 0, val);
733 [MethodImplAttribute(MethodImplOptions.InternalCall)]
734 public extern static void WriteIntPtr (IntPtr ptr, int ofs, IntPtr val);
736 [MonoTODO]
737 public static void WriteIntPtr([In, Out, MarshalAs(UnmanagedType.AsAny)] object ptr, int ofs, IntPtr val) {
738 throw new NotImplementedException ();
741 #if NET_2_0
742 [MonoTODO]
743 public static int FinalReleaseComObject (object o) {
744 throw new NotImplementedException ();
747 [MonoTODO]
748 public static Exception GetExceptionForHR (int errorCode) {
749 throw new NotImplementedException ();
752 [MonoTODO]
753 public static Exception GetExceptionForHR (int errorCode, IntPtr errorInfo) {
754 throw new NotImplementedException ();
757 [MethodImplAttribute(MethodImplOptions.InternalCall)]
758 private static extern Delegate GetDelegateForFunctionPointerInternal (IntPtr ptr, Type t);
760 public static Delegate GetDelegateForFunctionPointer (IntPtr ptr, Type t) {
761 if (!t.IsSubclassOf (typeof (MulticastDelegate)) || (t == typeof (MulticastDelegate)))
762 throw new ArgumentException ("Type is not a delegate", "t");
763 if (ptr == IntPtr.Zero)
764 throw new ArgumentNullException ("ptr");
766 return GetDelegateForFunctionPointerInternal (ptr, t);
769 [MethodImplAttribute(MethodImplOptions.InternalCall)]
770 private static extern IntPtr GetFunctionPointerForDelegateInternal (Delegate d);
772 public static IntPtr GetFunctionPointerForDelegate (Delegate d) {
773 if (d == null)
774 throw new ArgumentNullException ("d");
776 return GetFunctionPointerForDelegateInternal (d);
778 #endif