From 07eb7f5d694383696da0c86bf7a0a4319ae02285 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 15 Dec 2007 04:35:16 +0000 Subject: [PATCH] - use own version of GdiQueryTable() instead of relying on gdi32.dll - more tests for NtGdiGetDIBitsInternal svn path=/trunk/; revision=31226 --- .../apitests/w32knapi/ntgdi/NtGdiGetDIBits.c | 80 ++++++++++++++++--- rostests/apitests/w32knapi/w32knapi.c | 17 ++-- rostests/apitests/w32knapi/w32knapi.h | 2 - 3 files changed, 80 insertions(+), 19 deletions(-) diff --git a/rostests/apitests/w32knapi/ntgdi/NtGdiGetDIBits.c b/rostests/apitests/w32knapi/ntgdi/NtGdiGetDIBits.c index 6718bb9a17a..3c93677703e 100644 --- a/rostests/apitests/w32knapi/ntgdi/NtGdiGetDIBits.c +++ b/rostests/apitests/w32knapi/ntgdi/NtGdiGetDIBits.c @@ -26,8 +26,15 @@ INT Test_NtGdiGetDIBitsInternal(PTESTINFO pti) { HBITMAP hBitmap; - BITMAPINFO bi; + struct + { + BITMAPINFO bi; + RGBQUAD Colors[20]; + } bmp; +// BITMAPINFO bi; INT ScreenBpp; + BITMAPCOREINFO bic; + DWORD data[20*16]; HDC hDCScreen = GetDC(NULL); ASSERT(hDCScreen != NULL); @@ -48,21 +55,74 @@ Test_NtGdiGetDIBitsInternal(PTESTINFO pti) RTEST(GetLastError() == ERROR_SUCCESS); SetLastError(ERROR_SUCCESS); - RTEST(NtGdiGetDIBitsInternal((HDC)2345, hBitmap, 0, 15, NULL, &bi, 0, 0, 0) == 0); + RTEST(NtGdiGetDIBitsInternal(hDCScreen, hBitmap, 0, 0, NULL, NULL, 0, 0, 0) == 0); RTEST(GetLastError() == ERROR_SUCCESS); SetLastError(ERROR_SUCCESS); - ZeroMemory(&bi, sizeof(BITMAPINFO)); - bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - RTEST(NtGdiGetDIBitsInternal(hDCScreen, hBitmap, 0, 15, NULL, &bi, DIB_RGB_COLORS, - DIB_BitmapMaxBitsSize(&bi, 15), 0) > 0); + RTEST(NtGdiGetDIBitsInternal(hDCScreen, hBitmap, 0, 15, NULL, NULL, 0, 0, 0) == 0); + RTEST(GetLastError() == ERROR_SUCCESS); + + ZeroMemory(&bmp, sizeof(bmp)); + bmp.bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + FillMemory(&bmp.Colors, sizeof(bmp.Colors), 0x44); + + SetLastError(ERROR_SUCCESS); + RTEST(NtGdiGetDIBitsInternal((HDC)0, hBitmap, 0, 15, NULL, &bmp.bi, 0, 0, 0) > 0); + RTEST(GetLastError() == ERROR_SUCCESS); + TEST(bmp.Colors[0].rgbRed == 0x44); + + ZeroMemory(&bmp, sizeof(bmp)); + bmp.bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + FillMemory(&bmp.Colors, sizeof(bmp.Colors), 0x44); + + SetLastError(ERROR_SUCCESS); + RTEST(NtGdiGetDIBitsInternal((HDC)2345, hBitmap, 0, 15, NULL, &bmp.bi, 0, 0, 0) > 0); + RTEST(GetLastError() == ERROR_SUCCESS); + TEST(bmp.Colors[0].rgbRed == 0x44); + + ZeroMemory(&bmp, sizeof(bmp)); + bmp.bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + FillMemory(&bmp.Colors, sizeof(bmp.Colors), 0x44); + + SetLastError(ERROR_SUCCESS); + RTEST(NtGdiGetDIBitsInternal(hDCScreen, hBitmap, 0, 15, NULL, &bmp.bi, DIB_RGB_COLORS, + DIB_BitmapMaxBitsSize(&bmp.bi, 15), 0) > 0); RTEST(GetLastError() == ERROR_SUCCESS); ScreenBpp = GetDeviceCaps(hDCScreen, BITSPIXEL); - RTEST(bi.bmiHeader.biWidth == 16); - RTEST(bi.bmiHeader.biHeight == 16); - RTEST(bi.bmiHeader.biBitCount == ScreenBpp); - RTEST(bi.bmiHeader.biSizeImage == (16 * 16) * (ScreenBpp / 8)); + + RTEST(bmp.bi.bmiHeader.biWidth == 16); + RTEST(bmp.bi.bmiHeader.biHeight == 16); + RTEST(bmp.bi.bmiHeader.biBitCount == ScreenBpp); + RTEST(bmp.bi.bmiHeader.biSizeImage == (16 * 16) * (ScreenBpp / 8)); + + TEST(bmp.Colors[0].rgbRed == 0x44); + + /* Test with pointer */ +// ZeroMemory(&bmp.bi, sizeof(BITMAPINFO)); + bmp.bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); +// FillMemory(&bmp.Colors, sizeof(bmp.Colors), 0x11223344); + + SetLastError(ERROR_SUCCESS); + TEST(NtGdiGetDIBitsInternal(hDCScreen, hBitmap, 0, 15, (void*)data, &bmp.bi, DIB_RGB_COLORS, + DIB_BitmapMaxBitsSize(&bmp.bi, 15), 0) > 0); + RTEST(GetLastError() == ERROR_SUCCESS); + + RTEST(bmp.bi.bmiHeader.biWidth == 16); + RTEST(bmp.bi.bmiHeader.biHeight == 16); + RTEST(bmp.bi.bmiHeader.biBitCount == ScreenBpp); + RTEST(bmp.bi.bmiHeader.biSizeImage == (16 * 16) * (ScreenBpp / 8)); + + TEST(bmp.Colors[0].rgbRed != 0x44); + + /* Test a BITMAPCOREINFO structure */ + SetLastError(ERROR_SUCCESS); + ZeroMemory(&bic, sizeof(BITMAPCOREINFO)); + bic.bmciHeader.bcSize = sizeof(BITMAPCOREHEADER); + TEST(NtGdiGetDIBitsInternal(hDCScreen, hBitmap, 0, 15, NULL, (PBITMAPINFO)&bic, DIB_RGB_COLORS, + DIB_BitmapMaxBitsSize((PBITMAPINFO)&bic, 15), 0) > 0); + RTEST(GetLastError() == ERROR_SUCCESS); + ReleaseDC(NULL, hDCScreen); DeleteObject(hBitmap); diff --git a/rostests/apitests/w32knapi/w32knapi.c b/rostests/apitests/w32knapi/w32knapi.c index 864d5ba6b9f..a80d89716d5 100644 --- a/rostests/apitests/w32knapi/w32knapi.c +++ b/rostests/apitests/w32knapi/w32knapi.c @@ -4,6 +4,15 @@ HINSTANCE g_hInstance; HMODULE g_hModule = NULL; PGDI_TABLE_ENTRY GdiHandleTable; +static +PGDI_TABLE_ENTRY +MyGdiQueryTable() +{ + PTEB pTeb = NtCurrentTeb(); + PPEB pPeb = pTeb->ProcessEnvironmentBlock; + return pPeb->GdiSharedHandleTable; +} + static DWORD STDCALL IntSyscall(FARPROC proc, UINT cParams, PVOID pFirstParam) { @@ -59,7 +68,6 @@ WinMain(HINSTANCE hInstance, int nCmdShow) { g_hInstance = hInstance; - GDIQUERYPROC GdiQueryTable; printf("Win32k native API test\n"); @@ -73,12 +81,7 @@ WinMain(HINSTANCE hInstance, return -1; } - GdiQueryTable = (GDIQUERYPROC)GetProcAddress(GetModuleHandleW(L"GDI32.DLL"), "GdiQueryTable"); - if(!GdiQueryTable) - { - return -1; - } - GdiHandleTable = GdiQueryTable(); + GdiHandleTable = MyGdiQueryTable(); if(!GdiHandleTable) { return -1; diff --git a/rostests/apitests/w32knapi/w32knapi.h b/rostests/apitests/w32knapi/w32knapi.h index cf29efc94a5..247849483bb 100644 --- a/rostests/apitests/w32knapi/w32knapi.h +++ b/rostests/apitests/w32knapi/w32knapi.h @@ -32,8 +32,6 @@ typedef struct INT nParams; } SYCALL_ENTRY, *PSYSCALL_ENTRY; -typedef PGDI_TABLE_ENTRY (CALLBACK * GDIQUERYPROC) (void); - extern HINSTANCE g_hInstance; extern HMODULE g_hModule; extern PGDI_TABLE_ENTRY GdiHandleTable;