diff --git a/reactos/dll/win32/gdi32/include/gdi32p.h b/reactos/dll/win32/gdi32/include/gdi32p.h index 2f34eebe84d..aa018341e8b 100644 --- a/reactos/dll/win32/gdi32/include/gdi32p.h +++ b/reactos/dll/win32/gdi32/include/gdi32p.h @@ -114,6 +114,10 @@ GdiGetHandleUserData( PLDC GdiGetLDC(HDC hDC); +HGDIOBJ +STDCALL +GdiFixUpHandle(HGDIOBJ hGO); + BOOL WINAPI CalculateColorTableSize( diff --git a/reactos/dll/win32/gdi32/misc/misc.c b/reactos/dll/win32/gdi32/misc/misc.c index bef5120eeed..0c696ae35bb 100644 --- a/reactos/dll/win32/gdi32/misc/misc.c +++ b/reactos/dll/win32/gdi32/misc/misc.c @@ -32,6 +32,20 @@ PGDI_TABLE_ENTRY GdiHandleTable = NULL; HANDLE CurrentProcessId = NULL; DWORD GDI_BatchLimit = 1; + +/* + * @implemented + */ +HGDIOBJ +STDCALL +GdiFixUpHandle(HGDIOBJ hGdiObj) +{ + if (((ULONG_PTR)(hGdiObj)) & GDI_HANDLE_UPPER_MASK ) return hGdiObj; + PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_TO_ENTRY(hGdiObj); + return hGdiObj = (HGDIOBJ)(((LONG_PTR)(hGdiObj)) | + (Entry->Type << 16)); // Rebuild handle for Object +} + /* * @implemented */ @@ -44,7 +58,7 @@ GdiQueryTable(VOID) BOOL GdiIsHandleValid(HGDIOBJ hGdiObj) { - PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hGdiObj); + PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_TO_ENTRY(hGdiObj); if(Entry->KernelData != NULL && (Entry->Type & GDI_HANDLE_TYPE_MASK) == (LONG)GDI_HANDLE_GET_TYPE(hGdiObj)) { HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1); @@ -58,7 +72,7 @@ BOOL GdiIsHandleValid(HGDIOBJ hGdiObj) BOOL GdiGetHandleUserData(HGDIOBJ hGdiObj, PVOID *UserData) { - PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hGdiObj); + PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_TO_ENTRY(hGdiObj); if(Entry->KernelData != NULL && (Entry->Type & GDI_HANDLE_TYPE_MASK) == (LONG)GDI_HANDLE_GET_TYPE(hGdiObj)) { HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1); @@ -103,3 +117,5 @@ GdiGetBatchLimit() { return GDI_BatchLimit; } + + diff --git a/reactos/include/reactos/win32k/ntgdihdl.h b/reactos/include/reactos/win32k/ntgdihdl.h index edeab978796..eb3cf345cf6 100644 --- a/reactos/include/reactos/win32k/ntgdihdl.h +++ b/reactos/include/reactos/win32k/ntgdihdl.h @@ -25,6 +25,7 @@ #define GDI_HANDLE_TYPE_MASK 0x007f0000 #define GDI_HANDLE_STOCK_MASK 0x00800000 #define GDI_HANDLE_REUSE_MASK 0xff000000 +#define GDI_HANDLE_UPPER_MASK (GDI_HANDLE_TYPE_MASK|GDI_HANDLE_STOCK_MASK|GDI_HANDLE_REUSE_MASK) #define GDI_HANDLE_REUSECNT_SHIFT 24 /*! \defgroup GDI object types @@ -106,6 +107,11 @@ typedef struct _GDI_TABLE_ENTRY PVOID UserData; /* Points to the user mode structure, usually NULL though */ } GDI_TABLE_ENTRY, *PGDI_TABLE_ENTRY; + +#define GDI_HANDLE_TO_ENTRY(h) \ + ((((ULONG_PTR)(h)) & GDI_HANDLE_INDEX_MASK) * sizeof(GDI_TABLE_ENTRY)) + + typedef struct _RGNATTR { ULONG AttrFlags;