Example #1
0
 /// <summary>
 /// Allocates unmanaged memory.
 /// </summary>
 /// <param name="cb">The number of bytes in memory required. </param>
 /// <returns>An IntPtr to the newly allocated memory. This memory must be released using the Marshal.FreeHGlobal method.</returns>
 public static IntPtr AllocHGlobal(IntPtr cb)
 {
     return(MarshalEx.AllocHGlobal((int)cb));
 }
Example #2
0
 /// <summary>
 /// Writes an IntPtr value to unmanaged memory.
 /// </summary>
 /// <param name="ptr">The address in unmanaged memory from which to write. </param>
 /// <param name="ofs">The offset of the IntPtr from the ptr.</param>
 /// <param name="val">The value to write. </param>
 public static void WriteIntPtr(IntPtr ptr, int ofs, IntPtr val)
 {
     MarshalEx.WriteInt32(ptr, ofs, val.ToInt32());
 }