Beginnings of support for window stations and desktops.
diff --git a/dlls/user/Makefile.in b/dlls/user/Makefile.in
index f2145e1..c862524 100644
--- a/dlls/user/Makefile.in
+++ b/dlls/user/Makefile.in
@@ -62,6 +62,7 @@
winhelp.c \
winpos.c \
winproc.c \
+ winstation.c \
wsprintf.c
C_SRCS16 = \
diff --git a/dlls/user/misc.c b/dlls/user/misc.c
index d7ad216..bcad0dc 100644
--- a/dlls/user/misc.c
+++ b/dlls/user/misc.c
@@ -135,33 +135,6 @@
}
-/* callback to allow EnumDesktopsA to use EnumDesktopsW */
-typedef struct {
- DESKTOPENUMPROCA lpEnumFunc;
- LPARAM lParam;
-} ENUMDESKTOPS_LPARAM;
-
-/* EnumDesktopsA passes this callback function to EnumDesktopsW.
- * It simply converts the string to ASCII and calls the callback
- * function provided by the original caller
- */
-static BOOL CALLBACK EnumDesktopProcWtoA(LPWSTR lpszDesktop, LPARAM lParam)
-{
- LPSTR buffer;
- INT len;
- BOOL ret;
- ENUMDESKTOPS_LPARAM *data = (ENUMDESKTOPS_LPARAM *)lParam;
-
- len = WideCharToMultiByte(CP_ACP, 0, lpszDesktop, -1, NULL, 0, NULL, NULL);
- if (!(buffer = HeapAlloc( GetProcessHeap(), 0, len))) return FALSE;
- WideCharToMultiByte(CP_ACP, 0, lpszDesktop, -1, buffer, len, NULL, NULL);
-
- ret = data->lpEnumFunc(buffer, data->lParam);
-
- HeapFree(GetProcessHeap(), 0, buffer);
- return ret;
-}
-
/**********************************************************************
* SetLastErrorEx [USER32.@]
*
@@ -208,44 +181,6 @@
}
/******************************************************************************
- * GetProcessWindowStation [USER32.@]
- *
- * Returns handle of window station
- *
- * NOTES
- * Docs say the return value is HWINSTA
- *
- * RETURNS
- * Success: Handle to window station associated with calling process
- * Failure: NULL
- */
-HWINSTA WINAPI GetProcessWindowStation(void)
-{
- FIXME("(void): stub\n");
- return (HWINSTA)1;
-}
-
-
-/******************************************************************************
- * GetThreadDesktop [USER32.@]
- *
- * Returns handle to desktop
- *
- * PARAMS
- * dwThreadId [I] Thread identifier
- *
- * RETURNS
- * Success: Handle to desktop associated with specified thread
- * Failure: NULL
- */
-HDESK WINAPI GetThreadDesktop( DWORD dwThreadId )
-{
- FIXME("(%lx): stub\n",dwThreadId);
- return (HDESK)1;
-}
-
-
-/******************************************************************************
* SetDebugErrorLevel [USER32.@]
* Sets the minimum error level for generating debugging events
*
@@ -307,118 +242,6 @@
/***********************************************************************
- * CreateDesktopA (USER32.@)
- */
-HDESK WINAPI CreateDesktopA( LPSTR lpszDesktop,LPSTR lpszDevice,LPDEVMODEA pDevmode,
- DWORD dwFlags,DWORD dwDesiredAccess,LPSECURITY_ATTRIBUTES lpsa )
-{
- FIXME("(%s,%s,%p,0x%08lx,0x%08lx,%p),stub!\n", lpszDesktop,lpszDevice,pDevmode,
- dwFlags,dwDesiredAccess,lpsa );
- return (HDESK)0xcafedead;
-}
-
-/***********************************************************************
- * CreateDesktopW (USER32.@)
- */
-HDESK WINAPI CreateDesktopW( LPWSTR lpszDesktop,LPWSTR lpszDevice,LPDEVMODEW pDevmode,
- DWORD dwFlags,DWORD dwDesiredAccess,LPSECURITY_ATTRIBUTES lpsa)
-{
- FIXME("(%s,%s,%p,0x%08lx,0x%08lx,%p),stub!\n",
- debugstr_w(lpszDesktop),debugstr_w(lpszDevice),pDevmode,
- dwFlags,dwDesiredAccess,lpsa );
- return (HDESK)0xcafedead;
-}
-
-/******************************************************************************
- * OpenDesktopA [USER32.@]
- *
- * Not supported on Win9x - returns NULL and calls SetLastError.
- */
-HDESK WINAPI OpenDesktopA( LPCSTR lpszDesktop, DWORD dwFlags,
- BOOL fInherit, DWORD dwDesiredAccess )
-{
- FIXME("(%s,%lx,%i,%lx): stub\n",debugstr_a(lpszDesktop),dwFlags,
- fInherit,dwDesiredAccess);
-
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return 0;
-}
-
-/******************************************************************************
- * OpenInputDesktop [USER32.@]
- *
- * Not supported on Win9x - returns NULL and calls SetLastError.
- */
-HDESK WINAPI OpenInputDesktop( DWORD dwFlags, BOOL fInherit, ACCESS_MASK dwDesiredAccess )
-{
- FIXME("(%lx,%i,%lx): stub\n",dwFlags, fInherit,dwDesiredAccess);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return 0;
-}
-
-/***********************************************************************
- * CloseDesktop (USER32.@)
- */
-BOOL WINAPI CloseDesktop(HDESK hDesk)
-{
- FIXME("(%p)\n", hDesk);
- return TRUE;
-}
-
-/******************************************************************************
- * EnumDesktopsA [USER32.@]
- */
-BOOL WINAPI EnumDesktopsA( HWINSTA hwinsta, DESKTOPENUMPROCA lpEnumFunc,
- LPARAM lParam )
-{
- ENUMDESKTOPS_LPARAM caller_data;
-
- caller_data.lpEnumFunc = lpEnumFunc;
- caller_data.lParam = lParam;
-
- return EnumDesktopsW(hwinsta, EnumDesktopProcWtoA, (LPARAM) &caller_data);
-}
-
-/******************************************************************************
- * EnumDesktopsW [USER32.@]
- */
-BOOL WINAPI EnumDesktopsW( HWINSTA hwinsta, DESKTOPENUMPROCW lpEnumFunc,
- LPARAM lParam )
-{
- FIXME("%p,%p,%lx): stub\n",hwinsta,lpEnumFunc,lParam);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
-}
-
-/***********************************************************************
- * EnumDesktopWindows (USER32.@)
- */
-BOOL WINAPI EnumDesktopWindows( HDESK hDesktop, WNDENUMPROC lpfn, LPARAM lParam )
-{
- FIXME("(%p, %p, 0x%08lx), stub!\n", hDesktop, lpfn, lParam );
- return TRUE;
-}
-
-/***********************************************************************
- * CreateWindowStationW (USER32.@)
- */
-HWINSTA WINAPI CreateWindowStationW( LPWSTR winstation,DWORD res1,DWORD desiredaccess,
- LPSECURITY_ATTRIBUTES lpsa )
-{
- FIXME("(%s,0x%08lx,0x%08lx,%p),stub!\n",debugstr_w(winstation), res1,desiredaccess,lpsa );
- return (HWINSTA)0xdeadcafe;
-}
-
-/***********************************************************************
- * CloseWindowStation (USER32.@)
- */
-BOOL WINAPI CloseWindowStation(HWINSTA hWinSta)
-{
- FIXME("(%p)\n", hWinSta);
- return TRUE;
-}
-
-/***********************************************************************
* SetWindowStationUser (USER32.@)
*/
DWORD WINAPI SetWindowStationUser(DWORD x1,DWORD x2)
@@ -428,92 +251,6 @@
}
/***********************************************************************
- * SetProcessWindowStation (USER32.@)
- */
-BOOL WINAPI SetProcessWindowStation(HWINSTA hWinSta)
-{
- FIXME("(%p),stub!\n",hWinSta);
- return TRUE;
-}
-
-/******************************************************************************
- * EnumWindowStationsA [USER32.@]
- */
-BOOL WINAPI EnumWindowStationsA( WINSTAENUMPROCA lpEnumFunc, LPARAM lParam)
-{
- FIXME("%p,%lx): stub\n",lpEnumFunc,lParam);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
-}
-
-/******************************************************************************
- * EnumWindowStationsW [USER32.@]
- */
-BOOL WINAPI EnumWindowStationsW( WINSTAENUMPROCW lpEnumFunc, LPARAM lParam)
-{
- FIXME("%p,%lx): stub\n",lpEnumFunc,lParam);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
-}
-
-/***********************************************************************
- * GetUserObjectInformationA (USER32.@)
- */
-BOOL WINAPI GetUserObjectInformationA( HANDLE hObj, INT nIndex, LPVOID pvInfo, DWORD nLength, LPDWORD lpnLen )
-{
- FIXME("(%p %i %p %ld %p),stub!\n", hObj, nIndex, pvInfo, nLength, lpnLen );
- return TRUE;
-}
-
-/***********************************************************************
- * GetUserObjectInformationW (USER32.@)
- */
-BOOL WINAPI GetUserObjectInformationW( HANDLE hObj, INT nIndex, LPVOID pvInfo, DWORD nLength, LPDWORD lpnLen )
-{
- FIXME("(%p %i %p %ld %p),stub!\n", hObj, nIndex, pvInfo, nLength, lpnLen );
- return TRUE;
-}
-
-/******************************************************************************
- * SetUserObjectInformationA (USER32.@)
- */
-BOOL WINAPI SetUserObjectInformationA( HANDLE hObj, INT nIndex,
- LPVOID pvInfo, DWORD nLength )
-{
- FIXME("(%p,%d,%p,%lx): stub\n",hObj,nIndex,pvInfo,nLength);
- return TRUE;
-}
-
-/***********************************************************************
- * GetUserObjectSecurity (USER32.@)
- */
-BOOL WINAPI GetUserObjectSecurity(HANDLE hObj, PSECURITY_INFORMATION pSIRequested,
- PSECURITY_DESCRIPTOR pSID, DWORD nLength, LPDWORD lpnLengthNeeded)
-{
- FIXME("(%p %p %p len=%ld %p),stub!\n", hObj, pSIRequested, pSID, nLength, lpnLengthNeeded);
- return TRUE;
-}
-
-/***********************************************************************
- * SetUserObjectSecurity (USER32.@)
- */
-BOOL WINAPI SetUserObjectSecurity( HANDLE hObj, PSECURITY_INFORMATION pSIRequested,
- PSECURITY_DESCRIPTOR pSID )
-{
- FIXME("(%p,%p,%p),stub!\n",hObj,pSIRequested,pSID);
- return TRUE;
-}
-
-/******************************************************************************
- * SetThreadDesktop (USER32.@)
- */
-BOOL WINAPI SetThreadDesktop( HANDLE hDesktop )
-{
- FIXME("(%p): stub\n",hDesktop);
- return TRUE;
-}
-
-/***********************************************************************
* RegisterLogonProcess (USER32.@)
*/
DWORD WINAPI RegisterLogonProcess(HANDLE hprocess,BOOL x)
diff --git a/dlls/user/tests/.cvsignore b/dlls/user/tests/.cvsignore
index 7d3eb32..9ab9727 100644
--- a/dlls/user/tests/.cvsignore
+++ b/dlls/user/tests/.cvsignore
@@ -16,4 +16,5 @@
testlist.c
text.ok
win.ok
+winstation.ok
wsprintf.ok
diff --git a/dlls/user/tests/Makefile.in b/dlls/user/tests/Makefile.in
index 5a8b63b..12bab2e 100644
--- a/dlls/user/tests/Makefile.in
+++ b/dlls/user/tests/Makefile.in
@@ -21,6 +21,7 @@
sysparams.c \
text.c \
win.c \
+ winstation.c \
wsprintf.c
RC_SRCS = resource.rc
diff --git a/dlls/user/tests/winstation.c b/dlls/user/tests/winstation.c
new file mode 100644
index 0000000..48df48f
--- /dev/null
+++ b/dlls/user/tests/winstation.c
@@ -0,0 +1,214 @@
+/*
+ * Unit tests for window stations and desktops
+ *
+ * Copyright 2002 Alexandre Julliard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "wine/test.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "winuser.h"
+
+#define DESKTOP_ALL_ACCESS 0x01ff
+
+static void print_object( HANDLE obj )
+{
+ char buffer[100];
+ DWORD size;
+
+ strcpy( buffer, "foobar" );
+ if (!GetUserObjectInformationA( obj, UOI_NAME, buffer, sizeof(buffer), &size ))
+ trace( "could not get info for %p\n", obj );
+ else
+ trace( "obj %p name '%s'\n", obj, buffer );
+ strcpy( buffer, "foobar" );
+ if (!GetUserObjectInformationA( obj, UOI_TYPE, buffer, sizeof(buffer), &size ))
+ trace( "could not get type for %p\n", obj );
+ else
+ trace( "obj %p type '%s'\n", obj, buffer );
+}
+
+static DWORD CALLBACK thread( LPVOID arg )
+{
+ HDESK d1, d2;
+ HWND hwnd = CreateWindowExA(0,"BUTTON","test",WS_POPUP,0,0,100,100,GetDesktopWindow(),0,0,0);
+ ok( hwnd != 0, "CreateWindow failed\n" );
+ d1 = GetThreadDesktop(GetCurrentThreadId());
+ trace( "thread %p desktop: %p\n", arg, d1 );
+
+ if (0) /* FIXME: this should be todo_wine but it would break the rest of the test */
+ {
+ SetLastError( 0xdeadbeef );
+ ok( !CloseHandle( d1 ), "CloseHandle succeeded\n" );
+ ok( GetLastError() == ERROR_INVALID_HANDLE, "bad last error %ld\n", GetLastError() );
+ }
+
+ SetLastError( 0xdeadbeef );
+ ok( !CloseDesktop( d1 ), "CloseDesktop succeeded\n" );
+ ok( GetLastError() == ERROR_BUSY, "bad last error %ld\n", GetLastError() );
+ print_object( d1 );
+ d2 = CreateDesktop( "foobar2", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL );
+ trace( "created desktop %p\n", d2 );
+ ok( d2 != 0, "CreateDesktop failed\n" );
+
+ todo_wine
+ {
+ SetLastError( 0xdeadbeef );
+ ok( !SetThreadDesktop( d2 ), "set thread desktop succeeded with existing window\n" );
+ ok( GetLastError() == ERROR_BUSY, "bad last error %ld\n", GetLastError() );
+ }
+
+ DestroyWindow( hwnd );
+ ok( SetThreadDesktop( d2 ), "set thread desktop failed\n" );
+ d1 = GetThreadDesktop(GetCurrentThreadId());
+ ok( d1 == d2, "GetThreadDesktop did not return set desktop %p/%p\n", d1, d2 );
+ print_object( d2 );
+ if (arg < (LPVOID)5)
+ {
+ HANDLE hthread = CreateThread( NULL, 0, thread, (char *)arg + 1, 0, NULL );
+ Sleep(1000);
+ WaitForSingleObject( hthread, INFINITE );
+ }
+ return 0;
+}
+
+static void test_handles(void)
+{
+ HWINSTA w1, w2, w3;
+ HDESK d1, d2, d3;
+ HANDLE hthread;
+ DWORD id, flags;
+
+ /* win stations */
+
+ w1 = GetProcessWindowStation();
+ ok( GetProcessWindowStation() == w1, "GetProcessWindowStation returned different handles\n" );
+ ok( !CloseWindowStation(w1), "closing process win station succeeded\n" );
+ SetLastError( 0xdeadbeef );
+ ok( !CloseHandle(w1), "closing process win station handle succeeded\n" );
+ ok( GetLastError() == ERROR_INVALID_HANDLE, "bad last error %ld\n", GetLastError() );
+ print_object( w1 );
+
+ flags = 0;
+ ok( GetHandleInformation( w1, &flags ), "GetHandleInformation failed\n" );
+ todo_wine ok( !(flags & HANDLE_FLAG_PROTECT_FROM_CLOSE), "handle %p PROTECT_FROM_CLOSE set\n", w1 );
+
+ ok( DuplicateHandle( GetCurrentProcess(), w1, GetCurrentProcess(), (PHANDLE)&w2, 0,
+ TRUE, DUPLICATE_SAME_ACCESS ), "DuplicateHandle failed\n" );
+ ok( CloseWindowStation(w2), "closing dup win station failed\n" );
+
+ ok( DuplicateHandle( GetCurrentProcess(), w1, GetCurrentProcess(), (PHANDLE)&w2, 0,
+ TRUE, DUPLICATE_SAME_ACCESS ), "DuplicateHandle failed\n" );
+ ok( CloseHandle(w2), "closing dup win station handle failed\n" );
+
+ w2 = CreateWindowStation("WinSta0", 0, WINSTA_ALL_ACCESS, NULL );
+ ok( w2 != 0, "CreateWindowStation failed\n" );
+ ok( w2 != w1, "CreateWindowStation returned default handle\n" );
+ SetLastError( 0xdeadbeef );
+ ok( !CloseDesktop( (HDESK)w2 ), "CloseDesktop succeeded on win station\n" );
+ ok( GetLastError() == ERROR_INVALID_HANDLE, "bad last error %ld\n", GetLastError() );
+ ok( CloseWindowStation( w2 ), "CloseWindowStation failed\n" );
+
+ w2 = CreateWindowStation("WinSta0", 0, WINSTA_ALL_ACCESS, NULL );
+ ok( CloseHandle( w2 ), "CloseHandle failed\n" );
+
+ w2 = OpenWindowStation("winsta0", TRUE, WINSTA_ALL_ACCESS );
+ ok( w2 != 0, "OpenWindowStation failed\n" );
+ ok( w2 != w1, "OpenWindowStation returned default handle\n" );
+ ok( CloseWindowStation( w2 ), "CloseWindowStation failed\n" );
+
+ w2 = OpenWindowStation("dummy name", TRUE, WINSTA_ALL_ACCESS );
+ ok( !w2, "open dummy win station succeeded\n" );
+
+ CreateMutexA( NULL, 0, "foobar" );
+ w2 = CreateWindowStation("foobar", 0, WINSTA_ALL_ACCESS, NULL );
+ ok( w2 != 0, "create foobar station failed\n" );
+
+ w3 = OpenWindowStation("foobar", TRUE, WINSTA_ALL_ACCESS );
+ ok( w3 != 0, "open foobar station failed\n" );
+ ok( w3 != w2, "open foobar station returned same handle\n" );
+ ok( CloseWindowStation( w2 ), "CloseWindowStation failed\n" );
+ ok( CloseWindowStation( w3 ), "CloseWindowStation failed\n" );
+
+ w3 = OpenWindowStation("foobar", TRUE, WINSTA_ALL_ACCESS );
+ ok( !w3, "open foobar station succeeded\n" );
+
+ /* desktops */
+ d1 = GetThreadDesktop(GetCurrentThreadId());
+ ok( GetThreadDesktop(GetCurrentThreadId()) == d1,
+ "GetThreadDesktop returned different handles\n" );
+
+ flags = 0;
+ ok( GetHandleInformation( d1, &flags ), "GetHandleInformation failed\n" );
+ ok( !(flags & HANDLE_FLAG_PROTECT_FROM_CLOSE), "handle %p PROTECT_FROM_CLOSE set\n", d1 );
+
+ SetLastError( 0xdeadbeef );
+ ok( !CloseDesktop(d1), "closing thread desktop succeeded\n" );
+ ok( GetLastError() == ERROR_BUSY, "bad last error %ld\n", GetLastError() );
+
+ if (0) /* FIXME: this should be todo_wine but it would break the rest of the test */
+ {
+ SetLastError( 0xdeadbeef );
+ ok( !CloseHandle(d1), "closing thread desktop handle failed\n" );
+ ok( GetLastError() == ERROR_INVALID_HANDLE, "bad last error %ld\n", GetLastError() );
+ }
+
+ ok( DuplicateHandle( GetCurrentProcess(), d1, GetCurrentProcess(), (PHANDLE)&d2, 0,
+ TRUE, DUPLICATE_SAME_ACCESS ), "DuplicateHandle failed\n" );
+ ok( CloseDesktop(d2), "closing dup desktop failed\n" );
+
+ ok( DuplicateHandle( GetCurrentProcess(), d1, GetCurrentProcess(), (PHANDLE)&d2, 0,
+ TRUE, DUPLICATE_SAME_ACCESS ), "DuplicateHandle failed\n" );
+ ok( CloseHandle(d2), "closing dup desktop handle failed\n" );
+
+ d2 = OpenDesktop( "dummy name", 0, TRUE, DESKTOP_ALL_ACCESS );
+ ok( !d2, "open dummy desktop succeeded\n" );
+
+ d2 = CreateDesktop( "foobar", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL );
+ ok( d2 != 0, "create foobar desktop failed\n" );
+ SetLastError( 0xdeadbeef );
+ ok( !CloseWindowStation( (HWINSTA)d2 ), "CloseWindowStation succeeded on desktop\n" );
+ ok( GetLastError() == ERROR_INVALID_HANDLE, "bad last error %ld\n", GetLastError() );
+
+ d3 = OpenDesktop( "foobar", 0, TRUE, DESKTOP_ALL_ACCESS );
+ ok( d3 != 0, "open foobar desktop failed\n" );
+ ok( d3 != d2, "open foobar desktop returned same handle\n" );
+ ok( CloseDesktop( d2 ), "CloseDesktop failed\n" );
+ ok( CloseDesktop( d3 ), "CloseDesktop failed\n" );
+
+ d3 = OpenDesktop( "foobar", 0, TRUE, DESKTOP_ALL_ACCESS );
+ ok( !d3, "open foobar desktop succeeded\n" );
+
+ if (0) /* FIXME: this should be todo_wine but it would break the rest of the test */
+ {
+ ok( !CloseHandle(d1), "closing thread desktop handle succeeded\n" );
+ d2 = GetThreadDesktop(GetCurrentThreadId());
+ ok( d1 == d2, "got different handles after close\n" );
+ }
+
+ trace( "thread 1 desktop: %p\n", d2 );
+ print_object( d2 );
+ hthread = CreateThread( NULL, 0, thread, (LPVOID)2, 0, &id );
+ Sleep(1000);
+ trace( "get other thread desktop: %p\n", GetThreadDesktop(id) );
+ WaitForSingleObject( hthread, INFINITE );
+}
+
+START_TEST(winstation)
+{
+ test_handles();
+}
diff --git a/dlls/user/user32.spec b/dlls/user/user32.spec
index 18eff6f..5817b5d 100644
--- a/dlls/user/user32.spec
+++ b/dlls/user/user32.spec
@@ -87,7 +87,7 @@
@ stdcall CreatePopupMenu()
@ stdcall CreateWindowExA(long str str long long long long long long long long ptr)
@ stdcall CreateWindowExW(long wstr wstr long long long long long long long long ptr)
-@ stub CreateWindowStationA
+@ stdcall CreateWindowStationA(str long long ptr)
@ stdcall CreateWindowStationW(wstr long long ptr)
@ stdcall DdeAbandonTransaction(long long long)
@ stdcall DdeAccessData(long ptr)
@@ -436,11 +436,11 @@
@ stdcall OffsetRect(ptr long long)
@ stdcall OpenClipboard(long)
@ stdcall OpenDesktopA(str long long long)
-@ stub OpenDesktopW
+@ stdcall OpenDesktopW(wstr long long long)
@ stdcall OpenIcon(long)
@ stdcall OpenInputDesktop(long long long)
-@ stub OpenWindowStationA
-@ stub OpenWindowStationW
+@ stdcall OpenWindowStationA(str long long)
+@ stdcall OpenWindowStationW(wstr long long)
@ stdcall PackDDElParam(long long long)
@ stdcall PaintDesktop(long)
@ stdcall PeekMessageA(ptr long long long long)
@@ -547,8 +547,8 @@
@ stdcall SetSystemTimer(long long long ptr)
@ stdcall SetThreadDesktop(long)
@ stdcall SetTimer(long long long ptr)
-@ stdcall SetUserObjectInformationA(long long long long)
-@ stub SetUserObjectInformationW
+@ stdcall SetUserObjectInformationA(long long ptr long)
+@ stdcall SetUserObjectInformationW(long long ptr long)
@ stdcall SetUserObjectSecurity(long ptr ptr)
@ stdcall SetWindowContextHelpId(long long)
@ stub SetWindowFullScreenState
diff --git a/dlls/user/winstation.c b/dlls/user/winstation.c
new file mode 100644
index 0000000..99ae96f
--- /dev/null
+++ b/dlls/user/winstation.c
@@ -0,0 +1,582 @@
+/*
+ * Window stations and desktops
+ *
+ * Copyright 2002 Alexandre Julliard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <stdarg.h>
+#include "windef.h"
+#include "winbase.h"
+#include "winnls.h"
+#include "winerror.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "wine/server.h"
+#include "wine/unicode.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(winstation);
+
+
+/* callback for enumeration functions */
+struct enum_proc_lparam
+{
+ NAMEENUMPROCA func;
+ LPARAM lparam;
+};
+
+static BOOL CALLBACK enum_names_WtoA( LPWSTR name, LPARAM lparam )
+{
+ struct enum_proc_lparam *data = (struct enum_proc_lparam *)lparam;
+ char buffer[MAX_PATH];
+
+ if (!WideCharToMultiByte( CP_ACP, 0, name, -1, buffer, sizeof(buffer), NULL, NULL ))
+ return FALSE;
+ return data->func( buffer, data->lparam );
+}
+
+
+/***********************************************************************
+ * CreateWindowStationA (USER32.@)
+ */
+HWINSTA WINAPI CreateWindowStationA( LPCSTR name, DWORD reserved, ACCESS_MASK access,
+ LPSECURITY_ATTRIBUTES sa )
+{
+ WCHAR buffer[MAX_PATH];
+
+ if (!name) return CreateWindowStationW( NULL, reserved, 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 );
+}
+
+
+/***********************************************************************
+ * CreateWindowStationW (USER32.@)
+ */
+HWINSTA WINAPI CreateWindowStationW( LPCWSTR name, DWORD reserved, ACCESS_MASK access,
+ LPSECURITY_ATTRIBUTES sa )
+{
+ HANDLE ret;
+ DWORD len = name ? strlenW(name) : 0;
+
+ if (len >= MAX_PATH)
+ {
+ SetLastError( ERROR_FILENAME_EXCED_RANGE );
+ return 0;
+ }
+ SERVER_START_REQ( create_winstation )
+ {
+ req->flags = 0;
+ req->access = access;
+ req->inherit = (sa && sa->bInheritHandle);
+ wine_server_add_data( req, name, len * sizeof(WCHAR) );
+ /* it doesn't seem to set last error */
+ wine_server_call( req );
+ ret = reply->handle;
+ }
+ SERVER_END_REQ;
+ return ret;
+}
+
+
+/******************************************************************************
+ * OpenWindowStationA (USER32.@)
+ */
+HWINSTA WINAPI OpenWindowStationA( LPCSTR name, BOOL inherit, ACCESS_MASK access )
+{
+ WCHAR buffer[MAX_PATH];
+
+ if (!name) return OpenWindowStationW( NULL, inherit, access );
+
+ if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
+ {
+ SetLastError( ERROR_FILENAME_EXCED_RANGE );
+ return 0;
+ }
+ return OpenWindowStationW( buffer, inherit, access );
+}
+
+
+/******************************************************************************
+ * OpenWindowStationW (USER32.@)
+ */
+HWINSTA WINAPI OpenWindowStationW( LPCWSTR name, BOOL inherit, ACCESS_MASK access )
+{
+ HANDLE ret = 0;
+ DWORD len = name ? strlenW(name) : 0;
+ if (len >= MAX_PATH)
+ {
+ SetLastError( ERROR_FILENAME_EXCED_RANGE );
+ return 0;
+ }
+ SERVER_START_REQ( open_winstation )
+ {
+ req->access = access;
+ req->inherit = inherit;
+ wine_server_add_data( req, name, len * sizeof(WCHAR) );
+ if (!wine_server_call_err( req )) ret = reply->handle;
+ }
+ SERVER_END_REQ;
+ return ret;
+}
+
+
+/***********************************************************************
+ * CloseWindowStation (USER32.@)
+ */
+BOOL WINAPI CloseWindowStation( HWINSTA handle )
+{
+ BOOL ret;
+ SERVER_START_REQ( close_winstation )
+ {
+ req->handle = handle;
+ ret = !wine_server_call_err( req );
+ }
+ SERVER_END_REQ;
+ return ret;
+}
+
+
+/******************************************************************************
+ * GetProcessWindowStation (USER32.@)
+ */
+HWINSTA WINAPI GetProcessWindowStation(void)
+{
+ HWINSTA ret = 0;
+
+ SERVER_START_REQ( get_process_winstation )
+ {
+ if (!wine_server_call_err( req )) ret = reply->handle;
+ }
+ SERVER_END_REQ;
+ return ret;
+}
+
+
+/***********************************************************************
+ * SetProcessWindowStation (USER32.@)
+ */
+BOOL WINAPI SetProcessWindowStation( HWINSTA handle )
+{
+ BOOL ret;
+
+ SERVER_START_REQ( set_process_winstation )
+ {
+ req->handle = handle;
+ ret = !wine_server_call_err( req );
+ }
+ SERVER_END_REQ;
+ return ret;
+}
+
+
+/******************************************************************************
+ * EnumWindowStationsA (USER32.@)
+ */
+BOOL WINAPI EnumWindowStationsA( WINSTAENUMPROCA func, LPARAM lparam )
+{
+ struct enum_proc_lparam data;
+ data.func = func;
+ data.lparam = lparam;
+ return EnumWindowStationsW( enum_names_WtoA, (LPARAM)&data );
+}
+
+
+/******************************************************************************
+ * EnumWindowStationsA (USER32.@)
+ */
+BOOL WINAPI EnumWindowStationsW( WINSTAENUMPROCW func, LPARAM lparam )
+{
+ FIXME( "(%p,%lx): stub\n", func, lparam );
+ SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
+ return FALSE;
+}
+
+
+/***********************************************************************
+ * CreateDesktopA (USER32.@)
+ */
+HDESK WINAPI CreateDesktopA( LPCSTR name, LPCSTR device, LPDEVMODEA devmode,
+ DWORD flags, ACCESS_MASK access, LPSECURITY_ATTRIBUTES sa )
+{
+ WCHAR buffer[MAX_PATH];
+
+ if (device || devmode)
+ {
+ SetLastError( ERROR_INVALID_PARAMETER );
+ return 0;
+ }
+ if (!name) return CreateDesktopW( NULL, NULL, NULL, flags, access, sa );
+
+ if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
+ {
+ SetLastError( ERROR_FILENAME_EXCED_RANGE );
+ return 0;
+ }
+ return CreateDesktopW( buffer, NULL, NULL, flags, access, sa );
+}
+
+
+/***********************************************************************
+ * CreateDesktopW (USER32.@)
+ */
+HDESK WINAPI CreateDesktopW( LPCWSTR name, LPCWSTR device, LPDEVMODEW devmode,
+ DWORD flags, ACCESS_MASK access, LPSECURITY_ATTRIBUTES sa )
+{
+ HANDLE ret;
+ DWORD len = name ? strlenW(name) : 0;
+
+ if (device || devmode)
+ {
+ SetLastError( ERROR_INVALID_PARAMETER );
+ return 0;
+ }
+ if (len >= MAX_PATH)
+ {
+ SetLastError( ERROR_FILENAME_EXCED_RANGE );
+ return 0;
+ }
+ SERVER_START_REQ( create_desktop )
+ {
+ req->flags = flags;
+ req->access = access;
+ req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
+ wine_server_add_data( req, name, len * sizeof(WCHAR) );
+ /* it doesn't seem to set last error */
+ wine_server_call( req );
+ ret = reply->handle;
+ }
+ SERVER_END_REQ;
+ return ret;
+}
+
+
+/******************************************************************************
+ * OpenDesktopA (USER32.@)
+ */
+HDESK WINAPI OpenDesktopA( LPCSTR name, DWORD flags, BOOL inherit, ACCESS_MASK access )
+{
+ WCHAR buffer[MAX_PATH];
+
+ if (!name) return OpenDesktopW( NULL, flags, inherit, access );
+
+ if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
+ {
+ SetLastError( ERROR_FILENAME_EXCED_RANGE );
+ return 0;
+ }
+ return OpenDesktopW( buffer, flags, inherit, access );
+}
+
+
+/******************************************************************************
+ * OpenDesktopW (USER32.@)
+ */
+HDESK WINAPI OpenDesktopW( LPCWSTR name, DWORD flags, BOOL inherit, ACCESS_MASK access )
+{
+ HANDLE ret = 0;
+ DWORD len = name ? strlenW(name) : 0;
+ if (len >= MAX_PATH)
+ {
+ SetLastError( ERROR_FILENAME_EXCED_RANGE );
+ return 0;
+ }
+ SERVER_START_REQ( open_desktop )
+ {
+ req->flags = flags;
+ req->access = access;
+ req->inherit = inherit;
+ wine_server_add_data( req, name, len * sizeof(WCHAR) );
+ if (!wine_server_call( req )) ret = reply->handle;
+ }
+ SERVER_END_REQ;
+ return ret;
+}
+
+
+/***********************************************************************
+ * CloseDesktop (USER32.@)
+ */
+BOOL WINAPI CloseDesktop( HDESK handle )
+{
+ BOOL ret;
+ SERVER_START_REQ( close_desktop )
+ {
+ req->handle = handle;
+ ret = !wine_server_call_err( req );
+ }
+ SERVER_END_REQ;
+ return ret;
+}
+
+
+/******************************************************************************
+ * GetThreadDesktop (USER32.@)
+ */
+HDESK WINAPI GetThreadDesktop( DWORD thread )
+{
+ HDESK ret = 0;
+
+ SERVER_START_REQ( get_thread_desktop )
+ {
+ req->tid = thread;
+ if (!wine_server_call_err( req )) ret = reply->handle;
+ }
+ SERVER_END_REQ;
+ return ret;
+}
+
+
+/******************************************************************************
+ * SetThreadDesktop (USER32.@)
+ */
+BOOL WINAPI SetThreadDesktop( HDESK handle )
+{
+ BOOL ret;
+
+ SERVER_START_REQ( set_thread_desktop )
+ {
+ req->handle = handle;
+ ret = !wine_server_call_err( req );
+ }
+ SERVER_END_REQ;
+ return ret;
+}
+
+
+/******************************************************************************
+ * EnumDesktopsA (USER32.@)
+ */
+BOOL WINAPI EnumDesktopsA( HWINSTA winsta, DESKTOPENUMPROCA func, LPARAM lparam )
+{
+ struct enum_proc_lparam data;
+ data.func = func;
+ data.lparam = lparam;
+ return EnumDesktopsW( winsta, enum_names_WtoA, (LPARAM)&data );
+}
+
+
+/******************************************************************************
+ * EnumDesktopsW (USER32.@)
+ */
+BOOL WINAPI EnumDesktopsW( HWINSTA winsta, DESKTOPENUMPROCW func, LPARAM lparam )
+{
+ FIXME( "(%p,%p,%lx): stub\n", winsta, func, lparam );
+ SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
+ return FALSE;
+}
+
+
+/******************************************************************************
+ * OpenInputDesktop (USER32.@)
+ */
+HDESK WINAPI OpenInputDesktop( DWORD flags, BOOL inherit, ACCESS_MASK access )
+{
+ FIXME( "(%lx,%i,%lx): stub\n", flags, inherit, access );
+ SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
+ return 0;
+}
+
+
+/***********************************************************************
+ * EnumDesktopWindows (USER32.@)
+ */
+BOOL WINAPI EnumDesktopWindows( HDESK desktop, WNDENUMPROC func, LPARAM lparam )
+{
+ FIXME( "(%p,%p,0x%lx): stub!\n", desktop, func, lparam );
+ return TRUE;
+}
+
+
+/***********************************************************************
+ * GetUserObjectInformationA (USER32.@)
+ */
+BOOL WINAPI GetUserObjectInformationA( HANDLE handle, INT index, LPVOID info, DWORD len, LPDWORD needed )
+{
+ /* check for information types returning strings */
+ if (index == UOI_TYPE || index == UOI_NAME)
+ {
+ WCHAR buffer[MAX_PATH];
+ DWORD lenA;
+
+ if (!GetUserObjectInformationW( handle, index, buffer, sizeof(buffer), NULL )) return FALSE;
+ lenA = WideCharToMultiByte( CP_ACP, 0, buffer, -1, NULL, 0, NULL, NULL );
+ if (needed) *needed = lenA;
+ if (lenA > len)
+ {
+ SetLastError( ERROR_MORE_DATA );
+ return FALSE;
+ }
+ if (info) WideCharToMultiByte( CP_ACP, 0, buffer, -1, info, len, NULL, NULL );
+ return TRUE;
+ }
+ return GetUserObjectInformationW( handle, index, info, len, needed );
+}
+
+
+/***********************************************************************
+ * GetUserObjectInformationW (USER32.@)
+ */
+BOOL WINAPI GetUserObjectInformationW( HANDLE handle, INT index, LPVOID info, DWORD len, LPDWORD needed )
+{
+ static const WCHAR desktopW[] = { 'D','e','s','k','t','o','p',0 };
+ static const WCHAR winstationW[] = { 'W','i','n','d','o','w','S','t','a','t','i','o','n',0 };
+ BOOL ret;
+
+ switch(index)
+ {
+ case UOI_FLAGS:
+ {
+ USEROBJECTFLAGS *obj_flags = info;
+ if (needed) *needed = sizeof(*obj_flags);
+ if (len < sizeof(*obj_flags))
+ {
+ SetLastError( ERROR_BUFFER_OVERFLOW );
+ return FALSE;
+ }
+ SERVER_START_REQ( set_user_object_info )
+ {
+ req->handle = handle;
+ req->flags = 0;
+ ret = !wine_server_call_err( req );
+ if (ret)
+ {
+ /* FIXME: inherit flag */
+ obj_flags->dwFlags = reply->old_obj_flags;
+ }
+ }
+ SERVER_END_REQ;
+ }
+ return ret;
+
+ case UOI_TYPE:
+ SERVER_START_REQ( set_user_object_info )
+ {
+ req->handle = handle;
+ req->flags = 0;
+ ret = !wine_server_call_err( req );
+ if (ret)
+ {
+ size_t size = reply->is_desktop ? sizeof(desktopW) : sizeof(winstationW);
+ if (needed) *needed = size;
+ if (len < size)
+ {
+ SetLastError( ERROR_MORE_DATA );
+ ret = FALSE;
+ }
+ else memcpy( info, reply->is_desktop ? desktopW : winstationW, size );
+ }
+ }
+ SERVER_END_REQ;
+ return ret;
+
+ case UOI_NAME:
+ {
+ WCHAR buffer[MAX_PATH];
+ SERVER_START_REQ( set_user_object_info )
+ {
+ req->handle = handle;
+ req->flags = 0;
+ wine_server_set_reply( req, buffer, sizeof(buffer) - sizeof(WCHAR) );
+ ret = !wine_server_call_err( req );
+ if (ret)
+ {
+ size_t size = wine_server_reply_size( reply );
+ buffer[size / sizeof(WCHAR)] = 0;
+ size += sizeof(WCHAR);
+ if (needed) *needed = size;
+ if (len < size)
+ {
+ SetLastError( ERROR_MORE_DATA );
+ ret = FALSE;
+ }
+ else memcpy( info, buffer, size );
+ }
+ }
+ SERVER_END_REQ;
+ }
+ return ret;
+
+ case UOI_USER_SID:
+ FIXME( "not supported index %d\n", index );
+ /* fall through */
+ default:
+ SetLastError( ERROR_INVALID_PARAMETER );
+ return FALSE;
+ }
+}
+
+
+/******************************************************************************
+ * SetUserObjectInformationA (USER32.@)
+ */
+BOOL WINAPI SetUserObjectInformationA( HANDLE handle, INT index, LPVOID info, DWORD len )
+{
+ return SetUserObjectInformationW( handle, index, info, len );
+}
+
+
+/******************************************************************************
+ * SetUserObjectInformationW (USER32.@)
+ */
+BOOL WINAPI SetUserObjectInformationW( HANDLE handle, INT index, LPVOID info, DWORD len )
+{
+ BOOL ret;
+ const USEROBJECTFLAGS *obj_flags = info;
+
+ if (index != UOI_FLAGS || !info || len < sizeof(*obj_flags))
+ {
+ SetLastError( ERROR_INVALID_PARAMETER );
+ return FALSE;
+ }
+ /* FIXME: inherit flag */
+ SERVER_START_REQ( set_user_object_info )
+ {
+ req->handle = handle;
+ req->flags = SET_USER_OBJECT_FLAGS;
+ req->obj_flags = obj_flags->dwFlags;
+ ret = !wine_server_call_err( req );
+ }
+ SERVER_END_REQ;
+ return ret;
+}
+
+
+/***********************************************************************
+ * GetUserObjectSecurity (USER32.@)
+ */
+BOOL WINAPI GetUserObjectSecurity( HANDLE handle, PSECURITY_INFORMATION info,
+ PSECURITY_DESCRIPTOR sid, DWORD len, LPDWORD needed )
+{
+ FIXME( "(%p %p %p len=%ld %p),stub!\n", handle, info, sid, len, needed );
+ return TRUE;
+}
+
+/***********************************************************************
+ * SetUserObjectSecurity (USER32.@)
+ */
+BOOL WINAPI SetUserObjectSecurity( HANDLE handle, PSECURITY_INFORMATION info,
+ PSECURITY_DESCRIPTOR sid )
+{
+ FIXME( "(%p,%p,%p),stub!\n", handle, info, sid );
+ return TRUE;
+}
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h
index 9bd3274..7c939b5 100644
--- a/include/wine/server_protocol.h
+++ b/include/wine/server_protocol.h
@@ -2877,6 +2877,160 @@
+struct create_winstation_request
+{
+ struct request_header __header;
+ unsigned int flags;
+ unsigned int access;
+ int inherit;
+ /* VARARG(name,unicode_str); */
+};
+struct create_winstation_reply
+{
+ struct reply_header __header;
+ obj_handle_t handle;
+};
+
+
+
+struct open_winstation_request
+{
+ struct request_header __header;
+ unsigned int access;
+ int inherit;
+ /* VARARG(name,unicode_str); */
+};
+struct open_winstation_reply
+{
+ struct reply_header __header;
+ obj_handle_t handle;
+};
+
+
+
+struct close_winstation_request
+{
+ struct request_header __header;
+ obj_handle_t handle;
+};
+struct close_winstation_reply
+{
+ struct reply_header __header;
+};
+
+
+
+struct get_process_winstation_request
+{
+ struct request_header __header;
+};
+struct get_process_winstation_reply
+{
+ struct reply_header __header;
+ obj_handle_t handle;
+};
+
+
+
+struct set_process_winstation_request
+{
+ struct request_header __header;
+ obj_handle_t handle;
+};
+struct set_process_winstation_reply
+{
+ struct reply_header __header;
+};
+
+
+
+struct create_desktop_request
+{
+ struct request_header __header;
+ unsigned int flags;
+ unsigned int access;
+ int inherit;
+ /* VARARG(name,unicode_str); */
+};
+struct create_desktop_reply
+{
+ struct reply_header __header;
+ obj_handle_t handle;
+};
+
+
+
+struct open_desktop_request
+{
+ struct request_header __header;
+ unsigned int flags;
+ unsigned int access;
+ int inherit;
+ /* VARARG(name,unicode_str); */
+};
+struct open_desktop_reply
+{
+ struct reply_header __header;
+ obj_handle_t handle;
+};
+
+
+
+struct close_desktop_request
+{
+ struct request_header __header;
+ obj_handle_t handle;
+};
+struct close_desktop_reply
+{
+ struct reply_header __header;
+};
+
+
+
+struct get_thread_desktop_request
+{
+ struct request_header __header;
+ thread_id_t tid;
+};
+struct get_thread_desktop_reply
+{
+ struct reply_header __header;
+ obj_handle_t handle;
+};
+
+
+
+struct set_thread_desktop_request
+{
+ struct request_header __header;
+ obj_handle_t handle;
+};
+struct set_thread_desktop_reply
+{
+ struct reply_header __header;
+};
+
+
+
+struct set_user_object_info_request
+{
+ struct request_header __header;
+ obj_handle_t handle;
+ unsigned int flags;
+ unsigned int obj_flags;
+};
+struct set_user_object_info_reply
+{
+ struct reply_header __header;
+ int is_desktop;
+ unsigned int old_obj_flags;
+ /* VARARG(name,unicode_str); */
+};
+#define SET_USER_OBJECT_FLAGS 1
+
+
+
struct attach_thread_input_request
{
struct request_header __header;
@@ -3568,6 +3722,17 @@
REQ_remove_window_property,
REQ_get_window_property,
REQ_get_window_properties,
+ REQ_create_winstation,
+ REQ_open_winstation,
+ REQ_close_winstation,
+ REQ_get_process_winstation,
+ REQ_set_process_winstation,
+ REQ_create_desktop,
+ REQ_open_desktop,
+ REQ_close_desktop,
+ REQ_get_thread_desktop,
+ REQ_set_thread_desktop,
+ REQ_set_user_object_info,
REQ_attach_thread_input,
REQ_get_thread_input,
REQ_get_last_input_time,
@@ -3768,6 +3933,17 @@
struct remove_window_property_request remove_window_property_request;
struct get_window_property_request get_window_property_request;
struct get_window_properties_request get_window_properties_request;
+ struct create_winstation_request create_winstation_request;
+ struct open_winstation_request open_winstation_request;
+ struct close_winstation_request close_winstation_request;
+ struct get_process_winstation_request get_process_winstation_request;
+ struct set_process_winstation_request set_process_winstation_request;
+ struct create_desktop_request create_desktop_request;
+ struct open_desktop_request open_desktop_request;
+ struct close_desktop_request close_desktop_request;
+ struct get_thread_desktop_request get_thread_desktop_request;
+ struct set_thread_desktop_request set_thread_desktop_request;
+ struct set_user_object_info_request set_user_object_info_request;
struct attach_thread_input_request attach_thread_input_request;
struct get_thread_input_request get_thread_input_request;
struct get_last_input_time_request get_last_input_time_request;
@@ -3966,6 +4142,17 @@
struct remove_window_property_reply remove_window_property_reply;
struct get_window_property_reply get_window_property_reply;
struct get_window_properties_reply get_window_properties_reply;
+ struct create_winstation_reply create_winstation_reply;
+ struct open_winstation_reply open_winstation_reply;
+ struct close_winstation_reply close_winstation_reply;
+ struct get_process_winstation_reply get_process_winstation_reply;
+ struct set_process_winstation_reply set_process_winstation_reply;
+ struct create_desktop_reply create_desktop_reply;
+ struct open_desktop_reply open_desktop_reply;
+ struct close_desktop_reply close_desktop_reply;
+ struct get_thread_desktop_reply get_thread_desktop_reply;
+ struct set_thread_desktop_reply set_thread_desktop_reply;
+ struct set_user_object_info_reply set_user_object_info_reply;
struct attach_thread_input_reply attach_thread_input_reply;
struct get_thread_input_reply get_thread_input_reply;
struct get_last_input_time_reply get_last_input_time_reply;
@@ -3998,6 +4185,6 @@
struct set_mailslot_info_reply set_mailslot_info_reply;
};
-#define SERVER_PROTOCOL_VERSION 177
+#define SERVER_PROTOCOL_VERSION 178
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
diff --git a/include/winuser.h b/include/winuser.h
index 75fb405..d154f27 100644
--- a/include/winuser.h
+++ b/include/winuser.h
@@ -104,6 +104,29 @@
DWORD dwFlags;
} USEROBJECTFLAGS, *PUSEROBJECTFLAGS;
+/* Window stations */
+#define WINSTA_ENUMDESKTOPS 0x0001
+#define WINSTA_READATTRIBUTES 0x0002
+#define WINSTA_ACCESSCLIPBOARD 0x0004
+#define WINSTA_CREATEDESKTOP 0x0008
+#define WINSTA_WRITEATTRIBUTES 0x0010
+#define WINSTA_ACCESSGLOBALATOMS 0x0020
+#define WINSTA_EXITWINDOWS 0x0040
+#define WINSTA_ENUMERATE 0x0100
+#define WINSTA_READSCREEN 0x0200
+#define WINSTA_ALL_ACCESS 0x037f
+
+/* Desktops */
+#define DESKTOP_READOBJECTS 0x0001
+#define DESKTOP_CREATEWINDOW 0x0002
+#define DESKTOP_CREATEMENU 0x0004
+#define DESKTOP_HOOKCONTROL 0x0008
+#define DESKTOP_JOURNALRECORD 0x0010
+#define DESKTOP_JOURNALPLAYBACK 0x0020
+#define DESKTOP_ENUMERATE 0x0040
+#define DESKTOP_WRITEOBJECTS 0x0080
+#define DESKTOP_SWITCHDESKTOP 0x0100
+
/* flags for FILTERKEYS dwFlags field */
#define FKF_AVAILABLE 0x00000002
@@ -3868,6 +3891,9 @@
LONG WINAPI ChangeDisplaySettingsExA(LPCSTR,LPDEVMODEA,HWND,DWORD,LPVOID);
LONG WINAPI ChangeDisplaySettingsExW(LPCWSTR,LPDEVMODEW,HWND,DWORD,LPVOID);
#define ChangeDisplaySettingsEx WINELIB_NAME_AW(ChangeDisplaySettingsEx)
+HDESK WINAPI CreateDesktopA(LPCSTR,LPCSTR,LPDEVMODEA,DWORD,ACCESS_MASK,LPSECURITY_ATTRIBUTES);
+HDESK WINAPI CreateDesktopW(LPCWSTR,LPCWSTR,LPDEVMODEW,DWORD,ACCESS_MASK,LPSECURITY_ATTRIBUTES);
+#define CreateDesktop WINELIB_NAME_AW(CreateDesktop)
BOOL WINAPI EnumDisplayDevicesA(LPVOID,DWORD,LPDISPLAY_DEVICEA,DWORD);
BOOL WINAPI EnumDisplayDevicesW(LPVOID,DWORD,LPDISPLAY_DEVICEW,DWORD);
#define EnumDisplayDevices WINELIB_NAME_AW(EnumDisplayDevices)
@@ -4109,8 +4135,8 @@
HWND WINAPI CreateWindowExW(DWORD,LPCWSTR,LPCWSTR,DWORD,INT,INT,
INT,INT,HWND,HMENU,HINSTANCE,LPVOID);
#define CreateWindowEx WINELIB_NAME_AW(CreateWindowEx)
-HWINSTA WINAPI CreateWindowStationA(LPSTR,DWORD,DWORD,LPSECURITY_ATTRIBUTES);
-HWINSTA WINAPI CreateWindowStationW(LPWSTR,DWORD,DWORD,LPSECURITY_ATTRIBUTES);
+HWINSTA WINAPI CreateWindowStationA(LPCSTR,DWORD,ACCESS_MASK,LPSECURITY_ATTRIBUTES);
+HWINSTA WINAPI CreateWindowStationW(LPCWSTR,DWORD,ACCESS_MASK,LPSECURITY_ATTRIBUTES);
#define CreateWindowStation WINELIB_NAME_AW(CreateWindowStation)
HWND WINAPI CreateMDIWindowA(LPCSTR,LPCSTR,DWORD,INT,INT,
INT,INT,HWND,HINSTANCE,LPARAM);
@@ -4321,9 +4347,10 @@
DWORD WINAPI GetTabbedTextExtentW(HDC,LPCWSTR,INT,INT,const INT*);
#define GetTabbedTextExtent WINELIB_NAME_AW(GetTabbedTextExtent)
BOOL WINAPI GetTitleBarInfo(HWND,PTITLEBARINFO);
-HWND WINAPI GetTopWindow(HWND);
-BOOL WINAPI GetUpdateRect(HWND,LPRECT,BOOL);
-INT WINAPI GetUpdateRgn(HWND,HRGN,BOOL);
+HDESK WINAPI GetThreadDesktop(DWORD);
+HWND WINAPI GetTopWindow(HWND);
+BOOL WINAPI GetUpdateRect(HWND,LPRECT,BOOL);
+INT WINAPI GetUpdateRgn(HWND,HRGN,BOOL);
BOOL WINAPI GetUserObjectInformationA(HANDLE,INT,LPVOID,DWORD,LPDWORD);
BOOL WINAPI GetUserObjectInformationW(HANDLE,INT,LPVOID,DWORD,LPDWORD);
#define GetUserObjectInformation WINELIB_NAME_AW(GetUserObjectInformation)
@@ -4460,10 +4487,13 @@
#define OemToCharBuff WINELIB_NAME_AW(OemToCharBuff)
BOOL WINAPI OffsetRect(LPRECT,INT,INT);
BOOL WINAPI OpenClipboard(HWND);
-BOOL WINAPI OpenIcon(HWND);
-HDESK WINAPI OpenInputDesktop(DWORD,BOOL,ACCESS_MASK);
-HWINSTA WINAPI OpenWindowStationA(LPSTR,BOOL,ACCESS_MASK);
-HWINSTA WINAPI OpenWindowStationW(LPWSTR,BOOL,ACCESS_MASK);
+HDESK WINAPI OpenDesktopA(LPCSTR,DWORD,BOOL,ACCESS_MASK);
+HDESK WINAPI OpenDesktopW(LPCWSTR,DWORD,BOOL,ACCESS_MASK);
+#define OpenDesktop WINELIB_NAME_AW(OpenDesktop)
+BOOL WINAPI OpenIcon(HWND);
+HDESK WINAPI OpenInputDesktop(DWORD,BOOL,ACCESS_MASK);
+HWINSTA WINAPI OpenWindowStationA(LPCSTR,BOOL,ACCESS_MASK);
+HWINSTA WINAPI OpenWindowStationW(LPCWSTR,BOOL,ACCESS_MASK);
#define OpenWindowStation WINELIB_NAME_AW(OpenWindowStation)
BOOL WINAPI PeekMessageA(LPMSG,HWND,UINT,UINT,UINT);
BOOL WINAPI PeekMessageW(LPMSG,HWND,UINT,UINT,UINT);
@@ -4560,16 +4590,20 @@
BOOL WINAPI SetPropA(HWND,LPCSTR,HANDLE);
BOOL WINAPI SetPropW(HWND,LPCWSTR,HANDLE);
#define SetProp WINELIB_NAME_AW(SetProp)
-BOOL WINAPI SetRect(LPRECT,INT,INT,INT,INT);
-BOOL WINAPI SetRectEmpty(LPRECT);
-INT WINAPI SetScrollInfo(HWND,INT,const SCROLLINFO*,BOOL);
-INT WINAPI SetScrollPos(HWND,INT,INT,BOOL);
-BOOL WINAPI SetScrollRange(HWND,INT,INT,INT,BOOL);
+BOOL WINAPI SetRect(LPRECT,INT,INT,INT,INT);
+BOOL WINAPI SetRectEmpty(LPRECT);
+INT WINAPI SetScrollInfo(HWND,INT,const SCROLLINFO*,BOOL);
+INT WINAPI SetScrollPos(HWND,INT,INT,BOOL);
+BOOL WINAPI SetScrollRange(HWND,INT,INT,INT,BOOL);
#define SetSysModalWindow(hwnd) ((HWND)0)
-BOOL WINAPI SetSystemCursor(HCURSOR,DWORD);
-BOOL WINAPI SetSystemMenu(HWND,HMENU);
-UINT_PTR WINAPI SetSystemTimer(HWND,UINT_PTR,UINT,TIMERPROC);
-UINT_PTR WINAPI SetTimer(HWND,UINT_PTR,UINT,TIMERPROC);
+BOOL WINAPI SetSystemCursor(HCURSOR,DWORD);
+BOOL WINAPI SetSystemMenu(HWND,HMENU);
+UINT_PTR WINAPI SetSystemTimer(HWND,UINT_PTR,UINT,TIMERPROC);
+BOOL WINAPI SetThreadDesktop(HDESK);
+UINT_PTR WINAPI SetTimer(HWND,UINT_PTR,UINT,TIMERPROC);
+BOOL WINAPI SetUserObjectInformationA(HANDLE,INT,LPVOID,DWORD);
+BOOL WINAPI SetUserObjectInformationW(HANDLE,INT,LPVOID,DWORD);
+#define SetUserObjectInformation WINELIB_NAME_AW(SetUserObjectInformation)
BOOL WINAPI SetUserObjectSecurity(HANDLE,PSECURITY_INFORMATION,PSECURITY_DESCRIPTOR);
LONG WINAPI SetWindowLongA(HWND,INT,LONG);
LONG WINAPI SetWindowLongW(HWND,INT,LONG);
diff --git a/server/Makefile.in b/server/Makefile.in
index 17239a5..c3fc30e 100644
--- a/server/Makefile.in
+++ b/server/Makefile.in
@@ -44,7 +44,8 @@
trace.c \
unicode.c \
user.c \
- window.c
+ window.c \
+ winstation.c
PROGRAMS = wineserver
diff --git a/server/object.c b/server/object.c
index 479b09c..90aa35c 100644
--- a/server/object.c
+++ b/server/object.c
@@ -129,6 +129,15 @@
obj->name = ptr;
}
+/* get the name of an existing object */
+const WCHAR *get_object_name( struct object *obj, size_t *len )
+{
+ struct object_name *ptr = obj->name;
+ if (!ptr) return NULL;
+ *len = ptr->len;
+ return ptr->name;
+}
+
/* allocate and initialize an object */
void *alloc_object( const struct object_ops *ops )
{
diff --git a/server/object.h b/server/object.h
index 313ecab..9fd6581 100644
--- a/server/object.h
+++ b/server/object.h
@@ -88,6 +88,7 @@
extern void *mem_alloc( size_t size ); /* malloc wrapper */
extern void *memdup( const void *data, size_t len );
extern void *alloc_object( const struct object_ops *ops );
+extern const WCHAR *get_object_name( struct object *obj, size_t *len );
extern void dump_object_name( struct object *obj );
extern void *create_named_object( struct namespace *namespace, const struct object_ops *ops,
const WCHAR *name, size_t len );
diff --git a/server/process.c b/server/process.c
index eb869ec..e69fe1b 100644
--- a/server/process.c
+++ b/server/process.c
@@ -280,6 +280,7 @@
process->queue = NULL;
process->peb = NULL;
process->ldt_copy = NULL;
+ process->winstation = 0;
process->exe.file = NULL;
process->exe.dbg_offset = 0;
process->exe.dbg_size = 0;
@@ -376,6 +377,10 @@
return NULL;
}
+ /* connect to the window station and desktop */
+ connect_process_winstation( process, NULL, 0 );
+ connect_thread_desktop( current, NULL, 0 );
+
/* set the process console */
if (!set_process_console( process, parent_thread, info, reply )) return NULL;
diff --git a/server/process.h b/server/process.h
index d203ebd..c82848b 100644
--- a/server/process.h
+++ b/server/process.h
@@ -72,6 +72,7 @@
struct startup_info *startup_info; /* startup info while init is in progress */
struct event *idle_event; /* event for input idle */
struct msg_queue *queue; /* main message queue */
+ obj_handle_t winstation; /* main handle to process window station */
struct token *token; /* security token associated with this process */
struct process_dll exe; /* main exe file */
struct list dlls; /* list of loaded dlls */
diff --git a/server/protocol.def b/server/protocol.def
index b828174..108e57b 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -2023,6 +2023,101 @@
@END
+/* Create a window station */
+@REQ(create_winstation)
+ unsigned int flags; /* window station flags */
+ unsigned int access; /* wanted access rights */
+ int inherit; /* inherit flag */
+ VARARG(name,unicode_str); /* object name */
+@REPLY
+ obj_handle_t handle; /* handle to the window station */
+@END
+
+
+/* Open a handle to a window station */
+@REQ(open_winstation)
+ unsigned int access; /* wanted access rights */
+ int inherit; /* inherit flag */
+ VARARG(name,unicode_str); /* object name */
+@REPLY
+ obj_handle_t handle; /* handle to the window station */
+@END
+
+
+/* Close a window station */
+@REQ(close_winstation)
+ obj_handle_t handle; /* handle to the window station */
+@END
+
+
+/* Get the process current window station */
+@REQ(get_process_winstation)
+@REPLY
+ obj_handle_t handle; /* handle to the window station */
+@END
+
+
+/* Set the process current window station */
+@REQ(set_process_winstation)
+ obj_handle_t handle; /* handle to the window station */
+@END
+
+
+/* Create a desktop */
+@REQ(create_desktop)
+ unsigned int flags; /* desktop flags */
+ unsigned int access; /* wanted access rights */
+ int inherit; /* inherit flag */
+ VARARG(name,unicode_str); /* object name */
+@REPLY
+ obj_handle_t handle; /* handle to the desktop */
+@END
+
+
+/* Open a handle to a desktop */
+@REQ(open_desktop)
+ unsigned int flags; /* desktop flags */
+ unsigned int access; /* wanted access rights */
+ int inherit; /* inherit flag */
+ VARARG(name,unicode_str); /* object name */
+@REPLY
+ obj_handle_t handle; /* handle to the desktop */
+@END
+
+
+/* Close a desktop */
+@REQ(close_desktop)
+ obj_handle_t handle; /* handle to the desktop */
+@END
+
+
+/* Get the thread current desktop */
+@REQ(get_thread_desktop)
+ thread_id_t tid; /* thread id */
+@REPLY
+ obj_handle_t handle; /* handle to the desktop */
+@END
+
+
+/* Set the thread current desktop */
+@REQ(set_thread_desktop)
+ obj_handle_t handle; /* handle to the desktop */
+@END
+
+
+/* Get/set information about a user object (window station or desktop) */
+@REQ(set_user_object_info)
+ obj_handle_t handle; /* handle to the object */
+ unsigned int flags; /* information to set */
+ unsigned int obj_flags; /* new object flags */
+@REPLY
+ int is_desktop; /* is object a desktop? */
+ unsigned int old_obj_flags; /* old object flags */
+ VARARG(name,unicode_str); /* object name */
+@END
+#define SET_USER_OBJECT_FLAGS 1
+
+
/* Attach (or detach) thread inputs */
@REQ(attach_thread_input)
thread_id_t tid_from; /* thread to be attached */
diff --git a/server/request.h b/server/request.h
index 8172cdb..b8cd447 100644
--- a/server/request.h
+++ b/server/request.h
@@ -266,6 +266,17 @@
DECL_HANDLER(remove_window_property);
DECL_HANDLER(get_window_property);
DECL_HANDLER(get_window_properties);
+DECL_HANDLER(create_winstation);
+DECL_HANDLER(open_winstation);
+DECL_HANDLER(close_winstation);
+DECL_HANDLER(get_process_winstation);
+DECL_HANDLER(set_process_winstation);
+DECL_HANDLER(create_desktop);
+DECL_HANDLER(open_desktop);
+DECL_HANDLER(close_desktop);
+DECL_HANDLER(get_thread_desktop);
+DECL_HANDLER(set_thread_desktop);
+DECL_HANDLER(set_user_object_info);
DECL_HANDLER(attach_thread_input);
DECL_HANDLER(get_thread_input);
DECL_HANDLER(get_last_input_time);
@@ -465,6 +476,17 @@
(req_handler)req_remove_window_property,
(req_handler)req_get_window_property,
(req_handler)req_get_window_properties,
+ (req_handler)req_create_winstation,
+ (req_handler)req_open_winstation,
+ (req_handler)req_close_winstation,
+ (req_handler)req_get_process_winstation,
+ (req_handler)req_set_process_winstation,
+ (req_handler)req_create_desktop,
+ (req_handler)req_open_desktop,
+ (req_handler)req_close_desktop,
+ (req_handler)req_get_thread_desktop,
+ (req_handler)req_set_thread_desktop,
+ (req_handler)req_set_user_object_info,
(req_handler)req_attach_thread_input,
(req_handler)req_get_thread_input,
(req_handler)req_get_last_input_time,
diff --git a/server/thread.c b/server/thread.c
index 2d7a61b..9d69bf1 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -137,6 +137,7 @@
thread->priority = THREAD_PRIORITY_NORMAL;
thread->affinity = 1;
thread->suspend = 0;
+ thread->desktop = 0;
thread->creation_time = time(NULL);
thread->exit_time = 0;
@@ -213,6 +214,7 @@
free_msg_queue( thread );
cleanup_clipboard_thread(thread);
destroy_thread_windows( thread );
+ close_thread_desktop( thread );
for (i = 0; i < MAX_INFLIGHT_FDS; i++)
{
if (thread->inflight[i].client != -1)
@@ -226,6 +228,7 @@
thread->request_fd = NULL;
thread->reply_fd = NULL;
thread->wait_fd = NULL;
+ thread->desktop = 0;
if (thread == booting_thread) /* killing booting thread */
{
@@ -831,6 +834,7 @@
if ((thread = create_thread( request_fd, current->process )))
{
if (req->suspend) thread->suspend++;
+ thread->desktop = current->desktop;
reply->tid = get_thread_id( thread );
if ((reply->handle = alloc_handle( current->process, thread,
THREAD_ALL_ACCESS, req->inherit )))
diff --git a/server/thread.h b/server/thread.h
index d471686..749b277 100644
--- a/server/thread.h
+++ b/server/thread.h
@@ -82,6 +82,7 @@
int priority; /* priority level */
int affinity; /* affinity mask */
int suspend; /* suspend count */
+ obj_handle_t desktop; /* desktop handle */
time_t creation_time; /* Thread creation time */
time_t exit_time; /* Thread exit time */
struct token *token; /* security token associated with this thread */
diff --git a/server/trace.c b/server/trace.c
index d5fb96a..70129bd 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -2515,6 +2515,115 @@
dump_varargs_properties( cur_size );
}
+static void dump_create_winstation_request( const struct create_winstation_request *req )
+{
+ fprintf( stderr, " flags=%08x,", req->flags );
+ fprintf( stderr, " access=%08x,", req->access );
+ fprintf( stderr, " inherit=%d,", req->inherit );
+ fprintf( stderr, " name=" );
+ dump_varargs_unicode_str( cur_size );
+}
+
+static void dump_create_winstation_reply( const struct create_winstation_reply *req )
+{
+ fprintf( stderr, " handle=%p", req->handle );
+}
+
+static void dump_open_winstation_request( const struct open_winstation_request *req )
+{
+ fprintf( stderr, " access=%08x,", req->access );
+ fprintf( stderr, " inherit=%d,", req->inherit );
+ fprintf( stderr, " name=" );
+ dump_varargs_unicode_str( cur_size );
+}
+
+static void dump_open_winstation_reply( const struct open_winstation_reply *req )
+{
+ fprintf( stderr, " handle=%p", req->handle );
+}
+
+static void dump_close_winstation_request( const struct close_winstation_request *req )
+{
+ fprintf( stderr, " handle=%p", req->handle );
+}
+
+static void dump_get_process_winstation_request( const struct get_process_winstation_request *req )
+{
+}
+
+static void dump_get_process_winstation_reply( const struct get_process_winstation_reply *req )
+{
+ fprintf( stderr, " handle=%p", req->handle );
+}
+
+static void dump_set_process_winstation_request( const struct set_process_winstation_request *req )
+{
+ fprintf( stderr, " handle=%p", req->handle );
+}
+
+static void dump_create_desktop_request( const struct create_desktop_request *req )
+{
+ fprintf( stderr, " flags=%08x,", req->flags );
+ fprintf( stderr, " access=%08x,", req->access );
+ fprintf( stderr, " inherit=%d,", req->inherit );
+ fprintf( stderr, " name=" );
+ dump_varargs_unicode_str( cur_size );
+}
+
+static void dump_create_desktop_reply( const struct create_desktop_reply *req )
+{
+ fprintf( stderr, " handle=%p", req->handle );
+}
+
+static void dump_open_desktop_request( const struct open_desktop_request *req )
+{
+ fprintf( stderr, " flags=%08x,", req->flags );
+ fprintf( stderr, " access=%08x,", req->access );
+ fprintf( stderr, " inherit=%d,", req->inherit );
+ fprintf( stderr, " name=" );
+ dump_varargs_unicode_str( cur_size );
+}
+
+static void dump_open_desktop_reply( const struct open_desktop_reply *req )
+{
+ fprintf( stderr, " handle=%p", req->handle );
+}
+
+static void dump_close_desktop_request( const struct close_desktop_request *req )
+{
+ fprintf( stderr, " handle=%p", req->handle );
+}
+
+static void dump_get_thread_desktop_request( const struct get_thread_desktop_request *req )
+{
+ fprintf( stderr, " tid=%04x", req->tid );
+}
+
+static void dump_get_thread_desktop_reply( const struct get_thread_desktop_reply *req )
+{
+ fprintf( stderr, " handle=%p", req->handle );
+}
+
+static void dump_set_thread_desktop_request( const struct set_thread_desktop_request *req )
+{
+ fprintf( stderr, " handle=%p", req->handle );
+}
+
+static void dump_set_user_object_info_request( const struct set_user_object_info_request *req )
+{
+ fprintf( stderr, " handle=%p,", req->handle );
+ fprintf( stderr, " flags=%08x,", req->flags );
+ fprintf( stderr, " obj_flags=%08x", req->obj_flags );
+}
+
+static void dump_set_user_object_info_reply( const struct set_user_object_info_reply *req )
+{
+ fprintf( stderr, " is_desktop=%d,", req->is_desktop );
+ fprintf( stderr, " old_obj_flags=%08x,", req->old_obj_flags );
+ fprintf( stderr, " name=" );
+ dump_varargs_unicode_str( cur_size );
+}
+
static void dump_attach_thread_input_request( const struct attach_thread_input_request *req )
{
fprintf( stderr, " tid_from=%04x,", req->tid_from );
@@ -3106,6 +3215,17 @@
(dump_func)dump_remove_window_property_request,
(dump_func)dump_get_window_property_request,
(dump_func)dump_get_window_properties_request,
+ (dump_func)dump_create_winstation_request,
+ (dump_func)dump_open_winstation_request,
+ (dump_func)dump_close_winstation_request,
+ (dump_func)dump_get_process_winstation_request,
+ (dump_func)dump_set_process_winstation_request,
+ (dump_func)dump_create_desktop_request,
+ (dump_func)dump_open_desktop_request,
+ (dump_func)dump_close_desktop_request,
+ (dump_func)dump_get_thread_desktop_request,
+ (dump_func)dump_set_thread_desktop_request,
+ (dump_func)dump_set_user_object_info_request,
(dump_func)dump_attach_thread_input_request,
(dump_func)dump_get_thread_input_request,
(dump_func)dump_get_last_input_time_request,
@@ -3302,6 +3422,17 @@
(dump_func)dump_remove_window_property_reply,
(dump_func)dump_get_window_property_reply,
(dump_func)dump_get_window_properties_reply,
+ (dump_func)dump_create_winstation_reply,
+ (dump_func)dump_open_winstation_reply,
+ (dump_func)0,
+ (dump_func)dump_get_process_winstation_reply,
+ (dump_func)0,
+ (dump_func)dump_create_desktop_reply,
+ (dump_func)dump_open_desktop_reply,
+ (dump_func)0,
+ (dump_func)dump_get_thread_desktop_reply,
+ (dump_func)0,
+ (dump_func)dump_set_user_object_info_reply,
(dump_func)0,
(dump_func)dump_get_thread_input_reply,
(dump_func)dump_get_last_input_time_reply,
@@ -3498,6 +3629,17 @@
"remove_window_property",
"get_window_property",
"get_window_properties",
+ "create_winstation",
+ "open_winstation",
+ "close_winstation",
+ "get_process_winstation",
+ "set_process_winstation",
+ "create_desktop",
+ "open_desktop",
+ "close_desktop",
+ "get_thread_desktop",
+ "set_thread_desktop",
+ "set_user_object_info",
"attach_thread_input",
"get_thread_input",
"get_last_input_time",
diff --git a/server/user.h b/server/user.h
index 0f66a4d..ff8af79 100644
--- a/server/user.h
+++ b/server/user.h
@@ -118,4 +118,10 @@
extern atom_t get_class_atom( struct window_class *class );
extern void *get_class_client_ptr( struct window_class *class );
+/* windows station functions */
+
+extern void connect_process_winstation( struct process *process, const WCHAR *name, size_t len );
+extern void connect_thread_desktop( struct thread *thread, const WCHAR *name, size_t len );
+extern void close_thread_desktop( struct thread *thread );
+
#endif /* __WINE_SERVER_USER_H */
diff --git a/server/winstation.c b/server/winstation.c
new file mode 100644
index 0000000..f25e210
--- /dev/null
+++ b/server/winstation.c
@@ -0,0 +1,487 @@
+/*
+ * Server-side window stations and desktops handling
+ *
+ * Copyright (C) 2002, 2005 Alexandre Julliard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "config.h"
+#include "wine/port.h"
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+
+#include "object.h"
+#include "handle.h"
+#include "request.h"
+#include "process.h"
+#include "wine/unicode.h"
+
+struct winstation
+{
+ struct object obj; /* object header */
+ unsigned int flags; /* winstation flags */
+ struct list entry; /* entry in global winstation list */
+ struct list desktops; /* list of desktops of this winstation */
+};
+
+struct desktop
+{
+ struct object obj; /* object header */
+ unsigned int flags; /* desktop flags */
+ struct winstation *winstation; /* winstation this desktop belongs to */
+ struct list entry; /* entry in winstation list of desktops */
+};
+
+static struct list winstation_list = LIST_INIT(winstation_list);
+static struct winstation *interactive_winstation;
+static struct namespace *winstation_namespace;
+
+static void winstation_dump( struct object *obj, int verbose );
+static void winstation_destroy( struct object *obj );
+static void desktop_dump( struct object *obj, int verbose );
+static void desktop_destroy( struct object *obj );
+
+static const struct object_ops winstation_ops =
+{
+ sizeof(struct winstation), /* size */
+ winstation_dump, /* dump */
+ no_add_queue, /* add_queue */
+ NULL, /* remove_queue */
+ NULL, /* signaled */
+ NULL, /* satisfied */
+ no_signal, /* signal */
+ no_get_fd, /* get_fd */
+ winstation_destroy /* destroy */
+};
+
+
+static const struct object_ops desktop_ops =
+{
+ sizeof(struct desktop), /* size */
+ desktop_dump, /* dump */
+ no_add_queue, /* add_queue */
+ NULL, /* remove_queue */
+ NULL, /* signaled */
+ NULL, /* satisfied */
+ no_signal, /* signal */
+ no_get_fd, /* get_fd */
+ desktop_destroy /* destroy */
+};
+
+#define DESKTOP_ALL_ACCESS 0x01ff
+
+/* create a winstation object */
+static struct winstation *create_winstation( const WCHAR *name, size_t len, unsigned int flags )
+{
+ struct winstation *winstation;
+
+ if (!winstation_namespace && !(winstation_namespace = create_namespace( 7, FALSE )))
+ return NULL;
+
+ if (memchrW( name, '\\', len / sizeof(WCHAR) )) /* no backslash allowed in name */
+ {
+ set_error( STATUS_INVALID_PARAMETER );
+ return NULL;
+ }
+
+ if ((winstation = create_named_object( winstation_namespace, &winstation_ops, name, len )))
+ {
+ if (get_error() != STATUS_OBJECT_NAME_COLLISION)
+ {
+ /* initialize it if it didn't already exist */
+ winstation->flags = flags;
+ list_add_tail( &winstation_list, &winstation->entry );
+ list_init( &winstation->desktops );
+ }
+ }
+ return winstation;
+}
+
+static void winstation_dump( struct object *obj, int verbose )
+{
+ struct winstation *winstation = (struct winstation *)obj;
+
+ fprintf( stderr, "Winstation flags=%x ", winstation->flags );
+ dump_object_name( &winstation->obj );
+ fputc( '\n', stderr );
+}
+
+static void winstation_destroy( struct object *obj )
+{
+ struct winstation *winstation = (struct winstation *)obj;
+
+ if (winstation == interactive_winstation) interactive_winstation = NULL;
+ list_remove( &winstation->entry );
+}
+
+/* retrieve the process window station, checking the handle access rights */
+inline static struct winstation *get_process_winstation( struct process *process,
+ unsigned int access )
+{
+ return (struct winstation *)get_handle_obj( process, process->winstation,
+ access, &winstation_ops );
+}
+
+/* build the full name of a desktop object */
+static WCHAR *build_desktop_name( const WCHAR *name, size_t len,
+ struct winstation *winstation, size_t *res_len )
+{
+ const WCHAR *winstation_name;
+ WCHAR *full_name;
+ size_t winstation_len;
+
+ if (memchrW( name, '\\', len / sizeof(WCHAR) ))
+ {
+ set_error( STATUS_INVALID_PARAMETER );
+ return NULL;
+ }
+
+ if (!(winstation_name = get_object_name( &winstation->obj, &winstation_len )))
+ winstation_len = 0;
+
+ *res_len = winstation_len + len + sizeof(WCHAR);
+ if (!(full_name = mem_alloc( *res_len ))) return NULL;
+ memcpy( full_name, winstation_name, winstation_len );
+ full_name[winstation_len / sizeof(WCHAR)] = '\\';
+ memcpy( full_name + (winstation_len + 1) / sizeof(WCHAR), name, len );
+ return full_name;
+}
+
+/* create a desktop object */
+static struct desktop *create_desktop( const WCHAR *name, size_t len, unsigned int flags,
+ struct winstation *winstation )
+{
+ struct desktop *desktop;
+ WCHAR *full_name;
+ size_t full_len;
+
+ if (!(full_name = build_desktop_name( name, len, winstation, &full_len ))) return NULL;
+
+ if ((desktop = create_named_object( winstation_namespace, &desktop_ops, full_name, full_len )))
+ {
+ if (get_error() != STATUS_OBJECT_NAME_COLLISION)
+ {
+ /* initialize it if it didn't already exist */
+ desktop->flags = flags;
+ desktop->winstation = (struct winstation *)grab_object( winstation );
+ list_add_tail( &winstation->desktops, &desktop->entry );
+ }
+ }
+ free( full_name );
+ return desktop;
+}
+
+static void desktop_dump( struct object *obj, int verbose )
+{
+ struct desktop *desktop = (struct desktop *)obj;
+
+ fprintf( stderr, "Desktop flags=%x winstation=%p ", desktop->flags, desktop->winstation );
+ dump_object_name( &desktop->obj );
+ fputc( '\n', stderr );
+}
+
+static void desktop_destroy( struct object *obj )
+{
+ struct desktop *desktop = (struct desktop *)obj;
+
+ list_remove( &desktop->entry );
+ release_object( desktop->winstation );
+}
+
+/* close a desktop handle if allowed */
+static void close_desktop_handle( struct process *process, obj_handle_t handle )
+{
+ struct thread *thread;
+
+ /* make sure it's not in use by any thread in the process */
+ LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry )
+ {
+ if (thread->desktop == handle)
+ {
+ set_error( STATUS_DEVICE_BUSY );
+ return;
+ }
+ }
+ close_handle( process, handle, NULL );
+}
+
+/* connect a process to its window station */
+void connect_process_winstation( struct process *process, const WCHAR *name, size_t len )
+{
+ struct winstation *winstation;
+
+ if (process->winstation) return; /* already has one */
+
+ /* check for an inherited winstation handle (don't ask...) */
+ if ((process->winstation = find_inherited_handle( process, &winstation_ops )) != 0) return;
+
+ if (name)
+ {
+ winstation = create_winstation( name, len, 0 );
+ }
+ else
+ {
+ if (!interactive_winstation)
+ {
+ static const WCHAR winsta0W[] = {'W','i','n','S','t','a','0'};
+ interactive_winstation = create_winstation( winsta0W, sizeof(winsta0W), 0 );
+ winstation = interactive_winstation;
+ }
+ else winstation = (struct winstation *)grab_object( interactive_winstation );
+ }
+ if (winstation)
+ {
+ if ((process->winstation = alloc_handle( process, winstation, WINSTA_ALL_ACCESS, FALSE )))
+ {
+ int fd = -1;
+ /* FIXME: Windows doesn't do it this way */
+ set_handle_info( process, process->winstation, HANDLE_FLAG_PROTECT_FROM_CLOSE,
+ HANDLE_FLAG_PROTECT_FROM_CLOSE, &fd );
+ }
+ release_object( winstation );
+ }
+ clear_error(); /* ignore errors */
+}
+
+/* connect a thread to its desktop */
+void connect_thread_desktop( struct thread *thread, const WCHAR *name, size_t len )
+{
+ struct desktop *desktop;
+ struct winstation *winstation;
+ struct process *process = thread->process;
+
+ if (thread->desktop) return; /* already has one */
+
+ if ((winstation = get_process_winstation( process, WINSTA_CREATEDESKTOP )))
+ {
+ static const WCHAR defaultW[] = {'D','e','f','a','u','l','t'};
+
+ if (!name)
+ {
+ name = defaultW;
+ len = sizeof(defaultW);
+ }
+ if ((desktop = create_desktop( name, len, 0, winstation )))
+ {
+ thread->desktop = alloc_handle( process, desktop, DESKTOP_ALL_ACCESS, FALSE );
+ release_object( desktop );
+ }
+ release_object( winstation );
+ }
+ clear_error(); /* ignore errors */
+}
+
+/* close the desktop of a given thread */
+void close_thread_desktop( struct thread *thread )
+{
+ obj_handle_t handle = thread->desktop;
+
+ thread->desktop = 0;
+ if (handle) close_desktop_handle( thread->process, handle );
+ clear_error(); /* ignore errors */
+}
+
+
+/* create a window station */
+DECL_HANDLER(create_winstation)
+{
+ struct winstation *winstation;
+
+ reply->handle = 0;
+ if ((winstation = create_winstation( get_req_data(), get_req_data_size(), req->flags )))
+ {
+ reply->handle = alloc_handle( current->process, winstation, req->access, req->inherit );
+ release_object( winstation );
+ }
+}
+
+/* open a handle to a window station */
+DECL_HANDLER(open_winstation)
+{
+ if (winstation_namespace)
+ reply->handle = open_object( winstation_namespace, get_req_data(), get_req_data_size(),
+ &winstation_ops, req->access, req->inherit );
+ else
+ set_error( STATUS_OBJECT_NAME_NOT_FOUND );
+}
+
+
+/* close a window station */
+DECL_HANDLER(close_winstation)
+{
+ struct winstation *winstation;
+
+ if ((winstation = (struct winstation *)get_handle_obj( current->process, req->handle,
+ 0, &winstation_ops )))
+ {
+ if (req->handle != current->process->winstation)
+ close_handle( current->process, req->handle, NULL );
+ else
+ set_error( STATUS_ACCESS_DENIED );
+ release_object( winstation );
+ }
+}
+
+
+/* get the process current window station */
+DECL_HANDLER(get_process_winstation)
+{
+ reply->handle = current->process->winstation;
+}
+
+
+/* set the process current window station */
+DECL_HANDLER(set_process_winstation)
+{
+ struct winstation *winstation;
+
+ if ((winstation = (struct winstation *)get_handle_obj( current->process, req->handle,
+ 0, &winstation_ops )))
+ {
+ /* FIXME: should we close the old one? */
+ current->process->winstation = req->handle;
+ release_object( winstation );
+ }
+}
+
+/* create a desktop */
+DECL_HANDLER(create_desktop)
+{
+ struct desktop *desktop;
+ struct winstation *winstation;
+
+ reply->handle = 0;
+ if ((winstation = get_process_winstation( current->process, WINSTA_CREATEDESKTOP )))
+ {
+ if ((desktop = create_desktop( get_req_data(), get_req_data_size(),
+ req->flags, winstation )))
+ {
+ reply->handle = alloc_handle( current->process, desktop, req->access, req->inherit );
+ release_object( desktop );
+ }
+ release_object( winstation );
+ }
+}
+
+/* open a handle to a desktop */
+DECL_HANDLER(open_desktop)
+{
+ struct winstation *winstation;
+
+ if ((winstation = get_process_winstation( current->process, 0 /* FIXME: access rights? */ )))
+ {
+ size_t full_len;
+ WCHAR *full_name;
+
+ if ((full_name = build_desktop_name( get_req_data(), get_req_data_size(),
+ winstation, &full_len )))
+ {
+ reply->handle = open_object( winstation_namespace, full_name, full_len,
+ &desktop_ops, req->access, req->inherit );
+ free( full_name );
+ }
+ release_object( winstation );
+ }
+}
+
+
+/* close a desktop */
+DECL_HANDLER(close_desktop)
+{
+ struct desktop *desktop;
+
+ /* make sure it is a desktop handle */
+ if ((desktop = (struct desktop *)get_handle_obj( current->process, req->handle,
+ 0, &desktop_ops )))
+ {
+ close_desktop_handle( current->process, req->handle );
+ release_object( desktop );
+ }
+}
+
+
+/* get the thread current desktop */
+DECL_HANDLER(get_thread_desktop)
+{
+ struct thread *thread;
+
+ if (!(thread = get_thread_from_id( req->tid ))) return;
+ reply->handle = thread->desktop;
+ release_object( thread );
+}
+
+
+/* set the thread current desktop */
+DECL_HANDLER(set_thread_desktop)
+{
+ struct desktop *desktop;
+
+ if ((desktop = (struct desktop *)get_handle_obj( current->process, req->handle, 0, &desktop_ops )))
+ {
+ /* FIXME: should we close the old one? */
+ current->desktop = req->handle;
+ release_object( desktop );
+ }
+}
+
+
+/* get/set information about a user object (window station or desktop) */
+DECL_HANDLER(set_user_object_info)
+{
+ struct object *obj;
+
+ if (!(obj = get_handle_obj( current->process, req->handle, 0, NULL ))) return;
+
+ if (obj->ops == &desktop_ops)
+ {
+ struct desktop *desktop = (struct desktop *)obj;
+ reply->is_desktop = 1;
+ reply->old_obj_flags = desktop->flags;
+ if (req->flags & SET_USER_OBJECT_FLAGS) desktop->flags = req->obj_flags;
+ }
+ else if (obj->ops == &winstation_ops)
+ {
+ struct winstation *winstation = (struct winstation *)obj;
+ reply->is_desktop = 0;
+ reply->old_obj_flags = winstation->flags;
+ if (req->flags & SET_USER_OBJECT_FLAGS) winstation->flags = req->obj_flags;
+ }
+ else
+ {
+ set_error( STATUS_OBJECT_TYPE_MISMATCH );
+ release_object( obj );
+ return;
+ }
+ if (get_reply_max_size())
+ {
+ size_t len;
+ const WCHAR *ptr, *name = get_object_name( obj, &len );
+
+ /* if there is a backslash return the part of the name after it */
+ if (name && (ptr = memchrW( name, '\\', len )))
+ {
+ name = ptr + 1;
+ len -= (ptr - name) * sizeof(WCHAR);
+ }
+ if (name) set_reply_data( name, min( len, get_reply_max_size() ));
+ }
+ release_object( obj );
+}