Author: tfaber
Date: Sun Jan 13 20:13:30 2013
New Revision: 58171

URL: http://svn.reactos.org/svn/reactos?rev=58171&view=rev
Log:
[EXPLORER_NEW]
- Check policy before processing startup items. Simplify startup code. Patch by 
Edijs Kolesnikovičs.

Modified:
    trunk/reactos/base/shell/explorer-new/explorer.c
    trunk/reactos/base/shell/explorer-new/precomp.h
    trunk/reactos/base/shell/explorer-new/startup.c

Modified: trunk/reactos/base/shell/explorer-new/explorer.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/explorer.c?rev=58171&r1=58170&r2=58171&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer-new/explorer.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer-new/explorer.c [iso-8859-1] Sun Jan 13 
20:13:30 2013
@@ -401,7 +401,7 @@
         if (!SetShellReadyEvent(TEXT("msgina: ShellReadyEvent")))
             SetShellReadyEvent(TEXT("Global\\msgina: ShellReadyEvent"));
 
-        startup(0, NULL);
+        ProcessStartupItems();
     }
     else
     {

Modified: trunk/reactos/base/shell/explorer-new/precomp.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/precomp.h?rev=58171&r1=58170&r2=58171&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer-new/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer-new/precomp.h [iso-8859-1] Sun Jan 13 
20:13:30 2013
@@ -260,7 +260,8 @@
  * startup.c
  */
 
-int startup(int argc, const char *argv[]);
+int
+ProcessStartupItems(VOID);
 
 /*
  * trayprop.h

Modified: trunk/reactos/base/shell/explorer-new/startup.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/startup.c?rev=58171&r1=58170&r2=58171&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer-new/startup.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer-new/startup.c [iso-8859-1] Sun Jan 13 
20:13:30 2013
@@ -44,18 +44,6 @@
 #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
 /**
@@ -245,24 +233,11 @@
     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? */
+    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;
@@ -305,41 +280,21 @@
         }
     }
 
-    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;
-
-    /* do not run certain items in Safe Mode */
-    if (GetSystemMetrics(SM_CLEANBOOT)) ops.startup = FALSE;
-
-    /* Perform the ops by order, stopping if one fails, skipping if necessary 
*/
+    /* 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;
-    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 && (SHRestricted(REST_NOLOCALMACHINERUNONCE) == 0))
+        res = ProcessRunKeys(HKEY_LOCAL_MACHINE, L"RunOnce", TRUE, TRUE);
+
+    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);
+
+    if (res && bNormalBoot && (SHRestricted(REST_NOCURRENTUSERRUNONCE) == 0))
+        res = ProcessRunKeys(HKEY_CURRENT_USER, L"RunOnce", TRUE, FALSE);
 
     printf("Operation done\n");
 


Reply via email to