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 ();
119 [MethodImplAttribute(MethodImplOptions.InternalCall)]
120 public extern static void DestroyStructure (IntPtr ptr, Type structuretype);
123 public static void FreeBSTR (IntPtr ptr) {
124 throw new NotImplementedException ();
128 public static void FreeCoTaskMem (IntPtr ptr) {
129 throw new NotImplementedException ();
132 [MethodImplAttribute(MethodImplOptions.InternalCall)]
133 public extern static void FreeHGlobal (IntPtr hglobal);
136 public static Guid GenerateGuidForType (Type type) {
137 throw new NotImplementedException ();
141 public static string GenerateProgIdForType (Type type) {
142 throw new NotImplementedException ();
146 public static object GetActiveObject (string progID) {
147 throw new NotImplementedException ();
151 public static IntPtr GetComInterfaceForObject (object o, Type T) {
152 throw new NotImplementedException ();
156 public static object GetComObjectData (object obj, object key) {
157 throw new NotImplementedException ();
161 public static int GetComSlotForMethodInfo (MemberInfo m) {
162 throw new NotImplementedException ();
166 public static int GetEndComSlot (Type t) {
167 throw new NotImplementedException ();
171 public static int GetExceptionCode() {
172 throw new NotImplementedException ();
176 public static IntPtr GetExceptionPointers() {
177 throw new NotImplementedException ();
181 public static IntPtr GetHINSTANCE (Module m) {
182 throw new NotImplementedException ();
186 public static int GetHRForException (Exception e) {
187 throw new NotImplementedException ();
191 public static int GetHRForLastWin32Error() {
192 throw new NotImplementedException ();
196 public static IntPtr GetIDispatchForObject (object o) {
197 throw new NotImplementedException ();
201 public static IntPtr GetITypeInfoForType (Type t) {
202 throw new NotImplementedException ();
206 public static IntPtr GetIUnknownForObject (object o) {
207 throw new NotImplementedException ();
210 [MethodImplAttribute(MethodImplOptions.InternalCall)]
211 public static extern int GetLastWin32Error();
214 public static IntPtr GetManagedThunkForUnmanagedMethodPtr (IntPtr pfnMethodToWrap, IntPtr pbSignature, int cbSignature) {
215 throw new NotImplementedException ();
219 public static MemberInfo GetMethodInfoForComSlot (Type t, int slot, ref ComMemberType memberType) {
220 throw new NotImplementedException ();
224 public static void GetNativeVariantForObject (object obj, IntPtr pDstNativeVariant) {
225 throw new NotImplementedException ();
229 public static object GetObjectForIUnknown (IntPtr pUnk) {
230 throw new NotImplementedException ();
234 public static object GetObjectForNativeVariant (IntPtr pSrcNativeVariant) {
235 throw new NotImplementedException ();
239 public static object[] GetObjectsForNativeVariants (IntPtr aSrcNativeVariant, int cVars) {
240 throw new NotImplementedException ();
244 public static int GetStartComSlot (Type t) {
245 throw new NotImplementedException ();
249 public static Thread GetThreadFromFiberCookie (int cookie) {
250 throw new NotImplementedException ();
254 public static object GetTypedObjectForIUnknown (IntPtr pUnk, Type t) {
255 throw new NotImplementedException ();
259 public static Type GetTypeForITypeInfo (IntPtr piTypeInfo) {
260 throw new NotImplementedException ();
264 public static string GetTypeInfoName (UCOMITypeInfo pTI) {
265 throw new NotImplementedException ();
269 public static Guid GetTypeLibGuid (UCOMITypeLib pTLB) {
270 throw new NotImplementedException ();
274 public static Guid GetTypeLibGuidForAssembly (Assembly asm) {
275 throw new NotImplementedException ();
279 public static int GetTypeLibLcid (UCOMITypeLib pTLB) {
280 throw new NotImplementedException ();
284 public static string GetTypeLibName (UCOMITypeLib pTLB) {
285 throw new NotImplementedException ();
289 public static IntPtr GetUnmanagedThunkForManagedMethodPtr (IntPtr pfnMethodToWrap, IntPtr pbSignature, int cbSignature) {
290 throw new NotImplementedException ();
294 public static bool IsComObject (object o) {
295 throw new NotImplementedException ();
299 public static bool IsTypeVisibleFromCom (Type t) {
300 throw new NotImplementedException ();
304 public static int NumParamBytes (MethodInfo m) {
305 throw new NotImplementedException ();
308 [MethodImplAttribute(MethodImplOptions.InternalCall)]
309 public extern static IntPtr OffsetOf (Type t, string fieldName);
311 [MethodImplAttribute(MethodImplOptions.InternalCall)]
312 public extern static void Prelink (MethodInfo m);
314 [MethodImplAttribute(MethodImplOptions.InternalCall)]
315 public extern static void PrelinkAll (Type c);
317 [MethodImplAttribute(MethodImplOptions.InternalCall)]
318 public extern static string PtrToStringAnsi (IntPtr ptr);
320 [MethodImplAttribute(MethodImplOptions.InternalCall)]
321 public extern static string PtrToStringAnsi (IntPtr ptr, int len);
323 [MethodImplAttribute(MethodImplOptions.InternalCall)]
324 public extern static string PtrToStringAuto (IntPtr ptr);
326 [MethodImplAttribute(MethodImplOptions.InternalCall)]
327 public extern static string PtrToStringAuto (IntPtr ptr, int len);
329 [MethodImplAttribute(MethodImplOptions.InternalCall)]
330 public extern static string PtrToStringUni (IntPtr ptr);
332 [MethodImplAttribute(MethodImplOptions.InternalCall)]
333 public extern static string PtrToStringUni (IntPtr ptr, int len);
335 [MethodImplAttribute(MethodImplOptions.InternalCall)]
336 public extern static string PtrToStringBSTR (IntPtr ptr);
338 [MethodImplAttribute(MethodImplOptions.InternalCall)]
339 public extern static void PtrToStructure (IntPtr ptr, object structure);
341 [MethodImplAttribute(MethodImplOptions.InternalCall)]
342 public extern static object PtrToStructure (IntPtr ptr, Type structureType);
345 public static int QueryInterface (IntPtr pUnk, ref Guid iid, out IntPtr ppv) {
346 throw new NotImplementedException ();
349 public static byte ReadByte (IntPtr ptr) {
350 return ReadByte (ptr, 0);
353 [MethodImplAttribute(MethodImplOptions.InternalCall)]
354 public extern static byte ReadByte (IntPtr ptr, int ofs);
357 public static byte ReadByte ([In] object ptr, int ofs) {
358 throw new NotImplementedException ();
361 public static short ReadInt16 (IntPtr ptr) {
362 return ReadInt16 (ptr, 0);
365 [MethodImplAttribute(MethodImplOptions.InternalCall)]
366 public extern static short ReadInt16 (IntPtr ptr, int ofs);
369 public static short ReadInt16 ([In] object ptr, int ofs) {
370 throw new NotImplementedException ();
373 public static int ReadInt32 (IntPtr ptr) {
374 return ReadInt32 (ptr, 0);
377 [MethodImplAttribute(MethodImplOptions.InternalCall)]
378 public extern static int ReadInt32 (IntPtr ptr, int ofs);
381 public static int ReadInt32 ([In] object ptr, int ofs) {
382 throw new NotImplementedException ();
385 public static long ReadInt64 (IntPtr ptr) {
386 return ReadInt64 (ptr, 0);
389 [MethodImplAttribute(MethodImplOptions.InternalCall)]
390 public extern static long ReadInt64 (IntPtr ptr, int ofs);
393 public static long ReadInt64(object ptr, int ofs) {
394 throw new NotImplementedException ();
397 public static IntPtr ReadIntPtr (IntPtr ptr) {
398 return ReadIntPtr (ptr, 0);
401 [MethodImplAttribute(MethodImplOptions.InternalCall)]
402 public extern static IntPtr ReadIntPtr (IntPtr ptr, int ofs);
405 public static IntPtr ReadIntPtr(object ptr, int ofs) {
406 throw new NotImplementedException ();
410 public static IntPtr ReAllocCoTaskMem (IntPtr pv, int cb) {
411 throw new NotImplementedException ();
414 [MethodImplAttribute(MethodImplOptions.InternalCall)]
415 public extern static IntPtr ReAllocHGlobal (IntPtr pv, IntPtr cb);
418 public static int Release (IntPtr pUnk) {
419 throw new NotImplementedException ();
423 public static int ReleaseComObject (object o) {
424 throw new NotImplementedException ();
428 public static void ReleaseThreadCache() {
429 throw new NotImplementedException ();
433 public static bool SetComObjectData (object obj, object key, object data) {
434 throw new NotImplementedException ();
437 public static int SizeOf (object structure) {
438 return SizeOf (structure.GetType ());
441 [MethodImplAttribute(MethodImplOptions.InternalCall)]
442 public extern static int SizeOf (Type t);
445 public static IntPtr StringToBSTR (string s) {
446 throw new NotImplementedException ();
450 public static IntPtr StringToCoTaskMemAnsi (string s) {
451 throw new NotImplementedException ();
455 public static IntPtr StringToCoTaskMemAuto (string s) {
456 throw new NotImplementedException ();
460 public static IntPtr StringToCoTaskMemUni (string s) {
461 throw new NotImplementedException ();
464 [MethodImplAttribute(MethodImplOptions.InternalCall)]
465 public extern static IntPtr StringToHGlobalAnsi (string s);
467 [MethodImplAttribute(MethodImplOptions.InternalCall)]
468 public extern static IntPtr StringToHGlobalAuto (string s);
470 [MethodImplAttribute(MethodImplOptions.InternalCall)]
471 public extern static IntPtr StringToHGlobalUni (string s);
473 [MethodImplAttribute(MethodImplOptions.InternalCall)]
474 public extern static void StructureToPtr (object structure, IntPtr ptr, bool fDeleteOld);
477 public static void ThrowExceptionForHR (int errorCode) {
478 throw new NotImplementedException ();
482 public static void ThrowExceptionForHR (int errorCode, IntPtr errorInfo) {
483 throw new NotImplementedException ();
487 public static IntPtr UnsafeAddrOfPinnedArrayElement (Array arr, int index) {
488 throw new NotImplementedException ();
491 public static void WriteByte (IntPtr ptr, byte val) {
492 WriteByte (ptr, 0, val);
495 [MethodImplAttribute(MethodImplOptions.InternalCall)]
496 public extern static void WriteByte (IntPtr ptr, int ofs, byte val);
499 public static void WriteByte([In,Out] object ptr, int ofs, byte val) {
500 throw new NotImplementedException ();
503 public static void WriteInt16 (IntPtr ptr, short val) {
504 WriteInt16 (ptr, 0, val);
507 [MethodImplAttribute(MethodImplOptions.InternalCall)]
508 public extern static void WriteInt16 (IntPtr ptr, int ofs, short val);
511 public static void WriteInt16([In,Out] object ptr, int ofs, short val) {
512 throw new NotImplementedException ();
515 public static void WriteInt32 (IntPtr ptr, int val) {
516 WriteInt32 (ptr, 0, val);
519 [MethodImplAttribute(MethodImplOptions.InternalCall)]
520 public extern static void WriteInt32 (IntPtr ptr, int ofs, int val);
523 public static void WriteInt32([In,Out] object ptr, int ofs, int val) {
524 throw new NotImplementedException ();
527 public static void WriteInt64 (IntPtr ptr, long val) {
528 WriteInt64 (ptr, 0, val);
531 [MethodImplAttribute(MethodImplOptions.InternalCall)]
532 public extern static void WriteInt64 (IntPtr ptr, int ofs, long val);
535 public static void WriteInt64(object ptr, int ofs, long val) {
536 throw new NotImplementedException ();
539 public static void WriteIntPtr (IntPtr ptr, IntPtr val) {
540 WriteIntPtr (ptr, 0, val);
543 [MethodImplAttribute(MethodImplOptions.InternalCall)]
544 public extern static void WriteIntPtr (IntPtr ptr, int ofs, IntPtr val);
547 public static void WriteIntPtr(object ptr, int ofs, IntPtr val) {
548 throw new NotImplementedException ();