From 02258e7e3901148df5acb94251184acfeb1e1600 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Sat, 28 Mar 2009 17:06:17 +0000 Subject: [PATCH] - Remove a header structure from memory regions allocated with EngAllocUserMem. Modern versions of Windows (at least XP and higher) don't do this and instead save this information elsewhere. Confirmed by Alexandre Julliard's test case for calling WriteFile with the DIB section bits as buffer (5 less failures now) and by arguing with Evgeniy Boltik. svn path=/trunk/; revision=40269 --- reactos/subsystems/win32/win32k/eng/mem.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/reactos/subsystems/win32/win32k/eng/mem.c b/reactos/subsystems/win32/win32k/eng/mem.c index 0583f58d0e3..e7aec7ef1d9 100644 --- a/reactos/subsystems/win32/win32k/eng/mem.c +++ b/reactos/subsystems/win32/win32k/eng/mem.c @@ -32,13 +32,6 @@ #define NDEBUG #include -typedef struct _USERMEMHEADER - { - ULONG Tag; - ULONG MemSize; - } -USERMEMHEADER, *PUSERMEMHEADER; - /* * @implemented */ @@ -76,8 +69,7 @@ EngAllocUserMem(SIZE_T cj, ULONG Tag) { PVOID NewMem = NULL; NTSTATUS Status; - SIZE_T MemSize = sizeof(USERMEMHEADER) + cj; - PUSERMEMHEADER Header; + SIZE_T MemSize = cj; Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &NewMem, 0, &MemSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); @@ -86,11 +78,9 @@ EngAllocUserMem(SIZE_T cj, ULONG Tag) return NULL; } - Header = (PUSERMEMHEADER) NewMem; - Header->Tag = Tag; - Header->MemSize = cj; + /* TODO: Add allocation info to AVL tree (stored inside W32PROCESS structure) */ - return (PVOID)(Header + 1); + return NewMem; } /* @@ -99,10 +89,12 @@ EngAllocUserMem(SIZE_T cj, ULONG Tag) VOID APIENTRY EngFreeUserMem(PVOID pv) { - PUSERMEMHEADER Header = ((PUSERMEMHEADER) pv) - 1; + PVOID BaseAddress = pv; SIZE_T MemSize = 0; - ZwFreeVirtualMemory(NtCurrentProcess(), (PVOID *) &Header, &MemSize, MEM_RELEASE); + ZwFreeVirtualMemory(NtCurrentProcess(), &BaseAddress, &MemSize, MEM_RELEASE); + + /* TODO: Remove allocation info from AVL tree */ }