Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/dlls/advapi32/advapi.c
4387 views
1
/*
2
* Win32 advapi functions
3
*
4
* Copyright 1995 Sven Verdoolaege
5
*
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2.1 of the License, or (at your option) any later version.
10
*
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this library; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19
*/
20
21
#include <errno.h>
22
#include <stdio.h>
23
#include <string.h>
24
#include <stdarg.h>
25
26
#include "windef.h"
27
#include "winbase.h"
28
#include "winnls.h"
29
#include "winreg.h"
30
#include "winternl.h"
31
#include "winerror.h"
32
#include "wincred.h"
33
#include "wct.h"
34
#include "perflib.h"
35
36
#include "wine/debug.h"
37
38
#include "advapi32_misc.h"
39
40
WINE_DEFAULT_DEBUG_CHANNEL(advapi);
41
42
/******************************************************************************
43
* GetUserNameA [ADVAPI32.@]
44
*/
45
BOOL WINAPI GetUserNameA( LPSTR name, LPDWORD size )
46
{
47
DWORD len = GetEnvironmentVariableA( "WINEUSERNAME", name, *size );
48
BOOL ret;
49
50
if (!len) return FALSE;
51
if ((ret = (len < *size))) len++;
52
else SetLastError( ERROR_INSUFFICIENT_BUFFER );
53
*size = len;
54
return ret;
55
}
56
57
/******************************************************************************
58
* GetUserNameW [ADVAPI32.@]
59
*/
60
BOOL WINAPI GetUserNameW( LPWSTR name, LPDWORD size )
61
{
62
DWORD len = GetEnvironmentVariableW( L"WINEUSERNAME", name, *size );
63
BOOL ret;
64
65
if (!len) return FALSE;
66
if ((ret = (len < *size))) len++;
67
else SetLastError( ERROR_INSUFFICIENT_BUFFER );
68
*size = len;
69
return ret;
70
}
71
72
/******************************************************************************
73
* GetCurrentHwProfileA [ADVAPI32.@]
74
*
75
* Get the current hardware profile.
76
*
77
* PARAMS
78
* pInfo [O] Destination for hardware profile information.
79
*
80
* RETURNS
81
* Success: TRUE. pInfo is updated with the hardware profile details.
82
* Failure: FALSE.
83
*/
84
BOOL WINAPI GetCurrentHwProfileA(LPHW_PROFILE_INFOA pInfo)
85
{
86
FIXME("(%p) semi-stub\n", pInfo);
87
pInfo->dwDockInfo = DOCKINFO_DOCKED;
88
strcpy(pInfo->szHwProfileGuid,"{12340001-1234-1234-1234-123456789012}");
89
strcpy(pInfo->szHwProfileName,"Wine Profile");
90
return TRUE;
91
}
92
93
/******************************************************************************
94
* GetCurrentHwProfileW [ADVAPI32.@]
95
*
96
* See GetCurrentHwProfileA.
97
*/
98
BOOL WINAPI GetCurrentHwProfileW(LPHW_PROFILE_INFOW pInfo)
99
{
100
FIXME("(%p)\n", pInfo);
101
return FALSE;
102
}
103
104
105
/**************************************************************************
106
* IsTextUnicode (ADVAPI32.@)
107
*
108
* Attempt to guess whether a text buffer is Unicode.
109
*
110
* PARAMS
111
* buf [I] Text buffer to test
112
* len [I] Length of buf
113
* flags [O] Destination for test results
114
*
115
* RETURNS
116
* TRUE if the buffer is likely Unicode, FALSE otherwise.
117
*/
118
BOOL WINAPI IsTextUnicode( LPCVOID buf, INT len, LPINT flags )
119
{
120
return RtlIsTextUnicode( buf, len, flags );
121
}
122
123
124
/******************************************************************************
125
* AbortSystemShutdownA [ADVAPI32.@]
126
*
127
* Stop a system shutdown if one is in progress.
128
*
129
* PARAMS
130
* lpMachineName [I] Name of machine to not shutdown.
131
*
132
* RETURNS
133
* Success: TRUE.
134
* Failure: FALSE.
135
*
136
* NOTES
137
* The Wine implementation of this function is a harmless stub.
138
*/
139
BOOL WINAPI AbortSystemShutdownA( LPSTR lpMachineName )
140
{
141
TRACE("stub %s (harmless)\n", debugstr_a(lpMachineName));
142
return TRUE;
143
}
144
145
/******************************************************************************
146
* AbortSystemShutdownW [ADVAPI32.@]
147
*
148
* See AbortSystemShutdownA.
149
*/
150
BOOL WINAPI AbortSystemShutdownW( LPWSTR lpMachineName )
151
{
152
TRACE("stub %s (harmless)\n", debugstr_w(lpMachineName));
153
return TRUE;
154
}
155
156
/******************************************************************************
157
* InitiateSystemShutdownExA [ADVAPI32.@]
158
*
159
* Initiate a shutdown or optionally restart the computer.
160
*
161
* PARAMS
162
* lpMachineName [I] Network name of machine to shutdown.
163
* lpMessage [I] Message displayed in shutdown dialog box.
164
* dwTimeout [I] Number of seconds dialog is displayed before shutdown.
165
* bForceAppsClosed [I] If TRUE, apps close without saving, else dialog is
166
* displayed requesting user to close apps.
167
* bRebootAfterShutdown [I] If TRUE, system reboots after restart, else the
168
* system flushes all caches to disk and clears
169
* the screen
170
* dwReason [I] Reason for shutting down. Must be a system shutdown reason
171
* code.
172
*
173
* RETURNS
174
* Success: TRUE
175
* Failure: FALSE
176
*
177
* NOTES
178
* if lpMachineName is NULL, the local computer is shutdown.
179
*/
180
BOOL WINAPI InitiateSystemShutdownExA( LPSTR lpMachineName, LPSTR lpMessage,
181
DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown,
182
DWORD dwReason)
183
{
184
FIXME("%s %s %ld %d %d %#lx\n", debugstr_a(lpMachineName),
185
debugstr_a(lpMessage), dwTimeout, bForceAppsClosed,
186
bRebootAfterShutdown, dwReason);
187
return TRUE;
188
}
189
190
/******************************************************************************
191
* InitiateSystemShutdownExW [ADVAPI32.@]
192
*
193
* See InitiateSystemShutdownExA.
194
*/
195
BOOL WINAPI InitiateSystemShutdownExW( LPWSTR lpMachineName, LPWSTR lpMessage,
196
DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown,
197
DWORD dwReason)
198
{
199
FIXME("%s %s %ld %d %d %#lx\n", debugstr_w(lpMachineName),
200
debugstr_w(lpMessage), dwTimeout, bForceAppsClosed,
201
bRebootAfterShutdown, dwReason);
202
return TRUE;
203
}
204
205
BOOL WINAPI InitiateSystemShutdownA( LPSTR lpMachineName, LPSTR lpMessage, DWORD dwTimeout,
206
BOOL bForceAppsClosed, BOOL bRebootAfterShutdown )
207
{
208
return InitiateSystemShutdownExA( lpMachineName, lpMessage, dwTimeout,
209
bForceAppsClosed, bRebootAfterShutdown,
210
SHTDN_REASON_MAJOR_LEGACY_API );
211
}
212
213
BOOL WINAPI InitiateSystemShutdownW( LPWSTR lpMachineName, LPWSTR lpMessage, DWORD dwTimeout,
214
BOOL bForceAppsClosed, BOOL bRebootAfterShutdown )
215
{
216
return InitiateSystemShutdownExW( lpMachineName, lpMessage, dwTimeout,
217
bForceAppsClosed, bRebootAfterShutdown,
218
SHTDN_REASON_MAJOR_LEGACY_API );
219
}
220
221
/***********************************************************************
222
* InitiateShutdownA [ADVAPI32.@]
223
*/
224
DWORD WINAPI InitiateShutdownA(char *name, char *message, DWORD seconds, DWORD flags, DWORD reason)
225
{
226
FIXME("%s, %s, %ld, %ld, %ld stub\n", debugstr_a(name), debugstr_a(message), seconds, flags, reason);
227
return ERROR_CALL_NOT_IMPLEMENTED;
228
}
229
230
/***********************************************************************
231
* InitiateShutdownW [ADVAPI32.@]
232
*/
233
DWORD WINAPI InitiateShutdownW(WCHAR *name, WCHAR *message, DWORD seconds, DWORD flags, DWORD reason)
234
{
235
FIXME("%s, %s, %ld, %ld, %ld stub\n", debugstr_w(name), debugstr_w(message), seconds, flags, reason);
236
return ERROR_CALL_NOT_IMPLEMENTED;
237
}
238
239
BOOL WINAPI LogonUserA( LPCSTR lpszUsername, LPCSTR lpszDomain, LPCSTR lpszPassword,
240
DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken )
241
{
242
WCHAR *usernameW = NULL, *domainW = NULL, *passwordW = NULL;
243
BOOL ret = FALSE;
244
245
TRACE("%s %s %p 0x%08lx 0x%08lx %p\n", debugstr_a(lpszUsername),
246
debugstr_a(lpszDomain), lpszPassword, dwLogonType, dwLogonProvider, phToken);
247
248
if (lpszUsername && !(usernameW = strdupAW( lpszUsername ))) return FALSE;
249
if (lpszDomain && !(domainW = strdupAW( lpszUsername ))) goto done;
250
if (lpszPassword && !(passwordW = strdupAW( lpszPassword ))) goto done;
251
252
ret = LogonUserW( usernameW, domainW, passwordW, dwLogonType, dwLogonProvider, phToken );
253
254
done:
255
free( usernameW );
256
free( domainW );
257
free( passwordW );
258
return ret;
259
}
260
261
BOOL WINAPI LogonUserW( LPCWSTR lpszUsername, LPCWSTR lpszDomain, LPCWSTR lpszPassword,
262
DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken )
263
{
264
FIXME("%s %s %p 0x%08lx 0x%08lx %p - stub\n", debugstr_w(lpszUsername),
265
debugstr_w(lpszDomain), lpszPassword, dwLogonType, dwLogonProvider, phToken);
266
267
*phToken = (HANDLE *)0xdeadbeef;
268
return TRUE;
269
}
270
271
typedef UINT (WINAPI *fnMsiProvideComponentFromDescriptor)(LPCWSTR,LPWSTR,DWORD*,DWORD*);
272
273
DWORD WINAPI CommandLineFromMsiDescriptor( WCHAR *szDescriptor,
274
WCHAR *szCommandLine, DWORD *pcchCommandLine )
275
{
276
fnMsiProvideComponentFromDescriptor mpcfd;
277
HMODULE hmsi;
278
UINT r = ERROR_CALL_NOT_IMPLEMENTED;
279
280
TRACE("%s %p %p\n", debugstr_w(szDescriptor), szCommandLine, pcchCommandLine);
281
282
hmsi = LoadLibraryW( L"msi" );
283
if (!hmsi)
284
return r;
285
mpcfd = (fnMsiProvideComponentFromDescriptor)GetProcAddress( hmsi,
286
"MsiProvideComponentFromDescriptorW" );
287
if (mpcfd)
288
r = mpcfd( szDescriptor, szCommandLine, pcchCommandLine, NULL );
289
FreeLibrary( hmsi );
290
return r;
291
}
292
293
/***********************************************************************
294
* RegisterWaitChainCOMCallback (ole32.@)
295
*/
296
void WINAPI RegisterWaitChainCOMCallback(PCOGETCALLSTATE call_state_cb,
297
PCOGETACTIVATIONSTATE activation_state_cb)
298
{
299
FIXME("%p, %p\n", call_state_cb, activation_state_cb);
300
}
301
302
HWCT WINAPI OpenThreadWaitChainSession(DWORD flags, PWAITCHAINCALLBACK callback)
303
{
304
FIXME("flags %ld, callback %p stub!\n", flags, callback);
305
SetLastError(ERROR_NOT_SUPPORTED);
306
return NULL;
307
}
308
309
BOOL WINAPI GetThreadWaitChain(HWCT handle, DWORD_PTR ctx, DWORD flags, DWORD thread_id, DWORD *node_count,
310
WAITCHAIN_NODE_INFO *node_info_arr, BOOL *is_cycle)
311
{
312
FIXME( "handle %p, ctx %Ix, flags %ld, thread_id %ld, node_count %p, node_info_arr %p, is_cycle %p stub!\n",
313
handle, ctx, flags, thread_id, node_count, node_info_arr, is_cycle );
314
SetLastError(ERROR_NOT_SUPPORTED);
315
return FALSE;
316
}
317
318
ULONG WINAPI PerfCloseQueryHandle( HANDLE query )
319
{
320
FIXME( "query %p stub.\n", query );
321
322
return ERROR_SUCCESS;
323
}
324
325
ULONG WINAPI PerfOpenQueryHandle( const WCHAR *machine, HANDLE *query )
326
{
327
FIXME( "machine %s, query %p.\n", debugstr_w(machine), query );
328
329
if (!query) return ERROR_INVALID_PARAMETER;
330
*query = (HANDLE)0xdeadbeef;
331
332
return ERROR_SUCCESS;
333
}
334
335
ULONG WINAPI PerfAddCounters( HANDLE query, PERF_COUNTER_IDENTIFIER *id, DWORD size )
336
{
337
FIXME( "query %p, id %p, size %lu stub.\n", query, id, size );
338
339
if (!id || size < sizeof(*id) || id->Size < sizeof(*id)) return ERROR_INVALID_PARAMETER;
340
341
id->Status = ERROR_WMI_GUID_NOT_FOUND;
342
return ERROR_SUCCESS;
343
}
344
345
ULONG WINAPI PerfQueryCounterData( HANDLE query, PERF_DATA_HEADER *data, DWORD data_size, DWORD *size_needed )
346
{
347
FIXME( "query %p, data %p, data_size %lu, size_needed %p stub.\n", query, data, data_size, size_needed );
348
349
if (!size_needed) return ERROR_INVALID_PARAMETER;
350
351
*size_needed = sizeof(PERF_DATA_HEADER);
352
353
if (!data || data_size < sizeof(PERF_DATA_HEADER)) return ERROR_NOT_ENOUGH_MEMORY;
354
355
data->dwTotalSize = sizeof(PERF_DATA_HEADER);
356
data->dwNumCounters = 0;
357
QueryPerformanceCounter( (LARGE_INTEGER *)&data->PerfTimeStamp );
358
QueryPerformanceFrequency( (LARGE_INTEGER *)&data->PerfFreq );
359
GetSystemTimeAsFileTime( (FILETIME *)&data->PerfTime100NSec );
360
FileTimeToSystemTime( (FILETIME *)&data->PerfTime100NSec, &data->SystemTime );
361
362
return ERROR_SUCCESS;
363
}
364
365