public static IntPtr AllocHGlobal(IntPtr cb) { IntPtr pNewMem = Win32Native.LocalAlloc(LMEM_FIXED, cb); if (pNewMem == Win32Native.NULL) { throw new OutOfMemoryException(); } return(pNewMem); }