~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/userenv/userenv_main.c

Version: ~ [ wine-1.5.31 ] ~ [ wine-1.5.30 ] ~ [ wine-1.5.29 ] ~ [ wine-1.5.28 ] ~ [ wine-1.5.27 ] ~ [ wine-1.5.26 ] ~ [ wine-1.5.25 ] ~ [ wine-1.5.24 ] ~ [ wine-1.5.23 ] ~ [ wine-1.5.22 ] ~ [ wine-1.5.21 ] ~ [ wine-1.5.20 ] ~ [ wine-1.5.19 ] ~ [ wine-1.5.18 ] ~ [ wine-1.5.17 ] ~ [ wine-1.5.16 ] ~ [ wine-1.5.15 ] ~ [ wine-1.5.14 ] ~ [ wine-1.5.13 ] ~ [ wine-1.5.12 ] ~ [ wine-1.5.11 ] ~ [ wine-1.5.10 ] ~ [ wine-1.5.9 ] ~ [ wine-1.5.8 ] ~ [ wine-1.5.7 ] ~ [ wine-1.4.1 ] ~ [ wine-1.5.6 ] ~ [ wine-1.5.5 ] ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * Implementation of userenv.dll
  3  *
  4  * Copyright 2006 Mike McCormack for CodeWeavers
  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 <stdarg.h>
 22 
 23 #include "ntstatus.h"
 24 #define WIN32_NO_STATUS
 25 #include "windef.h"
 26 #include "winbase.h"
 27 #include "winreg.h"
 28 #include "winternl.h"
 29 #include "userenv.h"
 30 
 31 #include "wine/debug.h"
 32 
 33 WINE_DEFAULT_DEBUG_CHANNEL( userenv );
 34 
 35 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 36 {
 37     TRACE("%p %d %p\n", hinstDLL, fdwReason, lpvReserved);
 38 
 39     switch (fdwReason)
 40     {
 41     case DLL_WINE_PREATTACH:
 42         return FALSE;  /* prefer native version */
 43     case DLL_PROCESS_ATTACH:
 44         DisableThreadLibraryCalls(hinstDLL);
 45         break;
 46     case DLL_PROCESS_DETACH:
 47         break;
 48     }
 49     return TRUE;
 50 }
 51 
 52 BOOL WINAPI CreateEnvironmentBlock( LPVOID* lpEnvironment,
 53                      HANDLE hToken, BOOL bInherit )
 54 {
 55     NTSTATUS r;
 56 
 57     TRACE("%p %p %d\n", lpEnvironment, hToken, bInherit );
 58 
 59     if (!lpEnvironment)
 60         return FALSE;
 61 
 62     r = RtlCreateEnvironment(bInherit, (WCHAR **)lpEnvironment);
 63     if (r == STATUS_SUCCESS)
 64         return TRUE;
 65     return FALSE;
 66 }
 67 
 68 BOOL WINAPI DestroyEnvironmentBlock(LPVOID lpEnvironment)
 69 {
 70     NTSTATUS r;
 71 
 72     TRACE("%p\n", lpEnvironment);
 73     r = RtlDestroyEnvironment(lpEnvironment);
 74     if (r == STATUS_SUCCESS)
 75         return TRUE;
 76     return FALSE;
 77 }
 78 
 79 BOOL WINAPI ExpandEnvironmentStringsForUserA( HANDLE hToken, LPCSTR lpSrc,
 80                      LPSTR lpDest, DWORD dwSize )
 81 {
 82     BOOL ret;
 83 
 84     TRACE("%p %s %p %d\n", hToken, debugstr_a(lpSrc), lpDest, dwSize);
 85 
 86     ret = ExpandEnvironmentStringsA( lpSrc, lpDest, dwSize );
 87     TRACE("<- %s\n", debugstr_a(lpDest));
 88     return ret;
 89 }
 90 
 91 BOOL WINAPI ExpandEnvironmentStringsForUserW( HANDLE hToken, LPCWSTR lpSrc,
 92                      LPWSTR lpDest, DWORD dwSize )
 93 {
 94     BOOL ret;
 95 
 96     TRACE("%p %s %p %d\n", hToken, debugstr_w(lpSrc), lpDest, dwSize);
 97 
 98     ret = ExpandEnvironmentStringsW( lpSrc, lpDest, dwSize );
 99     TRACE("<- %s\n", debugstr_w(lpDest));
100     return ret;
101 }
102 
103 BOOL WINAPI GetDefaultUserProfileDirectoryA( LPSTR lpProfileDir, LPDWORD lpcchSize )
104 {
105     FIXME("%p %p\n", lpProfileDir, lpcchSize );
106     return FALSE;
107 }
108 
109 BOOL WINAPI GetDefaultUserProfileDirectoryW( LPWSTR lpProfileDir, LPDWORD lpcchSize )
110 {
111     FIXME("%p %p\n", lpProfileDir, lpcchSize );
112     return FALSE;
113 }
114 
115 BOOL WINAPI GetUserProfileDirectoryA( HANDLE hToken, LPSTR lpProfileDir,
116                      LPDWORD lpcchSize )
117 {
118     FIXME("%p %p %p\n", hToken, lpProfileDir, lpcchSize );
119     return FALSE;
120 }
121 
122 BOOL WINAPI GetUserProfileDirectoryW( HANDLE hToken, LPWSTR lpProfileDir,
123                      LPDWORD lpcchSize )
124 {
125     FIXME("%p %p %p\n", hToken, lpProfileDir, lpcchSize );
126     return FALSE;
127 }
128 
129 static const char ProfileListA[] = "Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList";
130 
131 BOOL WINAPI GetProfilesDirectoryA( LPSTR lpProfilesDir, LPDWORD lpcchSize )
132 {
133     static const char ProfilesDirectory[] = "ProfilesDirectory";
134     LONG l;
135     HKEY key;
136     BOOL ret = FALSE;
137     DWORD len = 0, expanded_len;
138     LPSTR unexpanded_profiles_dir = NULL;
139 
140     TRACE("%p %p\n", lpProfilesDir, lpcchSize );
141 
142     if (!lpProfilesDir || !lpcchSize)
143     {
144         SetLastError(ERROR_INVALID_PARAMETER);
145         return FALSE;
146     }
147 
148     l = RegOpenKeyExA(HKEY_LOCAL_MACHINE, ProfileListA, 0, KEY_READ, &key);
149     if (l)
150     {
151         SetLastError(l);
152         return FALSE;
153     }
154     l = RegQueryValueExA(key, ProfilesDirectory, NULL, NULL, NULL, &len);
155     if (l)
156     {
157         SetLastError(l);
158         goto end;
159     }
160     unexpanded_profiles_dir = HeapAlloc(GetProcessHeap(), 0, len);
161     if (!unexpanded_profiles_dir)
162     {
163         SetLastError(ERROR_OUTOFMEMORY);
164         goto end;
165     }
166     l = RegQueryValueExA(key, ProfilesDirectory, NULL, NULL,
167                              (BYTE *)unexpanded_profiles_dir, &len);
168     if (l)
169     {
170         SetLastError(l);
171         goto end;
172     }
173     expanded_len = ExpandEnvironmentStringsA(unexpanded_profiles_dir, NULL, 0);
174     /* The returned length doesn't include the NULL terminator. */
175     if (*lpcchSize < expanded_len - 1)
176     {
177         *lpcchSize = expanded_len - 1;
178         SetLastError(ERROR_INSUFFICIENT_BUFFER);
179         goto end;
180     }
181     *lpcchSize = expanded_len - 1;
182     /* The return value is also the expected length. */
183     ret = ExpandEnvironmentStringsA(unexpanded_profiles_dir, lpProfilesDir,
184                                     expanded_len) - 1;
185 end:
186     HeapFree(GetProcessHeap(), 0, unexpanded_profiles_dir);
187     RegCloseKey(key);
188     return ret;
189 }
190 
191 static const WCHAR ProfileListW[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','P','r','o','f','i','l','e','L','i','s','t',0};
192 
193 BOOL WINAPI GetProfilesDirectoryW( LPWSTR lpProfilesDir, LPDWORD lpcchSize )
194 {
195     static const WCHAR ProfilesDirectory[] = {'P','r','o','f','i','l','e','s','D','i','r','e','c','t','o','r','y',0};
196     LONG l;
197     HKEY key;
198     BOOL ret = FALSE;
199     DWORD len = 0, expanded_len;
200     LPWSTR unexpanded_profiles_dir = NULL;
201 
202     TRACE("%p %p\n", lpProfilesDir, lpcchSize );
203 
204     if (!lpProfilesDir || !lpcchSize)
205     {
206         SetLastError(ERROR_INVALID_PARAMETER);
207         return FALSE;
208     }
209 
210     l = RegOpenKeyExW(HKEY_LOCAL_MACHINE, ProfileListW, 0, KEY_READ, &key);
211     if (l)
212     {
213         SetLastError(l);
214         return FALSE;
215     }
216     l = RegQueryValueExW(key, ProfilesDirectory, NULL, NULL, NULL, &len);
217     if (l)
218     {
219         SetLastError(l);
220         goto end;
221     }
222     unexpanded_profiles_dir = HeapAlloc(GetProcessHeap(), 0, len);
223     if (!unexpanded_profiles_dir)
224     {
225         SetLastError(ERROR_OUTOFMEMORY);
226         goto end;
227     }
228     l = RegQueryValueExW(key, ProfilesDirectory, NULL, NULL,
229                              (BYTE *)unexpanded_profiles_dir, &len);
230     if (l)
231     {
232         SetLastError(l);
233         goto end;
234     }
235     expanded_len = ExpandEnvironmentStringsW(unexpanded_profiles_dir, NULL, 0);
236     /* The returned length doesn't include the NULL terminator. */
237     if (*lpcchSize < expanded_len - 1)
238     {
239         *lpcchSize = expanded_len - 1;
240         SetLastError(ERROR_INSUFFICIENT_BUFFER);
241         goto end;
242     }
243     *lpcchSize = expanded_len - 1;
244     /* The return value is also the expected length. */
245     ret = ExpandEnvironmentStringsW(unexpanded_profiles_dir, lpProfilesDir,
246                                     expanded_len) - 1;
247 end:
248     HeapFree(GetProcessHeap(), 0, unexpanded_profiles_dir);
249     RegCloseKey(key);
250     return ret;
251 }
252 
253 BOOL WINAPI GetAllUsersProfileDirectoryA( LPSTR lpProfileDir, LPDWORD lpcchSize )
254 {
255     FIXME("%p %p\n", lpProfileDir, lpcchSize);
256     return FALSE;
257 }
258 
259 BOOL WINAPI GetAllUsersProfileDirectoryW( LPWSTR lpProfileDir, LPDWORD lpcchSize )
260 {
261     FIXME("%p %p\n", lpProfileDir, lpcchSize);
262     return FALSE;
263 }
264 
265 BOOL WINAPI GetProfileType( DWORD *pdwFlags )
266 {
267     FIXME("%p\n", pdwFlags );
268     *pdwFlags = 0;
269     return TRUE;
270 }
271 
272 BOOL WINAPI LoadUserProfileA( HANDLE hToken, LPPROFILEINFOA lpProfileInfo )
273 {
274     FIXME("%p %p\n", hToken, lpProfileInfo );
275     lpProfileInfo->hProfile = HKEY_CURRENT_USER;
276     return TRUE;
277 }
278 
279 BOOL WINAPI LoadUserProfileW( HANDLE hToken, LPPROFILEINFOW lpProfileInfo )
280 {
281     FIXME("%p %p\n", hToken, lpProfileInfo );
282     lpProfileInfo->hProfile = HKEY_CURRENT_USER;
283     return TRUE;
284 }
285 
286 BOOL WINAPI RegisterGPNotification( HANDLE event, BOOL machine )
287 {
288     FIXME("%p %d\n", event, machine );
289     return TRUE;
290 }
291 
292 BOOL WINAPI UnregisterGPNotification( HANDLE event )
293 {
294     FIXME("%p\n", event );
295     return TRUE;
296 }
297 
298 BOOL WINAPI UnloadUserProfile( HANDLE hToken, HANDLE hProfile )
299 {
300     FIXME("(%p, %p): stub\n", hToken, hProfile);
301     return FALSE;
302 }
303 
304 /******************************************************************************
305  *              USERENV.138
306  *
307  * Create .lnk file
308  *
309  * PARAMETERS
310  *   int     csidl               [in] well-known directory location to create link in
311  *   LPCSTR lnk_dir              [in] directory (relative to directory specified by csidl) to create link in
312  *   LPCSTR lnk_filename         [in] filename of the link file without .lnk extension
313  *   LPCSTR lnk_target           [in] file/directory pointed to by link
314  *   LPCSTR lnk_iconfile         [in] link icon resource filename
315  *   DWORD   lnk_iconid          [in] link icon resource id in file referred by lnk_iconfile
316  *   LPCSTR work_directory       [in] link target's work directory
317  *   WORD    hotkey              [in] link hotkey (virtual key id)
318  *   DWORD   win_state           [in] initial window size (SW_SHOWMAXIMIZED to start maximized,
319  *                                     SW_SHOWMINNOACTIVE to start minimized, everything else is default state)
320  *   LPCSTR comment              [in] comment - link's comment
321  *   LPCSTR loc_filename_resfile [in] resource file which holds localized filename for this link file
322  *   DWORD   loc_filename_resid  [in] resource id for this link file's localized filename
323  *
324  * RETURNS
325  *    TRUE:  Link file was successfully created
326  *    FALSE: Link file was not created
327  */
328 BOOL WINAPI USERENV_138( int csidl, LPCSTR lnk_dir, LPCSTR lnk_filename,
329             LPCSTR lnk_target, LPCSTR lnk_iconfile, DWORD lnk_iconid,
330             LPCSTR work_directory, WORD hotkey, DWORD win_state, LPCSTR comment,
331             LPCSTR loc_filename_resfile, DWORD loc_filename_resid)
332 {
333     FIXME("(%d,%s,%s,%s,%s,%d,%s,0x%x,%d,%s,%s,%d) - stub\n", csidl, debugstr_a(lnk_dir),
334             debugstr_a(lnk_filename), debugstr_a(lnk_target), debugstr_a(lnk_iconfile),
335             lnk_iconid, debugstr_a(work_directory), hotkey, win_state,
336             debugstr_a(comment), debugstr_a(loc_filename_resfile), loc_filename_resid );
337 
338     return FALSE;
339 }
340 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.