mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 21:53:06 +00:00
- use own version of GdiQueryTable() instead of relying on gdi32.dll
- more tests for NtGdiGetDIBitsInternal svn path=/trunk/; revision=31226
This commit is contained in:
parent
5f55fe95c7
commit
07eb7f5d69
3 changed files with 80 additions and 19 deletions
|
@ -26,8 +26,15 @@ INT
|
||||||
Test_NtGdiGetDIBitsInternal(PTESTINFO pti)
|
Test_NtGdiGetDIBitsInternal(PTESTINFO pti)
|
||||||
{
|
{
|
||||||
HBITMAP hBitmap;
|
HBITMAP hBitmap;
|
||||||
BITMAPINFO bi;
|
struct
|
||||||
|
{
|
||||||
|
BITMAPINFO bi;
|
||||||
|
RGBQUAD Colors[20];
|
||||||
|
} bmp;
|
||||||
|
// BITMAPINFO bi;
|
||||||
INT ScreenBpp;
|
INT ScreenBpp;
|
||||||
|
BITMAPCOREINFO bic;
|
||||||
|
DWORD data[20*16];
|
||||||
|
|
||||||
HDC hDCScreen = GetDC(NULL);
|
HDC hDCScreen = GetDC(NULL);
|
||||||
ASSERT(hDCScreen != NULL);
|
ASSERT(hDCScreen != NULL);
|
||||||
|
@ -48,21 +55,74 @@ Test_NtGdiGetDIBitsInternal(PTESTINFO pti)
|
||||||
RTEST(GetLastError() == ERROR_SUCCESS);
|
RTEST(GetLastError() == ERROR_SUCCESS);
|
||||||
|
|
||||||
SetLastError(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);
|
RTEST(GetLastError() == ERROR_SUCCESS);
|
||||||
|
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
ZeroMemory(&bi, sizeof(BITMAPINFO));
|
RTEST(NtGdiGetDIBitsInternal(hDCScreen, hBitmap, 0, 15, NULL, NULL, 0, 0, 0) == 0);
|
||||||
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
RTEST(GetLastError() == ERROR_SUCCESS);
|
||||||
RTEST(NtGdiGetDIBitsInternal(hDCScreen, hBitmap, 0, 15, NULL, &bi, DIB_RGB_COLORS,
|
|
||||||
DIB_BitmapMaxBitsSize(&bi, 15), 0) > 0);
|
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);
|
RTEST(GetLastError() == ERROR_SUCCESS);
|
||||||
|
|
||||||
ScreenBpp = GetDeviceCaps(hDCScreen, BITSPIXEL);
|
ScreenBpp = GetDeviceCaps(hDCScreen, BITSPIXEL);
|
||||||
RTEST(bi.bmiHeader.biWidth == 16);
|
|
||||||
RTEST(bi.bmiHeader.biHeight == 16);
|
RTEST(bmp.bi.bmiHeader.biWidth == 16);
|
||||||
RTEST(bi.bmiHeader.biBitCount == ScreenBpp);
|
RTEST(bmp.bi.bmiHeader.biHeight == 16);
|
||||||
RTEST(bi.bmiHeader.biSizeImage == (16 * 16) * (ScreenBpp / 8));
|
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);
|
ReleaseDC(NULL, hDCScreen);
|
||||||
DeleteObject(hBitmap);
|
DeleteObject(hBitmap);
|
||||||
|
|
|
@ -4,6 +4,15 @@ HINSTANCE g_hInstance;
|
||||||
HMODULE g_hModule = NULL;
|
HMODULE g_hModule = NULL;
|
||||||
PGDI_TABLE_ENTRY GdiHandleTable;
|
PGDI_TABLE_ENTRY GdiHandleTable;
|
||||||
|
|
||||||
|
static
|
||||||
|
PGDI_TABLE_ENTRY
|
||||||
|
MyGdiQueryTable()
|
||||||
|
{
|
||||||
|
PTEB pTeb = NtCurrentTeb();
|
||||||
|
PPEB pPeb = pTeb->ProcessEnvironmentBlock;
|
||||||
|
return pPeb->GdiSharedHandleTable;
|
||||||
|
}
|
||||||
|
|
||||||
static DWORD STDCALL
|
static DWORD STDCALL
|
||||||
IntSyscall(FARPROC proc, UINT cParams, PVOID pFirstParam)
|
IntSyscall(FARPROC proc, UINT cParams, PVOID pFirstParam)
|
||||||
{
|
{
|
||||||
|
@ -59,7 +68,6 @@ WinMain(HINSTANCE hInstance,
|
||||||
int nCmdShow)
|
int nCmdShow)
|
||||||
{
|
{
|
||||||
g_hInstance = hInstance;
|
g_hInstance = hInstance;
|
||||||
GDIQUERYPROC GdiQueryTable;
|
|
||||||
|
|
||||||
printf("Win32k native API test\n");
|
printf("Win32k native API test\n");
|
||||||
|
|
||||||
|
@ -73,12 +81,7 @@ WinMain(HINSTANCE hInstance,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
GdiQueryTable = (GDIQUERYPROC)GetProcAddress(GetModuleHandleW(L"GDI32.DLL"), "GdiQueryTable");
|
GdiHandleTable = MyGdiQueryTable();
|
||||||
if(!GdiQueryTable)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
GdiHandleTable = GdiQueryTable();
|
|
||||||
if(!GdiHandleTable)
|
if(!GdiHandleTable)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -32,8 +32,6 @@ typedef struct
|
||||||
INT nParams;
|
INT nParams;
|
||||||
} SYCALL_ENTRY, *PSYSCALL_ENTRY;
|
} SYCALL_ENTRY, *PSYSCALL_ENTRY;
|
||||||
|
|
||||||
typedef PGDI_TABLE_ENTRY (CALLBACK * GDIQUERYPROC) (void);
|
|
||||||
|
|
||||||
extern HINSTANCE g_hInstance;
|
extern HINSTANCE g_hInstance;
|
||||||
extern HMODULE g_hModule;
|
extern HMODULE g_hModule;
|
||||||
extern PGDI_TABLE_ENTRY GdiHandleTable;
|
extern PGDI_TABLE_ENTRY GdiHandleTable;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue