1 // System.Runtime.InteropServices.Marshal
3 // Sean MacIsaac (macisaac@ximian.com)
4 // Paolo Molaro (lupus@ximian.com)
5 // Dietmar Maurer (dietmar@ximian.com)
7 // (C) 2001-2002 Ximian, Inc.
9 using System.Runtime.CompilerServices;
11 using System.Reflection;
12 using System.Threading;
14 namespace System.Runtime.InteropServices
16 public sealed class Marshal
19 public static readonly int SystemMaxDBCSCharSize = 2; // don't know what this is
20 public static readonly int SystemDefaultCharSize = 2;
25 public static int AddRef (IntPtr pUnk) {
26 throw new NotImplementedException ();
29 public static IntPtr AllocCoTaskMem (int cb) {
30 throw new NotImplementedException ();
33 [MethodImplAttribute(MethodImplOptions.InternalCall)]
34 public extern static IntPtr AllocHGlobal (IntPtr cb);
36 public static IntPtr AllocHGlobal (int cb) {
37 return AllocHGlobal ((IntPtr)cb);
41 public static object BindToMoniker (string monikerName) {
42 throw new NotImplementedException ();
46 public static void ChangeWrapperHandleStrength (object otp, bool fIsWeak) {
47 throw new NotImplementedException ();
50 [MethodImplAttribute(MethodImplOptions.InternalCall)]
51 extern static void copy_to_unmanaged (Array source, int startIndex,
52 IntPtr destination, int length);
54 [MethodImplAttribute(MethodImplOptions.InternalCall)]
55 extern static void copy_from_unmanaged (IntPtr source, int startIndex,
56 Array destination, int length);
58 public static void Copy (byte[] source, int startIndex, IntPtr destination, int length) {
59 copy_to_unmanaged (source, startIndex, destination, length);
62 public static void Copy (char[] source, int startIndex, IntPtr destination, int length) {
63 copy_to_unmanaged (source, startIndex, destination, length);
66 public static void Copy (short[] source, int startIndex, IntPtr destination, int length) {
67 copy_to_unmanaged (source, startIndex, destination, length);
70 public static void Copy (int[] source, int startIndex, IntPtr destination, int length) {
71 copy_to_unmanaged (source, startIndex, destination, length);
74 public static void Copy (long[] source, int startIndex, IntPtr destination, int length) {
75 copy_to_unmanaged (source, startIndex, destination, length);
78 public static void Copy (float[] source, int startIndex, IntPtr destination, int length) {
79 copy_to_unmanaged (source, startIndex, destination, length);
82 public static void Copy (double[] source, int startIndex, IntPtr destination, int length) {
83 copy_to_unmanaged (source, startIndex, destination, length);
86 public static void Copy (IntPtr source, byte[] destination, int startIndex, int length) {
87 copy_from_unmanaged (source, startIndex, destination, length);
90 public static void Copy (IntPtr source, char[] destination, int startIndex, int length) {
91 copy_from_unmanaged (source, startIndex, destination, length);
94 public static void Copy (IntPtr source, short[] destination, int startIndex, int length) {
95 copy_from_unmanaged (source, startIndex, destination, length);
98 public static void Copy (IntPtr source, int[] destination, int startIndex, int length) {
99 copy_from_unmanaged (source, startIndex, destination, length);
102 public static void Copy (IntPtr source, long[] destination, int startIndex, int length) {
103 copy_from_unmanaged (source, startIndex, destination, length);
106 public static void Copy (IntPtr source, float[] destination, int startIndex, int length) {
107 copy_from_unmanaged (source, startIndex, destination, length);
110 public static void Copy (IntPtr source, double[] destination, int startIndex, int length) {
111 copy_from_unmanaged (source, startIndex, destination, length);
115 public static object CreateWrapperOfType (object o, Type t) {
116 throw new NotImplementedException ();
120 public static void DestroyStructure (IntPtr ptr, Type structuretype) {
121 throw new NotImplementedException ();
125 public static void FreeBSTR (IntPtr ptr) {
126 throw new NotImplementedException ();
130 public static void FreeCoTaskMem (IntPtr ptr) {
131 throw new NotImplementedException ();
134 [MethodImplAttribute(MethodImplOptions.InternalCall)]
135 public extern static void FreeHGlobal (IntPtr hglobal);
138 public static Guid GenerateGuidForType (Type type) {
139 throw new NotImplementedException ();
143 public static string GenerateProgIdForType (Type type) {
144 throw new NotImplementedException ();
148 public static object GetActiveObject (string progID) {
149 throw new NotImplementedException ();
153 public static IntPtr GetComInterfaceForObject (object o, Type T) {
154 throw new NotImplementedException ();
158 public static object GetComObjectData (object obj, object key) {
159 throw new NotImplementedException ();
163 public static int GetComSlotForMethodInfo (MemberInfo m) {
164 throw new NotImplementedException ();
168 public static int GetEndComSlot (Type t) {
169 throw new NotImplementedException ();
173 public static int GetExceptionCode() {
174 throw new NotImplementedException ();
178 public static IntPtr GetExceptionPointers() {
179 throw new NotImplementedException ();
183 public static IntPtr GetHINSTANCE (Module m) {
184 throw new NotImplementedException ();
188 public static int GetHRForException (Exception e) {
189 throw new NotImplementedException ();
193 public static int GetHRForLastWin32Error() {
194 throw new NotImplementedException ();
198 public static IntPtr GetIDispatchForObject (object o) {
199 throw new NotImplementedException ();
203 public static IntPtr GetITypeInfoForType (Type t) {
204 throw new NotImplementedException ();
208 public static IntPtr GetIUnknownForObject (object o) {
209 throw new NotImplementedException ();
212 [MethodImplAttribute(MethodImplOptions.InternalCall)]
213 public static extern int GetLastWin32Error();
216 public static IntPtr GetManagedThunkForUnmanagedMethodPtr (IntPtr pfnMethodToWrap, IntPtr pbSignature, int cbSignature) {
217 throw new NotImplementedException ();
221 public static MemberInfo GetMethodInfoForComSlot (Type t, int slot, ref ComMemberType memberType) {
222 throw new NotImplementedException ();
226 public static void GetNativeVariantForObject (object obj, IntPtr pDstNativeVariant) {
227 throw new NotImplementedException ();
231 public static object GetObjectForIUnknown (IntPtr pUnk) {
232 throw new NotImplementedException ();
236 public static object GetObjectForNativeVariant (IntPtr pSrcNativeVariant) {
237 throw new NotImplementedException ();
241 public static object[] GetObjectsForNativeVariants (IntPtr aSrcNativeVariant, int cVars) {
242 throw new NotImplementedException ();
246 public static int GetStartComSlot (Type t) {
247 throw new NotImplementedException ();
251 public static Thread GetThreadFromFiberCookie (int cookie) {
252 throw new NotImplementedException ();
256 public static object GetTypedObjectForIUnknown (IntPtr pUnk, Type t) {
257 throw new NotImplementedException ();
261 public static Type GetTypeForITypeInfo (IntPtr piTypeInfo) {
262 throw new NotImplementedException ();
266 public static string GetTypeInfoName (UCOMITypeInfo pTI) {
267 throw new NotImplementedException ();
271 public static Guid GetTypeLibGuid (UCOMITypeLib pTLB) {
272 throw new NotImplementedException ();
276 public static Guid GetTypeLibGuidForAssembly (Assembly asm) {
277 throw new NotImplementedException ();
281 public static int GetTypeLibLcid (UCOMITypeLib pTLB) {
282 throw new NotImplementedException ();
286 public static string GetTypeLibName (UCOMITypeLib pTLB) {
287 throw new NotImplementedException ();
291 public static IntPtr GetUnmanagedThunkForManagedMethodPtr (IntPtr pfnMethodToWrap, IntPtr pbSignature, int cbSignature) {
292 throw new NotImplementedException ();
296 public static bool IsComObject (object o) {
297 throw new NotImplementedException ();
301 public static bool IsTypeVisibleFromCom (Type t) {
302 throw new NotImplementedException ();
306 public static int NumParamBytes (MethodInfo m) {
307 throw new NotImplementedException ();
311 public static IntPtr OffsetOf (Type t, string fieldName) {
312 throw new NotImplementedException ();
316 public static void Prelink (MethodInfo m) {
317 throw new NotImplementedException ();
321 public static void PrelinkAll (Type c) {
322 throw new NotImplementedException ();
326 public static string PtrToStringAnsi (IntPtr ptr) {
327 throw new NotImplementedException ();
331 public static string PtrToStringAnsi (IntPtr ptr, int len) {
332 throw new NotImplementedException ();
336 public static string PtrToStringAuto (IntPtr ptr, int len) {
337 throw new NotImplementedException ();
340 [MethodImplAttribute(MethodImplOptions.InternalCall)]
341 public static extern string PtrToStringAuto (IntPtr ptr);
344 public static string PtrToStringBSTR (IntPtr ptr) {
345 throw new NotImplementedException ();
349 public static string PtrToStringUni (IntPtr ptr) {
350 throw new NotImplementedException ();
354 public static string PtrToStringUni (IntPtr ptr, int len) {
355 throw new NotImplementedException ();
358 [MethodImplAttribute(MethodImplOptions.InternalCall)]
359 public extern static void PtrToStructure (IntPtr ptr, object structure);
362 public static object PtrToStructure (IntPtr ptr, Type structureType) {
363 throw new NotImplementedException ();
367 public static int QueryInterface (IntPtr pUnk, ref Guid iid, out IntPtr ppv) {
368 throw new NotImplementedException ();
371 public static byte ReadByte (IntPtr ptr) {
372 return ReadByte (ptr, 0);
375 [MethodImplAttribute(MethodImplOptions.InternalCall)]
376 public extern static byte ReadByte (IntPtr ptr, int ofs);
379 public static byte ReadByte (object ptr, int ofs) {
380 throw new NotImplementedException ();
383 public static short ReadInt16 (IntPtr ptr) {
384 return ReadInt16 (ptr, 0);
387 [MethodImplAttribute(MethodImplOptions.InternalCall)]
388 public extern static short ReadInt16 (IntPtr ptr, int ofs);
391 public static short ReadInt16 (object ptr, int ofs) {
392 throw new NotImplementedException ();
395 public static int ReadInt32 (IntPtr ptr) {
396 return ReadInt32 (ptr, 0);
399 [MethodImplAttribute(MethodImplOptions.InternalCall)]
400 public extern static int ReadInt32 (IntPtr ptr, int ofs);
403 public static int ReadInt32 (object ptr, int ofs) {
404 throw new NotImplementedException ();
407 public static long ReadInt64 (IntPtr ptr) {
408 return ReadInt64 (ptr, 0);
411 [MethodImplAttribute(MethodImplOptions.InternalCall)]
412 public extern static long ReadInt64 (IntPtr ptr, int ofs);
415 public static long ReadInt64(object ptr, int ofs) {
416 throw new NotImplementedException ();
419 public static IntPtr ReadIntPtr (IntPtr ptr) {
420 return ReadIntPtr (ptr, 0);
423 [MethodImplAttribute(MethodImplOptions.InternalCall)]
424 public extern static IntPtr ReadIntPtr (IntPtr ptr, int ofs);
427 public static IntPtr ReadIntPtr(object ptr, int ofs) {
428 throw new NotImplementedException ();
432 public static IntPtr ReAllocCoTaskMem (IntPtr pv, int cb) {
433 throw new NotImplementedException ();
436 [MethodImplAttribute(MethodImplOptions.InternalCall)]
437 public extern static IntPtr ReAllocHGlobal (IntPtr pv, IntPtr cb);
440 public static int Release (IntPtr pUnk) {
441 throw new NotImplementedException ();
445 public static int ReleaseComObject (object o) {
446 throw new NotImplementedException ();
450 public static void ReleaseThreadCache() {
451 throw new NotImplementedException ();
455 public static bool SetComObjectData (object obj, object key, object data) {
456 throw new NotImplementedException ();
459 public static int SizeOf (object structure) {
460 return SizeOf (structure.GetType ());
463 [MethodImplAttribute(MethodImplOptions.InternalCall)]
464 public extern static int SizeOf (Type t);
467 public static IntPtr StringToBSTR (string s) {
468 throw new NotImplementedException ();
472 public static IntPtr StringToCoTaskMemAnsi (string s) {
473 throw new NotImplementedException ();
477 public static IntPtr StringToCoTaskMemAuto (string s) {
478 throw new NotImplementedException ();
482 public static IntPtr StringToCoTaskMemUni (string s) {
483 throw new NotImplementedException ();
487 public static IntPtr StringToHGlobalAnsi (string s) {
488 throw new NotImplementedException ();
492 public static IntPtr StringToHGlobalAuto (string s) {
493 throw new NotImplementedException ();
497 public static IntPtr StringToHGlobalUni (string s) {
498 throw new NotImplementedException ();
501 [MethodImplAttribute(MethodImplOptions.InternalCall)]
502 public extern static void StructureToPtr (object structure, IntPtr ptr, bool fDeleteOld);
505 public static void ThrowExceptionForHR (int errorCode) {
506 throw new NotImplementedException ();
510 public static void ThrowExceptionForHR (int errorCode, IntPtr errorInfo) {
511 throw new NotImplementedException ();
515 public static IntPtr UnsafeAddrOfPinnedArrayElement (Array arr, int index) {
516 throw new NotImplementedException ();
519 public static void WriteByte (IntPtr ptr, byte val) {
520 WriteByte (ptr, 0, val);
523 [MethodImplAttribute(MethodImplOptions.InternalCall)]
524 public extern static void WriteByte (IntPtr ptr, int ofs, byte val);
527 public static void WriteByte(object ptr, int ofs, byte val) {
528 throw new NotImplementedException ();
531 public static void WriteInt16 (IntPtr ptr, short val) {
532 WriteInt16 (ptr, 0, val);
535 [MethodImplAttribute(MethodImplOptions.InternalCall)]
536 public extern static void WriteInt16 (IntPtr ptr, int ofs, short val);
539 public static void WriteInt16(object ptr, int ofs, short val) {
540 throw new NotImplementedException ();
543 public static void WriteInt32 (IntPtr ptr, int val) {
544 WriteInt32 (ptr, 0, val);
547 [MethodImplAttribute(MethodImplOptions.InternalCall)]
548 public extern static void WriteInt32 (IntPtr ptr, int ofs, int val);
551 public static void WriteInt32(object ptr, int ofs, int val) {
552 throw new NotImplementedException ();
555 public static void WriteInt64 (IntPtr ptr, long val) {
556 WriteInt64 (ptr, 0, val);
559 [MethodImplAttribute(MethodImplOptions.InternalCall)]
560 public extern static void WriteInt64 (IntPtr ptr, int ofs, long val);
563 public static void WriteInt64(object ptr, int ofs, long val) {
564 throw new NotImplementedException ();
567 public static void WriteIntPtr (IntPtr ptr, IntPtr val) {
568 WriteIntPtr (ptr, 0, val);
571 [MethodImplAttribute(MethodImplOptions.InternalCall)]
572 public extern static void WriteIntPtr (IntPtr ptr, int ofs, IntPtr val);
575 public static void WriteIntPtr(object ptr, int ofs, IntPtr val) {
576 throw new NotImplementedException ();