user32: Add a test for GetClassInfo, make it pass under Wine. Take 2.
Dmitry Timoshkov
dmitry at codeweavers.com
Sun Aug 1 03:09:18 CDT 2010
This patch should fix the crash reported in the bug 23818.
This version of the patch uses broken() for values returned by Win9x.
---
dlls/user32/class.c | 12 +++++++++
dlls/user32/tests/class.c | 60 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+), 0 deletions(-)
diff --git a/dlls/user32/class.c b/dlls/user32/class.c
index 6d1ab7f..91409e2 100644
--- a/dlls/user32/class.c
+++ b/dlls/user32/class.c
@@ -1070,6 +1070,12 @@ BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name, WNDCLASSEXA *wc )
TRACE("%p %s %p\n", hInstance, debugstr_a(name), wc);
+ if (!wc)
+ {
+ SetLastError( ERROR_NOACCESS );
+ return FALSE;
+ }
+
if (!hInstance) hInstance = user32_module;
if (!IS_INTRESOURCE(name))
@@ -1115,6 +1121,12 @@ BOOL WINAPI GetClassInfoExW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSEXW *wc
TRACE("%p %s %p\n", hInstance, debugstr_w(name), wc);
+ if (!wc)
+ {
+ SetLastError( ERROR_NOACCESS );
+ return FALSE;
+ }
+
if (!hInstance) hInstance = user32_module;
if (!(classPtr = CLASS_FindClass( name, hInstance )))
diff --git a/dlls/user32/tests/class.c b/dlls/user32/tests/class.c
index 800d763..79e8430 100644
--- a/dlls/user32/tests/class.c
+++ b/dlls/user32/tests/class.c
@@ -900,10 +900,70 @@ static void test_extra_values(void)
}
}
+static void test_GetClassInfo(void)
+{
+ static const WCHAR staticW[] = {'s','t','a','t','i','c',0};
+ WNDCLASSA wc;
+ WNDCLASSEXA wcx;
+ BOOL ret;
+
+ SetLastError(0xdeadbeef);
+ ret = GetClassInfoA(0, "static", &wc);
+ ok(ret, "GetClassInfoA() error %d\n", GetLastError());
+
+if (0) { /* crashes under XP */
+ SetLastError(0xdeadbeef);
+ ret = GetClassInfoA(0, "static", NULL);
+ ok(ret, "GetClassInfoA() error %d\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ ret = GetClassInfoW(0, staticW, NULL);
+ ok(ret, "GetClassInfoW() error %d\n", GetLastError());
+}
+
+ wcx.cbSize = sizeof(wcx);
+ SetLastError(0xdeadbeef);
+ ret = GetClassInfoExA(0, "static", &wcx);
+ ok(ret, "GetClassInfoExA() error %d\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ ret = GetClassInfoExA(0, "static", NULL);
+ ok(!ret, "GetClassInfoExA() should fail\n");
+ ok(GetLastError() == ERROR_NOACCESS ||
+ broken(GetLastError() == 0xdeadbeef), /* win9x */
+ "expected ERROR_NOACCESS, got %d\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ ret = GetClassInfoExW(0, staticW, NULL);
+ ok(!ret, "GetClassInfoExW() should fail\n");
+ ok(GetLastError() == ERROR_NOACCESS ||
+ broken(GetLastError() == ERROR_CALL_NOT_IMPLEMENTED), /* win9x */
+ "expected ERROR_NOACCESS, got %d\n", GetLastError());
+
+ wcx.cbSize = 0;
+ SetLastError(0xdeadbeef);
+ ret = GetClassInfoExA(0, "static", &wcx);
+ ok(ret, "GetClassInfoExA() error %d\n", GetLastError());
+ ok(wcx.cbSize == 0, "expected 0, got %u\n", wcx.cbSize);
+
+ wcx.cbSize = sizeof(wcx) - 1;
+ SetLastError(0xdeadbeef);
+ ret = GetClassInfoExA(0, "static", &wcx);
+ ok(ret, "GetClassInfoExA() error %d\n", GetLastError());
+ ok(wcx.cbSize == sizeof(wcx) - 1, "expected sizeof(wcx)-1, got %u\n", wcx.cbSize);
+
+ wcx.cbSize = sizeof(wcx) + 1;
+ SetLastError(0xdeadbeef);
+ ret = GetClassInfoExA(0, "static", &wcx);
+ ok(ret, "GetClassInfoExA() error %d\n", GetLastError());
+ ok(wcx.cbSize == sizeof(wcx) + 1, "expected sizeof(wcx)+1, got %u\n", wcx.cbSize);
+}
+
START_TEST(class)
{
HANDLE hInstance = GetModuleHandleA( NULL );
+ test_GetClassInfo();
test_extra_values();
if (!GetModuleHandleW(0))
--
1.7.0.6
More information about the wine-patches
mailing list