You've already forked wine-staging
mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-04-13 14:42:51 -07:00
Added patch to assign random name when trying to create Window Station without name.
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
From 4a137148ed5f42a6f598eba630d668d2b9613b4c Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Lackner <sebastian@fds-team.de>
|
||||
Date: Wed, 24 Feb 2016 17:49:10 +0100
|
||||
Subject: user32: Implement CWF_CREATE_ONLY flag for CreateWindowStation.
|
||||
|
||||
---
|
||||
dlls/user32/winstation.c | 11 ++++++-----
|
||||
include/winuser.h | 2 ++
|
||||
2 files changed, 8 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/dlls/user32/winstation.c b/dlls/user32/winstation.c
|
||||
index 61add76..70715ad 100644
|
||||
--- a/dlls/user32/winstation.c
|
||||
+++ b/dlls/user32/winstation.c
|
||||
@@ -80,26 +80,26 @@ static HANDLE get_winstations_dir_handle(void)
|
||||
/***********************************************************************
|
||||
* CreateWindowStationA (USER32.@)
|
||||
*/
|
||||
-HWINSTA WINAPI CreateWindowStationA( LPCSTR name, DWORD reserved, ACCESS_MASK access,
|
||||
+HWINSTA WINAPI CreateWindowStationA( LPCSTR name, DWORD flags, ACCESS_MASK access,
|
||||
LPSECURITY_ATTRIBUTES sa )
|
||||
{
|
||||
WCHAR buffer[MAX_PATH];
|
||||
|
||||
- if (!name) return CreateWindowStationW( NULL, reserved, access, sa );
|
||||
+ if (!name) return CreateWindowStationW( NULL, flags, access, sa );
|
||||
|
||||
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
||||
{
|
||||
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
||||
return 0;
|
||||
}
|
||||
- return CreateWindowStationW( buffer, reserved, access, sa );
|
||||
+ return CreateWindowStationW( buffer, flags, access, sa );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* CreateWindowStationW (USER32.@)
|
||||
*/
|
||||
-HWINSTA WINAPI CreateWindowStationW( LPCWSTR name, DWORD reserved, ACCESS_MASK access,
|
||||
+HWINSTA WINAPI CreateWindowStationW( LPCWSTR name, DWORD flags, ACCESS_MASK access,
|
||||
LPSECURITY_ATTRIBUTES sa )
|
||||
{
|
||||
HANDLE ret;
|
||||
@@ -114,7 +114,8 @@ HWINSTA WINAPI CreateWindowStationW( LPCWSTR name, DWORD reserved, ACCESS_MASK a
|
||||
{
|
||||
req->flags = 0;
|
||||
req->access = access;
|
||||
- req->attributes = OBJ_CASE_INSENSITIVE | OBJ_OPENIF |
|
||||
+ req->attributes = OBJ_CASE_INSENSITIVE |
|
||||
+ ((flags & CWF_CREATE_ONLY) ? 0 : OBJ_OPENIF) |
|
||||
((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0);
|
||||
req->rootdir = wine_server_obj_handle( get_winstations_dir_handle() );
|
||||
wine_server_add_data( req, name, len * sizeof(WCHAR) );
|
||||
diff --git a/include/winuser.h b/include/winuser.h
|
||||
index fa3e661..64dd6e7 100644
|
||||
--- a/include/winuser.h
|
||||
+++ b/include/winuser.h
|
||||
@@ -101,6 +101,8 @@ typedef void* HPOWERNOTIFY;
|
||||
#define WSF_VISIBLE 1
|
||||
#define DF_ALLOWOTHERACCOUNTHOOK 1
|
||||
|
||||
+#define CWF_CREATE_ONLY 0x01
|
||||
+
|
||||
typedef struct tagUSEROBJECTFLAGS {
|
||||
BOOL fInherit;
|
||||
BOOL fReserved;
|
||||
--
|
||||
2.7.1
|
||||
|
@@ -0,0 +1,38 @@
|
||||
From 15e83e517e6b227a55ecee9541cca567b94701b8 Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Lackner <sebastian@fds-team.de>
|
||||
Date: Wed, 24 Feb 2016 17:51:48 +0100
|
||||
Subject: user32/tests: Add additional tests for window station name.
|
||||
|
||||
---
|
||||
dlls/user32/tests/winstation.c | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
diff --git a/dlls/user32/tests/winstation.c b/dlls/user32/tests/winstation.c
|
||||
index e49420b..4a553ca 100644
|
||||
--- a/dlls/user32/tests/winstation.c
|
||||
+++ b/dlls/user32/tests/winstation.c
|
||||
@@ -114,6 +114,8 @@ static void test_handles(void)
|
||||
DWORD id, flags, le;
|
||||
ATOM atom;
|
||||
char buffer[20];
|
||||
+ DWORD size;
|
||||
+ BOOL ret;
|
||||
|
||||
/* win stations */
|
||||
|
||||
@@ -215,6 +217,12 @@ static void test_handles(void)
|
||||
w2 = CreateWindowStationA( "", 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 returned %x\n", ret );
|
||||
+ todo_wine ok( !memcmp(buffer, "Service-0x0-", 12), "unexpected WindowStation name '%s'\n", buffer );
|
||||
+ todo_wine ok( buffer[strlen(buffer) - 1] == '$', "unexpected WindowStation name '%s'\n", buffer );
|
||||
+
|
||||
SetLastError( 0xdeadbeef );
|
||||
w3 = OpenWindowStationA( "", TRUE, WINSTA_ALL_ACCESS );
|
||||
todo_wine
|
||||
--
|
||||
2.7.1
|
||||
|
@@ -0,0 +1,73 @@
|
||||
From ca6e61e6b9c6813d684eb60d074d3036f10d166e Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Lackner <sebastian@fds-team.de>
|
||||
Date: Wed, 24 Feb 2016 19:18:52 +0100
|
||||
Subject: server: Assign random name when no name was passed to
|
||||
create_winstation.
|
||||
|
||||
---
|
||||
dlls/user32/tests/winstation.c | 4 ++--
|
||||
server/winstation.c | 24 +++++++++++++++++++++++-
|
||||
2 files changed, 25 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/dlls/user32/tests/winstation.c b/dlls/user32/tests/winstation.c
|
||||
index 4a553ca..b4a1a49 100644
|
||||
--- a/dlls/user32/tests/winstation.c
|
||||
+++ b/dlls/user32/tests/winstation.c
|
||||
@@ -220,8 +220,8 @@ static void test_handles(void)
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
ret = GetUserObjectInformationA( w2, UOI_NAME, buffer, sizeof(buffer), &size );
|
||||
ok( ret, "GetUserObjectInformationA returned %x\n", ret );
|
||||
- todo_wine ok( !memcmp(buffer, "Service-0x0-", 12), "unexpected WindowStation name '%s'\n", buffer );
|
||||
- todo_wine ok( buffer[strlen(buffer) - 1] == '$', "unexpected WindowStation name '%s'\n", buffer );
|
||||
+ ok( !memcmp(buffer, "Service-0x0-", 12), "unexpected WindowStation name '%s'\n", buffer );
|
||||
+ ok( buffer[strlen(buffer) - 1] == '$', "unexpected WindowStation name '%s'\n", buffer );
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
w3 = OpenWindowStationA( "", TRUE, WINSTA_ALL_ACCESS );
|
||||
diff --git a/server/winstation.c b/server/winstation.c
|
||||
index 0034343..39131d5 100644
|
||||
--- a/server/winstation.c
|
||||
+++ b/server/winstation.c
|
||||
@@ -111,9 +111,30 @@ static const struct object_ops desktop_ops =
|
||||
static struct winstation *create_winstation( struct object *root, const struct unicode_str *name,
|
||||
unsigned int attr, unsigned int flags )
|
||||
{
|
||||
+ static const WCHAR formatW[] = {'S','e','r','v','i','c','e','-','0','x','0','-','%','x','$',0};
|
||||
+ static unsigned int id = 0x10000;
|
||||
struct winstation *winstation;
|
||||
+ struct unicode_str default_name;
|
||||
+ WCHAR buffer[32];
|
||||
|
||||
- if ((winstation = create_named_object( root, &winstation_ops, name, attr, NULL )))
|
||||
+ if (name->len)
|
||||
+ {
|
||||
+ winstation = create_named_object( root, &winstation_ops, name, attr, NULL );
|
||||
+ goto done;
|
||||
+ }
|
||||
+
|
||||
+ do
|
||||
+ {
|
||||
+ if (!++id) id = 1; /* avoid an id of 0 */
|
||||
+ sprintfW( buffer, formatW, id );
|
||||
+ default_name.str = buffer;
|
||||
+ default_name.len = strlenW( buffer ) * sizeof(WCHAR);
|
||||
+ winstation = create_named_object( root, &winstation_ops, &default_name, attr & ~OBJ_OPENIF, NULL );
|
||||
+ }
|
||||
+ while (!winstation && get_error() == STATUS_OBJECT_NAME_COLLISION);
|
||||
+
|
||||
+done:
|
||||
+ if (winstation)
|
||||
{
|
||||
if (get_error() != STATUS_OBJECT_NAME_EXISTS)
|
||||
{
|
||||
@@ -131,6 +152,7 @@ static struct winstation *create_winstation( struct object *root, const struct u
|
||||
}
|
||||
else clear_error();
|
||||
}
|
||||
+
|
||||
return winstation;
|
||||
}
|
||||
|
||||
--
|
||||
2.7.1
|
||||
|
@@ -1 +1,2 @@
|
||||
Fixes: Fix possible leak of explorer.exe processes and implement proper desktop refcounting
|
||||
Fixes: Assign random name when trying to create Window Station without name
|
||||
|
Reference in New Issue
Block a user