Zebediah Figura : ddraw/tests: Test vtbl protection.
Alexandre Julliard
julliard at winehq.org
Mon Apr 27 15:19:31 CDT 2020
Module: wine
Branch: master
Commit: b95fe88ff5606df702ccd1048621bd2e13e8d574
URL: https://source.winehq.org/git/wine.git/?a=commit;h=b95fe88ff5606df702ccd1048621bd2e13e8d574
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Mon Apr 27 11:29:04 2020 -0500
ddraw/tests: Test vtbl protection.
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ddraw/tests/ddraw1.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 70 insertions(+)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index 0e1f4ce85c..4e27ecfb79 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -13410,6 +13410,75 @@ done:
DestroyWindow(window);
}
+static void check_vtbl_protection_(int line, const void *vtbl, SIZE_T size)
+{
+ MEMORY_BASIC_INFORMATION info;
+ SIZE_T ret = VirtualQuery(vtbl, &info, size);
+ ok_(__FILE__, line)(ret == sizeof(info), "Failed to query memory.\n");
+ ok_(__FILE__, line)(info.Protect & (PAGE_READWRITE | PAGE_WRITECOPY), "Got protection %#x.\n", info.Protect);
+}
+#define check_vtbl_protection(a) check_vtbl_protection_(__LINE__, a, sizeof(*(a)))
+
+static void test_vtbl_protection(void)
+{
+ PALETTEENTRY palette_entries[256];
+ IDirectDrawSurface7 *surface7;
+ IDirectDrawSurface4 *surface4;
+ IDirectDrawSurface3 *surface3;
+ IDirectDrawSurface2 *surface2;
+ IDirectDrawSurface *surface1;
+ IDirectDrawPalette *palette;
+ DDSURFACEDESC surface_desc;
+ IDirectDraw *ddraw;
+ ULONG refcount;
+ HWND window;
+ HRESULT hr;
+
+ window = create_window();
+ ddraw = create_ddraw();
+ ok(!!ddraw, "Failed to create a ddraw object.\n");
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ surface_desc.dwFlags = DDSD_CAPS;
+ surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
+ hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirectDrawSurface_QueryInterface(surface1, &IID_IDirectDrawSurface2, (void **)&surface2);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirectDrawSurface_QueryInterface(surface1, &IID_IDirectDrawSurface3, (void **)&surface3);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirectDrawSurface_QueryInterface(surface1, &IID_IDirectDrawSurface4, (void **)&surface4);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirectDrawSurface_QueryInterface(surface1, &IID_IDirectDrawSurface7, (void **)&surface7);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+
+ memset(palette_entries, 0, sizeof(palette_entries));
+ hr = IDirectDraw_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
+ palette_entries, &palette, NULL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+
+ check_vtbl_protection(ddraw->lpVtbl);
+ check_vtbl_protection(palette->lpVtbl);
+ check_vtbl_protection(surface1->lpVtbl);
+ check_vtbl_protection(surface2->lpVtbl);
+ check_vtbl_protection(surface3->lpVtbl);
+ check_vtbl_protection(surface4->lpVtbl);
+ check_vtbl_protection(surface7->lpVtbl);
+
+ IDirectDrawPalette_Release(palette);
+ IDirectDrawSurface_Release(surface1);
+ IDirectDrawSurface2_Release(surface2);
+ IDirectDrawSurface3_Release(surface3);
+ IDirectDrawSurface4_Release(surface4);
+ IDirectDrawSurface7_Release(surface7);
+ refcount = IDirectDraw_Release(ddraw);
+ ok(!refcount, "%u references left.\n", refcount);
+ DestroyWindow(window);
+}
+
START_TEST(ddraw1)
{
DDDEVICEIDENTIFIER identifier;
@@ -13523,4 +13592,5 @@ START_TEST(ddraw1)
test_caps();
test_d32_support();
test_cursor_clipping();
+ test_vtbl_protection();
}
More information about the wine-cvs
mailing list