- Hax-implement NtGdiSetPixelFormat and add a support function UserGethWnd with some code cleanup.

svn path=/trunk/; revision=41250
This commit is contained in:
James Tabor
2009-06-02 06:50:36 +00:00
parent e640466446
commit cdacb4b6b5
4 changed files with 113 additions and 15 deletions
@@ -56,5 +56,6 @@ void FASTCALL DceFreeWindowDCE(PWINDOW_OBJECT Window);
void FASTCALL DceEmptyCache(void);
VOID FASTCALL DceResetActiveDCEs(PWINDOW_OBJECT Window);
void FASTCALL DceFreeClassDCE(HDC);
HWND FASTCALL UserGethWnd(HDC,PWNDOBJ*);
#endif /* _WIN32K_DCE_H */
@@ -1922,18 +1922,18 @@ NtUserDrawCaptionTemp(
ProbeForRead(lpRc, sizeof(RECTL), sizeof(ULONG));
RtlCopyMemory(&SafeRect, lpRc, sizeof(RECTL));
if (str != NULL)
{
SafeStr = ProbeForReadUnicodeString(str);
if (SafeStr.Length != 0)
{
ProbeForRead(SafeStr.Buffer,
SafeStr.Length,
sizeof(WCHAR));
}
Ret = UserDrawCaption(pWnd, hDC, &SafeRect, hFont, hIcon, &SafeStr, uFlags);
{
SafeStr = ProbeForReadUnicodeString(str);
if (SafeStr.Length != 0)
{
ProbeForRead( SafeStr.Buffer,
SafeStr.Length,
sizeof(WCHAR));
}
Ret = UserDrawCaption(pWnd, hDC, &SafeRect, hFont, hIcon, &SafeStr, uFlags);
}
else
Ret = UserDrawCaption(pWnd, hDC, &SafeRect, hFont, hIcon, NULL, uFlags);
else
Ret = UserDrawCaption(pWnd, hDC, &SafeRect, hFont, hIcon, NULL, uFlags);
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
@@ -866,6 +866,36 @@ UserGetWindowDC(PWINDOW_OBJECT Wnd)
return UserGetDCEx(Wnd, 0, DCX_USESTYLE | DCX_WINDOW);
}
HWND FASTCALL
UserGethWnd( HDC hdc, PWNDOBJ *pwndo)
{
PWNDGDI pWndgdi;
PWINDOW_OBJECT Wnd = NULL;
HWND hWnd;
BOOL Hit = FALSE;
PLIST_ENTRY Entry;
hWnd = IntWindowFromDC(hdc);
if (hWnd && !(Wnd = UserGetWindowObject(hWnd)))
{
KeEnterCriticalRegion();
Entry = Wnd->WndObjListHead.Flink;
while (Entry != &Wnd->WndObjListHead)
{
pWndgdi = (PWNDGDI)Entry;
if (pWndgdi->Hwnd == hWnd)
{
Hit = TRUE;
break;
}
Entry = Entry->Flink;
}
if (pwndo && Hit) *pwndo = (PWNDOBJ)pWndgdi;
KeLeaveCriticalRegion();
}
return hWnd;
}
HDC APIENTRY
NtUserGetDCEx(HWND hWnd OPTIONAL, HANDLE ClipRegion, ULONG Flags)
{
@@ -38,7 +38,6 @@ IntGetipfdDevMax(PDC pdc)
if (ppdev->DriverFunctions.DescribePixelFormat)
{
Ret = ppdev->DriverFunctions.DescribePixelFormat(
ppdev->hPDev,
1,
@@ -94,7 +93,6 @@ NtGdiDescribePixelFormat(HDC hDC,
if (ppdev->DriverFunctions.DescribePixelFormat)
{
Ret = ppdev->DriverFunctions.DescribePixelFormat(
ppdev->hPDev,
PixelFormat,
@@ -129,8 +127,77 @@ NtGdiSetPixelFormat(
IN HDC hdc,
IN INT ipfd)
{
UNIMPLEMENTED;
return FALSE;
PDC pdc;
PPDEVOBJ ppdev;
HWND hWnd;
PWNDOBJ pWndObj;
SURFOBJ *pso = NULL;
BOOL Ret = FALSE;
pdc = DC_LockDc(hdc);
if (!pdc)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE;
}
if (!pdc->ipfdDevMax) IntGetipfdDevMax(pdc);
if ( ipfd < 1 ||
ipfd > pdc->ipfdDevMax )
{
SetLastWin32Error(ERROR_INVALID_PARAMETER);
goto Exit;
}
UserEnterExclusive();
hWnd = UserGethWnd(hdc, &pWndObj);
UserLeave();
if (!hWnd)
{
SetLastWin32Error(ERROR_INVALID_WINDOW_STYLE);
goto Exit;
}
ppdev = pdc->ppdev;
if (pWndObj) pso = pWndObj->psoOwner;
else
{
SetLastWin32Error(ERROR_INVALID_PIXEL_FORMAT);
goto Exit;
}
if (!pso)
{
/*
Based on some rules! InfoDC to DC or, based on wiki information!
All pointers, it's a "must be!", (CONTAINING_RECORD +10h = SURFOBJ), the
pointer will start at SURFOBJ of the SURFACE structure.
*/
pso = (SURFOBJ *)pdc->dclevel.pSurface;
if (!pso) pso = pdc->pSurfInfo;
if (!pso) pso = ppdev->pSurface;
}
if (ppdev->flFlags & PDEV_META_DEVICE)
{
UNIMPLEMENTED;
goto Exit;
}
if (ppdev->DriverFunctions.SetPixelFormat)
{
Ret = ppdev->DriverFunctions.SetPixelFormat(
pso,
ipfd,
hWnd);
}
Exit:
DC_UnlockDc(pdc);
return Ret;
}
BOOL