mf/session: Forward more events to the application.
[wine/zf.git] / dlls / wtsapi32 / wtsapi32.c
bloba5c9bf6519fd8469df455e71a560e96f5b49680d
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
18 #include <stdarg.h>
19 #include <stdlib.h>
20 #include "windef.h"
21 #include "winbase.h"
22 #include "winnls.h"
23 #include "lmcons.h"
24 #include "wtsapi32.h"
25 #include "wine/debug.h"
26 #include "wine/heap.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(wtsapi);
31 /************************************************************
32 * WTSCloseServer (WTSAPI32.@)
34 void WINAPI WTSCloseServer(HANDLE hServer)
36 FIXME("Stub %p\n", hServer);
39 /************************************************************
40 * WTSConnectSessionA (WTSAPI32.@)
42 BOOL WINAPI WTSConnectSessionA(ULONG LogonId, ULONG TargetLogonId, PSTR pPassword, BOOL bWait)
44 FIXME("Stub %d %d (%s) %d\n", LogonId, TargetLogonId, debugstr_a(pPassword), bWait);
45 return TRUE;
48 /************************************************************
49 * WTSConnectSessionW (WTSAPI32.@)
51 BOOL WINAPI WTSConnectSessionW(ULONG LogonId, ULONG TargetLogonId, PWSTR pPassword, BOOL bWait)
53 FIXME("Stub %d %d (%s) %d\n", LogonId, TargetLogonId, debugstr_w(pPassword), bWait);
54 return TRUE;
57 /************************************************************
58 * WTSDisconnectSession (WTSAPI32.@)
60 BOOL WINAPI WTSDisconnectSession(HANDLE hServer, DWORD SessionId, BOOL bWait)
62 FIXME("Stub %p 0x%08x %d\n", hServer, SessionId, bWait);
63 return TRUE;
66 /************************************************************
67 * WTSEnableChildSessions (WTSAPI32.@)
69 BOOL WINAPI WTSEnableChildSessions(BOOL enable)
71 FIXME("Stub %d\n", enable);
72 return TRUE;
76 /************************************************************
77 * WTSEnumerateProcessesExW (WTSAPI32.@)
79 BOOL WINAPI WTSEnumerateProcessesExW(HANDLE server, DWORD *level, DWORD session_id, WCHAR **info, DWORD *count)
81 FIXME("Stub %p %p %d %p %p\n", server, level, session_id, info, count);
82 if (count) *count = 0;
83 return FALSE;
86 /************************************************************
87 * WTSEnumerateProcessesExA (WTSAPI32.@)
89 BOOL WINAPI WTSEnumerateProcessesExA(HANDLE server, DWORD *level, DWORD session_id, char **info, DWORD *count)
91 FIXME("Stub %p %p %d %p %p\n", server, level, session_id, info, count);
92 if (count) *count = 0;
93 return FALSE;
96 /************************************************************
97 * WTSEnumerateProcessesA (WTSAPI32.@)
99 BOOL WINAPI WTSEnumerateProcessesA(HANDLE hServer, DWORD Reserved, DWORD Version,
100 PWTS_PROCESS_INFOA* ppProcessInfo, DWORD* pCount)
102 FIXME("Stub %p 0x%08x 0x%08x %p %p\n", hServer, Reserved, Version,
103 ppProcessInfo, pCount);
105 if (!ppProcessInfo || !pCount) return FALSE;
107 *pCount = 0;
108 *ppProcessInfo = NULL;
110 return TRUE;
113 /************************************************************
114 * WTSEnumerateProcessesW (WTSAPI32.@)
116 BOOL WINAPI WTSEnumerateProcessesW(HANDLE hServer, DWORD Reserved, DWORD Version,
117 PWTS_PROCESS_INFOW* ppProcessInfo, DWORD* pCount)
119 FIXME("Stub %p 0x%08x 0x%08x %p %p\n", hServer, Reserved, Version,
120 ppProcessInfo, pCount);
122 if (!ppProcessInfo || !pCount || Reserved != 0 || Version != 1)
124 SetLastError(ERROR_INVALID_PARAMETER);
125 return FALSE;
128 *pCount = 0;
129 *ppProcessInfo = NULL;
131 return TRUE;
134 /************************************************************
135 * WTSEnumerateServersA (WTSAPI32.@)
137 BOOL WINAPI WTSEnumerateServersA(LPSTR pDomainName, DWORD Reserved, DWORD Version, PWTS_SERVER_INFOA *ppServerInfo, DWORD *pCount)
139 FIXME("Stub %s 0x%08x 0x%08x %p %p\n", debugstr_a(pDomainName), Reserved, Version, ppServerInfo, pCount);
140 return FALSE;
143 /************************************************************
144 * WTSEnumerateServersW (WTSAPI32.@)
146 BOOL WINAPI WTSEnumerateServersW(LPWSTR pDomainName, DWORD Reserved, DWORD Version, PWTS_SERVER_INFOW *ppServerInfo, DWORD *pCount)
148 FIXME("Stub %s 0x%08x 0x%08x %p %p\n", debugstr_w(pDomainName), Reserved, Version, ppServerInfo, pCount);
149 return FALSE;
153 /************************************************************
154 * WTSEnumerateEnumerateSessionsExW (WTSAPI32.@)
156 BOOL WINAPI WTSEnumerateSessionsExW(HANDLE server, DWORD *level, DWORD filter, WTS_SESSION_INFO_1W* info, DWORD *count)
158 FIXME("Stub %p %p %d %p %p\n", server, level, filter, info, count);
159 if (count) *count = 0;
160 return FALSE;
163 /************************************************************
164 * WTSEnumerateEnumerateSessionsExA (WTSAPI32.@)
166 BOOL WINAPI WTSEnumerateSessionsExA(HANDLE server, DWORD *level, DWORD filter, WTS_SESSION_INFO_1A* info, DWORD *count)
168 FIXME("Stub %p %p %d %p %p\n", server, level, filter, info, count);
169 if (count) *count = 0;
170 return FALSE;
173 /************************************************************
174 * WTSEnumerateEnumerateSessionsA (WTSAPI32.@)
176 BOOL WINAPI WTSEnumerateSessionsA(HANDLE hServer, DWORD Reserved, DWORD Version,
177 PWTS_SESSION_INFOA* ppSessionInfo, DWORD* pCount)
179 static int once;
181 if (!once++) FIXME("Stub %p 0x%08x 0x%08x %p %p\n", hServer, Reserved, Version,
182 ppSessionInfo, pCount);
184 if (!ppSessionInfo || !pCount) return FALSE;
186 *pCount = 0;
187 *ppSessionInfo = NULL;
189 return TRUE;
192 /************************************************************
193 * WTSEnumerateEnumerateSessionsW (WTSAPI32.@)
195 BOOL WINAPI WTSEnumerateSessionsW(HANDLE hServer, DWORD Reserved, DWORD Version,
196 PWTS_SESSION_INFOW* ppSessionInfo, DWORD* pCount)
198 FIXME("Stub %p 0x%08x 0x%08x %p %p\n", hServer, Reserved, Version,
199 ppSessionInfo, pCount);
201 if (!ppSessionInfo || !pCount) return FALSE;
203 *pCount = 0;
204 *ppSessionInfo = NULL;
206 return TRUE;
209 /************************************************************
210 * WTSFreeMemory (WTSAPI32.@)
212 void WINAPI WTSFreeMemory(PVOID pMemory)
214 heap_free(pMemory);
217 /************************************************************
218 * WTSFreeMemoryExA (WTSAPI32.@)
220 BOOL WINAPI WTSFreeMemoryExA(WTS_TYPE_CLASS type, void *ptr, ULONG nmemb)
222 TRACE("%d %p %d\n", type, ptr, nmemb);
223 heap_free(ptr);
224 return TRUE;
227 /************************************************************
228 * WTSFreeMemoryExW (WTSAPI32.@)
230 BOOL WINAPI WTSFreeMemoryExW(WTS_TYPE_CLASS type, void *ptr, ULONG nmemb)
232 TRACE("%d %p %d\n", type, ptr, nmemb);
233 heap_free(ptr);
234 return TRUE;
238 /************************************************************
239 * WTSLogoffSession (WTSAPI32.@)
241 BOOL WINAPI WTSLogoffSession(HANDLE hserver, DWORD session_id, BOOL bwait)
243 FIXME("(%p, 0x%x, %d): stub\n", hserver, session_id, bwait);
244 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
245 return FALSE;
249 /************************************************************
250 * WTSOpenServerExW (WTSAPI32.@)
252 HANDLE WINAPI WTSOpenServerExW(WCHAR *server_name)
254 FIXME("(%s) stub\n", debugstr_w(server_name));
255 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
256 return NULL;
259 /************************************************************
260 * WTSOpenServerExA (WTSAPI32.@)
262 HANDLE WINAPI WTSOpenServerExA(char *server_name)
264 FIXME("(%s) stub\n", debugstr_a(server_name));
265 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
266 return NULL;
269 /************************************************************
270 * WTSOpenServerA (WTSAPI32.@)
272 HANDLE WINAPI WTSOpenServerA(LPSTR pServerName)
274 FIXME("(%s) stub\n", debugstr_a(pServerName));
275 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
276 return NULL;
279 /************************************************************
280 * WTSOpenServerW (WTSAPI32.@)
282 HANDLE WINAPI WTSOpenServerW(LPWSTR pServerName)
284 FIXME("(%s) stub\n", debugstr_w(pServerName));
285 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
286 return NULL;
289 /************************************************************
290 * WTSQuerySessionInformationA (WTSAPI32.@)
292 BOOL WINAPI WTSQuerySessionInformationA(HANDLE server, DWORD session_id, WTS_INFO_CLASS class, char **buffer, DWORD *count)
294 WCHAR *bufferW = NULL;
296 TRACE("%p 0x%08x %d %p %p\n", server, session_id, class, buffer, count);
298 if (!buffer || !count)
300 SetLastError(ERROR_INVALID_USER_BUFFER);
301 return FALSE;
304 if (!WTSQuerySessionInformationW(server, session_id, class, &bufferW, count))
305 return FALSE;
307 *count = WideCharToMultiByte(CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL);
308 if (!*count)
310 WTSFreeMemory(bufferW);
311 return FALSE;
314 if (!(*buffer = heap_alloc(*count)))
316 WTSFreeMemory(bufferW);
317 return FALSE;
320 if (!(*count = WideCharToMultiByte(CP_ACP, 0, bufferW, -1, *buffer, *count, NULL, NULL)))
322 WTSFreeMemory(bufferW);
323 heap_free(*buffer);
324 return FALSE;
327 WTSFreeMemory(bufferW);
328 return TRUE;
331 /************************************************************
332 * WTSQuerySessionInformationW (WTSAPI32.@)
334 BOOL WINAPI WTSQuerySessionInformationW(HANDLE server, DWORD session_id, WTS_INFO_CLASS class, WCHAR **buffer, DWORD *count)
336 TRACE("%p 0x%08x %d %p %p\n", server, session_id, class, buffer, count);
338 if (!buffer || !count)
340 SetLastError(ERROR_INVALID_USER_BUFFER);
341 return FALSE;
344 if (class == WTSUserName)
346 DWORD size = UNLEN + 1;
347 WCHAR *username;
349 if (!(username = heap_alloc(size * sizeof(WCHAR)))) return FALSE;
350 GetUserNameW(username, &size);
351 *buffer = username;
352 *count = size * sizeof(WCHAR);
353 return TRUE;
356 if (class == WTSDomainName)
358 DWORD size = MAX_COMPUTERNAME_LENGTH + 1;
359 WCHAR *computername;
361 if (!(computername = heap_alloc(size * sizeof(WCHAR)))) return FALSE;
362 GetComputerNameW(computername, &size);
363 *buffer = computername;
364 /* GetComputerNameW() return size doesn't include terminator */
365 size++;
366 *count = size * sizeof(WCHAR);
367 return TRUE;
370 FIXME("Unimplemented class %d\n", class);
372 *buffer = NULL;
373 *count = 0;
374 return FALSE;
377 /************************************************************
378 * WTSQueryUserToken (WTSAPI32.@)
380 BOOL WINAPI WTSQueryUserToken(ULONG session_id, PHANDLE token)
382 FIXME("%u %p semi-stub!\n", session_id, token);
384 if (!token)
386 SetLastError(ERROR_INVALID_PARAMETER);
387 return FALSE;
390 return DuplicateHandle(GetCurrentProcess(), GetCurrentProcessToken(),
391 GetCurrentProcess(), token,
392 0, FALSE, DUPLICATE_SAME_ACCESS);
395 /************************************************************
396 * WTSQueryUserConfigA (WTSAPI32.@)
398 BOOL WINAPI WTSQueryUserConfigA(LPSTR pServerName, LPSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPSTR *ppBuffer, DWORD *pBytesReturned)
400 FIXME("Stub (%s) (%s) 0x%08x %p %p\n", debugstr_a(pServerName), debugstr_a(pUserName), WTSConfigClass,
401 ppBuffer, pBytesReturned);
402 return FALSE;
405 /************************************************************
406 * WTSQueryUserConfigW (WTSAPI32.@)
408 BOOL WINAPI WTSQueryUserConfigW(LPWSTR pServerName, LPWSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPWSTR *ppBuffer, DWORD *pBytesReturned)
410 FIXME("Stub (%s) (%s) 0x%08x %p %p\n", debugstr_w(pServerName), debugstr_w(pUserName), WTSConfigClass,
411 ppBuffer, pBytesReturned);
412 return FALSE;
416 /************************************************************
417 * WTSRegisterSessionNotification (WTSAPI32.@)
419 BOOL WINAPI WTSRegisterSessionNotification(HWND hWnd, DWORD dwFlags)
421 FIXME("Stub %p 0x%08x\n", hWnd, dwFlags);
422 return TRUE;
425 /************************************************************
426 * WTSRegisterSessionNotificationEx (WTSAPI32.@)
428 BOOL WINAPI WTSRegisterSessionNotificationEx(HANDLE hServer, HWND hWnd, DWORD dwFlags)
430 FIXME("Stub %p %p 0x%08x\n", hServer, hWnd, dwFlags);
431 return TRUE;
435 /************************************************************
436 * WTSSendMessageA (WTSAPI32.@)
438 BOOL WINAPI WTSSendMessageA(HANDLE hServer, DWORD SessionId, LPSTR pTitle, DWORD TitleLength, LPSTR pMessage,
439 DWORD MessageLength, DWORD Style, DWORD Timeout, DWORD *pResponse, BOOL bWait)
441 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);
442 return FALSE;
445 /************************************************************
446 * WTSSendMessageW (WTSAPI32.@)
448 BOOL WINAPI WTSSendMessageW(HANDLE hServer, DWORD SessionId, LPWSTR pTitle, DWORD TitleLength, LPWSTR pMessage,
449 DWORD MessageLength, DWORD Style, DWORD Timeout, DWORD *pResponse, BOOL bWait)
451 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);
452 return FALSE;
455 /************************************************************
456 * WTSSetUserConfigA (WTSAPI32.@)
458 BOOL WINAPI WTSSetUserConfigA(LPSTR pServerName, LPSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPSTR pBuffer, DWORD DataLength)
460 FIXME("Stub (%s) (%s) 0x%08x %p %d\n", debugstr_a(pServerName), debugstr_a(pUserName), WTSConfigClass,pBuffer, DataLength);
461 return FALSE;
464 /************************************************************
465 * WTSSetUserConfigW (WTSAPI32.@)
467 BOOL WINAPI WTSSetUserConfigW(LPWSTR pServerName, LPWSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPWSTR pBuffer, DWORD DataLength)
469 FIXME("Stub (%s) (%s) 0x%08x %p %d\n", debugstr_w(pServerName), debugstr_w(pUserName), WTSConfigClass,pBuffer, DataLength);
470 return FALSE;
473 /************************************************************
474 * WTSShutdownSystem (WTSAPI32.@)
476 BOOL WINAPI WTSShutdownSystem(HANDLE hServer, DWORD ShutdownFlag)
478 FIXME("Stub %p 0x%08x\n", hServer,ShutdownFlag);
479 return FALSE;
482 /************************************************************
483 * WTSStartRemoteControlSessionA (WTSAPI32.@)
485 BOOL WINAPI WTSStartRemoteControlSessionA(LPSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers)
487 FIXME("Stub (%s) %d %d %d\n", debugstr_a(pTargetServerName), TargetLogonId, HotkeyVk, HotkeyModifiers);
488 return FALSE;
491 /************************************************************
492 * WTSStartRemoteControlSessionW (WTSAPI32.@)
494 BOOL WINAPI WTSStartRemoteControlSessionW(LPWSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers)
496 FIXME("Stub (%s) %d %d %d\n", debugstr_w(pTargetServerName), TargetLogonId, HotkeyVk, HotkeyModifiers);
497 return FALSE;
500 /************************************************************
501 * WTSStopRemoteControlSession (WTSAPI32.@)
503 BOOL WINAPI WTSStopRemoteControlSession(ULONG LogonId)
505 FIXME("Stub %d\n", LogonId);
506 return FALSE;
509 /************************************************************
510 * WTSTerminateProcess (WTSAPI32.@)
512 BOOL WINAPI WTSTerminateProcess(HANDLE hServer, DWORD ProcessId, DWORD ExitCode)
514 FIXME("Stub %p %d %d\n", hServer, ProcessId, ExitCode);
515 return FALSE;
518 /************************************************************
519 * WTSUnRegisterSessionNotification (WTSAPI32.@)
521 BOOL WINAPI WTSUnRegisterSessionNotification(HWND hWnd)
523 FIXME("Stub %p\n", hWnd);
524 return FALSE;
527 /************************************************************
528 * WTSUnRegisterSessionNotification (WTSAPI32.@)
530 BOOL WINAPI WTSUnRegisterSessionNotificationEx(HANDLE hServer, HWND hWnd)
532 FIXME("Stub %p %p\n", hServer, hWnd);
533 return FALSE;
537 /************************************************************
538 * WTSVirtualChannelClose (WTSAPI32.@)
540 BOOL WINAPI WTSVirtualChannelClose(HANDLE hChannelHandle)
542 FIXME("Stub %p\n", hChannelHandle);
543 return FALSE;
546 /************************************************************
547 * WTSVirtualChannelOpen (WTSAPI32.@)
549 HANDLE WINAPI WTSVirtualChannelOpen(HANDLE hServer, DWORD SessionId, LPSTR pVirtualName)
551 FIXME("Stub %p %d (%s)\n", hServer, SessionId, debugstr_a(pVirtualName));
552 return NULL;
555 /************************************************************
556 * WTSVirtualChannelOpen (WTSAPI32.@)
558 HANDLE WINAPI WTSVirtualChannelOpenEx(DWORD SessionId, LPSTR pVirtualName, DWORD flags)
560 FIXME("Stub %d (%s) %d\n", SessionId, debugstr_a(pVirtualName), flags);
561 return NULL;
564 /************************************************************
565 * WTSVirtualChannelPurgeInput (WTSAPI32.@)
567 BOOL WINAPI WTSVirtualChannelPurgeInput(HANDLE hChannelHandle)
569 FIXME("Stub %p\n", hChannelHandle);
570 return FALSE;
573 /************************************************************
574 * WTSVirtualChannelPurgeOutput (WTSAPI32.@)
576 BOOL WINAPI WTSVirtualChannelPurgeOutput(HANDLE hChannelHandle)
578 FIXME("Stub %p\n", hChannelHandle);
579 return FALSE;
583 /************************************************************
584 * WTSVirtualChannelQuery (WTSAPI32.@)
586 BOOL WINAPI WTSVirtualChannelQuery(HANDLE hChannelHandle, WTS_VIRTUAL_CLASS WtsVirtualClass, PVOID *ppBuffer, DWORD *pBytesReturned)
588 FIXME("Stub %p %d %p %p\n", hChannelHandle, WtsVirtualClass, ppBuffer, pBytesReturned);
589 return FALSE;
592 /************************************************************
593 * WTSVirtualChannelRead (WTSAPI32.@)
595 BOOL WINAPI WTSVirtualChannelRead(HANDLE hChannelHandle, ULONG TimeOut, PCHAR Buffer, ULONG BufferSize, PULONG pBytesRead)
597 FIXME("Stub %p %d %p %d %p\n", hChannelHandle, TimeOut, Buffer, BufferSize, pBytesRead);
598 return FALSE;
601 /************************************************************
602 * WTSVirtualChannelWrite (WTSAPI32.@)
604 BOOL WINAPI WTSVirtualChannelWrite(HANDLE hChannelHandle, PCHAR Buffer, ULONG Length, PULONG pBytesWritten)
606 FIXME("Stub %p %p %d %p\n", hChannelHandle, Buffer, Length, pBytesWritten);
607 return FALSE;
610 /************************************************************
611 * WTSWaitSystemEvent (WTSAPI32.@)
613 BOOL WINAPI WTSWaitSystemEvent(HANDLE hServer, DWORD Mask, DWORD* Flags)
615 /* FIXME: Forward request to winsta.dll::WinStationWaitSystemEvent */
616 FIXME("Stub %p 0x%08x %p\n", hServer, Mask, Flags);
617 return FALSE;