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"
29 WINE_DEFAULT_DEBUG_CHANNEL(wtsapi
);
31 #ifdef __REACTOS__ /* FIXME: Inspect */
32 #define GetCurrentProcessToken() ((HANDLE)~(ULONG_PTR)3)
35 /************************************************************
36 * WTSCloseServer (WTSAPI32.@)
38 void WINAPI
WTSCloseServer(HANDLE hServer
)
40 FIXME("Stub %p\n", hServer
);
43 /************************************************************
44 * WTSConnectSessionA (WTSAPI32.@)
46 BOOL WINAPI
WTSConnectSessionA(ULONG LogonId
, ULONG TargetLogonId
, PSTR pPassword
, BOOL bWait
)
48 FIXME("Stub %d %d (%s) %d\n", LogonId
, TargetLogonId
, debugstr_a(pPassword
), bWait
);
52 /************************************************************
53 * WTSConnectSessionW (WTSAPI32.@)
55 BOOL WINAPI
WTSConnectSessionW(ULONG LogonId
, ULONG TargetLogonId
, PWSTR pPassword
, BOOL bWait
)
57 FIXME("Stub %d %d (%s) %d\n", LogonId
, TargetLogonId
, debugstr_w(pPassword
), bWait
);
61 /************************************************************
62 * WTSDisconnectSession (WTSAPI32.@)
64 BOOL WINAPI
WTSDisconnectSession(HANDLE hServer
, DWORD SessionId
, BOOL bWait
)
66 FIXME("Stub %p 0x%08x %d\n", hServer
, SessionId
, bWait
);
70 /************************************************************
71 * WTSEnableChildSessions (WTSAPI32.@)
73 BOOL WINAPI
WTSEnableChildSessions(BOOL enable
)
75 FIXME("Stub %d\n", enable
);
79 /************************************************************
80 * WTSEnumerateProcessesA (WTSAPI32.@)
82 BOOL WINAPI
WTSEnumerateProcessesA(HANDLE hServer
, DWORD Reserved
, DWORD Version
,
83 PWTS_PROCESS_INFOA
* ppProcessInfo
, DWORD
* pCount
)
85 FIXME("Stub %p 0x%08x 0x%08x %p %p\n", hServer
, Reserved
, Version
,
86 ppProcessInfo
, pCount
);
88 if (!ppProcessInfo
|| !pCount
) return FALSE
;
91 *ppProcessInfo
= NULL
;
96 /************************************************************
97 * WTSEnumerateProcessesW (WTSAPI32.@)
99 BOOL WINAPI
WTSEnumerateProcessesW(HANDLE hServer
, DWORD Reserved
, DWORD Version
,
100 PWTS_PROCESS_INFOW
* ppProcessInfo
, DWORD
* pCount
)
102 WTS_PROCESS_INFOW
*processInfo
;
103 SYSTEM_PROCESS_INFORMATION
*spi
;
110 if (!ppProcessInfo
|| !pCount
|| Reserved
!= 0 || Version
!= 1)
112 SetLastError(ERROR_INVALID_PARAMETER
);
116 if (hServer
!= WTS_CURRENT_SERVER_HANDLE
)
118 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
125 HeapFree(GetProcessHeap(), 0, buf
);
126 buf
= HeapAlloc(GetProcessHeap(), 0, size
);
129 SetLastError(ERROR_OUTOFMEMORY
);
132 status
= NtQuerySystemInformation(SystemProcessInformation
, buf
, size
, NULL
);
134 while (status
== STATUS_INFO_LENGTH_MISMATCH
);
136 if (status
!= STATUS_SUCCESS
)
138 HeapFree(GetProcessHeap(), 0, buf
);
139 SetLastError(RtlNtStatusToDosError(status
));
147 size
+= sizeof(WTS_PROCESS_INFOW
) + spi
->ProcessName
.Length
+ sizeof(WCHAR
);
149 if (spi
->NextEntryOffset
== 0) break;
150 spi
= (SYSTEM_PROCESS_INFORMATION
*)(((PCHAR
)spi
) + spi
->NextEntryOffset
);
153 processInfo
= HeapAlloc(GetProcessHeap(), 0, size
);
156 HeapFree(GetProcessHeap(), 0, buf
);
157 SetLastError(ERROR_OUTOFMEMORY
);
160 name
= (WCHAR
*)&processInfo
[count
];
162 *ppProcessInfo
= processInfo
;
168 processInfo
->SessionId
= 0;
169 processInfo
->ProcessId
= HandleToUlong(spi
->UniqueProcessId
);
170 processInfo
->pProcessName
= name
;
171 processInfo
->pUserSid
= NULL
;
172 memcpy( name
, spi
->ProcessName
.Buffer
, spi
->ProcessName
.Length
);
173 name
[ spi
->ProcessName
.Length
/sizeof(WCHAR
) ] = 0;
176 name
+= (spi
->ProcessName
.Length
+ sizeof(WCHAR
))/sizeof(WCHAR
);
177 spi
= (SYSTEM_PROCESS_INFORMATION
*)(((PCHAR
)spi
) + spi
->NextEntryOffset
);
180 HeapFree(GetProcessHeap(), 0, buf
);
184 /************************************************************
185 * WTSEnumerateServersA (WTSAPI32.@)
187 BOOL WINAPI
WTSEnumerateServersA(LPSTR pDomainName
, DWORD Reserved
, DWORD Version
, PWTS_SERVER_INFOA
*ppServerInfo
, DWORD
*pCount
)
189 FIXME("Stub %s 0x%08x 0x%08x %p %p\n", debugstr_a(pDomainName
), Reserved
, Version
, ppServerInfo
, pCount
);
193 /************************************************************
194 * WTSEnumerateServersW (WTSAPI32.@)
196 BOOL WINAPI
WTSEnumerateServersW(LPWSTR pDomainName
, DWORD Reserved
, DWORD Version
, PWTS_SERVER_INFOW
*ppServerInfo
, DWORD
*pCount
)
198 FIXME("Stub %s 0x%08x 0x%08x %p %p\n", debugstr_w(pDomainName
), Reserved
, Version
, ppServerInfo
, pCount
);
203 /************************************************************
204 * WTSEnumerateEnumerateSessionsA (WTSAPI32.@)
206 BOOL WINAPI
WTSEnumerateSessionsA(HANDLE hServer
, DWORD Reserved
, DWORD Version
,
207 PWTS_SESSION_INFOA
* ppSessionInfo
, DWORD
* pCount
)
211 if (!once
++) FIXME("Stub %p 0x%08x 0x%08x %p %p\n", hServer
, Reserved
, Version
,
212 ppSessionInfo
, pCount
);
214 if (!ppSessionInfo
|| !pCount
) return FALSE
;
217 *ppSessionInfo
= NULL
;
222 /************************************************************
223 * WTSEnumerateEnumerateSessionsW (WTSAPI32.@)
225 BOOL WINAPI
WTSEnumerateSessionsW(HANDLE hServer
, DWORD Reserved
, DWORD Version
,
226 PWTS_SESSION_INFOW
* ppSessionInfo
, DWORD
* pCount
)
228 FIXME("Stub %p 0x%08x 0x%08x %p %p\n", hServer
, Reserved
, Version
,
229 ppSessionInfo
, pCount
);
231 if (!ppSessionInfo
|| !pCount
) return FALSE
;
234 *ppSessionInfo
= NULL
;
239 /************************************************************
240 * WTSFreeMemory (WTSAPI32.@)
242 void WINAPI
WTSFreeMemory(PVOID pMemory
)
244 HeapFree(GetProcessHeap(), 0, pMemory
);
247 /************************************************************
248 * WTSLogoffSession (WTSAPI32.@)
250 BOOL WINAPI
WTSLogoffSession(HANDLE hserver
, DWORD session_id
, BOOL bwait
)
252 FIXME("(%p, 0x%x, %d): stub\n", hserver
, session_id
, bwait
);
253 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
257 /************************************************************
258 * WTSOpenServerA (WTSAPI32.@)
260 HANDLE WINAPI
WTSOpenServerA(LPSTR pServerName
)
262 FIXME("(%s) stub\n", debugstr_a(pServerName
));
263 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
267 /************************************************************
268 * WTSOpenServerW (WTSAPI32.@)
270 HANDLE WINAPI
WTSOpenServerW(LPWSTR pServerName
)
272 FIXME("(%s) stub\n", debugstr_w(pServerName
));
273 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
277 /************************************************************
278 * WTSQuerySessionInformationA (WTSAPI32.@)
280 BOOL WINAPI
WTSQuerySessionInformationA(
283 WTS_INFO_CLASS WTSInfoClass
,
285 DWORD
* BytesReturned
)
287 /* FIXME: Forward request to winsta.dll::WinStationQueryInformationA */
288 FIXME("Stub %p 0x%08x %d %p %p\n", hServer
, SessionId
, WTSInfoClass
,
289 Buffer
, BytesReturned
);
294 /************************************************************
295 * WTSQuerySessionInformationW (WTSAPI32.@)
297 BOOL WINAPI
WTSQuerySessionInformationW(
300 WTS_INFO_CLASS WTSInfoClass
,
302 DWORD
* BytesReturned
)
304 /* FIXME: Forward request to winsta.dll::WinStationQueryInformationW */
305 FIXME("Stub %p 0x%08x %d %p %p\n", hServer
, SessionId
, WTSInfoClass
,
306 Buffer
, BytesReturned
);
311 /************************************************************
312 * WTSQueryUserToken (WTSAPI32.@)
314 BOOL WINAPI
WTSQueryUserToken(ULONG session_id
, PHANDLE token
)
316 FIXME("%u %p\n", session_id
, token
);
320 SetLastError(ERROR_INVALID_PARAMETER
);
324 return DuplicateHandle(GetCurrentProcess(), GetCurrentProcessToken(),
325 GetCurrentProcess(), token
,
326 0, FALSE
, DUPLICATE_SAME_ACCESS
);
329 /************************************************************
330 * WTSQueryUserConfigA (WTSAPI32.@)
332 BOOL WINAPI
WTSQueryUserConfigA(LPSTR pServerName
, LPSTR pUserName
, WTS_CONFIG_CLASS WTSConfigClass
, LPSTR
*ppBuffer
, DWORD
*pBytesReturned
)
334 FIXME("Stub (%s) (%s) 0x%08x %p %p\n", debugstr_a(pServerName
), debugstr_a(pUserName
), WTSConfigClass
,
335 ppBuffer
, pBytesReturned
);
339 /************************************************************
340 * WTSQueryUserConfigW (WTSAPI32.@)
342 BOOL WINAPI
WTSQueryUserConfigW(LPWSTR pServerName
, LPWSTR pUserName
, WTS_CONFIG_CLASS WTSConfigClass
, LPWSTR
*ppBuffer
, DWORD
*pBytesReturned
)
344 FIXME("Stub (%s) (%s) 0x%08x %p %p\n", debugstr_w(pServerName
), debugstr_w(pUserName
), WTSConfigClass
,
345 ppBuffer
, pBytesReturned
);
350 /************************************************************
351 * WTSRegisterSessionNotification (WTSAPI32.@)
353 BOOL WINAPI
WTSRegisterSessionNotification(HWND hWnd
, DWORD dwFlags
)
355 FIXME("Stub %p 0x%08x\n", hWnd
, dwFlags
);
359 /************************************************************
360 * WTSRegisterSessionNotificationEx (WTSAPI32.@)
362 BOOL WINAPI
WTSRegisterSessionNotificationEx(HANDLE hServer
, HWND hWnd
, DWORD dwFlags
)
364 FIXME("Stub %p %p 0x%08x\n", hServer
, hWnd
, dwFlags
);
369 /************************************************************
370 * WTSSendMessageA (WTSAPI32.@)
372 BOOL WINAPI
WTSSendMessageA(HANDLE hServer
, DWORD SessionId
, LPSTR pTitle
, DWORD TitleLength
, LPSTR pMessage
,
373 DWORD MessageLength
, DWORD Style
, DWORD Timeout
, DWORD
*pResponse
, BOOL bWait
)
375 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
);
379 /************************************************************
380 * WTSSendMessageW (WTSAPI32.@)
382 BOOL WINAPI
WTSSendMessageW(HANDLE hServer
, DWORD SessionId
, LPWSTR pTitle
, DWORD TitleLength
, LPWSTR pMessage
,
383 DWORD MessageLength
, DWORD Style
, DWORD Timeout
, DWORD
*pResponse
, BOOL bWait
)
385 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
);
389 /************************************************************
390 * WTSSetUserConfigA (WTSAPI32.@)
392 BOOL WINAPI
WTSSetUserConfigA(LPSTR pServerName
, LPSTR pUserName
, WTS_CONFIG_CLASS WTSConfigClass
, LPSTR pBuffer
, DWORD DataLength
)
394 FIXME("Stub (%s) (%s) 0x%08x %p %d\n", debugstr_a(pServerName
), debugstr_a(pUserName
), WTSConfigClass
,pBuffer
, DataLength
);
398 /************************************************************
399 * WTSSetUserConfigW (WTSAPI32.@)
401 BOOL WINAPI
WTSSetUserConfigW(LPWSTR pServerName
, LPWSTR pUserName
, WTS_CONFIG_CLASS WTSConfigClass
, LPWSTR pBuffer
, DWORD DataLength
)
403 FIXME("Stub (%s) (%s) 0x%08x %p %d\n", debugstr_w(pServerName
), debugstr_w(pUserName
), WTSConfigClass
,pBuffer
, DataLength
);
407 /************************************************************
408 * WTSShutdownSystem (WTSAPI32.@)
410 BOOL WINAPI
WTSShutdownSystem(HANDLE hServer
, DWORD ShutdownFlag
)
412 FIXME("Stub %p 0x%08x\n", hServer
,ShutdownFlag
);
416 /************************************************************
417 * WTSStartRemoteControlSessionA (WTSAPI32.@)
419 BOOL WINAPI
WTSStartRemoteControlSessionA(LPSTR pTargetServerName
, ULONG TargetLogonId
, BYTE HotkeyVk
, USHORT HotkeyModifiers
)
421 FIXME("Stub (%s) %d %d %d\n", debugstr_a(pTargetServerName
), TargetLogonId
, HotkeyVk
, HotkeyModifiers
);
425 /************************************************************
426 * WTSStartRemoteControlSessionW (WTSAPI32.@)
428 BOOL WINAPI
WTSStartRemoteControlSessionW(LPWSTR pTargetServerName
, ULONG TargetLogonId
, BYTE HotkeyVk
, USHORT HotkeyModifiers
)
430 FIXME("Stub (%s) %d %d %d\n", debugstr_w(pTargetServerName
), TargetLogonId
, HotkeyVk
, HotkeyModifiers
);
434 /************************************************************
435 * WTSStopRemoteControlSession (WTSAPI32.@)
437 BOOL WINAPI
WTSStopRemoteControlSession(ULONG LogonId
)
439 FIXME("Stub %d\n", LogonId
);
443 /************************************************************
444 * WTSTerminateProcess (WTSAPI32.@)
446 BOOL WINAPI
WTSTerminateProcess(HANDLE hServer
, DWORD ProcessId
, DWORD ExitCode
)
448 FIXME("Stub %p %d %d\n", hServer
, ProcessId
, ExitCode
);
452 /************************************************************
453 * WTSUnRegisterSessionNotification (WTSAPI32.@)
455 BOOL WINAPI
WTSUnRegisterSessionNotification(HWND hWnd
)
457 FIXME("Stub %p\n", hWnd
);
461 /************************************************************
462 * WTSUnRegisterSessionNotification (WTSAPI32.@)
464 BOOL WINAPI
WTSUnRegisterSessionNotificationEx(HANDLE hServer
, HWND hWnd
)
466 FIXME("Stub %p %p\n", hServer
, hWnd
);
471 /************************************************************
472 * WTSVirtualChannelClose (WTSAPI32.@)
474 BOOL WINAPI
WTSVirtualChannelClose(HANDLE hChannelHandle
)
476 FIXME("Stub %p\n", hChannelHandle
);
480 /************************************************************
481 * WTSVirtualChannelOpen (WTSAPI32.@)
483 HANDLE WINAPI
WTSVirtualChannelOpen(HANDLE hServer
, DWORD SessionId
, LPSTR pVirtualName
)
485 FIXME("Stub %p %d (%s)\n", hServer
, SessionId
, debugstr_a(pVirtualName
));
489 /************************************************************
490 * WTSVirtualChannelOpen (WTSAPI32.@)
492 HANDLE WINAPI
WTSVirtualChannelOpenEx(DWORD SessionId
, LPSTR pVirtualName
, DWORD flags
)
494 FIXME("Stub %d (%s) %d\n", SessionId
, debugstr_a(pVirtualName
), flags
);
498 /************************************************************
499 * WTSVirtualChannelPurgeInput (WTSAPI32.@)
501 BOOL WINAPI
WTSVirtualChannelPurgeInput(HANDLE hChannelHandle
)
503 FIXME("Stub %p\n", hChannelHandle
);
507 /************************************************************
508 * WTSVirtualChannelPurgeOutput (WTSAPI32.@)
510 BOOL WINAPI
WTSVirtualChannelPurgeOutput(HANDLE hChannelHandle
)
512 FIXME("Stub %p\n", hChannelHandle
);
517 /************************************************************
518 * WTSVirtualChannelQuery (WTSAPI32.@)
520 BOOL WINAPI
WTSVirtualChannelQuery(HANDLE hChannelHandle
, WTS_VIRTUAL_CLASS WtsVirtualClass
, PVOID
*ppBuffer
, DWORD
*pBytesReturned
)
522 FIXME("Stub %p %d %p %p\n", hChannelHandle
, WtsVirtualClass
, ppBuffer
, pBytesReturned
);
526 /************************************************************
527 * WTSVirtualChannelRead (WTSAPI32.@)
529 BOOL WINAPI
WTSVirtualChannelRead(HANDLE hChannelHandle
, ULONG TimeOut
, PCHAR Buffer
, ULONG BufferSize
, PULONG pBytesRead
)
531 FIXME("Stub %p %d %p %d %p\n", hChannelHandle
, TimeOut
, Buffer
, BufferSize
, pBytesRead
);
535 /************************************************************
536 * WTSVirtualChannelWrite (WTSAPI32.@)
538 BOOL WINAPI
WTSVirtualChannelWrite(HANDLE hChannelHandle
, PCHAR Buffer
, ULONG Length
, PULONG pBytesWritten
)
540 FIXME("Stub %p %p %d %p\n", hChannelHandle
, Buffer
, Length
, pBytesWritten
);
544 /************************************************************
545 * WTSWaitSystemEvent (WTSAPI32.@)
547 BOOL WINAPI
WTSWaitSystemEvent(HANDLE hServer
, DWORD Mask
, DWORD
* Flags
)
549 /* FIXME: Forward request to winsta.dll::WinStationWaitSystemEvent */
550 FIXME("Stub %p 0x%08x %p\n", hServer
, Mask
, Flags
);