* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
* COPYRIGHT: See COPYING in the top level directory
WARN("FindFirstFile(%s) failed with error %lu\n", debugstr_w(szPath), GetLastError());
return;
}
- szPath[len] = L'\0';
do
{
{
memset(&ExecInfo, 0x0, sizeof(SHELLEXECUTEINFOW));
ExecInfo.cbSize = sizeof(ExecInfo);
+ wcscpy(&szPath[len+1], findData.cFileName);
ExecInfo.lpVerb = L"open";
- ExecInfo.lpFile = findData.cFileName;
- ExecInfo.lpDirectory = szPath;
+ ExecInfo.lpFile = szPath;
+ ExecInfo.lpDirectory = NULL;
TRACE("Executing %s in directory %s\n",
debugstr_w(findData.cFileName), debugstr_w(szPath));
ShellExecuteExW(&ExecInfo);
{
WCHAR Shell[MAX_PATH];
TCHAR szMsg[RC_STRING_MAX_SIZE];
+ DWORD Type, Size;
+ DWORD Value = 0;
+ LONG rc;
+ HKEY hKey;
TRACE("()\n");
+ /* Safe Mode shell run */
+ rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+ L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Option",
+ 0, KEY_QUERY_VALUE, &hKey);
+ if(rc == ERROR_SUCCESS)
+ {
+ Size = sizeof(Value);
+ rc = RegQueryValueExW(hKey, L"UseAlternateShell", NULL,
+ &Type, (LPBYTE)&Value, &Size);
+ if(rc == ERROR_SUCCESS)
+ {
+ RegCloseKey(hKey);
+ if(Type == REG_DWORD)
+ {
+ if(Value)
+ {
+ /* Safe Mode Alternate Shell required */
+ rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+ L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot",
+ 0, KEY_READ, &hKey);
+ if(rc == ERROR_SUCCESS)
+ {
+ Size = MAX_PATH * sizeof(WCHAR);
+ rc = RegQueryValueExW(hKey, L"AlternateShell", NULL,
+ &Type, (LPBYTE)Shell, &Size);
+ if(rc == ERROR_SUCCESS)
+ {
+ RegCloseKey(hKey);
+ if ((Type == REG_SZ) || (Type == REG_EXPAND_SZ))
+ {
+ TRACE("Key located - %s\n", debugstr_w(Shell));
+ /* Try to run alternate shell */
+ if (TryToStartShell(Shell))
+ {
+ TRACE("Alternate shell started (Safe Mode)\n");
+ return;
+ }
+ }
+ else
+ {
+ WARN("Wrong type %lu (expected %u or %u)\n",
+ Type, REG_SZ, REG_EXPAND_SZ);
+ }
+ }
+ else
+ {
+ WARN("Alternate shell in Safe Mode required but not specified.");
+ }
+ }
+ }
+ }
+ else
+ {
+ WARN("Wrong type %lu (expected %u)\n", Type, REG_DWORD);
+ }
+ }
+ }
/* Try to run shell in user key */
if (GetShell(Shell, HKEY_CURRENT_USER) && TryToStartShell(Shell))
{
WARN("RegOpenKeyEx() failed with error %lu\n", rc);
}
-static VOID
-PlayLogonSound()
-{
- HKEY hKey;
- WCHAR szBuffer[MAX_PATH] = {0};
- WCHAR szDest[MAX_PATH];
- DWORD dwSize = sizeof(szBuffer);
- HMODULE hLibrary;
- typedef BOOL WINAPI (*PLAYSOUNDW)(LPCWSTR,HMODULE,DWORD);
- PLAYSOUNDW Play;
-
- if (RegOpenKeyExW(HKEY_CURRENT_USER, L"AppEvents\\Schemes\\Apps\\.Default\\WindowsLogon\\.Current", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
- {
- return;
- }
-
- if (RegQueryValueExW(hKey, NULL, NULL, NULL, (LPBYTE)szBuffer, &dwSize) != ERROR_SUCCESS)
- {
- RegCloseKey(hKey);
- return;
- }
-
-
- RegCloseKey(hKey);
-
- if (!szBuffer[0])
- return;
-
-
- szBuffer[MAX_PATH-1] = L'\0';
- if (ExpandEnvironmentStringsW(szBuffer, szDest, MAX_PATH))
- {
- hLibrary = LoadLibraryW(L"winmm.dll");
- if (hLibrary)
- {
- Play = (PLAYSOUNDW)GetProcAddress(hLibrary, "PlaySoundW");
- if (Play)
- {
- Play(szDest, NULL, SND_FILENAME);
- }
- FreeLibrary(hLibrary);
- }
- }
-}
-
static
VOID SetUserSettings(VOID)
{
SetUserSettings();
StartShell();
NotifyLogon();
- PlayLogonSound();
return 0;
}