ntdll: Make sure we don't try to attach the main exe a second time.
[wine/zf.git] / dlls / wtsapi32 / wtsapi32.c
blob026e7f436902a8cefb1a0727e217ec5223feb274
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 "wtsapi32.h"
23 #include "wine/debug.h"
24 #include "wine/heap.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(wtsapi);
29 /************************************************************
30 * WTSCloseServer (WTSAPI32.@)
32 void WINAPI WTSCloseServer(HANDLE hServer)
34 FIXME("Stub %p\n", hServer);
37 /************************************************************
38 * WTSConnectSessionA (WTSAPI32.@)
40 BOOL WINAPI WTSConnectSessionA(ULONG LogonId, ULONG TargetLogonId, PSTR pPassword, BOOL bWait)
42 FIXME("Stub %d %d (%s) %d\n", LogonId, TargetLogonId, debugstr_a(pPassword), bWait);
43 return TRUE;
46 /************************************************************
47 * WTSConnectSessionW (WTSAPI32.@)
49 BOOL WINAPI WTSConnectSessionW(ULONG LogonId, ULONG TargetLogonId, PWSTR pPassword, BOOL bWait)
51 FIXME("Stub %d %d (%s) %d\n", LogonId, TargetLogonId, debugstr_w(pPassword), bWait);
52 return TRUE;
55 /************************************************************
56 * WTSDisconnectSession (WTSAPI32.@)
58 BOOL WINAPI WTSDisconnectSession(HANDLE hServer, DWORD SessionId, BOOL bWait)
60 FIXME("Stub %p 0x%08x %d\n", hServer, SessionId, bWait);
61 return TRUE;
64 /************************************************************
65 * WTSEnableChildSessions (WTSAPI32.@)
67 BOOL WINAPI WTSEnableChildSessions(BOOL enable)
69 FIXME("Stub %d\n", enable);
70 return TRUE;
74 /************************************************************
75 * WTSEnumerateProcessesExW (WTSAPI32.@)
77 BOOL WINAPI WTSEnumerateProcessesExW(HANDLE server, DWORD *level, DWORD session_id, WCHAR **info, DWORD *count)
79 FIXME("Stub %p %p %d %p %p\n", server, level, session_id, info, count);
80 if (count) *count = 0;
81 return FALSE;
84 /************************************************************
85 * WTSEnumerateProcessesExA (WTSAPI32.@)
87 BOOL WINAPI WTSEnumerateProcessesExA(HANDLE server, DWORD *level, DWORD session_id, char **info, DWORD *count)
89 FIXME("Stub %p %p %d %p %p\n", server, level, session_id, info, count);
90 if (count) *count = 0;
91 return FALSE;
94 /************************************************************
95 * WTSEnumerateProcessesA (WTSAPI32.@)
97 BOOL WINAPI WTSEnumerateProcessesA(HANDLE hServer, DWORD Reserved, DWORD Version,
98 PWTS_PROCESS_INFOA* ppProcessInfo, DWORD* pCount)
100 FIXME("Stub %p 0x%08x 0x%08x %p %p\n", hServer, Reserved, Version,
101 ppProcessInfo, pCount);
103 if (!ppProcessInfo || !pCount) return FALSE;
105 *pCount = 0;
106 *ppProcessInfo = NULL;
108 return TRUE;
111 /************************************************************
112 * WTSEnumerateProcessesW (WTSAPI32.@)
114 BOOL WINAPI WTSEnumerateProcessesW(HANDLE hServer, DWORD Reserved, DWORD Version,
115 PWTS_PROCESS_INFOW* ppProcessInfo, DWORD* pCount)
117 FIXME("Stub %p 0x%08x 0x%08x %p %p\n", hServer, Reserved, Version,
118 ppProcessInfo, pCount);
120 if (!ppProcessInfo || !pCount || Reserved != 0 || Version != 1)
122 SetLastError(ERROR_INVALID_PARAMETER);
123 return FALSE;
126 *pCount = 0;
127 *ppProcessInfo = NULL;
129 return TRUE;
132 /************************************************************
133 * WTSEnumerateServersA (WTSAPI32.@)
135 BOOL WINAPI WTSEnumerateServersA(LPSTR pDomainName, DWORD Reserved, DWORD Version, PWTS_SERVER_INFOA *ppServerInfo, DWORD *pCount)
137 FIXME("Stub %s 0x%08x 0x%08x %p %p\n", debugstr_a(pDomainName), Reserved, Version, ppServerInfo, pCount);
138 return FALSE;
141 /************************************************************
142 * WTSEnumerateServersW (WTSAPI32.@)
144 BOOL WINAPI WTSEnumerateServersW(LPWSTR pDomainName, DWORD Reserved, DWORD Version, PWTS_SERVER_INFOW *ppServerInfo, DWORD *pCount)
146 FIXME("Stub %s 0x%08x 0x%08x %p %p\n", debugstr_w(pDomainName), Reserved, Version, ppServerInfo, pCount);
147 return FALSE;
151 /************************************************************
152 * WTSEnumerateEnumerateSessionsExW (WTSAPI32.@)
154 BOOL WINAPI WTSEnumerateSessionsExW(HANDLE server, DWORD *level, DWORD filter, WTS_SESSION_INFO_1W* info, DWORD *count)
156 FIXME("Stub %p %p %d %p %p\n", server, level, filter, info, count);
157 if (count) *count = 0;
158 return FALSE;
161 /************************************************************
162 * WTSEnumerateEnumerateSessionsExA (WTSAPI32.@)
164 BOOL WINAPI WTSEnumerateSessionsExA(HANDLE server, DWORD *level, DWORD filter, WTS_SESSION_INFO_1A* info, DWORD *count)
166 FIXME("Stub %p %p %d %p %p\n", server, level, filter, info, count);
167 if (count) *count = 0;
168 return FALSE;
171 /************************************************************
172 * WTSEnumerateEnumerateSessionsA (WTSAPI32.@)
174 BOOL WINAPI WTSEnumerateSessionsA(HANDLE hServer, DWORD Reserved, DWORD Version,
175 PWTS_SESSION_INFOA* ppSessionInfo, DWORD* pCount)
177 static int once;
179 if (!once++) FIXME("Stub %p 0x%08x 0x%08x %p %p\n", hServer, Reserved, Version,
180 ppSessionInfo, pCount);
182 if (!ppSessionInfo || !pCount) return FALSE;
184 *pCount = 0;
185 *ppSessionInfo = NULL;
187 return TRUE;
190 /************************************************************
191 * WTSEnumerateEnumerateSessionsW (WTSAPI32.@)
193 BOOL WINAPI WTSEnumerateSessionsW(HANDLE hServer, DWORD Reserved, DWORD Version,
194 PWTS_SESSION_INFOW* ppSessionInfo, DWORD* pCount)
196 FIXME("Stub %p 0x%08x 0x%08x %p %p\n", hServer, Reserved, Version,
197 ppSessionInfo, pCount);
199 if (!ppSessionInfo || !pCount) return FALSE;
201 *pCount = 0;
202 *ppSessionInfo = NULL;
204 return TRUE;
207 /************************************************************
208 * WTSFreeMemory (WTSAPI32.@)
210 void WINAPI WTSFreeMemory(PVOID pMemory)
212 heap_free(pMemory);
215 /************************************************************
216 * WTSFreeMemoryExA (WTSAPI32.@)
218 BOOL WINAPI WTSFreeMemoryExA(WTS_TYPE_CLASS type, void *ptr, ULONG nmemb)
220 TRACE("%d %p %d\n", type, ptr, nmemb);
221 heap_free(ptr);
222 return TRUE;
225 /************************************************************
226 * WTSFreeMemoryExW (WTSAPI32.@)
228 BOOL WINAPI WTSFreeMemoryExW(WTS_TYPE_CLASS type, void *ptr, ULONG nmemb)
230 TRACE("%d %p %d\n", type, ptr, nmemb);
231 heap_free(ptr);
232 return TRUE;
236 /************************************************************
237 * WTSLogoffSession (WTSAPI32.@)
239 BOOL WINAPI WTSLogoffSession(HANDLE hserver, DWORD session_id, BOOL bwait)
241 FIXME("(%p, 0x%x, %d): stub\n", hserver, session_id, bwait);
242 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
243 return FALSE;
247 /************************************************************
248 * WTSOpenServerExW (WTSAPI32.@)
250 HANDLE WINAPI WTSOpenServerExW(WCHAR *server_name)
252 FIXME("(%s) stub\n", debugstr_w(server_name));
253 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
254 return NULL;
257 /************************************************************
258 * WTSOpenServerExA (WTSAPI32.@)
260 HANDLE WINAPI WTSOpenServerExA(char *server_name)
262 FIXME("(%s) stub\n", debugstr_a(server_name));
263 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
264 return NULL;
267 /************************************************************
268 * WTSOpenServerA (WTSAPI32.@)
270 HANDLE WINAPI WTSOpenServerA(LPSTR pServerName)
272 FIXME("(%s) stub\n", debugstr_a(pServerName));
273 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
274 return NULL;
277 /************************************************************
278 * WTSOpenServerW (WTSAPI32.@)
280 HANDLE WINAPI WTSOpenServerW(LPWSTR pServerName)
282 FIXME("(%s) stub\n", debugstr_w(pServerName));
283 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
284 return NULL;
287 /************************************************************
288 * WTSQuerySessionInformationA (WTSAPI32.@)
290 BOOL WINAPI WTSQuerySessionInformationA(
291 HANDLE hServer,
292 DWORD SessionId,
293 WTS_INFO_CLASS WTSInfoClass,
294 LPSTR* Buffer,
295 DWORD* BytesReturned)
297 /* FIXME: Forward request to winsta.dll::WinStationQueryInformationA */
298 FIXME("Stub %p 0x%08x %d %p %p\n", hServer, SessionId, WTSInfoClass,
299 Buffer, BytesReturned);
301 return FALSE;
304 /************************************************************
305 * WTSQuerySessionInformationW (WTSAPI32.@)
307 BOOL WINAPI WTSQuerySessionInformationW(
308 HANDLE hServer,
309 DWORD SessionId,
310 WTS_INFO_CLASS WTSInfoClass,
311 LPWSTR* Buffer,
312 DWORD* BytesReturned)
314 /* FIXME: Forward request to winsta.dll::WinStationQueryInformationW */
315 FIXME("Stub %p 0x%08x %d %p %p\n", hServer, SessionId, WTSInfoClass,
316 Buffer, BytesReturned);
318 if (WTSInfoClass == WTSUserName)
320 WCHAR *username;
321 DWORD count = 0;
323 GetUserNameW(NULL, &count);
324 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return FALSE;
325 if (!(username = heap_alloc(count * sizeof(WCHAR)))) return FALSE;
326 GetUserNameW(username, &count);
327 *Buffer = username;
328 *BytesReturned = count * sizeof(WCHAR);
329 return TRUE;
331 return FALSE;
334 /************************************************************
335 * WTSQueryUserToken (WTSAPI32.@)
337 BOOL WINAPI WTSQueryUserToken(ULONG session_id, PHANDLE token)
339 FIXME("%u %p semi-stub!\n", session_id, token);
341 if (!token)
343 SetLastError(ERROR_INVALID_PARAMETER);
344 return FALSE;
347 return DuplicateHandle(GetCurrentProcess(), GetCurrentProcessToken(),
348 GetCurrentProcess(), token,
349 0, FALSE, DUPLICATE_SAME_ACCESS);
352 /************************************************************
353 * WTSQueryUserConfigA (WTSAPI32.@)
355 BOOL WINAPI WTSQueryUserConfigA(LPSTR pServerName, LPSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPSTR *ppBuffer, DWORD *pBytesReturned)
357 FIXME("Stub (%s) (%s) 0x%08x %p %p\n", debugstr_a(pServerName), debugstr_a(pUserName), WTSConfigClass,
358 ppBuffer, pBytesReturned);
359 return FALSE;
362 /************************************************************
363 * WTSQueryUserConfigW (WTSAPI32.@)
365 BOOL WINAPI WTSQueryUserConfigW(LPWSTR pServerName, LPWSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPWSTR *ppBuffer, DWORD *pBytesReturned)
367 FIXME("Stub (%s) (%s) 0x%08x %p %p\n", debugstr_w(pServerName), debugstr_w(pUserName), WTSConfigClass,
368 ppBuffer, pBytesReturned);
369 return FALSE;
373 /************************************************************
374 * WTSRegisterSessionNotification (WTSAPI32.@)
376 BOOL WINAPI WTSRegisterSessionNotification(HWND hWnd, DWORD dwFlags)
378 FIXME("Stub %p 0x%08x\n", hWnd, dwFlags);
379 return TRUE;
382 /************************************************************
383 * WTSRegisterSessionNotificationEx (WTSAPI32.@)
385 BOOL WINAPI WTSRegisterSessionNotificationEx(HANDLE hServer, HWND hWnd, DWORD dwFlags)
387 FIXME("Stub %p %p 0x%08x\n", hServer, hWnd, dwFlags);
388 return TRUE;
392 /************************************************************
393 * WTSSendMessageA (WTSAPI32.@)
395 BOOL WINAPI WTSSendMessageA(HANDLE hServer, DWORD SessionId, LPSTR pTitle, DWORD TitleLength, LPSTR pMessage,
396 DWORD MessageLength, DWORD Style, DWORD Timeout, DWORD *pResponse, BOOL bWait)
398 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);
399 return FALSE;
402 /************************************************************
403 * WTSSendMessageW (WTSAPI32.@)
405 BOOL WINAPI WTSSendMessageW(HANDLE hServer, DWORD SessionId, LPWSTR pTitle, DWORD TitleLength, LPWSTR pMessage,
406 DWORD MessageLength, DWORD Style, DWORD Timeout, DWORD *pResponse, BOOL bWait)
408 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);
409 return FALSE;
412 /************************************************************
413 * WTSSetUserConfigA (WTSAPI32.@)
415 BOOL WINAPI WTSSetUserConfigA(LPSTR pServerName, LPSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPSTR pBuffer, DWORD DataLength)
417 FIXME("Stub (%s) (%s) 0x%08x %p %d\n", debugstr_a(pServerName), debugstr_a(pUserName), WTSConfigClass,pBuffer, DataLength);
418 return FALSE;
421 /************************************************************
422 * WTSSetUserConfigW (WTSAPI32.@)
424 BOOL WINAPI WTSSetUserConfigW(LPWSTR pServerName, LPWSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPWSTR pBuffer, DWORD DataLength)
426 FIXME("Stub (%s) (%s) 0x%08x %p %d\n", debugstr_w(pServerName), debugstr_w(pUserName), WTSConfigClass,pBuffer, DataLength);
427 return FALSE;
430 /************************************************************
431 * WTSShutdownSystem (WTSAPI32.@)
433 BOOL WINAPI WTSShutdownSystem(HANDLE hServer, DWORD ShutdownFlag)
435 FIXME("Stub %p 0x%08x\n", hServer,ShutdownFlag);
436 return FALSE;
439 /************************************************************
440 * WTSStartRemoteControlSessionA (WTSAPI32.@)
442 BOOL WINAPI WTSStartRemoteControlSessionA(LPSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers)
444 FIXME("Stub (%s) %d %d %d\n", debugstr_a(pTargetServerName), TargetLogonId, HotkeyVk, HotkeyModifiers);
445 return FALSE;
448 /************************************************************
449 * WTSStartRemoteControlSessionW (WTSAPI32.@)
451 BOOL WINAPI WTSStartRemoteControlSessionW(LPWSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers)
453 FIXME("Stub (%s) %d %d %d\n", debugstr_w(pTargetServerName), TargetLogonId, HotkeyVk, HotkeyModifiers);
454 return FALSE;
457 /************************************************************
458 * WTSStopRemoteControlSession (WTSAPI32.@)
460 BOOL WINAPI WTSStopRemoteControlSession(ULONG LogonId)
462 FIXME("Stub %d\n", LogonId);
463 return FALSE;
466 /************************************************************
467 * WTSTerminateProcess (WTSAPI32.@)
469 BOOL WINAPI WTSTerminateProcess(HANDLE hServer, DWORD ProcessId, DWORD ExitCode)
471 FIXME("Stub %p %d %d\n", hServer, ProcessId, ExitCode);
472 return FALSE;
475 /************************************************************
476 * WTSUnRegisterSessionNotification (WTSAPI32.@)
478 BOOL WINAPI WTSUnRegisterSessionNotification(HWND hWnd)
480 FIXME("Stub %p\n", hWnd);
481 return FALSE;
484 /************************************************************
485 * WTSUnRegisterSessionNotification (WTSAPI32.@)
487 BOOL WINAPI WTSUnRegisterSessionNotificationEx(HANDLE hServer, HWND hWnd)
489 FIXME("Stub %p %p\n", hServer, hWnd);
490 return FALSE;
494 /************************************************************
495 * WTSVirtualChannelClose (WTSAPI32.@)
497 BOOL WINAPI WTSVirtualChannelClose(HANDLE hChannelHandle)
499 FIXME("Stub %p\n", hChannelHandle);
500 return FALSE;
503 /************************************************************
504 * WTSVirtualChannelOpen (WTSAPI32.@)
506 HANDLE WINAPI WTSVirtualChannelOpen(HANDLE hServer, DWORD SessionId, LPSTR pVirtualName)
508 FIXME("Stub %p %d (%s)\n", hServer, SessionId, debugstr_a(pVirtualName));
509 return NULL;
512 /************************************************************
513 * WTSVirtualChannelOpen (WTSAPI32.@)
515 HANDLE WINAPI WTSVirtualChannelOpenEx(DWORD SessionId, LPSTR pVirtualName, DWORD flags)
517 FIXME("Stub %d (%s) %d\n", SessionId, debugstr_a(pVirtualName), flags);
518 return NULL;
521 /************************************************************
522 * WTSVirtualChannelPurgeInput (WTSAPI32.@)
524 BOOL WINAPI WTSVirtualChannelPurgeInput(HANDLE hChannelHandle)
526 FIXME("Stub %p\n", hChannelHandle);
527 return FALSE;
530 /************************************************************
531 * WTSVirtualChannelPurgeOutput (WTSAPI32.@)
533 BOOL WINAPI WTSVirtualChannelPurgeOutput(HANDLE hChannelHandle)
535 FIXME("Stub %p\n", hChannelHandle);
536 return FALSE;
540 /************************************************************
541 * WTSVirtualChannelQuery (WTSAPI32.@)
543 BOOL WINAPI WTSVirtualChannelQuery(HANDLE hChannelHandle, WTS_VIRTUAL_CLASS WtsVirtualClass, PVOID *ppBuffer, DWORD *pBytesReturned)
545 FIXME("Stub %p %d %p %p\n", hChannelHandle, WtsVirtualClass, ppBuffer, pBytesReturned);
546 return FALSE;
549 /************************************************************
550 * WTSVirtualChannelRead (WTSAPI32.@)
552 BOOL WINAPI WTSVirtualChannelRead(HANDLE hChannelHandle, ULONG TimeOut, PCHAR Buffer, ULONG BufferSize, PULONG pBytesRead)
554 FIXME("Stub %p %d %p %d %p\n", hChannelHandle, TimeOut, Buffer, BufferSize, pBytesRead);
555 return FALSE;
558 /************************************************************
559 * WTSVirtualChannelWrite (WTSAPI32.@)
561 BOOL WINAPI WTSVirtualChannelWrite(HANDLE hChannelHandle, PCHAR Buffer, ULONG Length, PULONG pBytesWritten)
563 FIXME("Stub %p %p %d %p\n", hChannelHandle, Buffer, Length, pBytesWritten);
564 return FALSE;
567 /************************************************************
568 * WTSWaitSystemEvent (WTSAPI32.@)
570 BOOL WINAPI WTSWaitSystemEvent(HANDLE hServer, DWORD Mask, DWORD* Flags)
572 /* FIXME: Forward request to winsta.dll::WinStationWaitSystemEvent */
573 FIXME("Stub %p 0x%08x %p\n", hServer, Mask, Flags);
574 return FALSE;