/// <summary>
        /// Allocate a buffer from the heap.
        /// </summary>
        /// <param name="flags">Heap flags.</param>
        /// <param name="size">Size of the allocation.</param>
        /// <returns>The allocated memory address.</returns>
        public long Allocate(HeapAllocFlags flags, long size)
        {
            long address = NtRtl.RtlAllocateHeap(_heap_handle, flags, new IntPtr(size)).ToInt64();

            if (address == 0)
            {
                throw new NtException(NtObjectUtils.MapDosErrorToStatus());
            }
            return(address);
        }
コード例 #2
0
        /// <summary>
        /// Allocate a buffer from the heap.
        /// </summary>
        /// <param name="flags">Heap flags.</param>
        /// <param name="size">Size of the allocation.</param>
        /// <param name="throw_on_error">True to throw on error.</param>
        /// <returns>The allocated memory address.</returns>
        public NtResult <long> Allocate(HeapAllocFlags flags, long size, bool throw_on_error)
        {
            long address = NtRtl.RtlAllocateHeap(_heap_handle, flags, new IntPtr(size)).ToInt64();

            if (address == 0)
            {
                return(NtObjectUtils.MapDosErrorToStatus().CreateResultFromError <long>(throw_on_error));
            }
            return(address.CreateResult());
        }