public override unsafe void *Reallocate(void *pointer, int elementCount, int elementSize = 1, bool initMemory = true) { if (pointer == null) { throw new ArgumentException("Invalid pointer"); } if (elementCount <= 0) { throw new ArgumentException(elementCount.ToString(), nameof(elementCount)); } if (elementSize <= 0) { throw new ArgumentException(elementSize.ToString(), nameof(elementSize)); } LocalMemoryFlags flags = initMemory ? LocalMemoryFlags.LMEM_MOVEABLE | LocalMemoryFlags.LMEM_ZEROINIT : LocalMemoryFlags.LMEM_MOVEABLE; void * newPointer = Kernel32LocalMemory.LocalReAlloc(pointer, (uint)(elementCount * elementSize), flags); if (newPointer == null) { Console.WriteLine(Marshal.GetLastWin32Error()); throw new OutOfMemoryException(); } return(newPointer); }
public override unsafe void *Allocate(int elementCount, int elementSize = 1, bool initMemory = true) { if (elementCount <= 0) { throw new ArgumentException(elementCount.ToString(), nameof(elementCount)); } if (elementSize <= 0) { throw new ArgumentException(elementSize.ToString(), nameof(elementSize)); } LocalMemoryFlags flags = initMemory? LocalMemoryFlags.LPTR: LocalMemoryFlags.LMEM_FIXED; void * pointer = Kernel32LocalMemory.LocalAlloc(flags, (uint)(elementCount * elementSize)); if (pointer == null) { throw new OutOfMemoryException(); } return(pointer); }
internal static extern SecurityIdentifierSafePtr AllocSecurityIdentifier(LocalMemoryFlags localMemFlags, uint uBytes);
internal static extern SecurityDescriptorSafePtr AllocSecurityDescriptor(LocalMemoryFlags localMemFlags, uint uBytes);
internal static extern LocalAllocSafePtr LocalAlloc(LocalMemoryFlags localMemFlags, uint uBytes);
public static extern IntPtr LocalAlloc(LocalMemoryFlags flag, UIntPtr size);
public static extern void *LocalReAlloc(void *pointer, uint totalBytes, LocalMemoryFlags flags);
public static extern void *LocalAlloc(LocalMemoryFlags flags, uint totalBytes);
public static extern IntPtr LocalReAlloc(IntPtr hMem, uint uBytes, [MarshalAs(UnmanagedType.U4)] LocalMemoryFlags uFlags);