From 291012914db01c3f07d03bdb6052cec76d1d4fc0 Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Sat, 26 Mar 2011 15:24:05 +0000 Subject: [PATCH] [GDI32] Fix gdi32:CreatePen apitest svn path=/trunk/; revision=51161 --- reactos/dll/win32/gdi32/misc/misc.c | 46 ++++++++++------------------- 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/reactos/dll/win32/gdi32/misc/misc.c b/reactos/dll/win32/gdi32/misc/misc.c index 408a658d72e..8fedb8fb820 100644 --- a/reactos/dll/win32/gdi32/misc/misc.c +++ b/reactos/dll/win32/gdi32/misc/misc.c @@ -124,38 +124,24 @@ BOOL GdiIsHandleValid(HGDIOBJ hGdiObj) BOOL GdiGetHandleUserData(HGDIOBJ hGdiObj, DWORD ObjectType, PVOID *UserData) { PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hGdiObj); - if((Entry->Type & GDI_ENTRY_BASETYPE_MASK) == ObjectType && - ( (Entry->Type << GDI_ENTRY_UPPER_SHIFT) & GDI_HANDLE_TYPE_MASK ) == - GDI_HANDLE_GET_TYPE(hGdiObj)) + + /* Check if twe have the correct type */ + if (GDI_HANDLE_GET_TYPE(hGdiObj) != ObjectType || + ((Entry->Type << GDI_ENTRY_UPPER_SHIFT) & GDI_HANDLE_TYPE_MASK) != ObjectType || + (Entry->Type & GDI_ENTRY_BASETYPE_MASK) != (ObjectType & GDI_ENTRY_BASETYPE_MASK)) { - HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1); - if(pid == NULL || pid == CurrentProcessId) - { - // - // Need to test if we have Read & Write access to the VM address space. - // - BOOL Result = TRUE; - if(Entry->UserData) - { - volatile CHAR *Current = (volatile CHAR*)Entry->UserData; - _SEH2_TRY - { - *Current = *Current; - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - Result = FALSE; - } - _SEH2_END - } - else - Result = FALSE; // Can not be zero. - if (Result) *UserData = Entry->UserData; - return Result; - } + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; } - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; + + /* Check if we are the owner */ + if ((HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1) != CurrentProcessId) + { + return FALSE; + } + + *UserData = Entry->UserData; + return TRUE; } PLDC -- 2.17.1