Source code of Windows XP (NT5)
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.

11066 lines
404 KiB

  1. #include "stdafx.h"
  2. #include "lzexpand.h"
  3. #include <loadperf.h>
  4. #include "setupapi.h"
  5. #include <ole2.h>
  6. #include <iis64.h>
  7. #include "iadmw.h"
  8. #include "iiscnfg.h"
  9. #include "mdkey.h"
  10. #include "mdentry.h"
  11. #include "mdacl.h"
  12. #include "dcomperm.h"
  13. #include "ocmanage.h"
  14. #include "log.h"
  15. #include "other.h"
  16. #include "kill.h"
  17. #include "strfn.h"
  18. #include "shellutl.h"
  19. #include "svc.h"
  20. #include "setuser.h"
  21. #include "wolfpack.h"
  22. #include <wbemcli.h>
  23. #include <direct.h>
  24. #include <aclapi.h>
  25. #include <wincrypt.h>
  26. #include <Dsgetdc.h>
  27. // for backward compat
  28. #define PWS_TRAY_WINDOW_CLASS _T("PWS_TRAY_WINDOW")
  29. GUID g_FTPGuid = { 0x91604620, 0x6305, 0x11ce, 0xae, 0x00, 0x00, 0xaa, 0x00, 0x4a, 0x38, 0xb9 };
  30. GUID g_HTTPGuid = { 0x585908c0, 0x6305, 0x11ce, 0xae, 0x00, 0x00, 0xaa, 0x00, 0x4a, 0x38, 0xb9 };
  31. GUID g_InetInfoGuid = { 0xa5569b20, 0xabe5, 0x11ce, 0x9c, 0xa4, 0x00, 0x00, 0x4c, 0x75, 0x27, 0x31 };
  32. GUID g_GopherGuid = { 0x62388f10, 0x58a2, 0x11ce, 0xbe, 0xc8, 0x00, 0xaa, 0x00, 0x47, 0xae, 0x4e };
  33. // guid stuff
  34. #define MY_DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) extern "C" const GUID name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
  35. #define MY_DEFINE_OLEGUID(name, l, w1, w2) MY_DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)
  36. MY_DEFINE_OLEGUID(IID_IPersistFile, 0x0000010b, 0, 0);
  37. // must be defined after the guid stuff
  38. #include "shlobj.h"
  39. extern int g_GlobalGuiOverRide;
  40. extern int g_GlobalTickValue;
  41. extern int g_CheckIfMetabaseValueWasWritten;
  42. extern HSPFILEQ g_GlobalFileQueueHandle;
  43. extern int g_GlobalFileQueueHandle_ReturnError;
  44. const TCHAR PARSE_ERROR_ENTRY_TO_BIG[] = _T("ProcessEntry_Entry:ParseError:%1!s!:%2!s! -- entry to big. FAIL.\n");
  45. const TCHAR csz101_NOT_SPECIFIED[] = _T("%s():101 Required for this 100 type and not specified, fail. entry=%s. Section=%s.\n");
  46. const TCHAR csz102_NOT_SPECIFIED[] = _T("%s():102 Required for this 100 type and not specified, fail. entry=%s. Section=%s.\n");
  47. const TCHAR csz103_NOT_SPECIFIED[] = _T("%s():103 Required for this 100 type and not specified, fail. entry=%s. Section=%s.\n");
  48. const TCHAR csz104_NOT_SPECIFIED[] = _T("%s():104 Required for this 100 type and not specified, fail. entry=%s. Section=%s.\n");
  49. const TCHAR csz105_NOT_SPECIFIED[] = _T("%s():105 Required for this 100 type and not specified, fail. entry=%s. Section=%s.\n");
  50. const TCHAR csz805_NOT_SPECIFIED[] = _T("%s():805 Required for this 100 type and not specified, fail. entry=%s. Section=%s.\n");
  51. typedef struct _MTS_ERROR_CODE_STRUCT
  52. {
  53. int iMtsThingWeWereDoing;
  54. DWORD dwErrorCode;
  55. } MTS_ERROR_CODE_STRUCT;
  56. MTS_ERROR_CODE_STRUCT gTempMTSError;
  57. const TCHAR ThingToDoNumType_100[] = _T("100=");
  58. const TCHAR ThingToDoNumType_101[] = _T("101=");
  59. const TCHAR ThingToDoNumType_102[] = _T("102=");
  60. const TCHAR ThingToDoNumType_103[] = _T("103=");
  61. const TCHAR ThingToDoNumType_104[] = _T("104=");
  62. const TCHAR ThingToDoNumType_105[] = _T("105=");
  63. const TCHAR ThingToDoNumType_106[] = _T("106=");
  64. const TCHAR ThingToDoNumType_200[] = _T("200=");
  65. const TCHAR ThingToDoNumType_701[] = _T("701=");
  66. const TCHAR ThingToDoNumType_702[] = _T("702=");
  67. const TCHAR ThingToDoNumType_703[] = _T("703=");
  68. const TCHAR ThingToDoNumType_801[] = _T("801=");
  69. const TCHAR ThingToDoNumType_802[] = _T("802=");
  70. const TCHAR ThingToDoNumType_803[] = _T("803=");
  71. const TCHAR ThingToDoNumType_804[] = _T("804=");
  72. const TCHAR ThingToDoNumType_805[] = _T("805=");
  73. typedef struct _ThingToDo {
  74. TCHAR szType[20];
  75. TCHAR szFileName[_MAX_PATH];
  76. TCHAR szData1[_MAX_PATH + _MAX_PATH];
  77. TCHAR szData2[_MAX_PATH];
  78. TCHAR szData3[_MAX_PATH];
  79. TCHAR szData4[_MAX_PATH];
  80. TCHAR szChangeDir[_MAX_PATH];
  81. TCHAR szOS[10];
  82. TCHAR szPlatformArchitecture[10];
  83. TCHAR szEnterprise[10];
  84. TCHAR szErrIfFileNotFound[10];
  85. TCHAR szMsgBoxBefore[10];
  86. TCHAR szMsgBoxAfter[10];
  87. TCHAR szDoNotDisplayErrIfFunctionFailed[10];
  88. TCHAR szProgressTitle[100];
  89. } ThingToDo;
  90. extern OCMANAGER_ROUTINES gHelperRoutines;
  91. extern int g_GlobalDebugLevelFlag;
  92. extern int g_GlobalDebugLevelFlag_WasSetByUnattendFile;
  93. extern int g_GlobalDebugCallValidateHeap;
  94. extern int g_GlobalDebugCrypto;
  95. extern int g_GlobalFastLoad;
  96. // Our Global List of Warnings to display after setup is completed.
  97. CStringList gcstrListOfWarnings;
  98. CStringList gcstrProgressBarTextStack;
  99. CStringList gcstrListOfOleInits;
  100. #define FUNCTION_PARAMS_NONE 0
  101. #define FUNCTION_PARAMS_HMODULE 1
  102. #define MAX_FAKE_METABASE_STRING_LEN 500
  103. LCID g_MyTrueThreadLocale;
  104. DWORD WINAPI GetNewlyCreatedThreadLocale(LPVOID lpParameter)
  105. {
  106. g_MyTrueThreadLocale = GetThreadLocale ();
  107. return 0;
  108. }
  109. int CheckForWriteAccess(LPCTSTR szFile)
  110. {
  111. int iReturn = FALSE;
  112. // check if the file exists
  113. // if it doesn't then return true!
  114. if (IsFileExist(szFile) != TRUE)
  115. {
  116. // we've got write access!
  117. return TRUE;
  118. }
  119. // try to open the file for write; if we can't, the file is read-only
  120. HANDLE hFile = CreateFile(szFile, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
  121. if (hFile != INVALID_HANDLE_VALUE)
  122. {
  123. // we've got write access!
  124. iReturn = TRUE;
  125. CloseHandle (hFile);
  126. }
  127. return iReturn;
  128. }
  129. /////////////////////////////////////////////////////////////////////////////
  130. //++
  131. // Return Value:
  132. // TRUE - the operating system is NTS Enterprise
  133. // FALSE - the operating system is not correct.
  134. //--
  135. /////////////////////////////////////////////////////////////////////////////
  136. int iReturnTrueIfEnterprise(void)
  137. {
  138. BOOL fReturnValue;
  139. OSVERSIONINFOEX osiv;
  140. ZeroMemory( &osiv, sizeof( OSVERSIONINFOEX ) );
  141. osiv.dwOSVersionInfoSize = sizeof( OSVERSIONINFOEX );
  142. osiv.dwMajorVersion = 5;
  143. osiv.dwMinorVersion = 0;
  144. osiv.wServicePackMajor = 0;
  145. osiv.wSuiteMask = VER_SUITE_ENTERPRISE;
  146. DWORDLONG dwlConditionMask;
  147. dwlConditionMask = (DWORDLONG) 0L;
  148. VER_SET_CONDITION( dwlConditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL );
  149. VER_SET_CONDITION( dwlConditionMask, VER_MINORVERSION, VER_GREATER_EQUAL );
  150. VER_SET_CONDITION( dwlConditionMask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL );
  151. VER_SET_CONDITION( dwlConditionMask, VER_SUITENAME, VER_AND );
  152. fReturnValue = VerifyVersionInfo( &osiv,VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SUITENAME,dwlConditionMask );
  153. if ( fReturnValue != (BOOL) TRUE )
  154. {
  155. DWORD dwErrorCode = GetLastError();
  156. }
  157. return ( fReturnValue );
  158. }
  159. void GlobalOleInitList_Push(int iTrueOrFalse)
  160. {
  161. if (FALSE == iTrueOrFalse)
  162. {
  163. gcstrListOfOleInits.AddTail(_T("TRUE"));
  164. }
  165. else
  166. {
  167. gcstrListOfOleInits.AddTail(_T("FALSE"));
  168. }
  169. return;
  170. }
  171. int GlobalOleInitList_Find(void)
  172. {
  173. if (gcstrListOfOleInits.IsEmpty() == TRUE)
  174. {
  175. return FALSE;
  176. }
  177. return TRUE;
  178. }
  179. int GlobalOleInitList_Pop(void)
  180. {
  181. CString csText;
  182. if (gcstrListOfOleInits.IsEmpty() == FALSE)
  183. {
  184. csText = gcstrListOfWarnings.RemoveTail();
  185. if (_tcsicmp(csText, _T("TRUE")) == 0)
  186. {
  187. return TRUE;
  188. }
  189. }
  190. return FALSE;
  191. }
  192. void ProgressBarTextStack_Push(CString csText)
  193. {
  194. gcstrListOfWarnings.AddTail(csText);
  195. if (gHelperRoutines.OcManagerContext)
  196. {
  197. gHelperRoutines.SetProgressText(gHelperRoutines.OcManagerContext,csText);
  198. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("SetProgressText = %s\n"),csText));
  199. }
  200. return;
  201. }
  202. void ProgressBarTextStack_Pop(void)
  203. {
  204. int iFoundLastEntry = FALSE;
  205. CString csText;
  206. // Get the last entry off of the stack and display it.
  207. if (gcstrListOfWarnings.IsEmpty() == FALSE)
  208. {
  209. csText = gcstrListOfWarnings.RemoveTail();
  210. if (gcstrListOfWarnings.IsEmpty() == FALSE)
  211. {
  212. csText = gcstrListOfWarnings.GetTail();
  213. if (csText)
  214. {
  215. iFoundLastEntry = TRUE;
  216. }
  217. }
  218. }
  219. if (iFoundLastEntry)
  220. {
  221. if (gHelperRoutines.OcManagerContext)
  222. {
  223. gHelperRoutines.SetProgressText(gHelperRoutines.OcManagerContext,csText);
  224. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("SetProgressText = %s\n"),csText));
  225. }
  226. }
  227. else
  228. {
  229. if (gHelperRoutines.OcManagerContext)
  230. {
  231. gHelperRoutines.SetProgressText(gHelperRoutines.OcManagerContext,_T(" "));
  232. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("SetProgressText = ' '\n")));
  233. }
  234. }
  235. return;
  236. }
  237. void ListOfWarnings_Add(TCHAR * szEntry)
  238. {
  239. //Add entry to the list of warnings if not already there
  240. if (_tcsicmp(szEntry, _T("")) != 0)
  241. {
  242. // Add it if it is not already there.
  243. if (TRUE != IsThisStringInThisCStringList(gcstrListOfWarnings, szEntry))
  244. {
  245. gcstrListOfWarnings.AddTail(szEntry);
  246. }
  247. }
  248. return;
  249. }
  250. void ListOfWarnings_Display(void)
  251. {
  252. if (gcstrListOfWarnings.IsEmpty() == FALSE)
  253. {
  254. iisDebugOut((LOG_TYPE_WARN, _T("************** WARNINGS START **************")));
  255. POSITION pos = NULL;
  256. CString csEntry;
  257. pos = gcstrListOfWarnings.GetHeadPosition();
  258. while (pos)
  259. {
  260. csEntry = gcstrListOfWarnings.GetAt(pos);
  261. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("%1!s!\n"), csEntry));
  262. gcstrListOfWarnings.GetNext(pos);
  263. }
  264. iisDebugOut((LOG_TYPE_WARN, _T("************** WARNINGS END **************")));
  265. }
  266. return;
  267. }
  268. int DebugLevelRegistryOveride(TCHAR * szSectionName, TCHAR * ValueName, int * iValueToSet)
  269. {
  270. int iReturn = FALSE;
  271. CRegKey regKey(HKEY_LOCAL_MACHINE, REG_INETSTP, KEY_READ);
  272. if ((HKEY)regKey)
  273. {
  274. // create the key to lookup
  275. // iis5_SectionName_ValueName
  276. // iis5_SetupInfo_
  277. if (szSectionName && ValueName)
  278. {
  279. TCHAR szTempRegString[255];
  280. DWORD dwValue = 0x0;
  281. _stprintf(szTempRegString, _T("IIS5:%s:%s"), szSectionName, ValueName);
  282. regKey.m_iDisplayWarnings = FALSE;
  283. if (regKey.QueryValue(szTempRegString, dwValue) == ERROR_SUCCESS)
  284. {
  285. if (dwValue <= 32000)
  286. {
  287. *iValueToSet = (int) dwValue;
  288. iReturn = TRUE;
  289. }
  290. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("RegistryINFValuesOveride:%s=%d."),szTempRegString, *iValueToSet));
  291. }
  292. }
  293. }
  294. return iReturn;
  295. }
  296. void GetDebugLevelFromInf(IN HINF hInfFileHandle)
  297. {
  298. int iTempDisplayLogging = FALSE;
  299. INFCONTEXT Context;
  300. TCHAR szTempString[10] = _T("");
  301. //
  302. // DebugLevel
  303. //
  304. if (!g_GlobalDebugLevelFlag_WasSetByUnattendFile)
  305. {
  306. iTempDisplayLogging = FALSE;
  307. g_GlobalDebugLevelFlag = LOG_TYPE_ERROR;
  308. if (SetupFindFirstLine_Wrapped(hInfFileHandle, _T("SetupInfo"), _T("DebugLevel"), &Context) )
  309. {
  310. SetupGetStringField(&Context, 1, szTempString, 10, NULL);
  311. if (IsValidNumber((LPCTSTR)szTempString))
  312. {
  313. g_GlobalDebugLevelFlag = _ttoi((LPCTSTR) szTempString);
  314. iTempDisplayLogging = TRUE;
  315. }
  316. if (g_GlobalDebugLevelFlag >= LOG_TYPE_TRACE_WIN32_API )
  317. {
  318. g_CheckIfMetabaseValueWasWritten = TRUE;
  319. }
  320. }
  321. if (DebugLevelRegistryOveride(_T("SetupInfo"), _T("DebugLevel"), &g_GlobalDebugLevelFlag))
  322. {iTempDisplayLogging = TRUE;}
  323. if (iTempDisplayLogging)
  324. {iisDebugOut((LOG_TYPE_TRACE, _T("DebugLevel=%d."),g_GlobalDebugLevelFlag));}
  325. }
  326. else
  327. {
  328. if (DebugLevelRegistryOveride(_T("SetupInfo"), _T("DebugLevel"), &g_GlobalDebugLevelFlag))
  329. {iTempDisplayLogging = TRUE;}
  330. if (iTempDisplayLogging)
  331. {iisDebugOut((LOG_TYPE_TRACE, _T("DebugLevel=%d."),g_GlobalDebugLevelFlag));}
  332. }
  333. //
  334. // DebugValidateHeap
  335. //
  336. iTempDisplayLogging = FALSE;
  337. g_GlobalDebugCallValidateHeap = TRUE;
  338. if (SetupFindFirstLine_Wrapped(hInfFileHandle, _T("SetupInfo"), _T("DebugValidateHeap"), &Context) )
  339. {
  340. SetupGetStringField(&Context, 1, szTempString, 10, NULL);
  341. if (IsValidNumber((LPCTSTR)szTempString))
  342. {
  343. g_GlobalDebugCallValidateHeap = _ttoi((LPCTSTR) szTempString);
  344. iTempDisplayLogging = TRUE;
  345. }
  346. }
  347. if (DebugLevelRegistryOveride(_T("SetupInfo"), _T("DebugValidateHeap"), &g_GlobalDebugCallValidateHeap))
  348. {iTempDisplayLogging = TRUE;}
  349. if (iTempDisplayLogging)
  350. {iisDebugOut((LOG_TYPE_TRACE, _T("DebugValidateHeap=%d."),g_GlobalDebugCallValidateHeap));}
  351. //
  352. // DebugCrypto
  353. //
  354. iTempDisplayLogging = FALSE;
  355. g_GlobalDebugCrypto = 0;
  356. if (SetupFindFirstLine_Wrapped(hInfFileHandle, _T("SetupInfo"), _T("DebugCrypto"), &Context) )
  357. {
  358. SetupGetStringField(&Context, 1, szTempString, 10, NULL);
  359. if (IsValidNumber((LPCTSTR)szTempString))
  360. {
  361. g_GlobalDebugCrypto = _ttoi((LPCTSTR) szTempString);
  362. iTempDisplayLogging = TRUE;
  363. }
  364. }
  365. if (DebugLevelRegistryOveride(_T("SetupInfo"), _T("DebugCrypto"), &g_GlobalDebugCrypto))
  366. {iTempDisplayLogging = TRUE;}
  367. if (iTempDisplayLogging)
  368. {iisDebugOut((LOG_TYPE_TRACE, _T("DebugCrypto=%d."),g_GlobalDebugCrypto));}
  369. //
  370. // FastDllInit
  371. //
  372. iTempDisplayLogging = FALSE;
  373. g_GlobalFastLoad = FALSE;
  374. if (SetupFindFirstLine_Wrapped(hInfFileHandle, _T("SetupInfo"), _T("FastDllInit"), &Context) )
  375. {
  376. SetupGetStringField(&Context, 1, szTempString, 10, NULL);
  377. if (IsValidNumber((LPCTSTR)szTempString))
  378. {
  379. g_GlobalFastLoad = _ttoi((LPCTSTR) szTempString);
  380. iTempDisplayLogging = TRUE;
  381. }
  382. }
  383. if (DebugLevelRegistryOveride(_T("SetupInfo"), _T("FastDllInit"), &g_GlobalFastLoad))
  384. {iTempDisplayLogging = TRUE;}
  385. if (iTempDisplayLogging)
  386. {iisDebugOut((LOG_TYPE_TRACE, _T("GlobalFastLoad=%d."),g_GlobalFastLoad));}
  387. //
  388. // Check if we should display messagebox popups
  389. //
  390. iTempDisplayLogging = FALSE;
  391. if (SetupFindFirstLine_Wrapped(hInfFileHandle, _T("SetupInfo"), _T("DisplayMsgbox"), &Context) )
  392. {
  393. SetupGetStringField(&Context, 1, szTempString, 10, NULL);
  394. if (IsValidNumber((LPCTSTR)szTempString))
  395. {
  396. int iTempNum = 0;
  397. iTempNum = _ttoi((LPCTSTR) szTempString);
  398. if (iTempNum > 0)
  399. {
  400. g_pTheApp->m_bAllowMessageBoxPopups = TRUE;
  401. iTempDisplayLogging = TRUE;
  402. }
  403. }
  404. }
  405. if (DebugLevelRegistryOveride(_T("SetupInfo"), _T("DisplayMsgbox"), &g_pTheApp->m_bAllowMessageBoxPopups))
  406. {iTempDisplayLogging = TRUE;}
  407. if (iTempDisplayLogging)
  408. {iisDebugOut((LOG_TYPE_TRACE, _T("DisplayMsgbox=%d."),g_pTheApp->m_bAllowMessageBoxPopups));}
  409. return;
  410. }
  411. //****************************************************************************
  412. //*
  413. //* This routine will center a dialog in the active windows.
  414. //*
  415. //* ENTRY:
  416. //* hwndDlg - Dialog window.
  417. //*
  418. //****************************************************************************
  419. void uiCenterDialog( HWND hwndDlg )
  420. {
  421. RECT rc;
  422. RECT rcScreen;
  423. int x, y;
  424. int cxDlg, cyDlg;
  425. int cxScreen;
  426. int cyScreen;
  427. SystemParametersInfo(SPI_GETWORKAREA, 0, &rcScreen, 0);
  428. cxScreen = rcScreen.right - rcScreen.left;
  429. cyScreen = rcScreen.bottom - rcScreen.top;
  430. GetWindowRect(hwndDlg,&rc);
  431. x = rc.left; // Default is to leave the dialog where the template
  432. y = rc.top; // was going to place it.
  433. cxDlg = rc.right - rc.left;
  434. cyDlg = rc.bottom - rc.top;
  435. y = rcScreen.top + ((cyScreen - cyDlg) / 2);
  436. x = rcScreen.left + ((cxScreen - cxDlg) / 2);
  437. // Position the dialog.
  438. SetWindowPos(hwndDlg, NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE);
  439. }
  440. /*
  441. //***************************************************************************
  442. //* *
  443. //* SYNOPSIS: Checks if a specific key in the given section and given file*
  444. //* is defined. IF so, get the value. OW return -1 *
  445. //* *
  446. //***************************************************************************
  447. DWORD IsMyKeyExists( LPCTSTR lpSec, LPCTSTR lpKey, LPTSTR lpBuf, UINT uSize, LPCTSTR lpFile )
  448. {
  449. DWORD dwRet;
  450. dwRet = GetPrivateProfileString( lpSec, lpKey, "ZZZZZZ", lpBuf, uSize, lpFile );
  451. if ( !lstrcmp( lpBuf, "ZZZZZZ" ) )
  452. {
  453. // no key defined
  454. dwRet = (DWORD)(-1);
  455. }
  456. return dwRet;
  457. }
  458. //***************************************************************************
  459. //
  460. // FormStrWithoutPlaceHolders( LPTSTR szDst, LPCTSTR szSrc, LPCTSTR lpFile );
  461. //
  462. // This function can be easily described by giving examples of what it
  463. // does:
  464. // Input: GenFormStrWithoutPlaceHolders(dest,"desc=%MS_XYZ%", hinf) ;
  465. // INF file has MS_VGA="Microsoft XYZ" in its [Strings] section!
  466. //
  467. // Output: "desc=Microsoft XYZ" in buffer dest when done.
  468. //
  469. //
  470. // ENTRY:
  471. // szDst - the destination where the string after the substitutions
  472. // for the place holders (the ones enclosed in "%' chars!)
  473. // is placed. This buffer should be big enough (LINE_LEN)
  474. // szSrc - the string with the place holders.
  475. //
  476. // EXIT:
  477. //
  478. // NOTES:
  479. // To use a '%' as such in the string, one would use %% in szSrc!
  480. // For the sake of simplicity, we have placed a restriction that the place
  481. // holder name string cannot have a '%' as part of it! If this is a problem
  482. // for internationalization, we can revisit this and support it too! Also,
  483. // the way it is implemented, if there is only one % in the string, it is
  484. // also used as such! Another point to note is that if the key is not
  485. // found in the [Strings] section, we just use the %strkey% as such in the
  486. // destination. This should really help in debugging.
  487. //
  488. // Get/modified it from setupx: gen1.c
  489. //***************************************************************************
  490. DWORD FormStrWithoutPlaceHolders( LPTSTR szDst, LPCTSTR szSrc, LPCTSTR lpFile)
  491. {
  492. int uCnt ;
  493. DWORD dwRet;
  494. TCHAR *pszTmp;
  495. LPTSTR pszSaveDst;
  496. pszSaveDst = szDst;
  497. // Do until we reach the end of source (null char)
  498. while( (*szDst++ = *szSrc) )
  499. {
  500. // Increment source as we have only incremented destination above
  501. if(*szSrc++ == '%')
  502. {
  503. if (*szSrc == '%')
  504. {
  505. // One can use %% to get a single percentage char in message
  506. szSrc++ ;
  507. continue ;
  508. }
  509. // see if it is well formed -- there should be a '%' delimiter
  510. if ( (pszTmp = strchr( szSrc, '%')) != NULL )
  511. {
  512. szDst--; // get back to the '%' char to replace
  513. // yes, there is a STR_KEY to be looked for in [Strings] sect.
  514. *pszTmp = '\0' ; // replace '%' with a NULL char
  515. dwRet = IsMyKeyExists( _T("Strings"), szSrc, szDst, _MAX_PATH, lpFile );
  516. if ( dwRet == -1 )
  517. {
  518. *pszTmp = '%'; // put back original character
  519. szSrc-- ; // get back to first '%' in Src
  520. uCnt = DIFF(pszTmp - szSrc) + 1; // include 2nd '%'
  521. // UGHHH... It copies 1 less byte from szSrc so that it can put
  522. // in a NULL character, that I don't care about!!!
  523. // Different from the normal API I am used to...
  524. lstrcpyn( szDst, szSrc, uCnt + 1 ) ;
  525. return (DWORD)-1;
  526. }
  527. else
  528. {
  529. // all was well, Dst filled right, but unfortunately count not passed
  530. // back, like it used too... :-( quick fix is a lstrlen()...
  531. uCnt = lstrlen( szDst ) ;
  532. }
  533. *pszTmp = '%' ; // put back original character
  534. szSrc = pszTmp + 1 ; // set Src after the second '%'
  535. szDst += uCnt ; // set Dst also right.
  536. }
  537. // else it is ill-formed -- we use the '%' as such!
  538. else
  539. {
  540. return (DWORD)-1;
  541. }
  542. }
  543. } // while
  544. return (DWORD)lstrlen(pszSaveDst);
  545. }
  546. */
  547. void LogImportantFiles(void)
  548. {
  549. TCHAR buf[_MAX_PATH];
  550. if (g_pTheApp->m_hInfHandle)
  551. {
  552. LogFileVersionsForGroupOfSections(g_pTheApp->m_hInfHandle);
  553. }
  554. // display current files in inetsrv date/version.
  555. CString csTempPath = g_pTheApp->m_csPathInetsrv;
  556. LogFilesInThisDir(csTempPath);
  557. // display the setup iis.dll file
  558. GetSystemDirectory( buf, _MAX_PATH);
  559. csTempPath = buf;
  560. csTempPath = AddPath(csTempPath, _T("iis.dll"));
  561. LogFileVersion(csTempPath, TRUE);
  562. return;
  563. }
  564. #ifndef _CHICAGO_
  565. int CreateIUSRAccount(CString csUsername, CString csPassword, INT* piNewlyCreatedUser)
  566. {
  567. int err;
  568. CString csComment, csFullName;
  569. INT iUserWasDeleted = 0;
  570. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("CreateIUSRAccount(): %1!s!\n"), csUsername));
  571. // delete the old user first
  572. //DeleteGuestUser((LPTSTR)(LPCTSTR)csUsername,&iUserWasDeleted);
  573. // create the new user
  574. MyLoadString(IDS_USER_COMMENT, csComment);
  575. MyLoadString(IDS_USER_FULLNAME, csFullName);
  576. // Create user either returns NERR_Success or err code
  577. err = CreateUser(csUsername, csPassword, csComment, csFullName, FALSE, piNewlyCreatedUser);
  578. if (err == NERR_Success)
  579. {iisDebugOut((LOG_TYPE_TRACE, _T("CreateIUSRAccount(): Return 0x%x Suceess\n"), err));}
  580. else
  581. {
  582. iisDebugOut((LOG_TYPE_ERROR, _T("CreateIUSRAccount(): Return Err=0x%x FAILURE. deleting and retrying.\n"), err));
  583. // try to delete it first then create it.
  584. DeleteGuestUser((LPTSTR)(LPCTSTR)csUsername,&iUserWasDeleted);
  585. err = CreateUser(csUsername, csPassword, csComment, csFullName, FALSE, piNewlyCreatedUser);
  586. iisDebugOut((LOG_TYPE_TRACE, _T("CreateIUSRAccount(): Return 0x%x\n"), err));
  587. }
  588. return err;
  589. }
  590. int CreateIWAMAccount(CString csUsername, CString csPassword,INT* piNewlyCreatedUser)
  591. {
  592. int err;
  593. CString csComment, csFullName;
  594. INT iUserWasDeleted = 0;
  595. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("CreateIWAMAccount(): %1!s!\n"), csUsername));
  596. //iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("CreateIWAMAccount(): %1!s!\n"), csPassword));
  597. // delete the old user first
  598. //DeleteGuestUser((LPTSTR)(LPCTSTR)csUsername,&iUserWasDeleted);
  599. // create the new user
  600. MyLoadString(IDS_WAMUSER_COMMENT, csComment);
  601. MyLoadString(IDS_WAMUSER_FULLNAME, csFullName);
  602. // Create user either returns NERR_Success or err code
  603. err = CreateUser(csUsername, csPassword, csComment, csFullName, TRUE, piNewlyCreatedUser);
  604. if (err == NERR_Success)
  605. {iisDebugOut((LOG_TYPE_TRACE, _T("CreateIWAMAccount(): Return 0x%x Suceess\n"), err));}
  606. else
  607. {
  608. iisDebugOut((LOG_TYPE_ERROR, _T("CreateIWAMAccount(): Return Err=0x%x FAILURE. deleting and retrying.\n"), err));
  609. // try to delete it first then create it.
  610. DeleteGuestUser((LPTSTR)(LPCTSTR)csUsername,&iUserWasDeleted);
  611. err = CreateUser(csUsername, csPassword, csComment, csFullName, TRUE, piNewlyCreatedUser);
  612. iisDebugOut((LOG_TYPE_TRACE, _T("CreateIWAMAccount(): Return 0x%x\n"), err));
  613. }
  614. return err;
  615. }
  616. #endif //_CHICAGO_
  617. INT InstallPerformance(CString nlsRegPerf,CString nlsDll,CString nlsOpen,CString nlsClose,CString nlsCollect )
  618. {
  619. iisDebugOut_Start1(_T("InstallPerformance"),nlsDll);
  620. INT err = NERR_Success;
  621. if (g_pTheApp->m_eOS != OS_W95)
  622. {
  623. CRegKey regPerf( nlsRegPerf, HKEY_LOCAL_MACHINE );
  624. if (regPerf)
  625. {
  626. regPerf.SetValue(_T("Library"), nlsDll );
  627. regPerf.SetValue(_T("Open"), nlsOpen );
  628. regPerf.SetValue(_T("Close"), nlsClose );
  629. regPerf.SetValue(_T("Collect"), nlsCollect );
  630. }
  631. }
  632. iisDebugOut_End1(_T("InstallPerformance"),nlsDll);
  633. return(err);
  634. }
  635. //
  636. // Add eventlog to the registry
  637. //
  638. INT AddEventLog(BOOL fSystem, CString nlsService, CString nlsMsgFile, DWORD dwType)
  639. {
  640. iisDebugOut_Start1(_T("AddEventLog"),nlsMsgFile);
  641. INT err = NERR_Success;
  642. CString nlsLog = (fSystem)? REG_EVENTLOG_SYSTEM : REG_EVENTLOG_APPLICATION;
  643. nlsLog += _T("\\");
  644. nlsLog += nlsService;
  645. CRegKey regService( nlsLog, HKEY_LOCAL_MACHINE );
  646. if ( regService )
  647. {
  648. regService.SetValue( _T("EventMessageFile"), nlsMsgFile, TRUE );
  649. regService.SetValue( _T("TypesSupported"), dwType );
  650. }
  651. iisDebugOut_End1(_T("AddEventLog"),nlsMsgFile);
  652. return(err);
  653. }
  654. //
  655. // Remove eventlog from the registry
  656. //
  657. INT RemoveEventLog( BOOL fSystem, CString nlsService )
  658. {
  659. iisDebugOut_Start1(_T("RemoveEventLog"),nlsService);
  660. INT err = NERR_Success;
  661. CString nlsLog = (fSystem)? REG_EVENTLOG_SYSTEM : REG_EVENTLOG_APPLICATION;
  662. CRegKey regService( HKEY_LOCAL_MACHINE, nlsLog );
  663. if ( regService )
  664. {
  665. regService.DeleteTree( nlsService );
  666. }
  667. iisDebugOut_End1(_T("RemoveEventLog"),nlsService);
  668. return(err);
  669. }
  670. //
  671. // Install SNMP agent to the registry
  672. //
  673. INT InstallAgent( CString nlsName, CString nlsPath )
  674. {
  675. iisDebugOut_Start1(_T("InstallAgent"),nlsPath);
  676. INT err = NERR_Success;
  677. do
  678. {
  679. CString nlsSnmpParam = REG_SNMPPARAMETERS;
  680. CRegKey regSnmpParam( HKEY_LOCAL_MACHINE, nlsSnmpParam );
  681. if ( regSnmpParam == (HKEY)NULL )
  682. break;
  683. CString nlsSoftwareMSFT = _T("Software\\Microsoft");
  684. CRegKey regSoftwareMSFT( HKEY_LOCAL_MACHINE, nlsSoftwareMSFT );
  685. if ( (HKEY) NULL == regSoftwareMSFT )
  686. break;
  687. // add agent key
  688. CRegKey regAgent( nlsName, regSoftwareMSFT );
  689. if ( (HKEY) NULL == regAgent )
  690. break;
  691. CString nlsCurVersion = _T("CurrentVersion");
  692. CRegKey regAgentCurVersion( nlsCurVersion, regAgent );
  693. if ((HKEY) NULL == regAgentCurVersion )
  694. break;
  695. regAgentCurVersion.SetValue(_T("Pathname"), nlsPath );
  696. CRegKey regAgentParam( nlsName, regSnmpParam );
  697. if ((HKEY) NULL == regAgentParam )
  698. break;
  699. CString nlsSnmpExt = REG_SNMPEXTAGENT;
  700. CRegKey regSnmpExt( nlsSnmpExt, HKEY_LOCAL_MACHINE );
  701. if ((HKEY) NULL == regSnmpExt )
  702. break;
  703. // find the first available number slot
  704. for ( INT i=0; ;i++ )
  705. {
  706. CString nlsPos;
  707. nlsPos.Format( _T("%d"),i);
  708. CString nlsValue;
  709. if ( regSnmpExt.QueryValue( nlsPos, nlsValue ) != NERR_Success )
  710. {
  711. // okay, an empty spot
  712. nlsValue.Format(_T("%s\\%s\\%s"),_T("Software\\Microsoft"),(LPCTSTR)nlsName,_T("CurrentVersion") );
  713. regSnmpExt.SetValue( nlsPos, nlsValue );
  714. break;
  715. } else
  716. {
  717. if ( nlsValue.Find( nlsName) != (-1))
  718. {
  719. break;
  720. }
  721. }
  722. }
  723. } while (FALSE);
  724. iisDebugOut_End1(_T("InstallAgent"),nlsPath);
  725. return(err);
  726. }
  727. //
  728. // Remove an SNMP agent from the registry
  729. //
  730. INT RemoveAgent( CString nlsServiceName )
  731. {
  732. iisDebugOut_Start1(_T("RemoveAgent"),nlsServiceName);
  733. INT err = NERR_Success;
  734. do
  735. {
  736. CString nlsSoftwareAgent = _T("Software\\Microsoft");
  737. CRegKey regSoftwareAgent( HKEY_LOCAL_MACHINE, nlsSoftwareAgent );
  738. if ((HKEY)NULL == regSoftwareAgent )
  739. break;
  740. regSoftwareAgent.DeleteTree( nlsServiceName );
  741. CString nlsSnmpParam = REG_SNMPPARAMETERS;
  742. CRegKey regSnmpParam( HKEY_LOCAL_MACHINE, nlsSnmpParam );
  743. if ((HKEY) NULL == regSnmpParam )
  744. break;
  745. regSnmpParam.DeleteTree( nlsServiceName );
  746. CString nlsSnmpExt = REG_SNMPEXTAGENT;
  747. CRegKey regSnmpExt( HKEY_LOCAL_MACHINE, nlsSnmpExt );
  748. if ((HKEY) NULL == regSnmpExt )
  749. break;
  750. CRegValueIter enumSnmpExt( regSnmpExt );
  751. CString strName;
  752. DWORD dwType;
  753. CString csServiceName;
  754. csServiceName = _T("\\") + nlsServiceName;
  755. csServiceName += _T("\\");
  756. while ( enumSnmpExt.Next( &strName, &dwType ) == NERR_Success )
  757. {
  758. CString nlsValue;
  759. regSnmpExt.QueryValue( strName, nlsValue );
  760. if ( nlsValue.Find( csServiceName ) != (-1))
  761. {
  762. // found it
  763. regSnmpExt.DeleteValue( (LPCTSTR)strName );
  764. break;
  765. }
  766. }
  767. } while (FALSE);
  768. iisDebugOut_End1(_T("RemoveAgent"),nlsServiceName);
  769. return(err);
  770. }
  771. void lodctr(LPCTSTR lpszIniFile)
  772. {
  773. #ifndef _CHICAGO_
  774. iisDebugOut_Start1(_T("lodctr"),lpszIniFile);
  775. CString csCmdLine = _T("lodctr ");
  776. csCmdLine += g_pTheApp->m_csSysDir;
  777. csCmdLine += _T("\\");
  778. csCmdLine += lpszIniFile;
  779. iisDebugOut_Start((_T("loadperf.dll:LoadPerfCounterTextStrings")));
  780. LoadPerfCounterTextStrings((LPTSTR)(LPCTSTR)csCmdLine, TRUE);
  781. iisDebugOut_End((_T("loadperf.dll:LoadPerfCounterTextStrings")));
  782. iisDebugOut_End1(_T("lodctr"),lpszIniFile);
  783. #endif
  784. return;
  785. }
  786. void unlodctr(LPCTSTR lpszDriver)
  787. {
  788. #ifndef _CHICAGO_
  789. iisDebugOut_Start1(_T("unlodctr"),lpszDriver);
  790. CString csCmdLine = _T("unlodctr ");
  791. csCmdLine += lpszDriver;
  792. iisDebugOut_Start(_T("loadperf.dll:UnloadPerfCounterTextStrings"));
  793. UnloadPerfCounterTextStrings((LPTSTR)(LPCTSTR)csCmdLine, TRUE);
  794. iisDebugOut_End((_T("loadperf.dll:UnloadPerfCounterTextStrings")));
  795. iisDebugOut_End1(_T("unlodctr"),lpszDriver);
  796. #endif
  797. return;
  798. }
  799. typedef void (*P_SslGenerateRandomBits)( PUCHAR pRandomData, LONG size );
  800. P_SslGenerateRandomBits ProcSslGenerateRandomBits = NULL;
  801. BOOL GenRandom(int *lpGoop, DWORD cbGoop)
  802. {
  803. BOOL fRet = FALSE;
  804. HCRYPTPROV hProv = 0;
  805. if (::CryptAcquireContext(&hProv,NULL,NULL,PROV_RSA_FULL,CRYPT_VERIFYCONTEXT))
  806. if (::CryptGenRandom(hProv,cbGoop,(BYTE *) lpGoop))
  807. {
  808. fRet = TRUE;
  809. }
  810. if (hProv) ::CryptReleaseContext(hProv,0);
  811. return fRet;
  812. }
  813. int GetRandomNum(void)
  814. {
  815. int RandomNum;
  816. UCHAR cRandomByte;
  817. RandomNum = rand();
  818. __try
  819. {
  820. // call the random number function
  821. if (!GenRandom(& RandomNum,1))
  822. {
  823. // if that fails then try this one...
  824. if ( ProcSslGenerateRandomBits != NULL )
  825. {
  826. (*ProcSslGenerateRandomBits)( &cRandomByte, 1 );
  827. RandomNum = cRandomByte;
  828. }
  829. }
  830. }
  831. __except(EXCEPTION_EXECUTE_HANDLER)
  832. {
  833. iisDebugOut((LOG_TYPE_WARN, _T("nException Caught in SCHANNEL.dll:ProcSslGenerateRandomBits()=0x%x.."),GetExceptionCode()));
  834. }
  835. return(RandomNum);
  836. }
  837. void ShuffleCharArray(int iSizeOfTheArray, TCHAR * lptsTheArray)
  838. {
  839. int i;
  840. int iTotal;
  841. int RandomNum;
  842. iTotal = iSizeOfTheArray / sizeof(_TCHAR);
  843. for (i=0; i<iTotal;i++ )
  844. {
  845. // shuffle the array
  846. RandomNum=GetRandomNum();
  847. TCHAR c = lptsTheArray[i];
  848. lptsTheArray[i]=lptsTheArray[RandomNum%iTotal];
  849. lptsTheArray[RandomNum%iTotal]=c;
  850. }
  851. return;
  852. }
  853. // password categories
  854. enum {STRONG_PWD_UPPER=0,
  855. STRONG_PWD_LOWER,
  856. STRONG_PWD_NUM,
  857. STRONG_PWD_PUNC};
  858. #define STRONG_PWD_CATS (STRONG_PWD_PUNC + 1)
  859. #define NUM_LETTERS 26
  860. #define NUM_NUMBERS 10
  861. #define MIN_PWD_LEN 8
  862. // password must contain at least one each of:
  863. // uppercase, lowercase, punctuation and numbers
  864. DWORD CreateGoodPassword(BYTE *szPwd, DWORD dwLen) {
  865. if (dwLen-1 < MIN_PWD_LEN)
  866. return ERROR_PASSWORD_RESTRICTION;
  867. HCRYPTPROV hProv;
  868. DWORD dwErr = 0;
  869. if (CryptAcquireContext(&hProv,NULL,NULL,PROV_RSA_FULL,CRYPT_VERIFYCONTEXT) == FALSE)
  870. return GetLastError();
  871. // zero it out and decrement the size to allow for trailing '\0'
  872. ZeroMemory(szPwd,dwLen);
  873. dwLen--;
  874. // generate a pwd pattern, each byte is in the range
  875. // (0..255) mod STRONG_PWD_CATS
  876. // this indicates which character pool to take a char from
  877. BYTE *pPwdPattern = new BYTE[dwLen];
  878. BOOL fFound[STRONG_PWD_CATS];
  879. do {
  880. // bug!bug! does CGR() ever fail?
  881. CryptGenRandom(hProv,dwLen,pPwdPattern);
  882. fFound[STRONG_PWD_UPPER] =
  883. fFound[STRONG_PWD_LOWER] =
  884. fFound[STRONG_PWD_PUNC] =
  885. fFound[STRONG_PWD_NUM] = FALSE;
  886. for (DWORD i=0; i < dwLen; i++)
  887. fFound[pPwdPattern[i] % STRONG_PWD_CATS] = TRUE;
  888. #ifdef _DEBUG
  889. if (!fFound[STRONG_PWD_UPPER] ||
  890. !fFound[STRONG_PWD_LOWER] ||
  891. !fFound[STRONG_PWD_PUNC] ||
  892. !fFound[STRONG_PWD_NUM]) {
  893. iisDebugOut((LOG_TYPE_TRACE,_T("Oops! Regen pattern required [%d, %d, %d, %d]\n"),
  894. fFound[STRONG_PWD_UPPER],
  895. fFound[STRONG_PWD_LOWER],
  896. fFound[STRONG_PWD_PUNC],
  897. fFound[STRONG_PWD_NUM]));
  898. }
  899. #endif
  900. // check that each character category is in the pattern
  901. } while (!fFound[STRONG_PWD_UPPER] ||
  902. !fFound[STRONG_PWD_LOWER] ||
  903. !fFound[STRONG_PWD_PUNC] ||
  904. !fFound[STRONG_PWD_NUM]);
  905. // populate password with random data
  906. // this, in conjunction with pPwdPattern, is
  907. // used to determine the actual data
  908. CryptGenRandom(hProv,dwLen,szPwd);
  909. for (DWORD i=0; i < dwLen; i++) {
  910. BYTE bChar = 0;
  911. // there is a bias in each character pool because of the % function
  912. switch (pPwdPattern[i] % STRONG_PWD_CATS) {
  913. case STRONG_PWD_UPPER : bChar = 'A' + szPwd[i] % NUM_LETTERS;
  914. break;
  915. case STRONG_PWD_LOWER : bChar = 'a' + szPwd[i] % NUM_LETTERS;
  916. break;
  917. case STRONG_PWD_NUM : bChar = '0' + szPwd[i] % NUM_NUMBERS;
  918. break;
  919. case STRONG_PWD_PUNC :
  920. default: char *szPunc="!@#$%^&*()_-+=[{]};:\'\"<>,./?\\|~`";
  921. DWORD dwLenPunc = lstrlenA(szPunc);
  922. bChar = szPunc[szPwd[i] % dwLenPunc];
  923. break;
  924. }
  925. szPwd[i] = bChar;
  926. #ifdef _DEBUG
  927. iisDebugOut((LOG_TYPE_TRACE,_T("[%03d] Pattern is %d, index is %d, char is '%c'\n"),i,pPwdPattern[i] % STRONG_PWD_CATS,szPwd[i],bChar));
  928. #endif
  929. }
  930. delete pPwdPattern;
  931. if (hProv != NULL)
  932. CryptReleaseContext(hProv,0);
  933. return dwErr;
  934. }
  935. //
  936. // Create a random password
  937. //
  938. void CreatePasswordOld(TCHAR *pszPassword, int iSize)
  939. {
  940. //
  941. // Use Maximum available password length, as
  942. // setting any other length might run afoul
  943. // of the minimum password length setting
  944. //
  945. int nLength = (iSize - 1);
  946. int iTotal = 0;
  947. int RandomNum = 0;
  948. int i;
  949. TCHAR six2pr[64] =
  950. {
  951. _T('A'), _T('B'), _T('C'), _T('D'), _T('E'), _T('F'), _T('G'), _T('H'), _T('I'), _T('J'), _T('K'), _T('L'), _T('M'),
  952. _T('N'), _T('O'), _T('P'), _T('Q'), _T('R'), _T('S'), _T('T'), _T('U'), _T('V'), _T('W'), _T('X'), _T('Y'), _T('Z'),
  953. _T('a'), _T('b'), _T('c'), _T('d'), _T('e'), _T('f'), _T('g'), _T('h'), _T('i'), _T('j'), _T('k'), _T('l'), _T('m'),
  954. _T('n'), _T('o'), _T('p'), _T('q'), _T('r'), _T('s'), _T('t'), _T('u'), _T('v'), _T('w'), _T('x'), _T('y'), _T('z'),
  955. _T('0'), _T('1'), _T('2'), _T('3'), _T('4'), _T('5'), _T('6'), _T('7'), _T('8'), _T('9'), _T('*'), _T('_')
  956. };
  957. // create a random password
  958. ProcSslGenerateRandomBits = NULL;
  959. HINSTANCE hSslDll = LoadLibraryEx(_T("schannel.dll"), NULL, 0 );
  960. if ( hSslDll )
  961. {
  962. ProcSslGenerateRandomBits = (P_SslGenerateRandomBits)GetProcAddress( hSslDll, "SslGenerateRandomBits");
  963. }
  964. else
  965. {
  966. // check if this file has missing file it's supposed to be linked with.
  967. // or if the file has mismatched import\export dependencies with linked files.
  968. #ifdef _WIN64
  969. // don't call cause it's broken
  970. #else
  971. //Check_File_Dependencies(_T("schannel.dll"));
  972. #endif
  973. }
  974. // See the random number generation for rand() call in GetRandomNum()
  975. time_t timer;
  976. time( &timer );
  977. srand( (unsigned int) timer );
  978. // shuffle around the global six2pr[] array
  979. ShuffleCharArray(sizeof(six2pr), (TCHAR*) &six2pr);
  980. // assign each character of the password array
  981. iTotal = sizeof(six2pr) / sizeof(_TCHAR);
  982. for ( i=0;i<nLength;i++ )
  983. {
  984. RandomNum=GetRandomNum();
  985. pszPassword[i]=six2pr[RandomNum%iTotal];
  986. }
  987. //
  988. // in order to meet a possible
  989. // policy set upon passwords..
  990. //
  991. // replace the last 4 chars with these:
  992. //
  993. // 1) something from !@#$%^&*()-+=
  994. // 2) something from 1234567890
  995. // 3) an uppercase letter
  996. // 4) a lowercase letter
  997. //
  998. TCHAR something1[12] = {_T('!'), _T('@'), _T('#'), _T('$'), _T('^'), _T('&'), _T('*'), _T('('), _T(')'), _T('-'), _T('+'), _T('=')};
  999. ShuffleCharArray(sizeof(something1), (TCHAR*) &something1);
  1000. TCHAR something2[10] = {_T('0'), _T('1'), _T('2'), _T('3'), _T('4'), _T('5'), _T('6'), _T('7'), _T('8'), _T('9')};
  1001. ShuffleCharArray(sizeof(something2),(TCHAR*) &something2);
  1002. TCHAR something3[26] = {_T('A'), _T('B'), _T('C'), _T('D'), _T('E'), _T('F'), _T('G'), _T('H'), _T('I'), _T('J'), _T('K'), _T('L'), _T('M'), _T('N'), _T('O'), _T('P'), _T('Q'), _T('R'), _T('S'), _T('T'), _T('U'), _T('V'), _T('W'), _T('X'), _T('Y'), _T('Z')};
  1003. ShuffleCharArray(sizeof(something3),(TCHAR*) &something3);
  1004. TCHAR something4[26] = {_T('a'), _T('b'), _T('c'), _T('d'), _T('e'), _T('f'), _T('g'), _T('h'), _T('i'), _T('j'), _T('k'), _T('l'), _T('m'), _T('n'), _T('o'), _T('p'), _T('q'), _T('r'), _T('s'), _T('t'), _T('u'), _T('v'), _T('w'), _T('x'), _T('y'), _T('z')};
  1005. ShuffleCharArray(sizeof(something4),(TCHAR*)&something4);
  1006. RandomNum=GetRandomNum();
  1007. iTotal = sizeof(something1) / sizeof(_TCHAR);
  1008. pszPassword[nLength-4]=something1[RandomNum%iTotal];
  1009. RandomNum=GetRandomNum();
  1010. iTotal = sizeof(something2) / sizeof(_TCHAR);
  1011. pszPassword[nLength-3]=something2[RandomNum%iTotal];
  1012. RandomNum=GetRandomNum();
  1013. iTotal = sizeof(something3) / sizeof(_TCHAR);
  1014. pszPassword[nLength-2]=something3[RandomNum%iTotal];
  1015. RandomNum=GetRandomNum();
  1016. iTotal = sizeof(something4) / sizeof(_TCHAR);
  1017. pszPassword[nLength-1]=something4[RandomNum%iTotal];
  1018. pszPassword[nLength]=_T('\0');
  1019. if (hSslDll)
  1020. {FreeLibrary( hSslDll );}
  1021. }
  1022. // Creates a secure password
  1023. // caller must GlobalFree Return pointer
  1024. // iSize = size of password to create
  1025. LPTSTR CreatePassword(int iSize)
  1026. {
  1027. LPTSTR pszPassword = NULL;
  1028. BYTE *szPwd = new BYTE[iSize];
  1029. DWORD dwPwdLen = iSize;
  1030. int i = 0;
  1031. // use the new secure password generator
  1032. // unfortunately this baby doesn't use unicode.
  1033. // so we'll call it and then convert it to unicode afterwards.
  1034. if (0 == CreateGoodPassword(szPwd,dwPwdLen))
  1035. {
  1036. #if defined(UNICODE) || defined(_UNICODE)
  1037. // convert it to unicode and copy it back into our unicode buffer.
  1038. // compute the length
  1039. i = MultiByteToWideChar(CP_ACP, 0, (LPSTR) szPwd, -1, NULL, 0);
  1040. if (i <= 0)
  1041. {goto CreatePassword_Exit;}
  1042. pszPassword = (LPTSTR) GlobalAlloc(GPTR, i * sizeof(TCHAR));
  1043. if (!pszPassword)
  1044. {goto CreatePassword_Exit;}
  1045. i = MultiByteToWideChar(CP_ACP, 0, (LPSTR) szPwd, -1, pszPassword, i);
  1046. if (i <= 0)
  1047. {
  1048. GlobalFree(pszPassword);
  1049. pszPassword = NULL;
  1050. goto CreatePassword_Exit;
  1051. }
  1052. // make sure ends with null
  1053. pszPassword[i - 1] = 0;
  1054. #else
  1055. pszPassword = (LPSTR) GlobalAlloc(GPTR, _tcslen((LPTSTR) szPwd) * sizeof(TCHAR));
  1056. #endif
  1057. }
  1058. else
  1059. {
  1060. iisDebugOut((LOG_TYPE_WARN,_T("CreateGoodPassword FAILED, using other password generator\n")));
  1061. // CreateGoodPassword failed...
  1062. // lets go with one that we know works...
  1063. pszPassword = (LPTSTR) GlobalAlloc(GPTR, iSize * sizeof(TCHAR));
  1064. if (!pszPassword)
  1065. {goto CreatePassword_Exit;}
  1066. CreatePasswordOld(pszPassword,iSize);
  1067. }
  1068. CreatePassword_Exit:
  1069. if (szPwd){delete szPwd;szPwd=NULL;}
  1070. return pszPassword;
  1071. }
  1072. BOOL RunProgram( LPCTSTR pszProgram, LPTSTR CmdLine, BOOL fMinimized , DWORD dwWaitTimeInSeconds, BOOL fCreateNewConsole)
  1073. {
  1074. DWORD dwProcessType = NORMAL_PRIORITY_CLASS;
  1075. STARTUPINFO si;
  1076. ZeroMemory(&si, sizeof(STARTUPINFO));
  1077. si.cb = sizeof( STARTUPINFO );
  1078. if (fMinimized)
  1079. {
  1080. GetStartupInfo(&si);
  1081. si.dwFlags |= STARTF_USESHOWWINDOW;
  1082. si.wShowWindow = SW_HIDE;
  1083. // Per bug #321409
  1084. // if you don't specify sw_hide, then this
  1085. // "accessibility magnifier" app will get funky focus events during setup
  1086. // from this CreateProcess.
  1087. //si.wShowWindow = SW_SHOWMINIMIZED;
  1088. }
  1089. PROCESS_INFORMATION pi;
  1090. if (fCreateNewConsole)
  1091. {
  1092. dwProcessType = CREATE_NEW_CONSOLE | NORMAL_PRIORITY_CLASS;
  1093. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("RunProgram:Start:Exe=%1!s!,Parm=%2!s!,NewConsole"),pszProgram, CmdLine)); }
  1094. else
  1095. {
  1096. // for some reason, a cmd window pops up during setup when we call "iisreset.exe /scm"
  1097. // only way to prevent this is specify DETACHED_PROCESS
  1098. dwProcessType = DETACHED_PROCESS | NORMAL_PRIORITY_CLASS;
  1099. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("RunProgram:Start:Exe=%1!s!,Parm=%2!s!"),pszProgram, CmdLine));
  1100. }
  1101. if (!CreateProcess( pszProgram, CmdLine, NULL, NULL, FALSE, dwProcessType, NULL, NULL, &si, &pi ))
  1102. {
  1103. iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("RunProgram:Failed:Exe=%1!s!\n, Parm=%2!s!"),pszProgram, CmdLine));
  1104. return FALSE;
  1105. }
  1106. if ( pi.hProcess != NULL )
  1107. {
  1108. DWORD dwSecondsToWait;
  1109. if (dwWaitTimeInSeconds == INFINITE)
  1110. {
  1111. dwSecondsToWait = INFINITE;
  1112. }
  1113. else
  1114. {
  1115. dwSecondsToWait = dwWaitTimeInSeconds * 1000;
  1116. }
  1117. DWORD dwEvent = WaitForSingleObject( pi.hProcess, dwSecondsToWait);
  1118. if ( dwEvent != ERROR_SUCCESS )
  1119. {
  1120. // check if wait failed
  1121. if ( dwEvent == WAIT_FAILED )
  1122. {iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("RunProgram:WaitForSingleObject() ERROR.WAIT_FAILED.Err=0x%1!x!."),GetLastError()));}
  1123. else if ( dwEvent == WAIT_ABANDONED )
  1124. {iisDebugOutSafeParams((LOG_TYPE_WARN, _T("RunProgram:WaitForSingleObject() WARNING.WAIT_ABANDONED.Err=0x%1!x!."),dwEvent));}
  1125. else if ( dwEvent == WAIT_OBJECT_0 )
  1126. {iisDebugOutSafeParams((LOG_TYPE_WARN, _T("RunProgram:WaitForSingleObject() WARNING.WAIT_OBJECT_0.Err=0x%1!x!."),dwEvent));}
  1127. else if ( dwEvent == WAIT_TIMEOUT )
  1128. {iisDebugOutSafeParams((LOG_TYPE_WARN, _T("RunProgram:WaitForSingleObject() WARNING.WAIT_TIMEOUT.Err=0x%1!x!."),dwEvent));}
  1129. else
  1130. {iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("RunProgram:WaitForSingleObject() FAILED.Err=0x%1!x!."),dwEvent));}
  1131. TerminateProcess( pi.hProcess, -1 );
  1132. CloseHandle( pi.hThread );
  1133. }
  1134. CloseHandle( pi.hProcess );
  1135. }
  1136. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("RunProgram:End:Exe=%1!s!,Parm=%2!s!"),pszProgram, CmdLine));
  1137. return TRUE;
  1138. }
  1139. void SetAppFriendlyName(LPCTSTR szKeyPath)
  1140. {
  1141. CString csKeyPath, csPath, csDesc;
  1142. CStringArray aPath, aDesc;
  1143. int nArray = 0, i = 0;
  1144. CMDKey cmdKey;
  1145. // szKeyPath is in the form of LM/W3SVC/i
  1146. csKeyPath = szKeyPath;
  1147. csPath = csKeyPath + _T("/Root");
  1148. aPath.Add(csPath);
  1149. MyLoadString(IDS_APP_FRIENDLY_ROOT, csDesc);
  1150. aDesc.Add(csDesc);
  1151. csPath = csKeyPath + _T("/Root/IISADMIN");
  1152. aPath.Add(csPath);
  1153. MyLoadString(IDS_APP_FRIENDLY_IISADMIN, csDesc);
  1154. aDesc.Add(csDesc);
  1155. csPath = csKeyPath + _T("/Root/WEBPUB");
  1156. aPath.Add(csPath);
  1157. MyLoadString(IDS_APP_FRIENDLY_WEBPUB, csDesc);
  1158. aDesc.Add(csDesc);
  1159. csPath = csKeyPath + _T("/Root/IISSAMPLES");
  1160. aPath.Add(csPath);
  1161. MyLoadString(IDS_APP_FRIENDLY_IISSAMPLES, csDesc);
  1162. aDesc.Add(csDesc);
  1163. csPath = csKeyPath + _T("/Root/IISHELP");
  1164. aPath.Add(csPath);
  1165. MyLoadString(IDS_APP_FRIENDLY_IISHELP, csDesc);
  1166. aDesc.Add(csDesc);
  1167. nArray = (int)aPath.GetSize();
  1168. for (i=0; i<nArray; i++)
  1169. {
  1170. cmdKey.OpenNode(aPath[i]);
  1171. if ( (METADATA_HANDLE)cmdKey )
  1172. {
  1173. CString csName;
  1174. TCHAR szName[_MAX_PATH];
  1175. DWORD attr, uType, dType, cbLen;
  1176. BOOL b;
  1177. b = cmdKey.GetData(MD_APP_FRIENDLY_NAME, &attr, &uType, &dType, &cbLen, (PBYTE)szName, _MAX_PATH);
  1178. if (!b || !(*szName))
  1179. {
  1180. csName = aDesc[i];
  1181. cmdKey.SetData(MD_APP_FRIENDLY_NAME,METADATA_INHERIT,IIS_MD_UT_WAM,STRING_METADATA,(csName.GetLength() + 1) * sizeof(TCHAR),(LPBYTE)(LPCTSTR)csName);
  1182. }
  1183. cmdKey.Close();
  1184. }
  1185. }
  1186. return;
  1187. }
  1188. void SetInProc( LPCTSTR szKeyPath)
  1189. {
  1190. CString csKeyPath, csPath;
  1191. CStringArray aPath;
  1192. int nArray = 0, i = 0;
  1193. CMDKey cmdKey;
  1194. // szKeyPath is in the form of LM/W3SVC/i
  1195. csKeyPath = szKeyPath;
  1196. csPath = csKeyPath + _T("/Root/IISSAMPLES");
  1197. aPath.Add(csPath);
  1198. csPath = csKeyPath + _T("/Root/IISHELP");
  1199. aPath.Add(csPath);
  1200. csPath = csKeyPath + _T("/Root/WEBPUB");
  1201. aPath.Add(csPath);
  1202. nArray = (int)aPath.GetSize();
  1203. for (i=0; i<nArray; i++) {
  1204. cmdKey.OpenNode(aPath[i]);
  1205. if ( (METADATA_HANDLE)cmdKey )
  1206. {
  1207. CString csName;
  1208. TCHAR szName[_MAX_PATH];
  1209. DWORD attr, uType, dType, cbLen;
  1210. BOOL b;
  1211. b = cmdKey.GetData(MD_APP_ROOT, &attr, &uType, &dType, &cbLen, (PBYTE)szName, _MAX_PATH);
  1212. cmdKey.Close();
  1213. if (!b || !(*szName))
  1214. {
  1215. CreateInProc_Wrap(aPath[i], TRUE);
  1216. }
  1217. }
  1218. }
  1219. return;
  1220. }
  1221. //------------------------------------------------------------------------------
  1222. // Add a custom error string to the existing custom errors. We are only adding FILE type
  1223. // error so that is assumed.
  1224. // dwCustErr is the ID of the error
  1225. // intSubCode is the sub code of the error. Pass in -1 to get a * for all subcodes
  1226. // szFilePath is the file to link to the custom error
  1227. // szKeyPath is the path in the metabase to write to
  1228. //#define SZ_CUSTOM_ERROR _T("404,*,FILE,%s\\help\\iishelp\\common\\404.htm|")
  1229. void AddCustomError(IN DWORD dwCustErr, IN INT intSubCode, IN LPCTSTR szErrorString, IN LPCTSTR szKeyPath, IN BOOL fOverwriteExisting )
  1230. {
  1231. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("AddCustomError().Start.%d:%d:%s:%s:%d\n"),dwCustErr,intSubCode,szErrorString,szKeyPath,fOverwriteExisting ));
  1232. CMDKey cmdKey;
  1233. DWORD err;
  1234. PVOID pData = NULL;
  1235. BOOL fFoundExisting = FALSE;
  1236. CString csCustomErrorString;
  1237. // start by building our new error string
  1238. // if intSubCode is < 1 use a * instead of a numerical value
  1239. if ( intSubCode < 0 )
  1240. csCustomErrorString.Format( _T("%d,*,%s"), dwCustErr, szErrorString );
  1241. else
  1242. csCustomErrorString.Format( _T("%d,%d,%s"), dwCustErr, intSubCode, szErrorString );
  1243. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("AddCustomError().part1:%s\n"),csCustomErrorString));
  1244. cmdKey.OpenNode(szKeyPath);
  1245. if ( (METADATA_HANDLE)cmdKey )
  1246. {
  1247. DWORD dwAttr = METADATA_INHERIT;
  1248. DWORD dwUType = IIS_MD_UT_FILE;
  1249. DWORD dwDType = MULTISZ_METADATA;
  1250. DWORD dwLength = 0;
  1251. // we need to start this process by getting the existing multisz data from the metabase
  1252. // first, figure out how much memory we will need to do this
  1253. if (_tcsicmp(szKeyPath,_T("LM/W3SVC/Info")) == 0)
  1254. {
  1255. dwAttr = METADATA_NO_ATTRIBUTES;
  1256. dwUType = IIS_MD_UT_SERVER;
  1257. cmdKey.GetData( MD_CUSTOM_ERROR_DESC,&dwAttr,&dwUType,&dwDType,&dwLength,NULL,0,METADATA_NO_ATTRIBUTES,IIS_MD_UT_SERVER,MULTISZ_METADATA);
  1258. }
  1259. else
  1260. {
  1261. cmdKey.GetData( MD_CUSTOM_ERROR,&dwAttr,&dwUType,&dwDType,&dwLength,NULL,0,METADATA_INHERIT,IIS_MD_UT_FILE,MULTISZ_METADATA);
  1262. }
  1263. // unfortunatly, the above routine only returns TRUE or FALSE. And since we are purposefully
  1264. // passing in a null ponter of 0 size in order to get the length of the data, it will always
  1265. // return 0 whether it was because the metabase is inacessable, or there pointer was NULL,
  1266. // which it is. So - I guess we assume it worked, allocate the buffer and attempt to read it
  1267. // in again.
  1268. TCHAR* pErrors;
  1269. DWORD cbBuffer = dwLength;
  1270. // add enough space to the allocated space that we can just append the string
  1271. cbBuffer += (csCustomErrorString.GetLength() + 4) * sizeof(WCHAR);
  1272. dwLength = cbBuffer;
  1273. // allocate the space, if it fails, we fail
  1274. // note that GPTR causes it to be initialized to zero
  1275. pData = GlobalAlloc( GPTR, cbBuffer );
  1276. if ( !pData )
  1277. {
  1278. cmdKey.Close();
  1279. return;
  1280. }
  1281. pErrors = (TCHAR*)pData;
  1282. // now get the data from the metabase
  1283. BOOL f;
  1284. if (_tcsicmp(szKeyPath,_T("LM/W3SVC/Info")) == 0)
  1285. {
  1286. f = cmdKey.GetData( MD_CUSTOM_ERROR_DESC,&dwAttr,&dwUType,&dwDType,&dwLength,(PUCHAR)pData,cbBuffer,METADATA_NO_ATTRIBUTES,IIS_MD_UT_SERVER,MULTISZ_METADATA );
  1287. }
  1288. else
  1289. {
  1290. f = cmdKey.GetData( MD_CUSTOM_ERROR,&dwAttr,&dwUType,&dwDType,&dwLength,(PUCHAR)pData,cbBuffer,METADATA_INHERIT,IIS_MD_UT_FILE,MULTISZ_METADATA );
  1291. }
  1292. // if we have successfully retrieved the existing custom errors, then we need to scan them
  1293. // and remove or find any duplicates. Then we can add our new custom error. Then we can write it
  1294. // out. If we didn't retrieve it, then we should just try to write out what we have.
  1295. if ( f )
  1296. {
  1297. // got the existing errors, scan them now - pErrors will be pointing at the second end \0
  1298. // when it is time to exit the loop.
  1299. while ( *pErrors )
  1300. {
  1301. CString csError = pErrors;
  1302. CString cs;
  1303. DWORD dwTestErrorID;
  1304. INT intTestSubCode;
  1305. // get the first error ID code
  1306. cs = csError.Left( csError.Find(_T(',')) );
  1307. csError = csError.Right( csError.GetLength() - (cs.GetLength() +1) );
  1308. _stscanf( cs, _T("%d"), &dwTestErrorID );
  1309. // get the second code
  1310. cs = csError.Left( csError.Find(_T(',')) );
  1311. if ( cs == _T('*') )
  1312. intTestSubCode = -1;
  1313. else
  1314. _stscanf( cs, _T("%d"), &intTestSubCode );
  1315. // if it is the same, then chop off this custom error string and do NOT increment pErrors
  1316. if ( (dwTestErrorID == dwCustErr) && (intTestSubCode == intSubCode) )
  1317. {
  1318. fFoundExisting = TRUE;
  1319. // NOTE: if we are not overwriting existing, then just break because we
  1320. // won't be doing anything after all - we found an existing one
  1321. if ( !fOverwriteExisting )
  1322. {
  1323. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("AddCustomError().Do not overwritexisting\n")));
  1324. break;
  1325. }
  1326. // get the location of the next string in the multisz
  1327. TCHAR* pNext = _tcsninc( pErrors, _tcslen(pErrors))+1;
  1328. // Get the length of the data to copy
  1329. DWORD cbCopyLength = cbBuffer - DIFF((PBYTE)pNext - (PBYTE)pData);
  1330. // copy the memory down.
  1331. MoveMemory( pErrors, pNext, cbCopyLength );
  1332. // do not increment the string
  1333. continue;
  1334. }
  1335. // increment pErrors to the next string
  1336. pErrors = _tcsninc( pErrors, _tcslen(pErrors))+1;
  1337. }
  1338. }
  1339. // check if we need to finish this or not
  1340. if ( fOverwriteExisting || !fFoundExisting )
  1341. {
  1342. // append our new error to the end of the list. The value pErrors should be pointing
  1343. // to the correct location to copy it in to
  1344. _tcscpy( pErrors, csCustomErrorString );
  1345. // calculate the correct data length for this thing
  1346. // get the location of the end of the multisz
  1347. TCHAR* pNext = _tcsninc( pErrors, _tcslen(pErrors))+2;
  1348. // Get the length of the data to copy
  1349. cbBuffer = DIFF((PBYTE)pNext - (PBYTE)pData);
  1350. // write the new errors list back out to the metabase
  1351. if (_tcsicmp(szKeyPath,_T("LM/W3SVC/Info")) == 0)
  1352. {
  1353. cmdKey.SetData(MD_CUSTOM_ERROR_DESC,METADATA_NO_ATTRIBUTES,IIS_MD_UT_SERVER,MULTISZ_METADATA,cbBuffer,(PUCHAR)pData);
  1354. }
  1355. else
  1356. {
  1357. cmdKey.SetData(MD_CUSTOM_ERROR,METADATA_INHERIT,IIS_MD_UT_FILE,MULTISZ_METADATA,cbBuffer,(PUCHAR)pData);
  1358. }
  1359. }
  1360. else
  1361. {
  1362. //
  1363. //
  1364. //
  1365. }
  1366. // always close the metabase key
  1367. cmdKey.Close();
  1368. }
  1369. else
  1370. {
  1371. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("AddCustomError().OpenNode failed:%s\n"),szKeyPath));
  1372. }
  1373. // clean up
  1374. if ( pData ){GlobalFree(pData);pData=NULL;}
  1375. iisDebugOut_End((_T("AddCustomError")));
  1376. return;
  1377. }
  1378. ScriptMapNode *AllocNewScriptMapNode(LPTSTR szExt, LPTSTR szProcessor, DWORD dwFlags, LPTSTR szMethods)
  1379. {
  1380. ScriptMapNode *pNew = NULL;
  1381. pNew = (ScriptMapNode *)calloc(1, sizeof(ScriptMapNode));
  1382. if (pNew)
  1383. {
  1384. _tcscpy(pNew->szExt, szExt);
  1385. _tcscpy(pNew->szProcessor, szProcessor);
  1386. pNew->dwFlags = dwFlags;
  1387. _tcscpy(pNew->szMethods, szMethods);
  1388. pNew->prev = NULL;
  1389. pNew->next = NULL;
  1390. }
  1391. return pNew;
  1392. }
  1393. //
  1394. // The script map should not be sored because
  1395. // the order is infact important.
  1396. void InsertScriptMapList(ScriptMapNode *pList, ScriptMapNode *p, BOOL fReplace)
  1397. {
  1398. ScriptMapNode *t;
  1399. int i;
  1400. int bFound = FALSE;
  1401. if (!p) {return;}
  1402. #ifdef SCRIPTMAP_SORTED
  1403. t = pList->next;
  1404. while (t != pList)
  1405. {
  1406. i = _tcsicmp(t->szExt, p->szExt);
  1407. // if the next entry in the list is less than what we have.
  1408. // then
  1409. if (i < 0)
  1410. {
  1411. t = t->next;
  1412. // continue
  1413. }
  1414. if (i == 0)
  1415. {
  1416. if (fReplace)
  1417. {
  1418. // replace t
  1419. p->next = t->next;
  1420. p->prev = t->prev;
  1421. (t->prev)->next = p;
  1422. (t->next)->prev = p;
  1423. free(t);
  1424. }
  1425. else
  1426. {
  1427. // don't replace t
  1428. free(p);
  1429. }
  1430. return;
  1431. }
  1432. if (i > 0)
  1433. {
  1434. // location found: insert before t
  1435. break;
  1436. }
  1437. }
  1438. // insert before t
  1439. p->next = t;
  1440. p->prev = t->prev;
  1441. (t->prev)->next = p;
  1442. t->prev = p;
  1443. #else
  1444. // loop thru the whole list and see if we can find our entry.
  1445. // if we cannot find it then add it to the end.
  1446. // if we can find it then replace it if we need to.
  1447. bFound = FALSE;
  1448. t = pList->next;
  1449. while (t != pList)
  1450. {
  1451. i = _tcsicmp(t->szExt, p->szExt);
  1452. // we found a match, do replace or don't replace
  1453. if (i == 0)
  1454. {
  1455. bFound = TRUE;
  1456. if (fReplace)
  1457. {
  1458. // replace t
  1459. p->next = t->next;
  1460. p->prev = t->prev;
  1461. (t->prev)->next = p;
  1462. (t->next)->prev = p;
  1463. free(t);
  1464. }
  1465. else
  1466. {
  1467. // don't replace t
  1468. free(p);
  1469. }
  1470. return;
  1471. }
  1472. // Go get the next one
  1473. t = t->next;
  1474. }
  1475. // see if we found something
  1476. if (FALSE == bFound)
  1477. {
  1478. // insert before t
  1479. p->next = t;
  1480. p->prev = t->prev;
  1481. (t->prev)->next = p;
  1482. t->prev = p;
  1483. }
  1484. #endif
  1485. return;
  1486. }
  1487. void FreeScriptMapList(ScriptMapNode *pList)
  1488. {
  1489. ScriptMapNode *t = NULL, *p = NULL;
  1490. t = pList->next;
  1491. while (t != pList)
  1492. {
  1493. p = t->next;
  1494. free(t);
  1495. t = p;
  1496. }
  1497. t->prev = t;
  1498. t->next = t;
  1499. return;
  1500. }
  1501. void GetScriptMapListFromRegistry(ScriptMapNode *pList)
  1502. {
  1503. iisDebugOut_Start(_T("GetScriptMapListFromRegistry"), LOG_TYPE_TRACE);
  1504. int iFound = FALSE;
  1505. GetScriptMapListFromClean(pList, _T("ScriptMaps_CleanList"));
  1506. CRegKey regScriptMap( HKEY_LOCAL_MACHINE, _T("System\\CurrentControlSet\\Services\\W3svc\\Parameters\\Script Map"));
  1507. if ((HKEY)regScriptMap )
  1508. {
  1509. // delete mappings of .bat and .cmd
  1510. regScriptMap.DeleteValue( _T(".bat") );
  1511. regScriptMap.DeleteValue( _T(".cmd") );
  1512. CRegValueIter regEnum( regScriptMap );
  1513. CString csExt, csProcessor, csMethods;
  1514. CString csTemp;
  1515. ScriptMapNode *pNode;
  1516. while ( regEnum.Next( &csExt, &csProcessor ) == ERROR_SUCCESS )
  1517. {
  1518. iFound = FALSE;
  1519. csTemp = csProcessor;
  1520. csTemp.MakeLower();
  1521. csMethods = _T("");
  1522. if (csTemp.Right(7) == _T("asp.dll"))
  1523. {
  1524. // Make sure it points to the new location...
  1525. csProcessor = g_pTheApp->m_csPathInetsrv + _T("\\asp.dll");
  1526. // asp has special methods.
  1527. // add PROPFIND,PROPPATCH,MKCOL,COPY,MOVE,LOCK,UNLOCK,MS-SEARCH 6/17 per vanvan for Dav.
  1528. csMethods = _T("PUT,DELETE,OPTIONS,PROPFIND,PROPPATCH,MKCOL,COPY,MOVE,LOCK,UNLOCK,MS-SEARCH");
  1529. }
  1530. if (csTemp.Right(7) == _T("ism.dll"))
  1531. {
  1532. // Make sure it points to the new location...
  1533. // remap since ism.dll has a security hole
  1534. csProcessor = g_pTheApp->m_csPathInetsrv + _T("\\asp.dll");
  1535. }
  1536. if (csTemp.Right(12) == _T("httpodbc.dll"))
  1537. {
  1538. // Make sure it points to the new location...
  1539. csProcessor = g_pTheApp->m_csPathInetsrv + _T("\\httpodbc.dll");
  1540. }
  1541. if (csTemp.Right(9) == _T("ssinc.dll"))
  1542. {
  1543. // Make sure it points to the new location...
  1544. csProcessor = g_pTheApp->m_csPathInetsrv + _T("\\ssinc.dll");
  1545. }
  1546. // Add it to the script map
  1547. pNode = AllocNewScriptMapNode((LPTSTR)(LPCTSTR)csExt, (LPTSTR)(LPCTSTR)csProcessor, MD_SCRIPTMAPFLAG_SCRIPT, _T(""));
  1548. InsertScriptMapList(pList, pNode, FALSE);
  1549. }
  1550. }
  1551. iisDebugOut_End(_T("GetScriptMapListFromRegistry"),LOG_TYPE_TRACE);
  1552. return;
  1553. }
  1554. void GetScriptMapListFromMetabase(ScriptMapNode *pList, int iUpgradeType)
  1555. {
  1556. iisDebugOut_Start(_T("GetScriptMapListFromMetabase"), LOG_TYPE_TRACE);
  1557. //DumpScriptMapList();
  1558. // When upgrading from a metabase we should not add other script maps
  1559. // which the user probably explicitly removed!
  1560. // GetScriptMapListFromClean(pList, _T("ScriptMaps_CleanList"));
  1561. //DumpScriptMapList();
  1562. BOOL bFound = FALSE;
  1563. DWORD attr, uType, dType, cbLen;
  1564. CMDKey cmdKey;
  1565. BUFFER bufData;
  1566. LPTSTR p, rest, token;
  1567. CString csName, csValue;
  1568. PBYTE pData;
  1569. int BufSize;
  1570. CString csBinPath;
  1571. cmdKey.OpenNode(_T("LM/W3SVC"));
  1572. if ( (METADATA_HANDLE)cmdKey )
  1573. {
  1574. pData = (PBYTE)(bufData.QueryPtr());
  1575. BufSize = bufData.QuerySize();
  1576. cbLen = 0;
  1577. bFound = cmdKey.GetData(MD_SCRIPT_MAPS, &attr, &uType, &dType, &cbLen, pData, BufSize);
  1578. if (!bFound && (cbLen > 0))
  1579. {
  1580. if ( ! (bufData.Resize(cbLen)) )
  1581. {
  1582. cmdKey.Close();
  1583. return; // insufficient memory
  1584. }
  1585. else
  1586. {
  1587. pData = (PBYTE)(bufData.QueryPtr());
  1588. BufSize = cbLen;
  1589. cbLen = 0;
  1590. bFound = cmdKey.GetData(MD_SCRIPT_MAPS, &attr, &uType, &dType, &cbLen, pData, BufSize);
  1591. }
  1592. }
  1593. cmdKey.Close();
  1594. ScriptMapNode *pNode;
  1595. CString csString;
  1596. TCHAR szExt[32], szProcessor[_MAX_PATH], szMethods[_MAX_PATH];
  1597. DWORD dwFlags;
  1598. int i, j, len;
  1599. if (bFound && (dType == MULTISZ_METADATA))
  1600. {
  1601. p = (LPTSTR)pData;
  1602. while (*p)
  1603. {
  1604. rest = p + _tcslen(p) + 1;
  1605. // szExt,szProcessor,dwFlags[,szMethods]
  1606. LPTSTR q = p;
  1607. i = 0;
  1608. while ( *q )
  1609. {
  1610. if (*q == _T(','))
  1611. {
  1612. i++;
  1613. *q = _T('\0');
  1614. q = _tcsinc(q);
  1615. if (i == 1)
  1616. _tcscpy(szExt, p);
  1617. if (i == 2)
  1618. _tcscpy(szProcessor, p);
  1619. if (i == 3)
  1620. break;
  1621. p = q;
  1622. }
  1623. else
  1624. {
  1625. q = _tcsinc(q);
  1626. }
  1627. }
  1628. dwFlags = atodw(p);
  1629. _tcscpy(szMethods, q);
  1630. CString csProcessor = szProcessor;
  1631. csProcessor.MakeLower();
  1632. //
  1633. // Check if this is the one for asp.dll
  1634. //
  1635. if (csProcessor.Right(7) == _T("asp.dll"))
  1636. {
  1637. // metabase should now have inclusion list and not exclusion list, so
  1638. // don't do this for UT_50. 2/23/99 aaronl.
  1639. // But UT_40 have a exclusion list.
  1640. // So we have to make sure it have the full exclusion list
  1641. if ( iUpgradeType == UT_40)
  1642. {
  1643. CString csMethods = szMethods;
  1644. csMethods.MakeUpper();
  1645. // changed 4/21/98 aaronl, added 'Options'
  1646. // add PROPFIND,PROPPATCH,MKCOL,COPY,MOVE,LOCK,UNLOCK,MS-SEARCH 6/17 per vanvan for Dav.
  1647. if (csMethods.Find(_T("PUT,DELETE,OPTIONS,PROPFIND,PROPPATCH,MKCOL,COPY,MOVE,LOCK,UNLOCK,MS-SEARCH")) == -1)
  1648. {
  1649. if (csMethods.IsEmpty())
  1650. {
  1651. // if it's empty, then put to the default.
  1652. csMethods = _T("PUT,DELETE,OPTIONS,PROPFIND,PROPPATCH,MKCOL,COPY,MOVE,LOCK,UNLOCK,MS-SEARCH");
  1653. }
  1654. else
  1655. {
  1656. if (csMethods.Find(_T("GET")) == -1)
  1657. {
  1658. // We didn't find the "GET" verb so we can safely say
  1659. // that we are looking at an exclusion list
  1660. CString csMethodsNew;
  1661. csMethodsNew = _T("");
  1662. // is put in there? if not add it
  1663. if (csMethods.Find(_T("PUT")) == -1) {csMethodsNew += _T("PUT,");}
  1664. if (csMethods.Find(_T("DELETE")) == -1) {csMethodsNew += _T("DELETE,");}
  1665. if (csMethods.Find(_T("OPTIONS")) == -1) {csMethodsNew += _T("OPTIONS,");}
  1666. if (csMethods.Find(_T("PROPFIND")) == -1) {csMethodsNew += _T("PROPFIND,");}
  1667. if (csMethods.Find(_T("PROPPATCH")) == -1) {csMethodsNew += _T("PROPPATCH,");}
  1668. if (csMethods.Find(_T("MKCOL")) == -1) {csMethodsNew += _T("MKCOL,");}
  1669. if (csMethods.Find(_T("COPY")) == -1) {csMethodsNew += _T("COPY,");}
  1670. if (csMethods.Find(_T("MOVE")) == -1) {csMethodsNew += _T("MOVE,");}
  1671. if (csMethods.Find(_T("LOCK")) == -1) {csMethodsNew += _T("LOCK,");}
  1672. if (csMethods.Find(_T("UNLOCK")) == -1) {csMethodsNew += _T("UNLOCK,");}
  1673. if (csMethods.Find(_T("MS-SEARCH")) == -1) {csMethodsNew += _T("MS-SEARCH,");}
  1674. // has an extra ',' at the end
  1675. //csMethods = _T("PUT,DELETE,OPTIONS,PROPFIND,PROPPATCH,MKCOL,COPY,MOVE,LOCK,UNLOCK,MS-SEARCH,");
  1676. csMethods = csMethodsNew;
  1677. csMethods += szMethods;
  1678. }
  1679. }
  1680. _tcscpy(szMethods, csMethods);
  1681. }
  1682. }
  1683. // make sure it points to the new asp.dll location
  1684. csBinPath = g_pTheApp->m_csPathInetsrv + _T("\\asp.dll");
  1685. _tcscpy(szProcessor, csBinPath);
  1686. }
  1687. //
  1688. // Check if this is the one for ism.dll
  1689. //
  1690. if (csProcessor.Right(7) == _T("ism.dll"))
  1691. {
  1692. // make sure it points to the new location
  1693. // remap since ism.dll has a security hole
  1694. csBinPath = g_pTheApp->m_csPathInetsrv + _T("\\asp.dll");
  1695. _tcscpy(szProcessor, csBinPath);
  1696. }
  1697. //
  1698. // Check if this is the one for httpodbc.dll
  1699. //
  1700. if (csProcessor.Right(12) == _T("httpodbc.dll"))
  1701. {
  1702. // make sure it points to the new location
  1703. csBinPath = g_pTheApp->m_csPathInetsrv + _T("\\httpodbc.dll");
  1704. _tcscpy(szProcessor, csBinPath);
  1705. }
  1706. //
  1707. // Check if this is the one for ssinc.dll
  1708. //
  1709. if (csProcessor.Right(9) == _T("ssinc.dll"))
  1710. {
  1711. // make sure it points to the new location
  1712. csBinPath = g_pTheApp->m_csPathInetsrv + _T("\\ssinc.dll");
  1713. _tcscpy(szProcessor, csBinPath);
  1714. }
  1715. p = rest; // points to the next string
  1716. pNode = AllocNewScriptMapNode(szExt, szProcessor, dwFlags | MD_SCRIPTMAPFLAG_SCRIPT, szMethods);
  1717. //iisDebugOut((LOG_TYPE_TRACE, _T("Calling InsertScriptMapList=%s:%s:%d:%s.\n"),szExt,szProcessor,dwFlags | MD_SCRIPTMAPFLAG_SCRIPT,szMethods));
  1718. InsertScriptMapList(pList, pNode, TRUE);
  1719. }
  1720. }
  1721. }
  1722. iisDebugOut_End(_T("GetScriptMapListFromMetabase"),LOG_TYPE_TRACE);
  1723. return;
  1724. }
  1725. void DumpScriptMapList()
  1726. {
  1727. BOOL bFound = FALSE;
  1728. DWORD attr, uType, dType, cbLen;
  1729. CMDKey cmdKey;
  1730. BUFFER bufData;
  1731. LPTSTR p, rest, token;
  1732. CString csName, csValue;
  1733. PBYTE pData;
  1734. int BufSize;
  1735. CString csBinPath;
  1736. cmdKey.OpenNode(_T("LM/W3SVC"));
  1737. if ( (METADATA_HANDLE)cmdKey )
  1738. {
  1739. pData = (PBYTE)(bufData.QueryPtr());
  1740. BufSize = bufData.QuerySize();
  1741. cbLen = 0;
  1742. bFound = cmdKey.GetData(MD_SCRIPT_MAPS, &attr, &uType, &dType, &cbLen, pData, BufSize);
  1743. if (!bFound && (cbLen > 0))
  1744. {
  1745. if ( ! (bufData.Resize(cbLen)) )
  1746. {
  1747. cmdKey.Close();
  1748. return; // insufficient memory
  1749. }
  1750. else
  1751. {
  1752. pData = (PBYTE)(bufData.QueryPtr());
  1753. BufSize = cbLen;
  1754. cbLen = 0;
  1755. bFound = cmdKey.GetData(MD_SCRIPT_MAPS, &attr, &uType, &dType, &cbLen, pData, BufSize);
  1756. }
  1757. }
  1758. cmdKey.Close();
  1759. ScriptMapNode *pNode;
  1760. CString csString;
  1761. TCHAR szExt[32], szProcessor[_MAX_PATH], szMethods[_MAX_PATH];
  1762. DWORD dwFlags;
  1763. int i, j, len;
  1764. if (bFound && (dType == MULTISZ_METADATA))
  1765. {
  1766. p = (LPTSTR)pData;
  1767. while (*p)
  1768. {
  1769. rest = p + _tcslen(p) + 1;
  1770. // szExt,szProcessor,dwFlags[,szMethods]
  1771. LPTSTR q = p;
  1772. i = 0;
  1773. while ( *q )
  1774. {
  1775. if (*q == _T(','))
  1776. {
  1777. i++;
  1778. *q = _T('\0');
  1779. q = _tcsinc(q);
  1780. if (i == 1)
  1781. _tcscpy(szExt, p);
  1782. if (i == 2)
  1783. _tcscpy(szProcessor, p);
  1784. if (i == 3)
  1785. break;
  1786. p = q;
  1787. }
  1788. else
  1789. {
  1790. q = _tcsinc(q);
  1791. }
  1792. }
  1793. dwFlags = atodw(p);
  1794. _tcscpy(szMethods, q);
  1795. CString csProcessor = szProcessor;
  1796. csProcessor.MakeLower();
  1797. iisDebugOut((LOG_TYPE_TRACE, _T("DumpScriptMapList=%s,%s,%s\n"),szExt, csProcessor,szMethods));
  1798. p = rest; // points to the next string
  1799. }
  1800. }
  1801. }
  1802. return;
  1803. }
  1804. void WriteScriptMapListToMetabase(ScriptMapNode *pList, LPTSTR szKeyPath, DWORD dwFlags)
  1805. {
  1806. iisDebugOut_Start1(_T("WriteScriptMapListToMetabase"), szKeyPath, LOG_TYPE_TRACE);
  1807. CString csString, csTemp;
  1808. ScriptMapNode *t = NULL;
  1809. int len = 0;
  1810. t = pList->next;
  1811. while (t != pList)
  1812. {
  1813. if ( *(t->szMethods) )
  1814. csTemp.Format( _T("%s,%s,%d,%s|"), t->szExt, t->szProcessor, (t->dwFlags | dwFlags), t->szMethods );
  1815. else
  1816. csTemp.Format( _T("%s,%s,%d|"), t->szExt, t->szProcessor, (t->dwFlags | dwFlags) );
  1817. len += csTemp.GetLength();
  1818. //iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("WriteScriptMapListToMetabase().ADDEntry=%1!s!\n"), csTemp));
  1819. csString += csTemp;
  1820. t = t->next;
  1821. }
  1822. if (len > 0)
  1823. {
  1824. HGLOBAL hBlock = NULL;
  1825. len++;
  1826. hBlock = GlobalAlloc(GPTR, len * sizeof(TCHAR));
  1827. if (hBlock)
  1828. {
  1829. LPTSTR s;
  1830. s = (LPTSTR)hBlock;
  1831. _tcscpy(s, csString);
  1832. while (*s)
  1833. {
  1834. if (*s == _T('|'))
  1835. {*s = _T('\0');}
  1836. s = _tcsinc(s);
  1837. }
  1838. CMDKey cmdKey;
  1839. cmdKey.CreateNode(METADATA_MASTER_ROOT_HANDLE, szKeyPath);
  1840. if ( (METADATA_HANDLE)cmdKey )
  1841. {
  1842. cmdKey.SetData(MD_SCRIPT_MAPS,METADATA_INHERIT,IIS_MD_UT_FILE,MULTISZ_METADATA,len * sizeof(TCHAR),(LPBYTE)hBlock);
  1843. cmdKey.Close();
  1844. }
  1845. }
  1846. }
  1847. iisDebugOut_End1(_T("WriteScriptMapListToMetabase"),szKeyPath,LOG_TYPE_TRACE);
  1848. //DumpScriptMapList();
  1849. return;
  1850. }
  1851. // this function does not use the va_list stuff because if
  1852. // there ever is this case: iisDebugOut("<SYSTEMROOT>") it will hose
  1853. // because it will try to put something in the %s part when there were no
  1854. // variables passed in.
  1855. void iisDebugOutSafe2(int iLogType, TCHAR * acsString)
  1856. {
  1857. // Check what type of log this should be.
  1858. int iProceed = FALSE;
  1859. if (iLogType == LOG_TYPE_ERROR)
  1860. {SetErrorFlag(__FILE__, __LINE__);}
  1861. switch(iLogType)
  1862. {
  1863. case LOG_TYPE_TRACE_WIN32_API:
  1864. if (g_GlobalDebugLevelFlag >= LOG_TYPE_TRACE_WIN32_API)
  1865. {iProceed = TRUE;}
  1866. break;
  1867. case LOG_TYPE_TRACE:
  1868. if (g_GlobalDebugLevelFlag >= LOG_TYPE_TRACE)
  1869. {iProceed = TRUE;}
  1870. break;
  1871. case LOG_TYPE_PROGRAM_FLOW:
  1872. if (g_GlobalDebugLevelFlag >= LOG_TYPE_PROGRAM_FLOW)
  1873. {iProceed = TRUE;}
  1874. break;
  1875. case LOG_TYPE_WARN:
  1876. if (g_GlobalDebugLevelFlag >= LOG_TYPE_WARN)
  1877. {iProceed = TRUE;}
  1878. break;
  1879. case LOG_TYPE_ERROR:
  1880. if (g_GlobalDebugLevelFlag >= LOG_TYPE_ERROR)
  1881. {iProceed = TRUE;}
  1882. break;
  1883. default:
  1884. // this must be an error
  1885. iProceed = TRUE;
  1886. break;
  1887. }
  1888. if (iProceed)
  1889. {
  1890. if (LOG_TYPE_ERROR == iLogType)
  1891. {
  1892. g_MyLogFile.LogFileWrite(_T("!FAIL! "));
  1893. }
  1894. // always output to the log file
  1895. g_MyLogFile.LogFileWrite(_T("%s"), acsString);
  1896. //#if DBG == 1 || DEBUG == 1 || _DEBUG == 1
  1897. // OK. Here is the deal.
  1898. // nt5 does not want to see any OutputDebugString stuff
  1899. // so, we need to remove it for them.
  1900. // Actually we'll check the registry key
  1901. // to see if it is turned on for the ocmanage component.
  1902. // if it is then, set it on for us.
  1903. if (g_GlobalDebugLevelFlag >= LOG_TYPE_TRACE_WIN32_API)
  1904. {
  1905. if (LOG_TYPE_ERROR == iLogType)
  1906. {OutputDebugString(_T("!FAIL!"));}
  1907. // output to screen
  1908. if (g_MyLogFile.m_szLogPreLineInfo) {OutputDebugString(g_MyLogFile.m_szLogPreLineInfo);}
  1909. OutputDebugString(acsString);
  1910. // if it does not end if '\r\n' then make one.
  1911. int nLen = _tcslen(acsString);
  1912. if (acsString[nLen-1] != _T('\n'))
  1913. {OutputDebugString(_T("\r\n"));}
  1914. }
  1915. //#endif // DBG
  1916. }
  1917. return;
  1918. }
  1919. void iisDebugOut2(int iLogType, TCHAR *pszfmt, ...)
  1920. {
  1921. // Check what type of log this should be.
  1922. int iProceed = FALSE;
  1923. switch(iLogType)
  1924. {
  1925. case LOG_TYPE_TRACE_WIN32_API:
  1926. if (g_GlobalDebugLevelFlag >= LOG_TYPE_TRACE_WIN32_API)
  1927. {iProceed = TRUE;}
  1928. break;
  1929. case LOG_TYPE_TRACE:
  1930. if (g_GlobalDebugLevelFlag >= LOG_TYPE_TRACE)
  1931. {iProceed = TRUE;}
  1932. break;
  1933. case LOG_TYPE_PROGRAM_FLOW:
  1934. if (g_GlobalDebugLevelFlag >= LOG_TYPE_PROGRAM_FLOW)
  1935. {iProceed = TRUE;}
  1936. break;
  1937. case LOG_TYPE_WARN:
  1938. if (g_GlobalDebugLevelFlag >= LOG_TYPE_WARN)
  1939. {iProceed = TRUE;}
  1940. break;
  1941. case LOG_TYPE_ERROR:
  1942. if (g_GlobalDebugLevelFlag >= LOG_TYPE_ERROR)
  1943. {iProceed = TRUE;}
  1944. break;
  1945. default:
  1946. // this must be an error
  1947. iProceed = TRUE;
  1948. break;
  1949. }
  1950. if (iProceed)
  1951. {
  1952. TCHAR acsString[1000];
  1953. // Encompass this whole iisdebugout deal in a try-catch.
  1954. // not too good to have this one access violating.
  1955. // when trying to produce a debugoutput!
  1956. __try
  1957. {
  1958. va_list va;
  1959. va_start(va, pszfmt);
  1960. _vstprintf(acsString, pszfmt, va);
  1961. va_end(va);
  1962. }
  1963. __except(EXCEPTION_EXECUTE_HANDLER)
  1964. {
  1965. TCHAR szErrorString[100];
  1966. _stprintf(szErrorString, _T("\r\n\r\nException Caught in iisDebugOut2(). GetExceptionCode()=0x%x.\r\n\r\n"), GetExceptionCode());
  1967. OutputDebugString(szErrorString);
  1968. g_MyLogFile.LogFileWrite(szErrorString);
  1969. }
  1970. // output to log file and the screen.
  1971. iisDebugOutSafe2(iLogType, acsString);
  1972. }
  1973. return;
  1974. }
  1975. // This function requires inputs like this:
  1976. // iisDebugOutSafeParams2("this %1!s! is %2!s! and has %3!d! args", "function", "kool", 3);
  1977. // you must specify the %1 deals. this is so that
  1978. // if something like this is passed in "this %SYSTEMROOT% %1!s!", it will put the string into %1 not %s!
  1979. void iisDebugOutSafeParams2(int iLogType, TCHAR *pszfmt, ...)
  1980. {
  1981. // Check what type of log this should be.
  1982. int iProceed = FALSE;
  1983. switch(iLogType)
  1984. {
  1985. case LOG_TYPE_TRACE_WIN32_API:
  1986. if (g_GlobalDebugLevelFlag >= LOG_TYPE_TRACE_WIN32_API)
  1987. {iProceed = TRUE;}
  1988. break;
  1989. case LOG_TYPE_TRACE:
  1990. if (g_GlobalDebugLevelFlag >= LOG_TYPE_TRACE)
  1991. {iProceed = TRUE;}
  1992. break;
  1993. case LOG_TYPE_PROGRAM_FLOW:
  1994. if (g_GlobalDebugLevelFlag >= LOG_TYPE_PROGRAM_FLOW)
  1995. {iProceed = TRUE;}
  1996. break;
  1997. case LOG_TYPE_WARN:
  1998. if (g_GlobalDebugLevelFlag >= LOG_TYPE_WARN)
  1999. {iProceed = TRUE;}
  2000. break;
  2001. case LOG_TYPE_ERROR:
  2002. if (g_GlobalDebugLevelFlag >= LOG_TYPE_ERROR)
  2003. {iProceed = TRUE;}
  2004. break;
  2005. default:
  2006. // this must be an error
  2007. iProceed = TRUE;
  2008. break;
  2009. }
  2010. if (iProceed)
  2011. {
  2012. // The count of parameters do not match
  2013. va_list va;
  2014. TCHAR *pszFullErrMsg = NULL;
  2015. va_start(va, pszfmt);
  2016. __try
  2017. {
  2018. FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_STRING, (LPCVOID) pszfmt, 0, 0, (LPTSTR) &pszFullErrMsg, 0, &va);
  2019. }
  2020. __except(EXCEPTION_EXECUTE_HANDLER)
  2021. {
  2022. TCHAR szErrorString[100];
  2023. _stprintf(szErrorString, _T("\r\n\r\nException Caught in iisDebugOutSafeParams2(). GetExceptionCode()=0x%x.\r\n\r\n"), GetExceptionCode());
  2024. OutputDebugString(szErrorString);
  2025. g_MyLogFile.LogFileWrite(szErrorString);
  2026. }
  2027. if (pszFullErrMsg)
  2028. {
  2029. // output to log file and the screen.
  2030. iisDebugOutSafe2(iLogType, pszFullErrMsg);
  2031. }
  2032. va_end(va);
  2033. if (pszFullErrMsg) {LocalFree(pszFullErrMsg);pszFullErrMsg=NULL;}
  2034. }
  2035. return;
  2036. }
  2037. void HandleSpecificErrors(DWORD iTheErrorCode, DWORD dwFormatReturn, CString csMsg, TCHAR pMsg[], CString *pcsErrMsg)
  2038. {
  2039. CString csErrMsg;
  2040. CString csExtraMsg;
  2041. switch(iTheErrorCode)
  2042. {
  2043. case NTE_BAD_SIGNATURE:
  2044. // load extra error message for this error!
  2045. MyLoadString(IDS_BAD_SIGNATURE_RELNOTES, csExtraMsg);
  2046. if (dwFormatReturn) {csErrMsg.Format(_T("%s\n\n0x%x=%s\n\n%s"), csMsg, iTheErrorCode, pMsg, csExtraMsg);}
  2047. else{csErrMsg.Format(_T("%s\n\nErrorCode=0x%x.\n\n%s"), csMsg, iTheErrorCode, csExtraMsg);}
  2048. break;
  2049. case CO_E_RUNAS_LOGON_FAILURE:
  2050. // we should get the mts runas user from the registry and display it.
  2051. default:
  2052. // Put everything into csErrMsg
  2053. if (dwFormatReturn) {csErrMsg.Format(_T("%s\n\n0x%x=%s"), csMsg, iTheErrorCode, pMsg);}
  2054. else{csErrMsg.Format(_T("%s\n\nErrorCode=0x%x."), csMsg, iTheErrorCode);}
  2055. break;
  2056. }
  2057. // copy the error string into the passed in CString
  2058. (*pcsErrMsg) = csErrMsg;
  2059. return;
  2060. }
  2061. //***************************************************************************
  2062. //*
  2063. //* purpose:
  2064. //*
  2065. //***************************************************************************
  2066. LPWSTR MakeWideStrFromAnsi(LPSTR psz)
  2067. {
  2068. LPWSTR pwsz;
  2069. int i;
  2070. // arg checking.
  2071. //
  2072. if (!psz)
  2073. return NULL;
  2074. // compute the length
  2075. //
  2076. i = MultiByteToWideChar(CP_ACP, 0, psz, -1, NULL, 0);
  2077. if (i <= 0) return NULL;
  2078. //iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ole32:CoTaskMemAlloc().Start.")));
  2079. pwsz = (LPWSTR) CoTaskMemAlloc(i * sizeof(WCHAR));
  2080. //iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ole32:CoTaskMemAlloc().End.")));
  2081. if (!pwsz) return NULL;
  2082. MultiByteToWideChar(CP_ACP, 0, psz, -1, pwsz, i);
  2083. pwsz[i - 1] = 0;
  2084. return pwsz;
  2085. }
  2086. DWORD CallProcedureInDll_wrap(LPCTSTR lpszDLLFile, LPCTSTR lpszProcedureToCall, BOOL bDisplayMsgOnErrFlag, BOOL bInitOleFlag,BOOL iFunctionPrototypeFlag)
  2087. {
  2088. int bFinishedFlag = FALSE;
  2089. UINT iMsg = NULL;
  2090. DWORD dwReturn = ERROR_SUCCESS;
  2091. TCHAR szExceptionString[50] = _T("");
  2092. LogHeapState(FALSE, __FILE__, __LINE__);
  2093. do
  2094. {
  2095. __try
  2096. {
  2097. dwReturn = CallProcedureInDll(lpszDLLFile, lpszProcedureToCall, bDisplayMsgOnErrFlag, bInitOleFlag, iFunctionPrototypeFlag);
  2098. LogHeapState(FALSE, __FILE__, __LINE__);
  2099. }
  2100. __except(EXCEPTION_EXECUTE_HANDLER)
  2101. {
  2102. iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("ExceptionCaught!:CallProcedureInDll_wrap(): File:%1!s!, Procedure:%2!s!\n"), lpszDLLFile, lpszProcedureToCall));
  2103. switch (GetExceptionCode())
  2104. {
  2105. case EXCEPTION_ACCESS_VIOLATION:
  2106. _tcscpy(szExceptionString, _T("EXCEPTION_ACCESS_VIOLATION"));
  2107. break;
  2108. case EXCEPTION_BREAKPOINT:
  2109. _tcscpy(szExceptionString, _T("EXCEPTION_BREAKPOINT"));
  2110. break;
  2111. case EXCEPTION_DATATYPE_MISALIGNMENT:
  2112. _tcscpy(szExceptionString, _T("EXCEPTION_DATATYPE_MISALIGNMENT"));
  2113. break;
  2114. case EXCEPTION_SINGLE_STEP:
  2115. _tcscpy(szExceptionString, _T("EXCEPTION_SINGLE_STEP"));
  2116. break;
  2117. case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
  2118. _tcscpy(szExceptionString, _T("EXCEPTION_ARRAY_BOUNDS_EXCEEDED"));
  2119. break;
  2120. case EXCEPTION_FLT_DENORMAL_OPERAND:
  2121. _tcscpy(szExceptionString, _T("EXCEPTION_FLT_DENORMAL_OPERAND"));
  2122. break;
  2123. case EXCEPTION_FLT_DIVIDE_BY_ZERO:
  2124. _tcscpy(szExceptionString, _T("EXCEPTION_FLT_DIVIDE_BY_ZERO"));
  2125. break;
  2126. case EXCEPTION_FLT_INEXACT_RESULT:
  2127. _tcscpy(szExceptionString, _T("EXCEPTION_FLT_INEXACT_RESULT"));
  2128. break;
  2129. case EXCEPTION_FLT_INVALID_OPERATION:
  2130. _tcscpy(szExceptionString, _T("EXCEPTION_FLT_INVALID_OPERATION"));
  2131. break;
  2132. case EXCEPTION_FLT_OVERFLOW:
  2133. _tcscpy(szExceptionString, _T("EXCEPTION_FLT_OVERFLOW"));
  2134. break;
  2135. case EXCEPTION_FLT_STACK_CHECK:
  2136. _tcscpy(szExceptionString, _T("EXCEPTION_FLT_STACK_CHECK"));
  2137. break;
  2138. case EXCEPTION_FLT_UNDERFLOW:
  2139. _tcscpy(szExceptionString, _T("EXCEPTION_FLT_UNDERFLOW"));
  2140. break;
  2141. case EXCEPTION_INT_DIVIDE_BY_ZERO:
  2142. _tcscpy(szExceptionString, _T("EXCEPTION_INT_DIVIDE_BY_ZERO"));
  2143. break;
  2144. case EXCEPTION_INT_OVERFLOW:
  2145. _tcscpy(szExceptionString, _T("EXCEPTION_INT_OVERFLOW"));
  2146. break;
  2147. case EXCEPTION_PRIV_INSTRUCTION:
  2148. _tcscpy(szExceptionString, _T("EXCEPTION_PRIV_INSTRUCTION"));
  2149. break;
  2150. case EXCEPTION_NONCONTINUABLE_EXCEPTION:
  2151. _tcscpy(szExceptionString, _T("EXCEPTION_NONCONTINUABLE_EXCEPTION"));
  2152. break;
  2153. default:
  2154. _tcscpy(szExceptionString, _T("Unknown Exception Type"));
  2155. break;
  2156. }
  2157. //MyMessageBox( NULL, IDS_REGSVR_CAUGHT_EXCEPTION, lpszProcedureToCall, lpszDLLFile, GetExceptionCode(), MB_OK | MB_SETFOREGROUND );
  2158. MyMessageBox( NULL, IDS_REGSVR_CAUGHT_EXCEPTION, szExceptionString, lpszProcedureToCall, lpszDLLFile, GetExceptionCode(), MB_OK | MB_SETFOREGROUND );
  2159. dwReturn = E_FAIL;
  2160. }
  2161. if (dwReturn == ERROR_SUCCESS)
  2162. {
  2163. break;
  2164. }
  2165. else
  2166. {
  2167. if (bDisplayMsgOnErrFlag == TRUE)
  2168. {
  2169. iMsg = MyMessageBox( NULL, IDS_RETRY, MB_ABORTRETRYIGNORE | MB_SETFOREGROUND );
  2170. switch ( iMsg )
  2171. {
  2172. case IDRETRY:
  2173. break;
  2174. case IDIGNORE:
  2175. case IDABORT:
  2176. default:
  2177. // return whatever err happened
  2178. goto CallProcedureInDll_wrap_Exit;
  2179. break;
  2180. }
  2181. }
  2182. else
  2183. {
  2184. // return whatever err happened
  2185. goto CallProcedureInDll_wrap_Exit;
  2186. }
  2187. }
  2188. } while (dwReturn != ERROR_SUCCESS);
  2189. CallProcedureInDll_wrap_Exit:
  2190. return dwReturn;
  2191. }
  2192. void AddOLEAUTRegKey()
  2193. {
  2194. CRegKey regCLSID46(_T("CLSID\\{00020424-0000-0000-C000-000000000046}"),HKEY_CLASSES_ROOT);
  2195. if ((HKEY)regCLSID46)
  2196. {
  2197. #ifdef _CHICAGO_
  2198. regCLSID46.SetValue(_T(""), _T("PSAutomation"));
  2199. #else
  2200. regCLSID46.SetValue(_T(""), _T("PSOAInterface"));
  2201. #endif
  2202. }
  2203. CRegKey regInProcServer(_T("CLSID\\{00020424-0000-0000-C000-000000000046}\\InprocServer"),HKEY_CLASSES_ROOT);
  2204. if ((HKEY)regInProcServer)
  2205. {
  2206. regInProcServer.SetValue(_T(""), _T("ole2disp.dll"));
  2207. }
  2208. CRegKey regInProcServer32(_T("CLSID\\{00020424-0000-0000-C000-000000000046}\\InprocServer32"),HKEY_CLASSES_ROOT);
  2209. if ((HKEY)regInProcServer32)
  2210. {
  2211. regInProcServer32.SetValue(_T(""), _T("oleaut32.dll"));
  2212. regInProcServer32.SetValue(_T("ThreadingModel"), _T("Both"));
  2213. }
  2214. return;
  2215. }
  2216. // Returns:
  2217. // ERROR_SUCCESS if successfull.
  2218. // ERROR_OPERATION_ABORTED if the operation failed and the user wants to abort setup!
  2219. DWORD RegisterOLEControl(LPCTSTR lpszOcxFile, BOOL fAction)
  2220. {
  2221. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("RegisterOLEControl():File=%1!s!, Action=%2!d!\n"), lpszOcxFile, fAction));
  2222. DWORD dwReturn = ERROR_SUCCESS;
  2223. if (fAction)
  2224. {
  2225. dwReturn = CallProcedureInDll_wrap(lpszOcxFile, _T("DllRegisterServer"), TRUE, TRUE, FUNCTION_PARAMS_NONE);
  2226. }
  2227. else
  2228. {
  2229. #if DBG == 1 || DEBUG == 1 || _DEBUG == 1
  2230. // Show errors if this is a debug build
  2231. dwReturn = CallProcedureInDll_wrap(lpszOcxFile, _T("DllUnregisterServer"), TRUE, TRUE, FUNCTION_PARAMS_NONE);
  2232. #else
  2233. // Set 3rd parameter to false so that there are no MyMessageBox popups if any errors
  2234. dwReturn = CallProcedureInDll_wrap(lpszOcxFile, _T("DllUnregisterServer"), FALSE, TRUE, FUNCTION_PARAMS_NONE);
  2235. #endif
  2236. }
  2237. return dwReturn;
  2238. }
  2239. typedef HRESULT (CALLBACK *HCRET)(void);
  2240. typedef HRESULT (*PFUNCTION2)(HMODULE myDllHandle);
  2241. DWORD CallProcedureInDll(LPCTSTR lpszDLLFile, LPCTSTR lpszProcedureToCall, BOOL bDisplayMsgOnErrFlag, BOOL bInitOleFlag, BOOL iFunctionPrototypeFlag)
  2242. {
  2243. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("------------------\n")));
  2244. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("CallProcedureInDll(%1!s!): %2!s!\n"), lpszDLLFile, lpszProcedureToCall));
  2245. DWORD dwReturn = ERROR_SUCCESS;
  2246. HINSTANCE hDll = NULL;
  2247. // Diferent function prototypes...
  2248. HCRET hProc = NULL;
  2249. PFUNCTION2 hProc2 = NULL;
  2250. int iTempProcGood = FALSE;
  2251. HRESULT hRes = 0;
  2252. BOOL bBalanceOLE = FALSE;
  2253. HRESULT hInitRes = NULL;
  2254. int err = NOERROR;
  2255. // Variables to changing and saving dirs
  2256. TCHAR szDirName[_MAX_PATH], szFilePath[_MAX_PATH];
  2257. // Variable to set error string
  2258. TCHAR szErrString[256];
  2259. _tcscpy(szDirName, _T(""));
  2260. _tcscpy(szErrString, _T(""));
  2261. // perform a defensive check
  2262. if ( FAILED(FTestForOutstandingCoInits()) )
  2263. {
  2264. iisDebugOut((LOG_TYPE_WARN, _T("Outstanding CoInit in %s. WARNING."), lpszDLLFile));
  2265. }
  2266. // If we need to initialize the ole library then init it.
  2267. if (bInitOleFlag)
  2268. {
  2269. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ole32(OleInitialize):start.\n")));
  2270. bBalanceOLE = iOleInitialize();
  2271. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ole32(OleInitialize):end.\n")));
  2272. if (FALSE == bBalanceOLE)
  2273. {
  2274. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ole32(OleInitialize):start.\n")));
  2275. hInitRes = OleInitialize(NULL);
  2276. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ole32(OleInitialize):end.\n")));
  2277. // Ole Failed.
  2278. dwReturn = hInitRes;
  2279. SetLastError(dwReturn);
  2280. if (bDisplayMsgOnErrFlag)
  2281. {
  2282. MyMessageBox(NULL, IDS_OLE_INIT_FAILED, lpszDLLFile, hInitRes, MB_OK | MB_SETFOREGROUND);
  2283. }
  2284. goto CallProcedureInDll_Exit;
  2285. }
  2286. }
  2287. // Check if the file exists
  2288. if (!IsFileExist(lpszDLLFile))
  2289. {
  2290. dwReturn = ERROR_FILE_NOT_FOUND;
  2291. if (bDisplayMsgOnErrFlag)
  2292. {
  2293. MyMessageBox(NULL, IDS_FILE_DOES_NOT_EXIST, lpszDLLFile, ERROR_FILE_NOT_FOUND, MB_OK | MB_SETFOREGROUND);
  2294. }
  2295. SetLastError(dwReturn);
  2296. goto CallProcedureInDll_Exit;
  2297. }
  2298. // Change Directory
  2299. GetCurrentDirectory( _MAX_PATH, szDirName );
  2300. InetGetFilePath(lpszDLLFile, szFilePath);
  2301. // Change to The Drive.
  2302. if (-1 == _chdrive( _totupper(szFilePath[0]) - 'A' + 1 )) {}
  2303. if (SetCurrentDirectory(szFilePath) == 0) {}
  2304. // Try to load the module,dll,ocx.
  2305. hDll = LoadLibraryEx(lpszDLLFile, NULL, LOAD_WITH_ALTERED_SEARCH_PATH );
  2306. if (!hDll)
  2307. {
  2308. // Failed to load library, Probably because some .dll file is missing.
  2309. // Show the error message.
  2310. iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("CallProcedureInDll():%1!s!:%2!s!:LoadLibraryEx FAILED.\n"), lpszDLLFile, lpszProcedureToCall));
  2311. dwReturn = TYPE_E_CANTLOADLIBRARY;
  2312. if (bDisplayMsgOnErrFlag)
  2313. {
  2314. MyMessageBox(NULL, IDS_LOADLIBRARY_FAILED, lpszDLLFile, TYPE_E_CANTLOADLIBRARY, MB_OK | MB_SETFOREGROUND);
  2315. }
  2316. SetLastError(dwReturn);
  2317. // check if this file has missing file it's supposed to be linked with.
  2318. // or if the file has mismatched import\export dependencies with linked files.
  2319. #ifdef _WIN64
  2320. // don't call cause it's broken
  2321. #else
  2322. //Check_File_Dependencies(lpszDLLFile);
  2323. #endif
  2324. goto CallProcedureInDll_Exit;
  2325. }
  2326. // Ok module was successfully loaded. now let's try to get the Address of the Procedure
  2327. // Convert the function name to ascii before passing it to GetProcAddress()
  2328. char AsciiProcedureName[255];
  2329. #if defined(UNICODE) || defined(_UNICODE)
  2330. // convert to ascii
  2331. WideCharToMultiByte( CP_ACP, 0, (TCHAR *)lpszProcedureToCall, -1, AsciiProcedureName, 255, NULL, NULL );
  2332. #else
  2333. // the is already ascii so just copy
  2334. strcpy(AsciiProcedureName, lpszProcedureToCall);
  2335. #endif
  2336. iTempProcGood = TRUE;
  2337. if (iFunctionPrototypeFlag == FUNCTION_PARAMS_HMODULE)
  2338. {
  2339. hProc2 = (PFUNCTION2)GetProcAddress(hDll, AsciiProcedureName);
  2340. if (!hProc2){iTempProcGood = FALSE;}
  2341. }
  2342. else
  2343. {
  2344. hProc = (HCRET)GetProcAddress(hDll, AsciiProcedureName);
  2345. if (!hProc){iTempProcGood = FALSE;}
  2346. }
  2347. if (!iTempProcGood)
  2348. {
  2349. // failed to load,find or whatever this function.
  2350. iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("CallProcedureInDll():%1!s!:%2!s!:() FAILED.\n"), lpszDLLFile, lpszProcedureToCall));
  2351. dwReturn = ERROR_PROC_NOT_FOUND;
  2352. if (bDisplayMsgOnErrFlag)
  2353. {
  2354. MyMessageBox(NULL, IDS_UNABLE_TO_LOCATE_PROCEDURE, lpszProcedureToCall, lpszDLLFile, ERROR_PROC_NOT_FOUND, MB_OK | MB_SETFOREGROUND);
  2355. }
  2356. SetLastError(dwReturn);
  2357. goto CallProcedureInDll_Exit;
  2358. }
  2359. // Call the function that we got the handle to
  2360. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("CallProcedureInDll: Calling '%1!s!'.Start\n"), lpszProcedureToCall));
  2361. __try
  2362. {
  2363. if (iFunctionPrototypeFlag == FUNCTION_PARAMS_HMODULE)
  2364. {
  2365. hRes = (*hProc2)((HMODULE) g_MyModuleHandle);
  2366. }
  2367. else
  2368. {
  2369. hRes = (*hProc)();
  2370. }
  2371. }
  2372. __except(EXCEPTION_EXECUTE_HANDLER)
  2373. {
  2374. TCHAR szErrorString[100];
  2375. _stprintf(szErrorString, _T("\r\n\r\nException Caught in CallProcedureInDll(). GetExceptionCode()=0x%x.\r\n\r\n"), GetExceptionCode());
  2376. OutputDebugString(szErrorString);
  2377. g_MyLogFile.LogFileWrite(szErrorString);
  2378. }
  2379. if (FAILED(hRes))
  2380. {
  2381. dwReturn = E_FAIL;
  2382. if (bDisplayMsgOnErrFlag)
  2383. {
  2384. MyMessageBox(NULL, IDS_ERR_CALLING_DLL_PROCEDURE, lpszProcedureToCall, lpszDLLFile, hRes, MB_OK | MB_SETFOREGROUND);
  2385. }
  2386. iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("CallProcedureInDll: Calling '%1!s!'.End.FAILED. Err=%2!x!.\n"), lpszProcedureToCall, hRes));
  2387. // this function returns E_FAIL but
  2388. // the actual error is in GetLastError()
  2389. // set the last error to whatever was returned from the function call
  2390. SetLastError(hRes);
  2391. }
  2392. else
  2393. {
  2394. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("CallProcedureInDll: Calling '%1!s!'.End.SUCCESS.\n"), lpszProcedureToCall));
  2395. }
  2396. CallProcedureInDll_Exit:
  2397. if (hDll)
  2398. {
  2399. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("FreeLibrary.start.\n")));
  2400. FreeLibrary(hDll);
  2401. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("FreeLibrary.end.\n")));
  2402. }
  2403. else
  2404. {
  2405. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Did not FreeLibrary: %1!s! !!!!!!!!!!!!\n"), lpszDLLFile));
  2406. }
  2407. if (_tcscmp(szDirName, _T("")) != 0){SetCurrentDirectory(szDirName);}
  2408. // To close the library gracefully, each successful call to OleInitialize,
  2409. // including those that return S_FALSE, must be balanced by a corresponding
  2410. // call to the OleUninitialize function.
  2411. iOleUnInitialize(bBalanceOLE);
  2412. // perform a defensive check
  2413. if ( FAILED(FTestForOutstandingCoInits()) )
  2414. {
  2415. iisDebugOut((LOG_TYPE_WARN, _T("Outstanding CoInit in %s. WARNING."), lpszDLLFile));
  2416. }
  2417. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("------------------\n")));
  2418. return dwReturn;
  2419. }
  2420. int IsThisStringInThisCStringList(CStringList &strList, LPCTSTR szStringToLookFor)
  2421. {
  2422. int iReturn = FALSE;
  2423. if (strList.IsEmpty() == FALSE)
  2424. {
  2425. POSITION pos = NULL;
  2426. CString csOurString;
  2427. LPTSTR p;
  2428. int nLen = 0;
  2429. pos = strList.GetHeadPosition();
  2430. while (pos)
  2431. {
  2432. csOurString = strList.GetAt(pos);
  2433. nLen += csOurString.GetLength() + 1;
  2434. // check if we have a match.
  2435. if (0 == _tcsicmp(csOurString, szStringToLookFor))
  2436. {
  2437. // we found a match, return true!
  2438. iReturn = TRUE;
  2439. goto IsThisStringInThisCStringList_Exit;
  2440. }
  2441. strList.GetNext(pos);
  2442. }
  2443. }
  2444. IsThisStringInThisCStringList_Exit:
  2445. return iReturn;
  2446. }
  2447. int KillProcess_Wrap(LPCTSTR lpFullPathOrJustFileName)
  2448. {
  2449. int iReturn = FALSE;
  2450. TCHAR szJustTheFileName[_MAX_FNAME];
  2451. // make sure to get only just the filename.
  2452. ReturnFileNameOnly(lpFullPathOrJustFileName, szJustTheFileName);
  2453. // Convert it to ansi for our "kill" function
  2454. char szFile[_MAX_FNAME];
  2455. #if defined(UNICODE) || defined(_UNICODE)
  2456. WideCharToMultiByte( CP_ACP, 0, (WCHAR*)szJustTheFileName, -1, szFile, _MAX_FNAME, NULL, NULL );
  2457. #else
  2458. _tcscpy(szFile, szJustTheFileName);
  2459. #endif
  2460. if (KillProcessNameReturn0(szFile) == 0)
  2461. {
  2462. iReturn = TRUE;
  2463. }
  2464. return iReturn;
  2465. }
  2466. void ProgressBarTextStack_Set(int iStringID)
  2467. {
  2468. CString csText;
  2469. MyLoadString(iStringID, csText);
  2470. ProgressBarTextStack_Push(csText);
  2471. }
  2472. void ProgressBarTextStack_Set(int iStringID, const CString& csFileName)
  2473. {
  2474. CString csText, csPart;
  2475. // configuring the %s deal....
  2476. MyLoadString(iStringID, csPart);
  2477. // configuring the "filename" deal....
  2478. csText.Format(csPart,csFileName);
  2479. ProgressBarTextStack_Push(csText);
  2480. }
  2481. void ProgressBarTextStack_Set(int iStringID, const CString& csString1, const CString& csString2)
  2482. {
  2483. CString csText, csPart;
  2484. // configuring the %s deal....
  2485. MyLoadString(iStringID, csPart);
  2486. // configuring the "filename" deal....
  2487. csText.Format(csPart,csString1, csString2);
  2488. ProgressBarTextStack_Push(csText);
  2489. }
  2490. void ProgressBarTextStack_Set(LPCTSTR szProgressTextString)
  2491. {
  2492. ProgressBarTextStack_Push(szProgressTextString);
  2493. }
  2494. void ProgressBarTextStack_Inst_Set( int ServiceNameID, int iInstanceNum)
  2495. {
  2496. CString csText, csSvcs;
  2497. TCHAR szShortDesc[_MAX_PATH];
  2498. // Configuring Web Site %d
  2499. MyLoadString(ServiceNameID, csSvcs);
  2500. // Configuring Web Site 1
  2501. csText.Format(csSvcs, iInstanceNum);
  2502. ProgressBarTextStack_Push(csText);
  2503. }
  2504. void ProgressBarTextStack_InstVRoot_Set( int ServiceNameID, int iInstanceNum, CString csVRName)
  2505. {
  2506. CString csText, csSvcs;
  2507. TCHAR szShortDesc[_MAX_PATH];
  2508. // Configuring Web Site %d, %s
  2509. MyLoadString(ServiceNameID, csSvcs);
  2510. // Configuring Web Site 1, Virtual Dir %s
  2511. csText.Format(csSvcs, iInstanceNum, csVRName);
  2512. ProgressBarTextStack_Push(csText);
  2513. }
  2514. void ProgressBarTextStack_InstInProc_Set( int ServiceNameID, int iInstanceNum, CString csVRName)
  2515. {
  2516. CString csText, csSvcs;
  2517. TCHAR szShortDesc[_MAX_PATH];
  2518. // Configuring Web Site %d, %s
  2519. MyLoadString(ServiceNameID, csSvcs);
  2520. // Configuring Web Site 1, In process Application %s
  2521. csText.Format(csSvcs, iInstanceNum, csVRName);
  2522. ProgressBarTextStack_Push(csText);
  2523. }
  2524. int ProcessEntry_CheckOS(IN LPCTSTR szOSstring)
  2525. {
  2526. int iTempFlag = TRUE;
  2527. int iOSTypes = 0;
  2528. if (szOSstring)
  2529. {
  2530. // This is workstation, check if we should be installing this on workstation...
  2531. if (g_pTheApp->m_eNTOSType == OT_NTW)
  2532. {
  2533. iTempFlag = FALSE;
  2534. if (IsValidNumber((LPCTSTR)szOSstring))
  2535. {iOSTypes = _ttoi(szOSstring);}
  2536. if (iOSTypes == 0) {iTempFlag = TRUE;}
  2537. if (iOSTypes == 1+2+4) {iTempFlag = TRUE;}
  2538. if (iOSTypes == 1+2) {iTempFlag = TRUE;}
  2539. if (iOSTypes == 2+4) {iTempFlag = TRUE;}
  2540. if (iOSTypes == 2) {iTempFlag = TRUE;}
  2541. }
  2542. if (g_pTheApp->m_eNTOSType == OT_NTS)
  2543. {
  2544. iTempFlag = FALSE;
  2545. if (IsValidNumber((LPCTSTR)szOSstring))
  2546. {iOSTypes = _ttoi(szOSstring);}
  2547. if (iOSTypes == 0) {iTempFlag = TRUE;}
  2548. if (iOSTypes == 1+2+4) {iTempFlag = TRUE;}
  2549. if (iOSTypes == 1+2) {iTempFlag = TRUE;}
  2550. if (iOSTypes == 1+4) {iTempFlag = TRUE;}
  2551. if (iOSTypes == 1) {iTempFlag = TRUE;}
  2552. }
  2553. if (g_pTheApp->m_eNTOSType == OT_PDC_OR_BDC)
  2554. {
  2555. iTempFlag = FALSE;
  2556. if (IsValidNumber((LPCTSTR)szOSstring))
  2557. {iOSTypes = _ttoi(szOSstring);}
  2558. if (iOSTypes == 0) {iTempFlag = TRUE;}
  2559. if (iOSTypes == 1+2+4) {iTempFlag = TRUE;}
  2560. if (iOSTypes == 1+2) {iTempFlag = TRUE;}
  2561. if (iOSTypes == 1+4) {iTempFlag = TRUE;}
  2562. if (iOSTypes == 1) {iTempFlag = TRUE;}
  2563. }
  2564. }
  2565. return iTempFlag;
  2566. }
  2567. int ProcessEntry_CheckEnterprise(IN LPCTSTR szEnterprise)
  2568. {
  2569. int iTempFlag = TRUE;
  2570. int iEnterpriseFlag = 0;
  2571. if (szEnterprise)
  2572. {
  2573. if (IsValidNumber((LPCTSTR)szEnterprise))
  2574. {iEnterpriseFlag = _ttoi(szEnterprise);}
  2575. // This entry should only get installed on enterprise.
  2576. // so check if this machine is an enterprise machine...
  2577. if (iEnterpriseFlag != 0)
  2578. {
  2579. // if this is not an enterprise machine.
  2580. // then return false, since it should not be installed.
  2581. if (TRUE == iReturnTrueIfEnterprise())
  2582. {
  2583. iTempFlag = TRUE;
  2584. }
  2585. else
  2586. {
  2587. iTempFlag = FALSE;
  2588. }
  2589. }
  2590. }
  2591. return iTempFlag;
  2592. }
  2593. int ProcessEntry_PlatArch(IN LPCTSTR szPlatArch)
  2594. {
  2595. int iTempFlag = TRUE;
  2596. int iPlatArchTypes = 0;
  2597. if (szPlatArch)
  2598. {
  2599. // This is x86, then check if we should be installing on x86
  2600. if (_tcsicmp(g_pTheApp->m_csPlatform, _T("x86")) == 0)
  2601. {
  2602. iTempFlag = FALSE;
  2603. if (IsValidNumber((LPCTSTR)szPlatArch))
  2604. {iPlatArchTypes = _ttoi(szPlatArch);}
  2605. if (iPlatArchTypes == 0) {iTempFlag = TRUE;}
  2606. if (iPlatArchTypes == 1+2) {iTempFlag = TRUE;}
  2607. if (iPlatArchTypes == 1) {iTempFlag = TRUE;}
  2608. }
  2609. if (_tcsicmp(g_pTheApp->m_csPlatform, _T("IA64")) == 0)
  2610. {
  2611. iTempFlag = FALSE;
  2612. if (IsValidNumber((LPCTSTR)szPlatArch))
  2613. {iPlatArchTypes = _ttoi(szPlatArch);}
  2614. if (iPlatArchTypes == 0) {iTempFlag = TRUE;}
  2615. if (iPlatArchTypes == 1+2) {iTempFlag = TRUE;}
  2616. if (iPlatArchTypes == 2) {iTempFlag = TRUE;}
  2617. }
  2618. }
  2619. return iTempFlag;
  2620. }
  2621. void ProcessEntry_AskLast(ThingToDo ParsedLine, int iWhichOneToUse)
  2622. {
  2623. if (_tcsicmp(ParsedLine.szMsgBoxAfter, _T("1")) == 0)
  2624. {
  2625. // just incase we have don't display user messagebox off.
  2626. int iSaveOld_AllowMessageBoxPopups = g_pTheApp->m_bAllowMessageBoxPopups;
  2627. // Make sure there are MyMessageBox popups!
  2628. // Make sure there are MyMessageBox popups!
  2629. g_pTheApp->m_bAllowMessageBoxPopups = TRUE;
  2630. if (iWhichOneToUse == 2)
  2631. {MyMessageBox( NULL, IDS_COMPLETED_FILE_CALL,ParsedLine.szData1,MB_OK | MB_SETFOREGROUND );}
  2632. else
  2633. {MyMessageBox( NULL, IDS_COMPLETED_FILE_CALL,ParsedLine.szFileName,MB_OK | MB_SETFOREGROUND );}
  2634. g_pTheApp->m_bAllowMessageBoxPopups = iSaveOld_AllowMessageBoxPopups;
  2635. }
  2636. return;
  2637. }
  2638. int ProcessEntry_AskFirst(ThingToDo ParsedLine, int iWhichOneToUse)
  2639. {
  2640. int iReturn = TRUE;
  2641. int iReturnTemp = 0;
  2642. // check if we need to ask the user if they want to call it for sure.
  2643. if (_tcsicmp(ParsedLine.szMsgBoxBefore, _T("1")) == 0)
  2644. {
  2645. // just incase we have don't display user messagebox off.
  2646. int iSaveOld_AllowMessageBoxPopups = g_pTheApp->m_bAllowMessageBoxPopups;
  2647. // Make sure there are MyMessageBox popups!
  2648. g_pTheApp->m_bAllowMessageBoxPopups = TRUE;
  2649. if (iWhichOneToUse == 2)
  2650. {
  2651. iReturnTemp = MyMessageBox(NULL, IDS_BEFORE_CALLING_FILE, ParsedLine.szData1, MB_YESNO | MB_SETFOREGROUND);
  2652. }
  2653. else
  2654. {
  2655. iReturnTemp = MyMessageBox(NULL, IDS_BEFORE_CALLING_FILE, ParsedLine.szFileName, MB_YESNO | MB_SETFOREGROUND);
  2656. }
  2657. g_pTheApp->m_bAllowMessageBoxPopups = iSaveOld_AllowMessageBoxPopups;
  2658. // display the messagebox
  2659. if (IDYES != iReturnTemp)
  2660. {
  2661. iReturn = FALSE;
  2662. iisDebugOut((LOG_TYPE_TRACE, _T("ProcessEntry_AskFirst:MyMessageBox Response = IDNO. Exiting.\n")));
  2663. }
  2664. }
  2665. return iReturn;
  2666. }
  2667. int ProcessEntry_CheckAll(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  2668. {
  2669. int iReturn = TRUE;
  2670. // Check if we pass for os system
  2671. if (!ProcessEntry_CheckOS(ParsedLine.szOS))
  2672. {
  2673. iReturn = FALSE;
  2674. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ProcessEntry_CheckAll():File=%s. Section=%s. Should not be setup on this OS platform (workstation, server, etc...). Skipping.\n"),ParsedLine.szFileName, szTheSection));
  2675. goto ProcessEntry_CheckAll_Exit;
  2676. }
  2677. // check if we pass for platform arch
  2678. if (!ProcessEntry_PlatArch(ParsedLine.szPlatformArchitecture))
  2679. {
  2680. iReturn = FALSE;
  2681. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ProcessEntry_CheckAll():File=%s. Section=%s. Should not be setup on this plat arch (%s). Skipping.\n"), ParsedLine.szFileName, szTheSection, ParsedLine.szPlatformArchitecture));
  2682. goto ProcessEntry_CheckAll_Exit;
  2683. }
  2684. // check if we pass for enterprise
  2685. if (!ProcessEntry_CheckEnterprise(ParsedLine.szEnterprise))
  2686. {
  2687. iReturn = FALSE;
  2688. goto ProcessEntry_CheckAll_Exit;
  2689. }
  2690. ProcessEntry_CheckAll_Exit:
  2691. return iReturn;
  2692. }
  2693. int ProcessEntry_CallDll(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  2694. {
  2695. int iReturn = FALSE;
  2696. int iTempFlag = FALSE;
  2697. int iProgressBarUpdated = FALSE;
  2698. int iShowErrorsOnFail = TRUE;
  2699. TCHAR szDirBefore[_MAX_PATH];
  2700. _tcscpy(szDirBefore, _T(""));
  2701. // Get the type.
  2702. // 100=Type (1=DllFunction,2=DllFunctionInitOle, 2=Executable, 3=RunThisExe, 4=DoSection, 5=DoINFSection)
  2703. if ( _tcsicmp(ParsedLine.szType, _T("1")) != 0 && _tcsicmp(ParsedLine.szType, _T("2")) != 0 )
  2704. {
  2705. goto ProcessEntry_CallDll_Exit;
  2706. }
  2707. // Check if there is other criteria we need to pass
  2708. if (!ProcessEntry_CheckAll(csEntry, szTheSection, ParsedLine ) )
  2709. {
  2710. goto ProcessEntry_CallDll_Exit;
  2711. }
  2712. // Make sure we have a value for the entry point..
  2713. iTempFlag = FALSE;
  2714. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  2715. if (iTempFlag == FALSE)
  2716. {
  2717. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  2718. goto ProcessEntry_CallDll_Exit;
  2719. }
  2720. // make sure we have a filename entry
  2721. iTempFlag = FALSE;
  2722. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  2723. if (iTempFlag == FALSE)
  2724. {
  2725. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  2726. goto ProcessEntry_CallDll_Exit;
  2727. }
  2728. // make sure the szFileName exists
  2729. if (!IsFileExist(ParsedLine.szFileName))
  2730. {
  2731. // The file does not exists.
  2732. // Check if we need to display an error!
  2733. if (_tcsicmp(ParsedLine.szErrIfFileNotFound, _T("1")) == 0)
  2734. {
  2735. // display the messagebox
  2736. MyMessageBox(NULL, IDS_FILE_DOES_NOT_EXIST, ParsedLine.szFileName, ERROR_FILE_NOT_FOUND, MB_OK | MB_SETFOREGROUND);
  2737. }
  2738. else
  2739. {
  2740. iisDebugOut((LOG_TYPE_TRACE, _T("ProcessEntry_CallDll():FileDoesNotExist=%s.\n"),ParsedLine.szFileName));
  2741. }
  2742. //goto ProcessEntry_CallDll_Exit;
  2743. }
  2744. // At this point the file exists...
  2745. iShowErrorsOnFail = TRUE;
  2746. if (_tcsicmp(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T("1")) == 0)
  2747. {iShowErrorsOnFail = FALSE;}
  2748. // update the progress bar if we need to
  2749. if (_tcsicmp(ParsedLine.szProgressTitle, _T("")) != 0)
  2750. {
  2751. ProgressBarTextStack_Set(ParsedLine.szProgressTitle);
  2752. iProgressBarUpdated = TRUE;
  2753. }
  2754. // Check if we need to change to a specific dir first...
  2755. if (ParsedLine.szChangeDir)
  2756. {
  2757. if (IsFileExist(ParsedLine.szChangeDir))
  2758. {
  2759. // save the current dir
  2760. GetCurrentDirectory( _MAX_PATH, szDirBefore);
  2761. // change to this dir
  2762. SetCurrentDirectory(ParsedLine.szChangeDir);
  2763. }
  2764. }
  2765. // check if we need to ask the user if they want to call it for sure.
  2766. if (!ProcessEntry_AskFirst(ParsedLine, 1))
  2767. {
  2768. goto ProcessEntry_CallDll_Exit;
  2769. }
  2770. // Call the function!!!!!
  2771. if (_tcsicmp(ParsedLine.szType, _T("2")) == 0)
  2772. {
  2773. // Initialize OLE
  2774. // check if they want us to pass them the hmodule for this module
  2775. // so they can call our exported functions (for logging)
  2776. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0)
  2777. {
  2778. CallProcedureInDll_wrap(ParsedLine.szFileName, ParsedLine.szData1, iShowErrorsOnFail, TRUE, FUNCTION_PARAMS_HMODULE);
  2779. }
  2780. else
  2781. {
  2782. CallProcedureInDll_wrap(ParsedLine.szFileName, ParsedLine.szData1, iShowErrorsOnFail, TRUE, FUNCTION_PARAMS_NONE);
  2783. }
  2784. }
  2785. else
  2786. {
  2787. // do not initialize ole!
  2788. // check if they want us to pass them the hmodule for this module
  2789. // so they can call our exported functions (for logging)
  2790. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0)
  2791. {
  2792. CallProcedureInDll_wrap(ParsedLine.szFileName, ParsedLine.szData1, iShowErrorsOnFail, FALSE, FUNCTION_PARAMS_HMODULE);
  2793. }
  2794. else
  2795. {
  2796. CallProcedureInDll_wrap(ParsedLine.szFileName, ParsedLine.szData1, iShowErrorsOnFail, FALSE, FUNCTION_PARAMS_NONE);
  2797. }
  2798. }
  2799. iReturn = TRUE;
  2800. if (ParsedLine.szChangeDir)
  2801. {
  2802. if (szDirBefore)
  2803. {
  2804. // change back to the original dir
  2805. SetCurrentDirectory(szDirBefore);
  2806. }
  2807. }
  2808. // display the messagebox that we completed the call...
  2809. ProcessEntry_AskLast(ParsedLine,1);
  2810. ProcessEntry_CallDll_Exit:
  2811. if (TRUE == iProgressBarUpdated){ProgressBarTextStack_Pop();}
  2812. return iReturn;
  2813. }
  2814. int ProcessEntry_Call_Exe(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  2815. {
  2816. int iReturn = FALSE;
  2817. int iTempNotMinimizedFlag = FALSE;
  2818. int iTempFlag = FALSE;
  2819. int iProgressBarUpdated = FALSE;
  2820. int iShowErrorsOnFail = TRUE;
  2821. int iReturnCode = FALSE;
  2822. int iType = 0;
  2823. DWORD dwTimeOut = INFINITE;
  2824. TCHAR szDirBefore[_MAX_PATH];
  2825. _tcscpy(szDirBefore, _T(""));
  2826. // Get the type.
  2827. // 100=Type (1=DllFunction,2=DllFunctionInitOle, 2=Executable, 3=RunThisExe, 4=DoSection, 5=DoINFSection)
  2828. if ( _tcsicmp(ParsedLine.szType, _T("3")) != 0)
  2829. {
  2830. goto ProcessEntry_Call_Exe_Exit;
  2831. }
  2832. // Check if there is other criteria we need to pass
  2833. if (!ProcessEntry_CheckAll(csEntry, szTheSection, ParsedLine) )
  2834. {
  2835. goto ProcessEntry_Call_Exe_Exit;
  2836. }
  2837. // make sure we have a filename entry
  2838. iTempFlag = FALSE;
  2839. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  2840. if (iTempFlag == FALSE)
  2841. {
  2842. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  2843. goto ProcessEntry_Call_Exe_Exit;
  2844. }
  2845. iShowErrorsOnFail = TRUE;
  2846. if (_tcsicmp(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T("1")) == 0)
  2847. {iShowErrorsOnFail = FALSE;}
  2848. if (_tcsicmp(ParsedLine.szProgressTitle, _T("")) != 0)
  2849. {
  2850. ProgressBarTextStack_Set(ParsedLine.szProgressTitle);
  2851. iProgressBarUpdated = TRUE;
  2852. }
  2853. // Check if we need to change to a specific dir first...
  2854. if (ParsedLine.szChangeDir)
  2855. {
  2856. if (IsFileExist(ParsedLine.szChangeDir))
  2857. {
  2858. // save the current dir
  2859. GetCurrentDirectory( _MAX_PATH, szDirBefore);
  2860. // change to this dir
  2861. SetCurrentDirectory(ParsedLine.szChangeDir);
  2862. }
  2863. }
  2864. // check if we need to ask the user if they want to call it for sure.
  2865. if (!ProcessEntry_AskFirst(ParsedLine, 1))
  2866. {
  2867. goto ProcessEntry_Call_Exe_Exit;
  2868. }
  2869. // make sure the szFileName exists
  2870. if (!IsFileExist(ParsedLine.szFileName))
  2871. {
  2872. // The file does not exists.
  2873. // Check if we need to display an error!
  2874. if (_tcsicmp(ParsedLine.szErrIfFileNotFound, _T("1")) == 0)
  2875. {
  2876. // display the messagebox
  2877. MyMessageBox(NULL, IDS_FILE_DOES_NOT_EXIST, ParsedLine.szFileName, ERROR_FILE_NOT_FOUND, MB_OK | MB_SETFOREGROUND);
  2878. }
  2879. else
  2880. {
  2881. iisDebugOut((LOG_TYPE_TRACE, _T("ProcessEntry_Call_Exe():FileDoesNotExist=%s.\n"),ParsedLine.szFileName));
  2882. }
  2883. //goto ProcessEntry_Call_Exe_Exit;
  2884. }
  2885. // Run The Executable...
  2886. // iShowErrorsOnFail
  2887. iReturnCode = FALSE;
  2888. iType = 0;
  2889. TCHAR szFullPathString[_MAX_PATH + _MAX_PATH + _MAX_PATH];
  2890. _tcscpy(szFullPathString, ParsedLine.szFileName);
  2891. _tcscat(szFullPathString, _T(" "));
  2892. _tcscat(szFullPathString, ParsedLine.szData1);
  2893. // Check if they specified timeout in sections.
  2894. dwTimeOut = INFINITE;
  2895. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0)
  2896. {dwTimeOut = atodw(ParsedLine.szData2);}
  2897. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0)
  2898. {iType = _ttoi(ParsedLine.szData3);}
  2899. if (_tcsicmp(ParsedLine.szData4, _T("")) != 0)
  2900. {iTempNotMinimizedFlag = TRUE;}
  2901. if (ParsedLine.szData1 && _tcsicmp(ParsedLine.szData1, _T("")) != 0)
  2902. {
  2903. switch (iType)
  2904. {
  2905. case 1:
  2906. iReturnCode = RunProgram(ParsedLine.szFileName, ParsedLine.szData1, !iTempNotMinimizedFlag, dwTimeOut, FALSE);
  2907. break;
  2908. case 2:
  2909. iReturnCode = RunProgram(szFullPathString, NULL, !iTempNotMinimizedFlag, dwTimeOut, FALSE);
  2910. break;
  2911. default:
  2912. iReturnCode = RunProgram(NULL, szFullPathString, !iTempNotMinimizedFlag, dwTimeOut, FALSE);
  2913. }
  2914. }
  2915. else
  2916. {
  2917. iReturnCode = RunProgram(ParsedLine.szFileName, NULL, !iTempNotMinimizedFlag, dwTimeOut, FALSE);
  2918. }
  2919. if (iReturnCode != TRUE)
  2920. {
  2921. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szFileName, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  2922. else{iisDebugOut((LOG_TYPE_TRACE, _T("RunProgram(%s). Failed. Err=0x%x.\n"), ParsedLine.szFileName, GetLastError() ));}
  2923. }
  2924. iReturn = TRUE;
  2925. // change back to the original dir
  2926. if (ParsedLine.szChangeDir)
  2927. {if (szDirBefore){SetCurrentDirectory(szDirBefore);}}
  2928. // display the messagebox that we completed the call...
  2929. ProcessEntry_AskLast(ParsedLine,1);
  2930. ProcessEntry_Call_Exe_Exit:
  2931. if (TRUE == iProgressBarUpdated){ProgressBarTextStack_Pop();}
  2932. return iReturn;
  2933. }
  2934. // 100=4
  2935. int ProcessEntry_Internal_iisdll(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  2936. {
  2937. int iReturn = FALSE;
  2938. int iTempFlag = FALSE;
  2939. int iProgressBarUpdated = FALSE;
  2940. int iShowErrorsOnFail = TRUE;
  2941. int iReturnCode = FALSE;
  2942. DWORD dwTimeOut = INFINITE;
  2943. int iFound = FALSE;
  2944. TCHAR szDirBefore[_MAX_PATH];
  2945. _tcscpy(szDirBefore, _T(""));
  2946. // Get the type.
  2947. // 100=Type (1=DllFunction,2=DllFunctionInitOle, 2=Executable, 3=RunThisExe, 4=DoSection, 5=DoINFSection)
  2948. if ( _tcsicmp(ParsedLine.szType, _T("4")) != 0)
  2949. {
  2950. goto ProcessEntry_Internal_iisdll_Exit;
  2951. }
  2952. // Check if there is other criteria we need to pass
  2953. if (!ProcessEntry_CheckAll(csEntry, szTheSection, ParsedLine) )
  2954. {
  2955. goto ProcessEntry_Internal_iisdll_Exit;
  2956. }
  2957. // make sure we have a filename entry
  2958. iTempFlag = FALSE;
  2959. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  2960. if (iTempFlag == FALSE)
  2961. {
  2962. iisDebugOut((LOG_TYPE_TRACE, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  2963. goto ProcessEntry_Internal_iisdll_Exit;
  2964. }
  2965. iShowErrorsOnFail = TRUE;
  2966. if (_tcsicmp(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T("1")) == 0)
  2967. {iShowErrorsOnFail = FALSE;}
  2968. if (_tcsicmp(ParsedLine.szProgressTitle, _T("")) != 0)
  2969. {
  2970. ProgressBarTextStack_Set(ParsedLine.szProgressTitle);
  2971. iProgressBarUpdated = TRUE;
  2972. }
  2973. // Check if we need to change to a specific dir first...
  2974. if (ParsedLine.szChangeDir)
  2975. {
  2976. if (IsFileExist(ParsedLine.szChangeDir))
  2977. {
  2978. // save the current dir
  2979. GetCurrentDirectory( _MAX_PATH, szDirBefore);
  2980. // change to this dir
  2981. SetCurrentDirectory(ParsedLine.szChangeDir);
  2982. }
  2983. }
  2984. // check if we need to ask the user if they want to call it for sure.
  2985. if (!ProcessEntry_AskFirst(ParsedLine, 1))
  2986. {
  2987. goto ProcessEntry_Internal_iisdll_Exit;
  2988. }
  2989. // Get the internal function to call...
  2990. if (_tcsicmp(ParsedLine.szFileName, _T("Register_iis_common")) == 0)
  2991. {iReturnCode = Register_iis_common();iFound=TRUE;}
  2992. if (_tcsicmp(ParsedLine.szFileName, _T("Register_iis_core")) == 0)
  2993. {iReturnCode = Register_iis_core();iFound=TRUE;}
  2994. if (_tcsicmp(ParsedLine.szFileName, _T("Register_iis_inetmgr")) == 0)
  2995. {iReturnCode = Register_iis_inetmgr();iFound=TRUE;}
  2996. if (_tcsicmp(ParsedLine.szFileName, _T("Register_iis_pwmgr")) == 0)
  2997. {iReturnCode = Register_iis_pwmgr();iFound=TRUE;}
  2998. if (_tcsicmp(ParsedLine.szFileName, _T("Register_iis_doc")) == 0)
  2999. {iReturnCode = Register_iis_doc();iFound=TRUE;}
  3000. if (_tcsicmp(ParsedLine.szFileName, _T("Register_iis_htmla")) == 0)
  3001. {iReturnCode = Register_iis_htmla();iFound=TRUE;}
  3002. if (_tcsicmp(ParsedLine.szFileName, _T("Register_iis_www")) == 0)
  3003. {iReturnCode = Register_iis_www();iFound=TRUE;}
  3004. if (_tcsicmp(ParsedLine.szFileName, _T("Register_iis_ftp")) == 0)
  3005. {iReturnCode = Register_iis_ftp();iFound=TRUE;}
  3006. if (_tcsicmp(ParsedLine.szFileName, _T("Unregister_old_asp")) == 0)
  3007. {iReturnCode = Unregister_old_asp();iFound=TRUE;}
  3008. if (_tcsicmp(ParsedLine.szFileName, _T("Unregister_iis_common")) == 0)
  3009. {iReturnCode = Unregister_iis_common();iFound=TRUE;}
  3010. if (_tcsicmp(ParsedLine.szFileName, _T("Unregister_iis_core")) == 0)
  3011. {iReturnCode = Unregister_iis_core();iFound=TRUE;}
  3012. if (_tcsicmp(ParsedLine.szFileName, _T("Unregister_iis_htmla")) == 0)
  3013. {iReturnCode = Unregister_iis_htmla();iFound=TRUE;}
  3014. if (_tcsicmp(ParsedLine.szFileName, _T("Unregister_iis_inetmgr")) == 0)
  3015. {iReturnCode = Unregister_iis_inetmgr();iFound=TRUE;}
  3016. if (_tcsicmp(ParsedLine.szFileName, _T("Unregister_iis_pwmgr")) == 0)
  3017. {iReturnCode = Unregister_iis_pwmgr();iFound=TRUE;}
  3018. if (_tcsicmp(ParsedLine.szFileName, _T("Unregister_iis_www")) == 0)
  3019. {iReturnCode = Unregister_iis_www();iFound=TRUE;}
  3020. if (_tcsicmp(ParsedLine.szFileName, _T("Unregister_iis_ftp")) == 0)
  3021. {iReturnCode = Unregister_iis_ftp();iFound=TRUE;}
  3022. if (iFound != TRUE)
  3023. {
  3024. iisDebugOut((LOG_TYPE_ERROR, _T("%s():FAILURE. Internal Function Does not exist. entry=%s. Section=%s.\n"), _T("ProcessEntry_Internal_iisdll"), csEntry, szTheSection));
  3025. }
  3026. /*
  3027. if (iReturnCode != TRUE)
  3028. {
  3029. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szFileName, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  3030. else{iisDebugOut((LOG_TYPE_TRACE, _T("RunProgram(%s). Failed. Err=0x%x.\n"), ParsedLine.szFileName, GetLastError() ));}
  3031. }
  3032. */
  3033. iReturn = TRUE;
  3034. // change back to the original dir
  3035. if (ParsedLine.szChangeDir)
  3036. {if (szDirBefore){SetCurrentDirectory(szDirBefore);}}
  3037. // display the messagebox that we completed the call...
  3038. ProcessEntry_AskLast(ParsedLine,1);
  3039. ProcessEntry_Internal_iisdll_Exit:
  3040. if (TRUE == iProgressBarUpdated){ProgressBarTextStack_Pop();}
  3041. return iReturn;
  3042. }
  3043. int ProcessEntry_Call_Section(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  3044. {
  3045. int iReturn = FALSE;
  3046. int iTempFlag = FALSE;
  3047. int iProgressBarUpdated = FALSE;
  3048. int iShowErrorsOnFail = TRUE;
  3049. TCHAR szDirBefore[_MAX_PATH];
  3050. _tcscpy(szDirBefore, _T(""));
  3051. // Get the type.
  3052. // 100=Type (1=DllFunction,2=DllFunctionInitOle, 2=Executable, 3=RunThisExe, 4=DoSection, 5=DoINFSection)
  3053. if ( _tcsicmp(ParsedLine.szType, _T("0")) != 0 && _tcsicmp(ParsedLine.szType, _T("5")) != 0 && _tcsicmp(ParsedLine.szType, _T("6")) != 0 )
  3054. {
  3055. goto ProcessEntry_6_Exit;
  3056. }
  3057. // make sure we have a INF Section
  3058. iTempFlag = FALSE;
  3059. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  3060. if (iTempFlag == FALSE)
  3061. {
  3062. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3063. goto ProcessEntry_6_Exit;
  3064. }
  3065. // Check if there is other criteria we need to pass
  3066. if (!ProcessEntry_CheckAll(csEntry, ParsedLine.szData1, ParsedLine) )
  3067. {
  3068. goto ProcessEntry_6_Exit;
  3069. }
  3070. // set the show erros on fail flag
  3071. iShowErrorsOnFail = TRUE;
  3072. if (_tcsicmp(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T("1")) == 0)
  3073. {iShowErrorsOnFail = FALSE;}
  3074. // update the progress bar if we need to
  3075. if (_tcsicmp(ParsedLine.szProgressTitle, _T("")) != 0)
  3076. {
  3077. ProgressBarTextStack_Set(ParsedLine.szProgressTitle);
  3078. iProgressBarUpdated = TRUE;
  3079. }
  3080. // Check if we need to change to a specific dir first...
  3081. if (ParsedLine.szChangeDir)
  3082. {
  3083. if (IsFileExist(ParsedLine.szChangeDir))
  3084. {
  3085. // save the current dir
  3086. GetCurrentDirectory( _MAX_PATH, szDirBefore);
  3087. // change to this dir
  3088. SetCurrentDirectory(ParsedLine.szChangeDir);
  3089. }
  3090. }
  3091. // check if we need to ask the user if they want to call it for sure.
  3092. if (!ProcessEntry_AskFirst(ParsedLine, 2))
  3093. {
  3094. goto ProcessEntry_6_Exit;
  3095. }
  3096. //
  3097. //
  3098. // Run The INF Section ...
  3099. //
  3100. // ParsedLine.szData1
  3101. //
  3102. if ( _tcsicmp(ParsedLine.szType, _T("5")) == 0)
  3103. {
  3104. //
  3105. // Do another one of these "special" install sections
  3106. //
  3107. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData1));
  3108. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData1);
  3109. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData1, iTempFlag));
  3110. // Check if it failed...
  3111. if (FALSE == iTempFlag)
  3112. {
  3113. iisDebugOut((LOG_TYPE_TRACE, _T("SetupInstallFromInfSection(%s). section missing\n"), ParsedLine.szData1));
  3114. }
  3115. }
  3116. if ( _tcsicmp(ParsedLine.szType, _T("6")) == 0)
  3117. {
  3118. //
  3119. // Do a regular ole inf section
  3120. //
  3121. CString csTempSectionName;
  3122. csTempSectionName = ParsedLine.szData1;
  3123. if (GetSectionNameToDo(g_pTheApp->m_hInfHandle, csTempSectionName))
  3124. {
  3125. TCHAR szTempSectionName[_MAX_PATH];
  3126. _tcscpy(szTempSectionName,csTempSectionName);
  3127. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling InstallInfSection:%1!s!:Start.\n"), ParsedLine.szData1));
  3128. iTempFlag = InstallInfSection_NoFiles(g_pTheApp->m_hInfHandle,_T(""),szTempSectionName);
  3129. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling InstallInfSection:%1!s!:End.\n"), ParsedLine.szData1));
  3130. // Check if it failed...
  3131. if (FALSE == iTempFlag)
  3132. {
  3133. // the call failed..
  3134. iisDebugOut((LOG_TYPE_WARN, _T("SetupInstallFromInfSection(%s). Failed. Err=0x%x.\n"), ParsedLine.szData1, GetLastError() ));
  3135. }
  3136. }
  3137. }
  3138. if ( _tcsicmp(ParsedLine.szType, _T("0")) == 0)
  3139. {
  3140. //
  3141. // Do a special installsection deal which queues files in the ocm manage global file queue.
  3142. //
  3143. if (g_GlobalFileQueueHandle)
  3144. {
  3145. // SP_COPY_NOPRUNE = setupapi has a new deal which will prune files from the copyqueue if they already exist on the system.
  3146. // however, the problem with the new deal is that the pruning code does not check if you have the same file
  3147. // queued in the delete or rename queue. specify SP_COPY_NOPRUNE to make sure that our file never gets
  3148. // pruned (removed) from the copy queue. aaronl 12/4/98
  3149. int iCopyType = SP_COPY_NOPRUNE;
  3150. //int iCopyType = SP_COPY_FORCE_NEWER | SP_COPY_NOPRUNE;
  3151. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0)
  3152. {iCopyType = _ttoi(ParsedLine.szData2);}
  3153. CString csTempSectionName;
  3154. csTempSectionName = ParsedLine.szData1;
  3155. if (GetSectionNameToDo(g_pTheApp->m_hInfHandle, csTempSectionName))
  3156. {
  3157. TCHAR szTempSectionName[_MAX_PATH];
  3158. _tcscpy(szTempSectionName,csTempSectionName);
  3159. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("Calling SetupInstallFilesFromInfSection:%1!s!, copytype=%2!d!:Start.\n"), ParsedLine.szData1, iCopyType));
  3160. iTempFlag = SetupInstallFilesFromInfSection(g_pTheApp->m_hInfHandle,NULL,g_GlobalFileQueueHandle,szTempSectionName,NULL,iCopyType);
  3161. g_GlobalFileQueueHandle_ReturnError = iTempFlag;
  3162. }
  3163. }
  3164. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling SetupInstallFilesFromInfSection:%1!s!:End.\n"), ParsedLine.szData1));
  3165. // Check if it failed...
  3166. if (FALSE == iTempFlag)
  3167. {
  3168. // the call failed..
  3169. iisDebugOut((LOG_TYPE_WARN, _T("SetupInstallFromInfSection(%s). Failed. Err=0x%x.\n"), ParsedLine.szData1, GetLastError() ));
  3170. }
  3171. }
  3172. iReturn = TRUE;
  3173. if (ParsedLine.szChangeDir)
  3174. {
  3175. if (szDirBefore)
  3176. {
  3177. // change back to the original dir
  3178. SetCurrentDirectory(szDirBefore);
  3179. }
  3180. }
  3181. // display the messagebox that we completed the call...
  3182. ProcessEntry_AskLast(ParsedLine,2);
  3183. ProcessEntry_6_Exit:
  3184. if (TRUE == iProgressBarUpdated){ProgressBarTextStack_Pop();}
  3185. return iReturn;
  3186. }
  3187. int ProcessEntry_Misc1(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  3188. {
  3189. int iReturn = FALSE;
  3190. int iTempFlag = FALSE;
  3191. int iProgressBarUpdated = FALSE;
  3192. int iShowErrorsOnFail = TRUE;
  3193. TCHAR szDirBefore[_MAX_PATH];
  3194. _tcscpy(szDirBefore, _T(""));
  3195. // Get the type.
  3196. if ( _tcsicmp(ParsedLine.szType, _T("7")) != 0 && _tcsicmp(ParsedLine.szType, _T("8")) != 0 &&
  3197. _tcsicmp(ParsedLine.szType, _T("9")) != 0 && _tcsicmp(ParsedLine.szType, _T("10")) != 0 &&
  3198. _tcsicmp(ParsedLine.szType, _T("11")) != 0 && _tcsicmp(ParsedLine.szType, _T("12")) != 0 &&
  3199. _tcsicmp(ParsedLine.szType, _T("12")) != 0 && _tcsicmp(ParsedLine.szType, _T("13")) != 0 &&
  3200. _tcsicmp(ParsedLine.szType, _T("14")) != 0 && _tcsicmp(ParsedLine.szType, _T("17")) != 0 &&
  3201. _tcsicmp(ParsedLine.szType, _T("18")) != 0
  3202. )
  3203. {
  3204. goto ProcessEntry_Misc1_Exit;
  3205. }
  3206. // Check if there is other criteria we need to pass
  3207. if (!ProcessEntry_CheckAll(csEntry, szTheSection, ParsedLine) )
  3208. {
  3209. goto ProcessEntry_Misc1_Exit;
  3210. }
  3211. // make sure we have a filename entry
  3212. iTempFlag = FALSE;
  3213. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  3214. if (iTempFlag == FALSE)
  3215. {
  3216. // type 10
  3217. // type 12 do not need filename
  3218. if ( _tcsicmp(ParsedLine.szType, _T("10")) != 0 && _tcsicmp(ParsedLine.szType, _T("12")) != 0)
  3219. {
  3220. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3221. goto ProcessEntry_Misc1_Exit;
  3222. }
  3223. }
  3224. //
  3225. // Counters.ini files are always in the system dir
  3226. // tack on the extra stuff, and make sure the file exists...
  3227. //
  3228. if ( _tcsicmp(ParsedLine.szType, _T("7")) == 0)
  3229. {
  3230. CString csFullFilePath;
  3231. csFullFilePath = g_pTheApp->m_csSysDir;
  3232. csFullFilePath += _T("\\");
  3233. csFullFilePath += ParsedLine.szFileName;
  3234. // make sure the szFileName exists
  3235. if (!IsFileExist(csFullFilePath))
  3236. {
  3237. // The file does not exists.
  3238. // Check if we need to display an error!
  3239. if (_tcsicmp(ParsedLine.szErrIfFileNotFound, _T("1")) == 0)
  3240. {
  3241. // display the messagebox
  3242. MyMessageBox(NULL, IDS_FILE_DOES_NOT_EXIST, csFullFilePath, ERROR_FILE_NOT_FOUND, MB_OK | MB_SETFOREGROUND);
  3243. }
  3244. else
  3245. {
  3246. iisDebugOut((LOG_TYPE_TRACE, _T("ProcessEntry_Misc1():FileDoesNotExist=%s.\n"),csFullFilePath));
  3247. }
  3248. goto ProcessEntry_Misc1_Exit;
  3249. }
  3250. }
  3251. //
  3252. // Check if the binary exists for addevent log!
  3253. //
  3254. if ( _tcsicmp(ParsedLine.szType, _T("9")) == 0)
  3255. {
  3256. // make sure the szFileName exists
  3257. if (!IsFileExist(ParsedLine.szFileName))
  3258. {
  3259. // The file does not exists.
  3260. // Check if we need to display an error!
  3261. if (_tcsicmp(ParsedLine.szErrIfFileNotFound, _T("1")) == 0)
  3262. {
  3263. // display the messagebox
  3264. MyMessageBox(NULL, IDS_FILE_DOES_NOT_EXIST, ParsedLine.szFileName, ERROR_FILE_NOT_FOUND, MB_OK | MB_SETFOREGROUND);
  3265. }
  3266. else
  3267. {
  3268. iisDebugOut((LOG_TYPE_TRACE, _T("ProcessEntry_Misc1():FileDoesNotExist=%s.\n"),ParsedLine.szFileName));
  3269. }
  3270. goto ProcessEntry_Misc1_Exit;
  3271. }
  3272. }
  3273. // if this is for addevent log, then check for the other information...
  3274. // AddEventLog( TRUE, _T("W3SVC"), csBinPath, 0x0 );
  3275. // InstallPerformance(REG_WWWPERFORMANCE, _T("w3ctrs.DLL"), _T("OpenW3PerformanceData"), _T("CloseW3PerformanceData"), _T("CollectW3PerformanceData"));
  3276. if ( _tcsicmp(ParsedLine.szType, _T("9")) == 0 || _tcsicmp(ParsedLine.szType, _T("13")) == 0)
  3277. {
  3278. // make sure we have a szData1 entry (
  3279. iTempFlag = FALSE;
  3280. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  3281. if (iTempFlag == FALSE)
  3282. {
  3283. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3284. goto ProcessEntry_Misc1_Exit;
  3285. }
  3286. // make sure we have a szData2 entry
  3287. iTempFlag = FALSE;
  3288. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  3289. if (iTempFlag == FALSE)
  3290. {
  3291. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3292. goto ProcessEntry_Misc1_Exit;
  3293. }
  3294. // make sure we have a szData3 entry
  3295. iTempFlag = FALSE;
  3296. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {iTempFlag = TRUE;}
  3297. if (iTempFlag == FALSE)
  3298. {
  3299. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3300. goto ProcessEntry_Misc1_Exit;
  3301. }
  3302. if ( _tcsicmp(ParsedLine.szType, _T("13")) == 0)
  3303. {
  3304. // make sure we have a szData4 entry
  3305. iTempFlag = FALSE;
  3306. if (_tcsicmp(ParsedLine.szData4, _T("")) != 0) {iTempFlag = TRUE;}
  3307. if (iTempFlag == FALSE)
  3308. {
  3309. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz105_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3310. goto ProcessEntry_Misc1_Exit;
  3311. }
  3312. }
  3313. }
  3314. // if this is for addevent log, then check for the other information...
  3315. //RemoveEventLog( FALSE, _T("W3Ctrs") );
  3316. if ( _tcsicmp(ParsedLine.szType, _T("10")) == 0)
  3317. {
  3318. // make sure we have a szData1 entry
  3319. iTempFlag = FALSE;
  3320. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  3321. if (iTempFlag == FALSE)
  3322. {
  3323. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3324. goto ProcessEntry_Misc1_Exit;
  3325. }
  3326. // make sure we have a szData2 entry
  3327. iTempFlag = FALSE;
  3328. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  3329. if (iTempFlag == FALSE)
  3330. {
  3331. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3332. goto ProcessEntry_Misc1_Exit;
  3333. }
  3334. }
  3335. // if this is for installAgent, check for other data..
  3336. //
  3337. // INT InstallAgent( CString nlsName, CString nlsPath )
  3338. // INT RemoveAgent( CString nlsServiceName )
  3339. //
  3340. if ( _tcsicmp(ParsedLine.szType, _T("11")) == 0 || _tcsicmp(ParsedLine.szType, _T("12")) == 0)
  3341. {
  3342. // make sure we have a szData1 entry
  3343. iTempFlag = FALSE;
  3344. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  3345. if (iTempFlag == FALSE)
  3346. {
  3347. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3348. goto ProcessEntry_Misc1_Exit;
  3349. }
  3350. }
  3351. iShowErrorsOnFail = TRUE;
  3352. if (_tcsicmp(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T("1")) == 0)
  3353. {iShowErrorsOnFail = FALSE;}
  3354. if (_tcsicmp(ParsedLine.szProgressTitle, _T("")) != 0)
  3355. {
  3356. ProgressBarTextStack_Set(ParsedLine.szProgressTitle);
  3357. iProgressBarUpdated = TRUE;
  3358. }
  3359. // Check if we need to change to a specific dir first...
  3360. if (ParsedLine.szChangeDir)
  3361. {
  3362. if (IsFileExist(ParsedLine.szChangeDir))
  3363. {
  3364. // save the current dir
  3365. GetCurrentDirectory( _MAX_PATH, szDirBefore);
  3366. // change to this dir
  3367. SetCurrentDirectory(ParsedLine.szChangeDir);
  3368. }
  3369. }
  3370. // check if we need to ask the user if they want to call it for sure.
  3371. if (!ProcessEntry_AskFirst(ParsedLine, 1))
  3372. {
  3373. goto ProcessEntry_Misc1_Exit;
  3374. }
  3375. //
  3376. // send this to the lodctr function...
  3377. // lodctr(_T("w3ctrs.ini"));
  3378. //
  3379. // see if it's lodctr or unlodctr ....
  3380. //
  3381. if ( _tcsicmp(ParsedLine.szType, _T("7")) == 0)
  3382. {
  3383. lodctr(ParsedLine.szFileName);
  3384. }
  3385. // if this is a unlodctr, should look like this....
  3386. //
  3387. // unlodctr( _T("W3SVC") );
  3388. //
  3389. if ( _tcsicmp(ParsedLine.szType, _T("8")) == 0)
  3390. {
  3391. unlodctr(ParsedLine.szFileName);
  3392. }
  3393. // if this is a AddEventLog, should look like this...
  3394. //
  3395. // AddEventLog( TRUE, _T("W3SVC"), csBinPath, 0x0 );
  3396. //
  3397. if ( _tcsicmp(ParsedLine.szType, _T("9")) == 0)
  3398. {
  3399. int iTempSystemFlag = 0;
  3400. int dwTempEventLogtype = 0;
  3401. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0){iTempSystemFlag = 1;}
  3402. dwTempEventLogtype = atodw(ParsedLine.szData3);
  3403. // Call event log registration function
  3404. AddEventLog( iTempSystemFlag, ParsedLine.szData1, ParsedLine.szFileName, dwTempEventLogtype);
  3405. }
  3406. // if this is a RemoveEventLog, should look like this...
  3407. //
  3408. // RemoveEventLog( FALSE, _T("W3Ctrs") );
  3409. //
  3410. if ( _tcsicmp(ParsedLine.szType, _T("10")) == 0)
  3411. {
  3412. int iTempSystemFlag = 0;
  3413. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0){iTempSystemFlag = 1;}
  3414. // Call event log registration function
  3415. RemoveEventLog(iTempSystemFlag, ParsedLine.szData1);
  3416. }
  3417. // if this is installagent
  3418. //
  3419. // INT InstallAgent( CString nlsName, CString nlsPath )
  3420. // INT RemoveAgent( CString nlsServiceName )
  3421. //
  3422. if ( _tcsicmp(ParsedLine.szType, _T("11")) == 0)
  3423. {
  3424. InstallAgent(ParsedLine.szData1, ParsedLine.szFileName);
  3425. }
  3426. if ( _tcsicmp(ParsedLine.szType, _T("12")) == 0)
  3427. {
  3428. RemoveAgent(ParsedLine.szData1);
  3429. }
  3430. if ( _tcsicmp(ParsedLine.szType, _T("13")) == 0)
  3431. {
  3432. InstallPerformance(ParsedLine.szData1, ParsedLine.szFileName, ParsedLine.szData2, ParsedLine.szData3, ParsedLine.szData4);
  3433. }
  3434. if ( _tcsicmp(ParsedLine.szType, _T("14")) == 0)
  3435. {
  3436. CString csPath = ParsedLine.szFileName;
  3437. CreateLayerDirectory(csPath);
  3438. }
  3439. if ( _tcsicmp(ParsedLine.szType, _T("17")) == 0)
  3440. {
  3441. int iUseWildCards = FALSE;
  3442. if (_tcsicmp(ParsedLine.szData1, _T("1")) == 0){iUseWildCards = TRUE;}
  3443. CString csPath = ParsedLine.szFileName;
  3444. if (iUseWildCards)
  3445. {
  3446. TCHAR szTempDir[_MAX_DRIVE + _MAX_PATH];
  3447. TCHAR szTempFileName[_MAX_PATH + _MAX_EXT];
  3448. if (ReturnFilePathOnly(csPath,szTempDir))
  3449. {
  3450. if (TRUE == ReturnFileNameOnly(csPath, szTempFileName))
  3451. {DeleteFilesWildcard(szTempDir,szTempFileName);}
  3452. }
  3453. }
  3454. else
  3455. {
  3456. InetDeleteFile(csPath);
  3457. }
  3458. }
  3459. if ( _tcsicmp(ParsedLine.szType, _T("18")) == 0)
  3460. {
  3461. int iTempDeleteEvenIfFull = FALSE;
  3462. if (_tcsicmp(ParsedLine.szData1, _T("1")) == 0){iTempDeleteEvenIfFull = 1;}
  3463. CString csPath = ParsedLine.szFileName;
  3464. if (iTempDeleteEvenIfFull)
  3465. {
  3466. RecRemoveDir(csPath);
  3467. }
  3468. else
  3469. {
  3470. RecRemoveEmptyDir(csPath);
  3471. }
  3472. }
  3473. // We called the function, so return true.
  3474. iReturn = TRUE;
  3475. // change back to the original dir
  3476. if (ParsedLine.szChangeDir){if (szDirBefore){SetCurrentDirectory(szDirBefore);}}
  3477. ProcessEntry_AskLast(ParsedLine, 1);
  3478. ProcessEntry_Misc1_Exit:
  3479. if (TRUE == iProgressBarUpdated){ProgressBarTextStack_Pop();}
  3480. return iReturn;
  3481. }
  3482. int ProcessEntry_SVC_Clus(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  3483. {
  3484. int iReturn = FALSE;
  3485. int iReturnTemp = FALSE;
  3486. int iTempFlag = FALSE;
  3487. int iProgressBarUpdated = FALSE;
  3488. int iShowErrorsOnFail = TRUE;
  3489. DWORD dwFailed = ERROR_SUCCESS;
  3490. // Get the type.
  3491. if ( _tcsicmp(ParsedLine.szType, _T("50")) != 0 && _tcsicmp(ParsedLine.szType, _T("51")) != 0 &&
  3492. _tcsicmp(ParsedLine.szType, _T("52")) != 0 && _tcsicmp(ParsedLine.szType, _T("53")) != 0 &&
  3493. _tcsicmp(ParsedLine.szType, _T("54")) != 0 && _tcsicmp(ParsedLine.szType, _T("55")) != 0 &&
  3494. _tcsicmp(ParsedLine.szType, _T("56")) != 0 && _tcsicmp(ParsedLine.szType, _T("57")) != 0 &&
  3495. _tcsicmp(ParsedLine.szType, _T("58")) != 0 && _tcsicmp(ParsedLine.szType, _T("59")) != 0 &&
  3496. _tcsicmp(ParsedLine.szType, _T("60")) != 0 && _tcsicmp(ParsedLine.szType, _T("61")) != 0 &&
  3497. _tcsicmp(ParsedLine.szType, _T("62")) != 0 && _tcsicmp(ParsedLine.szType, _T("63")) != 0 &&
  3498. _tcsicmp(ParsedLine.szType, _T("64")) != 0 && _tcsicmp(ParsedLine.szType, _T("65")) != 0 &&
  3499. _tcsicmp(ParsedLine.szType, _T("66")) != 0 && _tcsicmp(ParsedLine.szType, _T("67")) != 0 &&
  3500. _tcsicmp(ParsedLine.szType, _T("68")) != 0 && _tcsicmp(ParsedLine.szType, _T("69")) != 0
  3501. )
  3502. {
  3503. goto ProcessEntry_SVC_Clus_Exit;
  3504. }
  3505. // Check if there is other criteria we need to pass
  3506. if (!ProcessEntry_CheckAll(csEntry, szTheSection, ParsedLine) )
  3507. {
  3508. goto ProcessEntry_SVC_Clus_Exit;
  3509. }
  3510. if (_tcsicmp(ParsedLine.szType, _T("66")) == 0 || _tcsicmp(ParsedLine.szType, _T("67")) == 0)
  3511. {
  3512. // make sure not to require 102 parameter for 66 or 67
  3513. }
  3514. else
  3515. {
  3516. // make sure we have a szData1 entry
  3517. iTempFlag = FALSE;
  3518. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  3519. if (iTempFlag == FALSE)
  3520. {
  3521. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3522. goto ProcessEntry_SVC_Clus_Exit;
  3523. }
  3524. }
  3525. if ( _tcsicmp(ParsedLine.szType, _T("50")) == 0 || _tcsicmp(ParsedLine.szType, _T("52")) == 0)
  3526. {
  3527. // make sure we have a filename entry
  3528. iTempFlag = FALSE;
  3529. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  3530. if (iTempFlag == FALSE)
  3531. {
  3532. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3533. goto ProcessEntry_SVC_Clus_Exit;
  3534. }
  3535. CString csFullFilePath;
  3536. // Check if the file exists....
  3537. if ( _tcsicmp(ParsedLine.szType, _T("50")) == 0)
  3538. {
  3539. csFullFilePath = g_pTheApp->m_csSysDir;
  3540. csFullFilePath += _T("\\Drivers\\");
  3541. csFullFilePath += ParsedLine.szFileName;
  3542. }
  3543. else
  3544. {
  3545. csFullFilePath = ParsedLine.szFileName;
  3546. }
  3547. // make sure the szFileName exists
  3548. if (!IsFileExist(csFullFilePath))
  3549. {
  3550. // The file does not exists.
  3551. // Check if we need to display an error!
  3552. if (_tcsicmp(ParsedLine.szErrIfFileNotFound, _T("1")) == 0)
  3553. {
  3554. // display the messagebox
  3555. MyMessageBox(NULL, IDS_FILE_DOES_NOT_EXIST, csFullFilePath, ERROR_FILE_NOT_FOUND, MB_OK | MB_SETFOREGROUND);
  3556. goto ProcessEntry_SVC_Clus_Exit;
  3557. }
  3558. else
  3559. {
  3560. iisDebugOut((LOG_TYPE_TRACE, _T("o ProcessEntry_SVC_Clus():FileDoesNotExist=%s.\n"),csFullFilePath));
  3561. }
  3562. }
  3563. // make sure we have a szData2 entry
  3564. iTempFlag = FALSE;
  3565. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  3566. if (iTempFlag == FALSE)
  3567. {
  3568. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3569. goto ProcessEntry_SVC_Clus_Exit;
  3570. }
  3571. }
  3572. iShowErrorsOnFail = TRUE;
  3573. if (_tcsicmp(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T("1")) == 0)
  3574. {iShowErrorsOnFail = FALSE;}
  3575. if (_tcsicmp(ParsedLine.szProgressTitle, _T("")) != 0)
  3576. {
  3577. ProgressBarTextStack_Set(ParsedLine.szProgressTitle);
  3578. iProgressBarUpdated = TRUE;
  3579. }
  3580. // check if we need to ask the user if they want to call it for sure.
  3581. if (!ProcessEntry_AskFirst(ParsedLine, 1))
  3582. {
  3583. goto ProcessEntry_SVC_Clus_Exit;
  3584. }
  3585. // Run The Executable...
  3586. // iShowErrorsOnFail
  3587. dwFailed = ERROR_SUCCESS;
  3588. // Call the function!!!!!
  3589. if (_tcsicmp(ParsedLine.szType, _T("50")) == 0)
  3590. {
  3591. // Create the driver, retry if failed...
  3592. dwFailed = CreateDriver_Wrap(ParsedLine.szData1, ParsedLine.szData2, ParsedLine.szFileName, TRUE);
  3593. if (dwFailed != ERROR_SUCCESS)
  3594. {
  3595. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szFileName, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  3596. else{iisDebugOut((LOG_TYPE_ERROR, _T("CreateDriver(%s). Failed. Err=0x%x.\n"), ParsedLine.szFileName, GetLastError() ));}
  3597. }
  3598. else
  3599. {
  3600. iReturn = TRUE;
  3601. }
  3602. }
  3603. if (_tcsicmp(ParsedLine.szType, _T("51")) == 0)
  3604. {
  3605. // Remove driver.
  3606. dwFailed = InetDeleteService( ParsedLine.szData1 );
  3607. if (dwFailed != 0)
  3608. {
  3609. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szData1, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  3610. else{iisDebugOut((LOG_TYPE_ERROR, _T("InetDeleteService(%s). Failed. Err=0x%x.\n"), ParsedLine.szData1, GetLastError() ));}
  3611. }
  3612. else
  3613. {
  3614. iReturn = TRUE;
  3615. }
  3616. // flag the reboot flag.
  3617. SetRebootFlag();
  3618. }
  3619. if (_tcsicmp(ParsedLine.szType, _T("52")) == 0)
  3620. {
  3621. // Create the service, retry if failed...
  3622. dwFailed = CreateService_wrap(ParsedLine.szData1, ParsedLine.szData2, ParsedLine.szFileName, ParsedLine.szData3, ParsedLine.szData4, TRUE);
  3623. if (dwFailed != ERROR_SUCCESS)
  3624. {
  3625. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szFileName, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  3626. else{iisDebugOut((LOG_TYPE_ERROR, _T("CreateService(%s). Failed. Err=0x%x.\n"), ParsedLine.szFileName, GetLastError() ));}
  3627. }
  3628. else
  3629. {
  3630. iReturn = TRUE;
  3631. }
  3632. }
  3633. if (_tcsicmp(ParsedLine.szType, _T("53")) == 0)
  3634. {
  3635. // Remove Service.
  3636. dwFailed = InetDeleteService( ParsedLine.szData1 );
  3637. if (dwFailed != 0 && dwFailed != ERROR_SERVICE_DOES_NOT_EXIST)
  3638. {
  3639. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szData1, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  3640. else{iisDebugOut((LOG_TYPE_ERROR, _T("InetDeleteService(%s). Failed. Err=0x%x.\n"), ParsedLine.szData1, GetLastError() ));}
  3641. }
  3642. else
  3643. {
  3644. iReturn = TRUE;
  3645. }
  3646. }
  3647. if (_tcsicmp(ParsedLine.szType, _T("54")) == 0)
  3648. {
  3649. // Start Service
  3650. dwFailed = InetStartService(ParsedLine.szData1);
  3651. if (dwFailed == 0 || dwFailed == ERROR_SERVICE_ALREADY_RUNNING)
  3652. {
  3653. // yeah, the service started.
  3654. iReturn = TRUE;
  3655. }
  3656. else
  3657. {
  3658. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szData1, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  3659. else{iisDebugOut((LOG_TYPE_WARN, _T("InetStartService(%s). Unable to start. Err=0x%x.\n"), ParsedLine.szData1, GetLastError() ));}
  3660. }
  3661. }
  3662. if (_tcsicmp(ParsedLine.szType, _T("55")) == 0)
  3663. {
  3664. int iAddToRestartList=FALSE;
  3665. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0) {iAddToRestartList=TRUE;}
  3666. // Stop Service
  3667. dwFailed = StopServiceAndDependencies(ParsedLine.szData1, iAddToRestartList);
  3668. if (dwFailed == FALSE)
  3669. {
  3670. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szData1, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  3671. else{iisDebugOut((LOG_TYPE_ERROR, _T("StopServiceAndDependencies(%s). Failed. Err=0x%x.\n"), ParsedLine.szData1, GetLastError() ));}
  3672. }
  3673. else
  3674. {
  3675. // yeah, the service stopped.
  3676. iReturn = TRUE;
  3677. }
  3678. }
  3679. if (_tcsicmp(ParsedLine.szType, _T("56")) == 0 || _tcsicmp(ParsedLine.szType, _T("57")) == 0)
  3680. {
  3681. int iAdd = FALSE;
  3682. if (_tcsicmp(ParsedLine.szType, _T("56")) == 0) {iAdd = TRUE;}
  3683. // map/unmap to HTTP
  3684. InetRegisterService( g_pTheApp->m_csMachineName, ParsedLine.szData1, &g_HTTPGuid, 0, 80, iAdd);
  3685. iReturn = TRUE;
  3686. }
  3687. if (_tcsicmp(ParsedLine.szType, _T("58")) == 0 || _tcsicmp(ParsedLine.szType, _T("59")) == 0)
  3688. {
  3689. int iAdd = FALSE;
  3690. if (_tcsicmp(ParsedLine.szType, _T("58")) == 0) {iAdd = TRUE;}
  3691. // map/unmap to FTP
  3692. InetRegisterService( g_pTheApp->m_csMachineName, ParsedLine.szData1, &g_FTPGuid, 0, 21, iAdd);
  3693. iReturn = TRUE;
  3694. }
  3695. if (_tcsicmp(ParsedLine.szType, _T("60")) == 0 || _tcsicmp(ParsedLine.szType, _T("61")) == 0)
  3696. {
  3697. int iAdd = FALSE;
  3698. if (_tcsicmp(ParsedLine.szType, _T("60")) == 0) {iAdd = TRUE;}
  3699. // map/unmap to Gopher
  3700. InetRegisterService( g_pTheApp->m_csMachineName, ParsedLine.szData1, &g_GopherGuid, 0, 70, iAdd);
  3701. iReturn = TRUE;
  3702. }
  3703. if (_tcsicmp(ParsedLine.szType, _T("62")) == 0 || _tcsicmp(ParsedLine.szType, _T("63")) == 0)
  3704. {
  3705. int iAdd = FALSE;
  3706. if (_tcsicmp(ParsedLine.szType, _T("62")) == 0) {iAdd = TRUE;}
  3707. // map/unmap to Inetinfo
  3708. InetRegisterService( g_pTheApp->m_csMachineName, ParsedLine.szData1, &g_InetInfoGuid, 0x64e, 0x558, iAdd);
  3709. iReturn = TRUE;
  3710. }
  3711. if (_tcsicmp(ParsedLine.szType, _T("64")) == 0 || _tcsicmp(ParsedLine.szType, _T("65")) == 0)
  3712. {
  3713. iReturn = TRUE;
  3714. // make sure we have everything
  3715. iTempFlag = FALSE;
  3716. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  3717. if (iTempFlag == FALSE)
  3718. {
  3719. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3720. goto ProcessEntry_SVC_Clus_Exit;
  3721. }
  3722. iTempFlag = FALSE;
  3723. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  3724. if (iTempFlag == FALSE)
  3725. {
  3726. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3727. goto ProcessEntry_SVC_Clus_Exit;
  3728. }
  3729. if (_tcsicmp(ParsedLine.szType, _T("64")) == 0)
  3730. {
  3731. iTempFlag = FALSE;
  3732. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  3733. if (iTempFlag == FALSE)
  3734. {
  3735. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3736. goto ProcessEntry_SVC_Clus_Exit;
  3737. }
  3738. iTempFlag = FALSE;
  3739. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {iTempFlag = TRUE;}
  3740. if (iTempFlag == FALSE)
  3741. {
  3742. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3743. goto ProcessEntry_SVC_Clus_Exit;
  3744. }
  3745. // this function only takes wide characters...
  3746. #ifndef _CHICAGO_
  3747. iReturn = RegisterIisServerInstanceResourceType(ParsedLine.szFileName,ParsedLine.szData1,ParsedLine.szData2,ParsedLine.szData3);
  3748. #else
  3749. iisDebugOut((LOG_TYPE_TRACE, _T("RegisterIisServerInstanceResourceType(): not supported under ansi. only unicode.") ));
  3750. #endif
  3751. }
  3752. else
  3753. {
  3754. iTempFlag = FALSE;
  3755. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0) {iTempFlag = TRUE;}
  3756. // this function only takes wide characters...
  3757. #ifndef _CHICAGO_
  3758. iReturn = UnregisterIisServerInstanceResourceType(ParsedLine.szFileName,ParsedLine.szData1,iTempFlag,TRUE);
  3759. #else
  3760. iisDebugOut((LOG_TYPE_TRACE, _T("UnregisterIisServerInstanceResourceType(): not supported under ansi. only unicode.") ));
  3761. #endif
  3762. }
  3763. // iReturn = TRUE;
  3764. }
  3765. if (_tcsicmp(ParsedLine.szType, _T("66")) == 0)
  3766. {
  3767. #ifndef _CHICAGO_
  3768. DWORD dwReturn = 0;
  3769. dwReturn = BringALLIISClusterResourcesOffline();
  3770. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("BringALLIISClusterResourcesOffline ret=%d\n"),dwReturn));
  3771. #endif
  3772. iReturn = TRUE;
  3773. }
  3774. if (_tcsicmp(ParsedLine.szType, _T("67")) == 0)
  3775. {
  3776. #ifndef _CHICAGO_
  3777. DWORD dwReturn = 0;
  3778. dwReturn = BringALLIISClusterResourcesOnline();
  3779. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("BringALLIISClusterResourcesOnline ret=%d\n"),dwReturn));
  3780. #endif
  3781. iReturn = TRUE;
  3782. }
  3783. // Add/remove interactive flag to/from service
  3784. if (_tcsicmp(ParsedLine.szType, _T("68")) == 0 || _tcsicmp(ParsedLine.szType, _T("69")) == 0)
  3785. {
  3786. int iAdd = FALSE;
  3787. if (_tcsicmp(ParsedLine.szType, _T("68")) == 0) {iAdd = TRUE;}
  3788. InetConfigServiceInteractive(ParsedLine.szData1, iAdd);
  3789. iReturn = TRUE;
  3790. }
  3791. // display the messagebox that we completed the call...
  3792. ProcessEntry_AskLast(ParsedLine,1);
  3793. ProcessEntry_SVC_Clus_Exit:
  3794. if (TRUE == iProgressBarUpdated){ProgressBarTextStack_Pop();}
  3795. return iReturn;
  3796. }
  3797. int ProcessEntry_Dcom(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  3798. {
  3799. int iReturn = FALSE;
  3800. int iTempFlag = FALSE;
  3801. int iProgressBarUpdated = FALSE;
  3802. int iShowErrorsOnFail = TRUE;
  3803. DWORD dwFailed = ERROR_SUCCESS;
  3804. // Get the type.
  3805. if ( _tcsicmp(ParsedLine.szType, _T("70")) != 0 && _tcsicmp(ParsedLine.szType, _T("71")) != 0 &&
  3806. _tcsicmp(ParsedLine.szType, _T("72")) != 0 && _tcsicmp(ParsedLine.szType, _T("73")) != 0 &&
  3807. _tcsicmp(ParsedLine.szType, _T("74")) != 0 && _tcsicmp(ParsedLine.szType, _T("75")) != 0 &&
  3808. _tcsicmp(ParsedLine.szType, _T("76")) != 0 && _tcsicmp(ParsedLine.szType, _T("77")) != 0
  3809. )
  3810. {
  3811. goto ProcessEntry_Dcom_Exit;
  3812. }
  3813. // Check if there is other criteria we need to pass
  3814. if (!ProcessEntry_CheckAll(csEntry, szTheSection, ParsedLine) )
  3815. {
  3816. goto ProcessEntry_Dcom_Exit;
  3817. }
  3818. // make sure we have a szData1 entry
  3819. iTempFlag = FALSE;
  3820. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  3821. if (iTempFlag == FALSE)
  3822. {
  3823. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3824. goto ProcessEntry_Dcom_Exit;
  3825. }
  3826. if (_tcsicmp(ParsedLine.szType, _T("74")) == 0 ||
  3827. _tcsicmp(ParsedLine.szType, _T("75")) == 0 ||
  3828. _tcsicmp(ParsedLine.szType, _T("76")) == 0 ||
  3829. _tcsicmp(ParsedLine.szType, _T("77")) == 0)
  3830. {
  3831. // make sure we have a filename entry
  3832. iTempFlag = FALSE;
  3833. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  3834. if (iTempFlag == FALSE)
  3835. {
  3836. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3837. goto ProcessEntry_Dcom_Exit;
  3838. }
  3839. }
  3840. iShowErrorsOnFail = TRUE;
  3841. if (_tcsicmp(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T("1")) == 0)
  3842. {iShowErrorsOnFail = FALSE;}
  3843. if (_tcsicmp(ParsedLine.szProgressTitle, _T("")) != 0)
  3844. {
  3845. ProgressBarTextStack_Set(ParsedLine.szProgressTitle);
  3846. iProgressBarUpdated = TRUE;
  3847. }
  3848. // check if we need to ask the user if they want to call it for sure.
  3849. if (!ProcessEntry_AskFirst(ParsedLine, 1))
  3850. {
  3851. goto ProcessEntry_Dcom_Exit;
  3852. }
  3853. // Run The Executable...
  3854. // iShowErrorsOnFail
  3855. dwFailed = ERROR_SUCCESS;
  3856. // Call the function!!!!!
  3857. // Set dcom launch and access permissions
  3858. if (_tcsicmp(ParsedLine.szType, _T("70")) == 0 || _tcsicmp(ParsedLine.szType, _T("71")) == 0)
  3859. {
  3860. BOOL bDumbCall = FALSE;
  3861. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0)
  3862. {bDumbCall = TRUE;}
  3863. if (_tcsicmp(ParsedLine.szType, _T("70")) == 0)
  3864. {
  3865. dwFailed = ChangeDCOMLaunchACL((LPTSTR)(LPCTSTR)ParsedLine.szData1, TRUE, TRUE, bDumbCall);
  3866. }
  3867. else
  3868. {
  3869. dwFailed = ChangeDCOMLaunchACL((LPTSTR)(LPCTSTR)ParsedLine.szData1, FALSE, FALSE, bDumbCall);
  3870. }
  3871. if (dwFailed != ERROR_SUCCESS)
  3872. {
  3873. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szData1, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  3874. else{iisDebugOut((LOG_TYPE_ERROR, _T("ChangeDCOMAccessACL(%s). Failed. Err=0x%x.\n"), ParsedLine.szData1, GetLastError() ));}
  3875. }
  3876. else
  3877. {
  3878. iReturn = TRUE;
  3879. }
  3880. }
  3881. if (_tcsicmp(ParsedLine.szType, _T("72")) == 0 || _tcsicmp(ParsedLine.szType, _T("73")) == 0)
  3882. {
  3883. BOOL bDumbCall = FALSE;
  3884. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0)
  3885. {bDumbCall = TRUE;}
  3886. if (_tcsicmp(ParsedLine.szType, _T("72")) == 0)
  3887. {
  3888. dwFailed = ChangeDCOMAccessACL((LPTSTR)(LPCTSTR)ParsedLine.szData1, TRUE, TRUE, bDumbCall);
  3889. }
  3890. else
  3891. {
  3892. dwFailed = ChangeDCOMAccessACL((LPTSTR)(LPCTSTR)ParsedLine.szData1, FALSE, FALSE, bDumbCall);
  3893. }
  3894. if (dwFailed != ERROR_SUCCESS)
  3895. {
  3896. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szData1, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  3897. else{iisDebugOut((LOG_TYPE_ERROR, _T("ChangeDCOMAccessACL(%s). Failed. Err=0x%x.\n"), ParsedLine.szData1, GetLastError() ));}
  3898. }
  3899. else
  3900. {
  3901. iReturn = TRUE;
  3902. }
  3903. }
  3904. // dcom launch and access permissions
  3905. if (_tcsicmp(ParsedLine.szType, _T("74")) == 0 || _tcsicmp(ParsedLine.szType, _T("75")) == 0)
  3906. {
  3907. BOOL bDumbCall = FALSE;
  3908. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0)
  3909. {bDumbCall = TRUE;}
  3910. if (_tcsicmp(ParsedLine.szType, _T("74")) == 0)
  3911. {
  3912. dwFailed = ChangeAppIDLaunchACL(ParsedLine.szFileName, (LPTSTR)(LPCTSTR) ParsedLine.szData1, TRUE, TRUE, bDumbCall);
  3913. }
  3914. else
  3915. {
  3916. dwFailed = ChangeAppIDLaunchACL(ParsedLine.szFileName, (LPTSTR)(LPCTSTR) ParsedLine.szData1, FALSE, FALSE, bDumbCall);
  3917. }
  3918. if (dwFailed != ERROR_SUCCESS)
  3919. {
  3920. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szData1, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  3921. else{iisDebugOut((LOG_TYPE_ERROR, _T("ChangeAppIDLaunchACL(%s). Failed. Err=0x%x.\n"), ParsedLine.szData1, GetLastError() ));}
  3922. }
  3923. else
  3924. {
  3925. iReturn = TRUE;
  3926. }
  3927. }
  3928. // dcom launch and access permissions
  3929. if (_tcsicmp(ParsedLine.szType, _T("76")) == 0 || _tcsicmp(ParsedLine.szType, _T("77")) == 0)
  3930. {
  3931. BOOL bDumbCall = FALSE;
  3932. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0)
  3933. {bDumbCall = TRUE;}
  3934. if (_tcsicmp(ParsedLine.szType, _T("76")) == 0)
  3935. {
  3936. dwFailed = ChangeAppIDAccessACL(ParsedLine.szFileName, (LPTSTR)(LPCTSTR) ParsedLine.szData1, TRUE, TRUE, bDumbCall);
  3937. }
  3938. else
  3939. {
  3940. dwFailed = ChangeAppIDAccessACL(ParsedLine.szFileName, (LPTSTR)(LPCTSTR) ParsedLine.szData1, FALSE, FALSE, bDumbCall);
  3941. }
  3942. if (dwFailed != ERROR_SUCCESS)
  3943. {
  3944. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szData1, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  3945. else{iisDebugOut((LOG_TYPE_ERROR, _T("ChangeAppIDAccessACL(%s). Failed. Err=0x%x.\n"), ParsedLine.szData1, GetLastError() ));}
  3946. }
  3947. else
  3948. {
  3949. iReturn = TRUE;
  3950. }
  3951. }
  3952. // display the messagebox that we completed the call...
  3953. ProcessEntry_AskLast(ParsedLine,1);
  3954. // We called the function, so return true.
  3955. iReturn = TRUE;
  3956. ProcessEntry_Dcom_Exit:
  3957. return iReturn;
  3958. }
  3959. // function: IsMachineInDomain
  3960. //
  3961. // Test to see if the machine is in a domain, or if it
  3962. // is in a workstation
  3963. //
  3964. // Return Values:
  3965. // TRUE - In a domain
  3966. // FALSE - Not in a domain
  3967. //
  3968. int IsMachineInDomain()
  3969. {
  3970. DWORD dwRet;
  3971. LPBYTE pDomain = NULL;
  3972. // Retrieve the domain which this computer trusts.
  3973. // Hence: success->in a domain; error->not in a domain
  3974. dwRet = NetGetAnyDCName(NULL,NULL,&pDomain);
  3975. if (pDomain)
  3976. {
  3977. NetApiBufferFree(pDomain);
  3978. }
  3979. if (dwRet == NERR_Success)
  3980. {
  3981. return TRUE;
  3982. }
  3983. // Default Return Value is FALSE
  3984. return FALSE;
  3985. }
  3986. // function: RetrieveDomain
  3987. //
  3988. // Retrieve the domain that the current machine is in
  3989. //
  3990. // Parameters:
  3991. // [out] csDomainName - The name of the domain
  3992. //
  3993. // Return:
  3994. // TRUE - It worked
  3995. // FALSE - It Failed
  3996. //
  3997. int RetrieveDomain(CString &csDomainName)
  3998. {
  3999. PDOMAIN_CONTROLLER_INFO pDci;
  4000. if ( NO_ERROR != DsGetDcName( NULL, // Localhost
  4001. NULL, // No specific domain
  4002. NULL, // No Guid Specified
  4003. NULL, // No Site
  4004. 0, // No Flags
  4005. &pDci)
  4006. )
  4007. {
  4008. return FALSE;
  4009. }
  4010. // Copy string into csDomainName
  4011. csDomainName = pDci->DomainName;
  4012. NetApiBufferFree(pDci);
  4013. return TRUE;
  4014. }
  4015. int ProcessEntry_If(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  4016. {
  4017. int iReturn = FALSE;
  4018. int iTempFlag = FALSE;
  4019. int iTempFlag2 = FALSE;
  4020. int ifTrueStatementExists = FALSE;
  4021. int ifFalseStatementExists = FALSE;
  4022. // Get the type.
  4023. if (_tcsicmp(ParsedLine.szType, _T("39")) != 0 &&
  4024. _tcsicmp(ParsedLine.szType, _T("40")) != 0 && _tcsicmp(ParsedLine.szType, _T("41")) != 0 &&
  4025. _tcsicmp(ParsedLine.szType, _T("42")) != 0 && _tcsicmp(ParsedLine.szType, _T("43")) != 0 &&
  4026. _tcsicmp(ParsedLine.szType, _T("44")) != 0 && _tcsicmp(ParsedLine.szType, _T("45")) != 0 &&
  4027. _tcsicmp(ParsedLine.szType, _T("46")) != 0 && _tcsicmp(ParsedLine.szType, _T("47")) != 0 &&
  4028. _tcsicmp(ParsedLine.szType, _T("48")) != 0 && _tcsicmp(ParsedLine.szType, _T("49")) != 0 &&
  4029. _tcsicmp(ParsedLine.szType, _T("100")) != 0 && _tcsicmp(ParsedLine.szType, _T("119")) != 0
  4030. )
  4031. {
  4032. goto ProcessEntry_If_Exit;
  4033. }
  4034. // Check if there is other criteria we need to pass
  4035. if (!ProcessEntry_CheckAll(csEntry, szTheSection, ParsedLine) )
  4036. {
  4037. goto ProcessEntry_If_Exit;
  4038. }
  4039. if ( _tcsicmp(ParsedLine.szType, _T("40")) == 0)
  4040. {
  4041. // make sure we have a filename entry
  4042. iTempFlag = FALSE;
  4043. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4044. if (iTempFlag == FALSE)
  4045. {
  4046. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4047. goto ProcessEntry_If_Exit;
  4048. }
  4049. iTempFlag = FALSE;
  4050. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  4051. if (iTempFlag == FALSE)
  4052. {
  4053. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4054. goto ProcessEntry_If_Exit;
  4055. }
  4056. // make sure there is a szData3 or a szData4.
  4057. ifTrueStatementExists = FALSE;
  4058. ifFalseStatementExists = FALSE;
  4059. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4060. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4061. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4062. {
  4063. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4064. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4065. goto ProcessEntry_If_Exit;
  4066. }
  4067. // okay we have either szData3 or szData4
  4068. HKEY hRootKeyType = HKEY_LOCAL_MACHINE;
  4069. // check if the registry key exists...
  4070. if ( _tcsicmp(ParsedLine.szFileName, _T("HKLM")) == 0){hRootKeyType = HKEY_LOCAL_MACHINE;}
  4071. if ( _tcsicmp(ParsedLine.szFileName, _T("HKCR")) == 0){hRootKeyType = HKEY_CLASSES_ROOT;}
  4072. if ( _tcsicmp(ParsedLine.szFileName, _T("HKCU")) == 0){hRootKeyType = HKEY_CURRENT_USER;}
  4073. if ( _tcsicmp(ParsedLine.szFileName, _T("HKU")) == 0){hRootKeyType = HKEY_USERS;}
  4074. iTempFlag = FALSE;
  4075. CRegKey regTheKey(hRootKeyType, ParsedLine.szData1,KEY_READ);
  4076. if ((HKEY) regTheKey) {iTempFlag = TRUE;}
  4077. if (iTempFlag == TRUE)
  4078. {
  4079. // the result was true
  4080. // the key exists, so let's do the section...
  4081. if (ifTrueStatementExists)
  4082. {
  4083. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  4084. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  4085. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  4086. }
  4087. }
  4088. else
  4089. {
  4090. // the result was false
  4091. if (ifFalseStatementExists)
  4092. {
  4093. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData3));
  4094. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData3);
  4095. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData3, iTempFlag));
  4096. }
  4097. }
  4098. }
  4099. if ( _tcsicmp(ParsedLine.szType, _T("41")) == 0)
  4100. {
  4101. // make sure we have a filename entry
  4102. iTempFlag = FALSE;
  4103. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4104. if (iTempFlag == FALSE)
  4105. {
  4106. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4107. goto ProcessEntry_If_Exit;
  4108. }
  4109. iTempFlag = FALSE;
  4110. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  4111. if (iTempFlag == FALSE)
  4112. {
  4113. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4114. goto ProcessEntry_If_Exit;
  4115. }
  4116. iTempFlag = FALSE;
  4117. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  4118. if (iTempFlag == FALSE)
  4119. {
  4120. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4121. goto ProcessEntry_If_Exit;
  4122. }
  4123. // make sure there is a szData3 or a szData4.
  4124. ifTrueStatementExists = FALSE;
  4125. ifFalseStatementExists = FALSE;
  4126. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4127. if (_tcsicmp(ParsedLine.szData4, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4128. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4129. {
  4130. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4131. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz105_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4132. goto ProcessEntry_If_Exit;
  4133. }
  4134. // okay we have either szData3 or szData4
  4135. HKEY hRootKeyType = HKEY_LOCAL_MACHINE;
  4136. // check if the registry key exists...
  4137. if ( _tcsicmp(ParsedLine.szFileName, _T("HKLM")) == 0){hRootKeyType = HKEY_LOCAL_MACHINE;}
  4138. if ( _tcsicmp(ParsedLine.szFileName, _T("HKCR")) == 0){hRootKeyType = HKEY_CLASSES_ROOT;}
  4139. if ( _tcsicmp(ParsedLine.szFileName, _T("HKCU")) == 0){hRootKeyType = HKEY_CURRENT_USER;}
  4140. if ( _tcsicmp(ParsedLine.szFileName, _T("HKU")) == 0){hRootKeyType = HKEY_USERS;}
  4141. iTempFlag = FALSE;
  4142. CRegKey regTheKey(hRootKeyType, ParsedLine.szData1,KEY_READ);
  4143. CString strReturnQueryValue;
  4144. if ((HKEY) regTheKey)
  4145. {
  4146. if (ERROR_SUCCESS == regTheKey.QueryValue(ParsedLine.szData2, strReturnQueryValue))
  4147. {iTempFlag = TRUE;}
  4148. // If we failed to read it as a string, try a dword
  4149. if (FALSE == iTempFlag)
  4150. {
  4151. DWORD dwTheReturnDword = 0;
  4152. if (ERROR_SUCCESS == regTheKey.QueryValue(ParsedLine.szData2, dwTheReturnDword))
  4153. {iTempFlag = TRUE;}
  4154. }
  4155. // If we failed to read it as dword, try a binary
  4156. if (FALSE == iTempFlag)
  4157. {
  4158. CByteArray baData;
  4159. if (ERROR_SUCCESS == regTheKey.QueryValue(ParsedLine.szData2, baData))
  4160. {iTempFlag = TRUE;}
  4161. }
  4162. }
  4163. if (iTempFlag == TRUE)
  4164. {
  4165. if (ifTrueStatementExists)
  4166. {
  4167. // the key exists, so let's do the section...
  4168. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData3));
  4169. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData3);
  4170. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData3, iTempFlag));
  4171. }
  4172. }
  4173. else
  4174. {
  4175. if (ifFalseStatementExists)
  4176. {
  4177. // the key exists, so let's do the section...
  4178. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData4));
  4179. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData4);
  4180. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData4, iTempFlag));
  4181. }
  4182. }
  4183. }
  4184. if ( _tcsicmp(ParsedLine.szType, _T("42")) == 0)
  4185. {
  4186. // make sure we have a filename entry
  4187. iTempFlag = FALSE;
  4188. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4189. if (iTempFlag == FALSE)
  4190. {
  4191. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4192. goto ProcessEntry_If_Exit;
  4193. }
  4194. // make sure there is a szData1 or a szData2
  4195. ifTrueStatementExists = FALSE;
  4196. ifFalseStatementExists = FALSE;
  4197. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4198. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4199. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4200. {
  4201. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4202. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4203. goto ProcessEntry_If_Exit;
  4204. }
  4205. // okay we have either szData1 or szData2
  4206. // Check if the filename or dir exists...
  4207. iTempFlag = FALSE;
  4208. if (IsFileExist(ParsedLine.szFileName))
  4209. {iTempFlag = TRUE;}
  4210. if (iTempFlag == TRUE)
  4211. {
  4212. // the result was true
  4213. // the key exists, so let's do the section...
  4214. if (ifTrueStatementExists)
  4215. {
  4216. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData1));
  4217. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData1);
  4218. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData1, iTempFlag));
  4219. }
  4220. }
  4221. else
  4222. {
  4223. // the result was false
  4224. if (ifFalseStatementExists)
  4225. {
  4226. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  4227. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  4228. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  4229. }
  4230. }
  4231. }
  4232. if ( _tcsicmp(ParsedLine.szType, _T("43")) == 0)
  4233. {
  4234. // make sure we have a filename entry
  4235. iTempFlag = FALSE;
  4236. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4237. if (iTempFlag == FALSE)
  4238. {
  4239. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4240. goto ProcessEntry_If_Exit;
  4241. }
  4242. iTempFlag = FALSE;
  4243. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  4244. if (iTempFlag == FALSE)
  4245. {
  4246. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4247. goto ProcessEntry_If_Exit;
  4248. }
  4249. iTempFlag = FALSE;
  4250. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  4251. if (iTempFlag == FALSE)
  4252. {
  4253. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4254. goto ProcessEntry_If_Exit;
  4255. }
  4256. // make sure there is a szData3 or a szData4.
  4257. ifTrueStatementExists = FALSE;
  4258. ifFalseStatementExists = FALSE;
  4259. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4260. if (_tcsicmp(ParsedLine.szData4, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4261. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4262. {
  4263. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4264. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz105_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4265. goto ProcessEntry_If_Exit;
  4266. }
  4267. // okay we have either szData3 or szData4
  4268. HKEY hRootKeyType = HKEY_LOCAL_MACHINE;
  4269. // check if the registry key exists...
  4270. if ( _tcsicmp(ParsedLine.szFileName, _T("HKLM")) == 0){hRootKeyType = HKEY_LOCAL_MACHINE;}
  4271. if ( _tcsicmp(ParsedLine.szFileName, _T("HKCR")) == 0){hRootKeyType = HKEY_CLASSES_ROOT;}
  4272. if ( _tcsicmp(ParsedLine.szFileName, _T("HKCU")) == 0){hRootKeyType = HKEY_CURRENT_USER;}
  4273. if ( _tcsicmp(ParsedLine.szFileName, _T("HKU")) == 0){hRootKeyType = HKEY_USERS;}
  4274. // ParsedLine.szData1 = Software\Microsoft\etc..\TheValueToCheck
  4275. // so take off the last one and use that as the value to look up.
  4276. TCHAR theRegValuePart[100];
  4277. LPTSTR pszTempPointer = NULL;
  4278. pszTempPointer = _tcsrchr((LPTSTR) ParsedLine.szData1, _T('\\'));
  4279. if (pszTempPointer)
  4280. {
  4281. *pszTempPointer = _T('\0');
  4282. //set the "\" to a null
  4283. // increment to after the pointer
  4284. pszTempPointer = _tcsninc( pszTempPointer, _tcslen(pszTempPointer))+1;
  4285. _tcscpy(theRegValuePart, pszTempPointer );
  4286. }
  4287. //iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Var:Key=%1!s!:Value=%2!s!.\n"), ParsedLine.szData1, theRegValuePart));
  4288. iTempFlag = FALSE;
  4289. CRegKey regTheKey(hRootKeyType, ParsedLine.szData1,KEY_READ);
  4290. DWORD dwTheReturnDword = 0;
  4291. if ((HKEY) regTheKey)
  4292. {
  4293. if (ERROR_SUCCESS == regTheKey.QueryValue(theRegValuePart, dwTheReturnDword))
  4294. {
  4295. // Check against the value they want to check against.
  4296. DWORD dwCheckDword = atodw(ParsedLine.szData2);
  4297. if (dwTheReturnDword == dwCheckDword)
  4298. {
  4299. iTempFlag = TRUE;
  4300. }
  4301. }
  4302. }
  4303. if (iTempFlag == TRUE)
  4304. {
  4305. if (ifTrueStatementExists)
  4306. {
  4307. // the key exists, so let's do the section...
  4308. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData3));
  4309. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData3);
  4310. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData3, iTempFlag));
  4311. }
  4312. }
  4313. else
  4314. {
  4315. if (ifFalseStatementExists)
  4316. {
  4317. // the key exists, so let's do the section...
  4318. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData4));
  4319. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData4);
  4320. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData4, iTempFlag));
  4321. }
  4322. }
  4323. }
  4324. if ( _tcsicmp(ParsedLine.szType, _T("44")) == 0)
  4325. {
  4326. // make sure we have a filename entry
  4327. iTempFlag = FALSE;
  4328. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4329. if (iTempFlag == FALSE)
  4330. {
  4331. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4332. goto ProcessEntry_If_Exit;
  4333. }
  4334. iTempFlag = FALSE;
  4335. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  4336. if (iTempFlag == FALSE)
  4337. {
  4338. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4339. goto ProcessEntry_If_Exit;
  4340. }
  4341. iTempFlag = FALSE;
  4342. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  4343. if (iTempFlag == FALSE)
  4344. {
  4345. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4346. goto ProcessEntry_If_Exit;
  4347. }
  4348. // make sure there is a szData3 or a szData4.
  4349. ifTrueStatementExists = FALSE;
  4350. ifFalseStatementExists = FALSE;
  4351. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4352. if (_tcsicmp(ParsedLine.szData4, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4353. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4354. {
  4355. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4356. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz105_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4357. goto ProcessEntry_If_Exit;
  4358. }
  4359. // okay we have either szData3 or szData4
  4360. HKEY hRootKeyType = HKEY_LOCAL_MACHINE;
  4361. // check if the registry key exists...
  4362. if ( _tcsicmp(ParsedLine.szFileName, _T("HKLM")) == 0){hRootKeyType = HKEY_LOCAL_MACHINE;}
  4363. if ( _tcsicmp(ParsedLine.szFileName, _T("HKCR")) == 0){hRootKeyType = HKEY_CLASSES_ROOT;}
  4364. if ( _tcsicmp(ParsedLine.szFileName, _T("HKCU")) == 0){hRootKeyType = HKEY_CURRENT_USER;}
  4365. if ( _tcsicmp(ParsedLine.szFileName, _T("HKU")) == 0){hRootKeyType = HKEY_USERS;}
  4366. // ParsedLine.szData1 = Software\Microsoft\etc..\TheValueToCheck
  4367. // so take off the last one and use that as the value to look up.
  4368. TCHAR theRegValuePart[100];
  4369. LPTSTR pszTempPointer = NULL;
  4370. pszTempPointer = _tcsrchr((LPTSTR) ParsedLine.szData1, _T('\\'));
  4371. if (pszTempPointer)
  4372. {
  4373. *pszTempPointer = _T('\0');
  4374. //set the "\" to a null
  4375. // increment to after the pointer
  4376. pszTempPointer = _tcsninc( pszTempPointer, _tcslen(pszTempPointer))+1;
  4377. _tcscpy(theRegValuePart, pszTempPointer );
  4378. }
  4379. //iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Var:Key=%1!s!:Value=%2!s!.\n"), ParsedLine.szData1, theRegValuePart));
  4380. iTempFlag = FALSE;
  4381. CRegKey regTheKey(hRootKeyType, ParsedLine.szData1,KEY_READ);
  4382. CString strReturnQueryValue;
  4383. if ((HKEY) regTheKey)
  4384. {
  4385. if (ERROR_SUCCESS == regTheKey.QueryValue(theRegValuePart, strReturnQueryValue))
  4386. {
  4387. if (_tcsicmp(strReturnQueryValue,ParsedLine.szData2) == 0)
  4388. {
  4389. iTempFlag = TRUE;
  4390. }
  4391. }
  4392. }
  4393. if (iTempFlag == TRUE)
  4394. {
  4395. if (ifTrueStatementExists)
  4396. {
  4397. // the key exists, so let's do the section...
  4398. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData3));
  4399. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData3);
  4400. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData3, iTempFlag));
  4401. }
  4402. }
  4403. else
  4404. {
  4405. if (ifFalseStatementExists)
  4406. {
  4407. // the key exists, so let's do the section...
  4408. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData4));
  4409. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData4);
  4410. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData4, iTempFlag));
  4411. }
  4412. }
  4413. }
  4414. if ( _tcsicmp(ParsedLine.szType, _T("45")) == 0)
  4415. {
  4416. // make sure we have a filename entry
  4417. iTempFlag = FALSE;
  4418. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4419. if (iTempFlag == FALSE)
  4420. {
  4421. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4422. goto ProcessEntry_If_Exit;
  4423. }
  4424. // make sure there is a szData1 or a szData2
  4425. ifTrueStatementExists = FALSE;
  4426. ifFalseStatementExists = FALSE;
  4427. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4428. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4429. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4430. {
  4431. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4432. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4433. goto ProcessEntry_If_Exit;
  4434. }
  4435. // okay we have either szData1 or szData2
  4436. // Check if the Service exists...
  4437. iTempFlag = FALSE;
  4438. if (CheckifServiceExist(ParsedLine.szFileName) == 0 )
  4439. {
  4440. // yes the service exists..
  4441. iTempFlag = TRUE;
  4442. }
  4443. if (iTempFlag == TRUE)
  4444. {
  4445. // the result was true
  4446. // the key exists, so let's do the section...
  4447. if (ifTrueStatementExists)
  4448. {
  4449. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData1));
  4450. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData1);
  4451. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData1, iTempFlag));
  4452. }
  4453. }
  4454. else
  4455. {
  4456. // the result was false
  4457. if (ifFalseStatementExists)
  4458. {
  4459. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  4460. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  4461. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  4462. }
  4463. }
  4464. }
  4465. if ( _tcsicmp(ParsedLine.szType, _T("46")) == 0)
  4466. {
  4467. // make sure we have a filename entry
  4468. iTempFlag = FALSE;
  4469. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4470. if (iTempFlag == FALSE)
  4471. {
  4472. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4473. goto ProcessEntry_If_Exit;
  4474. }
  4475. // make sure there is a szData1 or a szData2
  4476. ifTrueStatementExists = FALSE;
  4477. ifFalseStatementExists = FALSE;
  4478. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4479. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4480. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4481. {
  4482. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4483. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4484. goto ProcessEntry_If_Exit;
  4485. }
  4486. // okay we have either szData1 or szData2
  4487. // Check if the Service exists...and is running..
  4488. iTempFlag = FALSE;
  4489. if (InetQueryServiceStatus(ParsedLine.szFileName) == SERVICE_RUNNING)
  4490. {
  4491. // yes the service exists..and is running...
  4492. iTempFlag = TRUE;
  4493. }
  4494. if (iTempFlag == TRUE)
  4495. {
  4496. // the result was true
  4497. // the key exists, so let's do the section...
  4498. if (ifTrueStatementExists)
  4499. {
  4500. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData1));
  4501. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData1);
  4502. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData1, iTempFlag));
  4503. }
  4504. }
  4505. else
  4506. {
  4507. // the result was false
  4508. if (ifFalseStatementExists)
  4509. {
  4510. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  4511. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  4512. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  4513. }
  4514. }
  4515. }
  4516. if ( _tcsicmp(ParsedLine.szType, _T("47")) == 0)
  4517. {
  4518. // make sure we have a filename entry
  4519. iTempFlag = FALSE;
  4520. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4521. if (iTempFlag == FALSE)
  4522. {
  4523. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4524. goto ProcessEntry_If_Exit;
  4525. }
  4526. iTempFlag = FALSE;
  4527. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  4528. if (iTempFlag == FALSE)
  4529. {
  4530. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4531. goto ProcessEntry_If_Exit;
  4532. }
  4533. // make sure there is a szData3 or a szData4.
  4534. ifTrueStatementExists = FALSE;
  4535. ifFalseStatementExists = FALSE;
  4536. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4537. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4538. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4539. {
  4540. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4541. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4542. goto ProcessEntry_If_Exit;
  4543. }
  4544. // okay we have either szData3 or szData4
  4545. // Check if the values match.
  4546. iTempFlag = FALSE;
  4547. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("ProcessEntry_If:check if [%1!s!=%2!s!]\n"), ParsedLine.szFileName, ParsedLine.szData1));
  4548. if ( _tcsicmp(ParsedLine.szFileName, ParsedLine.szData1) == 0)
  4549. {
  4550. iTempFlag = TRUE;
  4551. }
  4552. if (iTempFlag == TRUE)
  4553. {
  4554. // the result was true
  4555. // the key exists, so let's do the section...
  4556. if (ifTrueStatementExists)
  4557. {
  4558. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  4559. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  4560. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  4561. }
  4562. }
  4563. else
  4564. {
  4565. // the result was false
  4566. if (ifFalseStatementExists)
  4567. {
  4568. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData3));
  4569. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData3);
  4570. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData3, iTempFlag));
  4571. }
  4572. }
  4573. }
  4574. if ( _tcsicmp(ParsedLine.szType, _T("48")) == 0)
  4575. {
  4576. // make sure we have a filename entry
  4577. iTempFlag = FALSE;
  4578. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4579. if (iTempFlag == FALSE)
  4580. {
  4581. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4582. goto ProcessEntry_If_Exit;
  4583. }
  4584. // make sure there is a szData1 or a szData2
  4585. ifTrueStatementExists = FALSE;
  4586. ifFalseStatementExists = FALSE;
  4587. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4588. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4589. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4590. {
  4591. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4592. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4593. goto ProcessEntry_If_Exit;
  4594. }
  4595. // okay we have either szData1 or szData2
  4596. // Check if the language specified in the .inf corresponds to
  4597. // our systems language.
  4598. iTempFlag = FALSE;
  4599. // Get our language
  4600. // set iTempFlag to true if it matches the same language they specified.
  4601. DWORD thid;
  4602. LCID ThisThreadsLocale = GetThreadLocale();
  4603. LCID SystemDefaultLocale = GetSystemDefaultLCID();
  4604. LCID UserDefaultLocale = GetUserDefaultLCID();
  4605. HANDLE hHackThread = CreateThread (NULL,0,GetNewlyCreatedThreadLocale,NULL,0,&thid);
  4606. if (hHackThread)
  4607. {
  4608. // wait for 10 secs only
  4609. DWORD res = WaitForSingleObject (hHackThread,10*1000);
  4610. if (res == WAIT_TIMEOUT)
  4611. {
  4612. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ERROR GetNewlyCreatedThreadLocale thread never finished...\n")));
  4613. // iTempFlag will be false.
  4614. }
  4615. else
  4616. {
  4617. iisDebugOut((LOG_TYPE_TRACE, _T("ThisThreadsLocale=%0x, GetNewlyCreatedThreadLocale=%0x\n"),ThisThreadsLocale,g_MyTrueThreadLocale));
  4618. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("SystemDefaultLocale=%0x, UserDefaultLocale=%0x\n"),SystemDefaultLocale,UserDefaultLocale));
  4619. CloseHandle (hHackThread);
  4620. // Check if g_MyTrueThreadLocale matches the one in the .inf file!
  4621. DWORD dwTheLocaleSpecifiedinINF = 0;
  4622. dwTheLocaleSpecifiedinINF = atodw(ParsedLine.szFileName);
  4623. if (g_MyTrueThreadLocale == dwTheLocaleSpecifiedinINF)
  4624. {
  4625. iTempFlag = TRUE;
  4626. }
  4627. else if (ThisThreadsLocale == dwTheLocaleSpecifiedinINF)
  4628. {
  4629. iTempFlag = TRUE;
  4630. }
  4631. else if (SystemDefaultLocale == dwTheLocaleSpecifiedinINF)
  4632. {
  4633. iTempFlag = TRUE;
  4634. }
  4635. else if (UserDefaultLocale == dwTheLocaleSpecifiedinINF)
  4636. {
  4637. iTempFlag = TRUE;
  4638. }
  4639. }
  4640. }
  4641. else
  4642. {
  4643. iisDebugOut((LOG_TYPE_ERROR, _T("Failed to start GetNewlyCreatedThreadLocale thread. error =%0x\n"),GetLastError()));
  4644. }
  4645. if (iTempFlag == TRUE)
  4646. {
  4647. // the result was true
  4648. // the key exists, so let's do the section...
  4649. if (ifTrueStatementExists)
  4650. {
  4651. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData1));
  4652. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData1);
  4653. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData1, iTempFlag));
  4654. }
  4655. }
  4656. else
  4657. {
  4658. // the result was false
  4659. if (ifFalseStatementExists)
  4660. {
  4661. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  4662. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  4663. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  4664. }
  4665. }
  4666. }
  4667. if ( _tcsicmp(ParsedLine.szType, _T("49")) == 0)
  4668. {
  4669. BOOL bOperator_EqualTo = 0;
  4670. BOOL bOperator_GreaterThan = 0;
  4671. BOOL bOperator_LessThan = 0;
  4672. // make sure we have a filename entry
  4673. iTempFlag = FALSE;
  4674. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4675. if (iTempFlag == FALSE)
  4676. {
  4677. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4678. goto ProcessEntry_If_Exit;
  4679. }
  4680. // make sure there is an operator "=,>,<,>=,<="
  4681. iTempFlag = FALSE;
  4682. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  4683. if (iTempFlag == FALSE)
  4684. {
  4685. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4686. goto ProcessEntry_If_Exit;
  4687. }
  4688. iTempFlag = FALSE;
  4689. LPTSTR pchResult;
  4690. pchResult = _tcschr( ParsedLine.szData1, _T('=') );
  4691. if(pchResult){bOperator_EqualTo = TRUE;iTempFlag = TRUE;}
  4692. pchResult = NULL;
  4693. pchResult = _tcschr( ParsedLine.szData1, _T('>') );
  4694. if(pchResult){bOperator_GreaterThan = TRUE;iTempFlag = TRUE;}
  4695. pchResult = NULL;
  4696. pchResult = _tcschr( ParsedLine.szData1, _T('<') );
  4697. if(pchResult){bOperator_LessThan = TRUE;iTempFlag = TRUE;}
  4698. if (iTempFlag == FALSE)
  4699. {
  4700. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4701. goto ProcessEntry_If_Exit;
  4702. }
  4703. // make sure the version to compare it to is specified
  4704. iTempFlag = FALSE;
  4705. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  4706. if (iTempFlag == FALSE)
  4707. {
  4708. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4709. goto ProcessEntry_If_Exit;
  4710. }
  4711. // make sure there is a szData3 or a szData4.
  4712. ifTrueStatementExists = FALSE;
  4713. ifFalseStatementExists = FALSE;
  4714. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4715. if (_tcsicmp(ParsedLine.szData4, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4716. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4717. {
  4718. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4719. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz105_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4720. goto ProcessEntry_If_Exit;
  4721. }
  4722. // make sure to return true from here on!
  4723. iReturn = TRUE;
  4724. // check if the file exists
  4725. // Check if the filename or dir exists...
  4726. if (!IsFileExist(ParsedLine.szFileName))
  4727. {goto ProcessEntry_If_Exit;}
  4728. BOOL bThisIsABinary = FALSE;
  4729. TCHAR szExtensionOnly[_MAX_EXT] = _T("");
  4730. _tsplitpath(ParsedLine.szFileName, NULL, NULL, NULL, szExtensionOnly);
  4731. // Get version info for dll,exe,ocx only
  4732. if (_tcsicmp(szExtensionOnly, _T(".exe")) == 0){bThisIsABinary=TRUE;}
  4733. if (_tcsicmp(szExtensionOnly, _T(".dll")) == 0){bThisIsABinary=TRUE;}
  4734. if (_tcsicmp(szExtensionOnly, _T(".ocx")) == 0){bThisIsABinary=TRUE;}
  4735. if (FALSE == bThisIsABinary)
  4736. {
  4737. // no version, bail
  4738. goto ProcessEntry_If_Exit;
  4739. }
  4740. DWORD dwMSVer, dwLSVer = 0;
  4741. TCHAR szLocalizedVersion[100] = _T("");
  4742. // the file exists, lets get the file version and compare it with
  4743. // the inputed version, if the fileversion is <= inputversion, then do TRUE section,
  4744. // otherwise to FALSE section
  4745. // get the fileinformation
  4746. MyGetVersionFromFile(ParsedLine.szFileName, &dwMSVer, &dwLSVer, szLocalizedVersion);
  4747. if (!dwMSVer)
  4748. {
  4749. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("ProcessEntry_If:No Version in %1!s!, or filenot found\n"), ParsedLine.szFileName));
  4750. // no version, leave
  4751. goto ProcessEntry_If_Exit;
  4752. }
  4753. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("ProcessEntry_If:check if [%1!s! (%2!s! %3!s! %4!s!)]\n"), ParsedLine.szFileName, szLocalizedVersion, ParsedLine.szData1));
  4754. int iTempVerValue = 0;
  4755. iTempVerValue = VerCmp(szLocalizedVersion,ParsedLine.szData1);
  4756. if (0 == iTempVerValue)
  4757. {
  4758. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("ProcessEntry_If:VerCmp=%d\n"), iTempVerValue));
  4759. goto ProcessEntry_If_Exit;
  4760. }
  4761. iTempFlag = FALSE;
  4762. if (bOperator_EqualTo)
  4763. {
  4764. // check if the above operation was equal
  4765. if (1 == iTempVerValue){iTempFlag = TRUE;}
  4766. }
  4767. if (bOperator_GreaterThan)
  4768. {
  4769. // check if the above operation was greater than
  4770. if (2 == iTempVerValue){iTempFlag = TRUE;}
  4771. }
  4772. if (bOperator_LessThan)
  4773. {
  4774. // check if the above operation was less than
  4775. if (3 == iTempVerValue){iTempFlag = TRUE;}
  4776. }
  4777. if (iTempFlag == TRUE)
  4778. {
  4779. // the result was true
  4780. // the key exists, so let's do the section...
  4781. if (ifTrueStatementExists)
  4782. {
  4783. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData3));
  4784. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData3);
  4785. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData3, iTempFlag));
  4786. }
  4787. }
  4788. else
  4789. {
  4790. // the result was false
  4791. if (ifFalseStatementExists)
  4792. {
  4793. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData4));
  4794. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData4);
  4795. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData4, iTempFlag));
  4796. }
  4797. }
  4798. }
  4799. if ( _tcsicmp(ParsedLine.szType, _T("39")) == 0)
  4800. {
  4801. BOOL bOperator_EqualTo = 0;
  4802. BOOL bOperator_GreaterThan = 0;
  4803. BOOL bOperator_LessThan = 0;
  4804. // make sure we have a filename entry
  4805. iTempFlag = FALSE;
  4806. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4807. if (iTempFlag == FALSE)
  4808. {
  4809. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4810. goto ProcessEntry_If_Exit;
  4811. }
  4812. // make sure the description string to comprare it to is specified
  4813. iTempFlag = FALSE;
  4814. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  4815. if (iTempFlag == FALSE)
  4816. {
  4817. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4818. goto ProcessEntry_If_Exit;
  4819. }
  4820. ifTrueStatementExists = FALSE;
  4821. ifFalseStatementExists = FALSE;
  4822. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4823. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4824. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4825. {
  4826. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4827. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4828. goto ProcessEntry_If_Exit;
  4829. }
  4830. // make sure to return true from here on!
  4831. iReturn = TRUE;
  4832. // check if the file exists
  4833. // Check if the filename or dir exists...
  4834. if (!IsFileExist(ParsedLine.szFileName))
  4835. {goto ProcessEntry_If_Exit;}
  4836. TCHAR szFileDescriptionInfo[_MAX_PATH] = _T("");
  4837. // Get the file description info
  4838. // get the DescriptionInfo
  4839. if (!MyGetDescriptionFromFile(ParsedLine.szFileName, szFileDescriptionInfo))
  4840. {
  4841. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("ProcessEntry_If:No file desc in %1!s!, or filenot found\n"), ParsedLine.szFileName));
  4842. goto ProcessEntry_If_Exit;
  4843. }
  4844. iTempFlag = FALSE;
  4845. if ( _tcsicmp(szFileDescriptionInfo,ParsedLine.szData1) == 0)
  4846. {
  4847. // if they match the do the true!
  4848. iTempFlag = TRUE;
  4849. }
  4850. if (iTempFlag == TRUE)
  4851. {
  4852. // the result was true
  4853. // the key exists, so let's do the section...
  4854. if (ifTrueStatementExists)
  4855. {
  4856. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  4857. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  4858. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  4859. }
  4860. }
  4861. else
  4862. {
  4863. // the result was false
  4864. if (ifFalseStatementExists)
  4865. {
  4866. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData3));
  4867. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData3);
  4868. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData3, iTempFlag));
  4869. }
  4870. }
  4871. }
  4872. if ( _tcsicmp(ParsedLine.szType, _T("100")) == 0)
  4873. {
  4874. TCHAR buf[_MAX_PATH];
  4875. GetSystemDirectory(buf, _MAX_PATH);
  4876. // make sure there is a szData1 or a szData2
  4877. ifTrueStatementExists = FALSE;
  4878. ifFalseStatementExists = FALSE;
  4879. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4880. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4881. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4882. {
  4883. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4884. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4885. goto ProcessEntry_If_Exit;
  4886. }
  4887. // okay we have either szData1 or szData2
  4888. // Check if the Service exists...
  4889. iTempFlag = FALSE;
  4890. if (IsThisDriveNTFS(buf) == 0 )
  4891. {
  4892. // yes it is FAT
  4893. iTempFlag = TRUE;
  4894. }
  4895. if (iTempFlag == TRUE)
  4896. {
  4897. // the result was true
  4898. // the key exists, so let's do the section...
  4899. if (ifTrueStatementExists)
  4900. {
  4901. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData1));
  4902. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData1);
  4903. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData1, iTempFlag));
  4904. }
  4905. }
  4906. else
  4907. {
  4908. // the result was false
  4909. if (ifFalseStatementExists)
  4910. {
  4911. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  4912. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  4913. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  4914. }
  4915. }
  4916. }
  4917. if ( _tcsicmp(ParsedLine.szType, _T("119")) == 0)
  4918. {
  4919. if ( IsMachineInDomain() )
  4920. {
  4921. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0 )
  4922. {
  4923. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  4924. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  4925. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  4926. }
  4927. }
  4928. else
  4929. {
  4930. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0 )
  4931. {
  4932. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData3));
  4933. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData3);
  4934. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData3, iTempFlag));
  4935. }
  4936. }
  4937. }
  4938. // We called the function, so return true.
  4939. iReturn = TRUE;
  4940. ProcessEntry_If_Exit:
  4941. return iReturn;
  4942. }
  4943. int ProcessEntry_Metabase(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  4944. {
  4945. int iShowErrorsOnFail = TRUE;
  4946. int iReturn = FALSE;
  4947. int iTempFlag = FALSE;
  4948. // Get the type.
  4949. if ( _tcsicmp(ParsedLine.szType, _T("82")) != 0 && _tcsicmp(ParsedLine.szType, _T("83")) != 0 &&
  4950. _tcsicmp(ParsedLine.szType, _T("84")) != 0 && _tcsicmp(ParsedLine.szType, _T("85")) != 0
  4951. )
  4952. {
  4953. goto ProcessEntry_Metabase_Exit;
  4954. }
  4955. // Check if there is other criteria we need to pass
  4956. if (!ProcessEntry_CheckAll(csEntry, szTheSection, ParsedLine) )
  4957. {
  4958. goto ProcessEntry_Metabase_Exit;
  4959. }
  4960. iShowErrorsOnFail = TRUE;
  4961. if (_tcsicmp(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T("1")) == 0)
  4962. {iShowErrorsOnFail = FALSE;}
  4963. if ( _tcsicmp(ParsedLine.szType, _T("82")) == 0)
  4964. {
  4965. // make sure we have a filename entry
  4966. iTempFlag = FALSE;
  4967. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4968. if (iTempFlag == FALSE)
  4969. {
  4970. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4971. goto ProcessEntry_Metabase_Exit;
  4972. }
  4973. iTempFlag = FALSE;
  4974. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  4975. if (iTempFlag == FALSE)
  4976. {
  4977. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4978. goto ProcessEntry_Metabase_Exit;
  4979. }
  4980. // Check if hte szData1 includes a "/*"
  4981. // if it does, then that means to do it for every server instance.
  4982. iTempFlag = FALSE;
  4983. if (_tcsstr(ParsedLine.szFileName, _T("/*")))
  4984. {iTempFlag = TRUE;}
  4985. // Check if we need to do this for every server instance.
  4986. if (iTempFlag)
  4987. {
  4988. CString csTempString;
  4989. CString BeforeString;
  4990. CString AfterString;
  4991. csTempString = ParsedLine.szFileName;
  4992. BeforeString = csTempString;
  4993. AfterString = _T("");
  4994. // Find the "/*" and get the stuff before it.
  4995. int iWhere = 0;
  4996. iWhere = csTempString.Find(_T("/*"));
  4997. if (-1 != iWhere)
  4998. {
  4999. // there is a '/*' in the string
  5000. BeforeString = csTempString.Left(iWhere);
  5001. // Get the after comma vlues
  5002. CString csVeryTemp;
  5003. csVeryTemp = _T("/*");
  5004. AfterString = csTempString.Right( csTempString.GetLength() - (iWhere + csVeryTemp.GetLength()));
  5005. }
  5006. CStringArray arrayInstance;
  5007. int nArray = 0, i = 0;
  5008. if (CheckifServiceExist(_T("IISADMIN")) == 0 )
  5009. {
  5010. CMDKey cmdKey;
  5011. //cmdKey.OpenNode(ParsedLine.szFileName);
  5012. cmdKey.OpenNode(BeforeString);
  5013. if ( (METADATA_HANDLE) cmdKey )
  5014. {
  5015. // enumerate thru this key for other keys...
  5016. CMDKeyIter cmdKeyEnum(cmdKey);
  5017. CString csKeyName;
  5018. while (cmdKeyEnum.Next(&csKeyName) == ERROR_SUCCESS)
  5019. {
  5020. // make sure that it's a number that we are adding.
  5021. if (IsValidNumber(csKeyName))
  5022. {
  5023. arrayInstance.Add(csKeyName);
  5024. }
  5025. }
  5026. cmdKey.Close();
  5027. nArray = (int)arrayInstance.GetSize();
  5028. for (i=0; i<nArray; i++)
  5029. {
  5030. /*
  5031. // Recurse Thru This nodes entries
  5032. // Probably look something like these...
  5033. [/W3SVC]
  5034. [/W3SVC/1/ROOT/IISSAMPLES/ExAir]
  5035. [/W3SVC/1/ROOT/IISADMIN]
  5036. [/W3SVC/1/ROOT/IISHELP]
  5037. [/W3SVC/1/ROOT/specs]
  5038. [/W3SVC/2/ROOT]
  5039. [/W3SVC/2/ROOT/IISADMIN]
  5040. [/W3SVC/2/ROOT/IISHELP]
  5041. etc...
  5042. */
  5043. CString csPath;
  5044. csPath = BeforeString;
  5045. csPath += _T("/");
  5046. csPath += arrayInstance[i];
  5047. csPath += AfterString;
  5048. // delete the metabase node.
  5049. cmdKey.OpenNode(csPath);
  5050. if ( (METADATA_HANDLE)cmdKey )
  5051. {
  5052. cmdKey.DeleteNode(ParsedLine.szData1);
  5053. cmdKey.Close();
  5054. }
  5055. }
  5056. }
  5057. }
  5058. }
  5059. else
  5060. {
  5061. // delete the metabase node.
  5062. if (CheckifServiceExist(_T("IISADMIN")) == 0 )
  5063. {
  5064. CMDKey cmdKey;
  5065. cmdKey.OpenNode(ParsedLine.szFileName);
  5066. if ( (METADATA_HANDLE)cmdKey )
  5067. {
  5068. cmdKey.DeleteNode(ParsedLine.szData1);
  5069. cmdKey.Close();
  5070. }
  5071. }
  5072. }
  5073. }
  5074. if ( _tcsicmp(ParsedLine.szType, _T("83")) == 0)
  5075. {
  5076. // make sure we have a filename entry
  5077. iTempFlag = FALSE;
  5078. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5079. if (iTempFlag == FALSE)
  5080. {
  5081. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5082. goto ProcessEntry_Metabase_Exit;
  5083. }
  5084. iTempFlag = FALSE;
  5085. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  5086. if (iTempFlag == FALSE)
  5087. {
  5088. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5089. goto ProcessEntry_Metabase_Exit;
  5090. }
  5091. iTempFlag = FALSE;
  5092. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  5093. if (iTempFlag == FALSE)
  5094. {
  5095. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5096. goto ProcessEntry_Metabase_Exit;
  5097. }
  5098. // Check if hte szData1 includes a "/*"
  5099. // if it does, then that means to do it for every server instance.
  5100. iTempFlag = FALSE;
  5101. if (_tcsstr(ParsedLine.szFileName, _T("/*")))
  5102. {iTempFlag = TRUE;}
  5103. // Check if we need to do this for every server instance.
  5104. if (iTempFlag)
  5105. {
  5106. CString csTempString;
  5107. CString BeforeString;
  5108. CString AfterString;
  5109. csTempString = ParsedLine.szFileName;
  5110. BeforeString = csTempString;
  5111. AfterString = _T("");
  5112. // Find the "/*" and get the stuff before it.
  5113. int iWhere = 0;
  5114. iWhere = csTempString.Find(_T("/*"));
  5115. if (-1 != iWhere)
  5116. {
  5117. // there is a '/*' in the string
  5118. BeforeString = csTempString.Left(iWhere);
  5119. // Get the after comma vlues
  5120. CString csVeryTemp;
  5121. csVeryTemp = _T("/*");
  5122. AfterString = csTempString.Right( csTempString.GetLength() - (iWhere + csVeryTemp.GetLength()));
  5123. }
  5124. CStringArray arrayInstance;
  5125. int nArray = 0, i = 0;
  5126. if (CheckifServiceExist(_T("IISADMIN")) == 0 )
  5127. {
  5128. CMDKey cmdKey;
  5129. //cmdKey.OpenNode(ParsedLine.szFileName);
  5130. cmdKey.OpenNode(BeforeString);
  5131. if ( (METADATA_HANDLE) cmdKey )
  5132. {
  5133. // enumerate thru this key for other keys...
  5134. CMDKeyIter cmdKeyEnum(cmdKey);
  5135. CString csKeyName;
  5136. while (cmdKeyEnum.Next(&csKeyName) == ERROR_SUCCESS)
  5137. {
  5138. // make sure that it's a number that we are adding.
  5139. if (IsValidNumber(csKeyName))
  5140. {
  5141. arrayInstance.Add(csKeyName);
  5142. }
  5143. }
  5144. cmdKey.Close();
  5145. nArray = (int)arrayInstance.GetSize();
  5146. for (i=0; i<nArray; i++)
  5147. {
  5148. /*
  5149. // Recurse Thru This nodes entries
  5150. // Probably look something like these...
  5151. [/W3SVC]
  5152. [/W3SVC/1/ROOT/IISSAMPLES/ExAir]
  5153. [/W3SVC/1/ROOT/IISADMIN]
  5154. [/W3SVC/1/ROOT/IISHELP]
  5155. [/W3SVC/1/ROOT/specs]
  5156. [/W3SVC/2/ROOT]
  5157. [/W3SVC/2/ROOT/IISADMIN]
  5158. [/W3SVC/2/ROOT/IISHELP]
  5159. etc...
  5160. */
  5161. CString csPath;
  5162. csPath = BeforeString;
  5163. csPath += _T("/");
  5164. csPath += arrayInstance[i];
  5165. csPath += AfterString;
  5166. // DO WHATEVER YOU NEED TO DO.
  5167. int arrayInstanceNum = _ttoi(arrayInstance[i]);
  5168. // Add the virtual root
  5169. iTempFlag = FALSE;
  5170. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {iTempFlag = TRUE;}
  5171. // make sure it ParsedLine.szData1 starts with a "/"
  5172. TCHAR szTempString[_MAX_PATH];
  5173. _tcscpy(szTempString, ParsedLine.szData1);
  5174. if (szTempString[0] != _T('/'))
  5175. {_stprintf(ParsedLine.szData1, _T("/%s"), szTempString);}
  5176. if (iTempFlag)
  5177. {
  5178. AddMDVRootTree(csPath, ParsedLine.szData1, ParsedLine.szData2, ParsedLine.szData3, arrayInstanceNum);
  5179. }
  5180. else
  5181. {
  5182. AddMDVRootTree(csPath, ParsedLine.szData1, ParsedLine.szData2, NULL, arrayInstanceNum);
  5183. }
  5184. }
  5185. }
  5186. }
  5187. }
  5188. else
  5189. {
  5190. // Add the virtual root
  5191. if (CheckifServiceExist(_T("IISADMIN")) == 0 )
  5192. {
  5193. iTempFlag = FALSE;
  5194. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {iTempFlag = TRUE;}
  5195. // make sure it ParsedLine.szData1 starts with a "/"
  5196. TCHAR szTempString[_MAX_PATH];
  5197. _tcscpy(szTempString, ParsedLine.szData1);
  5198. if (szTempString[0] != _T('/'))
  5199. {_stprintf(ParsedLine.szData1, _T("/%s"), szTempString);}
  5200. if (iTempFlag)
  5201. {
  5202. AddMDVRootTree(ParsedLine.szFileName, ParsedLine.szData1, ParsedLine.szData2, ParsedLine.szData3, 0);
  5203. }
  5204. else
  5205. {
  5206. AddMDVRootTree(ParsedLine.szFileName, ParsedLine.szData1, ParsedLine.szData2, NULL, 0);
  5207. }
  5208. }
  5209. }
  5210. }
  5211. if ( _tcsicmp(ParsedLine.szType, _T("84")) == 0)
  5212. {
  5213. // make sure we have a filename entry
  5214. iTempFlag = FALSE;
  5215. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5216. if (iTempFlag == FALSE)
  5217. {
  5218. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5219. goto ProcessEntry_Metabase_Exit;
  5220. }
  5221. // call that particular migration section
  5222. CString csTheSection = ParsedLine.szFileName;
  5223. if (GetSectionNameToDo(g_pTheApp->m_hInfHandle, csTheSection))
  5224. {
  5225. MigrateInfSectionToMD(g_pTheApp->m_hInfHandle, csTheSection);
  5226. }
  5227. }
  5228. #ifndef _CHICAGO_
  5229. if ( _tcsicmp(ParsedLine.szType, _T("85")) == 0)
  5230. {
  5231. int iTheReturn = TRUE;
  5232. // make sure we have a filename entry
  5233. iTempFlag = FALSE;
  5234. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5235. if (iTempFlag == FALSE)
  5236. {
  5237. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5238. goto ProcessEntry_Metabase_Exit;
  5239. }
  5240. iTempFlag = FALSE;
  5241. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  5242. if (iTempFlag == FALSE)
  5243. {
  5244. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5245. goto ProcessEntry_Metabase_Exit;
  5246. }
  5247. iTheReturn = ChangeUserPassword(ParsedLine.szFileName,ParsedLine.szData1);
  5248. if (FALSE == iTheReturn)
  5249. {
  5250. if (iShowErrorsOnFail){MyMessageBox(NULL, _T("ChangeUserPassword failed"), ParsedLine.szFileName, MB_OK | MB_SETFOREGROUND);}
  5251. else{iisDebugOut((LOG_TYPE_ERROR, _T("ChangeUserPassword(%s). Failed..\n"), ParsedLine.szFileName));}
  5252. }
  5253. }
  5254. #endif
  5255. // We called the function, so return true.
  5256. iReturn = TRUE;
  5257. ProcessEntry_Metabase_Exit:
  5258. return iReturn;
  5259. }
  5260. int ProcessEntry_Misc2(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  5261. {
  5262. int iReturn = FALSE;
  5263. int iTempFlag = FALSE;
  5264. // Get the type.
  5265. if ( _tcsicmp(ParsedLine.szType, _T("15")) != 0 && _tcsicmp(ParsedLine.szType, _T("16")) != 0 &&
  5266. _tcsicmp(ParsedLine.szType, _T("78")) != 0 && _tcsicmp(ParsedLine.szType, _T("79")) != 0 &&
  5267. _tcsicmp(ParsedLine.szType, _T("80")) != 0 && _tcsicmp(ParsedLine.szType, _T("81")) != 0 &&
  5268. _tcsicmp(ParsedLine.szType, _T("86")) != 0 && _tcsicmp(ParsedLine.szType, _T("87")) != 0 &&
  5269. _tcsicmp(ParsedLine.szType, _T("88")) != 0 && _tcsicmp(ParsedLine.szType, _T("89")) != 0 &&
  5270. _tcsicmp(ParsedLine.szType, _T("90")) != 0 && _tcsicmp(ParsedLine.szType, _T("91")) != 0 &&
  5271. _tcsicmp(ParsedLine.szType, _T("92")) != 0 && _tcsicmp(ParsedLine.szType, _T("93")) != 0 &&
  5272. _tcsicmp(ParsedLine.szType, _T("94")) != 0 && _tcsicmp(ParsedLine.szType, _T("95")) != 0 &&
  5273. _tcsicmp(ParsedLine.szType, _T("96")) != 0 && _tcsicmp(ParsedLine.szType, _T("97")) != 0 &&
  5274. _tcsicmp(ParsedLine.szType, _T("98")) != 0 && _tcsicmp(ParsedLine.szType, _T("99")) != 0
  5275. )
  5276. {
  5277. goto ProcessEntry_Misc2_Exit;
  5278. }
  5279. // Check if there is other criteria we need to pass
  5280. if (!ProcessEntry_CheckAll(csEntry, szTheSection, ParsedLine) )
  5281. {
  5282. goto ProcessEntry_Misc2_Exit;
  5283. }
  5284. // make sure we have a progresstitle
  5285. if ( _tcsicmp(ParsedLine.szType, _T("15")) == 0)
  5286. {
  5287. iTempFlag = FALSE;
  5288. if (_tcsicmp(ParsedLine.szProgressTitle, _T("")) != 0) {iTempFlag = TRUE;}
  5289. if (iTempFlag == FALSE)
  5290. {
  5291. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz805_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5292. goto ProcessEntry_Misc2_Exit;
  5293. }
  5294. }
  5295. if ( _tcsicmp(ParsedLine.szType, _T("15")) == 0)
  5296. {
  5297. ProgressBarTextStack_Set(ParsedLine.szProgressTitle);
  5298. }
  5299. if ( _tcsicmp(ParsedLine.szType, _T("16")) == 0)
  5300. {
  5301. ProgressBarTextStack_Pop();
  5302. }
  5303. if ( _tcsicmp(ParsedLine.szType, _T("78")) == 0)
  5304. {
  5305. iTempFlag = FALSE;
  5306. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5307. if (iTempFlag == FALSE)
  5308. {
  5309. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5310. goto ProcessEntry_Misc2_Exit;
  5311. }
  5312. if (!IsFileExist(ParsedLine.szFileName))
  5313. {
  5314. iisDebugOut((LOG_TYPE_TRACE, _T("ProcessEntry_other():'%s' does not exist.\n"),ParsedLine.szFileName));
  5315. goto ProcessEntry_Misc2_Exit;
  5316. }
  5317. MakeSureDirAclsHaveAtLeastRead((LPTSTR) ParsedLine.szFileName);
  5318. }
  5319. if ( _tcsicmp(ParsedLine.szType, _T("79")) == 0)
  5320. {
  5321. int ifTrueStatementExists = FALSE;
  5322. int ifFalseStatementExists = FALSE;
  5323. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  5324. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  5325. iTempFlag = FALSE;
  5326. iTempFlag = IsMetabaseCorrupt();
  5327. if (iTempFlag == TRUE)
  5328. {
  5329. // the result was true
  5330. // the key exists, so let's do the section...
  5331. if (ifTrueStatementExists)
  5332. {
  5333. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szFileName));
  5334. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szFileName);
  5335. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szFileName, iTempFlag));
  5336. }
  5337. }
  5338. else
  5339. {
  5340. // the result was false
  5341. if (ifFalseStatementExists)
  5342. {
  5343. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData1));
  5344. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData1);
  5345. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData1, iTempFlag));
  5346. }
  5347. }
  5348. }
  5349. if ( _tcsicmp(ParsedLine.szType, _T("80")) == 0)
  5350. {
  5351. // initialize ole
  5352. iisDebugOut_Start((_T("ole32:OleInitialize")));
  5353. int iBalanceOLE = iOleInitialize();
  5354. iisDebugOut_End((_T("ole32:OleInitialize")));
  5355. // add it to the stack of ole inits and uninits...
  5356. GlobalOleInitList_Push(iBalanceOLE);
  5357. }
  5358. if ( _tcsicmp(ParsedLine.szType, _T("81")) == 0)
  5359. {
  5360. // Uninitialize ole.
  5361. // Check if there is a corresponding oleinit, if there is,
  5362. // then uninit, else uninit anyways.
  5363. // Grab the last thing on the stack...
  5364. // if there is one, then do whatever it is.
  5365. // if there is none, then OleUninitialize anyway
  5366. if (GlobalOleInitList_Find() == TRUE)
  5367. {
  5368. if (TRUE == GlobalOleInitList_Pop())
  5369. {
  5370. iOleUnInitialize(TRUE);
  5371. }
  5372. else
  5373. {
  5374. iOleUnInitialize(FALSE);
  5375. }
  5376. }
  5377. else
  5378. {
  5379. iOleUnInitialize(TRUE);
  5380. }
  5381. }
  5382. if ( _tcsicmp(ParsedLine.szType, _T("86")) == 0)
  5383. {
  5384. // See if there is an extra param in the other field
  5385. int iTicksToAdvance = 1;
  5386. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0)
  5387. {
  5388. if (IsValidNumber((LPCTSTR)ParsedLine.szFileName))
  5389. {iTicksToAdvance = _ttoi((LPCTSTR)ParsedLine.szFileName);}
  5390. }
  5391. AdvanceProgressBarTickGauge(iTicksToAdvance);
  5392. }
  5393. if ( _tcsicmp(ParsedLine.szType, _T("87")) == 0)
  5394. {
  5395. LogFilesInThisDir(ParsedLine.szFileName);
  5396. }
  5397. if ( _tcsicmp(ParsedLine.szType, _T("88")) == 0)
  5398. {
  5399. LogFileVersion(ParsedLine.szFileName, TRUE);
  5400. }
  5401. if ( _tcsicmp(ParsedLine.szType, _T("89")) == 0)
  5402. {
  5403. // make sure the metabase writes all the information to disk now.
  5404. WriteToMD_ForceMetabaseToWriteToDisk();
  5405. }
  5406. if ( _tcsicmp(ParsedLine.szType, _T("90")) == 0)
  5407. {
  5408. iTempFlag = FALSE;
  5409. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5410. if (iTempFlag == FALSE)
  5411. {
  5412. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5413. goto ProcessEntry_Misc2_Exit;
  5414. }
  5415. DWORD dwTheID = _ttol(ParsedLine.szFileName);
  5416. //iisDebugOut((LOG_TYPE_ERROR, _T("Values: %s, %d"), ParsedLine.szFileName, dwTheID));
  5417. if ( ( dwTheID == 32802 ) && // DomainName
  5418. ( _tcsicmp(ParsedLine.szData1, _T("")) == 0)
  5419. )
  5420. {
  5421. CString DomainName;
  5422. if ( RetrieveDomain(DomainName) )
  5423. {
  5424. SetupSetStringId_Wrapper(g_pTheApp->m_hInfHandle,dwTheID,DomainName.GetBuffer(0));
  5425. }
  5426. }
  5427. else
  5428. {
  5429. SetupSetStringId_Wrapper(g_pTheApp->m_hInfHandle,dwTheID,ParsedLine.szData1);
  5430. }
  5431. }
  5432. if ( _tcsicmp(ParsedLine.szType, _T("91")) == 0)
  5433. {
  5434. iTempFlag = FALSE;
  5435. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5436. if (iTempFlag == FALSE)
  5437. {
  5438. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5439. goto ProcessEntry_Misc2_Exit;
  5440. }
  5441. DWORD dwTheID = atodw(ParsedLine.szFileName);
  5442. SetupSetStringId_Wrapper(g_pTheApp->m_hInfHandle,dwTheID,ParsedLine.szData1);
  5443. }
  5444. if ( _tcsicmp(ParsedLine.szType, _T("92")) == 0)
  5445. {
  5446. // 100=92|101=Inst mode (0,1,2,3)|102=UpgType(UT_10,etc..)|103=UpgTypeHasMetabaseFlag (0|1)|104=AllCompOffByDefaultFlag
  5447. iTempFlag = FALSE;
  5448. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5449. if (iTempFlag == FALSE)
  5450. {
  5451. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5452. goto ProcessEntry_Misc2_Exit;
  5453. }
  5454. iTempFlag = FALSE;
  5455. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  5456. if (iTempFlag == FALSE)
  5457. {
  5458. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5459. goto ProcessEntry_Misc2_Exit;
  5460. }
  5461. iTempFlag = FALSE;
  5462. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  5463. if (iTempFlag == FALSE)
  5464. {
  5465. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5466. goto ProcessEntry_Misc2_Exit;
  5467. }
  5468. iTempFlag = FALSE;
  5469. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {iTempFlag = TRUE;}
  5470. if (iTempFlag == FALSE)
  5471. {
  5472. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5473. goto ProcessEntry_Misc2_Exit;
  5474. }
  5475. //m_eInstallMode = IM_FRESH;
  5476. //m_eUpgradeType = UT_NONE;
  5477. //m_bUpgradeTypeHasMetabaseFlag = FALSE;
  5478. //m_bPleaseDoNotInstallByDefault = TRUE;
  5479. if (_tcsicmp(ParsedLine.szFileName, _T("1")) == 0)
  5480. {g_pTheApp->m_eInstallMode = IM_FRESH;}
  5481. if (_tcsicmp(ParsedLine.szFileName, _T("2")) == 0)
  5482. {g_pTheApp->m_eInstallMode = IM_UPGRADE;}
  5483. if (_tcsicmp(ParsedLine.szFileName, _T("3")) == 0)
  5484. {g_pTheApp->m_eInstallMode = IM_MAINTENANCE;}
  5485. if (_tcsicmp(ParsedLine.szData1, _T("UT_NONE")) == 0)
  5486. {g_pTheApp->m_eUpgradeType = UT_NONE;}
  5487. if (_tcsicmp(ParsedLine.szData1, _T("UT_351")) == 0)
  5488. {g_pTheApp->m_eUpgradeType = UT_351;}
  5489. if (_tcsicmp(ParsedLine.szData1, _T("UT_10")) == 0)
  5490. {g_pTheApp->m_eUpgradeType = UT_10;}
  5491. if (_tcsicmp(ParsedLine.szData1, _T("UT_20")) == 0)
  5492. {g_pTheApp->m_eUpgradeType = UT_20;}
  5493. if (_tcsicmp(ParsedLine.szData1, _T("UT_30")) == 0)
  5494. {g_pTheApp->m_eUpgradeType = UT_30;}
  5495. if (_tcsicmp(ParsedLine.szData1, _T("UT_40")) == 0)
  5496. {g_pTheApp->m_eUpgradeType = UT_40;}
  5497. if (_tcsicmp(ParsedLine.szData1, _T("UT_50")) == 0)
  5498. {g_pTheApp->m_eUpgradeType = UT_50;}
  5499. if (_tcsicmp(ParsedLine.szData1, _T("UT_51")) == 0)
  5500. {g_pTheApp->m_eUpgradeType = UT_51;}
  5501. if (_tcsicmp(ParsedLine.szData1, _T("UT_60")) == 0)
  5502. {g_pTheApp->m_eUpgradeType = UT_60;}
  5503. if (_tcsicmp(ParsedLine.szData1, _T("UT_10_W95")) == 0)
  5504. {g_pTheApp->m_eUpgradeType = UT_10_W95;}
  5505. g_pTheApp->m_bUpgradeTypeHasMetabaseFlag = FALSE;
  5506. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0)
  5507. {g_pTheApp->m_bUpgradeTypeHasMetabaseFlag = TRUE;}
  5508. g_pTheApp->m_bPleaseDoNotInstallByDefault = FALSE;
  5509. if (_tcsicmp(ParsedLine.szData3, _T("1")) == 0)
  5510. {g_pTheApp->m_bPleaseDoNotInstallByDefault = TRUE;}
  5511. }
  5512. if ( _tcsicmp(ParsedLine.szType, _T("93")) == 0)
  5513. {
  5514. iTempFlag = FALSE;
  5515. if (_tcsicmp(ParsedLine.szFileName, _T("1")) == 0) {iTempFlag = TRUE;}
  5516. StopAllServicesRegardless(iTempFlag);
  5517. }
  5518. if ( _tcsicmp(ParsedLine.szType, _T("94")) == 0)
  5519. {
  5520. DisplayActionsForAllOurComponents(g_pTheApp->m_hInfHandle);
  5521. }
  5522. if ( _tcsicmp(ParsedLine.szType, _T("95")) == 0)
  5523. {
  5524. // Check if the specified file has a version >= iis4.
  5525. // if it does then rename the file.
  5526. // make sure it has a 101
  5527. iTempFlag = FALSE;
  5528. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5529. if (iTempFlag == FALSE)
  5530. {
  5531. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5532. goto ProcessEntry_Misc2_Exit;
  5533. }
  5534. // make sure the file exists.
  5535. if (!IsFileExist(ParsedLine.szFileName))
  5536. {
  5537. iisDebugOut((LOG_TYPE_TRACE, _T("ProcessEntry_other():'%s' does not exist.\n"),ParsedLine.szFileName));
  5538. goto ProcessEntry_Misc2_Exit;
  5539. }
  5540. DWORD dwMajorVersion = 0x0;
  5541. DWORD dwMinorVersion = 0x0;
  5542. // make sure it has a 102
  5543. iTempFlag = FALSE;
  5544. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  5545. if (iTempFlag == FALSE)
  5546. {
  5547. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5548. goto ProcessEntry_Misc2_Exit;
  5549. }
  5550. // make sure it has a 103
  5551. iTempFlag = FALSE;
  5552. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  5553. if (iTempFlag == FALSE)
  5554. {
  5555. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5556. goto ProcessEntry_Misc2_Exit;
  5557. }
  5558. else
  5559. {
  5560. dwMajorVersion = atodw(ParsedLine.szData2);
  5561. }
  5562. // make sure it has a 104
  5563. iTempFlag = FALSE;
  5564. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {iTempFlag = TRUE;}
  5565. if (iTempFlag == FALSE)
  5566. {
  5567. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5568. goto ProcessEntry_Misc2_Exit;
  5569. }
  5570. else
  5571. {
  5572. dwMinorVersion = atodw(ParsedLine.szData3);
  5573. }
  5574. // Check if the file has a larger version.
  5575. //DWORD dwNtopMSVer = 0x40002;
  5576. //DWORD dwNtopLSVer = 0x26e0001;
  5577. if (FALSE == IsFileLessThanThisVersion(ParsedLine.szFileName, dwMajorVersion, dwMinorVersion))
  5578. {
  5579. // ok, this is a 'special' built file that the user built themselves.
  5580. // let's rename it to something else.
  5581. // check if the "to" filename exists.
  5582. iTempFlag = FALSE;
  5583. int I1 = 0;
  5584. TCHAR szTempFileName[_MAX_PATH];
  5585. _tcscpy(szTempFileName, ParsedLine.szData1);
  5586. do
  5587. {
  5588. if (!IsFileExist(szTempFileName) || (I1 > 10))
  5589. {
  5590. iTempFlag = TRUE;
  5591. // rename it
  5592. if (MoveFileEx( ParsedLine.szFileName, szTempFileName, MOVEFILE_COPY_ALLOWED|MOVEFILE_WRITE_THROUGH|MOVEFILE_REPLACE_EXISTING))
  5593. {iisDebugOut((LOG_TYPE_WARN, _T("%s was renamed to %s for safety because it is probably a user compiled file. WARNING."),ParsedLine.szFileName, szTempFileName));}
  5594. else
  5595. {iisDebugOut((LOG_TYPE_ERROR, _T("Rename of %s to %s for safety because it is probably a user compiled file. FAILED."),ParsedLine.szFileName, szTempFileName));}
  5596. }
  5597. else
  5598. {
  5599. // add on some other stuff.
  5600. I1++;
  5601. _stprintf(szTempFileName, _T("%s%d"), ParsedLine.szData1, I1);
  5602. }
  5603. } while (iTempFlag == FALSE);
  5604. }
  5605. }
  5606. if ( _tcsicmp(ParsedLine.szType, _T("96")) == 0)
  5607. {
  5608. // show messagebox
  5609. int iSaveOld_AllowMessageBoxPopups = g_pTheApp->m_bAllowMessageBoxPopups;
  5610. g_pTheApp->m_bAllowMessageBoxPopups = TRUE;
  5611. MyMessageBox(NULL, ParsedLine.szData1, ParsedLine.szFileName, MB_OK | MB_SETFOREGROUND);
  5612. g_pTheApp->m_bAllowMessageBoxPopups = iSaveOld_AllowMessageBoxPopups;
  5613. }
  5614. if ( _tcsicmp(ParsedLine.szType, _T("97")) == 0)
  5615. {
  5616. // do nothing...
  5617. }
  5618. if ( _tcsicmp(ParsedLine.szType, _T("98")) == 0)
  5619. {
  5620. //Reboot
  5621. SetRebootFlag();
  5622. }
  5623. if ( _tcsicmp(ParsedLine.szType, _T("99")) == 0)
  5624. {
  5625. // dump internal variables
  5626. g_pTheApp->DumpAppVars();
  5627. int iDoExtraStuff = 0;
  5628. if (ParsedLine.szFileName && _tcsicmp(ParsedLine.szFileName, _T("")) != 0)
  5629. {
  5630. if (IsValidNumber((LPCTSTR)ParsedLine.szFileName))
  5631. {
  5632. iDoExtraStuff = _ttoi((LPCTSTR)ParsedLine.szFileName);
  5633. }
  5634. }
  5635. if (g_GlobalDebugLevelFlag >= LOG_TYPE_TRACE)
  5636. {
  5637. if (iDoExtraStuff >= 2)
  5638. {
  5639. // display locked dlls by setup
  5640. LogThisProcessesDLLs();
  5641. // display running processes
  5642. LogCurrentProcessIDs();
  5643. // free some memory used for the task list
  5644. FreeTaskListMem();
  5645. UnInit_Lib_PSAPI();
  5646. }
  5647. // display running services
  5648. if (iDoExtraStuff >= 1)
  5649. {
  5650. LogEnumServicesStatus();
  5651. }
  5652. // log file versions
  5653. LogImportantFiles();
  5654. // check if temp dir is writeable
  5655. LogCheckIfTempDirWriteable();
  5656. }
  5657. }
  5658. // We called the function, so return true.
  5659. iReturn = TRUE;
  5660. ProcessEntry_Misc2_Exit:
  5661. return iReturn;
  5662. }
  5663. int ProcessEntry_Misc3(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  5664. {
  5665. int iReturn = FALSE;
  5666. int iTempFlag = FALSE;
  5667. int ifTrueStatementExists = FALSE;
  5668. int ifFalseStatementExists = FALSE;
  5669. int iShowErrorsOnFail = TRUE;
  5670. if (_tcsicmp(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T("1")) == 0)
  5671. {iShowErrorsOnFail = FALSE;}
  5672. // Get the type.
  5673. if ( _tcsicmp(ParsedLine.szType, _T("101")) != 0 && _tcsicmp(ParsedLine.szType, _T("102")) != 0 &&
  5674. _tcsicmp(ParsedLine.szType, _T("103")) != 0 && _tcsicmp(ParsedLine.szType, _T("104")) != 0 &&
  5675. _tcsicmp(ParsedLine.szType, _T("105")) != 0 && _tcsicmp(ParsedLine.szType, _T("106")) != 0 &&
  5676. _tcsicmp(ParsedLine.szType, _T("107")) != 0 && _tcsicmp(ParsedLine.szType, _T("108")) != 0 &&
  5677. _tcsicmp(ParsedLine.szType, _T("109")) != 0 && _tcsicmp(ParsedLine.szType, _T("110")) != 0 &&
  5678. _tcsicmp(ParsedLine.szType, _T("111")) != 0 && _tcsicmp(ParsedLine.szType, _T("112")) != 0 &&
  5679. _tcsicmp(ParsedLine.szType, _T("113")) != 0 && _tcsicmp(ParsedLine.szType, _T("114")) != 0 &&
  5680. _tcsicmp(ParsedLine.szType, _T("115")) != 0 && _tcsicmp(ParsedLine.szType, _T("116")) != 0 &&
  5681. _tcsicmp(ParsedLine.szType, _T("117")) != 0 && _tcsicmp(ParsedLine.szType, _T("118")) != 0
  5682. )
  5683. {
  5684. goto ProcessEntry_Misc3_Exit;
  5685. }
  5686. // Check if there is other criteria we need to pass
  5687. if (!ProcessEntry_CheckAll(csEntry, szTheSection, ParsedLine) )
  5688. {
  5689. goto ProcessEntry_Misc3_Exit;
  5690. }
  5691. if ( _tcsicmp(ParsedLine.szType, _T("101")) == 0)
  5692. {
  5693. // Remove filter
  5694. // make sure we have a filename entry
  5695. iTempFlag = FALSE;
  5696. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5697. if (iTempFlag == FALSE)
  5698. {
  5699. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5700. goto ProcessEntry_Misc3_Exit;
  5701. }
  5702. // Check for extra flag
  5703. iTempFlag = FALSE;
  5704. if (_tcsicmp(ParsedLine.szData1, _T("1")) == 0){iTempFlag = TRUE;}
  5705. // Remove the filter
  5706. RemoveMetabaseFilter(ParsedLine.szFileName, iTempFlag);
  5707. }
  5708. if ( _tcsicmp(ParsedLine.szType, _T("102")) == 0)
  5709. {
  5710. // Remove bad filters
  5711. // make sure we have a filename entry
  5712. iTempFlag = FALSE;
  5713. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5714. if (iTempFlag == FALSE)
  5715. {
  5716. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5717. goto ProcessEntry_Misc3_Exit;
  5718. }
  5719. // Check for extra flag
  5720. iTempFlag = FALSE;
  5721. if (_tcsicmp(ParsedLine.szData1, _T("1")) == 0){iTempFlag = TRUE;}
  5722. // Remove the filter
  5723. RemoveIncompatibleMetabaseFilters(ParsedLine.szFileName,iTempFlag);
  5724. }
  5725. if ( _tcsicmp(ParsedLine.szType, _T("103")) == 0)
  5726. {
  5727. // Compile mof file
  5728. // make sure we have a filename entry
  5729. iTempFlag = FALSE;
  5730. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5731. if (iTempFlag == FALSE)
  5732. {
  5733. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5734. goto ProcessEntry_Misc3_Exit;
  5735. }
  5736. // Remove the filter
  5737. HRESULT hres = MofCompile(ParsedLine.szFileName);
  5738. if (FAILED(hres))
  5739. {
  5740. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szFileName, hres, MB_OK | MB_SETFOREGROUND);}
  5741. else{iisDebugOut((LOG_TYPE_ERROR, _T("MofCompile(%s). Failed. Err=0x%x.\n"), ParsedLine.szFileName,hres));}
  5742. }
  5743. }
  5744. if ( _tcsicmp(ParsedLine.szType, _T("104")) == 0)
  5745. {
  5746. // make sure we have a filename entry
  5747. iTempFlag = FALSE;
  5748. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5749. if (iTempFlag == FALSE)
  5750. {
  5751. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5752. goto ProcessEntry_Misc3_Exit;
  5753. }
  5754. // Make sure we have a value for the entry point..
  5755. iTempFlag = FALSE;
  5756. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  5757. if (iTempFlag == FALSE)
  5758. {
  5759. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5760. goto ProcessEntry_Misc3_Exit;
  5761. }
  5762. // make sure there is a szData3 or a szData4.
  5763. ifTrueStatementExists = FALSE;
  5764. ifFalseStatementExists = FALSE;
  5765. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  5766. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  5767. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  5768. {
  5769. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5770. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5771. goto ProcessEntry_Misc3_Exit;
  5772. }
  5773. // okay we have either szData3 or szData4
  5774. // Check Entry point exists
  5775. iTempFlag = FALSE;
  5776. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("ProcessEntry_If:check for entrypoint [%1!s! (%2!s!)]\n"), ParsedLine.szFileName, ParsedLine.szData1));
  5777. // check if entry point exists
  5778. DWORD dwReturn = DoesEntryPointExist(ParsedLine.szFileName,ParsedLine.szData1);
  5779. if (ERROR_SUCCESS == dwReturn)
  5780. {
  5781. iTempFlag = TRUE;
  5782. }
  5783. else
  5784. {
  5785. if (ERROR_FILE_NOT_FOUND == dwReturn)
  5786. {
  5787. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("FileNot found:[%1!s!]\n"), ParsedLine.szFileName));
  5788. }
  5789. }
  5790. if (iTempFlag == TRUE)
  5791. {
  5792. // the result was true
  5793. // the key exists, so let's do the section...
  5794. if (ifTrueStatementExists)
  5795. {
  5796. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  5797. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  5798. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  5799. }
  5800. }
  5801. else
  5802. {
  5803. // the result was false
  5804. if (ifFalseStatementExists)
  5805. {
  5806. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData3));
  5807. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData3);
  5808. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData3, iTempFlag));
  5809. }
  5810. }
  5811. }
  5812. if ( _tcsicmp(ParsedLine.szType, _T("105")) == 0)
  5813. {
  5814. HRESULT hr;
  5815. // make sure we have a filename entry
  5816. iTempFlag = FALSE;
  5817. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5818. if (iTempFlag == FALSE)
  5819. {
  5820. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5821. goto ProcessEntry_Misc3_Exit;
  5822. }
  5823. // Make sure we have a value for the entry point..
  5824. iTempFlag = FALSE;
  5825. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  5826. if (iTempFlag == FALSE)
  5827. {
  5828. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5829. goto ProcessEntry_Misc3_Exit;
  5830. }
  5831. // Make sure we have a value for the entry point..
  5832. iTempFlag = FALSE;
  5833. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  5834. if (iTempFlag == FALSE)
  5835. {
  5836. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5837. goto ProcessEntry_Misc3_Exit;
  5838. }
  5839. // call function to CreateGroup
  5840. #ifndef _CHICAGO_
  5841. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0)
  5842. {
  5843. // add group
  5844. hr = CreateGroup(ParsedLine.szFileName,ParsedLine.szData1,TRUE);
  5845. if (FAILED(hr))
  5846. {
  5847. iisDebugOut((LOG_TYPE_WARN, _T("CreateGroup:%s,%s.failed.code=0x%x\n"),ParsedLine.szFileName, ParsedLine.szData1,hr));
  5848. }
  5849. }
  5850. else
  5851. {
  5852. // remove group
  5853. hr = CreateGroup(ParsedLine.szFileName,ParsedLine.szData1,FALSE);
  5854. if (FAILED(hr))
  5855. {
  5856. iisDebugOut((LOG_TYPE_WARN, _T("DeleteGroup:%s,%s.failed.code=0x%x\n"),ParsedLine.szFileName, ParsedLine.szData1,hr));
  5857. }
  5858. }
  5859. #endif
  5860. }
  5861. if ( _tcsicmp(ParsedLine.szType, _T("106")) == 0)
  5862. {
  5863. // make sure we have a filename entry
  5864. iTempFlag = FALSE;
  5865. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5866. if (iTempFlag == FALSE)
  5867. {
  5868. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5869. goto ProcessEntry_Misc3_Exit;
  5870. }
  5871. // Make sure we have a value for the entry point..
  5872. iTempFlag = FALSE;
  5873. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  5874. if (iTempFlag == FALSE)
  5875. {
  5876. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5877. goto ProcessEntry_Misc3_Exit;
  5878. }
  5879. // call function to CreateGroup
  5880. DWORD dwPermissions = MD_ACR_ENUM_KEYS;
  5881. dwPermissions = atodw(ParsedLine.szData1);
  5882. #ifndef _CHICAGO_
  5883. iTempFlag = TRUE;
  5884. if (g_pTheApp->m_bUpgradeTypeHasMetabaseFlag)
  5885. {
  5886. if (DoesAdminACLExist(ParsedLine.szFileName) == TRUE)
  5887. {iTempFlag = FALSE;}
  5888. }
  5889. // if this is upgrading from win95, then make sure to write the acl...
  5890. if (g_pTheApp->m_bWin95Migration){iTempFlag = TRUE;}
  5891. if (iTempFlag)
  5892. {
  5893. SetAdminACL_wrap(ParsedLine.szFileName,dwPermissions,TRUE);
  5894. }
  5895. #endif
  5896. }
  5897. if ( _tcsicmp(ParsedLine.szType, _T("107")) == 0)
  5898. {
  5899. // Run the ftp, upgrade code to move registry stuff to the metabase
  5900. FTP_Upgrade_RegToMetabase(g_pTheApp->m_hInfHandle);
  5901. }
  5902. if ( _tcsicmp(ParsedLine.szType, _T("108")) == 0)
  5903. {
  5904. // Run the w3svc, upgrade code to move registry stuff to the metabase
  5905. WWW_Upgrade_RegToMetabase(g_pTheApp->m_hInfHandle);
  5906. }
  5907. if ( _tcsicmp(ParsedLine.szType, _T("109")) == 0)
  5908. {
  5909. iTempFlag = FALSE;
  5910. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5911. if (iTempFlag == FALSE)
  5912. {
  5913. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5914. goto ProcessEntry_Misc3_Exit;
  5915. }
  5916. UpgradeFilters(ParsedLine.szFileName);
  5917. }
  5918. if ( _tcsicmp(ParsedLine.szType, _T("110")) == 0)
  5919. {
  5920. iTempFlag = FALSE;
  5921. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5922. if (iTempFlag == FALSE)
  5923. {
  5924. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5925. goto ProcessEntry_Misc3_Exit;
  5926. }
  5927. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  5928. if (iTempFlag == FALSE)
  5929. {
  5930. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5931. goto ProcessEntry_Misc3_Exit;
  5932. }
  5933. #ifndef _CHICAGO_
  5934. if (_tcsicmp(ParsedLine.szData1, _T("1")) == 0)
  5935. {
  5936. // add
  5937. RegisterAccountToLocalGroup(_T("system"),ParsedLine.szFileName,TRUE);
  5938. RegisterAccountToLocalGroup(_T("service"),ParsedLine.szFileName,TRUE);
  5939. RegisterAccountToLocalGroup(_T("networkservice"),ParsedLine.szFileName,TRUE);
  5940. }
  5941. else
  5942. {
  5943. // remove
  5944. RegisterAccountToLocalGroup(_T("system"),ParsedLine.szFileName,FALSE);
  5945. RegisterAccountToLocalGroup(_T("service"),ParsedLine.szFileName,FALSE);
  5946. RegisterAccountToLocalGroup(_T("networkservice"),ParsedLine.szFileName,FALSE);
  5947. }
  5948. #endif
  5949. }
  5950. if ( _tcsicmp(ParsedLine.szType, _T("111")) == 0)
  5951. {
  5952. iTempFlag = FALSE;
  5953. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5954. if (iTempFlag == FALSE)
  5955. {
  5956. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5957. goto ProcessEntry_Misc3_Exit;
  5958. }
  5959. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  5960. if (iTempFlag == FALSE)
  5961. {
  5962. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5963. goto ProcessEntry_Misc3_Exit;
  5964. }
  5965. #ifndef _CHICAGO_
  5966. AddUserToMetabaseACL(ParsedLine.szFileName,ParsedLine.szData1);
  5967. #endif
  5968. }
  5969. if ( _tcsicmp(ParsedLine.szType, _T("112")) == 0)
  5970. {
  5971. iTempFlag = FALSE;
  5972. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5973. if (iTempFlag == FALSE)
  5974. {
  5975. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5976. goto ProcessEntry_Misc3_Exit;
  5977. }
  5978. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  5979. if (iTempFlag == FALSE)
  5980. {
  5981. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5982. goto ProcessEntry_Misc3_Exit;
  5983. }
  5984. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  5985. if (iTempFlag == FALSE)
  5986. {
  5987. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5988. goto ProcessEntry_Misc3_Exit;
  5989. }
  5990. #ifndef _CHICAGO_
  5991. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0)
  5992. {
  5993. // add
  5994. RegisterAccountToLocalGroup(ParsedLine.szData1,ParsedLine.szFileName,TRUE);
  5995. }
  5996. else
  5997. {
  5998. // remove
  5999. RegisterAccountToLocalGroup(ParsedLine.szData1,ParsedLine.szFileName,FALSE);
  6000. }
  6001. #endif
  6002. }
  6003. if ( _tcsicmp(ParsedLine.szType, _T("113")) == 0)
  6004. {
  6005. iTempFlag = FALSE;
  6006. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6007. if (iTempFlag == FALSE)
  6008. {
  6009. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6010. goto ProcessEntry_Misc3_Exit;
  6011. }
  6012. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  6013. if (iTempFlag == FALSE)
  6014. {
  6015. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6016. goto ProcessEntry_Misc3_Exit;
  6017. }
  6018. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  6019. if (iTempFlag == FALSE)
  6020. {
  6021. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6022. goto ProcessEntry_Misc3_Exit;
  6023. }
  6024. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {iTempFlag = TRUE;}
  6025. if (iTempFlag == FALSE)
  6026. {
  6027. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6028. goto ProcessEntry_Misc3_Exit;
  6029. }
  6030. HKEY hRootKeyType = HKEY_LOCAL_MACHINE;
  6031. // check if the registry key exists...
  6032. if ( _tcsicmp(ParsedLine.szFileName, _T("HKLM")) == 0){hRootKeyType = HKEY_LOCAL_MACHINE;}
  6033. if ( _tcsicmp(ParsedLine.szFileName, _T("HKCR")) == 0){hRootKeyType = HKEY_CLASSES_ROOT;}
  6034. if ( _tcsicmp(ParsedLine.szFileName, _T("HKCU")) == 0){hRootKeyType = HKEY_CURRENT_USER;}
  6035. if ( _tcsicmp(ParsedLine.szFileName, _T("HKU")) == 0){hRootKeyType = HKEY_USERS;}
  6036. #ifndef _CHICAGO_
  6037. DWORD dwAccessMask = atodw(ParsedLine.szData3);
  6038. DWORD dwInheritMask = CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE;
  6039. SetRegistryKeySecurity(hRootKeyType,ParsedLine.szData1,ParsedLine.szData2,dwAccessMask,dwInheritMask,TRUE,ParsedLine.szData4);
  6040. #endif
  6041. }
  6042. if ( _tcsicmp(ParsedLine.szType, _T("114")) == 0)
  6043. {
  6044. iTempFlag = FALSE;
  6045. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6046. if (iTempFlag == FALSE)
  6047. {
  6048. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6049. goto ProcessEntry_Misc3_Exit;
  6050. }
  6051. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  6052. if (iTempFlag == FALSE)
  6053. {
  6054. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6055. goto ProcessEntry_Misc3_Exit;
  6056. }
  6057. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  6058. if (iTempFlag == FALSE)
  6059. {
  6060. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6061. goto ProcessEntry_Misc3_Exit;
  6062. }
  6063. // rename the metabase node.
  6064. if (CheckifServiceExist(_T("IISADMIN")) == 0 )
  6065. {
  6066. CMDKey cmdKey;
  6067. cmdKey.OpenNode(ParsedLine.szFileName);
  6068. if ( (METADATA_HANDLE)cmdKey )
  6069. {
  6070. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("RenameNode:%s=%s\n"),ParsedLine.szData1,ParsedLine.szData2));
  6071. cmdKey.RenameNode(ParsedLine.szData1, ParsedLine.szData2);
  6072. cmdKey.Close();
  6073. }
  6074. }
  6075. }
  6076. if ( _tcsicmp(ParsedLine.szType, _T("115")) == 0)
  6077. {
  6078. // make sure we have a filename entry
  6079. iTempFlag = FALSE;
  6080. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6081. if (iTempFlag == FALSE)
  6082. {
  6083. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6084. goto ProcessEntry_Misc3_Exit;
  6085. }
  6086. // make sure there is a szData1 or a szData2
  6087. ifTrueStatementExists = FALSE;
  6088. ifFalseStatementExists = FALSE;
  6089. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  6090. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  6091. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  6092. {
  6093. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6094. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6095. goto ProcessEntry_Misc3_Exit;
  6096. }
  6097. // okay we have either szData1 or szData2
  6098. // Check if the language specified in the .inf corresponds to
  6099. // our systems language.
  6100. iTempFlag = FALSE;
  6101. // Get our language
  6102. // set iTempFlag to true if it matches the same language they specified.
  6103. DWORD dwCodePage = GetACP();
  6104. DWORD dwTheCodePageSpecifiedinINF = 0;
  6105. dwTheCodePageSpecifiedinINF = atodw(ParsedLine.szFileName);
  6106. iisDebugOut((LOG_TYPE_TRACE, _T("CodePage=0x%x,%d\n"),dwCodePage,dwCodePage));
  6107. if (dwTheCodePageSpecifiedinINF == dwCodePage)
  6108. {
  6109. iTempFlag = TRUE;
  6110. }
  6111. if (iTempFlag == TRUE)
  6112. {
  6113. // the result was true
  6114. // the key exists, so let's do the section...
  6115. if (ifTrueStatementExists)
  6116. {
  6117. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData1));
  6118. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData1);
  6119. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData1, iTempFlag));
  6120. }
  6121. }
  6122. else
  6123. {
  6124. // the result was false
  6125. if (ifFalseStatementExists)
  6126. {
  6127. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  6128. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  6129. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  6130. }
  6131. }
  6132. }
  6133. if ( _tcsicmp(ParsedLine.szType, _T("116")) == 0)
  6134. {
  6135. iisDebugOut((LOG_TYPE_TRACE, _T("CreateDummyMetabaseBin\n")));
  6136. CreateDummyMetabaseBin();
  6137. }
  6138. if ( _tcsicmp(ParsedLine.szType, _T("117")) == 0)
  6139. {
  6140. // make sure we have a filename entry
  6141. iTempFlag = FALSE;
  6142. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6143. if (iTempFlag == FALSE)
  6144. {
  6145. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6146. goto ProcessEntry_Misc3_Exit;
  6147. }
  6148. // make sure there is a szData1 or a szData2
  6149. ifTrueStatementExists = FALSE;
  6150. ifFalseStatementExists = FALSE;
  6151. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  6152. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  6153. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  6154. {
  6155. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6156. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6157. goto ProcessEntry_Misc3_Exit;
  6158. }
  6159. // okay we have either szData1 or szData2
  6160. iTempFlag = CheckForWriteAccess(ParsedLine.szFileName);
  6161. if (iTempFlag == TRUE)
  6162. {
  6163. // the result was true
  6164. // the key exists, so let's do the section...
  6165. if (ifTrueStatementExists)
  6166. {
  6167. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData1));
  6168. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData1);
  6169. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData1, iTempFlag));
  6170. }
  6171. }
  6172. else
  6173. {
  6174. // the result was false
  6175. if (ifFalseStatementExists)
  6176. {
  6177. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  6178. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  6179. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  6180. }
  6181. }
  6182. }
  6183. if ( _tcsicmp(ParsedLine.szType, _T("118")) == 0)
  6184. {
  6185. iTempFlag = FALSE;
  6186. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6187. if (iTempFlag == FALSE)
  6188. {
  6189. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6190. goto ProcessEntry_Misc3_Exit;
  6191. }
  6192. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  6193. if (iTempFlag == FALSE)
  6194. {
  6195. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6196. goto ProcessEntry_Misc3_Exit;
  6197. }
  6198. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  6199. if (iTempFlag == FALSE)
  6200. {
  6201. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6202. goto ProcessEntry_Misc3_Exit;
  6203. }
  6204. #ifndef _CHICAGO_
  6205. if ( ( _tcsicmp(ParsedLine.szData4, _T("")) != 0) &&
  6206. ( _ttoi(ParsedLine.szData4) == 1 )
  6207. )
  6208. {
  6209. RemovePrincipalFromFileAcl(ParsedLine.szFileName,ParsedLine.szData1);
  6210. }
  6211. else
  6212. {
  6213. DWORD dwAccessMask = atodw(ParsedLine.szData2);
  6214. //DWORD dwInheritMask = CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE;
  6215. // don't remove any iheritance, keep all inheritance
  6216. DWORD dwInheritMask = 0;
  6217. INT iAceType = ACCESS_ALLOWED_ACE_TYPE;
  6218. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0)
  6219. {
  6220. iAceType = _ttoi(ParsedLine.szData3);
  6221. //dwInheritMask = CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE | INHERITED_ACE;
  6222. }
  6223. SetDirectorySecurity(ParsedLine.szFileName,ParsedLine.szData1,iAceType,dwAccessMask,dwInheritMask);
  6224. }
  6225. #endif
  6226. }
  6227. // We called the function, so return true.
  6228. iReturn = TRUE;
  6229. ProcessEntry_Misc3_Exit:
  6230. return iReturn;
  6231. }
  6232. int ProcessEntry_other(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  6233. {
  6234. int iReturn = FALSE;
  6235. int iTempFlag = FALSE;
  6236. int iProgressBarUpdated = FALSE;
  6237. int iShowErrorsOnFail = TRUE;
  6238. TCHAR szDirBefore[_MAX_PATH];
  6239. _tcscpy(szDirBefore, _T(""));
  6240. // Get the type.
  6241. if ( _tcsicmp(ParsedLine.szType, _T("19")) != 0 && _tcsicmp(ParsedLine.szType, _T("20")) != 0 &&
  6242. _tcsicmp(ParsedLine.szType, _T("21")) != 0 && _tcsicmp(ParsedLine.szType, _T("22")) != 0 &&
  6243. _tcsicmp(ParsedLine.szType, _T("23")) != 0 && _tcsicmp(ParsedLine.szType, _T("24")) != 0 &&
  6244. _tcsicmp(ParsedLine.szType, _T("25")) != 0 && _tcsicmp(ParsedLine.szType, _T("26")) != 0 &&
  6245. _tcsicmp(ParsedLine.szType, _T("27")) != 0 && _tcsicmp(ParsedLine.szType, _T("28")) != 0 &&
  6246. _tcsicmp(ParsedLine.szType, _T("29")) != 0 && _tcsicmp(ParsedLine.szType, _T("30")) != 0 &&
  6247. _tcsicmp(ParsedLine.szType, _T("31")) != 0 && _tcsicmp(ParsedLine.szType, _T("32")) != 0 &&
  6248. _tcsicmp(ParsedLine.szType, _T("33")) != 0 && _tcsicmp(ParsedLine.szType, _T("34")) != 0 &&
  6249. _tcsicmp(ParsedLine.szType, _T("35")) != 0 && _tcsicmp(ParsedLine.szType, _T("36")) != 0 &&
  6250. _tcsicmp(ParsedLine.szType, _T("37")) != 0 && _tcsicmp(ParsedLine.szType, _T("38")) != 0 &&
  6251. _tcsicmp(ParsedLine.szType, _T("120"))
  6252. )
  6253. {
  6254. goto ProcessEntry_other_Exit;
  6255. }
  6256. // Check if there is other criteria we need to pass
  6257. if (!ProcessEntry_CheckAll(csEntry, szTheSection, ParsedLine) )
  6258. {
  6259. goto ProcessEntry_other_Exit;
  6260. }
  6261. if (_tcsicmp(ParsedLine.szType, _T("28")) != 0)
  6262. {
  6263. if (_tcsicmp(ParsedLine.szType, _T("37")) != 0)
  6264. {
  6265. // make sure we have a filename entry
  6266. iTempFlag = FALSE;
  6267. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6268. if (iTempFlag == FALSE)
  6269. {
  6270. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6271. goto ProcessEntry_other_Exit;
  6272. }
  6273. }
  6274. }
  6275. iShowErrorsOnFail = TRUE;
  6276. if (_tcsicmp(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T("1")) == 0)
  6277. {iShowErrorsOnFail = FALSE;}
  6278. if (_tcsicmp(ParsedLine.szProgressTitle, _T("")) != 0)
  6279. {
  6280. ProgressBarTextStack_Set(ParsedLine.szProgressTitle);
  6281. iProgressBarUpdated = TRUE;
  6282. }
  6283. // Check if we need to change to a specific dir first...
  6284. if (ParsedLine.szChangeDir)
  6285. {
  6286. if (IsFileExist(ParsedLine.szChangeDir))
  6287. {
  6288. // save the current dir
  6289. GetCurrentDirectory( _MAX_PATH, szDirBefore);
  6290. // change to this dir
  6291. SetCurrentDirectory(ParsedLine.szChangeDir);
  6292. }
  6293. }
  6294. // check if we need to ask the user if they want to call it for sure.
  6295. if (!ProcessEntry_AskFirst(ParsedLine, 1))
  6296. {
  6297. goto ProcessEntry_other_Exit;
  6298. }
  6299. if ( _tcsicmp(ParsedLine.szType, _T("19")) == 0)
  6300. {
  6301. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("MyAddGroup:%1!s!\n"),ParsedLine.szFileName));
  6302. MyAddGroup(ParsedLine.szFileName);
  6303. }
  6304. if ( _tcsicmp(ParsedLine.szType, _T("20")) == 0)
  6305. {
  6306. if ( _tcsicmp(ParsedLine.szData1, _T("1")) == 0)
  6307. {
  6308. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("MyDeleteGroup:%1!s!. even if not empty.\n"),ParsedLine.szFileName));
  6309. MyDeleteGroup(ParsedLine.szFileName);
  6310. }
  6311. else
  6312. {
  6313. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("MyDeleteGroup:%1!s!. only if empty.\n"),ParsedLine.szFileName));
  6314. if (MyIsGroupEmpty(ParsedLine.szFileName)) {MyDeleteGroup(ParsedLine.szFileName);}
  6315. }
  6316. }
  6317. if ( _tcsicmp(ParsedLine.szType, _T("21")) == 0)
  6318. {
  6319. //MyAddItem(csGroupName, csAppName, csProgram, NULL, NULL);
  6320. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("MyAddItem:Type=%1!s!,%2!s!,%3!s!,%4!s!,%5!s!\n"),ParsedLine.szFileName, ParsedLine.szData1, ParsedLine.szData2, ParsedLine.szData3, ParsedLine.szData4));
  6321. if ( _tcsicmp(ParsedLine.szData3, _T("")) == 0 && _tcsicmp(ParsedLine.szData4, _T("")) == 0)
  6322. {
  6323. MyAddItem(ParsedLine.szFileName, ParsedLine.szData1, ParsedLine.szData2, NULL, NULL, NULL);
  6324. }
  6325. else
  6326. {
  6327. // if ParsedLine.szData4 is a directory, then
  6328. // the start in dir should be used there.
  6329. // if ParsedLine.szData4 is a filename, then
  6330. // the start in dir should be used there.
  6331. // and you ought to use the filename specified for the icon
  6332. if (IsFileExist(ParsedLine.szData4))
  6333. {
  6334. DWORD retCode = GetFileAttributes(ParsedLine.szData4);
  6335. if (retCode & FILE_ATTRIBUTE_DIRECTORY)
  6336. {
  6337. // It is a directory, so pass in only the directory information
  6338. MyAddItem(ParsedLine.szFileName, ParsedLine.szData1, ParsedLine.szData2, ParsedLine.szData3, ParsedLine.szData4, NULL);
  6339. }
  6340. else
  6341. {
  6342. // it is a file so get the directory and pass in the filename as well.
  6343. TCHAR szDirOnly[_MAX_PATH];
  6344. TCHAR szDirOnly2[_MAX_PATH];
  6345. _tcscpy(szDirOnly, _T(""));
  6346. _tcscpy(szDirOnly2, _T(""));
  6347. InetGetFilePath(ParsedLine.szData4, szDirOnly);
  6348. // change e:\winnt\system32 to %systemroot%\system32 if we need to.
  6349. ReverseExpandEnvironmentStrings(szDirOnly, szDirOnly2);
  6350. MyAddItem(ParsedLine.szFileName, ParsedLine.szData1, ParsedLine.szData2, ParsedLine.szData3, szDirOnly2, ParsedLine.szData4);
  6351. }
  6352. }
  6353. else
  6354. {
  6355. MyAddItem(ParsedLine.szFileName, ParsedLine.szData1, ParsedLine.szData2, NULL, NULL, NULL);
  6356. }
  6357. }
  6358. }
  6359. if ( _tcsicmp(ParsedLine.szType, _T("22")) == 0)
  6360. {
  6361. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("MyDeleteItem:%1!s!,%2!s!\n"),ParsedLine.szFileName, ParsedLine.szData1));
  6362. MyDeleteItem(ParsedLine.szFileName, ParsedLine.szData1);
  6363. }
  6364. if ( _tcsicmp(ParsedLine.szType, _T("23")) == 0)
  6365. {
  6366. //MyAddDeskTopItem(csAppName, csProgram, NULL, NULL, csProgram, 7);
  6367. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("MyAddDeskTopItem:Type=%1!s!,%2!s!,%3!s!\n"),ParsedLine.szFileName, ParsedLine.szData1, ParsedLine.szData2));
  6368. if ( _tcsicmp(ParsedLine.szData2, _T("")) == 0)
  6369. {
  6370. // icon number not specified
  6371. MyAddDeskTopItem(ParsedLine.szFileName, ParsedLine.szData1, NULL, NULL, ParsedLine.szData1, 7);
  6372. }
  6373. else
  6374. {
  6375. // icon specified use what they said to use
  6376. int iIconIndex = 7 ;
  6377. if (IsValidNumber((LPCTSTR)ParsedLine.szData2))
  6378. {iIconIndex = _ttoi((LPCTSTR)ParsedLine.szData2);}
  6379. MyAddDeskTopItem(ParsedLine.szFileName, ParsedLine.szData1, NULL, NULL, ParsedLine.szData1, iIconIndex);
  6380. }
  6381. }
  6382. if ( _tcsicmp(ParsedLine.szType, _T("24")) == 0)
  6383. {
  6384. //MyDeleteDeskTopItem(csAppName);
  6385. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("MyDeleteDeskTopItem:%1!s!\n"),ParsedLine.szFileName));
  6386. MyDeleteDeskTopItem(ParsedLine.szFileName);
  6387. }
  6388. if ( _tcsicmp(ParsedLine.szType, _T("120")) == 0)
  6389. {
  6390. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("DeleteFromGroup:%1!s!\n"),ParsedLine.szFileName));
  6391. DeleteFromGroup(ParsedLine.szFileName, ParsedLine.szData1);
  6392. }
  6393. if ( _tcsicmp(ParsedLine.szType, _T("25")) == 0)
  6394. {
  6395. //MyAddSendToItem(csAppName, csProgram, NULL, NULL);
  6396. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("MyAddSendToItem:Type=%1!s!,%2!s!\n"),ParsedLine.szFileName, ParsedLine.szData1));
  6397. MyAddSendToItem(ParsedLine.szFileName, ParsedLine.szData1, NULL, NULL);
  6398. }
  6399. if ( _tcsicmp(ParsedLine.szType, _T("26")) == 0)
  6400. {
  6401. //MyDeleteSendToItem(csAppName);
  6402. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("MyDeleteSendToItem:%1!s!\n"),ParsedLine.szFileName));
  6403. MyDeleteSendToItem(ParsedLine.szFileName);
  6404. }
  6405. if ( _tcsicmp(ParsedLine.szType, _T("27")) == 0)
  6406. {
  6407. if (ParsedLine.szFileName)
  6408. {
  6409. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0)
  6410. {
  6411. INT iUserWasNewlyCreated = 0;
  6412. //CreateIUSRAccount(g_pTheApp->m_csWWWAnonyName, g_pTheApp->m_csWWWAnonyPassword);
  6413. #ifndef _CHICAGO_
  6414. CreateIUSRAccount( (LPTSTR)(LPCTSTR) ParsedLine.szFileName, (LPTSTR)(LPCTSTR) ParsedLine.szData1,&iUserWasNewlyCreated);
  6415. #endif //_CHICAGO_
  6416. }
  6417. }
  6418. }
  6419. if ( _tcsicmp(ParsedLine.szType, _T("28")) == 0)
  6420. {
  6421. if (ParsedLine.szFileName)
  6422. {
  6423. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0)
  6424. {
  6425. #ifndef _CHICAGO_
  6426. int iUserWasDeleted = 0;
  6427. DeleteGuestUser( (LPTSTR)(LPCTSTR) ParsedLine.szFileName,&iUserWasDeleted);
  6428. // if the user was deleted, then remove it
  6429. // from the uninstall list!
  6430. if (1 == iUserWasDeleted)
  6431. {
  6432. g_pTheApp->UnInstallList_DelData(ParsedLine.szFileName);
  6433. }
  6434. #endif
  6435. }
  6436. }
  6437. }
  6438. // move location of directory recursive
  6439. if ( _tcsicmp(ParsedLine.szType, _T("29")) == 0)
  6440. {
  6441. if (ParsedLine.szFileName && _tcsicmp(ParsedLine.szFileName, _T("")) != 0)
  6442. {
  6443. // Check if the from directory even exist...
  6444. // see if the file exists
  6445. if (IsFileExist(ParsedLine.szFileName))
  6446. {
  6447. if (ParsedLine.szData1 && _tcsicmp(ParsedLine.szData1, _T("")) != 0)
  6448. {
  6449. if (TRUE == MoveFileEx( ParsedLine.szFileName, ParsedLine.szData1, MOVEFILE_COPY_ALLOWED|MOVEFILE_WRITE_THROUGH ))
  6450. {
  6451. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("MoveFileEx:%1!s! to %2!s!. success.\n"),ParsedLine.szFileName, ParsedLine.szData1));
  6452. }
  6453. else
  6454. {
  6455. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("MoveFileEx:%1!s! to %2!s!. failed.\n"),ParsedLine.szFileName, ParsedLine.szData1));
  6456. }
  6457. }
  6458. }
  6459. }
  6460. }
  6461. if ( _tcsicmp(ParsedLine.szType, _T("30")) == 0)
  6462. {
  6463. if (ParsedLine.szFileName && _tcsicmp(ParsedLine.szFileName, _T("")) != 0)
  6464. {
  6465. BOOL b;
  6466. BOOL bInstalled = FALSE;
  6467. CString csFile;
  6468. b = AddFontResource(ParsedLine.szFileName);
  6469. if (!b)
  6470. {
  6471. csFile = g_pTheApp->m_csWinDir + _T("\\Fonts\\");
  6472. csFile += ParsedLine.szFileName;
  6473. b = AddFontResource((LPCTSTR)csFile);
  6474. if (!b)
  6475. {
  6476. iisDebugOut((LOG_TYPE_ERROR, _T("AddFontResource:FAILED:, csFile=%s, err=0x%x,\n"), csFile, GetLastError()));
  6477. }
  6478. }
  6479. if (b)
  6480. {
  6481. SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
  6482. }
  6483. }
  6484. }
  6485. if ( _tcsicmp(ParsedLine.szType, _T("31")) == 0)
  6486. {
  6487. iTempFlag = FALSE;
  6488. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6489. if (iTempFlag == FALSE)
  6490. {
  6491. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6492. goto ProcessEntry_other_Exit;
  6493. }
  6494. iTempFlag = FALSE;
  6495. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  6496. if (iTempFlag == FALSE)
  6497. {
  6498. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6499. goto ProcessEntry_other_Exit;
  6500. }
  6501. iTempFlag = FALSE;
  6502. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  6503. if (iTempFlag == FALSE)
  6504. {
  6505. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6506. goto ProcessEntry_other_Exit;
  6507. }
  6508. AddURLShortcutItem( ParsedLine.szFileName, ParsedLine.szData1, ParsedLine.szData2);
  6509. }
  6510. if ( _tcsicmp(ParsedLine.szType, _T("32")) == 0)
  6511. {
  6512. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("MyAddItem:Type=%1!s!,%2!s!,%3!s!\n"),ParsedLine.szFileName, ParsedLine.szData1, ParsedLine.szData2));
  6513. MyAddItemInfoTip(ParsedLine.szFileName, ParsedLine.szData1, ParsedLine.szData2);
  6514. }
  6515. if ( _tcsicmp(ParsedLine.szType, _T("33")) == 0)
  6516. {
  6517. CString strUseThisFileName;
  6518. int iShowErrorsOnFail = TRUE;
  6519. if (_tcsicmp(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T("1")) == 0)
  6520. {iShowErrorsOnFail = FALSE;}
  6521. // the user can specify a filename or
  6522. // they can specify a registry location to get the filename from
  6523. // if the registry location is not there then use the filename.
  6524. // make sure we have a filename entry
  6525. iTempFlag = FALSE;
  6526. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6527. if (iTempFlag == FALSE)
  6528. {
  6529. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6530. goto ProcessEntry_other_Exit;
  6531. }
  6532. strUseThisFileName = ParsedLine.szFileName;
  6533. // if we have a valid registry entry then use that.
  6534. iTempFlag = FALSE;
  6535. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0)
  6536. {
  6537. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0)
  6538. {
  6539. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0)
  6540. {
  6541. // try to get the filename stored there.
  6542. HKEY hRootKeyType = HKEY_LOCAL_MACHINE;
  6543. // check if the registry key exists...
  6544. if ( _tcsicmp(ParsedLine.szData1, _T("HKLM")) == 0){hRootKeyType = HKEY_LOCAL_MACHINE;}
  6545. if ( _tcsicmp(ParsedLine.szData1, _T("HKCR")) == 0){hRootKeyType = HKEY_CLASSES_ROOT;}
  6546. if ( _tcsicmp(ParsedLine.szData1, _T("HKCU")) == 0){hRootKeyType = HKEY_CURRENT_USER;}
  6547. if ( _tcsicmp(ParsedLine.szData1, _T("HKU")) == 0){hRootKeyType = HKEY_USERS;}
  6548. iTempFlag = FALSE;
  6549. CRegKey regTheKey(hRootKeyType, ParsedLine.szData2,KEY_READ);
  6550. CString strReturnQueryValue;
  6551. if ((HKEY) regTheKey)
  6552. {
  6553. if (ERROR_SUCCESS == regTheKey.QueryValue(ParsedLine.szData3, strReturnQueryValue))
  6554. {
  6555. strUseThisFileName = strReturnQueryValue;
  6556. iTempFlag = TRUE;
  6557. }
  6558. }
  6559. }
  6560. }
  6561. }
  6562. // check if the the filename we want to use
  6563. // needs to get expanded "%windir%\myfile" or something.
  6564. if (-1 != strUseThisFileName.Find(_T('%')) )
  6565. {
  6566. // there is a '%' in the string
  6567. TCHAR szTempDir[_MAX_PATH];
  6568. _tcscpy(szTempDir, strUseThisFileName);
  6569. if (ExpandEnvironmentStrings( (LPCTSTR)strUseThisFileName, szTempDir, sizeof(szTempDir)/sizeof(TCHAR)))
  6570. {
  6571. strUseThisFileName = szTempDir;
  6572. }
  6573. }
  6574. if (TRUE == iTempFlag)
  6575. {
  6576. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("CreateAnEmptyFile:%1!s!. From Registry location.\n"),strUseThisFileName));
  6577. }
  6578. else
  6579. {
  6580. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("CreateAnEmptyFile:%1!s!\n"),strUseThisFileName));
  6581. }
  6582. if (TRUE != CreateAnEmptyFile(strUseThisFileName))
  6583. {
  6584. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, strUseThisFileName, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  6585. else{iisDebugOut((LOG_TYPE_TRACE, _T("CreateAnEmptyFile(%s). Failed. Err=0x%x.\n"), strUseThisFileName, GetLastError() ));}
  6586. }
  6587. }
  6588. if ( _tcsicmp(ParsedLine.szType, _T("34")) == 0)
  6589. {
  6590. CString strUseThisFileName;
  6591. TCHAR szUseThisFileName[_MAX_PATH];
  6592. iTempFlag = FALSE;
  6593. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6594. if (iTempFlag == FALSE)
  6595. {
  6596. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6597. goto ProcessEntry_other_Exit;
  6598. }
  6599. iTempFlag = FALSE;
  6600. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  6601. if (iTempFlag == FALSE)
  6602. {
  6603. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6604. goto ProcessEntry_other_Exit;
  6605. }
  6606. strUseThisFileName = ParsedLine.szFileName;
  6607. // if we have a valid registry entry then use that.
  6608. iTempFlag = FALSE;
  6609. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0)
  6610. {
  6611. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0)
  6612. {
  6613. if (_tcsicmp(ParsedLine.szData4, _T("")) != 0)
  6614. {
  6615. // try to get the filename stored there.
  6616. HKEY hRootKeyType = HKEY_LOCAL_MACHINE;
  6617. // check if the registry key exists...
  6618. if ( _tcsicmp(ParsedLine.szData2, _T("HKLM")) == 0){hRootKeyType = HKEY_LOCAL_MACHINE;}
  6619. if ( _tcsicmp(ParsedLine.szData2, _T("HKCR")) == 0){hRootKeyType = HKEY_CLASSES_ROOT;}
  6620. if ( _tcsicmp(ParsedLine.szData2, _T("HKCU")) == 0){hRootKeyType = HKEY_CURRENT_USER;}
  6621. if ( _tcsicmp(ParsedLine.szData2, _T("HKU")) == 0){hRootKeyType = HKEY_USERS;}
  6622. iTempFlag = FALSE;
  6623. CRegKey regTheKey(hRootKeyType, ParsedLine.szData3, KEY_READ);
  6624. CString strReturnQueryValue;
  6625. if ((HKEY) regTheKey)
  6626. {
  6627. if (ERROR_SUCCESS == regTheKey.QueryValue(ParsedLine.szData4, strReturnQueryValue))
  6628. {
  6629. strUseThisFileName = strReturnQueryValue;
  6630. iTempFlag = TRUE;
  6631. }
  6632. }
  6633. }
  6634. }
  6635. }
  6636. // check if the the filename we want to use
  6637. // needs to get expanded "%windir%\myfile" or something.
  6638. if (-1 != strUseThisFileName.Find(_T('%')) )
  6639. {
  6640. // there is a '%' in the string
  6641. TCHAR szTempDir[_MAX_PATH];
  6642. _tcscpy(szTempDir, strUseThisFileName);
  6643. if (ExpandEnvironmentStrings( (LPCTSTR)strUseThisFileName, szTempDir, sizeof(szTempDir)/sizeof(TCHAR)))
  6644. {
  6645. strUseThisFileName = szTempDir;
  6646. }
  6647. }
  6648. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("GrantUserAccessToFile:%1!s!,%2!s!\n"),strUseThisFileName, ParsedLine.szData1));
  6649. _tcscpy(szUseThisFileName, strUseThisFileName);
  6650. GrantUserAccessToFile(szUseThisFileName, ParsedLine.szData1);
  6651. }
  6652. if ( _tcsicmp(ParsedLine.szType, _T("35")) == 0)
  6653. {
  6654. DWORD dwID = 0;
  6655. DWORD dwAttrib = 0;
  6656. DWORD dwUserType = 0;
  6657. DWORD dwTheData = 0;
  6658. INT iOverwriteFlag = FALSE;
  6659. iTempFlag = FALSE;
  6660. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6661. if (iTempFlag == FALSE)
  6662. {
  6663. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6664. goto ProcessEntry_other_Exit;
  6665. }
  6666. iTempFlag = FALSE;
  6667. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  6668. if (iTempFlag == FALSE)
  6669. {
  6670. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6671. goto ProcessEntry_other_Exit;
  6672. }
  6673. // make sure we have a szData2 entry
  6674. iTempFlag = FALSE;
  6675. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  6676. if (iTempFlag == FALSE)
  6677. {
  6678. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6679. goto ProcessEntry_other_Exit;
  6680. }
  6681. // make sure we have a szData3 entry
  6682. iTempFlag = FALSE;
  6683. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {iTempFlag = TRUE;}
  6684. if (iTempFlag == FALSE)
  6685. {
  6686. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6687. goto ProcessEntry_other_Exit;
  6688. }
  6689. dwID = atodw(ParsedLine.szData1);
  6690. dwAttrib = METADATA_INHERIT;
  6691. dwUserType = atodw(ParsedLine.szData2);
  6692. dwTheData = atodw(ParsedLine.szData3);
  6693. iOverwriteFlag = FALSE;
  6694. if (_tcsicmp(ParsedLine.szData4, _T("1")) == 0)
  6695. {iOverwriteFlag = TRUE;}
  6696. if (CheckifServiceExist(_T("IISADMIN")) == 0 )
  6697. {
  6698. WriteToMD_DwordEntry(ParsedLine.szFileName, dwID, dwAttrib, dwUserType, dwTheData, iOverwriteFlag);
  6699. }
  6700. }
  6701. if ( _tcsicmp(ParsedLine.szType, _T("36")) == 0)
  6702. {
  6703. iTempFlag = FALSE;
  6704. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6705. if (iTempFlag == FALSE)
  6706. {
  6707. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6708. goto ProcessEntry_other_Exit;
  6709. }
  6710. #ifndef _CHICAGO_
  6711. SetIISADMINRestriction(ParsedLine.szFileName);
  6712. #endif
  6713. }
  6714. if ( _tcsicmp(ParsedLine.szType, _T("37")) == 0)
  6715. {
  6716. iTempFlag = FALSE;
  6717. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6718. if (iTempFlag == TRUE)
  6719. {
  6720. int MyLogErrorType = LOG_TYPE_TRACE;
  6721. if (_tcsicmp(ParsedLine.szData1, _T("0")) == 0)
  6722. {MyLogErrorType = LOG_TYPE_ERROR;}
  6723. if (_tcsicmp(ParsedLine.szData1, _T("1")) == 0)
  6724. {MyLogErrorType = LOG_TYPE_WARN;}
  6725. if (_tcsicmp(ParsedLine.szData1, _T("2")) == 0)
  6726. {MyLogErrorType = LOG_TYPE_PROGRAM_FLOW;}
  6727. if (_tcsicmp(ParsedLine.szData1, _T("3")) == 0)
  6728. {MyLogErrorType = LOG_TYPE_TRACE;}
  6729. if (_tcsicmp(ParsedLine.szData1, _T("4")) == 0)
  6730. {MyLogErrorType = LOG_TYPE_TRACE_WIN32_API;}
  6731. iisDebugOut((MyLogErrorType, _T("%s"), ParsedLine.szFileName));
  6732. }
  6733. }
  6734. if ( _tcsicmp(ParsedLine.szType, _T("38")) == 0)
  6735. {
  6736. BOOL bOK = FALSE;
  6737. BOOL bDeleteOld = FALSE;
  6738. BOOL bOverWriteToFile = FALSE;
  6739. // make sure we have a szData1 entry
  6740. iTempFlag = FALSE;
  6741. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  6742. if (iTempFlag == FALSE)
  6743. {
  6744. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6745. goto ProcessEntry_other_Exit;
  6746. }
  6747. bDeleteOld = FALSE;
  6748. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0) {bDeleteOld = TRUE;}
  6749. bOverWriteToFile = FALSE;
  6750. if (_tcsicmp(ParsedLine.szData3, _T("1")) == 0) {bOverWriteToFile = TRUE;}
  6751. if (IsFileExist(ParsedLine.szFileName))
  6752. {
  6753. //Save file attributes so they can be restored after we are done.
  6754. DWORD dwSourceAttrib = GetFileAttributes(ParsedLine.szFileName);
  6755. //Now set the file attributes to normal to ensure file ops succeed.
  6756. SetFileAttributes(ParsedLine.szFileName, FILE_ATTRIBUTE_NORMAL);
  6757. //from=ParsedLine.szFileName
  6758. //to=ParsedLine.szData1
  6759. // check if the 'to' filename exists.
  6760. if (!IsFileExist(ParsedLine.szData1))
  6761. {
  6762. // go ahead and try to copy it over
  6763. bOK = CopyFile(ParsedLine.szFileName, ParsedLine.szData1, FALSE);
  6764. if (bOK)
  6765. {
  6766. SetFileAttributes(ParsedLine.szData1, dwSourceAttrib);
  6767. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("%1!s! copied to %2!s!.\n"), ParsedLine.szFileName, ParsedLine.szData1));
  6768. // the file was copied. let's delete it now.
  6769. if (bDeleteOld)
  6770. {
  6771. if(!DeleteFile(ParsedLine.szFileName))
  6772. {
  6773. MoveFileEx(ParsedLine.szFileName, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
  6774. }
  6775. }
  6776. else
  6777. {
  6778. // set this files attribs back to what it was
  6779. SetFileAttributes(ParsedLine.szFileName, dwSourceAttrib);
  6780. }
  6781. }
  6782. else
  6783. {
  6784. // we were unable to copy the file over!
  6785. // don't delete the old one.
  6786. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("unabled to copy %1!s! to %2!s!.\n"), ParsedLine.szFileName, ParsedLine.szData1));
  6787. }
  6788. }
  6789. else
  6790. {
  6791. // the 'to' file exists, shall we overwrite it?
  6792. if (bOverWriteToFile)
  6793. {
  6794. if(DeleteFile(ParsedLine.szData1))
  6795. {
  6796. bOK = FALSE;
  6797. bOK = CopyFile(ParsedLine.szFileName, ParsedLine.szData1, FALSE);
  6798. if (bOK)
  6799. {
  6800. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("%1!s! copied to %2!s!.\n"), ParsedLine.szFileName, ParsedLine.szData1));
  6801. // the file was copied. let's delete it now.
  6802. if (bDeleteOld)
  6803. {
  6804. if(!DeleteFile(ParsedLine.szFileName))
  6805. {
  6806. MoveFileEx(ParsedLine.szFileName, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
  6807. }
  6808. }
  6809. else
  6810. {
  6811. // set this files attribs back to what it was
  6812. SetFileAttributes(ParsedLine.szFileName, dwSourceAttrib);
  6813. }
  6814. }
  6815. else
  6816. {
  6817. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("unabled to copy %1!s! to %2!s!.\n"), ParsedLine.szFileName, ParsedLine.szData1));
  6818. }
  6819. }
  6820. else
  6821. {
  6822. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("unabled to copy %1!s! to %2!s!. file#2 cannot be deleted.\n"), ParsedLine.szFileName, ParsedLine.szData1));
  6823. }
  6824. }
  6825. else
  6826. {
  6827. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("unabled to copy %1!s! to %2!s!. file#2 already exists.\n"), ParsedLine.szFileName, ParsedLine.szData1));
  6828. }
  6829. }
  6830. }
  6831. }
  6832. // We called the function, so return true.
  6833. iReturn = TRUE;
  6834. // change back to the original dir
  6835. if (ParsedLine.szChangeDir){if (szDirBefore){SetCurrentDirectory(szDirBefore);}}
  6836. ProcessEntry_AskLast(ParsedLine, 1);
  6837. ProcessEntry_other_Exit:
  6838. if (TRUE == iProgressBarUpdated){ProgressBarTextStack_Pop();}
  6839. return iReturn;
  6840. }
  6841. int ProcessEntry_Entry(IN HINF hFile, IN LPCTSTR szTheSection, IN CString csOneParseableLine)
  6842. {
  6843. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("ProcessEntry_Entry:%1!s!, %2!s!\n"),szTheSection, csOneParseableLine));
  6844. int iReturn = FALSE;
  6845. int iReturnTemp = FALSE;
  6846. int iTempFlag = FALSE;
  6847. ThingToDo ParsedLine;
  6848. _tcscpy(ParsedLine.szType, _T(""));
  6849. _tcscpy(ParsedLine.szFileName, _T(""));
  6850. _tcscpy(ParsedLine.szData1, _T(""));
  6851. _tcscpy(ParsedLine.szData2, _T(""));
  6852. _tcscpy(ParsedLine.szData3, _T(""));
  6853. _tcscpy(ParsedLine.szData4, _T(""));
  6854. _tcscpy(ParsedLine.szChangeDir, _T(""));
  6855. _tcscpy(ParsedLine.szOS, _T(""));
  6856. _tcscpy(ParsedLine.szPlatformArchitecture, _T(""));
  6857. _tcscpy(ParsedLine.szEnterprise, _T(""));
  6858. _tcscpy(ParsedLine.szErrIfFileNotFound, _T(""));
  6859. _tcscpy(ParsedLine.szMsgBoxBefore, _T(""));
  6860. _tcscpy(ParsedLine.szMsgBoxAfter, _T(""));
  6861. _tcscpy(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T(""));
  6862. _tcscpy(ParsedLine.szProgressTitle, _T(""));
  6863. // parse the line and put into another big cstring list
  6864. CStringList strListOrderImportant;
  6865. //
  6866. // Parse the long string and put into another list
  6867. //
  6868. LPTSTR lpBuffer = NULL;
  6869. lpBuffer = (LPTSTR) LocalAlloc(LPTR, (csOneParseableLine.GetLength() + 1) * sizeof(TCHAR) );
  6870. if ( !lpBuffer )
  6871. {
  6872. iisDebugOut((LOG_TYPE_ERROR, _T("ProcessEntry_Entry:Failed to allocate memory.")));
  6873. return iReturn;
  6874. }
  6875. _tcscpy(lpBuffer, csOneParseableLine);
  6876. TCHAR *token = NULL;
  6877. token = _tcstok(lpBuffer, _T("|"));
  6878. while (token != NULL)
  6879. {
  6880. strListOrderImportant.AddTail(token);
  6881. token = _tcstok(NULL, _T("|"));
  6882. }
  6883. // Loop thru the new list and set variables
  6884. int i = 0;
  6885. int iFoundMatch = FALSE;
  6886. POSITION pos = NULL;
  6887. CString csEntry;
  6888. int iEntryLen = 0;
  6889. pos = strListOrderImportant.GetHeadPosition();
  6890. while (pos)
  6891. {
  6892. iFoundMatch = FALSE;
  6893. csEntry = strListOrderImportant.GetAt(pos);
  6894. iEntryLen=(csEntry.GetLength() + 1) * sizeof(TCHAR);
  6895. // Look for "100:"
  6896. // 100=Type (1=DllFunction,2=DllFunctionInitOle, 2=Executable, 3=RunThisExe, 4=DoSection, 5=DoINFSection)
  6897. if (csEntry.Left(4) == ThingToDoNumType_100 && iFoundMatch != TRUE)
  6898. {
  6899. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  6900. if (iEntryLen <= sizeof(ParsedLine.szType)) {_tcscpy(ParsedLine.szType, csEntry);}
  6901. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_100,csEntry));}
  6902. iFoundMatch = TRUE;
  6903. }
  6904. // 101=File
  6905. if (csEntry.Left(4) == ThingToDoNumType_101 && iFoundMatch != TRUE)
  6906. {
  6907. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  6908. if (iEntryLen <= sizeof(ParsedLine.szFileName)) {_tcscpy(ParsedLine.szFileName, csEntry);}
  6909. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_101, csEntry));}
  6910. if (-1 != csEntry.Find(_T('<')) )
  6911. {
  6912. // there is a < in the string
  6913. int iWhere = 0;
  6914. CString csValue2;
  6915. csEntry.MakeUpper();
  6916. if (csEntry.Find(_T("<SYSTEMROOT>")) != (-1) )
  6917. {
  6918. // We Found the cheesy <SYSTEMROOT> deal. Now replace it with the real SYSTEMROOT
  6919. iWhere = csEntry.Find(_T("<SYSTEMROOT>"));
  6920. iWhere = iWhere + _tcslen(_T("<SYSTEMROOT>"));
  6921. csValue2 = g_pTheApp->m_csWinDir + csEntry.Right( csEntry.GetLength() - (iWhere) );
  6922. csEntry = csValue2;
  6923. if (iEntryLen <= sizeof(ParsedLine.szFileName)) {_tcscpy(ParsedLine.szFileName, csEntry);}
  6924. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("ProcessEntry_Entry:ParseError:%s.1:%1!s! -- entry to big\n"),ThingToDoNumType_101,csEntry));}
  6925. }
  6926. if (csEntry.Find(_T("<SYSTEMDRIVE>")) != (-1) )
  6927. {
  6928. // We Found the cheesy <SYSTEMDRIVE> deal. Now replace it with the real systemdrive
  6929. iWhere = csEntry.Find(_T("<SYSTEMDRIVE>"));
  6930. iWhere = iWhere + _tcslen(_T("<SYSTEMDRIVE>"));
  6931. csValue2 = g_pTheApp->m_csSysDrive + csEntry.Right( csEntry.GetLength() - (iWhere) );
  6932. csEntry = csValue2;
  6933. if (iEntryLen <= sizeof(ParsedLine.szFileName)) {_tcscpy(ParsedLine.szFileName, csEntry);}
  6934. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_101,csEntry));}
  6935. }
  6936. }
  6937. iFoundMatch = TRUE;
  6938. }
  6939. // ThingToDoNumType_102=szData1
  6940. if (csEntry.Left(4) == ThingToDoNumType_102 && iFoundMatch != TRUE)
  6941. {
  6942. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  6943. if (iEntryLen <= sizeof(ParsedLine.szData1)) {_tcscpy(ParsedLine.szData1, csEntry);}
  6944. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_102,csEntry));}
  6945. iFoundMatch = TRUE;
  6946. if (-1 != csEntry.Find(_T('<')) )
  6947. {
  6948. // there is a < in the string
  6949. int iWhere = 0;
  6950. CString csValue2;
  6951. csEntry.MakeUpper();
  6952. if (csEntry.Find(_T("<SYSTEMROOT>")) != (-1) )
  6953. {
  6954. // We Found the cheesy <SYSTEMROOT> deal. Now replace it with the real SYSTEMROOT
  6955. iWhere = csEntry.Find(_T("<SYSTEMROOT>"));
  6956. iWhere = iWhere + _tcslen(_T("<SYSTEMROOT>"));
  6957. csValue2 = g_pTheApp->m_csWinDir + csEntry.Right( csEntry.GetLength() - (iWhere) );
  6958. csEntry = csValue2;
  6959. if (iEntryLen <= sizeof(ParsedLine.szData1)) {_tcscpy(ParsedLine.szData1, csEntry);}
  6960. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("ProcessEntry_Entry:ParseError:%s.1:%1!s! -- entry to big\n"),ThingToDoNumType_102, csEntry));}
  6961. }
  6962. if (csEntry.Find(_T("<SYSTEMDRIVE>")) != (-1) )
  6963. {
  6964. // We Found the cheesy <SYSTEMDRIVE> deal. Now replace it with the real SYSTEMROOT
  6965. iWhere = csEntry.Find(_T("<SYSTEMDRIVE>"));
  6966. iWhere = iWhere + _tcslen(_T("<SYSTEMDRIVE>"));
  6967. csValue2 = g_pTheApp->m_csSysDrive + csEntry.Right( csEntry.GetLength() - (iWhere) );
  6968. csEntry = csValue2;
  6969. if (iEntryLen <= sizeof(ParsedLine.szData1)) {_tcscpy(ParsedLine.szData1, csEntry);}
  6970. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_102,csEntry));}
  6971. }
  6972. }
  6973. }
  6974. // ThingToDoNumType_103=szData2
  6975. if (csEntry.Left(4) == ThingToDoNumType_103 && iFoundMatch != TRUE)
  6976. {
  6977. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  6978. if (iEntryLen <= sizeof(ParsedLine.szData2)) {_tcscpy(ParsedLine.szData2, csEntry);}
  6979. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_103,csEntry));}
  6980. iFoundMatch = TRUE;
  6981. }
  6982. // ThingToDoNumType_104=szData3
  6983. if (csEntry.Left(4) == ThingToDoNumType_104 && iFoundMatch != TRUE)
  6984. {
  6985. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  6986. if (iEntryLen <= sizeof(ParsedLine.szData3)) {_tcscpy(ParsedLine.szData3, csEntry);}
  6987. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_104,csEntry));}
  6988. iFoundMatch = TRUE;
  6989. }
  6990. // ThingToDoNumType_105=szData4
  6991. if (csEntry.Left(4) == ThingToDoNumType_105 && iFoundMatch != TRUE)
  6992. {
  6993. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  6994. if (iEntryLen <= sizeof(ParsedLine.szData4)) {_tcscpy(ParsedLine.szData4, csEntry);}
  6995. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_105,csEntry));}
  6996. iFoundMatch = TRUE;
  6997. }
  6998. // 200=ChangeToThisDirFirst
  6999. if (csEntry.Left(4) == ThingToDoNumType_200 && iFoundMatch != TRUE)
  7000. {
  7001. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  7002. if (iEntryLen <= sizeof(ParsedLine.szChangeDir)) {_tcscpy(ParsedLine.szChangeDir, csEntry);}
  7003. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_200,csEntry));}
  7004. iFoundMatch = TRUE;
  7005. if (-1 != csEntry.Find(_T('<')) )
  7006. {
  7007. // there is a < in the string
  7008. int iWhere = 0;
  7009. CString csValue2;
  7010. csEntry.MakeUpper();
  7011. if (csEntry.Find(_T("<SYSTEMROOT>")) != (-1) )
  7012. {
  7013. // We Found the cheesy <SYSTEMROOT> deal. Now replace it with the real SYSTEMROOT
  7014. iWhere = csEntry.Find(_T("<SYSTEMROOT>"));
  7015. iWhere = iWhere + _tcslen(_T("<SYSTEMROOT>"));
  7016. csValue2 = g_pTheApp->m_csWinDir + csEntry.Right( csEntry.GetLength() - (iWhere) );
  7017. csEntry = csValue2;
  7018. if (iEntryLen <= sizeof(ParsedLine.szChangeDir)) {_tcscpy(ParsedLine.szChangeDir, csEntry);}
  7019. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("ProcessEntry_Entry:ParseError:%s.1:%1!s! -- entry to big\n"),ThingToDoNumType_200,csEntry));}
  7020. }
  7021. if (csEntry.Find(_T("<SYSTEMDRIVE>")) != (-1) )
  7022. {
  7023. // We Found the cheesy <SYSTEMDRIVE> deal. Now replace it with the real SYSTEMROOT
  7024. iWhere = csEntry.Find(_T("<SYSTEMDRIVE>"));
  7025. iWhere = iWhere + _tcslen(_T("<SYSTEMDRIVE>"));
  7026. csValue2 = g_pTheApp->m_csSysDrive + csEntry.Right( csEntry.GetLength() - (iWhere) );
  7027. csEntry = csValue2;
  7028. if (iEntryLen <= sizeof(ParsedLine.szChangeDir)) {_tcscpy(ParsedLine.szChangeDir, csEntry);}
  7029. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_200,csEntry));}
  7030. }
  7031. }
  7032. }
  7033. // 701=OS (0=ALL,1=NTS,2=NTW,4=NTDC)
  7034. if (csEntry.Left(4) == ThingToDoNumType_701 && iFoundMatch != TRUE)
  7035. {
  7036. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  7037. if (iEntryLen <= sizeof(ParsedLine.szOS)) {_tcscpy(ParsedLine.szOS, csEntry);}
  7038. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_701,csEntry));}
  7039. iFoundMatch = TRUE;
  7040. }
  7041. // 702=PlatformArchitecture (0=ALL,1=x86,2=alpha)
  7042. if (csEntry.Left(4) == ThingToDoNumType_702 && iFoundMatch != TRUE)
  7043. {
  7044. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  7045. if (iEntryLen <= sizeof(ParsedLine.szPlatformArchitecture)) {_tcscpy(ParsedLine.szPlatformArchitecture, csEntry);}
  7046. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_702,csEntry));}
  7047. iFoundMatch = TRUE;
  7048. }
  7049. // 703=Enterprise (1=yes,0=no)
  7050. if (csEntry.Left(4) == ThingToDoNumType_703 && iFoundMatch != TRUE)
  7051. {
  7052. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  7053. if (iEntryLen <= sizeof(ParsedLine.szEnterprise)) {_tcscpy(ParsedLine.szEnterprise, csEntry);}
  7054. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_703,csEntry));}
  7055. iFoundMatch = TRUE;
  7056. }
  7057. // 801=ErrIfFileNotFound (1=Show error if filenot found, 0=don't show error)
  7058. if (csEntry.Left(4) == ThingToDoNumType_801 && iFoundMatch != TRUE)
  7059. {
  7060. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  7061. if (iEntryLen <= sizeof(ParsedLine.szErrIfFileNotFound)) {_tcscpy(ParsedLine.szErrIfFileNotFound, csEntry);}
  7062. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_801,csEntry));}
  7063. iFoundMatch = TRUE;
  7064. }
  7065. // 802=Ask User if they want to call this function with msgbox (1=yes,0=no)
  7066. if (csEntry.Left(4) == ThingToDoNumType_802 && iFoundMatch != TRUE)
  7067. {
  7068. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  7069. if (iEntryLen <= sizeof(ParsedLine.szMsgBoxBefore)) {_tcscpy(ParsedLine.szMsgBoxBefore, csEntry);}
  7070. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_802,csEntry));}
  7071. iFoundMatch = TRUE;
  7072. }
  7073. // 803=notify use after calling the function (1=yes,0=no)
  7074. if (csEntry.Left(4) == ThingToDoNumType_803 && iFoundMatch != TRUE)
  7075. {
  7076. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  7077. if (iEntryLen <= sizeof(ParsedLine.szMsgBoxAfter)) {_tcscpy(ParsedLine.szMsgBoxAfter, csEntry);}
  7078. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_803,csEntry));}
  7079. iFoundMatch = TRUE;
  7080. }
  7081. // 804=szDoNotDisplayErrIfFunctionFailed (1= dont Show error , 0=show error)
  7082. if (csEntry.Left(4) == ThingToDoNumType_804 && iFoundMatch != TRUE)
  7083. {
  7084. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  7085. if (iEntryLen <= sizeof(ParsedLine.szDoNotDisplayErrIfFunctionFailed)) {_tcscpy(ParsedLine.szDoNotDisplayErrIfFunctionFailed, csEntry);}
  7086. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_804,csEntry));}
  7087. iFoundMatch = TRUE;
  7088. }
  7089. // 805=szProgressTitle
  7090. if (csEntry.Left(4) == ThingToDoNumType_805 && iFoundMatch != TRUE)
  7091. {
  7092. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  7093. if (iEntryLen <= sizeof(ParsedLine.szProgressTitle)) {_tcscpy(ParsedLine.szProgressTitle, csEntry);}
  7094. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_805,csEntry));}
  7095. iFoundMatch = TRUE;
  7096. }
  7097. if (iFoundMatch != TRUE)
  7098. {
  7099. // We didn't find a match, so output the problem to the logs..
  7100. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("ProcessEntry_Entry():UnknownOption '%1!s!'. Section=%2!s!..\n"),csEntry, szTheSection));
  7101. }
  7102. // Get next value
  7103. strListOrderImportant.GetNext(pos);
  7104. i++;
  7105. }
  7106. iFoundMatch = FALSE;
  7107. /*
  7108. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("ProcessEntry_Entry:PleaseProcess:type=%1!s!,filename=%2!s!,data=%3!s!,os=%4!s!,plat=%5!s!,errnofile=%6!s!,msgb=%7!s!,msga=%8!s!,noerr=%9!s!\n"),
  7109. ParsedLine.szType,
  7110. ParsedLine.szFileName,
  7111. ParsedLine.szData1,
  7112. ParsedLine.szOS,
  7113. ParsedLine.szPlatformArchitecture,
  7114. ParsedLine.szEnterprise
  7115. ParsedLine.szErrIfFileNotFound,
  7116. ParsedLine.szMsgBoxBefore,
  7117. ParsedLine.szMsgBoxAfter,
  7118. ParsedLine.szDoNotDisplayErrIfFunctionFailed
  7119. ));
  7120. */
  7121. if (i >= 1)
  7122. {
  7123. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("...ProcessEntry:100=%1!s!...\n"),ParsedLine.szType));
  7124. // Get the type.
  7125. //
  7126. // 100=Type (1=DllFunction,2=DllFunctionInitOle, 2=Executable, 3=RunThisExe, 4=DoSection, 5=DoINFSection)
  7127. //
  7128. if ( _tcsicmp(ParsedLine.szType, _T("1")) == 0 || _tcsicmp(ParsedLine.szType, _T("2")) == 0 )
  7129. {
  7130. // 100=1=DllFunction,2=DllFunctionInitOle
  7131. // We are doing a call to a function in a DLL.
  7132. iReturnTemp = ProcessEntry_CallDll(csEntry,szTheSection,ParsedLine);
  7133. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7134. iFoundMatch = TRUE;
  7135. }
  7136. // 100=7,8,9,10,11,12,13,14
  7137. if ( _tcsicmp(ParsedLine.szType, _T("7")) == 0 || _tcsicmp(ParsedLine.szType, _T("8")) == 0 ||
  7138. _tcsicmp(ParsedLine.szType, _T("9")) == 0 || _tcsicmp(ParsedLine.szType, _T("10")) == 0 ||
  7139. _tcsicmp(ParsedLine.szType, _T("11")) == 0 || _tcsicmp(ParsedLine.szType, _T("12")) == 0 ||
  7140. _tcsicmp(ParsedLine.szType, _T("13")) == 0 || _tcsicmp(ParsedLine.szType, _T("14")) == 0 ||
  7141. _tcsicmp(ParsedLine.szType, _T("17")) == 0 || _tcsicmp(ParsedLine.szType, _T("18")) == 0
  7142. )
  7143. {
  7144. iReturnTemp = ProcessEntry_Misc1(csEntry,szTheSection,ParsedLine);
  7145. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7146. iFoundMatch = TRUE;
  7147. }
  7148. if ( _tcsicmp(ParsedLine.szType, _T("19")) == 0 || _tcsicmp(ParsedLine.szType, _T("20")) == 0 ||
  7149. _tcsicmp(ParsedLine.szType, _T("21")) == 0 || _tcsicmp(ParsedLine.szType, _T("22")) == 0 ||
  7150. _tcsicmp(ParsedLine.szType, _T("23")) == 0 || _tcsicmp(ParsedLine.szType, _T("24")) == 0 ||
  7151. _tcsicmp(ParsedLine.szType, _T("25")) == 0 || _tcsicmp(ParsedLine.szType, _T("26")) == 0 ||
  7152. _tcsicmp(ParsedLine.szType, _T("27")) == 0 || _tcsicmp(ParsedLine.szType, _T("28")) == 0 ||
  7153. _tcsicmp(ParsedLine.szType, _T("29")) == 0 || _tcsicmp(ParsedLine.szType, _T("30")) == 0 ||
  7154. _tcsicmp(ParsedLine.szType, _T("31")) == 0 || _tcsicmp(ParsedLine.szType, _T("32")) == 0 ||
  7155. _tcsicmp(ParsedLine.szType, _T("33")) == 0 || _tcsicmp(ParsedLine.szType, _T("34")) == 0 ||
  7156. _tcsicmp(ParsedLine.szType, _T("35")) == 0 || _tcsicmp(ParsedLine.szType, _T("36")) == 0 ||
  7157. _tcsicmp(ParsedLine.szType, _T("37")) == 0 || _tcsicmp(ParsedLine.szType, _T("38")) == 0 ||
  7158. _tcsicmp(ParsedLine.szType, _T("120")) == 0
  7159. )
  7160. {
  7161. iReturnTemp = ProcessEntry_other(csEntry,szTheSection,ParsedLine);
  7162. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7163. iFoundMatch = TRUE;
  7164. }
  7165. if ( _tcsicmp(ParsedLine.szType, _T("39")) == 0 ||
  7166. _tcsicmp(ParsedLine.szType, _T("40")) == 0 || _tcsicmp(ParsedLine.szType, _T("41")) == 0 ||
  7167. _tcsicmp(ParsedLine.szType, _T("42")) == 0 || _tcsicmp(ParsedLine.szType, _T("43")) == 0 ||
  7168. _tcsicmp(ParsedLine.szType, _T("44")) == 0 || _tcsicmp(ParsedLine.szType, _T("45")) == 0 ||
  7169. _tcsicmp(ParsedLine.szType, _T("46")) == 0 || _tcsicmp(ParsedLine.szType, _T("47")) == 0 ||
  7170. _tcsicmp(ParsedLine.szType, _T("48")) == 0 || _tcsicmp(ParsedLine.szType, _T("49")) == 0 ||
  7171. _tcsicmp(ParsedLine.szType, _T("100")) == 0 || _tcsicmp(ParsedLine.szType, _T("119")) == 0
  7172. )
  7173. {
  7174. iReturnTemp = ProcessEntry_If(csEntry,szTheSection,ParsedLine);
  7175. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7176. iFoundMatch = TRUE;
  7177. }
  7178. if ( _tcsicmp(ParsedLine.szType, _T("50")) == 0 || _tcsicmp(ParsedLine.szType, _T("51")) == 0 ||
  7179. _tcsicmp(ParsedLine.szType, _T("52")) == 0 || _tcsicmp(ParsedLine.szType, _T("53")) == 0 ||
  7180. _tcsicmp(ParsedLine.szType, _T("54")) == 0 || _tcsicmp(ParsedLine.szType, _T("55")) == 0 ||
  7181. _tcsicmp(ParsedLine.szType, _T("56")) == 0 || _tcsicmp(ParsedLine.szType, _T("57")) == 0 ||
  7182. _tcsicmp(ParsedLine.szType, _T("58")) == 0 || _tcsicmp(ParsedLine.szType, _T("59")) == 0 ||
  7183. _tcsicmp(ParsedLine.szType, _T("60")) == 0 || _tcsicmp(ParsedLine.szType, _T("61")) == 0 ||
  7184. _tcsicmp(ParsedLine.szType, _T("62")) == 0 || _tcsicmp(ParsedLine.szType, _T("63")) == 0 ||
  7185. _tcsicmp(ParsedLine.szType, _T("64")) == 0 || _tcsicmp(ParsedLine.szType, _T("65")) == 0 ||
  7186. _tcsicmp(ParsedLine.szType, _T("66")) == 0 || _tcsicmp(ParsedLine.szType, _T("67")) == 0 ||
  7187. _tcsicmp(ParsedLine.szType, _T("68")) == 0 || _tcsicmp(ParsedLine.szType, _T("69")) == 0
  7188. )
  7189. {
  7190. iReturnTemp = ProcessEntry_SVC_Clus(csEntry,szTheSection,ParsedLine);
  7191. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7192. iFoundMatch = TRUE;
  7193. }
  7194. if ( _tcsicmp(ParsedLine.szType, _T("70")) == 0 || _tcsicmp(ParsedLine.szType, _T("71")) == 0 ||
  7195. _tcsicmp(ParsedLine.szType, _T("72")) == 0 || _tcsicmp(ParsedLine.szType, _T("73")) == 0 ||
  7196. _tcsicmp(ParsedLine.szType, _T("74")) == 0 || _tcsicmp(ParsedLine.szType, _T("75")) == 0 ||
  7197. _tcsicmp(ParsedLine.szType, _T("76")) == 0 || _tcsicmp(ParsedLine.szType, _T("77")) == 0
  7198. )
  7199. {
  7200. iReturnTemp = ProcessEntry_Dcom(csEntry,szTheSection,ParsedLine);
  7201. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7202. iFoundMatch = TRUE;
  7203. }
  7204. if ( _tcsicmp(ParsedLine.szType, _T("82")) == 0 || _tcsicmp(ParsedLine.szType, _T("83")) == 0 ||
  7205. _tcsicmp(ParsedLine.szType, _T("84")) == 0 || _tcsicmp(ParsedLine.szType, _T("85")) == 0
  7206. )
  7207. {
  7208. iReturnTemp = ProcessEntry_Metabase(csEntry,szTheSection,ParsedLine);
  7209. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7210. iFoundMatch = TRUE;
  7211. }
  7212. if ( _tcsicmp(ParsedLine.szType, _T("15")) == 0 || _tcsicmp(ParsedLine.szType, _T("16")) == 0 ||
  7213. _tcsicmp(ParsedLine.szType, _T("78")) == 0 || _tcsicmp(ParsedLine.szType, _T("79")) == 0 ||
  7214. _tcsicmp(ParsedLine.szType, _T("80")) == 0 || _tcsicmp(ParsedLine.szType, _T("81")) == 0 ||
  7215. _tcsicmp(ParsedLine.szType, _T("86")) == 0 || _tcsicmp(ParsedLine.szType, _T("87")) == 0 ||
  7216. _tcsicmp(ParsedLine.szType, _T("88")) == 0 || _tcsicmp(ParsedLine.szType, _T("89")) == 0 ||
  7217. _tcsicmp(ParsedLine.szType, _T("90")) == 0 || _tcsicmp(ParsedLine.szType, _T("91")) == 0 ||
  7218. _tcsicmp(ParsedLine.szType, _T("92")) == 0 || _tcsicmp(ParsedLine.szType, _T("93")) == 0 ||
  7219. _tcsicmp(ParsedLine.szType, _T("94")) == 0 || _tcsicmp(ParsedLine.szType, _T("95")) == 0 ||
  7220. _tcsicmp(ParsedLine.szType, _T("96")) == 0 || _tcsicmp(ParsedLine.szType, _T("97")) == 0 ||
  7221. _tcsicmp(ParsedLine.szType, _T("98")) == 0 || _tcsicmp(ParsedLine.szType, _T("99")) == 0
  7222. )
  7223. {
  7224. iReturnTemp = ProcessEntry_Misc2(csEntry,szTheSection,ParsedLine);
  7225. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7226. iFoundMatch = TRUE;
  7227. }
  7228. if ( _tcsicmp(ParsedLine.szType, _T("101")) == 0 || _tcsicmp(ParsedLine.szType, _T("102")) == 0 ||
  7229. _tcsicmp(ParsedLine.szType, _T("103")) == 0 || _tcsicmp(ParsedLine.szType, _T("104")) == 0 ||
  7230. _tcsicmp(ParsedLine.szType, _T("105")) == 0 || _tcsicmp(ParsedLine.szType, _T("106")) == 0 ||
  7231. _tcsicmp(ParsedLine.szType, _T("107")) == 0 || _tcsicmp(ParsedLine.szType, _T("108")) == 0 ||
  7232. _tcsicmp(ParsedLine.szType, _T("109")) == 0 || _tcsicmp(ParsedLine.szType, _T("110")) == 0 ||
  7233. _tcsicmp(ParsedLine.szType, _T("111")) == 0 || _tcsicmp(ParsedLine.szType, _T("112")) == 0 ||
  7234. _tcsicmp(ParsedLine.szType, _T("113")) == 0 || _tcsicmp(ParsedLine.szType, _T("114")) == 0 ||
  7235. _tcsicmp(ParsedLine.szType, _T("115")) == 0 || _tcsicmp(ParsedLine.szType, _T("116")) == 0 ||
  7236. _tcsicmp(ParsedLine.szType, _T("117")) == 0 || _tcsicmp(ParsedLine.szType, _T("118")) == 0
  7237. )
  7238. {
  7239. iReturnTemp = ProcessEntry_Misc3(csEntry,szTheSection,ParsedLine);
  7240. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7241. iFoundMatch = TRUE;
  7242. }
  7243. //
  7244. // 100= 3=Executable
  7245. //
  7246. if ( _tcsicmp(ParsedLine.szType, _T("3")) == 0)
  7247. {
  7248. iReturnTemp = ProcessEntry_Call_Exe(csEntry,szTheSection,ParsedLine);
  7249. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7250. iFoundMatch = TRUE;
  7251. }
  7252. //
  7253. // 100= 4=Call InternalSectionInIISDll
  7254. //
  7255. if ( _tcsicmp(ParsedLine.szType, _T("4")) == 0)
  7256. {
  7257. iReturnTemp = ProcessEntry_Internal_iisdll(csEntry,szTheSection,ParsedLine);
  7258. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7259. iFoundMatch = TRUE;
  7260. }
  7261. //
  7262. // 100= 0=DoINFSection queue file ops special
  7263. // 100= 5=DoSection
  7264. // 100= 6=DoINFSection
  7265. //
  7266. if ( _tcsicmp(ParsedLine.szType, _T("0")) == 0 || _tcsicmp(ParsedLine.szType, _T("5")) == 0 || _tcsicmp(ParsedLine.szType, _T("6")) == 0 )
  7267. {
  7268. iReturnTemp = ProcessEntry_Call_Section(csEntry,szTheSection,ParsedLine);
  7269. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7270. iFoundMatch = TRUE;
  7271. }
  7272. if (TRUE != iFoundMatch)
  7273. {
  7274. iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("ProcessEntry_Entry:ExecuteThing:Unknown Type:%1!s! FAILURE.\n"),ParsedLine.szType));
  7275. }
  7276. }
  7277. if (lpBuffer) {LocalFree(lpBuffer);lpBuffer=NULL;}
  7278. return iReturn;
  7279. }
  7280. int DoesThisSectionExist(IN HINF hFile, IN LPCTSTR szTheSection)
  7281. {
  7282. int iReturn = FALSE;
  7283. INFCONTEXT Context;
  7284. // go to the beginning of the section in the INF file
  7285. if (SetupFindFirstLine_Wrapped(hFile, szTheSection, NULL, &Context))
  7286. {iReturn = TRUE;}
  7287. return iReturn;
  7288. }
  7289. int GetSectionNameToDo(IN HINF hFile, CString & csTheSection)
  7290. {
  7291. iisDebugOut_Start1(_T("GetSectionNameToDo"),csTheSection);
  7292. int iReturn = FALSE;
  7293. // Check if this section has other sections which have something else appended to it.
  7294. //
  7295. // for example:
  7296. // csTheSection = iis_www_reg_CreateIISPackage
  7297. //
  7298. // could have:
  7299. // iis_www_reg_CreateIISPackage.UT_NONE
  7300. // iis_www_reg_CreateIISPackage.UT_351
  7301. // iis_www_reg_CreateIISPackage.UT_10
  7302. // iis_www_reg_CreateIISPackage.UT_20
  7303. // iis_www_reg_CreateIISPackage.UT_30
  7304. // iis_www_reg_CreateIISPackage.UT_40
  7305. // iis_www_reg_CreateIISPackage.UT_50
  7306. // iis_www_reg_CreateIISPackage.UT_51
  7307. // iis_www_reg_CreateIISPackage.UT_60
  7308. // iis_www_reg_CreateIISPackage.UT_10_W95.GUIMODE
  7309. //
  7310. // In That case, we only want to do the iis_www_reg_CreateIISPackage.UT_40
  7311. // and not do the iis_www_reg_CreateIISPackage one!
  7312. //
  7313. // Check for other upgrade specific sections...
  7314. // if we find one then do that, otherwise, just do the regular section...
  7315. TCHAR szTheSectionToDo[100];
  7316. TCHAR szTheUT[30];
  7317. _tcscpy(szTheUT,_T("UT_NONE"));
  7318. if (g_pTheApp->m_eUpgradeType == UT_351){_tcscpy(szTheUT,_T("UT_351"));}
  7319. if (g_pTheApp->m_eUpgradeType == UT_10){_tcscpy(szTheUT,_T("UT_10"));}
  7320. if (g_pTheApp->m_eUpgradeType == UT_20){_tcscpy(szTheUT,_T("UT_20"));}
  7321. if (g_pTheApp->m_eUpgradeType == UT_30){_tcscpy(szTheUT,_T("UT_30"));}
  7322. if (g_pTheApp->m_eUpgradeType == UT_40){_tcscpy(szTheUT,_T("UT_40"));}
  7323. if (g_pTheApp->m_eUpgradeType == UT_50){_tcscpy(szTheUT,_T("UT_50"));}
  7324. if (g_pTheApp->m_eUpgradeType == UT_51){_tcscpy(szTheUT,_T("UT_51"));}
  7325. if (g_pTheApp->m_eUpgradeType == UT_60){_tcscpy(szTheUT,_T("UT_60"));}
  7326. if (g_pTheApp->m_eUpgradeType == UT_10_W95){_tcscpy(szTheUT,_T("UT_10_W95"));}
  7327. BOOL bSectionFound = FALSE;
  7328. // If this is an upgrade from win95 then tack that one on...
  7329. if (g_pTheApp->m_bWin95Migration)
  7330. {
  7331. // Check for guimode of this...
  7332. if (g_pTheApp->m_fNTGuiMode)
  7333. {
  7334. _stprintf(szTheSectionToDo,TEXT("%s.%s.MIG95.GUIMODE"),csTheSection,szTheUT);
  7335. if (TRUE == DoesThisSectionExist(hFile, szTheSectionToDo)) {bSectionFound = TRUE;}
  7336. }
  7337. if (bSectionFound == FALSE)
  7338. {
  7339. _stprintf(szTheSectionToDo,TEXT("%s.%s.MIG95"),csTheSection,szTheUT);
  7340. if (TRUE == DoesThisSectionExist(hFile, szTheSectionToDo)) {bSectionFound = TRUE;}
  7341. }
  7342. }
  7343. // check with out the extract mig95 thingy
  7344. if (bSectionFound == FALSE)
  7345. {
  7346. if (g_pTheApp->m_fNTGuiMode)
  7347. {
  7348. _stprintf(szTheSectionToDo,TEXT("%s.%s.GUIMODE"),csTheSection,szTheUT);
  7349. if (TRUE == DoesThisSectionExist(hFile, szTheSectionToDo)) {bSectionFound = TRUE;}
  7350. }
  7351. if (bSectionFound == FALSE)
  7352. {
  7353. _stprintf(szTheSectionToDo,TEXT("%s.%s"),csTheSection,szTheUT);
  7354. if (TRUE == DoesThisSectionExist(hFile, szTheSectionToDo)) {bSectionFound = TRUE;}
  7355. }
  7356. }
  7357. // if we didn't find a specific section, then see if this is an upgrade
  7358. // and if there is upgrade type box.
  7359. if (bSectionFound == FALSE)
  7360. {
  7361. if (_tcsicmp(szTheUT, _T("UT_NONE")) != 0)
  7362. {
  7363. if (TRUE == g_pTheApp->m_bUpgradeTypeHasMetabaseFlag)
  7364. {
  7365. if (g_pTheApp->m_fNTGuiMode)
  7366. {
  7367. _stprintf(szTheSectionToDo,TEXT("%s.UT_ANYMETABASEUPGRADE.GUIMODE"),csTheSection);
  7368. if (TRUE == DoesThisSectionExist(hFile, szTheSectionToDo)) {bSectionFound = TRUE;}
  7369. }
  7370. if (bSectionFound == FALSE)
  7371. {
  7372. _stprintf(szTheSectionToDo,TEXT("%s.UT_ANYMETABASEUPGRADE"),csTheSection);
  7373. if (TRUE == DoesThisSectionExist(hFile, szTheSectionToDo)) {bSectionFound = TRUE;}
  7374. }
  7375. }
  7376. if (bSectionFound == FALSE)
  7377. {
  7378. if (g_pTheApp->m_fNTGuiMode)
  7379. {
  7380. _stprintf(szTheSectionToDo,TEXT("%s.UT_ANYUPGRADE.GUIMODE"),csTheSection);
  7381. if (TRUE == DoesThisSectionExist(hFile, szTheSectionToDo)) {bSectionFound = TRUE;}
  7382. }
  7383. if (bSectionFound == FALSE)
  7384. {
  7385. _stprintf(szTheSectionToDo,TEXT("%s.UT_ANYUPGRADE"),csTheSection);
  7386. if (TRUE == DoesThisSectionExist(hFile, szTheSectionToDo)) {bSectionFound = TRUE;}
  7387. }
  7388. }
  7389. }
  7390. }
  7391. // if we didn't find a specific section, then turn the regular one.
  7392. if (bSectionFound == FALSE)
  7393. {
  7394. if (g_pTheApp->m_fNTGuiMode)
  7395. {
  7396. _stprintf(szTheSectionToDo,TEXT("%s.GUIMODE"),csTheSection);
  7397. if (TRUE == DoesThisSectionExist(hFile, szTheSectionToDo)) {bSectionFound = TRUE;}
  7398. }
  7399. if (bSectionFound == FALSE)
  7400. {
  7401. _tcscpy(szTheSectionToDo,csTheSection);
  7402. if (TRUE == DoesThisSectionExist(hFile, szTheSectionToDo)) {bSectionFound = TRUE;}
  7403. }
  7404. }
  7405. if (bSectionFound == FALSE)
  7406. {
  7407. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("GetSectionNameToDo.[%s].Section not found.\n"), csTheSection));
  7408. iReturn = FALSE;
  7409. }
  7410. else
  7411. {
  7412. iReturn = TRUE;
  7413. csTheSection = szTheSectionToDo;
  7414. }
  7415. iisDebugOut_End1(_T("GetSectionNameToDo"),csTheSection);
  7416. return iReturn;
  7417. }
  7418. int ProcessSection(IN HINF hFile, IN LPCTSTR szTheSection)
  7419. {
  7420. int iReturn = FALSE;
  7421. CStringList strList;
  7422. CString csTheSection;
  7423. csTheSection = szTheSection;
  7424. if (GetSectionNameToDo(hFile, csTheSection))
  7425. {
  7426. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("ProcessSection.[%s].Start.\n"), csTheSection));
  7427. if (ERROR_SUCCESS == FillStrListWithListOfSections(hFile, strList, csTheSection))
  7428. {
  7429. // loop thru the list returned back
  7430. if (strList.IsEmpty() == FALSE)
  7431. {
  7432. POSITION pos = NULL;
  7433. CString csEntry;
  7434. pos = strList.GetHeadPosition();
  7435. while (pos)
  7436. {
  7437. csEntry = strList.GetAt(pos);
  7438. iReturn = ProcessEntry_Entry(hFile, csTheSection, csEntry);
  7439. strList.GetNext(pos);
  7440. }
  7441. }
  7442. }
  7443. iisDebugOut_End1(_T("ProcessSection"),csTheSection);
  7444. iReturn = TRUE;
  7445. }
  7446. return iReturn;
  7447. }
  7448. int iOleInitialize(void)
  7449. {
  7450. int iBalanceOLE = FALSE;
  7451. HRESULT hInitRes = NULL;
  7452. iisDebugOut_Start((_T("ole32:OleInitialize")));
  7453. hInitRes = OleInitialize(NULL);
  7454. iisDebugOut_End((_T("ole32:OleInitialize")));
  7455. if ( SUCCEEDED(hInitRes) || hInitRes == RPC_E_CHANGED_MODE )
  7456. {
  7457. if ( SUCCEEDED(hInitRes))
  7458. {
  7459. iisDebugOut((LOG_TYPE_TRACE, _T("iOleInitialize: Succeeded: %x. MakeSure to call OleUninitialize.\n"), hInitRes));
  7460. iBalanceOLE = TRUE;
  7461. }
  7462. else
  7463. {
  7464. iisDebugOut((LOG_TYPE_ERROR, _T("iOleInitialize: Failed 0x%x. RPC_E_CHANGED_MODE\n"), hInitRes));
  7465. }
  7466. }
  7467. else
  7468. {iisDebugOut((LOG_TYPE_ERROR, _T("iOleInitialize: Failed 0x%x.\n"), hInitRes));}
  7469. return iBalanceOLE;
  7470. }
  7471. void iOleUnInitialize(int iBalanceOLE)
  7472. {
  7473. // ----------------------------------------------
  7474. //
  7475. // uninit ole if we need to
  7476. //
  7477. // ----------------------------------------------
  7478. if (iBalanceOLE)
  7479. {
  7480. iisDebugOut_Start(_T("ole32:OleInitialize"),LOG_TYPE_TRACE_WIN32_API);
  7481. OleUninitialize();
  7482. iisDebugOut_End(_T("ole32:OleInitialize"),LOG_TYPE_TRACE_WIN32_API);
  7483. }
  7484. return;
  7485. }
  7486. BOOL SetupSetDirectoryId_Wrapper(HINF InfHandle,DWORD Id,LPCTSTR Directory)
  7487. {
  7488. TCHAR szTempDir[_MAX_PATH];
  7489. BOOL bTempFlag;
  7490. // default it with something
  7491. _tcscpy(szTempDir,Directory);
  7492. if (_tcscmp(szTempDir, _T("")) != 0)
  7493. {
  7494. // Check if the passed in parameter looks like this:
  7495. // %systemroot%\system32\inetsrv or something like that...
  7496. LPTSTR pch = NULL;
  7497. pch = _tcschr( (LPTSTR) Directory, _T('%'));
  7498. if (pch)
  7499. {
  7500. if (!ExpandEnvironmentStrings( (LPCTSTR)Directory, szTempDir, sizeof(szTempDir)/sizeof(TCHAR)))
  7501. {_tcscpy(szTempDir,Directory);}
  7502. }
  7503. // Check to see if the old Drive still exists -- it may not because
  7504. // the user could have added/removed a drive so now c:\winnt is really d:\winnt
  7505. if (!IsFileExist(Directory))
  7506. {
  7507. TCHAR szDrive_only[_MAX_DRIVE];
  7508. TCHAR szPath_only[_MAX_PATH];
  7509. _tsplitpath( Directory, szDrive_only, szPath_only, NULL, NULL);
  7510. // See if that drive exists...
  7511. if (!IsFileExist(szDrive_only))
  7512. {
  7513. // the drive doesn't exist.
  7514. // so replace it with the system drive.
  7515. GetSystemDirectory(szTempDir, _MAX_PATH);
  7516. // Get the DriveOnly
  7517. _tsplitpath(szTempDir, szDrive_only, NULL, NULL, NULL);
  7518. // Assemble the full path with the new drive
  7519. _tcscpy(szTempDir, szDrive_only);
  7520. _tcscat(szTempDir, szPath_only);
  7521. // do some extra debug output so we can see what happend.
  7522. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("%1!s! Not exist. Instead use %2!s!\n"), Directory, szTempDir));
  7523. }
  7524. }
  7525. }
  7526. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("%1!d!=%2!s!\n"), Id, szTempDir));
  7527. bTempFlag = SetupSetDirectoryId(InfHandle,Id,szTempDir);
  7528. // check for the alternate .inf file
  7529. if (g_pTheApp->m_hInfHandleAlternate && InfHandle != g_pTheApp->m_hInfHandleAlternate)
  7530. {
  7531. bTempFlag = SetupSetDirectoryId(g_pTheApp->m_hInfHandleAlternate,Id,szTempDir);
  7532. }
  7533. return bTempFlag;
  7534. }
  7535. BOOL SetupSetStringId_Wrapper(HINF InfHandle,DWORD Id,LPCTSTR TheString)
  7536. {
  7537. BOOL bTempFlag;
  7538. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("%1!d!=%2!s!\n"), Id, TheString));
  7539. bTempFlag = SetupSetDirectoryIdEx(InfHandle,Id,TheString,SETDIRID_NOT_FULL_PATH,0,0);
  7540. // check for the alternate .inf file
  7541. if (g_pTheApp->m_hInfHandleAlternate && InfHandle != g_pTheApp->m_hInfHandleAlternate)
  7542. {
  7543. bTempFlag = SetupSetDirectoryIdEx(g_pTheApp->m_hInfHandleAlternate,Id,TheString,SETDIRID_NOT_FULL_PATH,0,0);
  7544. }
  7545. return bTempFlag;
  7546. }
  7547. //-------------------------------------------------------------------------------------
  7548. HRESULT FTestForOutstandingCoInits(void)
  7549. {
  7550. HRESULT hInitRes = ERROR_SUCCESS;
  7551. #if defined(UNICODE) || defined(_UNICODE)
  7552. // perform a defensive check
  7553. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("TestForOutstandingCoInits:...COINIT_MULTITHREADED\n")));
  7554. hInitRes = CoInitializeEx( NULL, COINIT_MULTITHREADED );
  7555. if ( SUCCEEDED(hInitRes) )
  7556. {
  7557. //iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ole32:CoUninitialize().Start.")));
  7558. CoUninitialize();
  7559. //iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ole32:CoUninitialize().End.")));
  7560. }
  7561. else
  7562. {
  7563. goto FTestForOutstandingCoInits_Exit;
  7564. }
  7565. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("TestForOutstandingCoInits:...COINIT_APARTMENTTHREADED\n")));
  7566. hInitRes = CoInitializeEx( NULL, COINIT_APARTMENTTHREADED );
  7567. if ( SUCCEEDED(hInitRes) )
  7568. {
  7569. //iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ole32:CoUninitialize().Start.")));
  7570. CoUninitialize();
  7571. //iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ole32:CoUninitialize().End.")));
  7572. }
  7573. else
  7574. {
  7575. goto FTestForOutstandingCoInits_Exit;
  7576. }
  7577. #endif
  7578. // it worked out OK
  7579. hInitRes = NOERROR;
  7580. goto FTestForOutstandingCoInits_Exit;
  7581. FTestForOutstandingCoInits_Exit:
  7582. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("TestForOutstandingCoInits:...End. Return=0x%x.\n"), hInitRes));
  7583. return hInitRes;
  7584. }
  7585. void ReturnStringForMetabaseID(DWORD dwMetabaseID, LPTSTR lpReturnString)
  7586. {
  7587. switch (dwMetabaseID)
  7588. {
  7589. case IIS_MD_SERVER_BASE:
  7590. _tcscpy(lpReturnString, _T("IIS_MD_SERVER_BASE"));
  7591. break;
  7592. case MD_KEY_TYPE:
  7593. _tcscpy(lpReturnString, _T("MD_KEY_TYPE"));
  7594. break;
  7595. case MD_MAX_BANDWIDTH_BLOCKED:
  7596. _tcscpy(lpReturnString, _T("MD_MAX_BANDWIDTH_BLOCKED"));
  7597. break;
  7598. case MD_SERVER_COMMAND:
  7599. _tcscpy(lpReturnString, _T("MD_SERVER_COMMAND"));
  7600. break;
  7601. case MD_CONNECTION_TIMEOUT:
  7602. _tcscpy(lpReturnString, _T("MD_CONNECTION_TIMEOUT"));
  7603. break;
  7604. case MD_MAX_CONNECTIONS:
  7605. _tcscpy(lpReturnString, _T("MD_MAX_CONNECTIONS"));
  7606. break;
  7607. case MD_SERVER_COMMENT:
  7608. _tcscpy(lpReturnString, _T("MD_SERVER_COMMENT"));
  7609. break;
  7610. case MD_SERVER_STATE:
  7611. _tcscpy(lpReturnString, _T("MD_SERVER_STATE"));
  7612. break;
  7613. case MD_SERVER_AUTOSTART:
  7614. _tcscpy(lpReturnString, _T("MD_SERVER_AUTOSTART"));
  7615. break;
  7616. case MD_SERVER_SIZE:
  7617. _tcscpy(lpReturnString, _T("MD_SERVER_SIZE"));
  7618. break;
  7619. case MD_SERVER_LISTEN_BACKLOG:
  7620. _tcscpy(lpReturnString, _T("MD_SERVER_LISTEN_BACKLOG"));
  7621. break;
  7622. case MD_SERVER_LISTEN_TIMEOUT:
  7623. _tcscpy(lpReturnString, _T("MD_SERVER_LISTEN_TIMEOUT"));
  7624. break;
  7625. case MD_DOWNLEVEL_ADMIN_INSTANCE:
  7626. _tcscpy(lpReturnString, _T("MD_DOWNLEVEL_ADMIN_INSTANCE"));
  7627. break;
  7628. case MD_LEVELS_TO_SCAN:
  7629. _tcscpy(lpReturnString, _T("MD_LEVELS_TO_SCAN"));
  7630. break;
  7631. case MD_SERVER_BINDINGS:
  7632. _tcscpy(lpReturnString, _T("MD_SERVER_BINDINGS"));
  7633. break;
  7634. case MD_MAX_ENDPOINT_CONNECTIONS:
  7635. _tcscpy(lpReturnString, _T("MD_MAX_ENDPOINT_CONNECTIONS"));
  7636. break;
  7637. case MD_SERVER_CONFIGURATION_INFO:
  7638. _tcscpy(lpReturnString, _T("MD_SERVER_CONFIGURATION_INFO"));
  7639. break;
  7640. case MD_IISADMIN_EXTENSIONS:
  7641. _tcscpy(lpReturnString, _T("MD_IISADMIN_EXTENSIONS"));
  7642. break;
  7643. case IIS_MD_HTTP_BASE:
  7644. _tcscpy(lpReturnString, _T("IIS_MD_HTTP_BASE"));
  7645. break;
  7646. case MD_SECURE_BINDINGS:
  7647. _tcscpy(lpReturnString, _T("MD_SECURE_BINDINGS"));
  7648. break;
  7649. case MD_FILTER_LOAD_ORDER:
  7650. _tcscpy(lpReturnString, _T("MD_FILTER_LOAD_ORDER"));
  7651. break;
  7652. case MD_FILTER_IMAGE_PATH:
  7653. _tcscpy(lpReturnString, _T("MD_FILTER_IMAGE_PATH"));
  7654. break;
  7655. case MD_FILTER_STATE:
  7656. _tcscpy(lpReturnString, _T("MD_FILTER_STATE"));
  7657. break;
  7658. case MD_FILTER_ENABLED:
  7659. _tcscpy(lpReturnString, _T("MD_FILTER_ENABLED"));
  7660. break;
  7661. case MD_FILTER_FLAGS:
  7662. _tcscpy(lpReturnString, _T("MD_FILTER_FLAGS"));
  7663. break;
  7664. case MD_FILTER_DESCRIPTION:
  7665. _tcscpy(lpReturnString, _T("MD_FILTER_DESCRIPTION"));
  7666. break;
  7667. case MD_ADV_NOTIFY_PWD_EXP_IN_DAYS:
  7668. _tcscpy(lpReturnString, _T("MD_ADV_NOTIFY_PWD_EXP_IN_DAYS"));
  7669. break;
  7670. case MD_ADV_CACHE_TTL:
  7671. _tcscpy(lpReturnString, _T("MD_ADV_CACHE_TTL"));
  7672. break;
  7673. case MD_NET_LOGON_WKS:
  7674. _tcscpy(lpReturnString, _T("MD_NET_LOGON_WKS"));
  7675. break;
  7676. case MD_USE_HOST_NAME:
  7677. _tcscpy(lpReturnString, _T("MD_USE_HOST_NAME"));
  7678. break;
  7679. case MD_AUTH_CHANGE_FLAGS:
  7680. _tcscpy(lpReturnString, _T("MD_AUTH_CHANGE_FLAGS"));
  7681. break;
  7682. case MD_PROCESS_NTCR_IF_LOGGED_ON:
  7683. _tcscpy(lpReturnString, _T("MD_PROCESS_NTCR_IF_LOGGED_ON"));
  7684. break;
  7685. case MD_FRONTPAGE_WEB:
  7686. _tcscpy(lpReturnString, _T("MD_FRONTPAGE_WEB"));
  7687. break;
  7688. case MD_IN_PROCESS_ISAPI_APPS:
  7689. _tcscpy(lpReturnString, _T("MD_IN_PROCESS_ISAPI_APPS"));
  7690. break;
  7691. case MD_ALLOW_PATH_INFO_FOR_SCRIPT_MAPPINGS:
  7692. _tcscpy(lpReturnString, _T("MD_ALLOW_PATH_INFO_FOR_SCRIPT_MAPPINGS"));
  7693. break;
  7694. case MD_APP_FRIENDLY_NAME:
  7695. _tcscpy(lpReturnString, _T("MD_APP_FRIENDLY_NAME"));
  7696. break;
  7697. case MD_APP_ROOT:
  7698. _tcscpy(lpReturnString, _T("MD_APP_ROOT"));
  7699. break;
  7700. case MD_APP_ISOLATED:
  7701. _tcscpy(lpReturnString, _T("MD_APP_ISOLATED"));
  7702. break;
  7703. case MD_APP_WAM_CLSID:
  7704. _tcscpy(lpReturnString, _T("MD_APP_WAM_CLSID"));
  7705. break;
  7706. case MD_APP_PACKAGE_ID:
  7707. _tcscpy(lpReturnString, _T("MD_APP_PACKAGE_ID"));
  7708. break;
  7709. case MD_APP_PACKAGE_NAME:
  7710. _tcscpy(lpReturnString, _T("MD_APP_PACKAGE_NAME"));
  7711. break;
  7712. case MD_APP_OOP_RECOVER_LIMIT:
  7713. _tcscpy(lpReturnString, _T("MD_APP_OOP_RECOVER_LIMIT"));
  7714. break;
  7715. case MD_ADMIN_INSTANCE:
  7716. _tcscpy(lpReturnString, _T("MD_ADMIN_INSTANCE"));
  7717. break;
  7718. case MD_NOT_DELETABLE:
  7719. _tcscpy(lpReturnString, _T("MD_NOT_DELETABLE"));
  7720. break;
  7721. case MD_CUSTOM_ERROR_DESC:
  7722. _tcscpy(lpReturnString, _T("MD_CUSTOM_ERROR_DESC"));
  7723. break;
  7724. case MD_CAL_VC_PER_CONNECT:
  7725. _tcscpy(lpReturnString, _T("MD_CAL_VC_PER_CONNECT"));
  7726. break;
  7727. case MD_CAL_AUTH_RESERVE_TIMEOUT:
  7728. _tcscpy(lpReturnString, _T("MD_CAL_AUTH_RESERVE_TIMEOUT"));
  7729. break;
  7730. case MD_CAL_SSL_RESERVE_TIMEOUT:
  7731. _tcscpy(lpReturnString, _T("MD_CAL_SSL_RESERVE_TIMEOUT"));
  7732. break;
  7733. case MD_CAL_W3_ERROR:
  7734. _tcscpy(lpReturnString, _T("MD_CAL_W3_ERROR"));
  7735. break;
  7736. case MD_CPU_CGI_ENABLED:
  7737. _tcscpy(lpReturnString, _T("MD_CPU_CGI_ENABLED"));
  7738. break;
  7739. case MD_CPU_APP_ENABLED:
  7740. _tcscpy(lpReturnString, _T("MD_CPU_APP_ENABLED"));
  7741. break;
  7742. case MD_CPU_LIMITS_ENABLED:
  7743. _tcscpy(lpReturnString, _T("MD_CPU_LIMITS_ENABLED"));
  7744. break;
  7745. case MD_CPU_RESET_INTERVAL:
  7746. _tcscpy(lpReturnString, _T("MD_CPU_RESET_INTERVAL"));
  7747. break;
  7748. case MD_CPU_LOGGING_INTERVAL:
  7749. _tcscpy(lpReturnString, _T("MD_CPU_LOGGING_INTERVAL"));
  7750. break;
  7751. case MD_CPU_LOGGING_OPTIONS:
  7752. _tcscpy(lpReturnString, _T("MD_CPU_LOGGING_OPTIONS"));
  7753. break;
  7754. case MD_CPU_CGI_LIMIT:
  7755. _tcscpy(lpReturnString, _T("MD_CPU_CGI_LIMIT"));
  7756. break;
  7757. case MD_CPU_LIMIT_LOGEVENT:
  7758. _tcscpy(lpReturnString, _T("MD_CPU_LIMIT_LOGEVENT"));
  7759. break;
  7760. case MD_CPU_LIMIT_PRIORITY:
  7761. _tcscpy(lpReturnString, _T("MD_CPU_LIMIT_PRIORITY"));
  7762. break;
  7763. case MD_CPU_LIMIT_PROCSTOP:
  7764. _tcscpy(lpReturnString, _T("MD_CPU_LIMIT_PROCSTOP"));
  7765. break;
  7766. case MD_CPU_LIMIT_PAUSE:
  7767. _tcscpy(lpReturnString, _T("MD_CPU_LIMIT_PAUSE"));
  7768. break;
  7769. case MD_MD_SERVER_SS_AUTH_MAPPING:
  7770. _tcscpy(lpReturnString, _T("MD_MD_SERVER_SS_AUTH_MAPPING"));
  7771. break;
  7772. case MD_HC_COMPRESSION_DIRECTORY:
  7773. _tcscpy(lpReturnString, _T("MD_HC_COMPRESSION_DIRECTORY"));
  7774. break;
  7775. case MD_HC_CACHE_CONTROL_HEADER:
  7776. _tcscpy(lpReturnString, _T("MD_HC_CACHE_CONTROL_HEADER"));
  7777. break;
  7778. case MD_HC_EXPIRES_HEADER:
  7779. _tcscpy(lpReturnString, _T("MD_HC_EXPIRES_HEADER"));
  7780. break;
  7781. case MD_HC_DO_DYNAMIC_COMPRESSION:
  7782. _tcscpy(lpReturnString, _T("MD_HC_DO_DYNAMIC_COMPRESSION"));
  7783. break;
  7784. case MD_HC_DO_STATIC_COMPRESSION:
  7785. _tcscpy(lpReturnString, _T("MD_HC_DO_STATIC_COMPRESSION"));
  7786. break;
  7787. case MD_HC_DO_ON_DEMAND_COMPRESSION:
  7788. _tcscpy(lpReturnString, _T("MD_HC_DO_ON_DEMAND_COMPRESSION"));
  7789. break;
  7790. case MD_HC_DO_DISK_SPACE_LIMITING:
  7791. _tcscpy(lpReturnString, _T("MD_HC_DO_DISK_SPACE_LIMITING"));
  7792. break;
  7793. case MD_HC_NO_COMPRESSION_FOR_HTTP_10:
  7794. _tcscpy(lpReturnString, _T("MD_HC_NO_COMPRESSION_FOR_HTTP_10"));
  7795. break;
  7796. case MD_HC_NO_COMPRESSION_FOR_PROXIES:
  7797. _tcscpy(lpReturnString, _T("MD_HC_NO_COMPRESSION_FOR_PROXIES"));
  7798. break;
  7799. case MD_HC_NO_COMPRESSION_FOR_RANGE:
  7800. _tcscpy(lpReturnString, _T("MD_HC_NO_COMPRESSION_FOR_RANGE"));
  7801. break;
  7802. case MD_HC_SEND_CACHE_HEADERS:
  7803. _tcscpy(lpReturnString, _T("MD_HC_SEND_CACHE_HEADERS"));
  7804. break;
  7805. case MD_HC_MAX_DISK_SPACE_USAGE:
  7806. _tcscpy(lpReturnString, _T("MD_HC_MAX_DISK_SPACE_USAGE"));
  7807. break;
  7808. case MD_HC_IO_BUFFER_SIZE:
  7809. _tcscpy(lpReturnString, _T("MD_HC_IO_BUFFER_SIZE"));
  7810. break;
  7811. case MD_HC_COMPRESSION_BUFFER_SIZE:
  7812. _tcscpy(lpReturnString, _T("MD_HC_COMPRESSION_BUFFER_SIZE"));
  7813. break;
  7814. case MD_HC_MAX_QUEUE_LENGTH:
  7815. _tcscpy(lpReturnString, _T("MD_HC_MAX_QUEUE_LENGTH"));
  7816. break;
  7817. case MD_HC_FILES_DELETED_PER_DISK_FREE:
  7818. _tcscpy(lpReturnString, _T("MD_HC_FILES_DELETED_PER_DISK_FREE"));
  7819. break;
  7820. case MD_HC_MIN_FILE_SIZE_FOR_COMP:
  7821. _tcscpy(lpReturnString, _T("MD_HC_MIN_FILE_SIZE_FOR_COMP"));
  7822. break;
  7823. case MD_HC_COMPRESSION_DLL:
  7824. _tcscpy(lpReturnString, _T("MD_HC_COMPRESSION_DLL"));
  7825. break;
  7826. case MD_HC_FILE_EXTENSIONS:
  7827. _tcscpy(lpReturnString, _T("MD_HC_FILE_EXTENSIONS"));
  7828. break;
  7829. case MD_HC_MIME_TYPE:
  7830. _tcscpy(lpReturnString, _T("MD_HC_MIME_TYPE"));
  7831. break;
  7832. case MD_HC_PRIORITY:
  7833. _tcscpy(lpReturnString, _T("MD_HC_PRIORITY"));
  7834. break;
  7835. case MD_HC_DYNAMIC_COMPRESSION_LEVEL:
  7836. _tcscpy(lpReturnString, _T("MD_HC_DYNAMIC_COMPRESSION_LEVEL"));
  7837. break;
  7838. case MD_HC_ON_DEMAND_COMP_LEVEL:
  7839. _tcscpy(lpReturnString, _T("MD_HC_ON_DEMAND_COMP_LEVEL"));
  7840. break;
  7841. case MD_HC_CREATE_FLAGS:
  7842. _tcscpy(lpReturnString, _T("MD_HC_CREATE_FLAGS"));
  7843. break;
  7844. case MD_WIN32_ERROR:
  7845. _tcscpy(lpReturnString, _T("MD_WIN32_ERROR"));
  7846. break;
  7847. case IIS_MD_VR_BASE:
  7848. _tcscpy(lpReturnString, _T("IIS_MD_VR_BASE"));
  7849. break;
  7850. case MD_VR_PATH:
  7851. _tcscpy(lpReturnString, _T("MD_VR_PATH"));
  7852. break;
  7853. case MD_VR_USERNAME:
  7854. _tcscpy(lpReturnString, _T("MD_VR_USERNAME"));
  7855. break;
  7856. case MD_VR_PASSWORD:
  7857. _tcscpy(lpReturnString, _T("MD_VR_PASSWORD"));
  7858. break;
  7859. case MD_VR_PASSTHROUGH:
  7860. _tcscpy(lpReturnString, _T("MD_VR_PASSTHROUGH"));
  7861. break;
  7862. case MD_LOG_TYPE:
  7863. _tcscpy(lpReturnString, _T("MD_LOG_TYPE"));
  7864. break;
  7865. case MD_LOGFILE_DIRECTORY:
  7866. _tcscpy(lpReturnString, _T("MD_LOGFILE_DIRECTORY"));
  7867. break;
  7868. case MD_LOG_UNUSED1:
  7869. _tcscpy(lpReturnString, _T("MD_LOG_UNUSED1"));
  7870. break;
  7871. case MD_LOGFILE_PERIOD:
  7872. _tcscpy(lpReturnString, _T("MD_LOGFILE_PERIOD"));
  7873. break;
  7874. case MD_LOGFILE_TRUNCATE_SIZE:
  7875. _tcscpy(lpReturnString, _T("MD_LOGFILE_TRUNCATE_SIZE"));
  7876. break;
  7877. case MD_LOG_PLUGIN_MOD_ID:
  7878. _tcscpy(lpReturnString, _T("MD_LOG_PLUGIN_MOD_ID"));
  7879. break;
  7880. case MD_LOG_PLUGIN_UI_ID:
  7881. _tcscpy(lpReturnString, _T("MD_LOG_PLUGIN_UI_ID"));
  7882. break;
  7883. case MD_LOGSQL_DATA_SOURCES:
  7884. _tcscpy(lpReturnString, _T("MD_LOGSQL_DATA_SOURCES"));
  7885. break;
  7886. case MD_LOGSQL_TABLE_NAME:
  7887. _tcscpy(lpReturnString, _T("MD_LOGSQL_TABLE_NAME"));
  7888. break;
  7889. case MD_LOGSQL_USER_NAME:
  7890. _tcscpy(lpReturnString, _T("MD_LOGSQL_USER_NAME"));
  7891. break;
  7892. case MD_LOGSQL_PASSWORD:
  7893. _tcscpy(lpReturnString, _T("MD_LOGSQL_PASSWORD"));
  7894. break;
  7895. case MD_LOG_PLUGIN_ORDER:
  7896. _tcscpy(lpReturnString, _T("MD_LOG_PLUGIN_ORDER"));
  7897. break;
  7898. case MD_LOG_PLUGINS_AVAILABLE:
  7899. _tcscpy(lpReturnString, _T("MD_LOG_PLUGINS_AVAILABLE"));
  7900. break;
  7901. case MD_LOGEXT_FIELD_MASK:
  7902. _tcscpy(lpReturnString, _T("MD_LOGEXT_FIELD_MASK"));
  7903. break;
  7904. case MD_LOGEXT_FIELD_MASK2:
  7905. _tcscpy(lpReturnString, _T("MD_LOGEXT_FIELD_MASK2"));
  7906. break;
  7907. case MD_LOGFILE_LOCALTIME_ROLLOVER:
  7908. _tcscpy(lpReturnString, _T("MD_LOGFILE_LOCALTIME_ROLLOVER"));
  7909. break;
  7910. case IIS_MD_LOGCUSTOM_BASE:
  7911. _tcscpy(lpReturnString, _T("IIS_MD_LOGCUSTOM_BASE"));
  7912. break;
  7913. case MD_LOGCUSTOM_PROPERTY_NAME:
  7914. _tcscpy(lpReturnString, _T("MD_LOGCUSTOM_PROPERTY_NAME"));
  7915. break;
  7916. case MD_LOGCUSTOM_PROPERTY_HEADER:
  7917. _tcscpy(lpReturnString, _T("MD_LOGCUSTOM_PROPERTY_HEADER"));
  7918. break;
  7919. case MD_LOGCUSTOM_PROPERTY_ID:
  7920. _tcscpy(lpReturnString, _T("MD_LOGCUSTOM_PROPERTY_ID"));
  7921. break;
  7922. case MD_LOGCUSTOM_PROPERTY_MASK:
  7923. _tcscpy(lpReturnString, _T("MD_LOGCUSTOM_PROPERTY_MASK"));
  7924. break;
  7925. case MD_LOGCUSTOM_PROPERTY_DATATYPE:
  7926. _tcscpy(lpReturnString, _T("MD_LOGCUSTOM_PROPERTY_DATATYPE"));
  7927. break;
  7928. case MD_LOGCUSTOM_SERVICES_STRING:
  7929. _tcscpy(lpReturnString, _T("MD_LOGCUSTOM_SERVICES_STRING"));
  7930. break;
  7931. case MD_CPU_LOGGING_MASK:
  7932. _tcscpy(lpReturnString, _T("MD_CPU_LOGGING_MASK"));
  7933. break;
  7934. case IIS_MD_FTP_BASE:
  7935. _tcscpy(lpReturnString, _T("IIS_MD_FTP_BASE"));
  7936. break;
  7937. case MD_EXIT_MESSAGE:
  7938. _tcscpy(lpReturnString, _T("MD_EXIT_MESSAGE"));
  7939. break;
  7940. case MD_GREETING_MESSAGE:
  7941. _tcscpy(lpReturnString, _T("MD_GREETING_MESSAGE"));
  7942. break;
  7943. case MD_MAX_CLIENTS_MESSAGE:
  7944. _tcscpy(lpReturnString, _T("MD_MAX_CLIENTS_MESSAGE"));
  7945. break;
  7946. case MD_MSDOS_DIR_OUTPUT:
  7947. _tcscpy(lpReturnString, _T("MD_MSDOS_DIR_OUTPUT"));
  7948. break;
  7949. case MD_ALLOW_ANONYMOUS:
  7950. _tcscpy(lpReturnString, _T("MD_ALLOW_ANONYMOUS"));
  7951. break;
  7952. case MD_ANONYMOUS_ONLY:
  7953. _tcscpy(lpReturnString, _T("MD_ANONYMOUS_ONLY"));
  7954. break;
  7955. case MD_LOG_ANONYMOUS:
  7956. _tcscpy(lpReturnString, _T("MD_LOG_ANONYMOUS"));
  7957. break;
  7958. case MD_LOG_NONANONYMOUS:
  7959. _tcscpy(lpReturnString, _T("MD_LOG_NONANONYMOUS"));
  7960. break;
  7961. case MD_ALLOW_REPLACE_ON_RENAME:
  7962. _tcscpy(lpReturnString, _T("MD_ALLOW_REPLACE_ON_RENAME"));
  7963. break;
  7964. case MD_SSL_PUBLIC_KEY:
  7965. _tcscpy(lpReturnString, _T("MD_SSL_PUBLIC_KEY"));
  7966. break;
  7967. case MD_SSL_PRIVATE_KEY:
  7968. _tcscpy(lpReturnString, _T("MD_SSL_PRIVATE_KEY"));
  7969. break;
  7970. case MD_SSL_KEY_PASSWORD:
  7971. _tcscpy(lpReturnString, _T("MD_SSL_KEY_PASSWORD"));
  7972. break;
  7973. case MD_SSL_KEY_REQUEST:
  7974. _tcscpy(lpReturnString, _T("MD_SSL_KEY_REQUEST"));
  7975. break;
  7976. case MD_AUTHORIZATION:
  7977. _tcscpy(lpReturnString, _T("MD_AUTHORIZATION"));
  7978. break;
  7979. case MD_REALM:
  7980. _tcscpy(lpReturnString, _T("MD_REALM"));
  7981. break;
  7982. case MD_HTTP_EXPIRES:
  7983. _tcscpy(lpReturnString, _T("MD_HTTP_EXPIRES"));
  7984. break;
  7985. case MD_HTTP_PICS:
  7986. _tcscpy(lpReturnString, _T("MD_HTTP_PICS"));
  7987. break;
  7988. case MD_HTTP_CUSTOM:
  7989. _tcscpy(lpReturnString, _T("MD_HTTP_CUSTOM"));
  7990. break;
  7991. case MD_DIRECTORY_BROWSING:
  7992. _tcscpy(lpReturnString, _T("MD_DIRECTORY_BROWSING"));
  7993. break;
  7994. case MD_DEFAULT_LOAD_FILE:
  7995. _tcscpy(lpReturnString, _T("MD_DEFAULT_LOAD_FILE"));
  7996. break;
  7997. case MD_CUSTOM_ERROR:
  7998. _tcscpy(lpReturnString, _T("MD_CUSTOM_ERROR"));
  7999. break;
  8000. case MD_FOOTER_DOCUMENT:
  8001. _tcscpy(lpReturnString, _T("MD_FOOTER_DOCUMENT"));
  8002. break;
  8003. case MD_FOOTER_ENABLED:
  8004. _tcscpy(lpReturnString, _T("MD_FOOTER_ENABLED"));
  8005. break;
  8006. case MD_HTTP_REDIRECT:
  8007. _tcscpy(lpReturnString, _T("MD_HTTP_REDIRECT"));
  8008. break;
  8009. case MD_DEFAULT_LOGON_DOMAIN:
  8010. _tcscpy(lpReturnString, _T("MD_DEFAULT_LOGON_DOMAIN"));
  8011. break;
  8012. case MD_LOGON_METHOD:
  8013. _tcscpy(lpReturnString, _T("MD_LOGON_METHOD"));
  8014. break;
  8015. case MD_SCRIPT_MAPS:
  8016. _tcscpy(lpReturnString, _T("MD_SCRIPT_MAPS"));
  8017. break;
  8018. case MD_MIME_MAP:
  8019. _tcscpy(lpReturnString, _T("MD_MIME_MAP"));
  8020. break;
  8021. case MD_ACCESS_PERM:
  8022. _tcscpy(lpReturnString, _T("MD_ACCESS_PERM"));
  8023. break;
  8024. case MD_IP_SEC:
  8025. _tcscpy(lpReturnString, _T("MD_IP_SEC"));
  8026. break;
  8027. case MD_ANONYMOUS_USER_NAME:
  8028. _tcscpy(lpReturnString, _T("MD_ANONYMOUS_USER_NAME"));
  8029. break;
  8030. case MD_ANONYMOUS_PWD:
  8031. _tcscpy(lpReturnString, _T("MD_ANONYMOUS_PWD"));
  8032. break;
  8033. case MD_ANONYMOUS_USE_SUBAUTH:
  8034. _tcscpy(lpReturnString, _T("MD_ANONYMOUS_USE_SUBAUTH"));
  8035. break;
  8036. case MD_DONT_LOG:
  8037. _tcscpy(lpReturnString, _T("MD_DONT_LOG"));
  8038. break;
  8039. case MD_ADMIN_ACL:
  8040. _tcscpy(lpReturnString, _T("MD_ADMIN_ACL"));
  8041. break;
  8042. case MD_SSI_EXEC_DISABLED:
  8043. _tcscpy(lpReturnString, _T("MD_SSI_EXEC_DISABLED"));
  8044. break;
  8045. case MD_DO_REVERSE_DNS:
  8046. _tcscpy(lpReturnString, _T("MD_DO_REVERSE_DNS"));
  8047. break;
  8048. case MD_SSL_ACCESS_PERM:
  8049. _tcscpy(lpReturnString, _T("MD_SSL_ACCESS_PERM"));
  8050. break;
  8051. case MD_AUTHORIZATION_PERSISTENCE:
  8052. _tcscpy(lpReturnString, _T("MD_AUTHORIZATION_PERSISTENCE"));
  8053. break;
  8054. case MD_NTAUTHENTICATION_PROVIDERS:
  8055. _tcscpy(lpReturnString, _T("MD_NTAUTHENTICATION_PROVIDERS"));
  8056. break;
  8057. case MD_SCRIPT_TIMEOUT:
  8058. _tcscpy(lpReturnString, _T("MD_SCRIPT_TIMEOUT"));
  8059. break;
  8060. case MD_CACHE_EXTENSIONS:
  8061. _tcscpy(lpReturnString, _T("MD_CACHE_EXTENSIONS"));
  8062. break;
  8063. case MD_CREATE_PROCESS_AS_USER:
  8064. _tcscpy(lpReturnString, _T("MD_CREATE_PROCESS_AS_USER"));
  8065. break;
  8066. case MD_CREATE_PROC_NEW_CONSOLE:
  8067. _tcscpy(lpReturnString, _T("MD_CREATE_PROC_NEW_CONSOLE"));
  8068. break;
  8069. case MD_POOL_IDC_TIMEOUT:
  8070. _tcscpy(lpReturnString, _T("MD_POOL_IDC_TIMEOUT"));
  8071. break;
  8072. case MD_ALLOW_KEEPALIVES:
  8073. _tcscpy(lpReturnString, _T("MD_ALLOW_KEEPALIVES"));
  8074. break;
  8075. case MD_IS_CONTENT_INDEXED:
  8076. _tcscpy(lpReturnString, _T("MD_IS_CONTENT_INDEXED"));
  8077. break;
  8078. case MD_CC_NO_CACHE:
  8079. _tcscpy(lpReturnString, _T("MD_CC_NO_CACHE"));
  8080. break;
  8081. case MD_CC_MAX_AGE:
  8082. _tcscpy(lpReturnString, _T("MD_CC_MAX_AGE"));
  8083. break;
  8084. case MD_CC_OTHER:
  8085. _tcscpy(lpReturnString, _T("MD_CC_OTHER"));
  8086. break;
  8087. case MD_REDIRECT_HEADERS:
  8088. _tcscpy(lpReturnString, _T("MD_REDIRECT_HEADERS"));
  8089. break;
  8090. case MD_UPLOAD_READAHEAD_SIZE:
  8091. _tcscpy(lpReturnString, _T("MD_UPLOAD_READAHEAD_SIZE"));
  8092. break;
  8093. case MD_PUT_READ_SIZE:
  8094. _tcscpy(lpReturnString, _T("MD_PUT_READ_SIZE"));
  8095. break;
  8096. case MD_WAM_USER_NAME:
  8097. _tcscpy(lpReturnString, _T("MD_WAM_USER_NAME"));
  8098. break;
  8099. case MD_WAM_PWD:
  8100. _tcscpy(lpReturnString, _T("MD_WAM_PWD"));
  8101. break;
  8102. case MD_SCHEMA_METAID:
  8103. _tcscpy(lpReturnString, _T("MD_SCHEMA_METAID"));
  8104. break;
  8105. case MD_DISABLE_SOCKET_POOLING:
  8106. _tcscpy(lpReturnString, _T("MD_DISABLE_SOCKET_POOLING"));
  8107. break;
  8108. case MD_METADATA_ID_REGISTRATION:
  8109. _tcscpy(lpReturnString, _T("MD_METADATA_ID_REGISTRATION"));
  8110. break;
  8111. case MD_CPU_ENABLE_LOGGING:
  8112. _tcscpy(lpReturnString, _T("MD_CPU_ENABLE_LOGGING"));
  8113. break;
  8114. case MD_HC_SCRIPT_FILE_EXTENSIONS:
  8115. _tcscpy(lpReturnString, _T("MD_HC_SCRIPT_FILE_EXTENSIONS"));
  8116. break;
  8117. case MD_SHOW_4_DIGIT_YEAR:
  8118. _tcscpy(lpReturnString, _T("MD_SHOW_4_DIGIT_YEAR"));
  8119. break;
  8120. case MD_SSL_USE_DS_MAPPER:
  8121. _tcscpy(lpReturnString, _T("MD_SSL_USE_DS_MAPPER"));
  8122. break;
  8123. case MD_FILTER_ENABLE_CACHE:
  8124. _tcscpy(lpReturnString, _T("MD_FILTER_ENABLE_CACHE"));
  8125. break;
  8126. case MD_USE_DIGEST_SSP:
  8127. _tcscpy(lpReturnString, _T("MD_USE_DIGEST_SSP"));
  8128. break;
  8129. case MD_APPPOOL_PERIODIC_RESTART_TIME:
  8130. _tcscpy(lpReturnString, _T("MD_APPPOOL_PERIODIC_RESTART_TIME"));
  8131. break;
  8132. case MD_APPPOOL_PERIODIC_RESTART_REQUEST_COUNT:
  8133. _tcscpy(lpReturnString, _T("MD_APPPOOL_PERIODIC_RESTART_REQUEST_COUNT"));
  8134. break;
  8135. case MD_APPPOOL_MAX_PROCESS_COUNT:
  8136. _tcscpy(lpReturnString, _T("MD_APPPOOL_MAX_PROCESS_COUNT"));
  8137. break;
  8138. case MD_APPPOOL_PINGING_ENABLED:
  8139. _tcscpy(lpReturnString, _T("MD_APPPOOL_PINGING_ENABLED"));
  8140. break;
  8141. case MD_APPPOOL_IDLE_TIMEOUT:
  8142. _tcscpy(lpReturnString, _T("MD_APPPOOL_IDLE_TIMEOUT"));
  8143. break;
  8144. case MD_APPPOOL_RAPID_FAIL_PROTECTION_ENABLED:
  8145. _tcscpy(lpReturnString, _T("MD_APPPOOL_RAPID_F_PROTECTION_ENABLED"));
  8146. break;
  8147. case MD_APPPOOL_SMP_AFFINITIZED:
  8148. _tcscpy(lpReturnString, _T("MD_APPPOOL_SMP_AFFINITIZED"));
  8149. break;
  8150. case MD_APPPOOL_SMP_AFFINITIZED_PROCESSOR_MASK:
  8151. _tcscpy(lpReturnString, _T("MD_APPPOOL_SMP_AFFINITIZED_PROCESSOR_MASK"));
  8152. break;
  8153. case MD_APPPOOL_ORPHAN_PROCESSES_FOR_DEBUGGING:
  8154. _tcscpy(lpReturnString, _T("MD_APPPOOL_ORPHAN_PROCESSES_FOR_DEBUGGING"));
  8155. break;
  8156. case MD_APPPOOL_RUN_AS_LOCALSYSTEM:
  8157. _tcscpy(lpReturnString, _T("MD_APPPOOL_RUN_AS_LOCALSYSTEM"));
  8158. break;
  8159. case MD_APPPOOL_STARTUP_TIMELIMIT:
  8160. _tcscpy(lpReturnString, _T("MD_APPPOOL_STARTUP_TIMELIMIT"));
  8161. break;
  8162. case MD_APPPOOL_SHUTDOWN_TIMELIMIT:
  8163. _tcscpy(lpReturnString, _T("MD_APPPOOL_SHUTDOWN_TIMELIMIT"));
  8164. break;
  8165. case MD_APPPOOL_PING_INTERVAL:
  8166. _tcscpy(lpReturnString, _T("MD_APPPOOL_PING_INTERVAL"));
  8167. break;
  8168. case MD_APPPOOL_PING_RESPONSE_TIMELIMIT:
  8169. _tcscpy(lpReturnString, _T("MD_APPPOOL_PING_RESPONSE_TIMELIMIT"));
  8170. break;
  8171. case MD_APPPOOL_DISALLOW_OVERLAPPING_ROTATION:
  8172. _tcscpy(lpReturnString, _T("MD_APPPOOL_DISALLOW_OVERLAPPING_ROTATION"));
  8173. break;
  8174. case MD_APPPOOL_ORPHAN_ACTION:
  8175. _tcscpy(lpReturnString, _T("MD_APPPOOL_ORPHAN_ACTION"));
  8176. break;
  8177. case MD_APPPOOL_UL_APPPOOL_QUEUE_LENGTH:
  8178. _tcscpy(lpReturnString, _T("MD_APPPOOL_UL_APPPOOL_QUEUE_LENGTH"));
  8179. break;
  8180. case MD_APPPOOL_DISALLOW_ROTATION_ON_CONFIG_CHANGE:
  8181. _tcscpy(lpReturnString, _T("MD_APPPOOL_DISALLOW_ROTATION_ON_CONFIG_CHANGE"));
  8182. break;
  8183. case MD_APPPOOL_FRIENDLY_NAME:
  8184. _tcscpy(lpReturnString, _T("MD_APPPOOL_FRIENDLY_NAME"));
  8185. break;
  8186. case MD_APPPOOL_PERIODIC_RESTART_SCHEDULE:
  8187. _tcscpy(lpReturnString, _T("MD_APPPOOL_PERIODIC_RESTART_SCHEDULE"));
  8188. break;
  8189. case MD_APPPOOL_IDENTITY_TYPE:
  8190. _tcscpy(lpReturnString, _T("MD_APPPOOL_IDENTITY_TYPE"));
  8191. break;
  8192. case MD_CPU_ACTION:
  8193. _tcscpy(lpReturnString, _T("MD_CPU_ACTION"));
  8194. break;
  8195. case MD_CPU_LIMIT:
  8196. _tcscpy(lpReturnString, _T("MD_CPU_LIMIT"));
  8197. break;
  8198. case MD_APPPOOL_PERIODIC_RESTART_MEMORY:
  8199. _tcscpy(lpReturnString, _T("MD_APPPOOL_PERIODIC_RESTART_MEMORY"));
  8200. break;
  8201. case MD_DISABLE_PUBLISHING:
  8202. _tcscpy(lpReturnString, _T("MD_DISABLE_PUBLISHING"));
  8203. break;
  8204. case MD_APP_APPPOOL_ID:
  8205. _tcscpy(lpReturnString, _T("MD_APP_APPPOOL_ID"));
  8206. break;
  8207. case MD_APP_ALLOW_TRANSIENT_REGISTRATION:
  8208. _tcscpy(lpReturnString, _T("MD_APP_ALLOW_TRANSIENT_REGISTRATION"));
  8209. break;
  8210. case MD_APP_AUTO_START:
  8211. _tcscpy(lpReturnString, _T("MD_APP_AUTO_START"));
  8212. break;
  8213. case MD_APPPOOL_PERIODIC_RESTART_CONNECTIONS:
  8214. _tcscpy(lpReturnString, _T("MD_APPPOOL_PERIODIC_RESTART_CONNECTIONS"));
  8215. break;
  8216. case MD_MAX_GLOBAL_BANDWIDTH:
  8217. _tcscpy(lpReturnString, _T("MD_MAX_GLOBAL_BANDWIDTH"));
  8218. break;
  8219. case MD_MAX_GLOBAL_CONNECTIONS:
  8220. _tcscpy(lpReturnString, _T("MD_MAX_GLOBAL_CONNECTIONS"));
  8221. break;
  8222. case MD_GLOBAL_STANDARD_APP_MODE_ENABLED:
  8223. _tcscpy(lpReturnString, _T("MD_GLOBAL_STANDARD_APP_MODE_ENABLED"));
  8224. break;
  8225. case MD_HEADER_WAIT_TIMEOUT:
  8226. _tcscpy(lpReturnString, _T("MD_HEADER_WAIT_TIMEOUT"));
  8227. break;
  8228. case MD_MIN_FILE_KB_SEC:
  8229. _tcscpy(lpReturnString, _T("MD_MIN_FILE_KB_SEC"));
  8230. break;
  8231. case MD_GLOBAL_LOG_IN_UTF_8:
  8232. _tcscpy(lpReturnString, _T("MD_GLOBAL_LOG_IN_UTF_8"));
  8233. break;
  8234. case MD_ASP_ENABLEPARENTPATHS:
  8235. _tcscpy(lpReturnString, _T("MD_ASP_ENABLEPARENTPATHS"));
  8236. break;
  8237. case ASP_MD_SERVER_BASE:
  8238. case MD_ASP_LOGERRORREQUESTS:
  8239. case MD_ASP_SCRIPTERRORSSENTTOBROWSER:
  8240. case MD_ASP_SCRIPTERRORMESSAGE:
  8241. case MD_ASP_SCRIPTFILECACHESIZE:
  8242. case MD_ASP_SCRIPTENGINECACHEMAX:
  8243. case MD_ASP_SCRIPTTIMEOUT:
  8244. case MD_ASP_SESSIONTIMEOUT:
  8245. case MD_ASP_MEMFREEFACTOR:
  8246. case MD_ASP_MINUSEDBLOCKS:
  8247. case MD_ASP_ALLOWSESSIONSTATE:
  8248. case MD_ASP_SCRIPTLANGUAGE:
  8249. case MD_ASP_QUEUETIMEOUT:
  8250. case MD_ASP_ALLOWOUTOFPROCCOMPONENTS:
  8251. case MD_ASP_EXCEPTIONCATCHENABLE:
  8252. case MD_ASP_CODEPAGE:
  8253. case MD_ASP_SCRIPTLANGUAGELIST:
  8254. case MD_ASP_ENABLESERVERDEBUG:
  8255. case MD_ASP_ENABLECLIENTDEBUG:
  8256. case MD_ASP_TRACKTHREADINGMODEL:
  8257. case MD_ASP_ENABLEASPHTMLFALLBACK:
  8258. case MD_ASP_ENABLECHUNKEDENCODING:
  8259. case MD_ASP_ENABLETYPELIBCACHE:
  8260. case MD_ASP_ERRORSTONTLOG:
  8261. case MD_ASP_PROCESSORTHREADMAX:
  8262. case MD_ASP_REQEUSTQUEUEMAX:
  8263. case MD_ASP_ENABLEAPPLICATIONRESTART:
  8264. case MD_ASP_QUEUECONNECTIONTESTTIME:
  8265. case MD_ASP_SESSIONMAX:
  8266. case MD_ASP_THREADGATEENABLED:
  8267. case MD_ASP_THREADGATETIMESLICE:
  8268. case MD_ASP_THREADGATESLEEPDELAY:
  8269. case MD_ASP_THREADGATESLEEPMAX:
  8270. case MD_ASP_THREADGATELOADLOW:
  8271. case MD_ASP_THREADGATELOADHIGH:
  8272. _tcscpy(lpReturnString, _T("MD_ASP_????"));
  8273. break;
  8274. case WAM_MD_SERVER_BASE:
  8275. _tcscpy(lpReturnString, _T("WAM_MD_SERVER_BASE"));
  8276. break;
  8277. default:
  8278. _stprintf(lpReturnString, _T("%d"), dwMetabaseID);
  8279. break;
  8280. }
  8281. return;
  8282. }
  8283. void SetErrorFlag(char *szFileName, int iLineNumber)
  8284. {
  8285. // set flag to say that there was an error!!!
  8286. g_pTheApp->m_bThereWereErrorsChkLogfile = TRUE;
  8287. return;
  8288. }
  8289. DWORD FillStrListWithListOfSections(IN HINF hFile, CStringList &strList, IN LPCTSTR szSection)
  8290. {
  8291. DWORD dwReturn = ERROR_SUCCESS;
  8292. LPTSTR szLine = NULL;
  8293. DWORD dwRequiredSize;
  8294. BOOL b = FALSE;
  8295. INFCONTEXT Context;
  8296. // go to the beginning of the section in the INF file
  8297. b = SetupFindFirstLine_Wrapped(hFile, szSection, NULL, &Context);
  8298. if (!b)
  8299. {
  8300. dwReturn = E_FAIL;
  8301. goto FillStrListWithListOfSections_Exit;
  8302. }
  8303. // loop through the items in the section.
  8304. while (b)
  8305. {
  8306. // get the size of the memory we need for this
  8307. b = SetupGetLineText(&Context, NULL, NULL, NULL, NULL, 0, &dwRequiredSize);
  8308. // prepare the buffer to receive the line
  8309. szLine = (LPTSTR)GlobalAlloc( GPTR, dwRequiredSize * sizeof(TCHAR) );
  8310. if ( !szLine )
  8311. {
  8312. iisDebugOut((LOG_TYPE_ERROR, _T("FillStrListWithListOfSections %s. Failed on GlobalAlloc.\n"), szSection));
  8313. goto FillStrListWithListOfSections_Exit;
  8314. }
  8315. // get the line from the inf file1
  8316. if (SetupGetLineText(&Context, NULL, NULL, NULL, szLine, dwRequiredSize, NULL) == FALSE)
  8317. {
  8318. iisDebugOut((LOG_TYPE_ERROR, _T("FillStrListWithListOfSections %s. Failed on SetupGetLineText.\n"), szSection));
  8319. goto FillStrListWithListOfSections_Exit;
  8320. }
  8321. // Add it to the list
  8322. strList.AddTail(szLine);
  8323. // find the next line in the section. If there is no next line it should return false
  8324. b = SetupFindNextLine(&Context, &Context);
  8325. // free the temporary buffer
  8326. GlobalFree( szLine );
  8327. szLine = NULL;
  8328. }
  8329. if (szLine) {GlobalFree(szLine);szLine=NULL;}
  8330. FillStrListWithListOfSections_Exit:
  8331. return dwReturn;
  8332. }
  8333. void DisplayStringForMetabaseID(DWORD dwMetabaseID)
  8334. {
  8335. TCHAR lpReturnString[50];
  8336. ReturnStringForMetabaseID(dwMetabaseID, lpReturnString);
  8337. iisDebugOut((LOG_TYPE_TRACE, _T("%d=%s\n"), dwMetabaseID, lpReturnString));
  8338. return;
  8339. }
  8340. DWORD WINAPI MessageBoxFreeThread_MTS(LPVOID p)
  8341. {
  8342. HRESULT nNetErr = (HRESULT) gTempMTSError.dwErrorCode;
  8343. TCHAR pMsg[_MAX_PATH] = _T("");
  8344. DWORD dwFormatReturn = 0;
  8345. dwFormatReturn = FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM,NULL, gTempMTSError.dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT),pMsg, _MAX_PATH, NULL);
  8346. if ( dwFormatReturn == 0)
  8347. {
  8348. if (nNetErr >= NERR_BASE)
  8349. {
  8350. HMODULE hDll = (HMODULE)LoadLibrary(_T("netmsg.dll"));
  8351. if (hDll)
  8352. {
  8353. dwFormatReturn = FormatMessage( FORMAT_MESSAGE_FROM_HMODULE,hDll, gTempMTSError.dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT),pMsg, _MAX_PATH, NULL);
  8354. FreeLibrary(hDll);
  8355. }
  8356. }
  8357. }
  8358. CString csErrorString;
  8359. MyLoadString(IDS_SETUP_ERRORS_ENCOUNTERED_MTS, csErrorString);
  8360. CString csErrArea;
  8361. MyLoadString(gTempMTSError.iMtsThingWeWereDoing, csErrArea);
  8362. CString csTitle;
  8363. MyLoadString(IDS_MTS_ERROR_TITLEBAR, csTitle);
  8364. CString csMsg;
  8365. csMsg.Format(csErrorString, csErrArea);
  8366. CString csErrMsg;
  8367. HandleSpecificErrors(gTempMTSError.dwErrorCode, dwFormatReturn, csMsg, pMsg, &csErrMsg);
  8368. MyMessageBox(NULL, csErrMsg, csTitle, MB_OK | MB_SETFOREGROUND);
  8369. return 0;
  8370. }
  8371. DWORD WINAPI MessageBoxFreeThread_IIS(PVOID p)
  8372. {
  8373. INT_PTR iStringID = (INT_PTR) p;
  8374. MyMessageBox(NULL, (UINT) iStringID, g_MyLogFile.m_szLogFileName_Full, MB_OK | MB_SETFOREGROUND);
  8375. return 0;
  8376. }
  8377. void MesssageBoxErrors_IIS(void)
  8378. {
  8379. if (g_pTheApp->m_bThereWereErrorsChkLogfile == TRUE)
  8380. {
  8381. int iSaveOld_AllowMessageBoxPopups = g_pTheApp->m_bAllowMessageBoxPopups;
  8382. g_pTheApp->m_bAllowMessageBoxPopups = TRUE;
  8383. DWORD id;
  8384. INT_PTR iStringID = IDS_SETUP_ERRORS_ENCOUNTERED;
  8385. // show the messagebox display from another thread, so that setup can continue!
  8386. HANDLE hProc = NULL;
  8387. hProc = CreateThread(NULL, 0, MessageBoxFreeThread_IIS, (PVOID) iStringID, 0, &id);
  8388. g_pTheApp->m_bAllowMessageBoxPopups = iSaveOld_AllowMessageBoxPopups;
  8389. CString csErrMsg;
  8390. TCHAR szErrorString[255];
  8391. MyLoadString(IDS_SETUP_ERRORS_ENCOUNTERED, csErrMsg);
  8392. _stprintf(szErrorString, csErrMsg, g_MyLogFile.m_szLogFileName_Full);
  8393. //LogSevInformation 0x00000000
  8394. //LogSevWarning 0x00000001
  8395. //LogSevError 0x00000002
  8396. //LogSevFatalError 0x00000003
  8397. //LogSevMaximum 0x00000004
  8398. // Write it to the setupapi log file!
  8399. SetupLogError(szErrorString, LogSevError);
  8400. }
  8401. return;
  8402. }
  8403. void MesssageBoxErrors_MTS(int iMtsThingWeWereDoing, DWORD dwErrorCode)
  8404. {
  8405. if (!g_pTheApp->m_bThereWereErrorsFromMTS)
  8406. {
  8407. DWORD id;
  8408. int iSaveOld_AllowMessageBoxPopups = g_pTheApp->m_bAllowMessageBoxPopups;
  8409. gTempMTSError.iMtsThingWeWereDoing = iMtsThingWeWereDoing;
  8410. gTempMTSError.dwErrorCode = dwErrorCode;
  8411. g_pTheApp->m_bAllowMessageBoxPopups = TRUE;
  8412. // show the messagebox display from another thread, so that setup can continue!
  8413. HANDLE hProc = NULL;
  8414. hProc = CreateThread(NULL, 0, MessageBoxFreeThread_MTS, 0, 0, &id);
  8415. g_pTheApp->m_bAllowMessageBoxPopups = iSaveOld_AllowMessageBoxPopups;
  8416. g_pTheApp->m_bThereWereErrorsFromMTS = TRUE;
  8417. }
  8418. return;
  8419. }
  8420. void PleaseKillOrStopTheseExeFromRunning(LPCTSTR szModuleWhichIsLocked, CStringList &strList)
  8421. {
  8422. if (strList.IsEmpty() == FALSE)
  8423. {
  8424. POSITION pos;
  8425. CString csExeName;
  8426. LPTSTR p;
  8427. int nLen = 0;
  8428. TCHAR szReturnedServiceName[_MAX_PATH];
  8429. pos = strList.GetHeadPosition();
  8430. while (pos)
  8431. {
  8432. csExeName = strList.GetAt(pos);
  8433. nLen = 0;
  8434. nLen = csExeName.GetLength();
  8435. if (nLen > 0)
  8436. {
  8437. //iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("%1!s! is locking %2!s! service and is locking %3!s!\n"),csExeName, szModuleWhichIsLocked));
  8438. if (TRUE == InetIsThisExeAService(csExeName, szReturnedServiceName))
  8439. {
  8440. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("%1!s! is the %2!s! service and is locking %3!s!. Let's stop that service.\n"),csExeName,szReturnedServiceName, szModuleWhichIsLocked));
  8441. // Check if it is the netlogon service, We no don't want to stop this service for sure!!!
  8442. /*
  8443. if (_tcsicmp(szReturnedServiceName, _T("NetLogon")) == 0)
  8444. {
  8445. // no we do not want to stop this service!!!
  8446. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("%1!s! is the %2!s! service and is locking %3!s!. This service should not be stopped.\n"),csExeName,szReturnedServiceName, szModuleWhichIsLocked));
  8447. break;
  8448. }
  8449. */
  8450. // Don't stop any services which are not win32 services
  8451. // Don't stop any system services...
  8452. if (TRUE == IsThisOnNotStopList(g_pTheApp->m_hInfHandle, szReturnedServiceName, TRUE))
  8453. {
  8454. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("%1!s! is the %2!s! service and is locking %3!s!. This service should not be stopped.\n"),csExeName,szReturnedServiceName, szModuleWhichIsLocked));
  8455. }
  8456. else
  8457. {
  8458. // add this service to the list of
  8459. // services we need to restart after setup is done!!
  8460. ServicesRestartList_Add(szReturnedServiceName);
  8461. // Check the list of services which we are sure we do not want to stop!
  8462. // net stop it
  8463. InetStopService(szReturnedServiceName);
  8464. }
  8465. // otherwise go on to the next .exe file
  8466. }
  8467. else
  8468. {
  8469. // This .exe file is not a Service....
  8470. // Should we kill it???????
  8471. if (TRUE == IsThisOnNotStopList(g_pTheApp->m_hInfHandle, csExeName, FALSE))
  8472. {
  8473. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("%1!s! is locking it. This process should not be killed\n"),csExeName));
  8474. }
  8475. else
  8476. {
  8477. // Check the list of .exe which we are sure we do not want to kill!
  8478. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("%1!s! is locking %2!s!. Let's kill that process.\n"),csExeName,szModuleWhichIsLocked));
  8479. KillProcess_Wrap(csExeName);
  8480. }
  8481. }
  8482. }
  8483. strList.GetNext(pos);
  8484. }
  8485. }
  8486. return;
  8487. }
  8488. void ShowIfModuleUsedForThisINFSection(IN HINF hFile, IN LPCTSTR szSection, int iUnlockThem)
  8489. {
  8490. LPTSTR szLine = NULL;
  8491. DWORD dwRequiredSize;
  8492. BOOL b = FALSE;
  8493. CString csFile;
  8494. DWORD dwMSVer, dwLSVer;
  8495. INFCONTEXT Context;
  8496. TCHAR buf[_MAX_PATH];
  8497. GetSystemDirectory( buf, _MAX_PATH);
  8498. // go to the beginning of the section in the INF file
  8499. b = SetupFindFirstLine_Wrapped(hFile, szSection, NULL, &Context);
  8500. if (!b)
  8501. {
  8502. goto ShowIfModuleUsedForThisINFSection_Exit;
  8503. }
  8504. // loop through the items in the section.
  8505. while (b)
  8506. {
  8507. // get the size of the memory we need for this
  8508. b = SetupGetLineText(&Context, NULL, NULL, NULL, NULL, 0, &dwRequiredSize);
  8509. // prepare the buffer to receive the line
  8510. szLine = (LPTSTR)GlobalAlloc( GPTR, dwRequiredSize * sizeof(TCHAR) );
  8511. if ( !szLine )
  8512. {
  8513. goto ShowIfModuleUsedForThisINFSection_Exit;
  8514. }
  8515. // get the line from the inf file1
  8516. if (SetupGetLineText(&Context, NULL, NULL, NULL, szLine, dwRequiredSize, NULL) == FALSE)
  8517. {
  8518. goto ShowIfModuleUsedForThisINFSection_Exit;
  8519. }
  8520. // Attach the path to the from of this...
  8521. // check in this directory:
  8522. // 1. winnt\system32
  8523. // --------------------------------------
  8524. // may look like this "iisrtl.dll,,4"
  8525. // so get rid of the ',,4'
  8526. LPTSTR pch = NULL;
  8527. pch = _tcschr(szLine, _T(','));
  8528. if (pch) {_tcscpy(pch, _T(" "));}
  8529. // Remove any trailing spaces.
  8530. StripLastBackSlash(szLine);
  8531. // Get the system dir
  8532. csFile = buf;
  8533. csFile = AddPath(csFile, szLine);
  8534. CStringList strList;
  8535. strList.RemoveAll();
  8536. LogProcessesUsingThisModule(csFile, strList);
  8537. // if we're supposed to unlock this file, then
  8538. // we'll try it.
  8539. if (iUnlockThem)
  8540. {
  8541. PleaseKillOrStopTheseExeFromRunning(csFile, strList);
  8542. }
  8543. // find the next line in the section. If there is no next line it should return false
  8544. b = SetupFindNextLine(&Context, &Context);
  8545. // free the temporary buffer
  8546. GlobalFree( szLine );
  8547. szLine = NULL;
  8548. }
  8549. // free some memory used for the task list
  8550. FreeTaskListMem();
  8551. UnInit_Lib_PSAPI();
  8552. if (szLine) {GlobalFree(szLine);szLine=NULL;}
  8553. ShowIfModuleUsedForThisINFSection_Exit:
  8554. return;
  8555. }
  8556. void ShowIfModuleUsedForGroupOfSections(IN HINF hFile, int iUnlockThem)
  8557. {
  8558. CStringList strList;
  8559. CString csTheSection = _T("VerifyFileSections_Lockable");
  8560. if (GetSectionNameToDo(hFile, csTheSection))
  8561. {
  8562. if (ERROR_SUCCESS == FillStrListWithListOfSections(hFile, strList, csTheSection))
  8563. {
  8564. // loop thru the list returned back
  8565. if (strList.IsEmpty() == FALSE)
  8566. {
  8567. POSITION pos;
  8568. CString csEntry;
  8569. pos = strList.GetHeadPosition();
  8570. while (pos)
  8571. {
  8572. csEntry = strList.GetAt(pos);
  8573. ShowIfModuleUsedForThisINFSection(hFile, csEntry, iUnlockThem);
  8574. strList.GetNext(pos);
  8575. }
  8576. }
  8577. }
  8578. }
  8579. return;
  8580. }
  8581. int ReadGlobalsFromInf(HINF InfHandle)
  8582. {
  8583. int iReturn = FALSE;
  8584. INFCONTEXT Context;
  8585. TCHAR szTempString[_MAX_PATH] = _T("");
  8586. //
  8587. // Set the m_csAppName
  8588. //
  8589. if (!SetupFindFirstLine_Wrapped(InfHandle, _T("SetupInfo"), _T("AppName"), &Context) )
  8590. {iisDebugOut((LOG_TYPE_ERROR, _T("SetupFindFirstLine_Wrapped(SetupInfo, AppName) FAILED")));}
  8591. if (!SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  8592. {iisDebugOut((LOG_TYPE_ERROR, _T("SetupGetStringField(SetupInfo, AppName) FAILED")));}
  8593. // Set the global.
  8594. g_pTheApp->m_csAppName = szTempString;
  8595. //
  8596. // Set the m_csIISGroupName
  8597. //
  8598. _tcscpy(szTempString, _T(""));
  8599. if (!SetupFindFirstLine_Wrapped(InfHandle, _T("SetupInfo"), _T("StartMenuGroupName"), &Context) )
  8600. {iisDebugOut((LOG_TYPE_ERROR, _T("SetupFindFirstLine_Wrapped(SetupInfo, StartMenuGroupName) FAILED")));}
  8601. if (!SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  8602. {iisDebugOut((LOG_TYPE_ERROR, _T("SetupGetStringField(SetupInfo, StartMenuGroupName) FAILED")));}
  8603. g_pTheApp->m_csIISGroupName = szTempString;
  8604. iReturn = TRUE;
  8605. //
  8606. // Get the value of one tick on the progressbar
  8607. //
  8608. g_GlobalTickValue = 1;
  8609. _tcscpy(szTempString, _T(""));
  8610. SetupFindFirstLine_Wrapped(InfHandle, _T("SetupInfo"), _T("OneTick"), &Context);
  8611. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  8612. {g_GlobalTickValue = _ttoi(szTempString);}
  8613. //
  8614. // See if we want to fake out setup when it's running in add\remove, to think it's actually guimode
  8615. //
  8616. g_GlobalGuiOverRide = 0;
  8617. _tcscpy(szTempString, _T(""));
  8618. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupInfo"), _T("GuiMode"), &Context))
  8619. {
  8620. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  8621. {g_GlobalGuiOverRide = _ttoi(szTempString);}
  8622. }
  8623. return iReturn;
  8624. }
  8625. int CheckIfPlatformMatchesInf(HINF InfHandle)
  8626. {
  8627. int iReturn = TRUE;
  8628. INFCONTEXT Context;
  8629. TCHAR szPlatform[_MAX_PATH] = _T("");
  8630. BOOL fPlatform = FALSE;
  8631. int nPlatform = IDS_INCORRECT_PLATFORM;
  8632. if (!SetupFindFirstLine_Wrapped(InfHandle, _T("SetupInfo"), _T("Platform"), &Context) )
  8633. {iisDebugOut((LOG_TYPE_ERROR, _T("SetupFindFirstLine_Wrapped(SetupInfo, Platform) FAILED")));}
  8634. SetupGetStringField(&Context, 1, szPlatform, _MAX_PATH, NULL);
  8635. // Check if .inf file is for NTS
  8636. if (_tcsicmp(szPlatform, _T("NTS")) == 0)
  8637. {
  8638. if (g_pTheApp->m_eOS == OS_NT && g_pTheApp->m_eNTOSType != OT_NTW)
  8639. {fPlatform = TRUE;}
  8640. else
  8641. {
  8642. if (g_pTheApp->m_fInvokedByNT)
  8643. {
  8644. iisDebugOut((LOG_TYPE_WARN, _T("TemporaryHack. iis.inf=NTS system=NTW, but wait till nt5 fixes. FAIL.\n")));
  8645. g_pTheApp->m_eNTOSType = OT_NTS;
  8646. fPlatform = TRUE;
  8647. }
  8648. else
  8649. {
  8650. nPlatform = IDS_NEED_PLATFORM_NTW;
  8651. }
  8652. }
  8653. }
  8654. // Check if .inf file is for NTW
  8655. if (_tcsicmp(szPlatform, _T("NTW")) == 0)
  8656. {
  8657. if (g_pTheApp->m_eOS == OS_NT && g_pTheApp->m_eNTOSType == OT_NTW){fPlatform = TRUE;}
  8658. else{nPlatform = IDS_NEED_PLATFORM_NTW;}
  8659. }
  8660. /*
  8661. // Check if .inf file is for Windows 95
  8662. if (_tcsicmp(szPlatform, _T("W95")) == 0)
  8663. {
  8664. if (g_pTheApp->m_eOS == OS_W95){fPlatform = TRUE;}
  8665. else{nPlatform = IDS_NEED_PLATFORM_W95;}
  8666. }
  8667. */
  8668. // If We didn't find the specific platform, then produce error message.
  8669. if (!fPlatform)
  8670. {
  8671. MyMessageBox(NULL, nPlatform, MB_OK | MB_SETFOREGROUND);
  8672. iReturn = FALSE;
  8673. }
  8674. return iReturn;
  8675. }
  8676. int CheckSpecificBuildinInf(HINF InfHandle)
  8677. {
  8678. int iReturn = TRUE;
  8679. INFCONTEXT Context;
  8680. // Check for a specific build of nt5...
  8681. if ( g_pTheApp->m_eOS == OS_NT )
  8682. {
  8683. int iBuildNumRequired = 0;
  8684. TCHAR szBuildRequired[20] = _T("");
  8685. // check for Debug Keyword
  8686. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupInfo"), _T("Debug"), &Context) )
  8687. {
  8688. SetupGetStringField(&Context, 1, szBuildRequired, 50, NULL);
  8689. if (IsValidNumber((LPCTSTR)szBuildRequired))
  8690. {
  8691. iBuildNumRequired = _ttoi(szBuildRequired);
  8692. if (iBuildNumRequired >= 1) {g_pTheApp->m_bAllowMessageBoxPopups = TRUE;}
  8693. }
  8694. }
  8695. if (!SetupFindFirstLine_Wrapped(InfHandle, _T("SetupInfo"), _T("OSBuildRequired"), &Context) )
  8696. {iisDebugOut((LOG_TYPE_ERROR, _T("SetupFindFirstLine_Wrapped(SetupInfo, OSBuildRequired) FAILED")));}
  8697. SetupGetStringField(&Context, 1, szBuildRequired, 20, NULL);
  8698. // Since this is nt, we should be able to get the build number
  8699. CRegKey regWindowsNT( HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"),KEY_READ);
  8700. if ( (HKEY)regWindowsNT )
  8701. {
  8702. CString strBuildNumString;
  8703. regWindowsNT.m_iDisplayWarnings = FALSE;
  8704. if (ERROR_SUCCESS == regWindowsNT.QueryValue(_T("CurrentBuildNumber"), strBuildNumString))
  8705. {
  8706. int iBuildNumOS = 0;
  8707. if (IsValidNumber((LPCTSTR)strBuildNumString))
  8708. {iBuildNumOS = _ttoi(strBuildNumString);}
  8709. iisDebugOut((LOG_TYPE_TRACE, _T("NTCurrentBuildNumber=%d\n"), iBuildNumOS));
  8710. // We have a build entry.
  8711. // lets check if it larger than or equal to what the underlying operting system is...
  8712. if (_tcsicmp(szBuildRequired, _T("")) != 0)
  8713. {
  8714. if (IsValidNumber((LPCTSTR)szBuildRequired))
  8715. {iBuildNumRequired = _ttoi(szBuildRequired);}
  8716. if ((iBuildNumOS !=0 && iBuildNumRequired !=0) && (iBuildNumOS < iBuildNumRequired))
  8717. {
  8718. // They don't have a big enough build num
  8719. // give the error message.
  8720. MyMessageBox(NULL, IDS_OS_BUILD_NUM_REQUIREMENT,szBuildRequired, MB_OK | MB_SETFOREGROUND);
  8721. }
  8722. }
  8723. }
  8724. }
  8725. }
  8726. return iReturn;
  8727. }
  8728. int CheckForOldGopher(HINF InfHandle)
  8729. {
  8730. int iReturn = TRUE;
  8731. INFCONTEXT Context;
  8732. if ( !(g_pTheApp->m_fUnattended) && g_pTheApp->m_eInstallMode == IM_UPGRADE )
  8733. {
  8734. CRegKey regGopher(HKEY_LOCAL_MACHINE, REG_GOPHERSVC,KEY_READ);
  8735. if ( (HKEY)regGopher )
  8736. {
  8737. iisDebugOut((LOG_TYPE_TRACE, _T("GopherCurrentlyInstalled=YES")));
  8738. if (g_pTheApp->MsgBox(NULL, IDS_REMOVE_GOPHER, MB_OKCANCEL, FALSE) == IDCANCEL)
  8739. {
  8740. // setup should be terminated.
  8741. iReturn = FALSE;
  8742. goto CheckForOldGopher_Exit;
  8743. }
  8744. }
  8745. }
  8746. CheckForOldGopher_Exit:
  8747. return iReturn;
  8748. }
  8749. // IIS publish the following directories to iis partners products
  8750. // Note: Inetpub directory can be customized later, and we'll re-publish
  8751. // those affected directories again later.
  8752. void SetOCGlobalPrivateData(void)
  8753. {
  8754. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("PathInetsrv"),(PVOID)(LPCTSTR)g_pTheApp->m_csPathInetsrv,(g_pTheApp->m_csPathInetsrv.GetLength() + 1) * sizeof(TCHAR),REG_SZ);
  8755. CString csPathIISAdmin = g_pTheApp->m_csPathInetsrv + _T("\\iisadmin");
  8756. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("PathIISAdmin"),(PVOID)(LPCTSTR)csPathIISAdmin,(csPathIISAdmin.GetLength() + 1) * sizeof(TCHAR),REG_SZ);
  8757. CString csPathIISHelp = g_pTheApp->m_csWinDir + _T("\\Help\\iishelp");
  8758. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("PathIISHelp"),(PVOID)(LPCTSTR)csPathIISHelp,(csPathIISHelp.GetLength() + 1) * sizeof(TCHAR),REG_SZ);
  8759. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("PathFTPRoot"),(PVOID)(LPCTSTR)g_pTheApp->m_csPathFTPRoot,(g_pTheApp->m_csPathFTPRoot.GetLength() + 1) * sizeof(TCHAR),REG_SZ);
  8760. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("PathWWWRoot"),(PVOID)(LPCTSTR)g_pTheApp->m_csPathWWWRoot,(g_pTheApp->m_csPathWWWRoot.GetLength() + 1) * sizeof(TCHAR),REG_SZ);
  8761. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("PathIISSamples"),(PVOID)(LPCTSTR)g_pTheApp->m_csPathIISSamples,(g_pTheApp->m_csPathIISSamples.GetLength() + 1) * sizeof(TCHAR),REG_SZ);
  8762. CString csPathScripts = g_pTheApp->m_csPathIISSamples + _T("\\Scripts");
  8763. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("PathScripts"),(PVOID)(LPCTSTR)csPathScripts,(csPathScripts.GetLength() + 1) * sizeof(TCHAR),REG_SZ);
  8764. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("IISProgramGroup"),(PVOID)(LPCTSTR)g_pTheApp->m_csIISGroupName,(g_pTheApp->m_csIISGroupName.GetLength() + 1) * sizeof(TCHAR),REG_SZ);
  8765. DWORD dwUpgradeType = (DWORD)(g_pTheApp->m_eUpgradeType);
  8766. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("UpgradeType"),(PVOID)&dwUpgradeType,sizeof(DWORD),REG_DWORD);
  8767. return;
  8768. }
  8769. void SetDIRIDforThisInf(HINF InfHandle)
  8770. {
  8771. BOOL bTempFlag = FALSE;
  8772. // Create Directory IDs for the coresponding .inf file
  8773. bTempFlag = SetupSetDirectoryId_Wrapper(InfHandle, 32768, g_pTheApp->m_csPathInetsrv);
  8774. bTempFlag = SetupSetDirectoryId_Wrapper(InfHandle, 32769, g_pTheApp->m_csPathFTPRoot);
  8775. bTempFlag = SetupSetDirectoryId_Wrapper(InfHandle, 32770, g_pTheApp->m_csPathWWWRoot);
  8776. bTempFlag = SetupSetDirectoryId_Wrapper(InfHandle, 32771, g_pTheApp->m_csPathIISSamples);
  8777. bTempFlag = SetupSetDirectoryId_Wrapper(InfHandle, 32772, g_pTheApp->m_csPathScripts);
  8778. bTempFlag = SetupSetDirectoryId_Wrapper(InfHandle, 32773, g_pTheApp->m_csPathInetpub);
  8779. bTempFlag = SetupSetDirectoryId_Wrapper(InfHandle, 32774, g_pTheApp->m_csPathOldInetsrv);
  8780. if (g_pTheApp->m_eUpgradeType == UT_10_W95)
  8781. {
  8782. bTempFlag = SetupSetDirectoryId_Wrapper(InfHandle, 32775, g_pTheApp->m_csPathOldPWSFiles);
  8783. bTempFlag = SetupSetDirectoryId_Wrapper(InfHandle, 32776, g_pTheApp->m_csPathOldPWSSystemFiles);
  8784. }
  8785. TCHAR szJavaDir[_MAX_PATH];
  8786. GetJavaTLD(szJavaDir);
  8787. bTempFlag = SetupSetDirectoryId_Wrapper(InfHandle, 32778, szJavaDir);
  8788. SetupSetDirectoryId_Wrapper(InfHandle, 32777, g_pTheApp->m_csPathProgramFiles);
  8789. SetupSetDirectoryId_Wrapper(InfHandle, 32779, g_pTheApp->m_csPathWebPub);
  8790. if (g_pTheApp->m_eUpgradeType == UT_NONE){SetupSetStringId_Wrapper(InfHandle, 32801, _T("UT_NONE"));}
  8791. if (g_pTheApp->m_eUpgradeType == UT_351){SetupSetStringId_Wrapper(InfHandle, 32801, _T("UT_351"));}
  8792. if (g_pTheApp->m_eUpgradeType == UT_10){SetupSetStringId_Wrapper(InfHandle, 32801, _T("UT_10"));}
  8793. if (g_pTheApp->m_eUpgradeType == UT_20){SetupSetStringId_Wrapper(InfHandle, 32801, _T("UT_20"));}
  8794. if (g_pTheApp->m_eUpgradeType == UT_30){SetupSetStringId_Wrapper(InfHandle, 32801, _T("UT_30"));}
  8795. if (g_pTheApp->m_eUpgradeType == UT_40){SetupSetStringId_Wrapper(InfHandle, 32801, _T("UT_40"));} // can also be from win95
  8796. if (g_pTheApp->m_eUpgradeType == UT_50){SetupSetStringId_Wrapper(InfHandle, 32801, _T("UT_50"));}
  8797. if (g_pTheApp->m_eUpgradeType == UT_51){SetupSetStringId_Wrapper(InfHandle, 32801, _T("UT_51"));}
  8798. if (g_pTheApp->m_eUpgradeType == UT_60){SetupSetStringId_Wrapper(InfHandle, 32801, _T("UT_60"));}
  8799. if (g_pTheApp->m_eUpgradeType == UT_10_W95){SetupSetStringId_Wrapper(InfHandle, 32801, _T("UT_10_W95"));}
  8800. CString csMachineName = g_pTheApp->m_csMachineName.Right(g_pTheApp->m_csMachineName.GetLength() - 2);
  8801. SetupSetStringId_Wrapper(InfHandle, 32800, csMachineName);
  8802. SetupSetStringId_Wrapper(InfHandle, 32802, _T(""));
  8803. SetupSetStringId_Wrapper(InfHandle, 33000, g_pTheApp->m_csGuestName);
  8804. SetupSetStringId_Wrapper(InfHandle, 33001, g_pTheApp->m_csWAMAccountName);
  8805. SetupSetStringId_Wrapper(InfHandle, 33002, g_pTheApp->m_csWWWAnonyName);
  8806. SetupSetStringId_Wrapper(InfHandle, 33003, g_pTheApp->m_csFTPAnonyName);
  8807. if ( _tcsicmp(g_pTheApp->m_csWAMAccountName_Remove, _T("")) == 0)
  8808. {g_pTheApp->m_csWAMAccountName_Remove = g_pTheApp->m_csWAMAccountName;}
  8809. SetupSetStringId_Wrapper(InfHandle, 33004, g_pTheApp->m_csWAMAccountName_Remove);
  8810. if ( _tcsicmp(g_pTheApp->m_csWWWAnonyName_Remove, _T("")) == 0)
  8811. {g_pTheApp->m_csWWWAnonyName_Remove = g_pTheApp->m_csWWWAnonyName; }
  8812. SetupSetStringId_Wrapper(InfHandle, 33005, g_pTheApp->m_csWWWAnonyName_Remove);
  8813. if ( _tcsicmp(g_pTheApp->m_csWWWAnonyName_Remove, _T("")) == 0)
  8814. {g_pTheApp->m_csFTPAnonyName_Remove = g_pTheApp->m_csFTPAnonyName;}
  8815. SetupSetStringId_Wrapper(InfHandle, 33006, g_pTheApp->m_csFTPAnonyName_Remove);
  8816. SYSTEM_INFO SystemInfo;
  8817. GetSystemInfo( &SystemInfo );
  8818. TCHAR szSourceCatOSName[20];
  8819. _tcscpy(szSourceCatOSName, _T("\\i386"));
  8820. switch(SystemInfo.wProcessorArchitecture)
  8821. {
  8822. case PROCESSOR_ARCHITECTURE_AMD64:
  8823. _tcscpy(szSourceCatOSName, _T("\\AMD64"));
  8824. break;
  8825. // case PROCESSOR_ARCHITECTURE_IA64:
  8826. // _tcscpy(szSourceCatOSName, _T("\\IA64"));
  8827. // break;
  8828. case PROCESSOR_ARCHITECTURE_INTEL:
  8829. if (IsNEC_98) {_tcscpy(szSourceCatOSName, _T("\\Nec98"));}
  8830. break;
  8831. default:
  8832. break;
  8833. }
  8834. SetupSetStringId_Wrapper(InfHandle, 34000, szSourceCatOSName);
  8835. return;
  8836. }
  8837. BOOL GetJavaTLD(LPTSTR lpszDir)
  8838. {
  8839. CRegKey regKey(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\JAVA VM"),KEY_READ);
  8840. BOOL bFound = FALSE;
  8841. CString csValue;
  8842. CString csValue2;
  8843. int iWhere = -1;
  8844. if ((HKEY)regKey)
  8845. {
  8846. regKey.m_iDisplayWarnings = FALSE;
  8847. if (regKey.QueryValue(_T("TrustedLibsDirectory"), csValue) == ERROR_SUCCESS) {bFound = TRUE;}
  8848. // Warning: we are expecting something like this = "C:\WINNT\java\trustlib"
  8849. // However, recently 12/18 the nt5 "java vm" setup seems to be hosing and passing us:
  8850. // %systemroot%\java\trustlib
  8851. if (-1 != csValue.Find(_T('%')) )
  8852. {
  8853. // there is a '%' in the string
  8854. TCHAR szTempDir[_MAX_PATH];
  8855. _tcscpy(szTempDir, csValue);
  8856. if (ExpandEnvironmentStrings( (LPCTSTR)csValue, szTempDir, sizeof(szTempDir)/sizeof(TCHAR)))
  8857. {
  8858. csValue = szTempDir;
  8859. }
  8860. }
  8861. /*
  8862. // if we see %systemroot% in there then, i'm going to substitute WinDir in place of %Systemroot%
  8863. csValue.MakeUpper();
  8864. if (csValue.Find(_T("%SYSTEMROOT%")) != (-1) )
  8865. {
  8866. // We Found the cheesy %systemroot% deal. Now replace it with the real systemroot
  8867. iWhere = csValue.Find(_T("%SYSTEMROOT%"));
  8868. iWhere = iWhere + _tcslen(_T("%SYSTEMROOT%"));
  8869. csValue2 = g_pTheApp->m_csWinDir + csValue.Right( csValue.GetLength() - (iWhere) );
  8870. csValue = csValue2;
  8871. }
  8872. */
  8873. }
  8874. if (!bFound) {csValue = g_pTheApp->m_csWinDir + _T("\\Java\\TrustLib");}
  8875. _tcscpy(lpszDir, csValue);
  8876. return bFound;
  8877. }
  8878. void ShowStateOfTheseServices(IN HINF hFile)
  8879. {
  8880. CStringList strList;
  8881. DWORD dwStatus;
  8882. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T(" --- Display status of services which are required for IIS to run --- \n")));
  8883. CString csTheSection = _T("VerifyServices");
  8884. if (GetSectionNameToDo(hFile, csTheSection))
  8885. {
  8886. if (ERROR_SUCCESS == FillStrListWithListOfSections(hFile, strList, csTheSection))
  8887. {
  8888. // loop thru the list returned back
  8889. if (strList.IsEmpty() == FALSE)
  8890. {
  8891. POSITION pos;
  8892. CString csEntry;
  8893. pos = strList.GetHeadPosition();
  8894. while (pos)
  8895. {
  8896. csEntry = strList.GetAt(pos);
  8897. // Display state of this service.
  8898. dwStatus = InetQueryServiceStatus(csEntry);
  8899. switch(dwStatus)
  8900. {
  8901. case SERVICE_STOPPED:
  8902. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("SERVICE_STOPPED [%s].\n"), csEntry));
  8903. break;
  8904. case SERVICE_START_PENDING:
  8905. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("SERVICE_START_PENDING [%s].\n"), csEntry));
  8906. break;
  8907. case SERVICE_STOP_PENDING:
  8908. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("SERVICE_STOP_PENDING [%s].\n"), csEntry));
  8909. break;
  8910. case SERVICE_RUNNING:
  8911. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("SERVICE_RUNNING [%s].\n"), csEntry));
  8912. break;
  8913. case SERVICE_CONTINUE_PENDING:
  8914. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("SERVICE_CONTINUE_PENDING [%s].\n"), csEntry));
  8915. break;
  8916. case SERVICE_PAUSE_PENDING:
  8917. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("SERVICE_PAUSE_PENDING [%s].\n"), csEntry));
  8918. break;
  8919. case SERVICE_PAUSED:
  8920. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("SERVICE_PAUSED [%s].\n"), csEntry));
  8921. break;
  8922. }
  8923. strList.GetNext(pos);
  8924. }
  8925. }
  8926. }
  8927. }
  8928. return;
  8929. }
  8930. #define MD_SIGNATURE_STRINGA "*&$MetaData$&*"
  8931. #define MD_SIGNATURE_STRINGW L##"*&$MetaData$&*"
  8932. int IsMetabaseCorrupt(void)
  8933. {
  8934. // We've had a problem where sometimes the metabase.bin file
  8935. // gets corrupted and set to only spaces...
  8936. // so this function is here to determine where and when the metabase.bin is hosed!
  8937. int iTheMetabaseIsCorrupt = FALSE;
  8938. TCHAR szSystemDir[_MAX_PATH];
  8939. TCHAR szFullPath[_MAX_PATH];
  8940. HANDLE hReadFileHandle = INVALID_HANDLE_VALUE;
  8941. BYTE *chBuffer = NULL;
  8942. DWORD dwSize = 0;
  8943. DWORD dwWideSignatureLen = 0;
  8944. DWORD dwAnsiSignatureLen = 0;
  8945. TCHAR buf[MAX_FAKE_METABASE_STRING_LEN];
  8946. // get the c:\winnt\system32 dir
  8947. if (0 == GetSystemDirectory(szSystemDir, _MAX_PATH))
  8948. {goto IsMetabaseCorrupt_Exit;}
  8949. // Tack on the inf\iis.inf subdir and filename
  8950. _stprintf(szFullPath, _T("%s\\inetsrv\\metabase.bin"),szSystemDir);
  8951. // Check if the file exists
  8952. if (TRUE != IsFileExist(szFullPath))
  8953. {
  8954. iTheMetabaseIsCorrupt = FALSE;
  8955. // this function only works on version less than or equal to iis5
  8956. // since that's the only versions which had a metabase.bin file
  8957. // so just return that the metabase is not corrupt
  8958. goto IsMetabaseCorrupt_Exit;
  8959. }
  8960. // okay, so the metabase.bin file exists...
  8961. // let's open it and see if we can get something out of it.
  8962. //
  8963. // Open the file.
  8964. //
  8965. hReadFileHandle = CreateFile(szFullPath,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
  8966. if (hReadFileHandle == INVALID_HANDLE_VALUE)
  8967. {
  8968. iisDebugOut((LOG_TYPE_WARN, _T("IsMetabaseCorrupt: CreateFile on %s failed with 0x%x!\n"),szFullPath,GetLastError()));
  8969. goto IsMetabaseCorrupt_Exit;
  8970. }
  8971. dwSize = GetFileSize(hReadFileHandle, NULL);
  8972. dwWideSignatureLen = sizeof(MD_SIGNATURE_STRINGW);
  8973. dwAnsiSignatureLen = sizeof(MD_SIGNATURE_STRINGA);
  8974. // get the size of the whole file
  8975. //chBuffer = (BYTE *)HeapAlloc(GetProcessHeap(), 0, dwSize+1 );
  8976. if ((dwSize) >= dwWideSignatureLen)
  8977. {
  8978. chBuffer = (BYTE *)HeapAlloc(GetProcessHeap(), 0, dwWideSignatureLen+1);
  8979. dwSize = dwWideSignatureLen+1;
  8980. }
  8981. else
  8982. {
  8983. if ( dwSize >= dwAnsiSignatureLen)
  8984. {
  8985. chBuffer = (BYTE *)HeapAlloc(GetProcessHeap(), 0, dwAnsiSignatureLen+1 );
  8986. dwSize = dwAnsiSignatureLen+1;
  8987. }
  8988. else
  8989. {
  8990. iisDebugOut((LOG_TYPE_WARN, _T("IsMetabaseCorrupt: ReadFile on %s. Not enough data in there! Less than metabase signature len!\n"),szFullPath));
  8991. // Things are not kool
  8992. // This metabase must be hosed!
  8993. iTheMetabaseIsCorrupt = FALSE;
  8994. goto IsMetabaseCorrupt_Exit;
  8995. }
  8996. }
  8997. if (!chBuffer)
  8998. {
  8999. iisDebugOut((LOG_TYPE_WARN, _T("IsMetabaseCorrupt: HeapAlloc failed to get %d space.\n"),dwWideSignatureLen+1));
  9000. goto IsMetabaseCorrupt_Exit;
  9001. }
  9002. SetFilePointer(hReadFileHandle,0,0,FILE_BEGIN);
  9003. // kool, try to read the file
  9004. if (0 == ReadFile(hReadFileHandle, chBuffer, dwSize, &dwSize, NULL))
  9005. {
  9006. iisDebugOut((LOG_TYPE_WARN, _T("IsMetabaseCorrupt: ReadFile on %s failed with 0x%x!. size=%d\n"),szFullPath,GetLastError(),dwSize));
  9007. goto IsMetabaseCorrupt_Exit;
  9008. }
  9009. //
  9010. // take chBuffer and check if it matches the unicode/ansi signature.
  9011. //
  9012. if (0 == memcmp(MD_SIGNATURE_STRINGW,chBuffer,dwWideSignatureLen))
  9013. {
  9014. // things are kool, and this metabase should not be hosed.
  9015. iTheMetabaseIsCorrupt = FALSE;
  9016. goto IsMetabaseCorrupt_Exit;
  9017. }
  9018. if (0 == memcmp(MD_SIGNATURE_STRINGA,chBuffer,dwAnsiSignatureLen))
  9019. {
  9020. // if not, then check if it matches the ansi signature.
  9021. // things are kool, and this metabase should not be hosed.
  9022. iTheMetabaseIsCorrupt = FALSE;
  9023. goto IsMetabaseCorrupt_Exit;
  9024. }
  9025. // on other check...
  9026. // in iis6 there is a dummy fake metabase.bin put there by setup
  9027. // check if this is that dummy file.
  9028. if (chBuffer)
  9029. {HeapFree(GetProcessHeap(), 0, chBuffer); chBuffer = NULL;}
  9030. memset(buf, 0, _tcslen(buf) * sizeof(TCHAR));
  9031. // this iis.dll is always compiled unicode, so
  9032. // we know that buf is unicode
  9033. if (LoadString((HINSTANCE) g_MyModuleHandle, IDS_FAKE_METABASE_BIN_TEXT, buf, MAX_FAKE_METABASE_STRING_LEN))
  9034. {
  9035. dwSize = _tcslen(buf) * sizeof(TCHAR);
  9036. // add space for the FF and FE bytes
  9037. dwSize = dwSize + 2;
  9038. // open the file
  9039. SetFilePointer(hReadFileHandle,0,0,FILE_BEGIN);
  9040. chBuffer = (BYTE *)HeapAlloc(GetProcessHeap(), 0, dwSize);
  9041. // kool, try to read the file
  9042. if (0 == ReadFile(hReadFileHandle, chBuffer, dwSize, &dwSize, NULL))
  9043. {
  9044. iisDebugOut((LOG_TYPE_WARN, _T("IsMetabaseCorrupt: ReadFile on %s failed with 0x%x!. size=%d\n"),szFullPath,GetLastError(),dwSize));
  9045. goto IsMetabaseCorrupt_Exit;
  9046. }
  9047. // check if the input file is unicode
  9048. if (0xFF == chBuffer[0] && 0xFE == chBuffer[1])
  9049. {
  9050. // skip past these characters
  9051. chBuffer++;
  9052. chBuffer++;
  9053. // Compare what you got with what we think is in there
  9054. if (0 == memcmp(buf,chBuffer,dwSize))
  9055. {
  9056. // things are kool, and this metabase should not be hosed.
  9057. chBuffer--;
  9058. chBuffer--;
  9059. iTheMetabaseIsCorrupt = FALSE;
  9060. goto IsMetabaseCorrupt_Exit;
  9061. }
  9062. chBuffer--;
  9063. chBuffer--;
  9064. }
  9065. }
  9066. // if not then, it must be corrupt!
  9067. // Things are not kool
  9068. // This metabase must be hosed!
  9069. iTheMetabaseIsCorrupt = TRUE;
  9070. iisDebugOut((LOG_TYPE_WARN, _T("IsMetabaseCorrupt: unable to verify signature in Metabase.bin. Corrupt.\n")));
  9071. IsMetabaseCorrupt_Exit:
  9072. if (chBuffer)
  9073. {HeapFree(GetProcessHeap(), 0, chBuffer);}
  9074. if (hReadFileHandle != INVALID_HANDLE_VALUE)
  9075. {CloseHandle(hReadFileHandle);}
  9076. return iTheMetabaseIsCorrupt;
  9077. }
  9078. void iisDebugOut_Start(TCHAR *pszString, int iLogType)
  9079. {
  9080. iisDebugOut((iLogType, _T("%s:Start.\n"),pszString));
  9081. return;
  9082. }
  9083. void iisDebugOut_Start1(TCHAR *pszString1, TCHAR *pszString2, int iLogType)
  9084. {
  9085. iisDebugOut((iLogType, _T("%s:(%s)Start.\n"),pszString1,pszString2));
  9086. return;
  9087. }
  9088. void iisDebugOut_Start1(TCHAR *pszString1, CString pszString2, int iLogType)
  9089. {
  9090. iisDebugOut((iLogType, _T("%s:(%s)Start.\n"),pszString1,pszString2));
  9091. return;
  9092. }
  9093. void iisDebugOut_End(TCHAR *pszString, int iLogType)
  9094. {
  9095. iisDebugOut((iLogType, _T("%s:End.\n"),pszString));
  9096. return;
  9097. }
  9098. void iisDebugOut_End1(TCHAR *pszString1, TCHAR *pszString2, int iLogType)
  9099. {
  9100. iisDebugOut((iLogType, _T("%s(%s):End.\n"),pszString1, pszString2));
  9101. return;
  9102. }
  9103. void iisDebugOut_End1(TCHAR *pszString1, CString pszString2, int iLogType)
  9104. {
  9105. iisDebugOut((iLogType, _T("%s(%s):End.\n"),pszString1,pszString2));
  9106. return;
  9107. }
  9108. BOOL SetupFindFirstLine_Wrapped(
  9109. IN HINF InfHandle,
  9110. IN LPCTSTR Section,
  9111. IN LPCTSTR Key, OPTIONAL
  9112. INFCONTEXT *Context
  9113. )
  9114. {
  9115. BOOL bReturn = FALSE;
  9116. BOOL bGoGetWhatTheyOriginallyWanted = TRUE;
  9117. // check for the alternate .inf file
  9118. if (g_pTheApp->m_hInfHandleAlternate && InfHandle != g_pTheApp->m_hInfHandleAlternate)
  9119. {
  9120. bReturn = SetupFindFirstLine(g_pTheApp->m_hInfHandleAlternate, Section, Key, Context);
  9121. if (bReturn)
  9122. {
  9123. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("Using alternate iis.inf section:[%s]"),Section));
  9124. bGoGetWhatTheyOriginallyWanted = FALSE;
  9125. }
  9126. }
  9127. if (bGoGetWhatTheyOriginallyWanted)
  9128. {bReturn = SetupFindFirstLine(InfHandle, Section, Key, Context);}
  9129. return bReturn;
  9130. }
  9131. int ReadUserConfigurable(HINF InfHandle)
  9132. {
  9133. int iReturn = TRUE;
  9134. INFCONTEXT Context;
  9135. TCHAR szTempString[_MAX_PATH] = _T("");
  9136. DWORD dwValue = 0x0;
  9137. DWORD dwSomethingSpecifiedHere = 0;
  9138. //
  9139. // Get the IUSR name
  9140. //
  9141. _tcscpy(szTempString, _T(""));
  9142. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupConfig"), _T("IUSR"), &Context) )
  9143. {
  9144. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  9145. {
  9146. // WARNING: these values can be changed by a user supplied unattend file
  9147. // The User defined unattend file takes precidence over these!
  9148. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_WWW_USER_NAME))
  9149. {
  9150. g_pTheApp->m_csWWWAnonyName_Unattend = szTempString;
  9151. dwSomethingSpecifiedHere |= USER_SPECIFIED_INFO_WWW_USER_NAME;
  9152. //g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_WWW_USER_NAME;
  9153. iisDebugOut((LOG_TYPE_TRACE, _T("Custom iusr specified for www\n")));
  9154. }
  9155. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_FTP_USER_NAME))
  9156. {
  9157. g_pTheApp->m_csFTPAnonyName_Unattend = szTempString;
  9158. dwSomethingSpecifiedHere |= USER_SPECIFIED_INFO_FTP_USER_NAME;
  9159. //g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_FTP_USER_NAME;
  9160. iisDebugOut((LOG_TYPE_TRACE, _T("Custom iusr specified for ftp\n")));
  9161. }
  9162. }
  9163. }
  9164. /*
  9165. // this stuff should not be configurable from the iis.inf file
  9166. //
  9167. // Get the IUSR password
  9168. //
  9169. _tcscpy(szTempString, _T(""));
  9170. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupConfig"), _T("IUSR_PASS"), &Context) )
  9171. {
  9172. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  9173. {
  9174. // WARNING: these values can be changed by a user supplied unattend file
  9175. // The User defined unattend file takes precidence over these!
  9176. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_WWW_USER_PASS))
  9177. {
  9178. if (_tcsicmp(szTempString, _T("")) != 0)
  9179. {
  9180. if (_tcsicmp(szTempString, _T("(blank)")) == 0)
  9181. {
  9182. _tcscpy(szTempString, _T(""));
  9183. }
  9184. g_pTheApp->m_csWWWAnonyPassword_Unattend = szTempString;
  9185. dwSomethingSpecifiedHere |= USER_SPECIFIED_INFO_WWW_USER_PASS;
  9186. //g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_WWW_USER_PASS;
  9187. iisDebugOut((LOG_TYPE_TRACE, _T("Custom iusr pass specified for www\n")));
  9188. }
  9189. }
  9190. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_FTP_USER_PASS))
  9191. {
  9192. if (_tcsicmp(szTempString, _T("")) != 0)
  9193. {
  9194. if (_tcsicmp(szTempString, _T("(blank)")) == 0)
  9195. {
  9196. _tcscpy(szTempString, _T(""));
  9197. }
  9198. g_pTheApp->m_csFTPAnonyPassword_Unattend = szTempString;
  9199. dwSomethingSpecifiedHere |= USER_SPECIFIED_INFO_FTP_USER_PASS;
  9200. //g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_FTP_USER_PASS;
  9201. iisDebugOut((LOG_TYPE_TRACE, _T("Custom iusr pass specified for ftp\n")));
  9202. }
  9203. }
  9204. }
  9205. }
  9206. */
  9207. //
  9208. // Get the IUSR name for WWW
  9209. //
  9210. _tcscpy(szTempString, _T(""));
  9211. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupConfig"), _T("IUSR_WWW"), &Context) )
  9212. {
  9213. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  9214. {
  9215. // WARNING: these values can be changed by a user supplied unattend file
  9216. // The User defined unattend file takes precidence over these!
  9217. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_WWW_USER_NAME))
  9218. {
  9219. g_pTheApp->m_csWWWAnonyName_Unattend = szTempString;
  9220. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_WWW_USER_NAME;
  9221. iisDebugOut((LOG_TYPE_TRACE, _T("Custom iusr specified for www\n")));
  9222. }
  9223. }
  9224. }
  9225. /*
  9226. // this stuff should not be configurable from the iis.inf file
  9227. //
  9228. // Get the IUSR pass for WWW
  9229. //
  9230. _tcscpy(szTempString, _T(""));
  9231. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupConfig"), _T("IUSR_WWW_PASS"), &Context) )
  9232. {
  9233. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  9234. {
  9235. // WARNING: these values can be changed by a user supplied unattend file
  9236. // The User defined unattend file takes precidence over these!
  9237. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_WWW_USER_PASS))
  9238. {
  9239. if (_tcsicmp(szTempString, _T("")) != 0)
  9240. {
  9241. if (_tcsicmp(szTempString, _T("(blank)")) == 0)
  9242. {
  9243. _tcscpy(szTempString, _T(""));
  9244. }
  9245. g_pTheApp->m_csWWWAnonyPassword_Unattend = szTempString;
  9246. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_WWW_USER_PASS;
  9247. iisDebugOut((LOG_TYPE_TRACE, _T("Custom iusr pass specified for www\n")));
  9248. }
  9249. }
  9250. }
  9251. }
  9252. */
  9253. //
  9254. // Get the IUSR name for FTP
  9255. //
  9256. _tcscpy(szTempString, _T(""));
  9257. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupConfig"), _T("IUSR_FTP"), &Context) )
  9258. {
  9259. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  9260. {
  9261. // WARNING: these values can be changed by a user supplied unattend file
  9262. // The User defined unattend file takes precidence over these!
  9263. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_FTP_USER_NAME))
  9264. {
  9265. g_pTheApp->m_csFTPAnonyName_Unattend = szTempString;
  9266. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_FTP_USER_NAME;
  9267. iisDebugOut((LOG_TYPE_TRACE, _T("Custom iusr specified for ftp\n")));
  9268. }
  9269. }
  9270. }
  9271. /*
  9272. // this stuff should not be configurable from the iis.inf file
  9273. //
  9274. // Get the IUSR password for FTP
  9275. //
  9276. _tcscpy(szTempString, _T(""));
  9277. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupConfig"), _T("IUSR_FTP_PASS"), &Context) )
  9278. {
  9279. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  9280. {
  9281. // WARNING: these values can be changed by a user supplied unattend file
  9282. // The User defined unattend file takes precidence over these!
  9283. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_FTP_USER_PASS))
  9284. {
  9285. if (_tcsicmp(szTempString, _T("")) != 0)
  9286. {
  9287. if (_tcsicmp(szTempString, _T("(blank)")) == 0)
  9288. {
  9289. _tcscpy(szTempString, _T(""));
  9290. }
  9291. g_pTheApp->m_csFTPAnonyPassword_Unattend = szTempString;
  9292. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_FTP_USER_PASS;
  9293. iisDebugOut((LOG_TYPE_TRACE, _T("Custom iusr pass specified for ftp\n")));
  9294. }
  9295. }
  9296. }
  9297. }
  9298. */
  9299. //
  9300. // Get the WAM username
  9301. //
  9302. _tcscpy(szTempString, _T(""));
  9303. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupConfig"), _T("IWAM"), &Context) )
  9304. {
  9305. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  9306. {
  9307. // WARNING: these values can be changed by a user supplied unattend file
  9308. // The User defined unattend file takes precidence over these!
  9309. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_WAM_USER_NAME))
  9310. {
  9311. g_pTheApp->m_csWAMAccountName_Unattend = szTempString;
  9312. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_WAM_USER_NAME;
  9313. iisDebugOut((LOG_TYPE_TRACE, _T("Custom iwam specified for www\n")));
  9314. }
  9315. }
  9316. }
  9317. /*
  9318. // this stuff should not be configurable from the iis.inf file
  9319. //
  9320. // Get the WAM password
  9321. //
  9322. _tcscpy(szTempString, _T(""));
  9323. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupConfig"), _T("IWAM_PASS"), &Context) )
  9324. {
  9325. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  9326. {
  9327. // WARNING: these values can be changed by a user supplied unattend file
  9328. // The User defined unattend file takes precidence over these!
  9329. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_WAM_USER_PASS))
  9330. {
  9331. if (_tcsicmp(szTempString, _T("")) != 0)
  9332. {
  9333. if (_tcsicmp(szTempString, _T("(blank)")) == 0)
  9334. {
  9335. _tcscpy(szTempString, _T(""));
  9336. }
  9337. g_pTheApp->m_csWAMAccountPassword_Unattend = szTempString;
  9338. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_WAM_USER_PASS;
  9339. iisDebugOut((LOG_TYPE_TRACE, _T("Custom iwam pass specified for www\n")));
  9340. }
  9341. }
  9342. }
  9343. }
  9344. */
  9345. //
  9346. // Get Path for Inetpub
  9347. //
  9348. _tcscpy(szTempString, _T(""));
  9349. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupConfig"), _T("PathInetpub"), &Context) )
  9350. {
  9351. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  9352. {
  9353. // WARNING: these values can be changed by a user supplied unattend file
  9354. // The User defined unattend file takes precidence over these!
  9355. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_PATH_INETPUB))
  9356. {
  9357. if (_tcsicmp(szTempString, _T("")) != 0)
  9358. {
  9359. if (IsValidDirectoryName(szTempString))
  9360. {
  9361. iisDebugOut((LOG_TYPE_TRACE, _T("Custom PathInetpub=%s\n"),szTempString));
  9362. g_pTheApp->m_csPathInetpub = szTempString;
  9363. g_pTheApp->SetInetpubDerivatives();
  9364. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_PATH_INETPUB;
  9365. }
  9366. else
  9367. {
  9368. iisDebugOut((LOG_TYPE_WARN, _T("Custom PathInetpub specified (%s), however path not valid.ignoring unattend value. WARNING.\n"),szTempString));
  9369. }
  9370. }
  9371. }
  9372. }
  9373. }
  9374. //
  9375. // Get Path for ftp root
  9376. //
  9377. _tcscpy(szTempString, _T(""));
  9378. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupConfig"), _T("PathFTPRoot"), &Context) )
  9379. {
  9380. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  9381. {
  9382. // WARNING: these values can be changed by a user supplied unattend file
  9383. // The User defined unattend file takes precidence over these!
  9384. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_PATH_FTP))
  9385. {
  9386. if (_tcsicmp(szTempString, _T("")) != 0)
  9387. {
  9388. if (IsValidDirectoryName(szTempString))
  9389. {
  9390. iisDebugOut((LOG_TYPE_TRACE, _T("Custom PathFTPRoot=%s\n"),szTempString));
  9391. CustomFTPRoot(szTempString);
  9392. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_PATH_FTP;
  9393. }
  9394. else
  9395. {
  9396. iisDebugOut((LOG_TYPE_WARN, _T("Custom PathFTPRoot specified (%s), however path not valid.ignoring unattend value. WARNING.\n"),szTempString));
  9397. }
  9398. }
  9399. }
  9400. }
  9401. }
  9402. //
  9403. // Get Path for www root
  9404. //
  9405. _tcscpy(szTempString, _T(""));
  9406. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupConfig"), _T("PathWWWRoot"), &Context) )
  9407. {
  9408. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  9409. {
  9410. // WARNING: these values can be changed by a user supplied unattend file
  9411. // The User defined unattend file takes precidence over these!
  9412. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_PATH_WWW))
  9413. {
  9414. if (_tcsicmp(szTempString, _T("")) != 0)
  9415. {
  9416. if (IsValidDirectoryName(szTempString))
  9417. {
  9418. iisDebugOut((LOG_TYPE_TRACE, _T("Custom PathWWWRoot=%s\n"),szTempString));
  9419. CustomWWWRoot(szTempString);
  9420. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_PATH_WWW;
  9421. }
  9422. else
  9423. {
  9424. iisDebugOut((LOG_TYPE_WARN, _T("Custom PathWWWRoot specified (%s), however path not valid.ignoring unattend value. WARNING.\n"),szTempString));
  9425. }
  9426. }
  9427. }
  9428. }
  9429. }
  9430. //ReadUserConfigurable_Exit:
  9431. if (dwSomethingSpecifiedHere & USER_SPECIFIED_INFO_WWW_USER_NAME){g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_WWW_USER_NAME;}
  9432. if (dwSomethingSpecifiedHere & USER_SPECIFIED_INFO_FTP_USER_NAME){g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_FTP_USER_NAME;}
  9433. if (dwSomethingSpecifiedHere & USER_SPECIFIED_INFO_WWW_USER_PASS){g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_WWW_USER_PASS;}
  9434. if (dwSomethingSpecifiedHere & USER_SPECIFIED_INFO_FTP_USER_PASS){g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_FTP_USER_PASS;}
  9435. return iReturn;
  9436. }
  9437. INT IsThisOnNotStopList(IN HINF hFile, CString csInputName, BOOL bServiceFlag)
  9438. {
  9439. INT iReturn = FALSE;
  9440. CStringList strList;
  9441. // if the entry is not a service name,
  9442. // then it must be a process filename,
  9443. // so make sure to get just the end of it
  9444. if (!bServiceFlag)
  9445. {
  9446. TCHAR szJustTheFileName[_MAX_FNAME];
  9447. // make sure to get only just the filename.
  9448. if (TRUE == ReturnFileNameOnly(csInputName, szJustTheFileName))
  9449. {
  9450. csInputName = szJustTheFileName;
  9451. }
  9452. }
  9453. CString csTheSection = _T("NonStopList");
  9454. if (GetSectionNameToDo(hFile, csTheSection))
  9455. {
  9456. if (ERROR_SUCCESS == FillStrListWithListOfSections(hFile, strList, csTheSection))
  9457. {
  9458. // loop thru the list returned back
  9459. if (strList.IsEmpty() == FALSE)
  9460. {
  9461. POSITION pos;
  9462. CString csEntry;
  9463. pos = strList.GetHeadPosition();
  9464. while (pos)
  9465. {
  9466. csEntry = strList.GetAt(pos);
  9467. // check if this entry matchs the entry that was passed in...
  9468. if (_tcsicmp(csEntry, csInputName) == 0)
  9469. {
  9470. // it matches so return TRUE;
  9471. iReturn = TRUE;
  9472. goto IsThisOnNotStopList_Exit;
  9473. }
  9474. strList.GetNext(pos);
  9475. }
  9476. }
  9477. }
  9478. }
  9479. IsThisOnNotStopList_Exit:
  9480. return iReturn;
  9481. }
  9482. HRESULT MofCompile(TCHAR * szPathMofFile)
  9483. {
  9484. HRESULT hRes = E_FAIL;
  9485. WCHAR wszFileName[_MAX_PATH];
  9486. IMofCompiler *pMofComp = NULL;
  9487. WBEM_COMPILE_STATUS_INFO Info;
  9488. hRes = CoInitialize(NULL);
  9489. if (FAILED(hRes))
  9490. {
  9491. goto MofCompile_Exit;
  9492. }
  9493. hRes = CoCreateInstance( CLSID_MofCompiler, NULL, CLSCTX_INPROC_SERVER, IID_IMofCompiler, (LPVOID *)&pMofComp);
  9494. if (FAILED(hRes))
  9495. {
  9496. goto MofCompile_Exit;
  9497. }
  9498. // Ensure that the string is WCHAR.
  9499. #if defined(UNICODE) || defined(_UNICODE)
  9500. _tcscpy(wszFileName, szPathMofFile);
  9501. #else
  9502. MultiByteToWideChar( CP_ACP, 0, szPathMofFile, -1, wszFileName, _MAX_PATH);
  9503. #endif
  9504. pMofComp->CompileFile (
  9505. (LPWSTR) wszFileName,
  9506. NULL, // load into namespace specified in MOF file
  9507. NULL, // use default User
  9508. NULL, // use default Authority
  9509. NULL, // use default Password
  9510. 0, // no options
  9511. 0, // no class flags
  9512. 0, // no instance flags
  9513. &Info);
  9514. pMofComp->Release();
  9515. CoUninitialize();
  9516. MofCompile_Exit:
  9517. return hRes;
  9518. }
  9519. DWORD DoesEntryPointExist(LPCTSTR lpszDLLFile, LPCTSTR lpszProcedure)
  9520. {
  9521. DWORD dwReturn = E_FAIL;
  9522. HINSTANCE hDll = NULL;
  9523. HCRET hProc = NULL;
  9524. TCHAR szDirName[_MAX_PATH], szFilePath[_MAX_PATH];
  9525. _tcscpy(szDirName, _T(""));
  9526. // Check if the file exists
  9527. if (!IsFileExist(lpszDLLFile))
  9528. {
  9529. dwReturn = ERROR_FILE_NOT_FOUND;
  9530. goto DoesEntryPointExist_Exit;
  9531. }
  9532. // Change Directory
  9533. GetCurrentDirectory( _MAX_PATH, szDirName );
  9534. InetGetFilePath(lpszDLLFile, szFilePath);
  9535. // Change to The Drive.
  9536. if (-1 == _chdrive( _totupper(szFilePath[0]) - 'A' + 1 )) {}
  9537. if (SetCurrentDirectory(szFilePath) == 0) {}
  9538. // Try to load the module,dll,ocx.
  9539. hDll = LoadLibraryEx(lpszDLLFile, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
  9540. if (!hDll)
  9541. {
  9542. dwReturn = TYPE_E_CANTLOADLIBRARY;
  9543. goto DoesEntryPointExist_Exit;
  9544. }
  9545. // Ok module was successfully loaded. now let's try to get the Address of the Procedure
  9546. // Convert the function name to ascii before passing it to GetProcAddress()
  9547. char AsciiProcedureName[255];
  9548. #if defined(UNICODE) || defined(_UNICODE)
  9549. // convert to ascii
  9550. WideCharToMultiByte( CP_ACP, 0, (TCHAR *)lpszProcedure, -1, AsciiProcedureName, 255, NULL, NULL );
  9551. #else
  9552. // the is already ascii so just copy
  9553. strcpy(AsciiProcedureName, lpszProcedure);
  9554. #endif
  9555. // see if the entry point exists...
  9556. hProc = (HCRET)GetProcAddress(hDll, AsciiProcedureName);
  9557. if (!hProc)
  9558. {
  9559. // failed to load,find or whatever this function.
  9560. dwReturn = ERROR_PROC_NOT_FOUND;
  9561. goto DoesEntryPointExist_Exit;
  9562. }
  9563. iisDebugOut((LOG_TYPE_TRACE, _T("DoesEntryPointExist:%s=true\n"),lpszProcedure));
  9564. dwReturn = ERROR_SUCCESS;
  9565. DoesEntryPointExist_Exit:
  9566. if (hDll){FreeLibrary(hDll);}
  9567. if (_tcscmp(szDirName, _T("")) != 0){SetCurrentDirectory(szDirName);}
  9568. return dwReturn;
  9569. }
  9570. void CreateDummyMetabaseBin(void)
  9571. {
  9572. TCHAR szFullPath1[_MAX_PATH];
  9573. TCHAR szFullPath2[_MAX_PATH];
  9574. HANDLE hfile = INVALID_HANDLE_VALUE;
  9575. DWORD dwBytesWritten = 0;
  9576. TCHAR buf[MAX_FAKE_METABASE_STRING_LEN];
  9577. BYTE bOneByte = 0;
  9578. // check if there is an existing metabase.bin
  9579. // if there is then rename it to a unique filename.
  9580. // if we cannot rename it because its in use or something, then leave it and get out.
  9581. _stprintf(szFullPath1, _T("%s\\metabase.bin"),g_pTheApp->m_csPathInetsrv);
  9582. if (IsFileExist(szFullPath1))
  9583. {
  9584. // Check to see how big it is.
  9585. DWORD dwFileSize = ReturnFileSize(szFullPath1);
  9586. if (dwFileSize != 0xFFFFFFFF)
  9587. {
  9588. // if it's less than 2k then it must be the fake file already (must be an upgrade)
  9589. // leave it alone and don't replace it with the dummy (since it already is the dummy)
  9590. if (dwFileSize < 2000)
  9591. {
  9592. return;
  9593. }
  9594. }
  9595. int iCount = 0;
  9596. int iFlag = FALSE;
  9597. do
  9598. {
  9599. // check if the new unique file name exists...
  9600. _stprintf(szFullPath2, _T("%s.dfu.%d"),szFullPath1,iCount);
  9601. if (!IsFileExist(szFullPath2))
  9602. {
  9603. iFlag = TRUE;
  9604. }
  9605. } while (iFlag == FALSE && iCount < 9999);
  9606. // this is a unique filename, so let's use it and
  9607. // rename the metabase.bin to it
  9608. if (!MoveFileEx(szFullPath1, szFullPath2, MOVEFILE_COPY_ALLOWED|MOVEFILE_WRITE_THROUGH|MOVEFILE_REPLACE_EXISTING))
  9609. {
  9610. // log the failure at least
  9611. iisDebugOut((LOG_TYPE_WARN, _T("CreateDummyMetabaseBin: unable to rename existing metabase.bin file\n")));
  9612. return;
  9613. }
  9614. }
  9615. // Create a unicode text file named metabase.bin
  9616. // and stick some sting into it (from our setup resource)
  9617. // should be localized when localization localizes the iis.dll
  9618. memset(buf, 0, _tcslen(buf) * sizeof(TCHAR));
  9619. // this iis.dll is always compiled unicode, so
  9620. // we know that buf is unicode
  9621. if (!LoadString((HINSTANCE) g_MyModuleHandle, IDS_FAKE_METABASE_BIN_TEXT, buf, MAX_FAKE_METABASE_STRING_LEN))
  9622. {
  9623. iisDebugOut((LOG_TYPE_WARN, _T("LoadString(%d) Failed.\n"), IDS_FAKE_METABASE_BIN_TEXT));
  9624. return;
  9625. }
  9626. DeleteFile(szFullPath1);
  9627. // create the new metabase.bin file
  9628. hfile = CreateFile((LPTSTR)szFullPath1, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  9629. if( hfile == INVALID_HANDLE_VALUE)
  9630. {
  9631. iisDebugOut((LOG_TYPE_WARN, _T("CreateDummyMetabaseBin:CreateFile on %s failed with 0x%x!\n"),szFullPath1,GetLastError()));
  9632. return;
  9633. }
  9634. // write a couple of bytes to the beginning of the file say that it's "unicode"
  9635. bOneByte = 0xFF;
  9636. WriteFile(hfile, (LPCVOID) &bOneByte, 1, &dwBytesWritten, NULL);
  9637. bOneByte = 0xFE;
  9638. WriteFile(hfile, (LPCVOID) &bOneByte, 1, &dwBytesWritten, NULL);
  9639. if ( WriteFile( hfile, buf, _tcslen(buf) * sizeof(TCHAR), &dwBytesWritten, NULL ) == FALSE )
  9640. {
  9641. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("WriteFile(%1!s!) Failed. Error=0x%2!x!.\n"), szFullPath1, GetLastError()));
  9642. }
  9643. CloseHandle(hfile);
  9644. return;
  9645. }
  9646. //
  9647. // Check whether we are running as administrator on the machine
  9648. // or not
  9649. //
  9650. BOOL RunningAsAdministrator()
  9651. {
  9652. #ifdef _CHICAGO_
  9653. return TRUE;
  9654. #else
  9655. BOOL fReturn = FALSE;
  9656. PSID psidAdmin;
  9657. DWORD err;
  9658. SID_IDENTIFIER_AUTHORITY SystemSidAuthority= SECURITY_NT_AUTHORITY;
  9659. if ( AllocateAndInitializeSid ( &SystemSidAuthority, 2,
  9660. SECURITY_BUILTIN_DOMAIN_RID,
  9661. DOMAIN_ALIAS_RID_ADMINS,
  9662. 0, 0, 0, 0, 0, 0, &psidAdmin) )
  9663. {
  9664. if (!CheckTokenMembership( NULL, psidAdmin, &fReturn )) {
  9665. err = GetLastError();
  9666. iisDebugOut((LOG_TYPE_ERROR, _T("CheckTokenMembership failed on err %d.\n"), err));
  9667. }
  9668. FreeSid ( psidAdmin);
  9669. }
  9670. return ( fReturn );
  9671. #endif //_CHICAGO_
  9672. }
  9673. void StopAllServicesRegardless(int iShowErrorsFlag)
  9674. {
  9675. #ifndef _CHICAGO_
  9676. // important: you must take iis clusters off line before doing anykind of upgrade\installs...
  9677. // but incase the user didn't do this... try to take them off line for the user
  9678. DWORD dwResult = ERROR_SUCCESS;
  9679. dwResult = BringALLIISClusterResourcesOffline();
  9680. if (StopServiceAndDependencies(_T("W3SVC"), FALSE) == FALSE)
  9681. {
  9682. if (iShowErrorsFlag)
  9683. {
  9684. MyMessageBox(NULL, IDS_UNABLE_TO_STOP_SERVICE,_T("W3SVC"), MB_OK | MB_SETFOREGROUND);
  9685. }
  9686. }
  9687. if (StopServiceAndDependencies(_T("MSFTPSVC"), FALSE) == FALSE)
  9688. {
  9689. if (iShowErrorsFlag)
  9690. {
  9691. MyMessageBox(NULL, IDS_UNABLE_TO_STOP_SERVICE,_T("MSFTPSVC"), MB_OK | MB_SETFOREGROUND);
  9692. }
  9693. }
  9694. if (StopServiceAndDependencies(_T("IISADMIN"), TRUE) == FALSE)
  9695. {
  9696. if (iShowErrorsFlag)
  9697. {
  9698. MyMessageBox(NULL, IDS_UNABLE_TO_STOP_SERVICE,_T("IISADMIN"), MB_OK | MB_SETFOREGROUND);
  9699. }
  9700. }
  9701. /*
  9702. DWORD dwStatus = 0;
  9703. dwStatus = InetQueryServiceStatus(_T("MSDTC"));
  9704. if (SERVICE_RUNNING == dwStatus)
  9705. {
  9706. // if the service is running, then let' stop it!
  9707. if (StopServiceAndDependencies(_T("MSDTC"), TRUE) == FALSE)
  9708. {
  9709. if (iShowErrorsFlag){MyMessageBox(NULL, IDS_UNABLE_TO_STOP_SERVICE,_T("MSDTC"), MB_OK | MB_SETFOREGROUND);}
  9710. }
  9711. }
  9712. */
  9713. /*
  9714. dwStatus = InetQueryServiceStatus(_T("SPOOLER"));
  9715. if (SERVICE_RUNNING == dwStatus)
  9716. {
  9717. // if the service is running, then let' stop it!
  9718. if (StopServiceAndDependencies(_T("SPOOLER"), TRUE) == FALSE)
  9719. {
  9720. if (iShowErrorsFlag){MyMessageBox(NULL, IDS_UNABLE_TO_STOP_SERVICE,_T("SPOOLER"), MB_OK | MB_SETFOREGROUND);}
  9721. }
  9722. }
  9723. */
  9724. #else
  9725. // Shutdown newer than 1.0 pws methods.
  9726. W95ShutdownW3SVC();
  9727. W95ShutdownIISADMIN( );
  9728. // Shutdown peer web services 1.0
  9729. HWND hwnd = FindWindow("MS_INetPeerServerWindowClass", NULL);
  9730. if ( hwnd )
  9731. {
  9732. ::PostMessage(hwnd,(WM_USER+305),(WPARAM)0,0L);
  9733. ::PostMessage(hwnd,(WM_USER+301),(WPARAM)-1,0L);
  9734. }
  9735. #endif
  9736. // kill pwstray.exe in case of IIS4.0 Beta2 upgrade, to release admprox.dll
  9737. HWND hwndTray = NULL;
  9738. hwndTray = FindWindow(PWS_TRAY_WINDOW_CLASS, NULL);
  9739. if ( hwndTray ){::PostMessage( hwndTray, WM_CLOSE, 0, 0 );}
  9740. return;
  9741. }