mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 21:46:05 +00:00
- Fix implementation of RtlSetUserValueHeap and RtlGetUserInfoHeap to write their flags to the subheap and not the actual main heap structure (since those flags are valid for each allocation).
- Make heap allocations 8-byte aligned again. svn path=/trunk/; revision=22576
This commit is contained in:
parent
d3cd587e70
commit
ccde4e5475
1 changed files with 21 additions and 5 deletions
|
@ -87,6 +87,8 @@ typedef struct tagSUBHEAP
|
||||||
struct tagSUBHEAP *next; /* Next sub-heap */
|
struct tagSUBHEAP *next; /* Next sub-heap */
|
||||||
struct tagHEAP *heap; /* Main heap structure */
|
struct tagHEAP *heap; /* Main heap structure */
|
||||||
ULONG magic; /* Magic number */
|
ULONG magic; /* Magic number */
|
||||||
|
ULONG UserFlags;
|
||||||
|
PVOID UserValue;
|
||||||
}
|
}
|
||||||
SUBHEAP, *PSUBHEAP;
|
SUBHEAP, *PSUBHEAP;
|
||||||
|
|
||||||
|
@ -100,7 +102,6 @@ typedef struct tagHEAP
|
||||||
RTL_CRITICAL_SECTION critSection; /* Critical section for serialization */
|
RTL_CRITICAL_SECTION critSection; /* Critical section for serialization */
|
||||||
ULONG flags; /* Heap flags */
|
ULONG flags; /* Heap flags */
|
||||||
ULONG magic; /* Magic number */
|
ULONG magic; /* Magic number */
|
||||||
PVOID UserValue;
|
|
||||||
PRTL_HEAP_COMMIT_ROUTINE commitRoutine;
|
PRTL_HEAP_COMMIT_ROUTINE commitRoutine;
|
||||||
}
|
}
|
||||||
HEAP, *PHEAP;
|
HEAP, *PHEAP;
|
||||||
|
@ -1250,6 +1251,9 @@ RtlAllocateHeap(HANDLE heap, /* [in] Handle of private heap block */
|
||||||
pInUse->threadId = (ULONG)NtCurrentTeb()->Cid.UniqueThread;
|
pInUse->threadId = (ULONG)NtCurrentTeb()->Cid.UniqueThread;
|
||||||
pInUse->magic = ARENA_INUSE_MAGIC;
|
pInUse->magic = ARENA_INUSE_MAGIC;
|
||||||
|
|
||||||
|
/* Save user flags */
|
||||||
|
subheap->UserFlags = flags & HEAP_SETTABLE_USER_FLAGS;
|
||||||
|
|
||||||
/* Shrink the block */
|
/* Shrink the block */
|
||||||
|
|
||||||
HEAP_ShrinkBlock( subheap, pInUse, size );
|
HEAP_ShrinkBlock( subheap, pInUse, size );
|
||||||
|
@ -1262,7 +1266,7 @@ RtlAllocateHeap(HANDLE heap, /* [in] Handle of private heap block */
|
||||||
if (!(flags & HEAP_NO_SERIALIZE))
|
if (!(flags & HEAP_NO_SERIALIZE))
|
||||||
RtlLeaveHeapLock( &heapPtr->critSection );
|
RtlLeaveHeapLock( &heapPtr->critSection );
|
||||||
|
|
||||||
DPRINT("(%p,%08lx,%08lx): returning %p\n",
|
DPRINT1("(%p,%08lx,%08lx): returning %p\n",
|
||||||
heap, flags, size, (PVOID)(pInUse + 1) );
|
heap, flags, size, (PVOID)(pInUse + 1) );
|
||||||
return (PVOID)(pInUse + 1);
|
return (PVOID)(pInUse + 1);
|
||||||
}
|
}
|
||||||
|
@ -1855,9 +1859,15 @@ RtlSetUserValueHeap(IN PVOID HeapHandle,
|
||||||
IN PVOID UserValue)
|
IN PVOID UserValue)
|
||||||
{
|
{
|
||||||
HEAP *heapPtr = HEAP_GetPtr(HeapHandle);
|
HEAP *heapPtr = HEAP_GetPtr(HeapHandle);
|
||||||
|
ARENA_INUSE *pInUse;
|
||||||
|
SUBHEAP *subheap;
|
||||||
|
|
||||||
|
/* Get the subheap */
|
||||||
|
pInUse = (ARENA_INUSE *)BaseAddress - 1;
|
||||||
|
subheap = HEAP_FindSubHeap( heapPtr, pInUse );
|
||||||
|
|
||||||
/* Hack */
|
/* Hack */
|
||||||
heapPtr->UserValue = UserValue;
|
subheap->UserValue = UserValue;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1873,10 +1883,16 @@ RtlGetUserInfoHeap(IN PVOID HeapHandle,
|
||||||
OUT PULONG UserFlags)
|
OUT PULONG UserFlags)
|
||||||
{
|
{
|
||||||
HEAP *heapPtr = HEAP_GetPtr(HeapHandle);
|
HEAP *heapPtr = HEAP_GetPtr(HeapHandle);
|
||||||
|
ARENA_INUSE *pInUse;
|
||||||
|
SUBHEAP *subheap;
|
||||||
|
|
||||||
|
/* Get the subheap */
|
||||||
|
pInUse = (ARENA_INUSE *)BaseAddress - 1;
|
||||||
|
subheap = HEAP_FindSubHeap( heapPtr, pInUse );
|
||||||
|
|
||||||
/* Hack */
|
/* Hack */
|
||||||
if (UserValue) *UserValue = heapPtr->UserValue;
|
if (UserValue) *UserValue = subheap->UserValue;
|
||||||
if (UserFlags) *UserFlags = heapPtr->flags & HEAP_SETTABLE_USER_FLAGS;
|
if (UserFlags) *UserFlags = subheap->UserFlags;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue