Author: ekohl Date: Thu Oct 24 20:16:20 2013 New Revision: 60744
URL: http://svn.reactos.org/svn/reactos?rev=60744&view=rev Log: [USERENV] Fix coding style and indentation. No code changes!
Modified: trunk/reactos/dll/win32/userenv/desktop.c trunk/reactos/dll/win32/userenv/directory.c trunk/reactos/dll/win32/userenv/environment.c trunk/reactos/dll/win32/userenv/gpolicy.c trunk/reactos/dll/win32/userenv/internal.h trunk/reactos/dll/win32/userenv/misc.c trunk/reactos/dll/win32/userenv/profile.c trunk/reactos/dll/win32/userenv/registry.c trunk/reactos/dll/win32/userenv/resources.h trunk/reactos/dll/win32/userenv/setup.c trunk/reactos/dll/win32/userenv/userenv.c
Modified: trunk/reactos/dll/win32/userenv/desktop.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/userenv/desktop.c... ============================================================================== --- trunk/reactos/dll/win32/userenv/desktop.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/userenv/desktop.c [iso-8859-1] Thu Oct 24 20:16:20 2013 @@ -19,7 +19,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries - * FILE: lib/userenv/desktop.c + * FILE: dll/win32/userenv/desktop.c * PURPOSE: Desktop and start menu support functions. * PROGRAMMER: Eric Kohl */ @@ -32,867 +32,881 @@
/* FUNCTIONS ***************************************************************/
-static BOOL -GetDesktopPath (BOOL bCommonPath, - LPWSTR lpDesktopPath) -{ - WCHAR szPath[MAX_PATH]; - DWORD dwLength; - DWORD dwType; - HKEY hKey; - LONG Error; - - DPRINT ("GetDesktopPath() called\n"); - - Error = RegOpenKeyExW (HKEY_CURRENT_USER, - L"Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", - 0, - KEY_QUERY_VALUE, - &hKey); - if (Error != ERROR_SUCCESS) - { - DPRINT1 ("RegOpenKeyExW() failed\n"); - SetLastError((DWORD)Error); - return FALSE; - } - - dwLength = MAX_PATH * sizeof(WCHAR); - Error = RegQueryValueExW (hKey, - bCommonPath ? L"Common Desktop" : L"Desktop", - 0, - &dwType, - (LPBYTE)szPath, - &dwLength); - if (Error != ERROR_SUCCESS) - { - DPRINT1 ("RegQueryValueExW() failed\n"); - RegCloseKey (hKey); - SetLastError((DWORD)Error); - return FALSE; - } - - RegCloseKey (hKey); - - if (dwType == REG_EXPAND_SZ) - { - ExpandEnvironmentStringsW (szPath, - lpDesktopPath, - MAX_PATH); - } - else - { - wcscpy (lpDesktopPath, szPath); - } - - DPRINT ("GetDesktopPath() done\n"); - - return TRUE; -} - - -static BOOL -GetProgramsPath (BOOL bCommonPath, - LPWSTR lpProgramsPath) -{ - WCHAR szPath[MAX_PATH]; - DWORD dwLength; - DWORD dwType; - HKEY hKey; - LONG Error; - - DPRINT ("GetProgramsPath() called\n"); - - Error = RegOpenKeyExW (HKEY_CURRENT_USER, - L"Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", - 0, - KEY_QUERY_VALUE, - &hKey); - if (Error != ERROR_SUCCESS) - { - DPRINT1 ("RegOpenKeyExW() failed\n"); - SetLastError((DWORD)Error); - return FALSE; - } - - dwLength = MAX_PATH * sizeof(WCHAR); - Error = RegQueryValueExW (hKey, - bCommonPath ? L"Common Programs" : L"Programs", - 0, - &dwType, - (LPBYTE)szPath, - &dwLength); - if (Error != ERROR_SUCCESS) - { - DPRINT1 ("RegQueryValueExW() failed\n"); - RegCloseKey (hKey); - SetLastError((DWORD)Error); - return FALSE; - } - - RegCloseKey (hKey); - - if (dwType == REG_EXPAND_SZ) - { - ExpandEnvironmentStringsW (szPath, - lpProgramsPath, - MAX_PATH); - } - else - { - wcscpy (lpProgramsPath, - szPath); - } - - DPRINT ("GetProgramsPath() done\n"); - - return TRUE; -} - - -BOOL WINAPI -AddDesktopItemA (BOOL bCommonItem, - LPCSTR lpItemName, - LPCSTR lpArguments, - LPCSTR lpIconLocation, - INT iIcon, - LPCSTR lpWorkingDirectory, /* Optional */ - WORD wHotKey, - INT iShowCmd) -{ - UNICODE_STRING ItemName; - UNICODE_STRING Arguments; - UNICODE_STRING IconLocation; - UNICODE_STRING WorkingDirectory; - BOOL bResult; - - if (!RtlCreateUnicodeStringFromAsciiz(&ItemName, - (LPSTR)lpItemName)) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - if (!RtlCreateUnicodeStringFromAsciiz(&Arguments, - (LPSTR)lpArguments)) - { - RtlFreeUnicodeString(&ItemName); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - if (!RtlCreateUnicodeStringFromAsciiz(&IconLocation, - (LPSTR)lpIconLocation)) - { - RtlFreeUnicodeString(&Arguments); - RtlFreeUnicodeString(&ItemName); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - if (lpWorkingDirectory != NULL) - { - if (!RtlCreateUnicodeStringFromAsciiz(&WorkingDirectory, - (LPSTR)lpWorkingDirectory)) - { - RtlFreeUnicodeString(&IconLocation); - RtlFreeUnicodeString(&Arguments); - RtlFreeUnicodeString(&ItemName); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - } - - bResult = AddDesktopItemW(bCommonItem, - ItemName.Buffer, - Arguments.Buffer, - IconLocation.Buffer, - iIcon, - (lpWorkingDirectory != NULL) ? WorkingDirectory.Buffer : NULL, - wHotKey, - iShowCmd); - - if (lpWorkingDirectory != NULL) - { - RtlFreeUnicodeString(&WorkingDirectory); - } - - RtlFreeUnicodeString(&IconLocation); - RtlFreeUnicodeString(&Arguments); - RtlFreeUnicodeString(&ItemName); - - return bResult; -} - - -BOOL WINAPI -AddDesktopItemW (BOOL bCommonDesktop, - LPCWSTR lpItemName, - LPCWSTR lpArguments, - LPCWSTR lpIconLocation, - INT iIcon, - LPCWSTR lpWorkingDirectory, /* Optional */ - WORD wHotKey, - INT iShowCmd) -{ - DYN_FUNCS Ole32; - WCHAR szLinkPath[MAX_PATH]; - WCHAR szArguments[MAX_PATH]; - WCHAR szCommand[MAX_PATH]; - WIN32_FIND_DATAW FindData; - HANDLE hFind; - LPWSTR Ptr; - DWORD dwLength; - IShellLinkW* psl; - IPersistFile* ppf; - HRESULT hr; - BOOL bResult; - - DPRINT ("AddDesktopItemW() called\n"); - - bResult = FALSE; - - if (!GetDesktopPath (bCommonDesktop, szLinkPath)) - { - DPRINT1 ("GetDesktopPath() failed\n"); - return FALSE; - } - DPRINT ("Desktop path: '%S'\n", szLinkPath); - - /* Make sure the path exists */ - hFind = FindFirstFileW (szLinkPath, - &FindData); - if (hFind == INVALID_HANDLE_VALUE) - { - DPRINT ("'%S' does not exist\n", szLinkPath); - - /* Create directory path */ - if (!CreateDirectoryPath (szLinkPath, NULL)) - return FALSE; - } - else - { - DPRINT ("'%S' exists\n", szLinkPath); - FindClose (hFind); - } - - /* Append backslash, item name and ".lnk" extension */ - wcscat (szLinkPath, L"\"); - wcscat (szLinkPath, lpItemName); - wcscat (szLinkPath, L".lnk"); - DPRINT ("Link path: '%S'\n", szLinkPath); - - /* Split 'lpArguments' string into command and arguments */ - Ptr = wcschr (lpArguments, L' '); - DPRINT ("Ptr %p lpArguments %p\n", Ptr, lpArguments); - if (Ptr != NULL) - { - dwLength = (DWORD)(Ptr - lpArguments); - DPRINT ("dwLength %lu\n", dwLength); - memcpy (szCommand, lpArguments, dwLength * sizeof(WCHAR)); - szCommand[dwLength] = 0; - Ptr++; - wcscpy (szArguments, Ptr); - } - else - { - wcscpy (szCommand, lpArguments); - szArguments[0] = 0; - } - DPRINT ("szCommand: '%S'\n", szCommand); - DPRINT ("szArguments: '%S'\n", szArguments); - - /* Dynamically load ole32.dll */ - if (!LoadDynamicImports(&DynOle32, &Ole32)) - { - DPRINT1("USERENV: Unable to load OLE32.DLL\n"); - return FALSE; - } - - Ole32.fn.CoInitialize(NULL); - - hr = Ole32.fn.CoCreateInstance(&CLSID_ShellLink, - NULL, - CLSCTX_INPROC_SERVER, - &IID_IShellLinkW, - (LPVOID*)&psl); - if (!SUCCEEDED(hr)) - { - Ole32.fn.CoUninitialize(); - UnloadDynamicImports(&Ole32); - return FALSE; - } - - hr = psl->lpVtbl->QueryInterface(psl, - &IID_IPersistFile, - (LPVOID*)&ppf); - if (SUCCEEDED(hr)) - { - psl->lpVtbl->SetDescription(psl, - lpItemName); - - psl->lpVtbl->SetPath(psl, - szCommand); - - psl->lpVtbl->SetArguments(psl, - szArguments); - - psl->lpVtbl->SetIconLocation(psl, - lpIconLocation, - iIcon); - - if (lpWorkingDirectory != NULL) - { - psl->lpVtbl->SetWorkingDirectory(psl, - lpWorkingDirectory); - } - else - { - psl->lpVtbl->SetWorkingDirectory(psl, - L"%HOMEDRIVE%%HOMEPATH%"); - } - - psl->lpVtbl->SetHotkey(psl, - wHotKey); - - psl->lpVtbl->SetShowCmd(psl, +static +BOOL +GetDesktopPath(BOOL bCommonPath, + LPWSTR lpDesktopPath) +{ + WCHAR szPath[MAX_PATH]; + DWORD dwLength; + DWORD dwType; + HKEY hKey; + LONG Error; + + DPRINT("GetDesktopPath() called\n"); + + Error = RegOpenKeyExW(HKEY_CURRENT_USER, + L"Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", + 0, + KEY_QUERY_VALUE, + &hKey); + if (Error != ERROR_SUCCESS) + { + DPRINT1("RegOpenKeyExW() failed\n"); + SetLastError((DWORD)Error); + return FALSE; + } + + dwLength = MAX_PATH * sizeof(WCHAR); + Error = RegQueryValueExW(hKey, + bCommonPath ? L"Common Desktop" : L"Desktop", + 0, + &dwType, + (LPBYTE)szPath, + &dwLength); + if (Error != ERROR_SUCCESS) + { + DPRINT1("RegQueryValueExW() failed\n"); + RegCloseKey(hKey); + SetLastError((DWORD)Error); + return FALSE; + } + + RegCloseKey(hKey); + + if (dwType == REG_EXPAND_SZ) + { + ExpandEnvironmentStringsW(szPath, + lpDesktopPath, + MAX_PATH); + } + else + { + wcscpy(lpDesktopPath, szPath); + } + + DPRINT("GetDesktopPath() done\n"); + + return TRUE; +} + + +static +BOOL +GetProgramsPath(BOOL bCommonPath, + LPWSTR lpProgramsPath) +{ + WCHAR szPath[MAX_PATH]; + DWORD dwLength; + DWORD dwType; + HKEY hKey; + LONG Error; + + DPRINT("GetProgramsPath() called\n"); + + Error = RegOpenKeyExW(HKEY_CURRENT_USER, + L"Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", + 0, + KEY_QUERY_VALUE, + &hKey); + if (Error != ERROR_SUCCESS) + { + DPRINT1("RegOpenKeyExW() failed\n"); + SetLastError((DWORD)Error); + return FALSE; + } + + dwLength = MAX_PATH * sizeof(WCHAR); + Error = RegQueryValueExW(hKey, + bCommonPath ? L"Common Programs" : L"Programs", + 0, + &dwType, + (LPBYTE)szPath, + &dwLength); + if (Error != ERROR_SUCCESS) + { + DPRINT1("RegQueryValueExW() failed\n"); + RegCloseKey(hKey); + SetLastError((DWORD)Error); + return FALSE; + } + + RegCloseKey(hKey); + + if (dwType == REG_EXPAND_SZ) + { + ExpandEnvironmentStringsW(szPath, + lpProgramsPath, + MAX_PATH); + } + else + { + wcscpy(lpProgramsPath, + szPath); + } + + DPRINT("GetProgramsPath() done\n"); + + return TRUE; +} + + +BOOL +WINAPI +AddDesktopItemA(BOOL bCommonItem, + LPCSTR lpItemName, + LPCSTR lpArguments, + LPCSTR lpIconLocation, + INT iIcon, + LPCSTR lpWorkingDirectory, /* Optional */ + WORD wHotKey, + INT iShowCmd) +{ + UNICODE_STRING ItemName; + UNICODE_STRING Arguments; + UNICODE_STRING IconLocation; + UNICODE_STRING WorkingDirectory; + BOOL bResult; + + if (!RtlCreateUnicodeStringFromAsciiz(&ItemName, + (LPSTR)lpItemName)) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + if (!RtlCreateUnicodeStringFromAsciiz(&Arguments, + (LPSTR)lpArguments)) + { + RtlFreeUnicodeString(&ItemName); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + if (!RtlCreateUnicodeStringFromAsciiz(&IconLocation, + (LPSTR)lpIconLocation)) + { + RtlFreeUnicodeString(&Arguments); + RtlFreeUnicodeString(&ItemName); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + if (lpWorkingDirectory != NULL) + { + if (!RtlCreateUnicodeStringFromAsciiz(&WorkingDirectory, + (LPSTR)lpWorkingDirectory)) + { + RtlFreeUnicodeString(&IconLocation); + RtlFreeUnicodeString(&Arguments); + RtlFreeUnicodeString(&ItemName); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + } + + bResult = AddDesktopItemW(bCommonItem, + ItemName.Buffer, + Arguments.Buffer, + IconLocation.Buffer, + iIcon, + (lpWorkingDirectory != NULL) ? WorkingDirectory.Buffer : NULL, + wHotKey, iShowCmd);
- hr = ppf->lpVtbl->Save(ppf, - szLinkPath, - TRUE); - if (SUCCEEDED(hr)) - bResult = TRUE; - - ppf->lpVtbl->Release(ppf); - } - - psl->lpVtbl->Release(psl); - - Ole32.fn.CoUninitialize(); - - UnloadDynamicImports(&Ole32); - - DPRINT ("AddDesktopItemW() done\n"); - - return bResult; -} - - -BOOL WINAPI -DeleteDesktopItemA (BOOL bCommonItem, - LPCSTR lpItemName) -{ - UNICODE_STRING ItemName; - BOOL bResult; - - if (!RtlCreateUnicodeStringFromAsciiz(&ItemName, - (LPSTR)lpItemName)) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - bResult = DeleteDesktopItemW(bCommonItem, - ItemName.Buffer); - - RtlFreeUnicodeString(&ItemName); - - return bResult; -} - - -BOOL WINAPI -DeleteDesktopItemW (BOOL bCommonItem, - LPCWSTR lpItemName) -{ - WCHAR szLinkPath[MAX_PATH]; - - DPRINT ("DeleteDesktopItemW() called\n"); - - if (!GetDesktopPath (bCommonItem, szLinkPath)) - { - DPRINT1 ("GetDesktopPath() failed\n"); - return FALSE; - } - - wcscat (szLinkPath, L"\"); - wcscat (szLinkPath, lpItemName); - wcscat (szLinkPath, L".lnk"); - DPRINT ("Link path: '%S'\n", szLinkPath); - - return DeleteFileW (szLinkPath); -} - - -BOOL WINAPI -CreateGroupA (LPCSTR lpGroupName, - BOOL bCommonGroup) -{ - UNICODE_STRING GroupName; - BOOL bResult; - - if (!RtlCreateUnicodeStringFromAsciiz(&GroupName, - (LPSTR)lpGroupName)) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - bResult = CreateGroupW(GroupName.Buffer, bCommonGroup); - - RtlFreeUnicodeString(&GroupName); - - return bResult; -} - - -BOOL WINAPI -CreateGroupW (LPCWSTR lpGroupName, - BOOL bCommonGroup) -{ - WCHAR szGroupPath[MAX_PATH]; - - DPRINT1 ("CreateGroupW() called\n"); - - if (lpGroupName == NULL || *lpGroupName == 0) + if (lpWorkingDirectory != NULL) + { + RtlFreeUnicodeString(&WorkingDirectory); + } + + RtlFreeUnicodeString(&IconLocation); + RtlFreeUnicodeString(&Arguments); + RtlFreeUnicodeString(&ItemName); + + return bResult; +} + + +BOOL +WINAPI +AddDesktopItemW(BOOL bCommonDesktop, + LPCWSTR lpItemName, + LPCWSTR lpArguments, + LPCWSTR lpIconLocation, + INT iIcon, + LPCWSTR lpWorkingDirectory, /* Optional */ + WORD wHotKey, + INT iShowCmd) +{ + DYN_FUNCS Ole32; + WCHAR szLinkPath[MAX_PATH]; + WCHAR szArguments[MAX_PATH]; + WCHAR szCommand[MAX_PATH]; + WIN32_FIND_DATAW FindData; + HANDLE hFind; + LPWSTR Ptr; + DWORD dwLength; + IShellLinkW* psl; + IPersistFile* ppf; + HRESULT hr; + BOOL bResult; + + DPRINT("AddDesktopItemW() called\n"); + + bResult = FALSE; + + if (!GetDesktopPath(bCommonDesktop, szLinkPath)) + { + DPRINT1("GetDesktopPath() failed\n"); + return FALSE; + } + DPRINT("Desktop path: '%S'\n", szLinkPath); + + /* Make sure the path exists */ + hFind = FindFirstFileW(szLinkPath, + &FindData); + if (hFind == INVALID_HANDLE_VALUE) + { + DPRINT("'%S' does not exist\n", szLinkPath); + + /* Create directory path */ + if (!CreateDirectoryPath(szLinkPath, NULL)) + return FALSE; + } + else + { + DPRINT("'%S' exists\n", szLinkPath); + FindClose(hFind); + } + + /* Append backslash, item name and ".lnk" extension */ + wcscat(szLinkPath, L"\"); + wcscat(szLinkPath, lpItemName); + wcscat(szLinkPath, L".lnk"); + DPRINT("Link path: '%S'\n", szLinkPath); + + /* Split 'lpArguments' string into command and arguments */ + Ptr = wcschr(lpArguments, L' '); + DPRINT("Ptr %p lpArguments %p\n", Ptr, lpArguments); + if (Ptr != NULL) + { + dwLength = (DWORD)(Ptr - lpArguments); + DPRINT("dwLength %lu\n", dwLength); + memcpy(szCommand, lpArguments, dwLength * sizeof(WCHAR)); + szCommand[dwLength] = 0; + Ptr++; + wcscpy(szArguments, Ptr); + } + else + { + wcscpy(szCommand, lpArguments); + szArguments[0] = 0; + } + DPRINT("szCommand: '%S'\n", szCommand); + DPRINT("szArguments: '%S'\n", szArguments); + + /* Dynamically load ole32.dll */ + if (!LoadDynamicImports(&DynOle32, &Ole32)) + { + DPRINT1("USERENV: Unable to load OLE32.DLL\n"); + return FALSE; + } + + Ole32.fn.CoInitialize(NULL); + + hr = Ole32.fn.CoCreateInstance(&CLSID_ShellLink, + NULL, + CLSCTX_INPROC_SERVER, + &IID_IShellLinkW, + (LPVOID*)&psl); + if (!SUCCEEDED(hr)) + { + Ole32.fn.CoUninitialize(); + UnloadDynamicImports(&Ole32); + return FALSE; + } + + hr = psl->lpVtbl->QueryInterface(psl, + &IID_IPersistFile, + (LPVOID*)&ppf); + if (SUCCEEDED(hr)) + { + psl->lpVtbl->SetDescription(psl, + lpItemName); + + psl->lpVtbl->SetPath(psl, + szCommand); + + psl->lpVtbl->SetArguments(psl, + szArguments); + + psl->lpVtbl->SetIconLocation(psl, + lpIconLocation, + iIcon); + + if (lpWorkingDirectory != NULL) + { + psl->lpVtbl->SetWorkingDirectory(psl, + lpWorkingDirectory); + } + else + { + psl->lpVtbl->SetWorkingDirectory(psl, + L"%HOMEDRIVE%%HOMEPATH%"); + } + + psl->lpVtbl->SetHotkey(psl, + wHotKey); + + psl->lpVtbl->SetShowCmd(psl, + iShowCmd); + + hr = ppf->lpVtbl->Save(ppf, + szLinkPath, + TRUE); + if (SUCCEEDED(hr)) + bResult = TRUE; + + ppf->lpVtbl->Release(ppf); + } + + psl->lpVtbl->Release(psl); + + Ole32.fn.CoUninitialize(); + + UnloadDynamicImports(&Ole32); + + DPRINT("AddDesktopItemW() done\n"); + + return bResult; +} + + +BOOL +WINAPI +DeleteDesktopItemA(BOOL bCommonItem, + LPCSTR lpItemName) +{ + UNICODE_STRING ItemName; + BOOL bResult; + + if (!RtlCreateUnicodeStringFromAsciiz(&ItemName, + (LPSTR)lpItemName)) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + bResult = DeleteDesktopItemW(bCommonItem, + ItemName.Buffer); + + RtlFreeUnicodeString(&ItemName); + + return bResult; +} + + +BOOL +WINAPI +DeleteDesktopItemW(BOOL bCommonItem, + LPCWSTR lpItemName) +{ + WCHAR szLinkPath[MAX_PATH]; + + DPRINT("DeleteDesktopItemW() called\n"); + + if (!GetDesktopPath(bCommonItem, szLinkPath)) + { + DPRINT1("GetDesktopPath() failed\n"); + return FALSE; + } + + wcscat(szLinkPath, L"\"); + wcscat(szLinkPath, lpItemName); + wcscat(szLinkPath, L".lnk"); + DPRINT("Link path: '%S'\n", szLinkPath); + + return DeleteFileW (szLinkPath); +} + + +BOOL +WINAPI +CreateGroupA(LPCSTR lpGroupName, + BOOL bCommonGroup) +{ + UNICODE_STRING GroupName; + BOOL bResult; + + if (!RtlCreateUnicodeStringFromAsciiz(&GroupName, + (LPSTR)lpGroupName)) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + bResult = CreateGroupW(GroupName.Buffer, bCommonGroup); + + RtlFreeUnicodeString(&GroupName); + + return bResult; +} + + +BOOL +WINAPI +CreateGroupW(LPCWSTR lpGroupName, + BOOL bCommonGroup) +{ + WCHAR szGroupPath[MAX_PATH]; + + DPRINT1("CreateGroupW() called\n"); + + if (lpGroupName == NULL || *lpGroupName == 0) + return TRUE; + + if (!GetProgramsPath(bCommonGroup, szGroupPath)) + { + DPRINT1("GetProgramsPath() failed\n"); + return FALSE; + } + DPRINT1("Programs path: '%S'\n", szGroupPath); + + wcscat(szGroupPath, L"\"); + wcscat(szGroupPath, lpGroupName); + DPRINT1("Group path: '%S'\n", szGroupPath); + + /* Create directory path */ + if (!CreateDirectoryPath (szGroupPath, NULL)) + return FALSE; + + /* FIXME: Notify the shell */ + + DPRINT1("CreateGroupW() done\n"); + return TRUE; - - if (!GetProgramsPath (bCommonGroup, szGroupPath)) - { - DPRINT1 ("GetProgramsPath() failed\n"); - return FALSE; - } - DPRINT1 ("Programs path: '%S'\n", szGroupPath); - - wcscat (szGroupPath, L"\"); - wcscat (szGroupPath, lpGroupName); - DPRINT1 ("Group path: '%S'\n", szGroupPath); - - /* Create directory path */ - if (!CreateDirectoryPath (szGroupPath, NULL)) - return FALSE; - - /* FIXME: Notify the shell */ - - DPRINT1 ("CreateGroupW() done\n"); - - return TRUE; -} - - -BOOL WINAPI -DeleteGroupA (LPCSTR lpGroupName, - BOOL bCommonGroup) -{ - UNICODE_STRING GroupName; - BOOL bResult; - - if (!RtlCreateUnicodeStringFromAsciiz(&GroupName, - (LPSTR)lpGroupName)) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - bResult = DeleteGroupW(GroupName.Buffer, bCommonGroup); - - RtlFreeUnicodeString(&GroupName); - - return bResult; -} - - -BOOL WINAPI -DeleteGroupW (LPCWSTR lpGroupName, - BOOL bCommonGroup) -{ - WCHAR szGroupPath[MAX_PATH]; - - DPRINT ("DeleteGroupW() called\n"); - - if (lpGroupName == NULL || *lpGroupName == 0) +} + + +BOOL +WINAPI +DeleteGroupA(LPCSTR lpGroupName, + BOOL bCommonGroup) +{ + UNICODE_STRING GroupName; + BOOL bResult; + + if (!RtlCreateUnicodeStringFromAsciiz(&GroupName, + (LPSTR)lpGroupName)) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + bResult = DeleteGroupW(GroupName.Buffer, bCommonGroup); + + RtlFreeUnicodeString(&GroupName); + + return bResult; +} + + +BOOL +WINAPI +DeleteGroupW(LPCWSTR lpGroupName, + BOOL bCommonGroup) +{ + WCHAR szGroupPath[MAX_PATH]; + + DPRINT("DeleteGroupW() called\n"); + + if (lpGroupName == NULL || *lpGroupName == 0) + return TRUE; + + if (!GetProgramsPath(bCommonGroup, szGroupPath)) + { + DPRINT1("GetProgramsPath() failed\n"); + return FALSE; + } + DPRINT("Programs path: '%S'\n", szGroupPath); + + wcscat(szGroupPath, L"\"); + wcscat(szGroupPath, lpGroupName); + DPRINT("Group path: '%S'\n", szGroupPath); + + /* Remove directory path */ + if (!RemoveDirectoryPath (szGroupPath)) + return FALSE; + + /* FIXME: Notify the shell */ + + DPRINT("DeleteGroupW() done\n"); + return TRUE; - - if (!GetProgramsPath (bCommonGroup, szGroupPath)) - { - DPRINT1 ("GetProgramsPath() failed\n"); - return FALSE; - } - DPRINT ("Programs path: '%S'\n", szGroupPath); - - wcscat (szGroupPath, L"\"); - wcscat (szGroupPath, lpGroupName); - DPRINT ("Group path: '%S'\n", szGroupPath); - - /* Remove directory path */ - if (!RemoveDirectoryPath (szGroupPath)) - return FALSE; - - /* FIXME: Notify the shell */ - - DPRINT ("DeleteGroupW() done\n"); - - return TRUE; -} - - -BOOL WINAPI -AddItemA (LPCSTR lpGroupName, /* Optional */ - BOOL bCommonGroup, - LPCSTR lpItemName, - LPCSTR lpArguments, - LPCSTR lpIconLocation, - INT iIcon, - LPCSTR lpWorkingDirectory, /* Optional */ - WORD wHotKey, - INT iShowCmd) -{ - UNICODE_STRING GroupName; - UNICODE_STRING ItemName; - UNICODE_STRING Arguments; - UNICODE_STRING IconLocation; - UNICODE_STRING WorkingDirectory; - BOOL bResult; - - if (!RtlCreateUnicodeStringFromAsciiz(&ItemName, - (LPSTR)lpItemName)) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - if (!RtlCreateUnicodeStringFromAsciiz(&Arguments, - (LPSTR)lpArguments)) - { - RtlFreeUnicodeString(&ItemName); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - if (!RtlCreateUnicodeStringFromAsciiz(&IconLocation, - (LPSTR)lpIconLocation)) - { - RtlFreeUnicodeString(&Arguments); - RtlFreeUnicodeString(&ItemName); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - if (lpGroupName != NULL) - { - if (!RtlCreateUnicodeStringFromAsciiz(&GroupName, - (LPSTR)lpGroupName)) - { - RtlFreeUnicodeString(&IconLocation); - RtlFreeUnicodeString(&Arguments); - RtlFreeUnicodeString(&ItemName); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - } - - if (lpWorkingDirectory != NULL) - { - if (!RtlCreateUnicodeStringFromAsciiz(&WorkingDirectory, - (LPSTR)lpWorkingDirectory)) - { - if (lpGroupName != NULL) - { - RtlFreeUnicodeString(&GroupName); - } - RtlFreeUnicodeString(&IconLocation); - RtlFreeUnicodeString(&Arguments); - RtlFreeUnicodeString(&ItemName); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - } - - bResult = AddItemW((lpGroupName != NULL) ? GroupName.Buffer : NULL, - bCommonGroup, - ItemName.Buffer, - Arguments.Buffer, - IconLocation.Buffer, - iIcon, - (lpWorkingDirectory != NULL) ? WorkingDirectory.Buffer : NULL, - wHotKey, - iShowCmd); - - if (lpGroupName != NULL) - { - RtlFreeUnicodeString(&GroupName); - } - - if (lpWorkingDirectory != NULL) - { - RtlFreeUnicodeString(&WorkingDirectory); - } - - RtlFreeUnicodeString(&IconLocation); - RtlFreeUnicodeString(&Arguments); - RtlFreeUnicodeString(&ItemName); - - return bResult; -} - - -BOOL WINAPI -AddItemW (LPCWSTR lpGroupName, /* Optional */ - BOOL bCommonGroup, - LPCWSTR lpItemName, - LPCWSTR lpArguments, - LPCWSTR lpIconLocation, - INT iIcon, - LPCWSTR lpWorkingDirectory, /* Optional */ - WORD wHotKey, - INT iShowCmd) -{ - DYN_FUNCS Ole32; - WCHAR szLinkPath[MAX_PATH]; - WCHAR szArguments[MAX_PATH]; - WCHAR szCommand[MAX_PATH]; - WIN32_FIND_DATAW FindData; - HANDLE hFind; - LPWSTR Ptr; - DWORD dwLength; - IShellLinkW* psl; - IPersistFile* ppf; - HRESULT hr; - BOOL bResult; - - DPRINT ("AddItemW() called\n"); - - bResult = FALSE; - - if (!GetProgramsPath (bCommonGroup, szLinkPath)) - { - DPRINT1 ("GetProgramsPath() failed\n"); - return FALSE; - } - - DPRINT ("Programs path: '%S'\n", szLinkPath); - - if (lpGroupName != NULL && *lpGroupName != 0) - { - wcscat (szLinkPath, L"\"); - wcscat (szLinkPath, lpGroupName); - - /* Make sure the path exists */ - hFind = FindFirstFileW (szLinkPath, - &FindData); - if (hFind == INVALID_HANDLE_VALUE) - { - DPRINT ("'%S' does not exist\n", szLinkPath); - if (!CreateGroupW (lpGroupName, - bCommonGroup)) - return FALSE; - } - else - { - DPRINT ("'%S' exists\n", szLinkPath); - FindClose (hFind); - } - } - - wcscat (szLinkPath, L"\"); - wcscat (szLinkPath, lpItemName); - wcscat (szLinkPath, L".lnk"); - DPRINT ("Link path: '%S'\n", szLinkPath); - - /* Split 'lpArguments' string into command and arguments */ - Ptr = wcschr (lpArguments, L' '); - DPRINT ("Ptr %p lpArguments %p\n", Ptr, lpArguments); - if (Ptr != NULL) - { - dwLength = (DWORD)(Ptr - lpArguments); - DPRINT ("dwLength %lu\n", dwLength); - memcpy (szCommand, lpArguments, dwLength * sizeof(WCHAR)); - szCommand[dwLength] = 0; - Ptr++; - wcscpy (szArguments, Ptr); - } - else - { - wcscpy (szCommand, lpArguments); - szArguments[0] = 0; - } - DPRINT ("szCommand: '%S'\n", szCommand); - DPRINT ("szArguments: '%S'\n", szArguments); - - /* Dynamically load ole32.dll */ - if (!LoadDynamicImports(&DynOle32, &Ole32)) - { - DPRINT1("USERENV: Unable to load OLE32.DLL\n"); - return FALSE; - } - - Ole32.fn.CoInitialize(NULL); - - hr = Ole32.fn.CoCreateInstance(&CLSID_ShellLink, - NULL, - CLSCTX_INPROC_SERVER, - &IID_IShellLinkW, - (LPVOID*)&psl); - if (!SUCCEEDED(hr)) - { - Ole32.fn.CoUninitialize(); - UnloadDynamicImports(&Ole32); - return FALSE; - } - - hr = psl->lpVtbl->QueryInterface(psl, - &IID_IPersistFile, - (LPVOID*)&ppf); - if (SUCCEEDED(hr)) - { - psl->lpVtbl->SetDescription(psl, - lpItemName); - - psl->lpVtbl->SetPath(psl, - szCommand); - - psl->lpVtbl->SetArguments(psl, - szArguments); - - psl->lpVtbl->SetIconLocation(psl, - lpIconLocation, - iIcon); - - if (lpWorkingDirectory != NULL) - { - psl->lpVtbl->SetWorkingDirectory(psl, - lpWorkingDirectory); - } - else - { - psl->lpVtbl->SetWorkingDirectory(psl, - L"%HOMEDRIVE%%HOMEPATH%"); - } - - psl->lpVtbl->SetHotkey(psl, - wHotKey); - - psl->lpVtbl->SetShowCmd(psl, - iShowCmd); - - hr = ppf->lpVtbl->Save(ppf, - szLinkPath, - TRUE); - if (SUCCEEDED(hr)) - bResult = TRUE; - - ppf->lpVtbl->Release(ppf); - } - - psl->lpVtbl->Release(psl); - - Ole32.fn.CoUninitialize(); - UnloadDynamicImports(&Ole32); - - DPRINT ("AddItemW() done\n"); - - return bResult; -} - - -BOOL WINAPI -DeleteItemA (LPCSTR lpGroupName, /* Optional */ - BOOL bCommonGroup, - LPCSTR lpItemName, - BOOL bDeleteGroup) -{ - UNICODE_STRING GroupName; - UNICODE_STRING ItemName; - BOOL bResult; - - if (lpGroupName != NULL) - { - if (!RtlCreateUnicodeStringFromAsciiz(&GroupName, - (LPSTR)lpGroupName)) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - } - - if (!RtlCreateUnicodeStringFromAsciiz(&ItemName, - (LPSTR)lpItemName)) - { - if (lpGroupName != NULL) - { - RtlFreeUnicodeString(&GroupName); - } - - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - bResult = DeleteItemW((lpGroupName != NULL) ? GroupName.Buffer : NULL, - bCommonGroup, - ItemName.Buffer, - bDeleteGroup); - - RtlFreeUnicodeString(&ItemName); - if (lpGroupName != NULL) - { - RtlFreeUnicodeString(&GroupName); - } - - return bResult; -} - - -BOOL WINAPI -DeleteItemW (LPCWSTR lpGroupName, /* Optional */ - BOOL bCommonGroup, - LPCWSTR lpItemName, - BOOL bDeleteGroup) -{ - WCHAR szItemPath[MAX_PATH]; - LPWSTR Ptr; - - DPRINT ("DeleteItemW() called\n"); - - if (!GetProgramsPath (bCommonGroup, szItemPath)) - { - DPRINT1 ("GetProgramsPath() failed\n"); - return FALSE; - } - DPRINT ("Programs path: '%S'\n", szItemPath); - - if (lpGroupName != NULL && *lpGroupName != 0) - { - wcscat (szItemPath, L"\"); - wcscat (szItemPath, lpGroupName); - } - - wcscat (szItemPath, L"\"); - wcscat (szItemPath, lpItemName); - wcscat (szItemPath, L".lnk"); - DPRINT ("Item path: '%S'\n", szItemPath); - - if (!DeleteFileW (szItemPath)) - return FALSE; - - /* FIXME: Notify the shell */ - - if (bDeleteGroup) - { - Ptr = wcsrchr (szItemPath, L'\'); - if (Ptr == NULL) - return TRUE; - - *Ptr = 0; - DPRINT ("Item path: '%S'\n", szItemPath); - if (RemoveDirectoryW (szItemPath)) - { - /* FIXME: Notify the shell */ - } - } - - DPRINT ("DeleteItemW() done\n"); - - return TRUE; +} + + +BOOL +WINAPI +AddItemA(LPCSTR lpGroupName, /* Optional */ + BOOL bCommonGroup, + LPCSTR lpItemName, + LPCSTR lpArguments, + LPCSTR lpIconLocation, + INT iIcon, + LPCSTR lpWorkingDirectory, /* Optional */ + WORD wHotKey, + INT iShowCmd) +{ + UNICODE_STRING GroupName; + UNICODE_STRING ItemName; + UNICODE_STRING Arguments; + UNICODE_STRING IconLocation; + UNICODE_STRING WorkingDirectory; + BOOL bResult; + + if (!RtlCreateUnicodeStringFromAsciiz(&ItemName, + (LPSTR)lpItemName)) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + if (!RtlCreateUnicodeStringFromAsciiz(&Arguments, + (LPSTR)lpArguments)) + { + RtlFreeUnicodeString(&ItemName); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + if (!RtlCreateUnicodeStringFromAsciiz(&IconLocation, + (LPSTR)lpIconLocation)) + { + RtlFreeUnicodeString(&Arguments); + RtlFreeUnicodeString(&ItemName); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + if (lpGroupName != NULL) + { + if (!RtlCreateUnicodeStringFromAsciiz(&GroupName, + (LPSTR)lpGroupName)) + { + RtlFreeUnicodeString(&IconLocation); + RtlFreeUnicodeString(&Arguments); + RtlFreeUnicodeString(&ItemName); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + } + + if (lpWorkingDirectory != NULL) + { + if (!RtlCreateUnicodeStringFromAsciiz(&WorkingDirectory, + (LPSTR)lpWorkingDirectory)) + { + if (lpGroupName != NULL) + { + RtlFreeUnicodeString(&GroupName); + } + RtlFreeUnicodeString(&IconLocation); + RtlFreeUnicodeString(&Arguments); + RtlFreeUnicodeString(&ItemName); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + } + + bResult = AddItemW((lpGroupName != NULL) ? GroupName.Buffer : NULL, + bCommonGroup, + ItemName.Buffer, + Arguments.Buffer, + IconLocation.Buffer, + iIcon, + (lpWorkingDirectory != NULL) ? WorkingDirectory.Buffer : NULL, + wHotKey, + iShowCmd); + + if (lpGroupName != NULL) + { + RtlFreeUnicodeString(&GroupName); + } + + if (lpWorkingDirectory != NULL) + { + RtlFreeUnicodeString(&WorkingDirectory); + } + + RtlFreeUnicodeString(&IconLocation); + RtlFreeUnicodeString(&Arguments); + RtlFreeUnicodeString(&ItemName); + + return bResult; +} + + +BOOL +WINAPI +AddItemW(LPCWSTR lpGroupName, /* Optional */ + BOOL bCommonGroup, + LPCWSTR lpItemName, + LPCWSTR lpArguments, + LPCWSTR lpIconLocation, + INT iIcon, + LPCWSTR lpWorkingDirectory, /* Optional */ + WORD wHotKey, + INT iShowCmd) +{ + DYN_FUNCS Ole32; + WCHAR szLinkPath[MAX_PATH]; + WCHAR szArguments[MAX_PATH]; + WCHAR szCommand[MAX_PATH]; + WIN32_FIND_DATAW FindData; + HANDLE hFind; + LPWSTR Ptr; + DWORD dwLength; + IShellLinkW* psl; + IPersistFile* ppf; + HRESULT hr; + BOOL bResult; + + DPRINT("AddItemW() called\n"); + + bResult = FALSE; + + if (!GetProgramsPath(bCommonGroup, szLinkPath)) + { + DPRINT1("GetProgramsPath() failed\n"); + return FALSE; + } + + DPRINT("Programs path: '%S'\n", szLinkPath); + + if (lpGroupName != NULL && *lpGroupName != 0) + { + wcscat(szLinkPath, L"\"); + wcscat(szLinkPath, lpGroupName); + + /* Make sure the path exists */ + hFind = FindFirstFileW(szLinkPath, + &FindData); + if (hFind == INVALID_HANDLE_VALUE) + { + DPRINT("'%S' does not exist\n", szLinkPath); + if (!CreateGroupW(lpGroupName, + bCommonGroup)) + return FALSE; + } + else + { + DPRINT("'%S' exists\n", szLinkPath); + FindClose(hFind); + } + } + + wcscat(szLinkPath, L"\"); + wcscat(szLinkPath, lpItemName); + wcscat(szLinkPath, L".lnk"); + DPRINT("Link path: '%S'\n", szLinkPath); + + /* Split 'lpArguments' string into command and arguments */ + Ptr = wcschr(lpArguments, L' '); + DPRINT("Ptr %p lpArguments %p\n", Ptr, lpArguments); + if (Ptr != NULL) + { + dwLength = (DWORD)(Ptr - lpArguments); + DPRINT("dwLength %lu\n", dwLength); + memcpy(szCommand, lpArguments, dwLength * sizeof(WCHAR)); + szCommand[dwLength] = 0; + Ptr++; + wcscpy(szArguments, Ptr); + } + else + { + wcscpy(szCommand, lpArguments); + szArguments[0] = 0; + } + DPRINT("szCommand: '%S'\n", szCommand); + DPRINT("szArguments: '%S'\n", szArguments); + + /* Dynamically load ole32.dll */ + if (!LoadDynamicImports(&DynOle32, &Ole32)) + { + DPRINT1("USERENV: Unable to load OLE32.DLL\n"); + return FALSE; + } + + Ole32.fn.CoInitialize(NULL); + + hr = Ole32.fn.CoCreateInstance(&CLSID_ShellLink, + NULL, + CLSCTX_INPROC_SERVER, + &IID_IShellLinkW, + (LPVOID*)&psl); + if (!SUCCEEDED(hr)) + { + Ole32.fn.CoUninitialize(); + UnloadDynamicImports(&Ole32); + return FALSE; + } + + hr = psl->lpVtbl->QueryInterface(psl, + &IID_IPersistFile, + (LPVOID*)&ppf); + if (SUCCEEDED(hr)) + { + psl->lpVtbl->SetDescription(psl, + lpItemName); + + psl->lpVtbl->SetPath(psl, + szCommand); + + psl->lpVtbl->SetArguments(psl, + szArguments); + + psl->lpVtbl->SetIconLocation(psl, + lpIconLocation, + iIcon); + + if (lpWorkingDirectory != NULL) + { + psl->lpVtbl->SetWorkingDirectory(psl, + lpWorkingDirectory); + } + else + { + psl->lpVtbl->SetWorkingDirectory(psl, + L"%HOMEDRIVE%%HOMEPATH%"); + } + + psl->lpVtbl->SetHotkey(psl, + wHotKey); + + psl->lpVtbl->SetShowCmd(psl, + iShowCmd); + + hr = ppf->lpVtbl->Save(ppf, + szLinkPath, + TRUE); + if (SUCCEEDED(hr)) + bResult = TRUE; + + ppf->lpVtbl->Release(ppf); + } + + psl->lpVtbl->Release(psl); + + Ole32.fn.CoUninitialize(); + UnloadDynamicImports(&Ole32); + + DPRINT("AddItemW() done\n"); + + return bResult; +} + + +BOOL +WINAPI +DeleteItemA(LPCSTR lpGroupName, /* Optional */ + BOOL bCommonGroup, + LPCSTR lpItemName, + BOOL bDeleteGroup) +{ + UNICODE_STRING GroupName; + UNICODE_STRING ItemName; + BOOL bResult; + + if (lpGroupName != NULL) + { + if (!RtlCreateUnicodeStringFromAsciiz(&GroupName, + (LPSTR)lpGroupName)) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + } + + if (!RtlCreateUnicodeStringFromAsciiz(&ItemName, + (LPSTR)lpItemName)) + { + if (lpGroupName != NULL) + { + RtlFreeUnicodeString(&GroupName); + } + + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + bResult = DeleteItemW((lpGroupName != NULL) ? GroupName.Buffer : NULL, + bCommonGroup, + ItemName.Buffer, + bDeleteGroup); + + RtlFreeUnicodeString(&ItemName); + if (lpGroupName != NULL) + { + RtlFreeUnicodeString(&GroupName); + } + + return bResult; +} + + +BOOL +WINAPI +DeleteItemW(LPCWSTR lpGroupName, /* Optional */ + BOOL bCommonGroup, + LPCWSTR lpItemName, + BOOL bDeleteGroup) +{ + WCHAR szItemPath[MAX_PATH]; + LPWSTR Ptr; + + DPRINT("DeleteItemW() called\n"); + + if (!GetProgramsPath(bCommonGroup, szItemPath)) + { + DPRINT1("GetProgramsPath() failed\n"); + return FALSE; + } + DPRINT("Programs path: '%S'\n", szItemPath); + + if (lpGroupName != NULL && *lpGroupName != 0) + { + wcscat(szItemPath, L"\"); + wcscat(szItemPath, lpGroupName); + } + + wcscat(szItemPath, L"\"); + wcscat(szItemPath, lpItemName); + wcscat(szItemPath, L".lnk"); + DPRINT("Item path: '%S'\n", szItemPath); + + if (!DeleteFileW(szItemPath)) + return FALSE; + + /* FIXME: Notify the shell */ + + if (bDeleteGroup) + { + Ptr = wcsrchr(szItemPath, L'\'); + if (Ptr == NULL) + return TRUE; + + *Ptr = 0; + DPRINT("Item path: '%S'\n", szItemPath); + if (RemoveDirectoryW(szItemPath)) + { + /* FIXME: Notify the shell */ + } + } + + DPRINT("DeleteItemW() done\n"); + + return TRUE; }
/* EOF */
Modified: trunk/reactos/dll/win32/userenv/directory.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/userenv/directory... ============================================================================== --- trunk/reactos/dll/win32/userenv/directory.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/userenv/directory.c [iso-8859-1] Thu Oct 24 20:16:20 2013 @@ -19,7 +19,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries - * FILE: lib/userenv/directory.c + * FILE: dll/win32/userenv/directory.c * PURPOSE: User profile code * PROGRAMMER: Eric Kohl */ @@ -32,7 +32,8 @@
/* FUNCTIONS ***************************************************************/
-BOOL WINAPI +BOOL +WINAPI CopyProfileDirectoryA(LPCSTR lpSourcePath, LPCSTR lpDestinationPath, DWORD dwFlags) @@ -67,7 +68,8 @@ }
-BOOL WINAPI +BOOL +WINAPI CopyProfileDirectoryW(LPCWSTR lpSourcePath, LPCWSTR lpDestinationPath, DWORD dwFlags) @@ -78,8 +80,8 @@
BOOL -CopyDirectory (LPCWSTR lpDestinationPath, - LPCWSTR lpSourcePath) +CopyDirectory(LPCWSTR lpDestinationPath, + LPCWSTR lpSourcePath) { WCHAR szFileName[MAX_PATH]; WCHAR szFullSrcName[MAX_PATH]; @@ -89,110 +91,110 @@ LPWSTR lpDstPtr; HANDLE hFind;
- DPRINT ("CopyDirectory (%S, %S) called\n", + DPRINT("CopyDirectory (%S, %S) called\n", lpDestinationPath, lpSourcePath);
- wcscpy (szFileName, lpSourcePath); - wcscat (szFileName, L"\*.*"); - - hFind = FindFirstFileW (szFileName, - &FindFileData); + wcscpy(szFileName, lpSourcePath); + wcscat(szFileName, L"\*.*"); + + hFind = FindFirstFileW(szFileName, + &FindFileData); if (hFind == INVALID_HANDLE_VALUE) { - DPRINT1 ("Error: %lu\n", GetLastError()); - return FALSE; - } - - wcscpy (szFullSrcName, lpSourcePath); - lpSrcPtr = AppendBackslash (szFullSrcName); - - wcscpy (szFullDstName, lpDestinationPath); - lpDstPtr = AppendBackslash (szFullDstName); + DPRINT1("Error: %lu\n", GetLastError()); + return FALSE; + } + + wcscpy(szFullSrcName, lpSourcePath); + lpSrcPtr = AppendBackslash(szFullSrcName); + + wcscpy(szFullDstName, lpDestinationPath); + lpDstPtr = AppendBackslash(szFullDstName);
for (;;) { - if (wcscmp (FindFileData.cFileName, L".") && - wcscmp (FindFileData.cFileName, L"..")) - { - wcscpy (lpSrcPtr, FindFileData.cFileName); - wcscpy (lpDstPtr, FindFileData.cFileName); + if (wcscmp(FindFileData.cFileName, L".") && + wcscmp(FindFileData.cFileName, L"..")) + { + wcscpy(lpSrcPtr, FindFileData.cFileName); + wcscpy(lpDstPtr, FindFileData.cFileName);
if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - DPRINT ("Create directory: %S\n", szFullDstName); - if (!CreateDirectoryExW (szFullSrcName, szFullDstName, NULL)) - { - if (GetLastError () != ERROR_ALREADY_EXISTS) + DPRINT("Create directory: %S\n", szFullDstName); + if (!CreateDirectoryExW(szFullSrcName, szFullDstName, NULL)) + { + if (GetLastError() != ERROR_ALREADY_EXISTS) { - DPRINT1 ("Error: %lu\n", GetLastError()); - - FindClose (hFind); + DPRINT1("Error: %lu\n", GetLastError()); + + FindClose(hFind); return FALSE; } }
- if (!CopyDirectory (szFullDstName, szFullSrcName)) - { - DPRINT1 ("Error: %lu\n", GetLastError()); - - FindClose (hFind); + if (!CopyDirectory(szFullDstName, szFullSrcName)) + { + DPRINT1("Error: %lu\n", GetLastError()); + + FindClose(hFind); return FALSE; } } else { - DPRINT ("Copy file: %S -> %S\n", szFullSrcName, szFullDstName); - if (!CopyFileW (szFullSrcName, szFullDstName, FALSE)) - { - DPRINT1 ("Error: %lu\n", GetLastError()); - - FindClose (hFind); + DPRINT("Copy file: %S -> %S\n", szFullSrcName, szFullDstName); + if (!CopyFileW(szFullSrcName, szFullDstName, FALSE)) + { + DPRINT1("Error: %lu\n", GetLastError()); + + FindClose(hFind); return FALSE; } } }
- if (!FindNextFileW (hFind, &FindFileData)) - { - if (GetLastError () != ERROR_NO_MORE_FILES) - { - DPRINT1 ("Error: %lu\n", GetLastError()); + if (!FindNextFileW(hFind, &FindFileData)) + { + if (GetLastError() != ERROR_NO_MORE_FILES) + { + DPRINT1("Error: %lu\n", GetLastError()); }
break; } }
- FindClose (hFind); - - DPRINT ("CopyDirectory() done\n"); + FindClose(hFind); + + DPRINT("CopyDirectory() done\n");
return TRUE; }
BOOL -CreateDirectoryPath (LPCWSTR lpPathName, - LPSECURITY_ATTRIBUTES lpSecurityAttributes) +CreateDirectoryPath(LPCWSTR lpPathName, + LPSECURITY_ATTRIBUTES lpSecurityAttributes) { WCHAR szPath[MAX_PATH]; LPWSTR Ptr; DWORD dwError;
- DPRINT ("CreateDirectoryPath() called\n"); + DPRINT("CreateDirectoryPath() called\n");
if (lpPathName == NULL || *lpPathName == 0) return TRUE;
- if (CreateDirectoryW (lpPathName, - lpSecurityAttributes)) + if (CreateDirectoryW(lpPathName, + lpSecurityAttributes)) return TRUE;
- dwError = GetLastError (); + dwError = GetLastError(); if (dwError == ERROR_ALREADY_EXISTS) return TRUE;
- wcscpy (szPath, lpPathName); + wcscpy(szPath, lpPathName);
if (wcslen(szPath) > 3 && szPath[1] == ':' && szPath[2] == '\') { @@ -205,15 +207,15 @@
while (Ptr != NULL) { - Ptr = wcschr (Ptr, L'\'); + Ptr = wcschr(Ptr, L'\'); if (Ptr != NULL) *Ptr = 0;
- DPRINT ("CreateDirectory(%S)\n", szPath); - if (!CreateDirectoryW (szPath, - lpSecurityAttributes)) - { - dwError = GetLastError (); + DPRINT("CreateDirectory(%S)\n", szPath); + if (!CreateDirectoryW(szPath, + lpSecurityAttributes)) + { + dwError = GetLastError(); if (dwError != ERROR_ALREADY_EXISTS) return FALSE; } @@ -225,45 +227,46 @@ } }
- DPRINT ("CreateDirectoryPath() done\n"); + DPRINT("CreateDirectoryPath() done\n");
return TRUE; }
-static BOOL -RecursiveRemoveDir (LPCWSTR lpPath) +static +BOOL +RecursiveRemoveDir(LPCWSTR lpPath) { WCHAR szPath[MAX_PATH]; WIN32_FIND_DATAW FindData; HANDLE hFind; BOOL bResult;
- wcscpy (szPath, lpPath); - wcscat (szPath, L"\*.*"); - DPRINT ("Search path: '%S'\n", szPath); - - hFind = FindFirstFileW (szPath, - &FindData); + wcscpy(szPath, lpPath); + wcscat(szPath, L"\*.*"); + DPRINT("Search path: '%S'\n", szPath); + + hFind = FindFirstFileW(szPath, + &FindData); if (hFind == INVALID_HANDLE_VALUE) return FALSE;
bResult = TRUE; while (TRUE) { - if (wcscmp (FindData.cFileName, L".") && - wcscmp (FindData.cFileName, L"..")) - { - wcscpy (szPath, lpPath); - wcscat (szPath, L"\"); - wcscat (szPath, FindData.cFileName); - DPRINT ("File name: '%S'\n", szPath); + if (wcscmp(FindData.cFileName, L".") && + wcscmp(FindData.cFileName, L"..")) + { + wcscpy(szPath, lpPath); + wcscat(szPath, L"\"); + wcscat(szPath, FindData.cFileName); + DPRINT("File name: '%S'\n", szPath);
if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - DPRINT ("Delete directory: '%S'\n", szPath); - - if (!RecursiveRemoveDir (szPath)) + DPRINT("Delete directory: '%S'\n", szPath); + + if (!RecursiveRemoveDir(szPath)) { bResult = FALSE; break; @@ -271,11 +274,11 @@
if (FindData.dwFileAttributes & FILE_ATTRIBUTE_READONLY) { - SetFileAttributesW (szPath, - FindData.dwFileAttributes & ~FILE_ATTRIBUTE_READONLY); - } - - if (!RemoveDirectoryW (szPath)) + SetFileAttributesW(szPath, + FindData.dwFileAttributes & ~FILE_ATTRIBUTE_READONLY); + } + + if (!RemoveDirectoryW(szPath)) { bResult = FALSE; break; @@ -283,15 +286,15 @@ } else { - DPRINT ("Delete file: '%S'\n", szPath); + DPRINT("Delete file: '%S'\n", szPath);
if (FindData.dwFileAttributes & (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)) { - SetFileAttributesW (szPath, - FILE_ATTRIBUTE_NORMAL); - } - - if (!DeleteFileW (szPath)) + SetFileAttributesW(szPath, + FILE_ATTRIBUTE_NORMAL); + } + + if (!DeleteFileW(szPath)) { bResult = FALSE; break; @@ -299,11 +302,11 @@ } }
- if (!FindNextFileW (hFind, &FindData)) - { - if (GetLastError () != ERROR_NO_MORE_FILES) - { - DPRINT1 ("Error: %lu\n", GetLastError()); + if (!FindNextFileW(hFind, &FindData)) + { + if (GetLastError() != ERROR_NO_MORE_FILES) + { + DPRINT1("Error: %lu\n", GetLastError()); bResult = FALSE; break; } @@ -312,20 +315,20 @@ } }
- FindClose (hFind); + FindClose(hFind);
return bResult; }
BOOL -RemoveDirectoryPath (LPCWSTR lpPathName) -{ - if (!RecursiveRemoveDir (lpPathName)) - return FALSE; - - DPRINT ("Delete directory: '%S'\n", lpPathName); - return RemoveDirectoryW (lpPathName); +RemoveDirectoryPath(LPCWSTR lpPathName) +{ + if (!RecursiveRemoveDir(lpPathName)) + return FALSE; + + DPRINT("Delete directory: '%S'\n", lpPathName); + return RemoveDirectoryW(lpPathName); }
/* EOF */
Modified: trunk/reactos/dll/win32/userenv/environment.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/userenv/environme... ============================================================================== --- trunk/reactos/dll/win32/userenv/environment.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/userenv/environment.c [iso-8859-1] Thu Oct 24 20:16:20 2013 @@ -19,7 +19,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries - * FILE: lib/userenv/environment.c + * FILE: dll/win32/userenv/environment.c * PURPOSE: User environment functions * PROGRAMMER: Eric Kohl */ @@ -30,7 +30,8 @@ #include <debug.h>
-static BOOL +static +BOOL SetUserEnvironmentVariable(LPVOID *Environment, LPWSTR lpName, LPWSTR lpValue, @@ -117,7 +118,8 @@ }
-static BOOL +static +BOOL AppendUserEnvironmentVariable(LPVOID *Environment, LPWSTR lpName, LPWSTR lpValue) @@ -165,7 +167,8 @@ }
-static HKEY +static +HKEY GetCurrentUserKey(HANDLE hToken) { UNICODE_STRING SidString; @@ -198,7 +201,8 @@ }
-static BOOL +static +BOOL SetUserEnvironment(LPVOID *lpEnvironment, HKEY hKey, LPWSTR lpSubKeyName) @@ -310,7 +314,8 @@ }
-BOOL WINAPI +BOOL +WINAPI CreateEnvironmentBlock(LPVOID *lpEnvironment, HANDLE hToken, BOOL bInherit) @@ -454,7 +459,8 @@ }
-BOOL WINAPI +BOOL +WINAPI DestroyEnvironmentBlock(LPVOID lpEnvironment) { DPRINT("DestroyEnvironmentBlock() called\n"); @@ -471,7 +477,8 @@ }
-BOOL WINAPI +BOOL +WINAPI ExpandEnvironmentStringsForUserW(IN HANDLE hToken, IN LPCWSTR lpSrc, OUT LPWSTR lpDest, @@ -522,7 +529,8 @@ }
-BOOL WINAPI +BOOL +WINAPI ExpandEnvironmentStringsForUserA(IN HANDLE hToken, IN LPCSTR lpSrc, OUT LPSTR lpDest,
Modified: trunk/reactos/dll/win32/userenv/gpolicy.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/userenv/gpolicy.c... ============================================================================== --- trunk/reactos/dll/win32/userenv/gpolicy.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/userenv/gpolicy.c [iso-8859-1] Thu Oct 24 20:16:20 2013 @@ -19,7 +19,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries - * FILE: lib/userenv/gpolicy.c + * FILE: dll/win32/userenv/gpolicy.c * PURPOSE: Group policy functions * PROGRAMMER: Thomas Weidenmueller w3seek@reactos.com */ @@ -110,7 +110,8 @@ DeleteCriticalSection(&GPNotifyLock); }
-static VOID +static +VOID NotifyGPEvents(IN BOOL bMachine) { PGP_NOTIFY Notify = NotificationList; @@ -126,7 +127,9 @@ } }
-static DWORD WINAPI +static +DWORD +WINAPI GPNotificationThreadProc(IN LPVOID lpParameter) { HMODULE hModule; @@ -255,7 +258,8 @@ return 1; }
-static HANDLE +static +HANDLE CreateGPEvent(IN BOOL bMachine, IN PSECURITY_DESCRIPTOR lpSecurityDescriptor) { @@ -274,7 +278,8 @@ return hEvent; }
-BOOL WINAPI +BOOL +WINAPI RegisterGPNotification(IN HANDLE hEvent, IN BOOL bMachine) { @@ -378,7 +383,8 @@ return Ret; }
-BOOL WINAPI +BOOL +WINAPI UnregisterGPNotification(IN HANDLE hEvent) { PGP_NOTIFY Notify = NULL, *NotifyLink; @@ -418,7 +424,8 @@ return Ret; }
-BOOL WINAPI +BOOL +WINAPI RefreshPolicy(IN BOOL bMachine) { HANDLE hEvent; @@ -437,7 +444,8 @@ return Ret; }
-BOOL WINAPI +BOOL +WINAPI RefreshPolicyEx(IN BOOL bMachine, IN DWORD dwOptions) { @@ -470,7 +478,8 @@ } }
-HANDLE WINAPI +HANDLE +WINAPI EnterCriticalPolicySection(IN BOOL bMachine) { SECURITY_ATTRIBUTES SecurityAttributes; @@ -507,7 +516,8 @@ return NULL; }
-BOOL WINAPI +BOOL +WINAPI LeaveCriticalPolicySection(IN HANDLE hSection) { BOOL Ret; @@ -524,7 +534,8 @@ return Ret; }
-BOOL WINAPI +BOOL +WINAPI WaitForUserPolicyForegroundProcessing(VOID) { HANDLE hEvent; @@ -543,7 +554,8 @@ return Ret; }
-BOOL WINAPI +BOOL +WINAPI WaitForMachinePolicyForegroundProcessing(VOID) { HANDLE hEvent;
Modified: trunk/reactos/dll/win32/userenv/internal.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/userenv/internal.... ============================================================================== --- trunk/reactos/dll/win32/userenv/internal.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/userenv/internal.h [iso-8859-1] Thu Oct 24 20:16:20 2013 @@ -19,7 +19,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries - * FILE: lib/userenv/internal.h + * FILE: dll/win32/userenv/internal.h * PURPOSE: internal stuff * PROGRAMMER: Eric Kohl */ @@ -29,15 +29,15 @@
/* directory.c */ BOOL -CopyDirectory (LPCWSTR lpDestinationPath, - LPCWSTR lpSourcePath); +CopyDirectory(LPCWSTR lpDestinationPath, + LPCWSTR lpSourcePath);
BOOL -CreateDirectoryPath (LPCWSTR lpPathName, - LPSECURITY_ATTRIBUTES lpSecurityAttributes); +CreateDirectoryPath(LPCWSTR lpPathName, + LPSECURITY_ATTRIBUTES lpSecurityAttributes);
BOOL -RemoveDirectoryPath (LPCWSTR lpPathName); +RemoveDirectoryPath(LPCWSTR lpPathName);
/* misc.c */ typedef struct _DYN_FUNCS @@ -64,35 +64,36 @@ extern DYN_MODULE DynOle32;
BOOL -LoadDynamicImports(PDYN_MODULE Module, PDYN_FUNCS DynFuncs); +LoadDynamicImports(PDYN_MODULE Module, + PDYN_FUNCS DynFuncs);
VOID UnloadDynamicImports(PDYN_FUNCS DynFuncs);
LPWSTR -AppendBackslash (LPWSTR String); +AppendBackslash(LPWSTR String);
BOOL -GetUserSidFromToken (HANDLE hToken, - PUNICODE_STRING SidString); +GetUserSidFromToken(HANDLE hToken, + PUNICODE_STRING SidString);
PSECURITY_DESCRIPTOR CreateDefaultSecurityDescriptor(VOID);
/* profile.c */ BOOL -AppendSystemPostfix (LPWSTR lpName, - DWORD dwMaxLength); +AppendSystemPostfix(LPWSTR lpName, + DWORD dwMaxLength);
/* registry.c */ BOOL -CreateUserHive (LPCWSTR lpKeyName, - LPCWSTR lpProfilePath); +CreateUserHive(LPCWSTR lpKeyName, + LPCWSTR lpProfilePath);
/* setup.c */ BOOL UpdateUsersShellFolderSettings(LPCWSTR lpUserProfilePath, - HKEY hUserKey); + HKEY hUserKey);
/* userenv.c */ extern HINSTANCE hInstance;
Modified: trunk/reactos/dll/win32/userenv/misc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/userenv/misc.c?re... ============================================================================== --- trunk/reactos/dll/win32/userenv/misc.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/userenv/misc.c [iso-8859-1] Thu Oct 24 20:16:20 2013 @@ -19,7 +19,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries - * FILE: lib/userenv/misc.c + * FILE: dll/win32/userenv/misc.c * PURPOSE: User profile code * PROGRAMMER: Eric Kohl */ @@ -35,86 +35,86 @@ /* FUNCTIONS ***************************************************************/
LPWSTR -AppendBackslash (LPWSTR String) -{ - ULONG Length; - - Length = lstrlenW (String); - if (String[Length - 1] != L'\') - { - String[Length] = L'\'; - Length++; - String[Length] = (WCHAR)0; - } - - return &String[Length]; +AppendBackslash(LPWSTR String) +{ + ULONG Length; + + Length = lstrlenW(String); + if (String[Length - 1] != L'\') + { + String[Length] = L'\'; + Length++; + String[Length] = (WCHAR)0; + } + + return &String[Length]; }
BOOL -GetUserSidFromToken (HANDLE hToken, - PUNICODE_STRING SidString) -{ - PSID_AND_ATTRIBUTES SidBuffer, nsb; - ULONG Length; - NTSTATUS Status; - - Length = 256; - SidBuffer = LocalAlloc (LMEM_FIXED, - Length); - if (SidBuffer == NULL) - return FALSE; - - Status = NtQueryInformationToken (hToken, - TokenUser, - (PVOID)SidBuffer, - Length, - &Length); - if (Status == STATUS_BUFFER_TOO_SMALL) - { - nsb = LocalReAlloc (SidBuffer, - Length, - LMEM_MOVEABLE); - if (nsb == NULL) +GetUserSidFromToken(HANDLE hToken, + PUNICODE_STRING SidString) +{ + PSID_AND_ATTRIBUTES SidBuffer, nsb; + ULONG Length; + NTSTATUS Status; + + Length = 256; + SidBuffer = LocalAlloc(LMEM_FIXED, + Length); + if (SidBuffer == NULL) + return FALSE; + + Status = NtQueryInformationToken(hToken, + TokenUser, + (PVOID)SidBuffer, + Length, + &Length); + if (Status == STATUS_BUFFER_TOO_SMALL) + { + nsb = LocalReAlloc(SidBuffer, + Length, + LMEM_MOVEABLE); + if (nsb == NULL) { - LocalFree((HLOCAL)SidBuffer); - return FALSE; + LocalFree((HLOCAL)SidBuffer); + return FALSE; }
- SidBuffer = nsb; - Status = NtQueryInformationToken (hToken, - TokenUser, - (PVOID)SidBuffer, - Length, - &Length); - } - - if (!NT_SUCCESS (Status)) - { - LocalFree ((HLOCAL)SidBuffer); - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } - - DPRINT ("SidLength: %lu\n", RtlLengthSid (SidBuffer[0].Sid)); - - Status = RtlConvertSidToUnicodeString (SidString, - SidBuffer[0].Sid, - TRUE); - - LocalFree ((HLOCAL)SidBuffer); - - if (!NT_SUCCESS (Status)) - { - SetLastError (RtlNtStatusToDosError (Status)); - return FALSE; - } - - DPRINT ("SidString.Length: %lu\n", SidString->Length); - DPRINT ("SidString.MaximumLength: %lu\n", SidString->MaximumLength); - DPRINT ("SidString: '%wZ'\n", SidString); - - return TRUE; + SidBuffer = nsb; + Status = NtQueryInformationToken(hToken, + TokenUser, + (PVOID)SidBuffer, + Length, + &Length); + } + + if (!NT_SUCCESS (Status)) + { + LocalFree((HLOCAL)SidBuffer); + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } + + DPRINT("SidLength: %lu\n", RtlLengthSid (SidBuffer[0].Sid)); + + Status = RtlConvertSidToUnicodeString(SidString, + SidBuffer[0].Sid, + TRUE); + + LocalFree((HLOCAL)SidBuffer); + + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } + + DPRINT("SidString.Length: %lu\n", SidString->Length); + DPRINT("SidString.MaximumLength: %lu\n", SidString->MaximumLength); + DPRINT("SidString: '%wZ'\n", SidString); + + return TRUE; }
PSECURITY_DESCRIPTOR @@ -284,47 +284,48 @@ * has been created! */ BOOL -LoadDynamicImports(PDYN_MODULE Module, PDYN_FUNCS DynFuncs) -{ - LPSTR *fname; - PVOID *fn; - - ZeroMemory(DynFuncs, sizeof(DYN_FUNCS)); - - DynFuncs->hModule = LoadLibraryW(Module->Library); - if (!DynFuncs->hModule) - { - return FALSE; - } - - fn = &DynFuncs->fn.foo; - - /* load the imports */ - for (fname = Module->Functions; *fname != NULL; fname++) - { - *fn = GetProcAddress(DynFuncs->hModule, *fname); - if (*fn == NULL) +LoadDynamicImports(PDYN_MODULE Module, + PDYN_FUNCS DynFuncs) +{ + LPSTR *fname; + PVOID *fn; + + ZeroMemory(DynFuncs, sizeof(DYN_FUNCS)); + + DynFuncs->hModule = LoadLibraryW(Module->Library); + if (!DynFuncs->hModule) + { + return FALSE; + } + + fn = &DynFuncs->fn.foo; + + /* load the imports */ + for (fname = Module->Functions; *fname != NULL; fname++) + { + *fn = GetProcAddress(DynFuncs->hModule, *fname); + if (*fn == NULL) { - FreeLibrary(DynFuncs->hModule); - DynFuncs->hModule = (HMODULE)0; - - return FALSE; + FreeLibrary(DynFuncs->hModule); + DynFuncs->hModule = (HMODULE)0; + + return FALSE; }
- fn++; - } - - return TRUE; + fn++; + } + + return TRUE; }
VOID UnloadDynamicImports(PDYN_FUNCS DynFuncs) { - if (DynFuncs->hModule) - { - FreeLibrary(DynFuncs->hModule); - DynFuncs->hModule = (HMODULE)0; + if (DynFuncs->hModule) + { + FreeLibrary(DynFuncs->hModule); + DynFuncs->hModule = (HMODULE)0; } }
Modified: trunk/reactos/dll/win32/userenv/profile.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/userenv/profile.c... ============================================================================== --- trunk/reactos/dll/win32/userenv/profile.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/userenv/profile.c [iso-8859-1] Thu Oct 24 20:16:20 2013 @@ -18,7 +18,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries - * FILE: lib/userenv/profile.c + * FILE: dll/win32/userenv/profile.c * PURPOSE: User profile code * PROGRAMMERS: Eric Kohl * Hervé Poussineau
Modified: trunk/reactos/dll/win32/userenv/registry.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/userenv/registry.... ============================================================================== --- trunk/reactos/dll/win32/userenv/registry.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/userenv/registry.c [iso-8859-1] Thu Oct 24 20:16:20 2013 @@ -19,7 +19,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries - * FILE: lib/userenv/registry.c + * FILE: dll/win32/userenv/registry.c * PURPOSE: User profile code * PROGRAMMER: Eric Kohl */ @@ -32,301 +32,302 @@
/* FUNCTIONS ***************************************************************/
-static BOOL -CopyKey (HKEY hDstKey, - HKEY hSrcKey) +static +BOOL +CopyKey(HKEY hDstKey, + HKEY hSrcKey) { - LONG Error; + LONG Error;
#if (_WIN32_WINNT >= 0x0600) - Error = RegCopyTreeW(hSrcKey, - NULL, - hDstKey); - if (Error != ERROR_SUCCESS) - { - SetLastError((DWORD)Error); - return FALSE; - } - - return TRUE; + Error = RegCopyTreeW(hSrcKey, + NULL, + hDstKey); + if (Error != ERROR_SUCCESS) + { + SetLastError((DWORD)Error); + return FALSE; + } + + return TRUE;
#else - FILETIME LastWrite; - DWORD dwSubKeys; - DWORD dwValues; - DWORD dwType; - DWORD dwMaxSubKeyNameLength; - DWORD dwSubKeyNameLength; - DWORD dwMaxValueNameLength; - DWORD dwValueNameLength; - DWORD dwMaxValueLength; - DWORD dwValueLength; - DWORD dwDisposition; - DWORD i; - LPWSTR lpNameBuffer; - LPBYTE lpDataBuffer; - HKEY hDstSubKey; - HKEY hSrcSubKey; - - DPRINT ("CopyKey() called \n"); - - Error = RegQueryInfoKey (hSrcKey, - NULL, - NULL, - NULL, - &dwSubKeys, - &dwMaxSubKeyNameLength, - NULL, - &dwValues, - &dwMaxValueNameLength, - &dwMaxValueLength, - NULL, - NULL); - if (Error != ERROR_SUCCESS) - { - DPRINT1 ("RegQueryInfoKey() failed (Error %lu)\n", Error); - SetLastError((DWORD)Error); - return FALSE; - } - - DPRINT ("dwSubKeys %lu\n", dwSubKeys); - DPRINT ("dwMaxSubKeyNameLength %lu\n", dwMaxSubKeyNameLength); - DPRINT ("dwValues %lu\n", dwValues); - DPRINT ("dwMaxValueNameLength %lu\n", dwMaxValueNameLength); - DPRINT ("dwMaxValueLength %lu\n", dwMaxValueLength); - - /* Copy subkeys */ - if (dwSubKeys != 0) - { - lpNameBuffer = HeapAlloc (GetProcessHeap (), - 0, - dwMaxSubKeyNameLength * sizeof(WCHAR)); - if (lpNameBuffer == NULL) - { - DPRINT1("Buffer allocation failed\n"); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - for (i = 0; i < dwSubKeys; i++) - { - dwSubKeyNameLength = dwMaxSubKeyNameLength; - Error = RegEnumKeyExW (hSrcKey, - i, - lpNameBuffer, - &dwSubKeyNameLength, - NULL, - NULL, - NULL, - &LastWrite); - if (Error != ERROR_SUCCESS) - { - DPRINT1 ("Subkey enumeration failed (Error %lu)\n", Error); - HeapFree (GetProcessHeap (), - 0, - lpNameBuffer); - SetLastError((DWORD)Error); - return FALSE; - } - - Error = RegCreateKeyExW (hDstKey, - lpNameBuffer, - 0, - NULL, - REG_OPTION_NON_VOLATILE, - KEY_WRITE, - NULL, - &hDstSubKey, - &dwDisposition); - if (Error != ERROR_SUCCESS) - { - DPRINT1 ("Subkey creation failed (Error %lu)\n", Error); - HeapFree (GetProcessHeap (), - 0, - lpNameBuffer); - SetLastError((DWORD)Error); - return FALSE; - } - - Error = RegOpenKeyExW (hSrcKey, - lpNameBuffer, - 0, - KEY_READ, - &hSrcSubKey); - if (Error != ERROR_SUCCESS) - { - DPRINT1 ("Error: %lu\n", Error); - RegCloseKey (hDstSubKey); - HeapFree (GetProcessHeap (), - 0, - lpNameBuffer); - SetLastError((DWORD)Error); - return FALSE; - } - - if (!CopyKey (hDstSubKey, - hSrcSubKey)) - { - DPRINT1 ("Error: %lu\n", GetLastError()); - RegCloseKey (hSrcSubKey); - RegCloseKey (hDstSubKey); - HeapFree (GetProcessHeap (), - 0, - lpNameBuffer); - return FALSE; - } - - RegCloseKey (hSrcSubKey); - RegCloseKey (hDstSubKey); - } - - HeapFree (GetProcessHeap (), - 0, - lpNameBuffer); - } - - /* Copy values */ - if (dwValues != 0) - { - lpNameBuffer = HeapAlloc (GetProcessHeap (), - 0, - dwMaxValueNameLength * sizeof(WCHAR)); - if (lpNameBuffer == NULL) - { - DPRINT1 ("Buffer allocation failed\n"); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - lpDataBuffer = HeapAlloc (GetProcessHeap (), - 0, - dwMaxValueLength); - if (lpDataBuffer == NULL) - { - DPRINT1 ("Buffer allocation failed\n"); - HeapFree (GetProcessHeap (), - 0, - lpNameBuffer); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - for (i = 0; i < dwValues; i++) - { - dwValueNameLength = dwMaxValueNameLength; - dwValueLength = dwMaxValueLength; - Error = RegEnumValueW (hSrcKey, - i, - lpNameBuffer, - &dwValueNameLength, - NULL, - &dwType, - lpDataBuffer, - &dwValueLength); - if (Error != ERROR_SUCCESS) - { - DPRINT1("Error: %lu\n", Error); - HeapFree (GetProcessHeap (), - 0, - lpDataBuffer); - HeapFree (GetProcessHeap (), - 0, - lpNameBuffer); - SetLastError((DWORD)Error); - return FALSE; - } - - Error = RegSetValueExW (hDstKey, - lpNameBuffer, - 0, - dwType, - lpDataBuffer, - dwValueLength); - if (Error != ERROR_SUCCESS) - { - DPRINT1("Error: %lu\n", Error); - HeapFree (GetProcessHeap (), - 0, - lpDataBuffer); - HeapFree (GetProcessHeap (), - 0, - lpNameBuffer); - SetLastError((DWORD)Error); - return FALSE; - } - } - - HeapFree (GetProcessHeap (), - 0, - lpDataBuffer); - - HeapFree (GetProcessHeap (), - 0, - lpNameBuffer); - } - - DPRINT ("CopyKey() done \n"); - - return TRUE; + FILETIME LastWrite; + DWORD dwSubKeys; + DWORD dwValues; + DWORD dwType; + DWORD dwMaxSubKeyNameLength; + DWORD dwSubKeyNameLength; + DWORD dwMaxValueNameLength; + DWORD dwValueNameLength; + DWORD dwMaxValueLength; + DWORD dwValueLength; + DWORD dwDisposition; + DWORD i; + LPWSTR lpNameBuffer; + LPBYTE lpDataBuffer; + HKEY hDstSubKey; + HKEY hSrcSubKey; + + DPRINT ("CopyKey() called \n"); + + Error = RegQueryInfoKey(hSrcKey, + NULL, + NULL, + NULL, + &dwSubKeys, + &dwMaxSubKeyNameLength, + NULL, + &dwValues, + &dwMaxValueNameLength, + &dwMaxValueLength, + NULL, + NULL); + if (Error != ERROR_SUCCESS) + { + DPRINT1("RegQueryInfoKey() failed (Error %lu)\n", Error); + SetLastError((DWORD)Error); + return FALSE; + } + + DPRINT("dwSubKeys %lu\n", dwSubKeys); + DPRINT("dwMaxSubKeyNameLength %lu\n", dwMaxSubKeyNameLength); + DPRINT("dwValues %lu\n", dwValues); + DPRINT("dwMaxValueNameLength %lu\n", dwMaxValueNameLength); + DPRINT("dwMaxValueLength %lu\n", dwMaxValueLength); + + /* Copy subkeys */ + if (dwSubKeys != 0) + { + lpNameBuffer = HeapAlloc(GetProcessHeap(), + 0, + dwMaxSubKeyNameLength * sizeof(WCHAR)); + if (lpNameBuffer == NULL) + { + DPRINT1("Buffer allocation failed\n"); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + for (i = 0; i < dwSubKeys; i++) + { + dwSubKeyNameLength = dwMaxSubKeyNameLength; + Error = RegEnumKeyExW(hSrcKey, + i, + lpNameBuffer, + &dwSubKeyNameLength, + NULL, + NULL, + NULL, + &LastWrite); + if (Error != ERROR_SUCCESS) + { + DPRINT1("Subkey enumeration failed (Error %lu)\n", Error); + HeapFree(GetProcessHeap(), + 0, + lpNameBuffer); + SetLastError((DWORD)Error); + return FALSE; + } + + Error = RegCreateKeyExW(hDstKey, + lpNameBuffer, + 0, + NULL, + REG_OPTION_NON_VOLATILE, + KEY_WRITE, + NULL, + &hDstSubKey, + &dwDisposition); + if (Error != ERROR_SUCCESS) + { + DPRINT1("Subkey creation failed (Error %lu)\n", Error); + HeapFree(GetProcessHeap(), + 0, + lpNameBuffer); + SetLastError((DWORD)Error); + return FALSE; + } + + Error = RegOpenKeyExW(hSrcKey, + lpNameBuffer, + 0, + KEY_READ, + &hSrcSubKey); + if (Error != ERROR_SUCCESS) + { + DPRINT1("Error: %lu\n", Error); + RegCloseKey(hDstSubKey); + HeapFree(GetProcessHeap(), + 0, + lpNameBuffer); + SetLastError((DWORD)Error); + return FALSE; + } + + if (!CopyKey(hDstSubKey, + hSrcSubKey)) + { + DPRINT1("Error: %lu\n", GetLastError()); + RegCloseKey (hSrcSubKey); + RegCloseKey (hDstSubKey); + HeapFree(GetProcessHeap(), + 0, + lpNameBuffer); + return FALSE; + } + + RegCloseKey(hSrcSubKey); + RegCloseKey(hDstSubKey); + } + + HeapFree(GetProcessHeap(), + 0, + lpNameBuffer); + } + + /* Copy values */ + if (dwValues != 0) + { + lpNameBuffer = HeapAlloc(GetProcessHeap(), + 0, + dwMaxValueNameLength * sizeof(WCHAR)); + if (lpNameBuffer == NULL) + { + DPRINT1("Buffer allocation failed\n"); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + lpDataBuffer = HeapAlloc(GetProcessHeap(), + 0, + dwMaxValueLength); + if (lpDataBuffer == NULL) + { + DPRINT1("Buffer allocation failed\n"); + HeapFree(GetProcessHeap(), + 0, + lpNameBuffer); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + for (i = 0; i < dwValues; i++) + { + dwValueNameLength = dwMaxValueNameLength; + dwValueLength = dwMaxValueLength; + Error = RegEnumValueW(hSrcKey, + i, + lpNameBuffer, + &dwValueNameLength, + NULL, + &dwType, + lpDataBuffer, + &dwValueLength); + if (Error != ERROR_SUCCESS) + { + DPRINT1("Error: %lu\n", Error); + HeapFree(GetProcessHeap(), + 0, + lpDataBuffer); + HeapFree(GetProcessHeap(), + 0, + lpNameBuffer); + SetLastError((DWORD)Error); + return FALSE; + } + + Error = RegSetValueExW(hDstKey, + lpNameBuffer, + 0, + dwType, + lpDataBuffer, + dwValueLength); + if (Error != ERROR_SUCCESS) + { + DPRINT1("Error: %lu\n", Error); + HeapFree(GetProcessHeap(), + 0, + lpDataBuffer); + HeapFree(GetProcessHeap(), + 0, + lpNameBuffer); + SetLastError((DWORD)Error); + return FALSE; + } + } + + HeapFree(GetProcessHeap(), + 0, + lpDataBuffer); + + HeapFree(GetProcessHeap(), + 0, + lpNameBuffer); + } + + DPRINT("CopyKey() done \n"); + + return TRUE; #endif }
BOOL -CreateUserHive (LPCWSTR lpKeyName, - LPCWSTR lpProfilePath) +CreateUserHive(LPCWSTR lpKeyName, + LPCWSTR lpProfilePath) { - HKEY hDefaultKey = NULL; - HKEY hUserKey = NULL; - LONG Error; - BOOL Ret = FALSE; - - DPRINT ("CreateUserHive(%S) called\n", lpKeyName); - - Error = RegOpenKeyExW (HKEY_USERS, - L".Default", - 0, - KEY_READ, - &hDefaultKey); - if (Error != ERROR_SUCCESS) - { - SetLastError((DWORD)Error); - goto Cleanup; - } - - Error = RegOpenKeyExW (HKEY_USERS, - lpKeyName, - 0, - KEY_ALL_ACCESS, - &hUserKey); - if (Error != ERROR_SUCCESS) - { - SetLastError((DWORD)Error); - goto Cleanup; - } - - if (!CopyKey(hUserKey, hDefaultKey)) - { - goto Cleanup; - } - - if (!UpdateUsersShellFolderSettings(lpProfilePath, - hUserKey)) - { - goto Cleanup; - } - - RegFlushKey (hUserKey); - Ret = TRUE; + HKEY hDefaultKey = NULL; + HKEY hUserKey = NULL; + LONG Error; + BOOL Ret = FALSE; + + DPRINT("CreateUserHive(%S) called\n", lpKeyName); + + Error = RegOpenKeyExW(HKEY_USERS, + L".Default", + 0, + KEY_READ, + &hDefaultKey); + if (Error != ERROR_SUCCESS) + { + SetLastError((DWORD)Error); + goto Cleanup; + } + + Error = RegOpenKeyExW(HKEY_USERS, + lpKeyName, + 0, + KEY_ALL_ACCESS, + &hUserKey); + if (Error != ERROR_SUCCESS) + { + SetLastError((DWORD)Error); + goto Cleanup; + } + + if (!CopyKey(hUserKey, hDefaultKey)) + { + goto Cleanup; + } + + if (!UpdateUsersShellFolderSettings(lpProfilePath, + hUserKey)) + { + goto Cleanup; + } + + RegFlushKey(hUserKey); + Ret = TRUE;
Cleanup: - if (hUserKey != NULL) - RegCloseKey (hUserKey); - - if (hDefaultKey != NULL) - RegCloseKey (hDefaultKey); - - return Ret; + if (hUserKey != NULL) + RegCloseKey (hUserKey); + + if (hDefaultKey != NULL) + RegCloseKey (hDefaultKey); + + return Ret; }
/* EOF */
Modified: trunk/reactos/dll/win32/userenv/resources.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/userenv/resources... ============================================================================== --- trunk/reactos/dll/win32/userenv/resources.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/userenv/resources.h [iso-8859-1] Thu Oct 24 20:16:20 2013 @@ -19,7 +19,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries - * FILE: lib/userenv/resource.h + * FILE: dll/win32/userenv/resource.h * PURPOSE: Resource IDs * PROGRAMMER: Eric Kohl */
Modified: trunk/reactos/dll/win32/userenv/setup.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/userenv/setup.c?r... ============================================================================== --- trunk/reactos/dll/win32/userenv/setup.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/userenv/setup.c [iso-8859-1] Thu Oct 24 20:16:20 2013 @@ -19,7 +19,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries - * FILE: lib/userenv/setup.c + * FILE: dll/win32/userenv/setup.c * PURPOSE: Profile setup functions * PROGRAMMER: Eric Kohl */
Modified: trunk/reactos/dll/win32/userenv/userenv.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/userenv/userenv.c... ============================================================================== --- trunk/reactos/dll/win32/userenv/userenv.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/userenv/userenv.c [iso-8859-1] Thu Oct 24 20:16:20 2013 @@ -19,7 +19,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries - * FILE: lib/userenv/userenv.c + * FILE: dll/win32/userenv/userenv.c * PURPOSE: DLL initialization code * PROGRAMMER: Eric Kohl */ @@ -31,20 +31,21 @@
HINSTANCE hInstance = NULL;
-BOOL WINAPI -DllMain (HINSTANCE hinstDLL, - DWORD fdwReason, - LPVOID lpvReserved) +BOOL +WINAPI +DllMain(HINSTANCE hinstDLL, + DWORD fdwReason, + LPVOID lpvReserved) { - if (fdwReason == DLL_PROCESS_ATTACH) + if (fdwReason == DLL_PROCESS_ATTACH) { - hInstance = hinstDLL; - InitializeGPNotifications(); + hInstance = hinstDLL; + InitializeGPNotifications(); } - else if (fdwReason == DLL_PROCESS_DETACH) + else if (fdwReason == DLL_PROCESS_DETACH) { UninitializeGPNotifications(); }
- return TRUE; + return TRUE; }