示例#1
0
文件: GetObject.c 项目: GYGit/reactos
void
Test_DIBBrush(void)
{
    struct
    {
        BITMAPINFOHEADER bmiHeader;
        WORD wColors[4];
        BYTE jBuffer[16];
    } PackedDIB =
    {
        {sizeof(BITMAPINFOHEADER), 4, 4, 1, 8, BI_RGB, 0, 1, 1, 4, 0},
        {1, 7, 3, 1},
        {0,1,2,3,  1,2,3,0,  2,3,0,1,  3,0,1,2},
    };
    LOGBRUSH logbrush;
    HBRUSH hBrush;

    /* Create a DIB brush */
    hBrush = CreateDIBPatternBrushPt(&PackedDIB, DIB_PAL_COLORS);
    ok(hBrush != 0, "CreateSolidBrush failed, skipping tests.\n");
    if (!hBrush) return;

    FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77);
    SetLastError(ERROR_SUCCESS);

    ok_long(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush), sizeof(LOGBRUSH));
    ok_long(logbrush.lbStyle, BS_DIBPATTERN);
    ok_long(logbrush.lbColor, 0);
    ok_long(logbrush.lbHatch, (ULONG_PTR)&PackedDIB);

    ok_err(ERROR_SUCCESS);
    DeleteObject(hBrush);


    /* Create a DIB brush with undocumented iUsage 2 */
    hBrush = CreateDIBPatternBrushPt(&PackedDIB, 2);
    ok(hBrush != 0, "CreateSolidBrush failed, skipping tests.\n");
    if (!hBrush) return;

    FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77);
    SetLastError(ERROR_SUCCESS);

    ok_long(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush), sizeof(LOGBRUSH));
    ok_long(logbrush.lbStyle, BS_DIBPATTERN);
    ok_long(logbrush.lbColor, 0);
    ok_long(logbrush.lbHatch, (ULONG_PTR)&PackedDIB);

    ok_err(ERROR_SUCCESS);
    DeleteObject(hBrush);

}
示例#2
0
void Test_GetRandomRgn_RGN5()
{
    HDC hdc;
    HRGN hrgn1, hrgn2;
    INT ret;
    RECT rect, rect2;
    HBITMAP hbmp;
    DBG_UNREFERENCED_LOCAL_VARIABLE(hrgn2);
    DBG_UNREFERENCED_LOCAL_VARIABLE(rect2);

    hrgn1 = CreateRectRgn(11, 17, 23, 42);
    if (!hrgn1)
    {
        printf("Coun't create a region\n");
        return;
    }

    hdc = CreateCompatibleDC(0);
    if (!hdc)
    {
        printf("Coun't create a dc\n");
        return;
    }
#if 0 // this is vista+
    ret = GetRandomRgn(hdc, hrgn1, RGN5);
    ok_int(ret, 1);
    GetRgnBox(hrgn1, &rect);
    ok_long(rect.left, 0);
    ok_long(rect.top, 0);
    ok_long(rect.right, 1);
    ok_long(rect.bottom, 1);

    hrgn2 = CreateRectRgn(1, 2, 3, 4);
    SelectClipRgn(hdc, hrgn2);
    DeleteObject(hrgn2);
    ret = GetRandomRgn(hdc, hrgn1, RGN5);
    ok_int(ret, 1);
    GetRgnBox(hrgn1, &rect);
    ok_long(rect.left, 0);
    ok_long(rect.top, 0);
    ok_long(rect.right, 1);
    ok_long(rect.bottom, 1);
#endif

    hbmp = CreateCompatibleBitmap(hdc, 4, 7);
    SelectObject(hdc, hbmp);
    ret = GetRandomRgn(hdc, hrgn1, SYSRGN);
    ok_int(ret, 1);
    GetRgnBox(hrgn1, &rect);
    ok_long(rect.left, 0);
    ok_long(rect.top, 0);
    ok_long(rect.right, 4);
    ok_long(rect.bottom, 7);
    DeleteObject(hbmp);

#if 0 // this is vista+
    MoveWindow(ghwnd, 100, 100, 100, 100, 0);
    ret = GetRandomRgn(ghdcWindow, hrgn1, RGN5);
    ok_int(ret, 1);
    GetRgnBox(hrgn1, &rect);
    DPtoLP(ghdcWindow, (LPPOINT)&rect, 2);
    ok_long(rect.left, 104);
    ok_long(rect.top, 124);
    ok_long(rect.right, 209);
    ok_long(rect.bottom, 196);

    MoveWindow(ghwnd, 200, 400, 200, 200, 0);

    ret = GetRandomRgn(ghdcWindow, hrgn1, RGN5);
    ok_int(ret, 1);
    GetRgnBox(hrgn1, &rect2);
    DPtoLP(ghdcWindow, (LPPOINT)&rect2, 2);
    ok_long(rect2.left, rect.left + 100);
    ok_long(rect2.top, rect.top + 300);
    ok_long(rect2.right, rect.right + 200 - 13);
    ok_long(rect2.bottom, rect.bottom + 400);
#endif

    DeleteObject(hrgn1);
    DeleteDC(hdc);
}
示例#3
0
void Test_GetRandomRgn_CLIPRGN()
{
    HDC hdc;
    HRGN hrgn1, hrgn2;
    INT ret;
    RECT rect;

    hrgn1 = CreateRectRgn(11, 17, 23, 42);
    if (!hrgn1)
    {
        printf("Coun't create a region\n");
        return;
    }

    hdc = CreateCompatibleDC(0);
    if (!hdc)
    {
        printf("Coun't create a dc\n");
        return;
    }

    ret = GetRandomRgn(hdc, hrgn1, CLIPRGN);
    ok_int(ret, 0);
    GetRgnBox(hrgn1, &rect);
    ok_long(rect.left, 11);
    ok_long(rect.top, 17);
    ok_long(rect.right, 23);
    ok_long(rect.bottom, 42);

    hrgn2 = CreateRectRgn(1, 2, 3, 4);
    SelectClipRgn(hdc, hrgn2);
    DeleteObject(hrgn2);
    ret = GetRandomRgn(hdc, hrgn1, CLIPRGN);
    ok_int(ret, 1);
    GetRgnBox(hrgn1, &rect);
    ok_long(rect.left, 1);
    ok_long(rect.top, 2);
    ok_long(rect.right, 3);
    ok_long(rect.bottom, 4);

    hrgn2 = CreateRectRgn(2, 3, 4, 5);
    SelectClipRgn(ghdcWindow, hrgn2);
    DeleteObject(hrgn2);
    ret = GetRandomRgn(ghdcWindow, hrgn1, CLIPRGN);
    ok_int(ret, 1);
    GetRgnBox(hrgn1, &rect);
    ok_long(rect.left, 2);
    ok_long(rect.top, 3);
    ok_long(rect.right, 4);
    ok_long(rect.bottom, 5);

    MoveWindow(ghwnd, 200, 400, 100, 100, 0);

    ret = GetRandomRgn(ghdcWindow, hrgn1, CLIPRGN);
    ok_int(ret, 1);
    GetRgnBox(hrgn1, &rect);
    ok_long(rect.left, 2);
    ok_long(rect.top, 3);
    ok_long(rect.right, 4);
    ok_long(rect.bottom, 5);


    DeleteObject(hrgn1);
    DeleteDC(hdc);
}
示例#4
0
文件: PatBlt.c 项目: GYGit/reactos
void Test_BrushOrigin()
{
    ULONG aulBits[2] = {0x5555AAAA, 0};
    HBITMAP hbmp;
    HBRUSH hbr;
    BOOL ret;

    hbmp = CreateBitmap(2, 2, 1, 1, aulBits);
    if (!hbmp)
    {
        printf("Couln not create a bitmap\n");
        return;
    }

    hbr = CreatePatternBrush(hbmp);
    if (!hbr)
    {
        printf("Couln not create a bitmap\n");
        return;
    }

    if (!SelectObject(hdcTarget, hbr))
    {
        printf("failed to select pattern brush\n");
        return;
    }

    ret = PatBlt(hdcTarget, 0, 0, 2, 2, PATCOPY);
    ok_long(ret, 1);
    ok_long(gpulTargetBits[0], 0xffffff);
    ok_long(gpulTargetBits[1], 0);
    ok_long(gpulTargetBits[16], 0);
    ok_long(gpulTargetBits[17], 0xffffff);
    //printf("0x%lx, 0x%lx\n", gpulTargetBits[0], gpulTargetBits[1]);

    ret = PatBlt(hdcTarget, 1, 0, 2, 2, PATCOPY);
    ok_long(ret, 1);
    ok_long(gpulTargetBits[0], 0xffffff);
    ok_long(gpulTargetBits[1], 0);
    ok_long(gpulTargetBits[2], 0xffffff);
    ok_long(gpulTargetBits[16], 0);
    ok_long(gpulTargetBits[17], 0xffffff);
    ok_long(gpulTargetBits[18], 0);

}
示例#5
0
文件: PatBlt.c 项目: GYGit/reactos
void Test_PatBlt_Params()
{
    BOOL ret;
    ULONG i, rop;
    HDC hdc;

    /* Test a rop that contains only the operation index */
    ret = PatBlt(hdcTarget, 0, 0, 1, 1, PATCOPY & 0x00FF0000);
    ok_long(ret, 1);

    /* Test a rop that contains arbitrary values outside the operation index */
    ret = PatBlt(hdcTarget, 0, 0, 1, 1, (PATCOPY & 0x00FF0000) | 0xab00cdef);
    ok_long(ret, 1);

    /* Test an invalid rop  */
    SetLastError(0);
    ok_long(PatBlt(hdcTarget, 0, 0, 1, 1, SRCCOPY) , 0);
    ok_err(0);

    /* Test all rops */
    for (i = 0; i < 256; i++)
    {
        rop = i << 16;
        ret = PatBlt(hdcTarget, 0, 0, 1, 1, rop);

        /* Only these should succeed (they use no source) */
        if ((i == 0) || (i == 5) || (i == 10) || (i == 15) || (i == 80) ||
            (i == 85) || (i == 90) || (i == 95) || (i == 160) || (i == 165) ||
            (i == 170) || (i == 175) || (i == 240) || (i == 245) ||
            (i == 250) || (i == 255))
        {
            ok(ret == 1, "index %ld failed, but should succeed\n", i);
        }
        else
        {
            ok(ret == 0, "index %ld succeeded, but should fail\n", i);
        }
    }

    /* Test quaternary rop, the background part is simply ignored */
    ret = PatBlt(hdcTarget, 0, 0, 1, 1, MAKEROP4(PATCOPY, PATINVERT));
    ok_long(ret, 1);
    ret = PatBlt(hdcTarget, 0, 0, 1, 1, MAKEROP4(PATCOPY, SRCCOPY));
    ok_long(ret, 1);
    ret = PatBlt(hdcTarget, 0, 0, 1, 1, MAKEROP4(SRCCOPY, PATCOPY));
    ok_long(ret, 0);

    /* Test an info DC */
    hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
    ok(hdc != 0, "\n");
    SetLastError(0);
    ok_long(PatBlt(hdc, 0, 0, 1, 1, PATCOPY), 1);
    ok_err(0);
    DeleteDC(hdc);

    /* Test a mem DC without selecting a bitmap */
    hdc = CreateCompatibleDC(NULL);
    ok(hdc != 0, "\n");
    ok_long(PatBlt(hdc, 0, 0, 1, 1, PATCOPY), 1);
    ok_err(0);
    DeleteDC(hdc);



}
示例#6
0
void Test_CombineTransform()
{
    XFORM xform1, xform2, xform3;

    /* Test NULL paramters */
    set_xform(&xform1, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
    set_xform(&xform2, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
    SetLastError(ERROR_SUCCESS);
    ok_int(CombineTransform(&xform3, &xform1, NULL), 0);
    ok_int(CombineTransform(&xform3, NULL, &xform2), 0);
    ok_int(CombineTransform(NULL, &xform1, &xform2), 0);
    ok_int(GetLastError(), ERROR_SUCCESS);

    /* 2 zero matrices */
    set_xform(&xform1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
    set_xform(&xform2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
    SetLastError(ERROR_SUCCESS);
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
    ok_xform(xform3, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
    ok_int(GetLastError(), ERROR_SUCCESS);

    /* 2 Identity matrices */
    set_xform(&xform1, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
    set_xform(&xform2, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
    SetLastError(ERROR_SUCCESS);
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
    ok_xform(xform3, 1.0, 0., 0., 1.0, 0., 0.);
    ok_int(GetLastError(), ERROR_SUCCESS);

    /* 2 Identity matrices with offsets */
    set_xform(&xform1, 1.0, 0.0, 0.0, 1.0, 20.0, -100.0);
    set_xform(&xform2, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
    ok_xform(xform3, 1.0, 0., 0., 1.0, 20.0, -100.0);

    xform2.eDx = -60.0;
    xform2.eDy = -20;
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
    ok_flt(xform3.eDx, -40.0);
    ok_flt(xform3.eDy, -120.0);

    /* add some stretching */
    xform2.eM11 = 2;
    xform2.eM22 = 4;
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
    ok_xform(xform3, 2.0, 0., 0., 4.0, -20.0, -420.0);

    /* add some more stretching */
    xform1.eM11 = -2.5;
    xform1.eM22 = 0.5;
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
    ok_xform(xform3, -5.0, 0., 0., 2.0, -20.0, -420.0);

    xform1.eM12 = 2.0;
    xform1.eM21 = -0.5;
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
    ok_xform(xform3, -5.0, 8.0, -1.0, 2.0, -20.0, -420.0);

    xform2.eM12 = 4.0;
    xform2.eM21 = 6.5;
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
    ok_xform(xform3, 8.0, -2.0, 2.25, 0.0, -670.0, -340.0);

    set_xform(&xform1, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
    set_xform(&xform2, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
    set_xform(&xform3, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
    xform1.eDx = (FLOAT)4294967167.999999761;
    ok(xform1.eDx == 4294967040.0, "float rounding error.\n");
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
    ok_xform(xform3, 1.0, 0.0, 0.0, 1.0, 4294967040.0, 0.0);

    set_xform(&xform3, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
    xform1.eDx = (FLOAT)4294967167.999999762;
    ok(xform1.eDx == 4294967296.0, "float rounding error.\n");
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 0);
    ok_int(GetLastError(), ERROR_SUCCESS);
    ok_xform(xform3, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);

    xform1.eDx = (FLOAT)-4294967167.999999761;
    ok(xform1.eDx == -4294967040.0, "float rounding error.\n");
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);

    xform1.eDx = (FLOAT)-4294967167.999999762;
    ok(xform1.eDx == -4294967296.0, "float rounding error.\n");
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 0);
    ok_int(GetLastError(), ERROR_SUCCESS);

    xform1.eDx = 0;
    xform1.eDy = (FLOAT)4294967167.999999761;
    ok(xform1.eDy == 4294967040.0, "float rounding error.\n");
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);

    xform2.eDy = 1;
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
    ok_flt(xform3.eDy, 4294967040.0);

    xform1.eDy = (FLOAT)4294967167.999999762;
    ok(xform1.eDy == 4294967296.0, "float rounding error.\n");
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 0);
    ok_int(GetLastError(), ERROR_SUCCESS);

    xform1.eDy = (FLOAT)-4294967167.999999761;
    ok(xform1.eDy == -4294967040.0, "float rounding error.\n");
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);

    xform1.eDy = (FLOAT)-4294967167.999999762;
    ok(xform1.eDy == -4294967296.0, "float rounding error.\n");
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 0);
    ok_int(GetLastError(), ERROR_SUCCESS);

    xform2.eDy = 10000;
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);

    set_xform(&xform1, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0);
    xform1.eDx = (FLOAT)-4294967167.999999762;
    xform2.eM11 = 1000.0;
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 0);
    ok_int(GetLastError(), ERROR_SUCCESS);

    xform1.eDx = 100000.0;
    xform2.eM11 = 100000.0;
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 0);
    ok_int(GetLastError(), ERROR_SUCCESS);

    /* Some undefined values */
    set_xform(&xform1, geIND, 0.0, 0.0, geINF, 0.0, 0.0);
    xform2 = xform1;
    SetLastError(ERROR_SUCCESS);
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
    ok_xform(xform3, geIND, 0.0, 0.0, geINF, 0.0, 0.0);
    ok_int(GetLastError(), ERROR_SUCCESS);

    set_xform(&xform2, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0);
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
    ok_xform(xform3, geIND, geIND, geINF, geINF, 0.0, 0.0);
    ok_int(GetLastError(), ERROR_SUCCESS);

    set_xform(&xform1, (FLOAT)18446743500000000000.0, 0.0, 1.0, 0.0, 0.0, 0.0);
    xform2 = xform1;
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
    ok_flt(xform3.eM11, 340282326356119260000000000000000000000.0);

    xform1.eM11 = (FLOAT)18446745000000000000.0;
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
    ok_flt(xform3.eM11, 340282346638528860000000000000000000000.0);

    xform1.eM11 = (FLOAT)18446746000000000000.0;
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
    ok_long(*(DWORD*)&xform3.eM11, 0x7f800000);

    /* zero matrix + 1 invalid */
    set_xform(&xform1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
    set_xform(&xform2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
    *(DWORD*)&xform2.eM22 = 0x7f800000; // (0.0F/0.0F)
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
    ok_xform(xform3, 0.0, 0.0, 0.0, geIND, 0.0, 0.0);

    /* zero matrix + 1 invalid */
    xform2 = xform1;
    *(DWORD*)&xform2.eM12 = 0x7f800000; // (0.0F/0.0F)
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
    ok_xform(xform3, 0.0, geIND, 0.0, geIND, 0.0, 0.0);

    /* Some undefined values */
    set_xform(&xform1, 0.0, geIND, 0.0, 0.0, 0.0, 0.0);
    set_xform(&xform2, geIND, 0.0, 0.0, geINF, 0.0, 0.0);
    ok_int(CombineTransform(&xform3, &xform1, &xform2), 1);
    ok_xform(xform3, geIND, geIND, geIND, geIND, 0.0, 0.0);

}
示例#7
0
文件: GetObject.c 项目: GYGit/reactos
void
Test_Dibsection(void)
{
    BITMAPINFO bmi = {{sizeof(BITMAPINFOHEADER), 10, 9, 1, 16, BI_RGB, 0, 10, 10, 0,0}};
    HBITMAP hBitmap;
    BITMAP bitmap;
    DIBSECTION dibsection;
    PVOID pData;
    HDC hDC;

    FillMemory(&dibsection, sizeof(DIBSECTION), 0x77);
    hDC = GetDC(0);
    hBitmap = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, &pData, NULL, 0);
    ok(hBitmap != 0, "CreateDIBSection failed with %ld, skipping tests.\n", GetLastError());
    if (!hBitmap) return;

    ok(GetObjectA((HANDLE)((UINT_PTR)hBitmap & 0x0000ffff), 0, NULL) == sizeof(BITMAP), "\n");
    ok(GetObjectW((HANDLE)((UINT_PTR)hBitmap & 0x0000ffff), 0, NULL) == sizeof(BITMAP), "\n");

    SetLastError(ERROR_SUCCESS);
    ok_long(GetObject(hBitmap, sizeof(DIBSECTION), NULL), sizeof(BITMAP));
    ok_long(GetObject(hBitmap, 0, NULL), sizeof(BITMAP));
    ok_long(GetObject(hBitmap, 5, NULL), sizeof(BITMAP));
    ok_long(GetObject(hBitmap, -5, NULL), sizeof(BITMAP));
    ok_long(GetObject(hBitmap, 0, &dibsection), 0);
    ok_long(GetObject(hBitmap, 5, &dibsection), 0);
    ok_long(GetObject(hBitmap, sizeof(BITMAP), &bitmap), sizeof(BITMAP));
    ok_long(GetObject(hBitmap, sizeof(BITMAP)+2, &bitmap), sizeof(BITMAP));
    ok_long(bitmap.bmType, 0);
    ok_long(bitmap.bmWidth, 10);
    ok_long(bitmap.bmHeight, 9);
    ok_long(bitmap.bmWidthBytes, 20);
    ok_long(bitmap.bmPlanes, 1);
    ok_long(bitmap.bmBitsPixel, 16);
    ok(bitmap.bmBits == pData, "\n");
    ok_long(GetObject(hBitmap, sizeof(DIBSECTION), &dibsection), sizeof(DIBSECTION));
    ok_long(GetObject(hBitmap, sizeof(DIBSECTION)+2, &dibsection), sizeof(DIBSECTION));
    ok_long(GetObject(hBitmap, -5, &dibsection), sizeof(DIBSECTION));
    ok_err(ERROR_SUCCESS);
    DeleteObject(hBitmap);
    ReleaseDC(0, hDC);
}
示例#8
0
文件: GetObject.c 项目: GYGit/reactos
void
Test_General(void)
{
    struct
    {
        LOGBRUSH logbrush;
        BYTE additional[600];
    } TestStruct;
    PLOGBRUSH plogbrush;
    HBRUSH hBrush;
    HPEN hpen;
    INT ret;

    /* Test null pointer and invalid handles */
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA(0, 0, NULL) == 0, "\n");
    ok(GetObjectA((HANDLE)-1, 0, NULL) == 0, "\n");

    /* Test invalid habdles of different types */
    ok(GetObjectA((HANDLE)0x00380000, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_SUCCESS, "\n");
    ok(GetObjectA((HANDLE)0x00380000, 10, &TestStruct) == 0, "\n");
    ok(GetLastError() == ERROR_SUCCESS, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)0x00010000, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)0x00020000, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_SUCCESS, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)0x00030000, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_SUCCESS, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)0x00040000, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)0x00060000, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_SUCCESS, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)0x00070000, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_SUCCESS, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)0x000B0000, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_SUCCESS, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)0x000C0000, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_SUCCESS, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)0x000D0000, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_SUCCESS, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)0x000E0000, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_SUCCESS, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)0x000F0000, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_SUCCESS, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)0x00110000, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_SUCCESS, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)0x00120000, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_SUCCESS, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)0x00130000, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_SUCCESS, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)0x00140000, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_SUCCESS, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)0x00150000, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_SUCCESS, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)0x00160000, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_SUCCESS, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_DC, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_DC, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_REGION, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_REGION, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_EMF, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_EMF, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METAFILE, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_METAFILE, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_ENHMETAFILE, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_ENHMETAFILE, 0, NULL) == 0, "\n");
    ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");

    /* Test need of alignment */
    SetLastError(ERROR_SUCCESS);
    hBrush = GetStockObject(WHITE_BRUSH);
    plogbrush = (PVOID)((ULONG_PTR)&TestStruct.logbrush);
    ok(GetObject(hBrush, sizeof(LOGBRUSH), plogbrush) == sizeof(LOGBRUSH), "\n");
    plogbrush = (PVOID)((ULONG_PTR)&TestStruct.logbrush + 2);
    ok(GetObject(hBrush, sizeof(LOGBRUSH), plogbrush) == sizeof(LOGBRUSH), "\n");
    plogbrush = (PVOID)((ULONG_PTR)&TestStruct.logbrush + 1);
    //ok(GetObject(hBrush, sizeof(LOGBRUSH), plogbrush) == 0, "\n"); // fails on win7

    /* Test invalid buffer */
    SetLastError(0xbadbad00);
    ok(GetObjectA(GetStockObject(WHITE_BRUSH), sizeof(LOGBRUSH), (PVOID)0xc0000000) == 0, "\n");
    ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
    SetLastError(0xbadbad00);
    ok(GetObjectW(GetStockObject(BLACK_PEN), sizeof(LOGPEN), (PVOID)0xc0000000) == 0, "\n");
    ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
    SetLastError(0xbadbad00);
    ok(GetObjectW(GetStockObject(21), sizeof(BITMAP), (PVOID)0xc0000000) == 0, "\n");
    ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
    SetLastError(0xbadbad00);
    ok(GetObjectW(GetStockObject(SYSTEM_FONT), sizeof(LOGFONT), (PVOID)0xc0000000) == 0, "\n");
    ok(GetLastError() == 0xbadbad00, "wrong error: %ld\n", GetLastError());
    SetLastError(ERROR_SUCCESS);
    _SEH2_TRY
    {
        ret = GetObjectA(GetStockObject(SYSTEM_FONT), sizeof(LOGFONT), (PVOID)0xc0000000);
    }
    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
    {
        ret = -1;
    }
    _SEH2_END
    ok(ret == -1, "should have got an exception\n");

    ok(GetObjectW(GetStockObject(SYSTEM_FONT), 0x50000000, &TestStruct) == 356, "\n");
    ok(GetObjectW(GetStockObject(WHITE_BRUSH), 0x50000000, &TestStruct) == sizeof(LOGBRUSH), "\n");


    /* Test buffer size of 0 */
    SetLastError(0xbadbad00);
    hBrush = CreateSolidBrush(123);
    ok(hBrush != NULL, "Failed to create brush\n");
    ok_long(GetObjectA(hBrush, 0, &TestStruct), sizeof(LOGBRUSH));
    ok_err(0xbadbad00);
    DeleteObject(hBrush);
    SetLastError(0xbadbad00);
    hpen = CreatePen(PS_SOLID, 1, 123);
    ok(hpen != NULL, "Failed to create pen\n");
    ok_long(GetObjectA(hpen, 0, &TestStruct), 0);
    ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
    SetLastError(0xbadbad00);
    TestStruct.logbrush.lbStyle = BS_SOLID;
    TestStruct.logbrush.lbColor = RGB(1,2,3);
    TestStruct.logbrush.lbHatch = 0;
    hpen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID, 1, &TestStruct.logbrush, 0, NULL);
    ok(hpen != NULL, "Failed to create pen\n");
    ok_long(GetObjectA(hpen, 0, &TestStruct), 0);
    ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
    SetLastError(0xbadbad00);
    ok(GetObjectW(GetStockObject(SYSTEM_FONT), 0, &TestStruct) == 0, "\n");
    ok_err(0xbadbad00);
    SetLastError(0xbadbad00);
    ok(GetObjectW(GetStockObject(21), 0, &TestStruct) == 0, "\n");
    ok_err(0xbadbad00);

}