Example #1
0
 /// <summary>
 /// Changes the size or the attributes of a specified local memory object. The size can increase or decrease.
 /// </summary>
 /// <param name="hMem">A handle to the local memory object to be reallocated. This handle is returned by either the <see cref="LocalAlloc(LocalAllocFlags, IntPtr)"/> or <see cref="LocalReAlloc(void*, IntPtr, LocalReAllocFlags)"/> function.</param>
 /// <param name="uBytes">The new size of the memory block, in bytes. If uFlags specifies <see cref="LocalReAllocFlags.LMEM_MODIFY"/>, this parameter is ignored.</param>
 /// <param name="uFlags">
 /// The reallocation options. If <see cref="LocalReAllocFlags.LMEM_MODIFY"/> is specified, the function modifies the attributes of the memory object only (the uBytes parameter is ignored.) Otherwise, the function reallocates the memory object.
 /// </param>
 /// <returns>
 /// If the function succeeds, the return value is a handle to the reallocated memory object.
 /// If the function fails, the return value is NULL. To get extended error information, call <see cref="GetLastError"/>.
 /// </returns>
 /// <remarks>
 /// If LocalReAlloc fails, the original memory is not freed, and the original handle and pointer are still valid.
 /// If LocalReAlloc reallocates a fixed object, the value of the handle returned is the address of the first byte of the memory block. To access the memory, a process can simply cast the return value to a pointer.
 /// </remarks>
 public static unsafe void *LocalReAlloc(void *hMem, int uBytes, LocalReAllocFlags uFlags)
 {
     // The length of SIZE_T and IntPtr vary with the bitness of the process.
     // For convenience to callers we want to expose the size of a memory allocation
     // as an Int32 no matter the process bitness. So safely 'upscale' the Int32 to
     // the appropriate IntPtr and call the native overload.
     return(LocalReAlloc(hMem, new IntPtr(uBytes), uFlags));
 }
Example #2
0
 public static extern unsafe void* LocalReAlloc(void* hMem, IntPtr uBytes, LocalReAllocFlags uFlags);
Example #3
0
 /// <summary>
 /// Changes the size or the attributes of a specified local memory object. The size can increase or decrease.
 /// </summary>
 /// <param name="hMem">A handle to the local memory object to be reallocated. This handle is returned by either the <see cref="LocalAlloc(LocalAllocFlags, IntPtr)"/> or <see cref="LocalReAlloc(void*, IntPtr, LocalReAllocFlags)"/> function.</param>
 /// <param name="uBytes">The new size of the memory block, in bytes. If uFlags specifies <see cref="LocalReAllocFlags.LMEM_MODIFY"/>, this parameter is ignored.</param>
 /// <param name="uFlags">
 /// The reallocation options. If <see cref="LocalReAllocFlags.LMEM_MODIFY"/> is specified, the function modifies the attributes of the memory object only (the uBytes parameter is ignored.) Otherwise, the function reallocates the memory object.
 /// </param>
 /// <returns>
 /// If the function succeeds, the return value is a handle to the reallocated memory object.
 /// If the function fails, the return value is NULL. To get extended error information, call <see cref="GetLastError"/>.
 /// </returns>
 /// <remarks>
 /// If LocalReAlloc fails, the original memory is not freed, and the original handle and pointer are still valid.
 /// If LocalReAlloc reallocates a fixed object, the value of the handle returned is the address of the first byte of the memory block. To access the memory, a process can simply cast the return value to a pointer.
 /// </remarks>
 public static unsafe void* LocalReAlloc(void* hMem, int uBytes, LocalReAllocFlags uFlags)
 {
     // The length of SIZE_T and IntPtr vary with the bitness of the process.
     // For convenience to callers we want to expose the size of a memory allocation
     // as an Int32 no matter the process bitness. So safely 'upscale' the Int32 to
     // the appropriate IntPtr and call the native overload.
     return LocalReAlloc(hMem, new IntPtr(uBytes), uFlags);
 }