1 /* Copyright 2005 Ulrich Czekalla
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define WIN32_NO_STATUS
25 #include "wine/winternl.h"
27 #include "wine/debug.h"
28 #include "wine/heap.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(wtsapi
);
32 #ifdef __REACTOS__ /* FIXME: Inspect */
33 #define GetCurrentProcessToken() ((HANDLE)~(ULONG_PTR)3)
36 /************************************************************
37 * WTSCloseServer (WTSAPI32.@)
39 void WINAPI
WTSCloseServer(HANDLE hServer
)
41 FIXME("Stub %p\n", hServer
);
44 /************************************************************
45 * WTSConnectSessionA (WTSAPI32.@)
47 BOOL WINAPI
WTSConnectSessionA(ULONG LogonId
, ULONG TargetLogonId
, PSTR pPassword
, BOOL bWait
)
49 FIXME("Stub %d %d (%s) %d\n", LogonId
, TargetLogonId
, debugstr_a(pPassword
), bWait
);
53 /************************************************************
54 * WTSConnectSessionW (WTSAPI32.@)
56 BOOL WINAPI
WTSConnectSessionW(ULONG LogonId
, ULONG TargetLogonId
, PWSTR pPassword
, BOOL bWait
)
58 FIXME("Stub %d %d (%s) %d\n", LogonId
, TargetLogonId
, debugstr_w(pPassword
), bWait
);
62 /************************************************************
63 * WTSDisconnectSession (WTSAPI32.@)
65 BOOL WINAPI
WTSDisconnectSession(HANDLE hServer
, DWORD SessionId
, BOOL bWait
)
67 FIXME("Stub %p 0x%08x %d\n", hServer
, SessionId
, bWait
);
71 /************************************************************
72 * WTSEnableChildSessions (WTSAPI32.@)
74 BOOL WINAPI
WTSEnableChildSessions(BOOL enable
)
76 FIXME("Stub %d\n", enable
);
80 /************************************************************
81 * WTSEnumerateProcessesA (WTSAPI32.@)
83 BOOL WINAPI
WTSEnumerateProcessesA(HANDLE hServer
, DWORD Reserved
, DWORD Version
,
84 PWTS_PROCESS_INFOA
* ppProcessInfo
, DWORD
* pCount
)
86 FIXME("Stub %p 0x%08x 0x%08x %p %p\n", hServer
, Reserved
, Version
,
87 ppProcessInfo
, pCount
);
89 if (!ppProcessInfo
|| !pCount
) return FALSE
;
92 *ppProcessInfo
= NULL
;
97 /************************************************************
98 * WTSEnumerateProcessesW (WTSAPI32.@)
100 BOOL WINAPI
WTSEnumerateProcessesW(HANDLE hServer
, DWORD Reserved
, DWORD Version
,
101 PWTS_PROCESS_INFOW
* ppProcessInfo
, DWORD
* pCount
)
103 WTS_PROCESS_INFOW
*processInfo
;
104 SYSTEM_PROCESS_INFORMATION
*spi
;
111 if (!ppProcessInfo
|| !pCount
|| Reserved
!= 0 || Version
!= 1)
113 SetLastError(ERROR_INVALID_PARAMETER
);
117 if (hServer
!= WTS_CURRENT_SERVER_HANDLE
)
119 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
126 HeapFree(GetProcessHeap(), 0, buf
);
127 buf
= HeapAlloc(GetProcessHeap(), 0, size
);
130 SetLastError(ERROR_OUTOFMEMORY
);
133 status
= NtQuerySystemInformation(SystemProcessInformation
, buf
, size
, NULL
);
135 while (status
== STATUS_INFO_LENGTH_MISMATCH
);
137 if (status
!= STATUS_SUCCESS
)
139 HeapFree(GetProcessHeap(), 0, buf
);
140 SetLastError(RtlNtStatusToDosError(status
));
148 size
+= sizeof(WTS_PROCESS_INFOW
) + spi
->ProcessName
.Length
+ sizeof(WCHAR
);
150 if (spi
->NextEntryOffset
== 0) break;
151 spi
= (SYSTEM_PROCESS_INFORMATION
*)(((PCHAR
)spi
) + spi
->NextEntryOffset
);
154 processInfo
= HeapAlloc(GetProcessHeap(), 0, size
);
157 HeapFree(GetProcessHeap(), 0, buf
);
158 SetLastError(ERROR_OUTOFMEMORY
);
161 name
= (WCHAR
*)&processInfo
[count
];
163 *ppProcessInfo
= processInfo
;
169 processInfo
->SessionId
= 0;
170 processInfo
->ProcessId
= HandleToUlong(spi
->UniqueProcessId
);
171 processInfo
->pProcessName
= name
;
172 processInfo
->pUserSid
= NULL
;
173 memcpy( name
, spi
->ProcessName
.Buffer
, spi
->ProcessName
.Length
);
174 name
[ spi
->ProcessName
.Length
/sizeof(WCHAR
) ] = 0;
177 name
+= (spi
->ProcessName
.Length
+ sizeof(WCHAR
))/sizeof(WCHAR
);
178 spi
= (SYSTEM_PROCESS_INFORMATION
*)(((PCHAR
)spi
) + spi
->NextEntryOffset
);
181 HeapFree(GetProcessHeap(), 0, buf
);
185 /************************************************************
186 * WTSEnumerateServersA (WTSAPI32.@)
188 BOOL WINAPI
WTSEnumerateServersA(LPSTR pDomainName
, DWORD Reserved
, DWORD Version
, PWTS_SERVER_INFOA
*ppServerInfo
, DWORD
*pCount
)
190 FIXME("Stub %s 0x%08x 0x%08x %p %p\n", debugstr_a(pDomainName
), Reserved
, Version
, ppServerInfo
, pCount
);
194 /************************************************************
195 * WTSEnumerateServersW (WTSAPI32.@)
197 BOOL WINAPI
WTSEnumerateServersW(LPWSTR pDomainName
, DWORD Reserved
, DWORD Version
, PWTS_SERVER_INFOW
*ppServerInfo
, DWORD
*pCount
)
199 FIXME("Stub %s 0x%08x 0x%08x %p %p\n", debugstr_w(pDomainName
), Reserved
, Version
, ppServerInfo
, pCount
);
204 /************************************************************
205 * WTSEnumerateEnumerateSessionsA (WTSAPI32.@)
207 BOOL WINAPI
WTSEnumerateSessionsA(HANDLE hServer
, DWORD Reserved
, DWORD Version
,
208 PWTS_SESSION_INFOA
* ppSessionInfo
, DWORD
* pCount
)
212 if (!once
++) FIXME("Stub %p 0x%08x 0x%08x %p %p\n", hServer
, Reserved
, Version
,
213 ppSessionInfo
, pCount
);
215 if (!ppSessionInfo
|| !pCount
) return FALSE
;
218 *ppSessionInfo
= NULL
;
223 /************************************************************
224 * WTSEnumerateEnumerateSessionsW (WTSAPI32.@)
226 BOOL WINAPI
WTSEnumerateSessionsW(HANDLE hServer
, DWORD Reserved
, DWORD Version
,
227 PWTS_SESSION_INFOW
* ppSessionInfo
, DWORD
* pCount
)
229 FIXME("Stub %p 0x%08x 0x%08x %p %p\n", hServer
, Reserved
, Version
,
230 ppSessionInfo
, pCount
);
232 if (!ppSessionInfo
|| !pCount
) return FALSE
;
235 *ppSessionInfo
= NULL
;
240 /************************************************************
241 * WTSFreeMemory (WTSAPI32.@)
243 void WINAPI
WTSFreeMemory(PVOID pMemory
)
248 /************************************************************
249 * WTSLogoffSession (WTSAPI32.@)
251 BOOL WINAPI
WTSLogoffSession(HANDLE hserver
, DWORD session_id
, BOOL bwait
)
253 FIXME("(%p, 0x%x, %d): stub\n", hserver
, session_id
, bwait
);
254 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
258 /************************************************************
259 * WTSOpenServerA (WTSAPI32.@)
261 HANDLE WINAPI
WTSOpenServerA(LPSTR pServerName
)
263 FIXME("(%s) stub\n", debugstr_a(pServerName
));
264 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
268 /************************************************************
269 * WTSOpenServerW (WTSAPI32.@)
271 HANDLE WINAPI
WTSOpenServerW(LPWSTR pServerName
)
273 FIXME("(%s) stub\n", debugstr_w(pServerName
));
274 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
278 /************************************************************
279 * WTSQuerySessionInformationA (WTSAPI32.@)
281 BOOL WINAPI
WTSQuerySessionInformationA(
284 WTS_INFO_CLASS WTSInfoClass
,
286 DWORD
* BytesReturned
)
288 /* FIXME: Forward request to winsta.dll::WinStationQueryInformationA */
289 FIXME("Stub %p 0x%08x %d %p %p\n", hServer
, SessionId
, WTSInfoClass
,
290 Buffer
, BytesReturned
);
295 /************************************************************
296 * WTSQuerySessionInformationW (WTSAPI32.@)
298 BOOL WINAPI
WTSQuerySessionInformationW(
301 WTS_INFO_CLASS WTSInfoClass
,
303 DWORD
* BytesReturned
)
305 /* FIXME: Forward request to winsta.dll::WinStationQueryInformationW */
306 FIXME("Stub %p 0x%08x %d %p %p\n", hServer
, SessionId
, WTSInfoClass
,
307 Buffer
, BytesReturned
);
309 if (WTSInfoClass
== WTSUserName
)
314 GetUserNameW(NULL
, &count
);
315 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
) return FALSE
;
316 if (!(username
= heap_alloc(count
* sizeof(WCHAR
)))) return FALSE
;
317 GetUserNameW(username
, &count
);
319 *BytesReturned
= count
* sizeof(WCHAR
);
325 /************************************************************
326 * WTSQueryUserToken (WTSAPI32.@)
328 BOOL WINAPI
WTSQueryUserToken(ULONG session_id
, PHANDLE token
)
330 FIXME("%u %p\n", session_id
, token
);
334 SetLastError(ERROR_INVALID_PARAMETER
);
338 return DuplicateHandle(GetCurrentProcess(), GetCurrentProcessToken(),
339 GetCurrentProcess(), token
,
340 0, FALSE
, DUPLICATE_SAME_ACCESS
);
343 /************************************************************
344 * WTSQueryUserConfigA (WTSAPI32.@)
346 BOOL WINAPI
WTSQueryUserConfigA(LPSTR pServerName
, LPSTR pUserName
, WTS_CONFIG_CLASS WTSConfigClass
, LPSTR
*ppBuffer
, DWORD
*pBytesReturned
)
348 FIXME("Stub (%s) (%s) 0x%08x %p %p\n", debugstr_a(pServerName
), debugstr_a(pUserName
), WTSConfigClass
,
349 ppBuffer
, pBytesReturned
);
353 /************************************************************
354 * WTSQueryUserConfigW (WTSAPI32.@)
356 BOOL WINAPI
WTSQueryUserConfigW(LPWSTR pServerName
, LPWSTR pUserName
, WTS_CONFIG_CLASS WTSConfigClass
, LPWSTR
*ppBuffer
, DWORD
*pBytesReturned
)
358 FIXME("Stub (%s) (%s) 0x%08x %p %p\n", debugstr_w(pServerName
), debugstr_w(pUserName
), WTSConfigClass
,
359 ppBuffer
, pBytesReturned
);
364 /************************************************************
365 * WTSRegisterSessionNotification (WTSAPI32.@)
367 BOOL WINAPI
WTSRegisterSessionNotification(HWND hWnd
, DWORD dwFlags
)
369 FIXME("Stub %p 0x%08x\n", hWnd
, dwFlags
);
373 /************************************************************
374 * WTSRegisterSessionNotificationEx (WTSAPI32.@)
376 BOOL WINAPI
WTSRegisterSessionNotificationEx(HANDLE hServer
, HWND hWnd
, DWORD dwFlags
)
378 FIXME("Stub %p %p 0x%08x\n", hServer
, hWnd
, dwFlags
);
383 /************************************************************
384 * WTSSendMessageA (WTSAPI32.@)
386 BOOL WINAPI
WTSSendMessageA(HANDLE hServer
, DWORD SessionId
, LPSTR pTitle
, DWORD TitleLength
, LPSTR pMessage
,
387 DWORD MessageLength
, DWORD Style
, DWORD Timeout
, DWORD
*pResponse
, BOOL bWait
)
389 FIXME("Stub %p 0x%08x (%s) %d (%s) %d 0x%08x %d %p %d\n", hServer
, SessionId
, debugstr_a(pTitle
), TitleLength
, debugstr_a(pMessage
), MessageLength
, Style
, Timeout
, pResponse
, bWait
);
393 /************************************************************
394 * WTSSendMessageW (WTSAPI32.@)
396 BOOL WINAPI
WTSSendMessageW(HANDLE hServer
, DWORD SessionId
, LPWSTR pTitle
, DWORD TitleLength
, LPWSTR pMessage
,
397 DWORD MessageLength
, DWORD Style
, DWORD Timeout
, DWORD
*pResponse
, BOOL bWait
)
399 FIXME("Stub %p 0x%08x (%s) %d (%s) %d 0x%08x %d %p %d\n", hServer
, SessionId
, debugstr_w(pTitle
), TitleLength
, debugstr_w(pMessage
), MessageLength
, Style
, Timeout
, pResponse
, bWait
);
403 /************************************************************
404 * WTSSetUserConfigA (WTSAPI32.@)
406 BOOL WINAPI
WTSSetUserConfigA(LPSTR pServerName
, LPSTR pUserName
, WTS_CONFIG_CLASS WTSConfigClass
, LPSTR pBuffer
, DWORD DataLength
)
408 FIXME("Stub (%s) (%s) 0x%08x %p %d\n", debugstr_a(pServerName
), debugstr_a(pUserName
), WTSConfigClass
,pBuffer
, DataLength
);
412 /************************************************************
413 * WTSSetUserConfigW (WTSAPI32.@)
415 BOOL WINAPI
WTSSetUserConfigW(LPWSTR pServerName
, LPWSTR pUserName
, WTS_CONFIG_CLASS WTSConfigClass
, LPWSTR pBuffer
, DWORD DataLength
)
417 FIXME("Stub (%s) (%s) 0x%08x %p %d\n", debugstr_w(pServerName
), debugstr_w(pUserName
), WTSConfigClass
,pBuffer
, DataLength
);
421 /************************************************************
422 * WTSShutdownSystem (WTSAPI32.@)
424 BOOL WINAPI
WTSShutdownSystem(HANDLE hServer
, DWORD ShutdownFlag
)
426 FIXME("Stub %p 0x%08x\n", hServer
,ShutdownFlag
);
430 /************************************************************
431 * WTSStartRemoteControlSessionA (WTSAPI32.@)
433 BOOL WINAPI
WTSStartRemoteControlSessionA(LPSTR pTargetServerName
, ULONG TargetLogonId
, BYTE HotkeyVk
, USHORT HotkeyModifiers
)
435 FIXME("Stub (%s) %d %d %d\n", debugstr_a(pTargetServerName
), TargetLogonId
, HotkeyVk
, HotkeyModifiers
);
439 /************************************************************
440 * WTSStartRemoteControlSessionW (WTSAPI32.@)
442 BOOL WINAPI
WTSStartRemoteControlSessionW(LPWSTR pTargetServerName
, ULONG TargetLogonId
, BYTE HotkeyVk
, USHORT HotkeyModifiers
)
444 FIXME("Stub (%s) %d %d %d\n", debugstr_w(pTargetServerName
), TargetLogonId
, HotkeyVk
, HotkeyModifiers
);
448 /************************************************************
449 * WTSStopRemoteControlSession (WTSAPI32.@)
451 BOOL WINAPI
WTSStopRemoteControlSession(ULONG LogonId
)
453 FIXME("Stub %d\n", LogonId
);
457 /************************************************************
458 * WTSTerminateProcess (WTSAPI32.@)
460 BOOL WINAPI
WTSTerminateProcess(HANDLE hServer
, DWORD ProcessId
, DWORD ExitCode
)
462 FIXME("Stub %p %d %d\n", hServer
, ProcessId
, ExitCode
);
466 /************************************************************
467 * WTSUnRegisterSessionNotification (WTSAPI32.@)
469 BOOL WINAPI
WTSUnRegisterSessionNotification(HWND hWnd
)
471 FIXME("Stub %p\n", hWnd
);
475 /************************************************************
476 * WTSUnRegisterSessionNotification (WTSAPI32.@)
478 BOOL WINAPI
WTSUnRegisterSessionNotificationEx(HANDLE hServer
, HWND hWnd
)
480 FIXME("Stub %p %p\n", hServer
, hWnd
);
485 /************************************************************
486 * WTSVirtualChannelClose (WTSAPI32.@)
488 BOOL WINAPI
WTSVirtualChannelClose(HANDLE hChannelHandle
)
490 FIXME("Stub %p\n", hChannelHandle
);
494 /************************************************************
495 * WTSVirtualChannelOpen (WTSAPI32.@)
497 HANDLE WINAPI
WTSVirtualChannelOpen(HANDLE hServer
, DWORD SessionId
, LPSTR pVirtualName
)
499 FIXME("Stub %p %d (%s)\n", hServer
, SessionId
, debugstr_a(pVirtualName
));
503 /************************************************************
504 * WTSVirtualChannelOpen (WTSAPI32.@)
506 HANDLE WINAPI
WTSVirtualChannelOpenEx(DWORD SessionId
, LPSTR pVirtualName
, DWORD flags
)
508 FIXME("Stub %d (%s) %d\n", SessionId
, debugstr_a(pVirtualName
), flags
);
512 /************************************************************
513 * WTSVirtualChannelPurgeInput (WTSAPI32.@)
515 BOOL WINAPI
WTSVirtualChannelPurgeInput(HANDLE hChannelHandle
)
517 FIXME("Stub %p\n", hChannelHandle
);
521 /************************************************************
522 * WTSVirtualChannelPurgeOutput (WTSAPI32.@)
524 BOOL WINAPI
WTSVirtualChannelPurgeOutput(HANDLE hChannelHandle
)
526 FIXME("Stub %p\n", hChannelHandle
);
531 /************************************************************
532 * WTSVirtualChannelQuery (WTSAPI32.@)
534 BOOL WINAPI
WTSVirtualChannelQuery(HANDLE hChannelHandle
, WTS_VIRTUAL_CLASS WtsVirtualClass
, PVOID
*ppBuffer
, DWORD
*pBytesReturned
)
536 FIXME("Stub %p %d %p %p\n", hChannelHandle
, WtsVirtualClass
, ppBuffer
, pBytesReturned
);
540 /************************************************************
541 * WTSVirtualChannelRead (WTSAPI32.@)
543 BOOL WINAPI
WTSVirtualChannelRead(HANDLE hChannelHandle
, ULONG TimeOut
, PCHAR Buffer
, ULONG BufferSize
, PULONG pBytesRead
)
545 FIXME("Stub %p %d %p %d %p\n", hChannelHandle
, TimeOut
, Buffer
, BufferSize
, pBytesRead
);
549 /************************************************************
550 * WTSVirtualChannelWrite (WTSAPI32.@)
552 BOOL WINAPI
WTSVirtualChannelWrite(HANDLE hChannelHandle
, PCHAR Buffer
, ULONG Length
, PULONG pBytesWritten
)
554 FIXME("Stub %p %p %d %p\n", hChannelHandle
, Buffer
, Length
, pBytesWritten
);
558 /************************************************************
559 * WTSWaitSystemEvent (WTSAPI32.@)
561 BOOL WINAPI
WTSWaitSystemEvent(HANDLE hServer
, DWORD Mask
, DWORD
* Flags
)
563 /* FIXME: Forward request to winsta.dll::WinStationWaitSystemEvent */
564 FIXME("Stub %p 0x%08x %p\n", hServer
, Mask
, Flags
);