wbemdisp: Implement GetObjectText_().
[wine/zf.git] / dlls / wtsapi32 / wtsapi32.c
blobef3e0d10a0f1884c1f765656a9c75248384eaac5
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 "wtsapi32.h"
24 #include "wine/debug.h"
25 #include "wine/heap.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(wtsapi);
30 /************************************************************
31 * WTSCloseServer (WTSAPI32.@)
33 void WINAPI WTSCloseServer(HANDLE hServer)
35 FIXME("Stub %p\n", hServer);
38 /************************************************************
39 * WTSConnectSessionA (WTSAPI32.@)
41 BOOL WINAPI WTSConnectSessionA(ULONG LogonId, ULONG TargetLogonId, PSTR pPassword, BOOL bWait)
43 FIXME("Stub %d %d (%s) %d\n", LogonId, TargetLogonId, debugstr_a(pPassword), bWait);
44 return TRUE;
47 /************************************************************
48 * WTSConnectSessionW (WTSAPI32.@)
50 BOOL WINAPI WTSConnectSessionW(ULONG LogonId, ULONG TargetLogonId, PWSTR pPassword, BOOL bWait)
52 FIXME("Stub %d %d (%s) %d\n", LogonId, TargetLogonId, debugstr_w(pPassword), bWait);
53 return TRUE;
56 /************************************************************
57 * WTSDisconnectSession (WTSAPI32.@)
59 BOOL WINAPI WTSDisconnectSession(HANDLE hServer, DWORD SessionId, BOOL bWait)
61 FIXME("Stub %p 0x%08x %d\n", hServer, SessionId, bWait);
62 return TRUE;
65 /************************************************************
66 * WTSEnableChildSessions (WTSAPI32.@)
68 BOOL WINAPI WTSEnableChildSessions(BOOL enable)
70 FIXME("Stub %d\n", enable);
71 return TRUE;
75 /************************************************************
76 * WTSEnumerateProcessesExW (WTSAPI32.@)
78 BOOL WINAPI WTSEnumerateProcessesExW(HANDLE server, DWORD *level, DWORD session_id, WCHAR **info, DWORD *count)
80 FIXME("Stub %p %p %d %p %p\n", server, level, session_id, info, count);
81 if (count) *count = 0;
82 return FALSE;
85 /************************************************************
86 * WTSEnumerateProcessesExA (WTSAPI32.@)
88 BOOL WINAPI WTSEnumerateProcessesExA(HANDLE server, DWORD *level, DWORD session_id, char **info, DWORD *count)
90 FIXME("Stub %p %p %d %p %p\n", server, level, session_id, info, count);
91 if (count) *count = 0;
92 return FALSE;
95 /************************************************************
96 * WTSEnumerateProcessesA (WTSAPI32.@)
98 BOOL WINAPI WTSEnumerateProcessesA(HANDLE hServer, DWORD Reserved, DWORD Version,
99 PWTS_PROCESS_INFOA* ppProcessInfo, DWORD* pCount)
101 FIXME("Stub %p 0x%08x 0x%08x %p %p\n", hServer, Reserved, Version,
102 ppProcessInfo, pCount);
104 if (!ppProcessInfo || !pCount) return FALSE;
106 *pCount = 0;
107 *ppProcessInfo = NULL;
109 return TRUE;
112 /************************************************************
113 * WTSEnumerateProcessesW (WTSAPI32.@)
115 BOOL WINAPI WTSEnumerateProcessesW(HANDLE hServer, DWORD Reserved, DWORD Version,
116 PWTS_PROCESS_INFOW* ppProcessInfo, DWORD* pCount)
118 FIXME("Stub %p 0x%08x 0x%08x %p %p\n", hServer, Reserved, Version,
119 ppProcessInfo, pCount);
121 if (!ppProcessInfo || !pCount || Reserved != 0 || Version != 1)
123 SetLastError(ERROR_INVALID_PARAMETER);
124 return FALSE;
127 *pCount = 0;
128 *ppProcessInfo = NULL;
130 return TRUE;
133 /************************************************************
134 * WTSEnumerateServersA (WTSAPI32.@)
136 BOOL WINAPI WTSEnumerateServersA(LPSTR pDomainName, DWORD Reserved, DWORD Version, PWTS_SERVER_INFOA *ppServerInfo, DWORD *pCount)
138 FIXME("Stub %s 0x%08x 0x%08x %p %p\n", debugstr_a(pDomainName), Reserved, Version, ppServerInfo, pCount);
139 return FALSE;
142 /************************************************************
143 * WTSEnumerateServersW (WTSAPI32.@)
145 BOOL WINAPI WTSEnumerateServersW(LPWSTR pDomainName, DWORD Reserved, DWORD Version, PWTS_SERVER_INFOW *ppServerInfo, DWORD *pCount)
147 FIXME("Stub %s 0x%08x 0x%08x %p %p\n", debugstr_w(pDomainName), Reserved, Version, ppServerInfo, pCount);
148 return FALSE;
152 /************************************************************
153 * WTSEnumerateEnumerateSessionsExW (WTSAPI32.@)
155 BOOL WINAPI WTSEnumerateSessionsExW(HANDLE server, DWORD *level, DWORD filter, WTS_SESSION_INFO_1W* info, DWORD *count)
157 FIXME("Stub %p %p %d %p %p\n", server, level, filter, info, count);
158 if (count) *count = 0;
159 return FALSE;
162 /************************************************************
163 * WTSEnumerateEnumerateSessionsExA (WTSAPI32.@)
165 BOOL WINAPI WTSEnumerateSessionsExA(HANDLE server, DWORD *level, DWORD filter, WTS_SESSION_INFO_1A* info, DWORD *count)
167 FIXME("Stub %p %p %d %p %p\n", server, level, filter, info, count);
168 if (count) *count = 0;
169 return FALSE;
172 /************************************************************
173 * WTSEnumerateEnumerateSessionsA (WTSAPI32.@)
175 BOOL WINAPI WTSEnumerateSessionsA(HANDLE hServer, DWORD Reserved, DWORD Version,
176 PWTS_SESSION_INFOA* ppSessionInfo, DWORD* pCount)
178 static int once;
180 if (!once++) FIXME("Stub %p 0x%08x 0x%08x %p %p\n", hServer, Reserved, Version,
181 ppSessionInfo, pCount);
183 if (!ppSessionInfo || !pCount) return FALSE;
185 *pCount = 0;
186 *ppSessionInfo = NULL;
188 return TRUE;
191 /************************************************************
192 * WTSEnumerateEnumerateSessionsW (WTSAPI32.@)
194 BOOL WINAPI WTSEnumerateSessionsW(HANDLE hServer, DWORD Reserved, DWORD Version,
195 PWTS_SESSION_INFOW* ppSessionInfo, DWORD* pCount)
197 FIXME("Stub %p 0x%08x 0x%08x %p %p\n", hServer, Reserved, Version,
198 ppSessionInfo, pCount);
200 if (!ppSessionInfo || !pCount) return FALSE;
202 *pCount = 0;
203 *ppSessionInfo = NULL;
205 return TRUE;
208 /************************************************************
209 * WTSFreeMemory (WTSAPI32.@)
211 void WINAPI WTSFreeMemory(PVOID pMemory)
213 heap_free(pMemory);
216 /************************************************************
217 * WTSFreeMemoryExA (WTSAPI32.@)
219 BOOL WINAPI WTSFreeMemoryExA(WTS_TYPE_CLASS type, void *ptr, ULONG nmemb)
221 TRACE("%d %p %d\n", type, ptr, nmemb);
222 heap_free(ptr);
223 return TRUE;
226 /************************************************************
227 * WTSFreeMemoryExW (WTSAPI32.@)
229 BOOL WINAPI WTSFreeMemoryExW(WTS_TYPE_CLASS type, void *ptr, ULONG nmemb)
231 TRACE("%d %p %d\n", type, ptr, nmemb);
232 heap_free(ptr);
233 return TRUE;
237 /************************************************************
238 * WTSLogoffSession (WTSAPI32.@)
240 BOOL WINAPI WTSLogoffSession(HANDLE hserver, DWORD session_id, BOOL bwait)
242 FIXME("(%p, 0x%x, %d): stub\n", hserver, session_id, bwait);
243 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
244 return FALSE;
248 /************************************************************
249 * WTSOpenServerExW (WTSAPI32.@)
251 HANDLE WINAPI WTSOpenServerExW(WCHAR *server_name)
253 FIXME("(%s) stub\n", debugstr_w(server_name));
254 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
255 return NULL;
258 /************************************************************
259 * WTSOpenServerExA (WTSAPI32.@)
261 HANDLE WINAPI WTSOpenServerExA(char *server_name)
263 FIXME("(%s) stub\n", debugstr_a(server_name));
264 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
265 return NULL;
268 /************************************************************
269 * WTSOpenServerA (WTSAPI32.@)
271 HANDLE WINAPI WTSOpenServerA(LPSTR pServerName)
273 FIXME("(%s) stub\n", debugstr_a(pServerName));
274 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
275 return NULL;
278 /************************************************************
279 * WTSOpenServerW (WTSAPI32.@)
281 HANDLE WINAPI WTSOpenServerW(LPWSTR pServerName)
283 FIXME("(%s) stub\n", debugstr_w(pServerName));
284 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
285 return NULL;
288 /************************************************************
289 * WTSQuerySessionInformationA (WTSAPI32.@)
291 BOOL WINAPI WTSQuerySessionInformationA(HANDLE server, DWORD session_id, WTS_INFO_CLASS class, char **buffer, DWORD *count)
293 WCHAR *bufferW = NULL;
295 TRACE("%p 0x%08x %d %p %p\n", server, session_id, class, buffer, count);
297 if (!buffer || !count)
299 SetLastError(ERROR_INVALID_USER_BUFFER);
300 return FALSE;
303 if (!WTSQuerySessionInformationW(server, session_id, class, &bufferW, count))
304 return FALSE;
306 *count = WideCharToMultiByte(CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL);
307 if (!*count)
309 WTSFreeMemory(bufferW);
310 return FALSE;
313 if (!(*buffer = heap_alloc(*count)))
315 WTSFreeMemory(bufferW);
316 return FALSE;
319 if (!(*count = WideCharToMultiByte(CP_ACP, 0, bufferW, -1, *buffer, *count, NULL, NULL)))
321 WTSFreeMemory(bufferW);
322 heap_free(*buffer);
323 return FALSE;
326 WTSFreeMemory(bufferW);
327 return TRUE;
330 /************************************************************
331 * WTSQuerySessionInformationW (WTSAPI32.@)
333 BOOL WINAPI WTSQuerySessionInformationW(
334 HANDLE hServer,
335 DWORD SessionId,
336 WTS_INFO_CLASS WTSInfoClass,
337 LPWSTR* Buffer,
338 DWORD* BytesReturned)
340 /* FIXME: Forward request to winsta.dll::WinStationQueryInformationW */
341 FIXME("Stub %p 0x%08x %d %p %p\n", hServer, SessionId, WTSInfoClass,
342 Buffer, BytesReturned);
344 if (!Buffer || !BytesReturned)
346 SetLastError(ERROR_INVALID_USER_BUFFER);
347 return FALSE;
350 if (WTSInfoClass == WTSUserName)
352 WCHAR *username;
353 DWORD count = 0;
355 GetUserNameW(NULL, &count);
356 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return FALSE;
357 if (!(username = heap_alloc(count * sizeof(WCHAR)))) return FALSE;
358 GetUserNameW(username, &count);
359 *Buffer = username;
360 *BytesReturned = count * sizeof(WCHAR);
361 return TRUE;
363 else
365 *Buffer = NULL;
366 *BytesReturned = 0;
368 return FALSE;
371 /************************************************************
372 * WTSQueryUserToken (WTSAPI32.@)
374 BOOL WINAPI WTSQueryUserToken(ULONG session_id, PHANDLE token)
376 FIXME("%u %p semi-stub!\n", session_id, token);
378 if (!token)
380 SetLastError(ERROR_INVALID_PARAMETER);
381 return FALSE;
384 return DuplicateHandle(GetCurrentProcess(), GetCurrentProcessToken(),
385 GetCurrentProcess(), token,
386 0, FALSE, DUPLICATE_SAME_ACCESS);
389 /************************************************************
390 * WTSQueryUserConfigA (WTSAPI32.@)
392 BOOL WINAPI WTSQueryUserConfigA(LPSTR pServerName, LPSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPSTR *ppBuffer, DWORD *pBytesReturned)
394 FIXME("Stub (%s) (%s) 0x%08x %p %p\n", debugstr_a(pServerName), debugstr_a(pUserName), WTSConfigClass,
395 ppBuffer, pBytesReturned);
396 return FALSE;
399 /************************************************************
400 * WTSQueryUserConfigW (WTSAPI32.@)
402 BOOL WINAPI WTSQueryUserConfigW(LPWSTR pServerName, LPWSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPWSTR *ppBuffer, DWORD *pBytesReturned)
404 FIXME("Stub (%s) (%s) 0x%08x %p %p\n", debugstr_w(pServerName), debugstr_w(pUserName), WTSConfigClass,
405 ppBuffer, pBytesReturned);
406 return FALSE;
410 /************************************************************
411 * WTSRegisterSessionNotification (WTSAPI32.@)
413 BOOL WINAPI WTSRegisterSessionNotification(HWND hWnd, DWORD dwFlags)
415 FIXME("Stub %p 0x%08x\n", hWnd, dwFlags);
416 return TRUE;
419 /************************************************************
420 * WTSRegisterSessionNotificationEx (WTSAPI32.@)
422 BOOL WINAPI WTSRegisterSessionNotificationEx(HANDLE hServer, HWND hWnd, DWORD dwFlags)
424 FIXME("Stub %p %p 0x%08x\n", hServer, hWnd, dwFlags);
425 return TRUE;
429 /************************************************************
430 * WTSSendMessageA (WTSAPI32.@)
432 BOOL WINAPI WTSSendMessageA(HANDLE hServer, DWORD SessionId, LPSTR pTitle, DWORD TitleLength, LPSTR pMessage,
433 DWORD MessageLength, DWORD Style, DWORD Timeout, DWORD *pResponse, BOOL bWait)
435 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);
436 return FALSE;
439 /************************************************************
440 * WTSSendMessageW (WTSAPI32.@)
442 BOOL WINAPI WTSSendMessageW(HANDLE hServer, DWORD SessionId, LPWSTR pTitle, DWORD TitleLength, LPWSTR pMessage,
443 DWORD MessageLength, DWORD Style, DWORD Timeout, DWORD *pResponse, BOOL bWait)
445 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);
446 return FALSE;
449 /************************************************************
450 * WTSSetUserConfigA (WTSAPI32.@)
452 BOOL WINAPI WTSSetUserConfigA(LPSTR pServerName, LPSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPSTR pBuffer, DWORD DataLength)
454 FIXME("Stub (%s) (%s) 0x%08x %p %d\n", debugstr_a(pServerName), debugstr_a(pUserName), WTSConfigClass,pBuffer, DataLength);
455 return FALSE;
458 /************************************************************
459 * WTSSetUserConfigW (WTSAPI32.@)
461 BOOL WINAPI WTSSetUserConfigW(LPWSTR pServerName, LPWSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPWSTR pBuffer, DWORD DataLength)
463 FIXME("Stub (%s) (%s) 0x%08x %p %d\n", debugstr_w(pServerName), debugstr_w(pUserName), WTSConfigClass,pBuffer, DataLength);
464 return FALSE;
467 /************************************************************
468 * WTSShutdownSystem (WTSAPI32.@)
470 BOOL WINAPI WTSShutdownSystem(HANDLE hServer, DWORD ShutdownFlag)
472 FIXME("Stub %p 0x%08x\n", hServer,ShutdownFlag);
473 return FALSE;
476 /************************************************************
477 * WTSStartRemoteControlSessionA (WTSAPI32.@)
479 BOOL WINAPI WTSStartRemoteControlSessionA(LPSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers)
481 FIXME("Stub (%s) %d %d %d\n", debugstr_a(pTargetServerName), TargetLogonId, HotkeyVk, HotkeyModifiers);
482 return FALSE;
485 /************************************************************
486 * WTSStartRemoteControlSessionW (WTSAPI32.@)
488 BOOL WINAPI WTSStartRemoteControlSessionW(LPWSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers)
490 FIXME("Stub (%s) %d %d %d\n", debugstr_w(pTargetServerName), TargetLogonId, HotkeyVk, HotkeyModifiers);
491 return FALSE;
494 /************************************************************
495 * WTSStopRemoteControlSession (WTSAPI32.@)
497 BOOL WINAPI WTSStopRemoteControlSession(ULONG LogonId)
499 FIXME("Stub %d\n", LogonId);
500 return FALSE;
503 /************************************************************
504 * WTSTerminateProcess (WTSAPI32.@)
506 BOOL WINAPI WTSTerminateProcess(HANDLE hServer, DWORD ProcessId, DWORD ExitCode)
508 FIXME("Stub %p %d %d\n", hServer, ProcessId, ExitCode);
509 return FALSE;
512 /************************************************************
513 * WTSUnRegisterSessionNotification (WTSAPI32.@)
515 BOOL WINAPI WTSUnRegisterSessionNotification(HWND hWnd)
517 FIXME("Stub %p\n", hWnd);
518 return FALSE;
521 /************************************************************
522 * WTSUnRegisterSessionNotification (WTSAPI32.@)
524 BOOL WINAPI WTSUnRegisterSessionNotificationEx(HANDLE hServer, HWND hWnd)
526 FIXME("Stub %p %p\n", hServer, hWnd);
527 return FALSE;
531 /************************************************************
532 * WTSVirtualChannelClose (WTSAPI32.@)
534 BOOL WINAPI WTSVirtualChannelClose(HANDLE hChannelHandle)
536 FIXME("Stub %p\n", hChannelHandle);
537 return FALSE;
540 /************************************************************
541 * WTSVirtualChannelOpen (WTSAPI32.@)
543 HANDLE WINAPI WTSVirtualChannelOpen(HANDLE hServer, DWORD SessionId, LPSTR pVirtualName)
545 FIXME("Stub %p %d (%s)\n", hServer, SessionId, debugstr_a(pVirtualName));
546 return NULL;
549 /************************************************************
550 * WTSVirtualChannelOpen (WTSAPI32.@)
552 HANDLE WINAPI WTSVirtualChannelOpenEx(DWORD SessionId, LPSTR pVirtualName, DWORD flags)
554 FIXME("Stub %d (%s) %d\n", SessionId, debugstr_a(pVirtualName), flags);
555 return NULL;
558 /************************************************************
559 * WTSVirtualChannelPurgeInput (WTSAPI32.@)
561 BOOL WINAPI WTSVirtualChannelPurgeInput(HANDLE hChannelHandle)
563 FIXME("Stub %p\n", hChannelHandle);
564 return FALSE;
567 /************************************************************
568 * WTSVirtualChannelPurgeOutput (WTSAPI32.@)
570 BOOL WINAPI WTSVirtualChannelPurgeOutput(HANDLE hChannelHandle)
572 FIXME("Stub %p\n", hChannelHandle);
573 return FALSE;
577 /************************************************************
578 * WTSVirtualChannelQuery (WTSAPI32.@)
580 BOOL WINAPI WTSVirtualChannelQuery(HANDLE hChannelHandle, WTS_VIRTUAL_CLASS WtsVirtualClass, PVOID *ppBuffer, DWORD *pBytesReturned)
582 FIXME("Stub %p %d %p %p\n", hChannelHandle, WtsVirtualClass, ppBuffer, pBytesReturned);
583 return FALSE;
586 /************************************************************
587 * WTSVirtualChannelRead (WTSAPI32.@)
589 BOOL WINAPI WTSVirtualChannelRead(HANDLE hChannelHandle, ULONG TimeOut, PCHAR Buffer, ULONG BufferSize, PULONG pBytesRead)
591 FIXME("Stub %p %d %p %d %p\n", hChannelHandle, TimeOut, Buffer, BufferSize, pBytesRead);
592 return FALSE;
595 /************************************************************
596 * WTSVirtualChannelWrite (WTSAPI32.@)
598 BOOL WINAPI WTSVirtualChannelWrite(HANDLE hChannelHandle, PCHAR Buffer, ULONG Length, PULONG pBytesWritten)
600 FIXME("Stub %p %p %d %p\n", hChannelHandle, Buffer, Length, pBytesWritten);
601 return FALSE;
604 /************************************************************
605 * WTSWaitSystemEvent (WTSAPI32.@)
607 BOOL WINAPI WTSWaitSystemEvent(HANDLE hServer, DWORD Mask, DWORD* Flags)
609 /* FIXME: Forward request to winsta.dll::WinStationWaitSystemEvent */
610 FIXME("Stub %p 0x%08x %p\n", hServer, Mask, Flags);
611 return FALSE;