- use own version of GdiQueryTable() instead of relying on gdi32.dll

- CrateFont -> CreateFontA
- A bunch of tests for SelectObject

svn path=/trunk/; revision=31225
This commit is contained in:
Timo Kreuzer
2007-12-15 04:22:19 +00:00
parent de6ac22db5
commit 5f55fe95c7
5 changed files with 167 additions and 15 deletions
+16 -6
View File
@@ -128,7 +128,11 @@ typedef struct
ULONG ulForegroundClr;
#if (_WIN32_WINNT >= 0x0500)
unsigned unk020_00000000[4]; // 020
COLORREF crBrushClr; // 020
ULONG ulBrushClr;
COLORREF crPenClr;
ULONG ulPenClr;
#endif
int iCS_CP; // 030
int iGraphicsMode;
@@ -149,10 +153,10 @@ typedef struct
long lIcmMode;
unsigned hcmXform; // 060
HCOLORSPACE hColorSpace;
unsigned unk068_00000000;
FLONG flIcmFlags;
unsigned IcmBrushColor;
unsigned IcmPenColor; // 070
unsigned unk074_00000000;
PVOID pvLIcm;
#endif
long flTextAlign; // 078
@@ -167,7 +171,10 @@ typedef struct
MATRIX mxDeviceToWorld; // 0D0
MATRIX mxWorldToPage; // 10C
unsigned unk048_00000000[8]; // 148
EFLOAT_S efM11PtoD;
EFLOAT_S efM22PtoD;
EFLOAT_S efDxPtoD;
EFLOAT_S efDyPtoD;
int iMapMode; // 168
@@ -186,8 +193,11 @@ typedef struct
POINT ptlBrushOrigin; // 1a8
unsigned unk1b0_00000000[2]; // 1b0
unsigned RectRegionFlag; // 1b4
RECT VisRectRegion; // 1b8
RGNATTR VisRectRegion;
// unsigned unk1b0_00000000[2]; // 1b0
// unsigned RectRegionFlag; // 1b4
// RECT VisRectRegion; // 1b8
} DC_ATTR, *PDC_ATTR;
+10 -8
View File
@@ -9,22 +9,24 @@ IsFunctionPresent(LPWSTR lpszFunction)
return TRUE;
}
static
PGDI_TABLE_ENTRY
MyGdiQueryTable()
{
PTEB pTeb = NtCurrentTeb();
PPEB pPeb = pTeb->ProcessEnvironmentBlock;
return pPeb->GdiSharedHandleTable;
}
int APIENTRY
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
GDIQUERYPROC GdiQueryTable;
g_hInstance = hInstance;
GdiQueryTable = (GDIQUERYPROC)GetProcAddress(GetModuleHandleW(L"GDI32.DLL"), "GdiQueryTable");
if(!GdiQueryTable)
{
return -1;
}
GdiHandleTable = GdiQueryTable();
GdiHandleTable = MyGdiQueryTable();
if(!GdiHandleTable)
{
return -1;
+4
View File
@@ -1,6 +1,10 @@
#ifndef _GDITEST_H
#define _GDITEST_H
#define WIN32_NO_STATUS
#include <windows.h>
#include <ndk/ntndk.h>
#include "../apitest.h"
#include "gdi.h"
+1 -1
View File
@@ -308,7 +308,7 @@ Test_Font(PTESTINFO pti)
BYTE bData[270];
FillMemory(&logfonta, sizeof(LOGFONTA), 0x77);
hFont = CreateFont(8, 8, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
hFont = CreateFontA(8, 8, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS,
ANTIALIASED_QUALITY, DEFAULT_PITCH, "testfont");
TEST(hFont);
@@ -1,6 +1,142 @@
INT
Test_SelectObject(PTESTINFO pti)
{
HGDIOBJ hOldObj, hNewObj;
HDC hScreenDC, hDC;
PGDI_TABLE_ENTRY pEntry;
PDC_ATTR pDc_Attr;
HANDLE hcmXform;
BYTE bmBits[4] = {0};
hScreenDC = GetDC(NULL);
ASSERT (hScreenDC != NULL);
hDC = CreateCompatibleDC(hScreenDC);
ASSERT (hDC != NULL);
/* Get the Dc_Attr for later testing */
pEntry = &GdiHandleTable[GDI_HANDLE_GET_INDEX(hDC)];
ASSERT(pEntry);
pDc_Attr = pEntry->UserData;
ASSERT(pDc_Attr);
/* Test incomplete dc handle doesn't work */
SetLastError(ERROR_SUCCESS);
hNewObj = GetStockObject(GRAY_BRUSH);
hOldObj = SelectObject((HDC)GDI_HANDLE_GET_INDEX(hDC), hNewObj);
TEST(GetLastError() == ERROR_INVALID_HANDLE);
TEST(hOldObj == NULL);
TEST(pDc_Attr->hbrush == GetStockObject(WHITE_BRUSH));
SelectObject(hDC, hOldObj);
/* Test incomplete hobj handle works */
hNewObj = GetStockObject(GRAY_BRUSH);
hOldObj = SelectObject(hDC, (HGDIOBJ)GDI_HANDLE_GET_INDEX(hNewObj));
TEST(hOldObj == GetStockObject(WHITE_BRUSH));
TEST(pDc_Attr->hbrush == hNewObj);
SelectObject(hDC, hOldObj);
/* Test wrong hobj handle type */
SetLastError(ERROR_SUCCESS);
hNewObj = GetStockObject(GRAY_BRUSH);
hNewObj = (HGDIOBJ)((UINT_PTR)hNewObj & ~GDI_HANDLE_TYPE_MASK);
hNewObj = (HGDIOBJ)((UINT_PTR)hNewObj | GDI_OBJECT_TYPE_PEN);
hOldObj = SelectObject(hDC, hNewObj);
TEST(GetLastError() == ERROR_SUCCESS);
TEST(hOldObj == NULL);
TEST(pDc_Attr->hbrush == GetStockObject(WHITE_BRUSH));
SetLastError(ERROR_SUCCESS);
hNewObj = (HGDIOBJ)0x00761234;
hOldObj = SelectObject(hDC, hNewObj);
TEST(hOldObj == NULL);
TEST(GetLastError() == ERROR_SUCCESS);
SelectObject(hDC, hOldObj);
/* Test DC */
SetLastError(ERROR_SUCCESS);
hOldObj = SelectObject(hDC, hScreenDC);
TEST(hOldObj == NULL);
TEST(GetLastError() == ERROR_SUCCESS);
/* Test REGION */
SetLastError(ERROR_SUCCESS);
hNewObj = CreateRectRgn(0,0,0,0);
hOldObj = SelectObject(hDC, hNewObj);
TEST((UINT_PTR)hOldObj == NULLREGION);
DeleteObject(hNewObj);
hNewObj = CreateRectRgn(0,0,10,10);
TEST((UINT_PTR)SelectObject(hDC, hNewObj) == SIMPLEREGION);
hOldObj = CreateRectRgn(5,5,20,20);
TEST(CombineRgn(hNewObj, hNewObj, hOldObj, RGN_OR) == COMPLEXREGION);
DeleteObject(hOldObj);
TEST((UINT_PTR)SelectObject(hDC, hNewObj) == SIMPLEREGION); // ??? Why this?
DeleteObject(hNewObj);
TEST(GetLastError() == ERROR_SUCCESS);
/* Test BITMAP */
hNewObj = CreateBitmap(2, 2, 1, 1, &bmBits);
ASSERT(hNewObj != NULL);
hOldObj = SelectObject(hDC, hNewObj);
TEST(GDI_HANDLE_GET_TYPE(hOldObj) == GDI_OBJECT_TYPE_BITMAP);
hOldObj = SelectObject(hDC, hOldObj);
TEST(hOldObj == hNewObj);
/* Test CLIOBJ */
/* Test PATH */
/* Test PALETTE */
SetLastError(ERROR_SUCCESS);
hNewObj = GetStockObject(DEFAULT_PALETTE);
hOldObj = SelectObject(hDC, hNewObj);
TEST(hOldObj == NULL);
TEST(GetLastError() == ERROR_INVALID_FUNCTION);
/* Test COLORSPACE */
/* Test FONT */
/* Test PFE */
/* Test BRUSH */
hNewObj = GetStockObject(GRAY_BRUSH);
hOldObj = SelectObject(hDC, hNewObj);
TEST(hOldObj == GetStockObject(WHITE_BRUSH));
TEST(pDc_Attr->hbrush == hNewObj);
TEST(GDI_HANDLE_GET_TYPE(hOldObj) == GDI_OBJECT_TYPE_BRUSH);
SelectObject(hDC, hOldObj);
/* Test DC_BRUSH */
hNewObj = GetStockObject(DC_BRUSH);
hOldObj = SelectObject(hDC, hNewObj);
TEST(pDc_Attr->hbrush == hNewObj);
SelectObject(hDC, hOldObj);
/* Test BRUSH color xform */
hcmXform = (HANDLE)pDc_Attr->hcmXform;
/* Test EMF */
/* test METAFILE */
/* Test ENHMETAFILE */
/* Test PEN */
hNewObj = GetStockObject(GRAY_BRUSH);
hOldObj = SelectObject(hDC, hNewObj);
TEST(hOldObj == GetStockObject(WHITE_BRUSH));
TEST(pDc_Attr->hbrush == hNewObj);
TEST(GDI_HANDLE_GET_TYPE(hOldObj) == GDI_OBJECT_TYPE_BRUSH);
SelectObject(hDC, hOldObj);
/* Test EXTPEN */
/* Test METADC */
return APISTATUS_NORMAL;
}