Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

199 lines
6.2 KiB

  1. #define OEMRESOURCE
  2. #include <windows.h>
  3. #include <windowsx.h>
  4. #include <objidl.h>
  5. #include <commctrl.h>
  6. #include <comctrlp.h>
  7. #include <regstr.h>
  8. #include <shlobj.h>
  9. #include <shellapi.h>
  10. #include <advpub.h>
  11. #define MAX_ENTRYNAME 256
  12. #define WM_FINISHED (WM_USER + 0x123)
  13. // taken from \\trango\slmadd\src\shell\inc\shellp.h
  14. #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
  15. #define IsSpace(c) ((c) == ' ' || (c) == '\t' || (c) == '\r' || (c) == '\n' || (c) == '\v' || (c) == '\f')
  16. #define IsDigit(c) ((c) >= '0' && (c) <= '9')
  17. // Callback proc stuff for RunOnceExProcess
  18. typedef VOID (*RUNONCEEXPROCESSCALLBACK)
  19. (
  20. int nCurrent,
  21. int nMax,
  22. LPSTR pszError
  23. );
  24. //////////////////////////////////////////////////////////////////
  25. // TYPES:
  26. //////////////////////////////////////////////////////////////////
  27. typedef enum {
  28. RRA_DEFAULT = 0x0000,
  29. RRA_DELETE = 0x0001,
  30. RRA_WAIT = 0x0002,
  31. } RRA_FLAGS;
  32. typedef enum {
  33. RRAEX_NO_ERROR_DIALOGS = 0x0008,
  34. RRAEX_ERRORFILE = 0x0010,
  35. RRAEX_LOG_FILE = 0x0020,
  36. RRAEX_NO_EXCEPTION_TRAPPING = 0x0040,
  37. RRAEX_NO_STATUS_DIALOG = 0x0080,
  38. RRAEX_IGNORE_REG_FLAGS = 0x0100,
  39. RRAEX_CHECK_NT_ADMIN = 0x0200,
  40. RRAEX_SHOW_SOFTBOOT_UI = 0x0400,
  41. RRAEX_QUIT_IF_REBOOT_NEEDED = 0x0800,
  42. RRAEX_BACKUP_SYSTEM_DAT = 0x1000,
  43. #if 0
  44. /****
  45. RRAEX_DELETE_SYSTEM_IE4 = 0x2000,
  46. ****/
  47. #endif
  48. #if 0
  49. /**** enable this when explorer.exe is fixed (bug #30866)
  50. RRAEX_CREATE_REGFILE = 0x4000,
  51. ****/
  52. #endif
  53. } RRAEX_FLAGS;
  54. typedef struct tagArgsInfo
  55. {
  56. HKEY hkeyParent;
  57. LPCTSTR pszSubkey;
  58. DWORD dwFlags;
  59. HDPA hdpaSections;
  60. int iNumberOfSections;
  61. } ARGSINFO;
  62. enum eRunOnceExAction
  63. {
  64. eRO_Unknown, // This indicates that we don't yet know the action
  65. eRO_Register,
  66. eRO_Unregister,
  67. eRO_Install,
  68. eRO_WinMainFunction,
  69. eRO_Exe
  70. };
  71. //////////////////////////////////////////////////////////////////
  72. // Class Definitions
  73. //////////////////////////////////////////////////////////////////
  74. /****************************************************\
  75. CLASS: RunOnceExEntry
  76. DESCRIPTION:
  77. This class will contain one command that needs
  78. to be executed.
  79. \***************************************************/
  80. class RunOnceExEntry
  81. {
  82. public:
  83. // Member Variables
  84. TCHAR m_szRunOnceExEntryName[MAX_ENTRYNAME];
  85. TCHAR m_szFileName[MAX_PATH];
  86. TCHAR m_szFunctionName[MAX_ENTRYNAME];
  87. TCHAR m_szCmdLineArgs[MAX_PATH];
  88. eRunOnceExAction m_ROAction;
  89. // Member Functions
  90. RunOnceExEntry(LPTSTR lpszNewEntryName, LPTSTR lpszNewCmd, DWORD dwFlags);
  91. ~RunOnceExEntry();
  92. void Process(HKEY hkeyParent, LPCTSTR szSubkey, LPCTSTR szSectionName, DWORD dwFlags);
  93. };
  94. /****************************************************\
  95. CLASS: RunOnceExSection
  96. DESCRIPTION:
  97. This class will contain one grouping of
  98. commands that will need to be executed.
  99. \***************************************************/
  100. class RunOnceExSection
  101. {
  102. public:
  103. // Member Variables
  104. TCHAR m_szRunOnceExSectionName[MAX_ENTRYNAME];
  105. TCHAR m_szDisplayName[MAX_ENTRYNAME];
  106. HDPA m_hEntryArray;
  107. int m_NumberOfEntries;
  108. // Member Functions
  109. RunOnceExSection(LPTSTR lpszNewSectionName, LPTSTR lpszNewDisplayName);
  110. ~RunOnceExSection();
  111. void Process(HKEY hkeyParent, LPCTSTR szSubkey, DWORD dwFlags);
  112. };
  113. INT_PTR CALLBACK DlgProcRunOnceEx(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  114. void ProcessSections(HKEY hkeyParent, LPCTSTR pszSubkey, DWORD dwFlags, HDPA hdpaSections, int iNumberOfSections, HWND hWnd);
  115. extern const TCHAR *g_c_szTitleRegValue;
  116. extern TCHAR g_szTitleString[256];
  117. extern BOOL g_bRunningOnNT;
  118. extern HINSTANCE g_hinst;
  119. extern HANDLE g_hHeap;
  120. extern HANDLE g_hLogFile;
  121. extern RUNONCEEXPROCESSCALLBACK g_pCallbackProc;
  122. // internal functions defined in utils.cpp
  123. void AddPath(LPTSTR szPath, LPCTSTR szName);
  124. BOOL GetParentDir(LPTSTR szPath);
  125. BOOL RunningOnIE4();
  126. DWORD MsgWaitForMultipleObjectsLoop(HANDLE hEvent, DWORD dwTimeout);
  127. void LogOff(BOOL bRestart);
  128. void ReportError(DWORD dwFlags, UINT uiResourceNum, ...);
  129. long AtoL(const char *nptr);
  130. #ifdef UNICODE
  131. #define LocalStrChr LocalStrChrW
  132. #define LocalSHDeleteKey LocalSHDeleteKeyW
  133. #define LocalSHDeleteValue LocalSHDeleteValueW
  134. #else
  135. #define LocalStrChr LocalStrChrA
  136. #define LocalSHDeleteKey LocalSHDeleteKeyA
  137. #define LocalSHDeleteValue LocalSHDeleteValueA
  138. #endif
  139. // following copied from \\trango\slmadd\src\shell\shlwapi\path.c
  140. STDAPI_(LPTSTR) LocalPathGetArgs(LPCTSTR pszPath);
  141. STDAPI_(void) LocalPathUnquoteSpaces(LPTSTR lpsz);
  142. // following copied from \\trango\slmadd\src\shell\shlwapi\strings.c
  143. #ifdef UNICODE
  144. LPWSTR FAR PASCAL LocalStrChrW(LPCWSTR lpStart, WORD wMatch);
  145. __inline BOOL ChrCmpW_inline(WORD w1, WORD wMatch);
  146. #else
  147. LPSTR FAR PASCAL LocalStrChrA(LPCSTR lpStart, WORD wMatch);
  148. __inline BOOL ChrCmpA_inline(WORD w1, WORD wMatch);
  149. #endif
  150. // following copied from \\trango\slmadd\src\shell\shlwapi\reg.c
  151. #ifdef UNICODE
  152. STDAPI_(DWORD) LocalSHDeleteKeyW(HKEY hkey, LPCWSTR pwszSubKey);
  153. #else
  154. STDAPI_(DWORD) LocalSHDeleteKeyA(HKEY hkey, LPCSTR pszSubKey);
  155. #endif
  156. DWORD DeleteKeyRecursively(HKEY hkey, LPCSTR pszSubKey);
  157. #ifdef UNICODE
  158. STDAPI_(DWORD) LocalSHDeleteValueW(HKEY hkey, LPCWSTR pwszSubKey, LPCWSTR pwszValue);
  159. #endif
  160. STDAPI_(DWORD) LocalSHDeleteValueA(HKEY hkey, LPCSTR pszSubKey, LPCSTR pszValue);
  161. // related to logging
  162. LPTSTR GetLogFileName(LPCTSTR pcszLogFileKeyName, LPTSTR pszLogFileName, DWORD dwSizeInChars);
  163. VOID StartLogging(LPCTSTR pcszLogFileName, DWORD dwCreationFlags);
  164. VOID WriteToLog(LPCTSTR pcszFormatString, ...);
  165. VOID StopLogging();
  166. VOID LogDateAndTime();
  167. VOID LogFlags(DWORD dwFlags);