- Fix 2 user32 winstation test failures (patch by Giannis Adamopoulos johnyadams...
[reactos.git] / reactos / dll / win32 / user32 / misc / winsta.c
index 1595abd..a048169 100644 (file)
 
 #include <user32.h>
 
-/*
- * @implemented
- */
-BOOL STDCALL
-CloseWindowStation(HWINSTA hWinSta)
-{
-  return(NtUserCloseWindowStation(hWinSta));
-}
+#include <wine/debug.h>
 
 
 /*
  * @implemented
  */
-HWINSTA STDCALL
+HWINSTA WINAPI
 CreateWindowStationA(LPSTR lpwinsta,
                     DWORD dwReserved,
                     ACCESS_MASK dwDesiredAccess,
                     LPSECURITY_ATTRIBUTES lpsa)
 {
-  ANSI_STRING WindowStationNameA;
-  UNICODE_STRING WindowStationNameU;
-  HWINSTA hWinSta;
+    UNICODE_STRING WindowStationNameU;
+    HWINSTA hWinSta;
 
-  if (lpwinsta != NULL)
+    if (lpwinsta)
     {
-      RtlInitAnsiString(&WindowStationNameA, lpwinsta);
-      RtlAnsiStringToUnicodeString(&WindowStationNameU, &WindowStationNameA,
-                                  TRUE);
+        /* After conversion, the buffer is zero-terminated */
+        RtlCreateUnicodeStringFromAsciiz(&WindowStationNameU, lpwinsta);
     }
-  else
+    else
     {
-      RtlInitUnicodeString(&WindowStationNameU, NULL);
+        RtlInitUnicodeString(&WindowStationNameU, NULL);
     }
 
-  hWinSta = CreateWindowStationW(WindowStationNameU.Buffer,
-                                dwReserved,
-                                dwDesiredAccess,
-                                lpsa);
+    hWinSta = CreateWindowStationW(WindowStationNameU.Buffer,
+                                   dwReserved,
+                                   dwDesiredAccess,
+                                   lpsa);
 
-  RtlFreeUnicodeString(&WindowStationNameU);
+    /* Free the string, if it was allocated */
+    if (lpwinsta) RtlFreeUnicodeString(&WindowStationNameU);
 
-  return hWinSta;
+    return hWinSta;
 }
 
 
 /*
  * @implemented
  */
-HWINSTA STDCALL
+HWINSTA WINAPI
 CreateWindowStationW(LPWSTR lpwinsta,
                     DWORD dwReserved,
                     ACCESS_MASK dwDesiredAccess,
@@ -71,7 +63,7 @@ CreateWindowStationW(LPWSTR lpwinsta,
 
   return NtUserCreateWindowStation(&WindowStationName,
                                   dwDesiredAccess,
-                                  lpsa, 0, 0, 0);
+                                  lpsa, 0, 0, 0, 0);
 }
 
 /*
@@ -96,8 +88,7 @@ EnumNamesW(HWINSTA WindowStation,
     */
    if (NULL == WindowStation && Desktops)
    {
-      SetLastError(ERROR_INVALID_HANDLE);
-      return FALSE;
+      WindowStation = GetProcessWindowStation();
    }
 
    /*
@@ -252,7 +243,7 @@ EnumNamesA(HWINSTA WindowStation,
 /*
  * @implemented
  */
-BOOL STDCALL
+BOOL WINAPI
 EnumWindowStationsA(WINSTAENUMPROCA EnumFunc,
                    LPARAM Context)
 {
@@ -263,7 +254,7 @@ EnumWindowStationsA(WINSTAENUMPROCA EnumFunc,
 /*
  * @implemented
  */
-BOOL STDCALL
+BOOL WINAPI
 EnumWindowStationsW(WINSTAENUMPROCW EnumFunc,
                    LPARAM Context)
 {
@@ -274,50 +265,39 @@ EnumWindowStationsW(WINSTAENUMPROCW EnumFunc,
 /*
  * @implemented
  */
-HWINSTA STDCALL
-GetProcessWindowStation(VOID)
-{
-  return NtUserGetProcessWindowStation();
-}
-
-
-/*
- * @implemented
- */
-HWINSTA STDCALL
+HWINSTA WINAPI
 OpenWindowStationA(LPSTR lpszWinSta,
                   BOOL fInherit,
                   ACCESS_MASK dwDesiredAccess)
 {
-  ANSI_STRING WindowStationNameA;
-  UNICODE_STRING WindowStationNameU;
-  HWINSTA hWinSta;
+    UNICODE_STRING WindowStationNameU;
+    HWINSTA hWinSta;
 
-  if (lpszWinSta != NULL)
+    if (lpszWinSta)
     {
-      RtlInitAnsiString(&WindowStationNameA, lpszWinSta);
-      RtlAnsiStringToUnicodeString(&WindowStationNameU, &WindowStationNameA,
-                                  TRUE);
+        /* After conversion, the buffer is zero-terminated */
+        RtlCreateUnicodeStringFromAsciiz(&WindowStationNameU, lpszWinSta);
     }
-  else
+    else
     {
-      RtlInitUnicodeString(&WindowStationNameU, NULL);
+        RtlInitUnicodeString(&WindowStationNameU, NULL);
     }
 
-  hWinSta = OpenWindowStationW(WindowStationNameU.Buffer,
-                              fInherit,
-                              dwDesiredAccess);
+    hWinSta = OpenWindowStationW(WindowStationNameU.Buffer,
+                                 fInherit,
+                                 dwDesiredAccess);
 
-  RtlFreeUnicodeString(&WindowStationNameU);
+    /* Free the string, if it was allocated */
+    if (lpszWinSta) RtlFreeUnicodeString(&WindowStationNameU);
 
-  return hWinSta;
+    return hWinSta;
 }
 
 
 /*
  * @implemented
  */
-HWINSTA STDCALL
+HWINSTA WINAPI
 OpenWindowStationW(LPWSTR lpszWinSta,
                   BOOL fInherit,
                   ACCESS_MASK dwDesiredAccess)
@@ -330,21 +310,11 @@ OpenWindowStationW(LPWSTR lpszWinSta,
 }
 
 
-/*
- * @implemented
- */
-BOOL STDCALL
-SetProcessWindowStation(HWINSTA hWinSta)
-{
-  return NtUserSetProcessWindowStation(hWinSta);
-}
-
-
 /*
  * @unimplemented
  */
 DWORD
-STDCALL
+WINAPI
 SetWindowStationUser(
   DWORD Unknown1,
   DWORD Unknown2,
@@ -355,27 +325,5 @@ SetWindowStationUser(
   return NtUserSetWindowStationUser(Unknown1, Unknown2, Unknown3, Unknown4);
 }
 
-
-/*
- * @implemented
- */
-BOOL
-STDCALL
-LockWindowStation(HWINSTA hWinSta)
-{
-  return NtUserLockWindowStation(hWinSta);
-}
-
-
-/*
- * @implemented
- */
-BOOL
-STDCALL
-UnlockWindowStation(HWINSTA hWinSta)
-{
-  return NtUserUnlockWindowStation(hWinSta);
-}
-
 /* EOF */