Author: tkreuzer Date: Sat Dec 15 07:35:16 2007 New Revision: 31226
URL: http://svn.reactos.org/svn/reactos?rev=31226&view=rev Log: - use own version of GdiQueryTable() instead of relying on gdi32.dll - more tests for NtGdiGetDIBitsInternal
Modified: trunk/rostests/apitests/w32knapi/ntgdi/NtGdiGetDIBits.c trunk/rostests/apitests/w32knapi/w32knapi.c trunk/rostests/apitests/w32knapi/w32knapi.h
Modified: trunk/rostests/apitests/w32knapi/ntgdi/NtGdiGetDIBits.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/w32knapi/ntgdi/Nt... ============================================================================== --- trunk/rostests/apitests/w32knapi/ntgdi/NtGdiGetDIBits.c (original) +++ trunk/rostests/apitests/w32knapi/ntgdi/NtGdiGetDIBits.c Sat Dec 15 07:35:16 2007 @@ -26,8 +26,15 @@ 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 @@ 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);
Modified: trunk/rostests/apitests/w32knapi/w32knapi.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/w32knapi/w32knapi... ============================================================================== --- trunk/rostests/apitests/w32knapi/w32knapi.c (original) +++ trunk/rostests/apitests/w32knapi/w32knapi.c Sat Dec 15 07:35:16 2007 @@ -3,6 +3,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 @@ int nCmdShow) { g_hInstance = hInstance; - GDIQUERYPROC GdiQueryTable;
printf("Win32k native API test\n");
@@ -73,12 +81,7 @@ return -1; }
- GdiQueryTable = (GDIQUERYPROC)GetProcAddress(GetModuleHandleW(L"GDI32.DLL"), "GdiQueryTable"); - if(!GdiQueryTable) - { - return -1; - } - GdiHandleTable = GdiQueryTable(); + GdiHandleTable = MyGdiQueryTable(); if(!GdiHandleTable) { return -1;
Modified: trunk/rostests/apitests/w32knapi/w32knapi.h URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/w32knapi/w32knapi... ============================================================================== --- trunk/rostests/apitests/w32knapi/w32knapi.h (original) +++ trunk/rostests/apitests/w32knapi/w32knapi.h Sat Dec 15 07:35:16 2007 @@ -32,8 +32,6 @@ 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;