Signed-off-by: Torge Matthies openglfreak@googlemail.com --- dlls/win32u/tests/win32u.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
diff --git a/dlls/win32u/tests/win32u.c b/dlls/win32u/tests/win32u.c index a7c2e5ef029..f225a7893d2 100644 --- a/dlls/win32u/tests/win32u.c +++ b/dlls/win32u/tests/win32u.c @@ -16,12 +16,47 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#include "ntstatus.h" +#define WIN32_NO_STATUS + #include "wine/test.h"
#include "winbase.h" #include "ntuser.h"
+static void test_NtUserEnumDisplayDevices(void) +{ + NTSTATUS ret; + DISPLAY_DEVICEW info = { sizeof(DISPLAY_DEVICEW) }; + + SetLastError( 0xdeadbeef ); + ret = NtUserEnumDisplayDevices( NULL, 0, &info, 0 ); + todo_wine ok( !ret && GetLastError() == 0xdeadbeef, + "NtUserEnumDisplayDevices returned %x %u\n", ret, + GetLastError() ); + + SetLastError( 0xdeadbeef ); + ret = NtUserEnumDisplayDevices( NULL, 12345, &info, 0 ); + todo_wine ok( ret == STATUS_UNSUCCESSFUL && GetLastError() == 0xdeadbeef, + "NtUserEnumDisplayDevices returned %x %u\n", ret, + GetLastError() ); + + info.cb = 0; + + SetLastError( 0xdeadbeef ); + ret = NtUserEnumDisplayDevices( NULL, 0, &info, 0 ); + todo_wine ok( ret == STATUS_UNSUCCESSFUL && GetLastError() == 0xdeadbeef, + "NtUserEnumDisplayDevices returned %x %u\n", ret, + GetLastError() ); + + SetLastError( 0xdeadbeef ); + ret = NtUserEnumDisplayDevices( NULL, 12345, &info, 0 ); + todo_wine ok( ret == STATUS_UNSUCCESSFUL && GetLastError() == 0xdeadbeef, + "NtUserEnumDisplayDevices returned %x %u\n", ret, + GetLastError() ); +} + static void test_NtUserCloseWindowStation(void) { BOOL ret; @@ -67,6 +102,7 @@ START_TEST(win32u) /* native win32u.dll fails if user32 is not loaded, so make sure it's fully initialized */ GetDesktopWindow();
+ test_NtUserEnumDisplayDevices(); /* Must run before test_NtUserCloseWindowStation. */ test_NtUserCloseWindowStation(); test_window_props(); }
Signed-off-by: Torge Matthies openglfreak@googlemail.com --- dlls/user32/sysparams.c | 2 +- dlls/win32u/sysparams.c | 8 ++++---- dlls/win32u/tests/win32u.c | 9 ++++----- dlls/win32u/win32u_private.h | 2 +- dlls/win32u/wrappers.c | 4 ++-- include/ntuser.h | 4 ++-- 6 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index a21b5035048..9d553d7dfff 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -1216,7 +1216,7 @@ BOOL WINAPI EnumDisplayDevicesW( LPCWSTR device, DWORD index, DISPLAY_DEVICEW *i { UNICODE_STRING str; RtlInitUnicodeString( &str, device ); - return NtUserEnumDisplayDevices( &str, index, info, flags ); + return NT_SUCCESS(NtUserEnumDisplayDevices( &str, index, info, flags )); }
/********************************************************************** diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 94c7a58fc0e..b3d2b6c7d11 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -1562,8 +1562,8 @@ static struct adapter *find_adapter( UNICODE_STRING *name ) /*********************************************************************** * NtUserEnumDisplayDevices (win32u.@) */ -BOOL WINAPI NtUserEnumDisplayDevices( UNICODE_STRING *device, DWORD index, - DISPLAY_DEVICEW *info, DWORD flags ) +NTSTATUS WINAPI NtUserEnumDisplayDevices( UNICODE_STRING *device, DWORD index, + DISPLAY_DEVICEW *info, DWORD flags ) { struct display_device *found = NULL; struct adapter *adapter; @@ -1571,7 +1571,7 @@ BOOL WINAPI NtUserEnumDisplayDevices( UNICODE_STRING *device, DWORD index,
TRACE( "%s %u %p %#x\n", debugstr_us( device ), index, info, flags );
- if (!lock_display_devices()) return FALSE; + if (!lock_display_devices()) return STATUS_UNSUCCESSFUL;
if (!device || !device->Length) { @@ -1613,7 +1613,7 @@ BOOL WINAPI NtUserEnumDisplayDevices( UNICODE_STRING *device, DWORD index, lstrcpyW( info->DeviceKey, found->device_key ); } unlock_display_devices(); - return !!found; + return found ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL; }
#define _X_FIELD(prefix, bits) \ diff --git a/dlls/win32u/tests/win32u.c b/dlls/win32u/tests/win32u.c index f225a7893d2..10ffd36d134 100644 --- a/dlls/win32u/tests/win32u.c +++ b/dlls/win32u/tests/win32u.c @@ -32,13 +32,12 @@ static void test_NtUserEnumDisplayDevices(void)
SetLastError( 0xdeadbeef ); ret = NtUserEnumDisplayDevices( NULL, 0, &info, 0 ); - todo_wine ok( !ret && GetLastError() == 0xdeadbeef, - "NtUserEnumDisplayDevices returned %x %u\n", ret, - GetLastError() ); + ok( !ret && GetLastError() == 0xdeadbeef, + "NtUserEnumDisplayDevices returned %x %u\n", ret, GetLastError() );
SetLastError( 0xdeadbeef ); ret = NtUserEnumDisplayDevices( NULL, 12345, &info, 0 ); - todo_wine ok( ret == STATUS_UNSUCCESSFUL && GetLastError() == 0xdeadbeef, + ok( ret == STATUS_UNSUCCESSFUL && GetLastError() == 0xdeadbeef, "NtUserEnumDisplayDevices returned %x %u\n", ret, GetLastError() );
@@ -52,7 +51,7 @@ static void test_NtUserEnumDisplayDevices(void)
SetLastError( 0xdeadbeef ); ret = NtUserEnumDisplayDevices( NULL, 12345, &info, 0 ); - todo_wine ok( ret == STATUS_UNSUCCESSFUL && GetLastError() == 0xdeadbeef, + ok( ret == STATUS_UNSUCCESSFUL && GetLastError() == 0xdeadbeef, "NtUserEnumDisplayDevices returned %x %u\n", ret, GetLastError() ); } diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index d3abda5b47e..9bce2b7207b 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -197,7 +197,7 @@ struct unix_funcs LONG (WINAPI *pNtUserChangeDisplaySettings)( UNICODE_STRING *devname, DEVMODEW *devmode, HWND hwnd, DWORD flags, void *lparam ); INT (WINAPI *pNtUserCountClipboardFormats)(void); - BOOL (WINAPI *pNtUserEnumDisplayDevices)( UNICODE_STRING *device, DWORD index, + NTSTATUS (WINAPI *pNtUserEnumDisplayDevices)( UNICODE_STRING *device, DWORD index, DISPLAY_DEVICEW *info, DWORD flags ); BOOL (WINAPI *pNtUserEnumDisplayMonitors)( HDC hdc, RECT *rect, MONITORENUMPROC proc, LPARAM lp ); BOOL (WINAPI *pNtUserEnumDisplaySettings)( UNICODE_STRING *device, DWORD mode, diff --git a/dlls/win32u/wrappers.c b/dlls/win32u/wrappers.c index 863c95caf1e..fe56f5e0e3c 100644 --- a/dlls/win32u/wrappers.c +++ b/dlls/win32u/wrappers.c @@ -726,8 +726,8 @@ INT WINAPI NtUserCountClipboardFormats(void) return unix_funcs->pNtUserCountClipboardFormats(); }
-BOOL WINAPI NtUserEnumDisplayDevices( UNICODE_STRING *device, DWORD index, - DISPLAY_DEVICEW *info, DWORD flags ) +NTSTATUS WINAPI NtUserEnumDisplayDevices( UNICODE_STRING *device, DWORD index, + DISPLAY_DEVICEW *info, DWORD flags ) { if (!unix_funcs) return FALSE; return unix_funcs->pNtUserEnumDisplayDevices( device, index, info, flags ); diff --git a/include/ntuser.h b/include/ntuser.h index 9583b78acf2..d03a36a5126 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -114,8 +114,8 @@ HDESK WINAPI NtUserCreateDesktopEx( OBJECT_ATTRIBUTES *attr, UNICODE_STRING *d ULONG heap_size ); HWINSTA WINAPI NtUserCreateWindowStation( OBJECT_ATTRIBUTES *attr, ACCESS_MASK mask, ULONG arg3, ULONG arg4, ULONG arg5, ULONG arg6, ULONG arg7 ); -BOOL WINAPI NtUserEnumDisplayDevices( UNICODE_STRING *device, DWORD index, - DISPLAY_DEVICEW *info, DWORD flags ); +NTSTATUS WINAPI NtUserEnumDisplayDevices( UNICODE_STRING *device, DWORD index, + DISPLAY_DEVICEW *info, DWORD flags ); BOOL WINAPI NtUserEnumDisplayMonitors( HDC hdc, RECT *rect, MONITORENUMPROC proc, LPARAM lp ); BOOL WINAPI NtUserEnumDisplaySettings( UNICODE_STRING *device, DWORD mode, DEVMODEW *dev_mode, DWORD flags );
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Torge Matthies openglfreak@googlemail.com --- dlls/win32u/sysparams.c | 2 ++ dlls/win32u/tests/win32u.c | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index b3d2b6c7d11..e06a63bd4cd 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -1571,6 +1571,8 @@ NTSTATUS WINAPI NtUserEnumDisplayDevices( UNICODE_STRING *device, DWORD index,
TRACE( "%s %u %p %#x\n", debugstr_us( device ), index, info, flags );
+ if (!info || !info->cb) return STATUS_UNSUCCESSFUL; + if (!lock_display_devices()) return STATUS_UNSUCCESSFUL;
if (!device || !device->Length) diff --git a/dlls/win32u/tests/win32u.c b/dlls/win32u/tests/win32u.c index 10ffd36d134..13c732b7748 100644 --- a/dlls/win32u/tests/win32u.c +++ b/dlls/win32u/tests/win32u.c @@ -45,15 +45,23 @@ static void test_NtUserEnumDisplayDevices(void)
SetLastError( 0xdeadbeef ); ret = NtUserEnumDisplayDevices( NULL, 0, &info, 0 ); - todo_wine ok( ret == STATUS_UNSUCCESSFUL && GetLastError() == 0xdeadbeef, - "NtUserEnumDisplayDevices returned %x %u\n", ret, - GetLastError() ); + ok( ret == STATUS_UNSUCCESSFUL && GetLastError() == 0xdeadbeef, + "NtUserEnumDisplayDevices returned %x %u\n", ret, GetLastError() );
SetLastError( 0xdeadbeef ); ret = NtUserEnumDisplayDevices( NULL, 12345, &info, 0 ); ok( ret == STATUS_UNSUCCESSFUL && GetLastError() == 0xdeadbeef, - "NtUserEnumDisplayDevices returned %x %u\n", ret, - GetLastError() ); + "NtUserEnumDisplayDevices returned %x %u\n", ret, GetLastError() ); + + SetLastError( 0xdeadbeef ); + ret = NtUserEnumDisplayDevices( NULL, 0, NULL, 0 ); + ok( ret == STATUS_UNSUCCESSFUL && GetLastError() == 0xdeadbeef, + "NtUserEnumDisplayDevices returned %x %u\n", ret, GetLastError() ); + + SetLastError( 0xdeadbeef ); + ret = NtUserEnumDisplayDevices( NULL, 12345, NULL, 0 ); + ok( ret == STATUS_UNSUCCESSFUL && GetLastError() == 0xdeadbeef, + "NtUserEnumDisplayDevices returned %x %u\n", ret, GetLastError() ); }
static void test_NtUserCloseWindowStation(void)
Signed-off-by: Jacek Caban jacek@codeweavers.com