makefiles: Don't use standard libs for programs that specify -nodefaultlibs.
[wine/zf.git] / dlls / userenv / userenv_main.c
blob045bac0cfe175505f60c3eca86839fd9b5e1f259
1 /*
2 * Implementation of userenv.dll
4 * Copyright 2006 Mike McCormack for CodeWeavers
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
21 #include <stdarg.h>
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 "winnls.h"
30 #include "sddl.h"
31 #include "objbase.h"
32 #include "userenv.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL( userenv );
38 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
40 TRACE("%p %d %p\n", hinstDLL, fdwReason, lpvReserved);
42 switch (fdwReason)
44 case DLL_WINE_PREATTACH:
45 return FALSE; /* prefer native version */
46 case DLL_PROCESS_ATTACH:
47 DisableThreadLibraryCalls(hinstDLL);
48 break;
50 return TRUE;
53 static BOOL get_reg_value(WCHAR *env, HKEY hkey, const WCHAR *name, WCHAR *val, DWORD size)
55 DWORD type, res_size=0;
57 if (RegQueryValueExW(hkey, name, 0, &type, NULL, &res_size) != ERROR_SUCCESS)
58 return FALSE;
60 if (type == REG_SZ)
62 if (res_size > size)
63 return FALSE;
65 return RegQueryValueExW(hkey, name, 0, NULL, (BYTE*)val, &size) == ERROR_SUCCESS;
67 else if (type == REG_EXPAND_SZ)
69 UNICODE_STRING us_buf, us_expanded;
70 WCHAR *buf = HeapAlloc(GetProcessHeap(), 0, res_size);
71 if (!buf)
72 return FALSE;
74 if (RegQueryValueExW(hkey, name, 0, NULL, (BYTE*)buf, &res_size) != ERROR_SUCCESS)
76 HeapFree(GetProcessHeap(), 0, buf);
77 return FALSE;
80 RtlInitUnicodeString(&us_buf, buf);
81 us_expanded.Buffer = val;
82 us_expanded.MaximumLength = size;
83 if (RtlExpandEnvironmentStrings_U(env, &us_buf, &us_expanded, &size) != STATUS_SUCCESS)
85 HeapFree(GetProcessHeap(), 0, buf);
86 return FALSE;
89 HeapFree(GetProcessHeap(), 0, buf);
90 return TRUE;
93 return FALSE;
96 static void set_env_var( WCHAR **env, const WCHAR *name, const WCHAR *val )
98 UNICODE_STRING nameW, valW;
100 RtlInitUnicodeString( &nameW, name );
101 RtlInitUnicodeString( &valW, val );
102 RtlSetEnvironmentVariable( env, &nameW, &valW );
105 static void set_registry_variables(WCHAR **env, HKEY hkey, DWORD type, BOOL set_path)
107 UNICODE_STRING us_name, us_value;
108 WCHAR name[1024], value[1024];
109 DWORD ret, index, size;
111 for (index = 0; ; index++)
113 size = ARRAY_SIZE(name);
114 ret = RegEnumValueW(hkey, index, name, &size, NULL, NULL, NULL, NULL);
115 if (ret != ERROR_SUCCESS)
116 break;
118 if (!wcsicmp(name, L"SystemRoot")) continue;
119 if (!wcsicmp(name, L"SystemDrive")) continue;
121 RtlInitUnicodeString(&us_name, name);
122 us_value.Buffer = value;
123 us_value.MaximumLength = sizeof(value);
124 if (!wcsicmp(name, L"PATH") &&
125 !RtlQueryEnvironmentVariable_U(*env, &us_name, &us_value))
127 if (!set_path)
128 continue;
130 size = lstrlenW(value)+1;
131 if (!get_reg_value(*env, hkey, name, value+size,
132 sizeof(value)-size*sizeof(WCHAR)))
133 continue;
135 value[size] = ';';
136 set_env_var(env, name, value);
137 continue;
140 if (get_reg_value(*env, hkey, name, value, sizeof(value)) && value[0])
141 set_env_var(env, name, value);
145 static void set_wow64_environment(WCHAR **env)
147 WCHAR buf[64];
148 HKEY hkey;
149 BOOL is_win64 = (sizeof(void *) > sizeof(int));
150 BOOL is_wow64;
152 IsWow64Process( GetCurrentProcess(), &is_wow64 );
154 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion",
155 0, KEY_READ|KEY_WOW64_64KEY, &hkey))
156 return;
158 /* set the ProgramFiles variables */
160 if (get_reg_value(*env, hkey, L"ProgramFilesDir", buf, sizeof(buf)))
162 if (is_win64 || is_wow64) set_env_var(env, L"ProgramW6432", buf);
163 if (is_win64 || !is_wow64) set_env_var(env, L"ProgramFiles", buf);
165 if (get_reg_value(*env, hkey, L"ProgramFilesDir (x86)", buf, sizeof(buf)))
167 if (is_win64 || is_wow64) set_env_var(env, L"ProgramFiles(x86)", buf);
168 if (is_wow64) set_env_var(env, L"ProgramFiles", buf);
171 /* set the CommonProgramFiles variables */
173 if (get_reg_value(*env, hkey, L"CommonFilesDir", buf, sizeof(buf)))
175 if (is_win64 || is_wow64) set_env_var(env, L"CommonProgramW6432", buf);
176 if (is_win64 || !is_wow64) set_env_var(env, L"CommonProgramFiles", buf);
178 if (get_reg_value(*env, hkey, L"CommonFilesDir (x86)", buf, sizeof(buf)))
180 if (is_win64 || is_wow64) set_env_var(env, L"CommonProgramFiles(x86)", buf);
181 if (is_wow64) set_env_var(env, L"CommonProgramFiles", buf);
184 RegCloseKey(hkey);
187 BOOL WINAPI CreateEnvironmentBlock( LPVOID* lpEnvironment,
188 HANDLE hToken, BOOL bInherit )
190 static const WCHAR env_keyW[] = L"System\\CurrentControlSet\\Control\\Session Manager\\Environment";
191 static const WCHAR profile_keyW[] = L"Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList";
193 WCHAR *env, buf[UNICODE_STRING_MAX_CHARS], profiles_dir[MAX_PATH];
194 DWORD len;
195 HKEY hkey, hsubkey;
197 TRACE("%p %p %d\n", lpEnvironment, hToken, bInherit );
199 if (!lpEnvironment)
200 return FALSE;
202 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, env_keyW, 0, KEY_READ, &hkey) != ERROR_SUCCESS)
203 return FALSE;
205 if (RtlCreateEnvironment(bInherit, &env) != STATUS_SUCCESS)
207 RegCloseKey(hkey);
208 return FALSE;
211 if (!GetEnvironmentVariableW(L"SystemRoot", buf, UNICODE_STRING_MAX_CHARS))
213 if (!get_reg_value(env, hkey, L"SystemRoot", buf, UNICODE_STRING_MAX_CHARS))
215 buf[0] = 0;
216 WARN("SystemRoot variable not set\n");
219 set_env_var(&env, L"SystemRoot", buf);
221 if (!GetEnvironmentVariableW(L"SystemDrive", buf, UNICODE_STRING_MAX_CHARS))
223 if (!get_reg_value(env, hkey, L"SystemDrive", buf, UNICODE_STRING_MAX_CHARS))
225 buf[0] = 0;
226 WARN("SystemDrive variable not set\n");
229 set_env_var(&env, L"SystemDrive", buf);
231 set_registry_variables(&env, hkey, REG_SZ, !bInherit);
232 set_registry_variables(&env, hkey, REG_EXPAND_SZ, !bInherit);
234 if (RegOpenKeyExW(hkey, L"Environment", 0, KEY_READ, &hsubkey) == ERROR_SUCCESS)
236 set_registry_variables(&env, hsubkey, REG_SZ, !bInherit);
237 set_registry_variables(&env, hsubkey, REG_EXPAND_SZ, !bInherit);
238 RegCloseKey(hsubkey);
241 if (RegOpenKeyExW(hkey, L"Volatile Environment", 0, KEY_READ, &hsubkey) == ERROR_SUCCESS)
243 set_registry_variables(&env, hsubkey, REG_SZ, !bInherit);
244 set_registry_variables(&env, hsubkey, REG_EXPAND_SZ, !bInherit);
245 RegCloseKey(hsubkey);
247 RegCloseKey(hkey);
249 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, profile_keyW, 0, KEY_READ, &hkey) == ERROR_SUCCESS)
251 if (get_reg_value(env, hkey, L"ProfilesDirectory", profiles_dir, MAX_PATH - sizeof(WCHAR)))
253 len = lstrlenW(profiles_dir);
254 if (profiles_dir[len-1] != '\\')
256 profiles_dir[len++] = '\\';
257 profiles_dir[len] = '\0';
260 if (get_reg_value(env, hkey, L"Public", buf, UNICODE_STRING_MAX_CHARS))
261 set_env_var(&env, L"ALLUSERSPROFILE", buf);
263 else
265 profiles_dir[0] = 0;
268 RegCloseKey(hkey);
271 len = ARRAY_SIZE(buf);
272 if (GetComputerNameW(buf, &len))
273 set_env_var(&env, L"COMPUTERNAME", buf);
275 set_wow64_environment(&env);
277 if (!hToken)
279 if (profiles_dir[0])
281 len = lstrlenW(profiles_dir);
282 if (len * sizeof(WCHAR) + sizeof(L"Default") < sizeof(buf))
284 wcscpy(buf, profiles_dir);
285 wcscat(buf, L"Default");
286 set_env_var(&env, L"USERPROFILE", buf);
290 wcscpy(buf, L".Default");
292 else
294 TOKEN_USER *token_user = NULL;
295 SID_NAME_USE use;
296 WCHAR *sidW;
297 DWORD size, tmp=0;
299 if (GetTokenInformation(hToken, TokenUser, NULL, 0, &len) ||
300 GetLastError()!=ERROR_INSUFFICIENT_BUFFER ||
301 !(token_user = HeapAlloc(GetProcessHeap(), 0, len)) ||
302 !GetTokenInformation(hToken, TokenUser, token_user, len, &len) ||
303 !ConvertSidToStringSidW(token_user->User.Sid, &sidW))
305 HeapFree(GetProcessHeap(), 0, token_user);
306 RtlDestroyEnvironment(env);
307 return FALSE;
310 len = lstrlenW(profiles_dir);
311 memcpy(buf, profiles_dir, len*sizeof(WCHAR));
313 size = UNICODE_STRING_MAX_CHARS-len;
314 if (LookupAccountSidW(NULL, token_user->User.Sid,
315 buf+len, &size, NULL, &tmp, &use))
317 set_env_var(&env, L"USERNAME", buf+len);
318 if (len) set_env_var(&env, L"USERPROFILE", buf);
321 HeapFree(GetProcessHeap(), 0, token_user);
322 lstrcpyW(buf, sidW);
323 LocalFree(sidW);
326 if (RegOpenKeyExW(HKEY_USERS, buf, 0, KEY_READ, &hkey) == ERROR_SUCCESS)
328 if (RegOpenKeyExW(hkey, L"Environment", 0, KEY_READ, &hsubkey) == ERROR_SUCCESS)
330 set_registry_variables(&env, hsubkey, REG_SZ, !bInherit);
331 set_registry_variables(&env, hsubkey, REG_EXPAND_SZ, !bInherit);
332 RegCloseKey(hsubkey);
335 if (RegOpenKeyExW(hkey, L"Volatile Environment", 0, KEY_READ, &hsubkey) == ERROR_SUCCESS)
337 set_registry_variables(&env, hsubkey, REG_SZ, !bInherit);
338 set_registry_variables(&env, hsubkey, REG_EXPAND_SZ, !bInherit);
339 RegCloseKey(hsubkey);
341 RegCloseKey(hkey);
344 *lpEnvironment = env;
345 return TRUE;
348 BOOL WINAPI DestroyEnvironmentBlock(LPVOID lpEnvironment)
350 NTSTATUS r;
352 TRACE("%p\n", lpEnvironment);
353 r = RtlDestroyEnvironment(lpEnvironment);
354 if (r == STATUS_SUCCESS)
355 return TRUE;
356 return FALSE;
359 BOOL WINAPI ExpandEnvironmentStringsForUserA( HANDLE hToken, LPCSTR lpSrc,
360 LPSTR lpDest, DWORD dwSize )
362 BOOL ret;
364 TRACE("%p %s %p %d\n", hToken, debugstr_a(lpSrc), lpDest, dwSize);
366 ret = ExpandEnvironmentStringsA( lpSrc, lpDest, dwSize );
367 TRACE("<- %s\n", debugstr_a(lpDest));
368 return ret;
371 BOOL WINAPI ExpandEnvironmentStringsForUserW( HANDLE hToken, LPCWSTR lpSrc,
372 LPWSTR lpDest, DWORD dwSize )
374 BOOL ret;
376 TRACE("%p %s %p %d\n", hToken, debugstr_w(lpSrc), lpDest, dwSize);
378 ret = ExpandEnvironmentStringsW( lpSrc, lpDest, dwSize );
379 TRACE("<- %s\n", debugstr_w(lpDest));
380 return ret;
383 BOOL WINAPI GetDefaultUserProfileDirectoryA( LPSTR lpProfileDir, LPDWORD lpcchSize )
385 FIXME("%p %p\n", lpProfileDir, lpcchSize );
386 return FALSE;
389 BOOL WINAPI GetDefaultUserProfileDirectoryW( LPWSTR lpProfileDir, LPDWORD lpcchSize )
391 FIXME("%p %p\n", lpProfileDir, lpcchSize );
392 return FALSE;
395 BOOL WINAPI GetUserProfileDirectoryA( HANDLE hToken, LPSTR lpProfileDir,
396 LPDWORD lpcchSize )
398 BOOL ret;
399 WCHAR *dirW = NULL;
401 TRACE( "%p %p %p\n", hToken, lpProfileDir, lpcchSize );
403 if (!lpProfileDir || !lpcchSize)
405 SetLastError( ERROR_INVALID_PARAMETER );
406 return FALSE;
408 if (!(dirW = HeapAlloc( GetProcessHeap(), 0, *lpcchSize * sizeof(WCHAR) )))
409 return FALSE;
411 if ((ret = GetUserProfileDirectoryW( hToken, dirW, lpcchSize )))
412 WideCharToMultiByte( CP_ACP, 0, dirW, *lpcchSize, lpProfileDir, *lpcchSize, NULL, NULL );
414 HeapFree( GetProcessHeap(), 0, dirW );
415 return ret;
418 BOOL WINAPI GetUserProfileDirectoryW( HANDLE hToken, LPWSTR lpProfileDir,
419 LPDWORD lpcchSize )
421 static const WCHAR slashW[] = {'\\',0};
422 TOKEN_USER *t;
423 WCHAR *userW = NULL, *dirW = NULL;
424 DWORD len, dir_len, domain_len;
425 SID_NAME_USE use;
426 BOOL ret = FALSE;
428 TRACE( "%p %p %p\n", hToken, lpProfileDir, lpcchSize );
430 if (!lpcchSize)
432 SetLastError( ERROR_INVALID_PARAMETER );
433 return FALSE;
436 len = 0;
437 GetTokenInformation( hToken, TokenUser, NULL, 0, &len );
438 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return FALSE;
439 if (!(t = HeapAlloc( GetProcessHeap(), 0, len ))) return FALSE;
440 if (!GetTokenInformation( hToken, TokenUser, t, len, &len )) goto done;
442 len = domain_len = 0;
443 LookupAccountSidW( NULL, t->User.Sid, NULL, &len, NULL, &domain_len, NULL );
444 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) goto done;
445 if (!(userW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) goto done;
446 if (!LookupAccountSidW( NULL, t->User.Sid, userW, &len, NULL, &domain_len, &use )) goto done;
448 dir_len = 0;
449 GetProfilesDirectoryW( NULL, &dir_len );
450 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) goto done;
451 if (!(dirW = HeapAlloc( GetProcessHeap(), 0, (dir_len + 1) * sizeof(WCHAR) ))) goto done;
452 if (!GetProfilesDirectoryW( dirW, &dir_len )) goto done;
454 len += dir_len + 2;
455 if (*lpcchSize < len)
457 SetLastError( ERROR_INSUFFICIENT_BUFFER );
458 *lpcchSize = len;
459 goto done;
461 lstrcpyW( lpProfileDir, dirW );
462 lstrcatW( lpProfileDir, slashW );
463 lstrcatW( lpProfileDir, userW );
464 *lpcchSize = len;
465 ret = TRUE;
467 done:
468 HeapFree( GetProcessHeap(), 0, t );
469 HeapFree( GetProcessHeap(), 0, userW );
470 HeapFree( GetProcessHeap(), 0, dirW );
471 return ret;
474 static const char ProfileListA[] = "Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList";
476 BOOL WINAPI GetProfilesDirectoryA( LPSTR lpProfilesDir, LPDWORD lpcchSize )
478 static const char ProfilesDirectory[] = "ProfilesDirectory";
479 LONG l;
480 HKEY key;
481 BOOL ret = FALSE;
482 DWORD len = 0, expanded_len;
483 LPSTR unexpanded_profiles_dir = NULL;
485 TRACE("%p %p\n", lpProfilesDir, lpcchSize );
487 if (!lpProfilesDir || !lpcchSize)
489 SetLastError(ERROR_INVALID_PARAMETER);
490 return FALSE;
493 l = RegOpenKeyExA(HKEY_LOCAL_MACHINE, ProfileListA, 0, KEY_READ, &key);
494 if (l)
496 SetLastError(l);
497 return FALSE;
499 l = RegQueryValueExA(key, ProfilesDirectory, NULL, NULL, NULL, &len);
500 if (l)
502 SetLastError(l);
503 goto end;
505 unexpanded_profiles_dir = HeapAlloc(GetProcessHeap(), 0, len);
506 if (!unexpanded_profiles_dir)
508 SetLastError(ERROR_OUTOFMEMORY);
509 goto end;
511 l = RegQueryValueExA(key, ProfilesDirectory, NULL, NULL,
512 (BYTE *)unexpanded_profiles_dir, &len);
513 if (l)
515 SetLastError(l);
516 goto end;
518 expanded_len = ExpandEnvironmentStringsA(unexpanded_profiles_dir, NULL, 0);
519 /* The returned length doesn't include the NULL terminator. */
520 if (*lpcchSize < expanded_len - 1)
522 *lpcchSize = expanded_len - 1;
523 SetLastError(ERROR_INSUFFICIENT_BUFFER);
524 goto end;
526 *lpcchSize = expanded_len - 1;
527 /* The return value is also the expected length. */
528 ret = ExpandEnvironmentStringsA(unexpanded_profiles_dir, lpProfilesDir,
529 expanded_len) - 1;
530 end:
531 HeapFree(GetProcessHeap(), 0, unexpanded_profiles_dir);
532 RegCloseKey(key);
533 return ret;
536 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};
538 BOOL WINAPI GetProfilesDirectoryW( LPWSTR lpProfilesDir, LPDWORD lpcchSize )
540 static const WCHAR ProfilesDirectory[] = {'P','r','o','f','i','l','e','s','D','i','r','e','c','t','o','r','y',0};
541 LONG l;
542 HKEY key;
543 BOOL ret = FALSE;
544 DWORD len = 0, expanded_len;
545 LPWSTR unexpanded_profiles_dir = NULL;
547 TRACE("%p %p\n", lpProfilesDir, lpcchSize );
549 if (!lpcchSize)
551 SetLastError(ERROR_INVALID_PARAMETER);
552 return FALSE;
555 l = RegOpenKeyExW(HKEY_LOCAL_MACHINE, ProfileListW, 0, KEY_READ, &key);
556 if (l)
558 SetLastError(l);
559 return FALSE;
561 l = RegQueryValueExW(key, ProfilesDirectory, NULL, NULL, NULL, &len);
562 if (l)
564 SetLastError(l);
565 goto end;
567 unexpanded_profiles_dir = HeapAlloc(GetProcessHeap(), 0, len);
568 if (!unexpanded_profiles_dir)
570 SetLastError(ERROR_OUTOFMEMORY);
571 goto end;
573 l = RegQueryValueExW(key, ProfilesDirectory, NULL, NULL,
574 (BYTE *)unexpanded_profiles_dir, &len);
575 if (l)
577 SetLastError(l);
578 goto end;
580 expanded_len = ExpandEnvironmentStringsW(unexpanded_profiles_dir, NULL, 0);
581 /* The returned length doesn't include the NULL terminator. */
582 if (*lpcchSize < expanded_len - 1 || !lpProfilesDir)
584 *lpcchSize = expanded_len - 1;
585 SetLastError(ERROR_INSUFFICIENT_BUFFER);
586 goto end;
588 *lpcchSize = expanded_len - 1;
589 /* The return value is also the expected length. */
590 ret = ExpandEnvironmentStringsW(unexpanded_profiles_dir, lpProfilesDir,
591 expanded_len) - 1;
592 end:
593 HeapFree(GetProcessHeap(), 0, unexpanded_profiles_dir);
594 RegCloseKey(key);
595 return ret;
598 BOOL WINAPI GetAllUsersProfileDirectoryA( LPSTR lpProfileDir, LPDWORD lpcchSize )
600 FIXME("%p %p\n", lpProfileDir, lpcchSize);
601 return FALSE;
604 BOOL WINAPI GetAllUsersProfileDirectoryW( LPWSTR lpProfileDir, LPDWORD lpcchSize )
606 FIXME("%p %p\n", lpProfileDir, lpcchSize);
607 return FALSE;
610 BOOL WINAPI GetProfileType( DWORD *pdwFlags )
612 FIXME("%p\n", pdwFlags );
613 *pdwFlags = 0;
614 return TRUE;
617 BOOL WINAPI LoadUserProfileA( HANDLE hToken, LPPROFILEINFOA lpProfileInfo )
619 FIXME("%p %p\n", hToken, lpProfileInfo );
620 lpProfileInfo->hProfile = HKEY_CURRENT_USER;
621 return TRUE;
624 BOOL WINAPI LoadUserProfileW( HANDLE hToken, LPPROFILEINFOW lpProfileInfo )
626 FIXME("%p %p\n", hToken, lpProfileInfo );
627 lpProfileInfo->hProfile = HKEY_CURRENT_USER;
628 return TRUE;
631 BOOL WINAPI RegisterGPNotification( HANDLE event, BOOL machine )
633 FIXME("%p %d\n", event, machine );
634 return TRUE;
637 BOOL WINAPI UnregisterGPNotification( HANDLE event )
639 FIXME("%p\n", event );
640 return TRUE;
643 BOOL WINAPI UnloadUserProfile( HANDLE hToken, HANDLE hProfile )
645 FIXME("(%p, %p): stub\n", hToken, hProfile);
646 return FALSE;
649 HANDLE WINAPI EnterCriticalPolicySection(BOOL bMachine)
651 FIXME("(%x)\n", bMachine);
652 SetLastError(ERROR_ACCESS_DENIED);
653 return NULL;
656 BOOL WINAPI LeaveCriticalPolicySection(HANDLE hSection)
658 FIXME("(%p)\n", hSection);
659 return TRUE;
662 DWORD WINAPI GetAppliedGPOListW(DWORD dwFlags, LPCWSTR pMachineName, PSID pSidUser, GUID *pGuidExtension,
663 PGROUP_POLICY_OBJECTW *ppGPOList)
665 FIXME("(%x %s %p %s %p)\n", dwFlags, debugstr_w(pMachineName), pSidUser, debugstr_guid(pGuidExtension), ppGPOList);
666 return ERROR_ACCESS_DENIED;
669 /******************************************************************************
670 * USERENV.138
672 * Create .lnk file
674 * PARAMETERS
675 * int csidl [in] well-known directory location to create link in
676 * LPCSTR lnk_dir [in] directory (relative to directory specified by csidl) to create link in
677 * LPCSTR lnk_filename [in] filename of the link file without .lnk extension
678 * LPCSTR lnk_target [in] file/directory pointed to by link
679 * LPCSTR lnk_iconfile [in] link icon resource filename
680 * DWORD lnk_iconid [in] link icon resource id in file referred by lnk_iconfile
681 * LPCSTR work_directory [in] link target's work directory
682 * WORD hotkey [in] link hotkey (virtual key id)
683 * DWORD win_state [in] initial window size (SW_SHOWMAXIMIZED to start maximized,
684 * SW_SHOWMINNOACTIVE to start minimized, everything else is default state)
685 * LPCSTR comment [in] comment - link's comment
686 * LPCSTR loc_filename_resfile [in] resource file which holds localized filename for this link file
687 * DWORD loc_filename_resid [in] resource id for this link file's localized filename
689 * RETURNS
690 * TRUE: Link file was successfully created
691 * FALSE: Link file was not created
693 BOOL WINAPI USERENV_138( int csidl, LPCSTR lnk_dir, LPCSTR lnk_filename,
694 LPCSTR lnk_target, LPCSTR lnk_iconfile, DWORD lnk_iconid,
695 LPCSTR work_directory, WORD hotkey, DWORD win_state, LPCSTR comment,
696 LPCSTR loc_filename_resfile, DWORD loc_filename_resid)
698 FIXME("(%d,%s,%s,%s,%s,%d,%s,0x%x,%d,%s,%s,%d) - stub\n", csidl, debugstr_a(lnk_dir),
699 debugstr_a(lnk_filename), debugstr_a(lnk_target), debugstr_a(lnk_iconfile),
700 lnk_iconid, debugstr_a(work_directory), hotkey, win_state,
701 debugstr_a(comment), debugstr_a(loc_filename_resfile), loc_filename_resid );
703 return FALSE;