ReactOS
0.4.16-dev-36-g301675c
wtsapi.c
Go to the documentation of this file.
1
/*
2
* Copyright 2014 Stefan Leichter
3
*
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) any later version.
8
*
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
13
*
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17
*/
18
19
#include <stdarg.h>
20
#include <stdlib.h>
21
#include <
windef.h
>
22
#include <
winbase.h
>
23
#include <wine/winternl.h>
24
#include <
wtsapi32.h
>
25
26
#include "
wine/test.h
"
27
28
static
void
test_WTSEnumerateProcessesW
(
void
)
29
{
30
BOOL
found =
FALSE
,
ret
;
31
DWORD
count
,
i
;
32
PWTS_PROCESS_INFOW
info
;
33
WCHAR
*
pname
,
nameW
[
MAX_PATH
];
34
35
GetModuleFileNameW
(
NULL
,
nameW
,
MAX_PATH
);
36
for
(
pname
=
nameW
+
lstrlenW
(
nameW
);
pname
>
nameW
;
pname
--)
37
{
38
if
(*
pname
==
'/'
|| *
pname
==
'\\'
)
39
{
40
pname
++;
41
break
;
42
}
43
}
44
45
info
=
NULL
;
46
SetLastError
(0xdeadbeef);
47
ret
=
WTSEnumerateProcessesW
(
WTS_CURRENT_SERVER_HANDLE
, 1, 1, &
info
, &
count
);
48
ok
(!
ret
,
"expected WTSEnumerateProcessesW to fail\n"
);
49
ok
(
GetLastError
()==
ERROR_INVALID_PARAMETER
,
"expected ERROR_INVALID_PARAMETER got: %d\n"
,
GetLastError
());
50
WTSFreeMemory
(
info
);
51
52
info
=
NULL
;
53
SetLastError
(0xdeadbeef);
54
ret
=
WTSEnumerateProcessesW
(
WTS_CURRENT_SERVER_HANDLE
, 0, 0, &
info
, &
count
);
55
ok
(!
ret
,
"expected WTSEnumerateProcessesW to fail\n"
);
56
ok
(
GetLastError
()==
ERROR_INVALID_PARAMETER
,
"expected ERROR_INVALID_PARAMETER got: %d\n"
,
GetLastError
());
57
WTSFreeMemory
(
info
);
58
59
info
=
NULL
;
60
SetLastError
(0xdeadbeef);
61
ret
=
WTSEnumerateProcessesW
(
WTS_CURRENT_SERVER_HANDLE
, 0, 2, &
info
, &
count
);
62
ok
(!
ret
,
"expected WTSEnumerateProcessesW to fail\n"
);
63
ok
(
GetLastError
()==
ERROR_INVALID_PARAMETER
,
"expected ERROR_INVALID_PARAMETER got: %d\n"
,
GetLastError
());
64
WTSFreeMemory
(
info
);
65
66
SetLastError
(0xdeadbeef);
67
ret
=
WTSEnumerateProcessesW
(
WTS_CURRENT_SERVER_HANDLE
, 0, 1,
NULL
, &
count
);
68
ok
(!
ret
,
"expected WTSEnumerateProcessesW to fail\n"
);
69
ok
(
GetLastError
()==
ERROR_INVALID_PARAMETER
,
"expected ERROR_INVALID_PARAMETER got: %d\n"
,
GetLastError
());
70
71
info
=
NULL
;
72
SetLastError
(0xdeadbeef);
73
ret
=
WTSEnumerateProcessesW
(
WTS_CURRENT_SERVER_HANDLE
, 0, 1, &
info
,
NULL
);
74
ok
(!
ret
,
"expected WTSEnumerateProcessesW to fail\n"
);
75
ok
(
GetLastError
()==
ERROR_INVALID_PARAMETER
,
"expected ERROR_INVALID_PARAMETER got: %d\n"
,
GetLastError
());
76
WTSFreeMemory
(
info
);
77
78
count
= 0;
79
info
=
NULL
;
80
SetLastError
(0xdeadbeef);
81
ret
=
WTSEnumerateProcessesW
(
WTS_CURRENT_SERVER_HANDLE
, 0, 1, &
info
, &
count
);
82
ok
(
ret
||
broken
(!
ret
),
/* fails on Win2K with error ERROR_APP_WRONG_OS */
83
"expected WTSEnumerateProcessesW to succeed; failed with %d\n"
,
GetLastError
());
84
for
(
i
= 0;
ret
&&
i
<
count
;
i
++)
85
{
86
found = found || !
lstrcmpW
(
pname
,
info
[
i
].pProcessName);
87
}
88
ok
(found ||
broken
(!
ret
),
"process name %s not found\n"
,
wine_dbgstr_w
(
pname
));
89
WTSFreeMemory
(
info
);
90
}
91
92
static
void
test_WTSQuerySessionInformationW
(
void
)
93
{
94
BOOL
ret
;
95
WCHAR
*
buf
;
96
DWORD
count
;
97
98
count
= 0;
99
buf
=
NULL
;
100
ret
=
WTSQuerySessionInformationW
(
WTS_CURRENT_SERVER_HANDLE
,
WTS_CURRENT_SESSION
,
WTSUserName
, &
buf
, &
count
);
101
ok
(
ret
,
"got %u\n"
,
GetLastError
());
102
ok
(
buf
!=
NULL
,
"buf not set\n"
);
103
ok
(
count
== (
lstrlenW
(
buf
) + 1) *
sizeof
(
WCHAR
),
"got %u\n"
,
count
);
104
WTSFreeMemory
(
buf
);
105
}
106
107
static
void
test_WTSQueryUserToken
(
void
)
108
{
109
BOOL
ret
;
110
111
SetLastError
(0xdeadbeef);
112
ret
=
WTSQueryUserToken
(
WTS_CURRENT_SESSION
,
NULL
);
113
ok
(!
ret
,
"expected WTSQueryUserToken to fail\n"
);
114
ok
(
GetLastError
()==
ERROR_INVALID_PARAMETER
,
"expected ERROR_INVALID_PARAMETER got: %d\n"
,
GetLastError
());
115
}
116
117
START_TEST
(wtsapi)
118
{
119
test_WTSEnumerateProcessesW
();
120
test_WTSQuerySessionInformationW
();
121
test_WTSQueryUserToken
();
122
}
ok
#define ok(value,...)
Definition:
atltest.h:57
broken
#define broken(x)
Definition:
atltest.h:178
START_TEST
#define START_TEST(x)
Definition:
atltest.h:75
nameW
static const WCHAR nameW[]
Definition:
main.c:49
NULL
#define NULL
Definition:
types.h:112
FALSE
#define FALSE
Definition:
types.h:117
ERROR_INVALID_PARAMETER
#define ERROR_INVALID_PARAMETER
Definition:
compat.h:101
SetLastError
#define SetLastError(x)
Definition:
compat.h:752
MAX_PATH
#define MAX_PATH
Definition:
compat.h:34
lstrlenW
#define lstrlenW
Definition:
compat.h:750
GetModuleFileNameW
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition:
loader.c:600
lstrcmpW
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition:
locale.c:4242
BOOL
unsigned int BOOL
Definition:
ntddk_ex.h:94
DWORD
unsigned long DWORD
Definition:
ntddk_ex.h:95
count
GLuint GLuint GLsizei count
Definition:
gl.h:1545
pname
GLenum pname
Definition:
glext.h:5645
buf
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition:
glext.h:7751
i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition:
glfuncs.h:248
wine_dbgstr_w
#define wine_dbgstr_w
Definition:
kernel32.h:34
test.h
_WTS_PROCESS_INFOW
Definition:
wtsapi32.h:130
info
Definition:
notification.c:61
ret
int ret
Definition:
wcstombs-tests.c:31
winbase.h
GetLastError
DWORD WINAPI GetLastError(void)
Definition:
except.c:1042
windef.h
WTSFreeMemory
void WINAPI WTSFreeMemory(PVOID pMemory)
Definition:
wtsapi32.c:283
WTSQuerySessionInformationW
BOOL WINAPI WTSQuerySessionInformationW(HANDLE hServer, DWORD SessionId, WTS_INFO_CLASS WTSInfoClass, LPWSTR *Buffer, DWORD *BytesReturned)
Definition:
wtsapi32.c:443
WTSEnumerateProcessesW
BOOL WINAPI WTSEnumerateProcessesW(HANDLE hServer, DWORD Reserved, DWORD Version, PWTS_PROCESS_INFOW *ppProcessInfo, DWORD *pCount)
Definition:
wtsapi32.c:120
WTSQueryUserToken
BOOL WINAPI WTSQueryUserToken(ULONG session_id, PHANDLE token)
Definition:
wtsapi32.c:588
wtsapi32.h
WTS_CURRENT_SERVER_HANDLE
#define WTS_CURRENT_SERVER_HANDLE
Definition:
wtsapi32.h:197
WTSUserName
@ WTSUserName
Definition:
wtsapi32.h:50
WTS_CURRENT_SESSION
#define WTS_CURRENT_SESSION
Definition:
wtsapi32.h:198
test_WTSQueryUserToken
static void test_WTSQueryUserToken(void)
Definition:
wtsapi.c:107
test_WTSEnumerateProcessesW
static void test_WTSEnumerateProcessesW(void)
Definition:
wtsapi.c:28
test_WTSQuerySessionInformationW
static void test_WTSQuerySessionInformationW(void)
Definition:
wtsapi.c:92
WCHAR
__wchar_t WCHAR
Definition:
xmlstorage.h:180
modules
rostests
winetests
wtsapi32
wtsapi.c
Generated on Mon Sep 16 2024 06:10:42 for ReactOS by
1.9.6