1999-01-03 12:48:29 +00:00
|
|
|
/*
|
|
|
|
* Win32 advapi functions
|
|
|
|
*
|
|
|
|
* Copyright 1995 Sven Verdoolaege
|
2002-03-09 23:29:33 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1999-01-03 12:48:29 +00:00
|
|
|
*/
|
|
|
|
|
2002-04-26 19:05:15 +00:00
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
2001-11-20 20:26:54 +00:00
|
|
|
#include <errno.h>
|
1999-06-12 14:55:11 +00:00
|
|
|
#include <stdio.h>
|
1999-02-19 15:42:11 +00:00
|
|
|
#include <string.h>
|
2003-08-22 05:05:56 +00:00
|
|
|
#include <stdarg.h>
|
1999-02-17 13:51:06 +00:00
|
|
|
|
1999-03-14 16:35:05 +00:00
|
|
|
#include "windef.h"
|
2003-08-22 05:05:56 +00:00
|
|
|
#include "winbase.h"
|
2000-11-28 22:40:56 +00:00
|
|
|
#include "winnls.h"
|
2003-09-05 23:08:26 +00:00
|
|
|
#include "winreg.h"
|
2005-05-31 13:24:44 +00:00
|
|
|
#include "winternl.h"
|
1999-01-03 12:48:29 +00:00
|
|
|
#include "winerror.h"
|
2005-06-09 09:44:26 +00:00
|
|
|
#include "appmgmt.h"
|
1999-01-03 12:48:29 +00:00
|
|
|
|
2002-08-27 18:30:53 +00:00
|
|
|
#include "wine/library.h"
|
2002-03-09 23:29:33 +00:00
|
|
|
#include "wine/debug.h"
|
1999-02-17 13:51:06 +00:00
|
|
|
|
2002-03-09 23:29:33 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(advapi);
|
1999-01-03 12:48:29 +00:00
|
|
|
|
1999-01-28 13:46:25 +00:00
|
|
|
/******************************************************************************
|
2001-02-14 23:11:17 +00:00
|
|
|
* GetUserNameA [ADVAPI32.@]
|
2001-11-20 20:26:54 +00:00
|
|
|
*
|
2003-03-18 18:35:48 +00:00
|
|
|
* Get the current user name.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpszName [O] Destination for the user name.
|
|
|
|
* lpSize [I/O] Size of lpszName.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: The length of the user name, including terminating NUL.
|
|
|
|
* Failure: ERROR_MORE_DATA if *lpSize is too small.
|
1999-01-03 12:48:29 +00:00
|
|
|
*/
|
1999-02-26 11:11:13 +00:00
|
|
|
BOOL WINAPI
|
|
|
|
GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
|
1999-01-03 12:48:29 +00:00
|
|
|
{
|
2004-05-07 04:01:28 +00:00
|
|
|
WCHAR *buffer;
|
|
|
|
BOOL ret;
|
2004-05-10 21:26:58 +00:00
|
|
|
DWORD sizeW = *lpSize * 2;
|
2001-11-20 20:26:54 +00:00
|
|
|
|
2004-05-10 21:26:58 +00:00
|
|
|
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, sizeW * sizeof(WCHAR) )))
|
2004-05-07 04:01:28 +00:00
|
|
|
{
|
|
|
|
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-05-10 21:26:58 +00:00
|
|
|
ret = GetUserNameW( buffer, &sizeW );
|
2004-05-07 04:01:28 +00:00
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
if (!(*lpSize = WideCharToMultiByte( CP_ACP, 0, buffer, -1, lpszName, *lpSize, NULL, NULL )))
|
|
|
|
{
|
|
|
|
*lpSize = WideCharToMultiByte( CP_ACP, 0, buffer, -1, NULL, 0, NULL, NULL );
|
|
|
|
SetLastError( ERROR_MORE_DATA );
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
}
|
2004-05-10 21:26:58 +00:00
|
|
|
else *lpSize = sizeW * 2;
|
2004-05-07 04:01:28 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, buffer );
|
|
|
|
return ret;
|
1999-01-03 12:48:29 +00:00
|
|
|
}
|
|
|
|
|
1999-01-28 13:46:25 +00:00
|
|
|
/******************************************************************************
|
2001-02-14 23:11:17 +00:00
|
|
|
* GetUserNameW [ADVAPI32.@]
|
1999-01-28 13:46:25 +00:00
|
|
|
*
|
2003-03-18 18:35:48 +00:00
|
|
|
* See GetUserNameA.
|
1999-01-03 12:48:29 +00:00
|
|
|
*/
|
1999-02-26 11:11:13 +00:00
|
|
|
BOOL WINAPI
|
|
|
|
GetUserNameW( LPWSTR lpszName, LPDWORD lpSize )
|
1999-01-03 12:48:29 +00:00
|
|
|
{
|
2002-08-27 18:30:53 +00:00
|
|
|
const char *name = wine_get_user_name();
|
2004-05-07 04:01:28 +00:00
|
|
|
DWORD len = MultiByteToWideChar( CP_UNIXCP, 0, name, -1, NULL, 0 );
|
1999-01-03 12:48:29 +00:00
|
|
|
|
2002-08-27 18:30:53 +00:00
|
|
|
if (len > *lpSize)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_MORE_DATA);
|
|
|
|
*lpSize = len;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*lpSize = len;
|
2004-05-07 04:01:28 +00:00
|
|
|
MultiByteToWideChar( CP_UNIXCP, 0, name, -1, lpszName, len );
|
2002-08-27 18:30:53 +00:00
|
|
|
return TRUE;
|
1999-01-03 12:48:29 +00:00
|
|
|
}
|
2002-04-19 00:04:27 +00:00
|
|
|
|
2002-06-14 23:32:46 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* GetCurrentHwProfileA [ADVAPI32.@]
|
2003-03-18 18:35:48 +00:00
|
|
|
*
|
|
|
|
* Get the current hardware profile.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pInfo [O] Destination for hardware profile information.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE. pInfo is updated with the hardware profile details.
|
|
|
|
* Failure: FALSE.
|
2002-06-14 23:32:46 +00:00
|
|
|
*/
|
2003-03-18 18:35:48 +00:00
|
|
|
BOOL WINAPI GetCurrentHwProfileA(LPHW_PROFILE_INFOA pInfo)
|
2002-06-14 23:32:46 +00:00
|
|
|
{
|
2003-03-18 18:35:48 +00:00
|
|
|
FIXME("(%p) semi-stub\n", pInfo);
|
|
|
|
pInfo->dwDockInfo = DOCKINFO_DOCKED;
|
|
|
|
strcpy(pInfo->szHwProfileGuid,"{12340001-1234-1234-1234-1233456789012}");
|
|
|
|
strcpy(pInfo->szHwProfileName,"Wine Profile");
|
2002-06-14 23:32:46 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2004-12-14 15:27:05 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* GetCurrentHwProfileW [ADVAPI32.@]
|
|
|
|
*
|
|
|
|
* See GetCurrentHwProfileA.
|
|
|
|
*/
|
2004-12-01 15:27:59 +00:00
|
|
|
BOOL WINAPI GetCurrentHwProfileW(LPHW_PROFILE_INFOW pInfo)
|
|
|
|
{
|
|
|
|
FIXME("(%p)\n", pInfo);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-05-31 13:24:44 +00:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IsTextUnicode (ADVAPI32.@)
|
|
|
|
*
|
|
|
|
* Attempt to guess whether a text buffer is Unicode.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* buf [I] Text buffer to test
|
|
|
|
* len [I] Length of buf
|
|
|
|
* flags [O] Destination for test results
|
|
|
|
*/
|
|
|
|
BOOL WINAPI IsTextUnicode( LPCVOID buf, INT len, LPINT flags )
|
|
|
|
{
|
|
|
|
return RtlIsTextUnicode( buf, len, flags );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-19 00:04:27 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* AbortSystemShutdownA [ADVAPI32.@]
|
|
|
|
*
|
2003-03-18 18:35:48 +00:00
|
|
|
* Stop a system shutdown if one is in progress.
|
|
|
|
*
|
2002-04-19 00:04:27 +00:00
|
|
|
* PARAMS
|
2003-03-18 18:35:48 +00:00
|
|
|
* lpMachineName [I] Name of machine to not shutdown.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE.
|
|
|
|
* Failure: FALSE.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* The Wine implementation of this function is a harmless stub.
|
2002-04-19 00:04:27 +00:00
|
|
|
*/
|
|
|
|
BOOL WINAPI AbortSystemShutdownA( LPSTR lpMachineName )
|
|
|
|
{
|
|
|
|
TRACE("stub %s (harmless)\n", lpMachineName);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* AbortSystemShutdownW [ADVAPI32.@]
|
|
|
|
*
|
2003-03-18 18:35:48 +00:00
|
|
|
* See AbortSystemShutdownA.
|
2002-04-19 00:04:27 +00:00
|
|
|
*/
|
2003-09-05 23:08:26 +00:00
|
|
|
BOOL WINAPI AbortSystemShutdownW( LPWSTR lpMachineName )
|
2002-04-19 00:04:27 +00:00
|
|
|
{
|
|
|
|
TRACE("stub %s (harmless)\n", debugstr_w(lpMachineName));
|
|
|
|
return TRUE;
|
|
|
|
}
|
2003-08-12 18:53:14 +00:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* InitiateSystemShutdownExA [ADVAPI32.@]
|
2004-07-12 23:32:10 +00:00
|
|
|
*
|
|
|
|
* Initiate a shutdown or optionally restart the computer.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpMachineName [I] Network name of machine to shutdown.
|
|
|
|
* lpMessage [I] Message displayed in shutdown dialog box.
|
|
|
|
* dwTimeout [I] Number of seconds dialog is displayed before shutdown.
|
|
|
|
* bForceAppsClosed [I] If TRUE, apps close without saving, else dialog is
|
|
|
|
* displayed requesting user to close apps.
|
|
|
|
* bRebootAfterShutdown [I] If TRUE, system reboots after restart, else the
|
|
|
|
* system flushes all caches to disk and clears
|
|
|
|
* the screen
|
|
|
|
* dwReason [I] Reason for shutting down. Must be a system shutdown reason
|
|
|
|
* code.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* if lpMachineName is NULL, the local computer is shutdown.
|
2003-08-12 18:53:14 +00:00
|
|
|
*/
|
|
|
|
BOOL WINAPI InitiateSystemShutdownExA( LPSTR lpMachineName, LPSTR lpMessage,
|
|
|
|
DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown,
|
|
|
|
DWORD dwReason)
|
|
|
|
{
|
|
|
|
FIXME("%s %s %ld %d %d %ld\n", debugstr_a(lpMachineName),
|
|
|
|
debugstr_a(lpMessage), dwTimeout, bForceAppsClosed,
|
|
|
|
bRebootAfterShutdown, dwReason);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2004-07-12 23:32:10 +00:00
|
|
|
* InitiateSystemShutdownExW [ADVAPI32.@]
|
|
|
|
*
|
|
|
|
* see InitiateSystemShutdownExA
|
2003-08-12 18:53:14 +00:00
|
|
|
*/
|
|
|
|
BOOL WINAPI InitiateSystemShutdownExW( LPWSTR lpMachineName, LPWSTR lpMessage,
|
|
|
|
DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown,
|
|
|
|
DWORD dwReason)
|
|
|
|
{
|
|
|
|
FIXME("%s %s %ld %d %d %ld\n", debugstr_w(lpMachineName),
|
|
|
|
debugstr_w(lpMessage), dwTimeout, bForceAppsClosed,
|
|
|
|
bRebootAfterShutdown, dwReason);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2004-03-22 21:31:26 +00:00
|
|
|
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 17:12:51 +00:00
|
|
|
BOOL WINAPI InitiateSystemShutdownA( LPSTR lpMachineName, LPSTR lpMessage, DWORD dwTimeout,
|
|
|
|
BOOL bForceAppsClosed, BOOL bRebootAfterShutdown )
|
|
|
|
{
|
|
|
|
return InitiateSystemShutdownExA( lpMachineName, lpMessage, dwTimeout,
|
|
|
|
bForceAppsClosed, bRebootAfterShutdown,
|
|
|
|
SHTDN_REASON_MAJOR_LEGACY_API );
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI InitiateSystemShutdownW( LPWSTR lpMachineName, LPWSTR lpMessage, DWORD dwTimeout,
|
|
|
|
BOOL bForceAppsClosed, BOOL bRebootAfterShutdown )
|
|
|
|
{
|
|
|
|
return InitiateSystemShutdownExW( lpMachineName, lpMessage, dwTimeout,
|
|
|
|
bForceAppsClosed, bRebootAfterShutdown,
|
|
|
|
SHTDN_REASON_MAJOR_LEGACY_API );
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI LogonUserA( LPCSTR lpszUsername, LPCSTR lpszDomain, LPCSTR lpszPassword,
|
|
|
|
DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken )
|
|
|
|
{
|
|
|
|
FIXME("%s %s %p 0x%08lx 0x%08lx %p - stub\n", debugstr_a(lpszUsername),
|
|
|
|
debugstr_a(lpszDomain), lpszPassword, dwLogonType, dwLogonProvider, phToken);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI LogonUserW( LPCWSTR lpszUsername, LPCWSTR lpszDomain, LPCWSTR lpszPassword,
|
|
|
|
DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken )
|
|
|
|
{
|
|
|
|
FIXME("%s %s %p 0x%08lx 0x%08lx %p - stub\n", debugstr_w(lpszUsername),
|
|
|
|
debugstr_w(lpszDomain), lpszPassword, dwLogonType, dwLogonProvider, phToken);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-22 21:31:26 +00:00
|
|
|
DWORD WINAPI CommandLineFromMsiDescriptor(WCHAR *Descriptor, WCHAR *CommandLine,
|
|
|
|
DWORD *CommandLineLength)
|
|
|
|
{
|
|
|
|
FIXME("stub (%s)\n", debugstr_w(Descriptor));
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|