The default is of the form "Service-0x<luid high>-<luid low>$" where the luid in question is the logon session luid.
Signed-off-by: Huw Davies huw@codeweavers.com --- dlls/user32/tests/winstation.c | 24 +++++++++++++++++++----- dlls/user32/winstation.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 5 deletions(-)
diff --git a/dlls/user32/tests/winstation.c b/dlls/user32/tests/winstation.c index 4aa5565b96c..d239ead6e98 100644 --- a/dlls/user32/tests/winstation.c +++ b/dlls/user32/tests/winstation.c @@ -118,9 +118,10 @@ static void test_handles(void) HANDLE hthread; DWORD id, flags, le; ATOM atom; - char buffer[20]; + char buffer[29], default_name[29] = ""; DWORD size; BOOL ret; + TOKEN_STATISTICS token_stats;
/* win stations */
@@ -215,7 +216,6 @@ static void test_handles(void) SetLastError( 0xdeadbeef ); w2 = OpenWindowStationA( "", TRUE, WINSTA_ALL_ACCESS ); ok( !w2, "open station succeeded\n" ); - todo_wine ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef ); @@ -225,16 +225,30 @@ static void test_handles(void) memset( buffer, 0, sizeof(buffer) ); ret = GetUserObjectInformationA( w2, UOI_NAME, buffer, sizeof(buffer), &size ); ok( ret, "GetUserObjectInformationA failed with error %u\n", GetLastError() ); - todo_wine ok( !memcmp(buffer, "Service-0x0-", 12), "unexpected window station name '%s'\n", buffer ); - todo_wine ok( buffer[strlen(buffer) - 1] == '$', "unexpected window station name '%s'\n", buffer ); + /* Get the logon session LUID */ + ret = GetTokenInformation( GetCurrentProcessToken(), TokenStatistics, &token_stats, sizeof(token_stats), NULL ); + if (ret) + sprintf( default_name, "Service-0x%x-%x$", token_stats.AuthenticationId.HighPart, + token_stats.AuthenticationId.LowPart ); + if (*default_name) + ok( !strcmp( buffer, default_name ), "unexpected window station name '%s' expected '%s'\n", buffer, default_name );
SetLastError( 0xdeadbeef ); w3 = OpenWindowStationA( "", TRUE, WINSTA_ALL_ACCESS ); - todo_wine ok( w3 != 0, "open station failed err %u\n", GetLastError() ); CloseWindowStation( w3 ); CloseWindowStation( w2 );
+ w2 = CreateWindowStationA( NULL, 0, WINSTA_ALL_ACCESS, NULL ); + ok( w2 != 0, "create station failed err %u\n", GetLastError() ); + + memset( buffer, 0, sizeof(buffer) ); + ret = GetUserObjectInformationA( w2, UOI_NAME, buffer, sizeof(buffer), &size ); + ok( ret, "GetUserObjectInformationA failed with error %u\n", GetLastError() ); + if (*default_name) + ok( !strcmp( buffer, default_name ), "unexpected window station name '%s' expected '%s'\n", buffer, default_name ); + CloseWindowStation( w2 ); + SetLastError( 0xdeadbeef ); w2 = CreateWindowStationA( "foo\bar", 0, WINSTA_ALL_ACCESS, NULL ); ok( !w2, "create station succeeded\n" ); diff --git a/dlls/user32/winstation.c b/dlls/user32/winstation.c index 4f53b43bd6c..b5d5a372faf 100644 --- a/dlls/user32/winstation.c +++ b/dlls/user32/winstation.c @@ -80,6 +80,30 @@ static HANDLE get_winstations_dir_handle(void) return handle; }
+static BOOL WINAPI winstation_default_name_once( INIT_ONCE *once, void *param, void **context ) +{ + static const WCHAR fmt[] = {'S','e','r','v','i','c','e','-','0','x','%','x','-','%','x','$',0}; + WCHAR *name = (WCHAR *)param; + TOKEN_STATISTICS stats; + BOOL ret; + + ret = GetTokenInformation( GetCurrentProcessToken(), TokenStatistics, &stats, sizeof(stats), NULL ); + if (ret) + sprintfW( name, fmt, stats.AuthenticationId.HighPart, stats.AuthenticationId.LowPart ); + + return ret; +} + +static const WCHAR *get_winstation_default_name( void ) +{ + static INIT_ONCE once = INIT_ONCE_STATIC_INIT; + static WCHAR name[29]; + BOOL ret; + + ret = InitOnceExecuteOnce( &once, winstation_default_name_once, name, NULL ); + return ret ? name : NULL; +} + /*********************************************************************** * CreateWindowStationA (USER32.@) */ @@ -113,6 +137,11 @@ HWINSTA WINAPI CreateWindowStationW( LPCWSTR name, DWORD flags, ACCESS_MASK acce SetLastError( ERROR_FILENAME_EXCED_RANGE ); return 0; } + if (!len) + { + name = get_winstation_default_name(); + len = strlenW( name ); + } SERVER_START_REQ( create_winstation ) { req->flags = 0; @@ -160,6 +189,11 @@ HWINSTA WINAPI OpenWindowStationW( LPCWSTR name, BOOL inherit, ACCESS_MASK acces SetLastError( ERROR_FILENAME_EXCED_RANGE ); return 0; } + if (!len) + { + name = get_winstation_default_name(); + len = strlenW( name ); + } SERVER_START_REQ( open_winstation ) { req->access = access;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=73972
Your paranoid android.
=== debiant (32 bit WoW report) ===
user32: win.c:10166: Test failed: Expected foreground window 000D0120, got 00E300D4 win.c:10168: Test failed: GetActiveWindow() = 00000000 win.c:10168: Test failed: GetFocus() = 00000000 win.c:10169: Test failed: Received WM_ACTIVATEAPP(1), did not expect it. win.c:10170: Test failed: Received WM_ACTIVATEAPP(0), did not expect it. win.c:10178: Test failed: Expected foreground window 000D0120, got 00000000 win.c:10180: Test failed: GetActiveWindow() = 00000000 win.c:10180: Test failed: GetFocus() = 00000000 win.c:10188: Test failed: Received WM_ACTIVATEAPP(1), did not expect it.
=== debiant (64 bit WoW report) ===
user32: clipboard.c:760: Test failed: 6: gle 5 clipboard.c:765: Test failed: 6.0: got 0000 instead of 0008 clipboard.c:805: Test failed: 6: gle 1418 clipboard.c:815: Test failed: 6: count 3 clipboard.c:818: Test failed: 6: gle 1418 clipboard.c:852: Test failed: 6: format 0008 got data 002121A8 clipboard.c:853: Test failed: 6.0: formats 00000000 have been rendered clipboard.c:858: Test failed: 6.0: formats 00000000 have been rendered clipboard.c:852: Test failed: 6: format 0002 got data 00050045 clipboard.c:853: Test failed: 6.1: formats 00000000 have been rendered clipboard.c:858: Test failed: 6.1: formats 00000000 have been rendered clipboard.c:852: Test failed: 6: format 0011 got data 00C0E7C8 clipboard.c:853: Test failed: 6.2: formats 00000000 have been rendered clipboard.c:858: Test failed: 6.2: formats 00000000 have been rendered win.c:10143: Test failed: Expected foreground window 0, got 00E300D4 win.c:10149: Test failed: Expected foreground window 000D0120, got 00E300D4