Fix a heap corruption in MIX_Init ( sizeof() != strlen() ).
[wine/hacks.git] / dlls / advapi32 / advapi.c
bloba97b09f043585f4d8878b481342c20f0ed9ebc9b
1 /*
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include <errno.h>
25 #include <stdio.h>
26 #include <string.h>
27 #include <stdarg.h>
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winnls.h"
32 #include "winreg.h"
33 #include "winerror.h"
35 #include "wine/library.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
40 /******************************************************************************
41 * GetUserNameA [ADVAPI32.@]
43 * Get the current user name.
45 * PARAMS
46 * lpszName [O] Destination for the user name.
47 * lpSize [I/O] Size of lpszName.
49 * RETURNS
50 * Success: The length of the user name, including terminating NUL.
51 * Failure: ERROR_MORE_DATA if *lpSize is too small.
53 BOOL WINAPI
54 GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
56 WCHAR *buffer;
57 BOOL ret;
58 DWORD sizeW = *lpSize * 2;
60 if (!(buffer = HeapAlloc( GetProcessHeap(), 0, sizeW * sizeof(WCHAR) )))
62 SetLastError( ERROR_NOT_ENOUGH_MEMORY );
63 return FALSE;
65 ret = GetUserNameW( buffer, &sizeW );
66 if (ret)
68 if (!(*lpSize = WideCharToMultiByte( CP_ACP, 0, buffer, -1, lpszName, *lpSize, NULL, NULL )))
70 *lpSize = WideCharToMultiByte( CP_ACP, 0, buffer, -1, NULL, 0, NULL, NULL );
71 SetLastError( ERROR_MORE_DATA );
72 ret = FALSE;
75 else *lpSize = sizeW * 2;
76 HeapFree( GetProcessHeap(), 0, buffer );
77 return ret;
80 /******************************************************************************
81 * GetUserNameW [ADVAPI32.@]
83 * See GetUserNameA.
85 BOOL WINAPI
86 GetUserNameW( LPWSTR lpszName, LPDWORD lpSize )
88 const char *name = wine_get_user_name();
89 DWORD len = MultiByteToWideChar( CP_UNIXCP, 0, name, -1, NULL, 0 );
91 if (len > *lpSize)
93 SetLastError(ERROR_MORE_DATA);
94 *lpSize = len;
95 return FALSE;
98 *lpSize = len;
99 MultiByteToWideChar( CP_UNIXCP, 0, name, -1, lpszName, len );
100 return TRUE;
103 /******************************************************************************
104 * GetCurrentHwProfileA [ADVAPI32.@]
106 * Get the current hardware profile.
108 * PARAMS
109 * pInfo [O] Destination for hardware profile information.
111 * RETURNS
112 * Success: TRUE. pInfo is updated with the hardware profile details.
113 * Failure: FALSE.
115 BOOL WINAPI GetCurrentHwProfileA(LPHW_PROFILE_INFOA pInfo)
117 FIXME("(%p) semi-stub\n", pInfo);
118 pInfo->dwDockInfo = DOCKINFO_DOCKED;
119 strcpy(pInfo->szHwProfileGuid,"{12340001-1234-1234-1234-1233456789012}");
120 strcpy(pInfo->szHwProfileName,"Wine Profile");
121 return 1;
124 /******************************************************************************
125 * AbortSystemShutdownA [ADVAPI32.@]
127 * Stop a system shutdown if one is in progress.
129 * PARAMS
130 * lpMachineName [I] Name of machine to not shutdown.
132 * RETURNS
133 * Success: TRUE.
134 * Failure: FALSE.
136 * NOTES
137 * The Wine implementation of this function is a harmless stub.
139 BOOL WINAPI AbortSystemShutdownA( LPSTR lpMachineName )
141 TRACE("stub %s (harmless)\n", lpMachineName);
142 return TRUE;
145 /******************************************************************************
146 * AbortSystemShutdownW [ADVAPI32.@]
148 * See AbortSystemShutdownA.
150 BOOL WINAPI AbortSystemShutdownW( LPWSTR lpMachineName )
152 TRACE("stub %s (harmless)\n", debugstr_w(lpMachineName));
153 return TRUE;
156 /******************************************************************************
157 * InitiateSystemShutdownExA [ADVAPI32.@]
159 * Initiate a shutdown or optionally restart the computer.
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.
173 * RETURNS
174 * Success: TRUE
175 * Failure: FALSE
177 * NOTES
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,
182 DWORD dwReason)
184 FIXME("%s %s %ld %d %d %ld\n", debugstr_a(lpMachineName),
185 debugstr_a(lpMessage), dwTimeout, bForceAppsClosed,
186 bRebootAfterShutdown, dwReason);
187 return TRUE;
190 /******************************************************************************
191 * InitiateSystemShutdownExW [ADVAPI32.@]
193 * see InitiateSystemShutdownExA
195 BOOL WINAPI InitiateSystemShutdownExW( LPWSTR lpMachineName, LPWSTR lpMessage,
196 DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown,
197 DWORD dwReason)
199 FIXME("%s %s %ld %d %d %ld\n", debugstr_w(lpMachineName),
200 debugstr_w(lpMessage), dwTimeout, bForceAppsClosed,
201 bRebootAfterShutdown, dwReason);
202 return TRUE;
205 DWORD WINAPI CommandLineFromMsiDescriptor(WCHAR *Descriptor, WCHAR *CommandLine,
206 DWORD *CommandLineLength)
208 FIXME("stub (%s)\n", debugstr_w(Descriptor));
209 return ERROR_CALL_NOT_IMPLEMENTED;