2 * Win32 advapi functions
4 * Copyright 1995 Sven Verdoolaege
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.
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.
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
36 #include "wine/debug.h"
38 #include "advapi32_misc.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(advapi
);
42 /******************************************************************************
43 * GetUserNameA [ADVAPI32.@]
45 BOOL WINAPI
GetUserNameA( LPSTR name
, LPDWORD size
)
47 DWORD len
= GetEnvironmentVariableA( "WINEUSERNAME", name
, *size
);
50 if (!len
) return FALSE
;
51 if ((ret
= (len
< *size
))) len
++;
52 else SetLastError( ERROR_INSUFFICIENT_BUFFER
);
57 /******************************************************************************
58 * GetUserNameW [ADVAPI32.@]
60 BOOL WINAPI
GetUserNameW( LPWSTR name
, LPDWORD size
)
62 DWORD len
= GetEnvironmentVariableW( L
"WINEUSERNAME", name
, *size
);
65 if (!len
) return FALSE
;
66 if ((ret
= (len
< *size
))) len
++;
67 else SetLastError( ERROR_INSUFFICIENT_BUFFER
);
72 /******************************************************************************
73 * GetCurrentHwProfileA [ADVAPI32.@]
75 * Get the current hardware profile.
78 * pInfo [O] Destination for hardware profile information.
81 * Success: TRUE. pInfo is updated with the hardware profile details.
84 BOOL WINAPI
GetCurrentHwProfileA(LPHW_PROFILE_INFOA pInfo
)
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");
93 /******************************************************************************
94 * GetCurrentHwProfileW [ADVAPI32.@]
96 * See GetCurrentHwProfileA.
98 BOOL WINAPI
GetCurrentHwProfileW(LPHW_PROFILE_INFOW pInfo
)
100 FIXME("(%p)\n", pInfo
);
105 /**************************************************************************
106 * IsTextUnicode (ADVAPI32.@)
108 * Attempt to guess whether a text buffer is Unicode.
111 * buf [I] Text buffer to test
112 * len [I] Length of buf
113 * flags [O] Destination for test results
116 * TRUE if the buffer is likely Unicode, FALSE otherwise.
118 BOOL WINAPI
IsTextUnicode( LPCVOID buf
, INT len
, LPINT flags
)
120 return RtlIsTextUnicode( buf
, len
, flags
);
124 /******************************************************************************
125 * AbortSystemShutdownA [ADVAPI32.@]
127 * Stop a system shutdown if one is in progress.
130 * lpMachineName [I] Name of machine to not shutdown.
137 * The Wine implementation of this function is a harmless stub.
139 BOOL WINAPI
AbortSystemShutdownA( LPSTR lpMachineName
)
141 TRACE("stub %s (harmless)\n", debugstr_a(lpMachineName
));
145 /******************************************************************************
146 * AbortSystemShutdownW [ADVAPI32.@]
148 * See AbortSystemShutdownA.
150 BOOL WINAPI
AbortSystemShutdownW( LPWSTR lpMachineName
)
152 TRACE("stub %s (harmless)\n", debugstr_w(lpMachineName
));
156 /******************************************************************************
157 * InitiateSystemShutdownExA [ADVAPI32.@]
159 * Initiate a shutdown or optionally restart the computer.
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
170 * dwReason [I] Reason for shutting down. Must be a system shutdown reason
178 * if lpMachineName is NULL, the local computer is shutdown.
180 BOOL WINAPI
InitiateSystemShutdownExA( LPSTR lpMachineName
, LPSTR lpMessage
,
181 DWORD dwTimeout
, BOOL bForceAppsClosed
, BOOL bRebootAfterShutdown
,
184 FIXME("%s %s %ld %d %d %#lx\n", debugstr_a(lpMachineName
),
185 debugstr_a(lpMessage
), dwTimeout
, bForceAppsClosed
,
186 bRebootAfterShutdown
, dwReason
);
190 /******************************************************************************
191 * InitiateSystemShutdownExW [ADVAPI32.@]
193 * See InitiateSystemShutdownExA.
195 BOOL WINAPI
InitiateSystemShutdownExW( LPWSTR lpMachineName
, LPWSTR lpMessage
,
196 DWORD dwTimeout
, BOOL bForceAppsClosed
, BOOL bRebootAfterShutdown
,
199 FIXME("%s %s %ld %d %d %#lx\n", debugstr_w(lpMachineName
),
200 debugstr_w(lpMessage
), dwTimeout
, bForceAppsClosed
,
201 bRebootAfterShutdown
, dwReason
);
205 BOOL WINAPI
InitiateSystemShutdownA( LPSTR lpMachineName
, LPSTR lpMessage
, DWORD dwTimeout
,
206 BOOL bForceAppsClosed
, BOOL bRebootAfterShutdown
)
208 return InitiateSystemShutdownExA( lpMachineName
, lpMessage
, dwTimeout
,
209 bForceAppsClosed
, bRebootAfterShutdown
,
210 SHTDN_REASON_MAJOR_LEGACY_API
);
213 BOOL WINAPI
InitiateSystemShutdownW( LPWSTR lpMachineName
, LPWSTR lpMessage
, DWORD dwTimeout
,
214 BOOL bForceAppsClosed
, BOOL bRebootAfterShutdown
)
216 return InitiateSystemShutdownExW( lpMachineName
, lpMessage
, dwTimeout
,
217 bForceAppsClosed
, bRebootAfterShutdown
,
218 SHTDN_REASON_MAJOR_LEGACY_API
);
221 /***********************************************************************
222 * InitiateShutdownA [ADVAPI32.@]
224 DWORD WINAPI
InitiateShutdownA(char *name
, char *message
, DWORD seconds
, DWORD flags
, DWORD reason
)
226 FIXME("%s, %s, %ld, %ld, %ld stub\n", debugstr_a(name
), debugstr_a(message
), seconds
, flags
, reason
);
227 return ERROR_CALL_NOT_IMPLEMENTED
;
230 /***********************************************************************
231 * InitiateShutdownW [ADVAPI32.@]
233 DWORD WINAPI
InitiateShutdownW(WCHAR
*name
, WCHAR
*message
, DWORD seconds
, DWORD flags
, DWORD reason
)
235 FIXME("%s, %s, %ld, %ld, %ld stub\n", debugstr_w(name
), debugstr_w(message
), seconds
, flags
, reason
);
236 return ERROR_CALL_NOT_IMPLEMENTED
;
239 BOOL WINAPI
LogonUserA( LPCSTR lpszUsername
, LPCSTR lpszDomain
, LPCSTR lpszPassword
,
240 DWORD dwLogonType
, DWORD dwLogonProvider
, PHANDLE phToken
)
242 WCHAR
*usernameW
= NULL
, *domainW
= NULL
, *passwordW
= NULL
;
245 TRACE("%s %s %p 0x%08lx 0x%08lx %p\n", debugstr_a(lpszUsername
),
246 debugstr_a(lpszDomain
), lpszPassword
, dwLogonType
, dwLogonProvider
, phToken
);
248 if (lpszUsername
&& !(usernameW
= strdupAW( lpszUsername
))) return FALSE
;
249 if (lpszDomain
&& !(domainW
= strdupAW( lpszUsername
))) goto done
;
250 if (lpszPassword
&& !(passwordW
= strdupAW( lpszPassword
))) goto done
;
252 ret
= LogonUserW( usernameW
, domainW
, passwordW
, dwLogonType
, dwLogonProvider
, phToken
);
255 heap_free( usernameW
);
256 heap_free( domainW
);
257 heap_free( passwordW
);
261 BOOL WINAPI
LogonUserW( LPCWSTR lpszUsername
, LPCWSTR lpszDomain
, LPCWSTR lpszPassword
,
262 DWORD dwLogonType
, DWORD dwLogonProvider
, PHANDLE phToken
)
264 FIXME("%s %s %p 0x%08lx 0x%08lx %p - stub\n", debugstr_w(lpszUsername
),
265 debugstr_w(lpszDomain
), lpszPassword
, dwLogonType
, dwLogonProvider
, phToken
);
267 *phToken
= (HANDLE
*)0xdeadbeef;
271 typedef UINT (WINAPI
*fnMsiProvideComponentFromDescriptor
)(LPCWSTR
,LPWSTR
,DWORD
*,DWORD
*);
273 DWORD WINAPI
CommandLineFromMsiDescriptor( WCHAR
*szDescriptor
,
274 WCHAR
*szCommandLine
, DWORD
*pcchCommandLine
)
276 fnMsiProvideComponentFromDescriptor mpcfd
;
278 UINT r
= ERROR_CALL_NOT_IMPLEMENTED
;
280 TRACE("%s %p %p\n", debugstr_w(szDescriptor
), szCommandLine
, pcchCommandLine
);
282 hmsi
= LoadLibraryW( L
"msi" );
285 mpcfd
= (fnMsiProvideComponentFromDescriptor
)GetProcAddress( hmsi
,
286 "MsiProvideComponentFromDescriptorW" );
288 r
= mpcfd( szDescriptor
, szCommandLine
, pcchCommandLine
, NULL
);
293 /***********************************************************************
294 * RegisterWaitChainCOMCallback (ole32.@)
296 void WINAPI
RegisterWaitChainCOMCallback(PCOGETCALLSTATE call_state_cb
,
297 PCOGETACTIVATIONSTATE activation_state_cb
)
299 FIXME("%p, %p\n", call_state_cb
, activation_state_cb
);
302 HWCT WINAPI
OpenThreadWaitChainSession(DWORD flags
, PWAITCHAINCALLBACK callback
)
304 FIXME("flags %ld, callback %p stub!\n", flags
, callback
);
305 SetLastError(ERROR_NOT_SUPPORTED
);
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
)
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
);
318 ULONG WINAPI
PerfCloseQueryHandle( HANDLE query
)
320 FIXME( "query %p stub.\n", query
);
322 return ERROR_SUCCESS
;
325 ULONG WINAPI
PerfOpenQueryHandle( const WCHAR
*machine
, HANDLE
*query
)
327 FIXME( "machine %s, query %p.\n", debugstr_w(machine
), query
);
329 if (!query
) return ERROR_INVALID_PARAMETER
;
330 *query
= (HANDLE
)0xdeadbeef;
332 return ERROR_SUCCESS
;
335 ULONG WINAPI
PerfAddCounters( HANDLE query
, PERF_COUNTER_IDENTIFIER
*id
, DWORD size
)
337 FIXME( "query %p, id %p, size %lu stub.\n", query
, id
, size
);
339 if (!id
|| size
< sizeof(*id
) || id
->Size
< sizeof(*id
)) return ERROR_INVALID_PARAMETER
;
341 id
->Status
= ERROR_WMI_GUID_NOT_FOUND
;
342 return ERROR_SUCCESS
;
345 ULONG WINAPI
PerfQueryCounterData( HANDLE query
, PERF_DATA_HEADER
*data
, DWORD data_size
, DWORD
*size_needed
)
347 FIXME( "query %p, data %p, data_size %lu, size_needed %p stub.\n", query
, data
, data_size
, size_needed
);
349 if (!size_needed
) return ERROR_INVALID_PARAMETER
;
351 *size_needed
= sizeof(PERF_DATA_HEADER
);
353 if (!data
|| data_size
< sizeof(PERF_DATA_HEADER
)) return ERROR_NOT_ENOUGH_MEMORY
;
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
);
362 return ERROR_SUCCESS
;