* Also, 119941 has some info on grpconv.exe
* The operations performed are (by order of execution):
*
- * Startup (before the user logs in)
- * - Services (NT, ?semi-synchronous?, not implemented yet)
- * - HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce (9x, asynch)
- * - HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices (9x, asynch)
- *
* After log in
- * - HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce (all, synch)
- * - HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run (all, asynch)
- * - HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run (all, asynch)
- * - Startup folders (all, ?asynch?, no imp)
- * - HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce (all, asynch)
+ * - HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnceEx (synch, no imp)
+ * - HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce (synch)
+ * - HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run (asynch)
+ * - HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run (asynch)
+ * - All users Startup folder "%ALLUSERSPROFILE%\Start Menu\Programs\Startup" (asynch, no imp)
+ * - Current user Startup folder "%USERPROFILE%\Start Menu\Programs\Startup" (asynch, no imp)
+ * - HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce (asynch)
*
- * Somewhere in there is processing the RunOnceEx entries (also no imp)
+ * None is processed in Safe Mode // FIXME: Check RunOnceEx in Safe Mode
*/
#include "precomp.h"
EXTERN_C HRESULT WINAPI SHCreateSessionKey(REGSAM samDesired, PHKEY phKey);
-enum runkeys {
- RUNKEY_RUN, RUNKEY_RUNONCE, RUNKEY_RUNSERVICES, RUNKEY_RUNSERVICESONCE
-};
-
-const WCHAR runkeys_names[][30]=
-{
- {'R','u','n',0},
- {'R','u','n','O','n','c','e',0},
- {'R','u','n','S','e','r','v','i','c','e','s',0},
- {'R','u','n','S','e','r','v','i','c','e','s','O','n','c','e',0}
-};
-
#define INVALID_RUNCMD_RETURN -1
/**
* This function runs the specified command in the specified dir.
static BOOL ProcessRunKeys(HKEY hkRoot, LPCWSTR szKeyName, BOOL bDelete,
BOOL bSynchronous)
{
- static const WCHAR WINKEY_NAME[]={'S','o','f','t','w','a','r','e','\\',
- 'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
- 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0};
HKEY hkWin = NULL, hkRun=NULL;
LONG res = ERROR_SUCCESS;
DWORD i, nMaxCmdLine = 0, nMaxValue = 0;
else
wprintf(L"processing %s entries under HKCU\n", szKeyName);
- if ((res = RegOpenKeyExW(hkRoot, WINKEY_NAME, 0, KEY_READ, &hkWin)) != ERROR_SUCCESS)
+ if ((res = RegOpenKeyExW(hkRoot, L"Software\\Microsoft\\Windows\\CurrentVersion", 0, KEY_READ, &hkWin)) != ERROR_SUCCESS)
{
printf("RegOpenKey failed on Software\\Microsoft\\Windows\\CurrentVersion (%ld)\n",
res);
goto end;
}
- while(i > 0)
+ while (i > 0)
{
- DWORD nValLength=nMaxValue, nDataLength=nMaxCmdLine;
+ DWORD nValLength = nMaxValue, nDataLength = nMaxCmdLine;
DWORD type;
--i;
return res == ERROR_SUCCESS ? TRUE : FALSE;
}
- /// structure holding startup flags
-struct op_mask {
- BOOL w9xonly; /* Perform only operations done on Windows 9x */
- BOOL ntonly; /* Perform only operations done on Windows NT */
- BOOL startup; /* Perform the operations that are performed every boot */
- BOOL preboot; /* Perform file renames typically done before the system starts */
- BOOL prelogin; /* Perform the operations typically done before the user logs in */
- BOOL postlogin; /* Operations done after login */
-};
-
-static const struct op_mask
- SESSION_START = {FALSE, FALSE, TRUE, TRUE, TRUE, TRUE},
- SETUP = {FALSE, FALSE, FALSE, TRUE, TRUE, TRUE};
-#define DEFAULT SESSION_START
-
-int startup(int argc, const char *argv[])
+
+int
+ProcessStartupItems(VOID)
{
- struct op_mask ops; /* Which of the ops do we want to perform? */
+ /* TODO: ProcessRunKeys already checks SM_CLEANBOOT -- items prefixed with * should probably run even in safe mode */
+ BOOL bNormalBoot = GetSystemMetrics(SM_CLEANBOOT) == 0; /* Perform the operations that are performed every boot */
/* First, set the current directory to SystemRoot */
TCHAR gen_path[MAX_PATH];
DWORD res;
}
}
- if (argc > 1)
- {
- switch(argv[1][0])
- {
- case 'r': /* Restart */
- ops = SETUP;
- break;
- case 's': /* Full start */
- ops = SESSION_START;
- break;
- default:
- ops = DEFAULT;
- break;
- }
- }
- else
- ops = DEFAULT;
+ /* Perform the operations by order checking if policy allows it, checking if this is not Safe Mode,
+ * stopping if one fails, skipping if necessary.
+ */
+ res = TRUE;
+ /* TODO: RunOnceEx */
- /* do not run certain items in Safe Mode */
- if (GetSystemMetrics(SM_CLEANBOOT)) ops.startup = FALSE;
+ if (res && (SHRestricted(REST_NOLOCALMACHINERUNONCE) == 0))
+ res = ProcessRunKeys(HKEY_LOCAL_MACHINE, L"RunOnce", TRUE, TRUE);
- /* Perform the ops by order, stopping if one fails, skipping if necessary */
- res = TRUE;
- if (res && !ops.ntonly && ops.prelogin)
- res = ProcessRunKeys(HKEY_LOCAL_MACHINE, runkeys_names[RUNKEY_RUNSERVICESONCE], TRUE, FALSE);
- if (res && !ops.ntonly && ops.prelogin && ops.startup)
- res = ProcessRunKeys(HKEY_LOCAL_MACHINE, runkeys_names[RUNKEY_RUNSERVICES], FALSE, FALSE);
- if (res && ops.postlogin)
- res = ProcessRunKeys(HKEY_LOCAL_MACHINE, runkeys_names[RUNKEY_RUNONCE], TRUE, TRUE);
- if (res && ops.postlogin && ops.startup)
- res = ProcessRunKeys(HKEY_LOCAL_MACHINE, runkeys_names[RUNKEY_RUN], FALSE, FALSE);
- if (res && ops.postlogin && ops.startup)
- res = ProcessRunKeys(HKEY_CURRENT_USER, runkeys_names[RUNKEY_RUN], FALSE, FALSE);
- if (res && ops.postlogin && ops.startup)
- res = ProcessRunKeys(HKEY_CURRENT_USER, runkeys_names[RUNKEY_RUNONCE], TRUE, FALSE);
+ if (res && bNormalBoot && (SHRestricted(REST_NOLOCALMACHINERUN) == 0))
+ res = ProcessRunKeys(HKEY_LOCAL_MACHINE, L"Run", FALSE, FALSE);
+
+ if (res && bNormalBoot && (SHRestricted(REST_NOCURRENTUSERRUNONCE) == 0))
+ res = ProcessRunKeys(HKEY_CURRENT_USER, L"Run", FALSE, FALSE);
+
+ /* TODO: All users Startup folder */
+
+ /* TODO: Current user Startup folder */
+
+ /* TODO: HKCU\RunOnce runs even if StartupHasBeenRun exists */
+ if (res && bNormalBoot && (SHRestricted(REST_NOCURRENTUSERRUNONCE) == 0))
+ res = ProcessRunKeys(HKEY_CURRENT_USER, L"RunOnce", TRUE, FALSE);
printf("Operation done\n");