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

11475 lines
431 KiB

  1. #include "stdafx.h"
  2. #include "lzexpand.h"
  3. #include <loadperf.h>
  4. #include <ole2.h>
  5. #include <iis64.h>
  6. #include "iadmw.h"
  7. #include "iiscnfg.h"
  8. #include "mdkey.h"
  9. #include "mdentry.h"
  10. #include "mdacl.h"
  11. #include "dcomperm.h"
  12. #include "log.h"
  13. #include "other.h"
  14. #include "kill.h"
  15. #include "strfn.h"
  16. #include "shellutl.h"
  17. #include "svc.h"
  18. #include "setuser.h"
  19. #include "wolfpack.h"
  20. #include <wbemcli.h>
  21. #include <direct.h>
  22. #include <aclapi.h>
  23. #include <wincrypt.h>
  24. #include <Dsgetdc.h>
  25. #include "parse.hxx"
  26. // for backward compat
  27. #define PWS_TRAY_WINDOW_CLASS _T("PWS_TRAY_WINDOW")
  28. GUID g_FTPGuid = { 0x91604620, 0x6305, 0x11ce, 0xae, 0x00, 0x00, 0xaa, 0x00, 0x4a, 0x38, 0xb9 };
  29. GUID g_HTTPGuid = { 0x585908c0, 0x6305, 0x11ce, 0xae, 0x00, 0x00, 0xaa, 0x00, 0x4a, 0x38, 0xb9 };
  30. GUID g_InetInfoGuid = { 0xa5569b20, 0xabe5, 0x11ce, 0x9c, 0xa4, 0x00, 0x00, 0x4c, 0x75, 0x27, 0x31 };
  31. GUID g_GopherGuid = { 0x62388f10, 0x58a2, 0x11ce, 0xbe, 0xc8, 0x00, 0xaa, 0x00, 0x47, 0xae, 0x4e };
  32. // guid stuff
  33. #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 } }
  34. #define MY_DEFINE_OLEGUID(name, l, w1, w2) MY_DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)
  35. MY_DEFINE_OLEGUID(IID_IPersistFile, 0x0000010b, 0, 0);
  36. // must be defined after the guid stuff
  37. #include "shlobj.h"
  38. extern int g_GlobalGuiOverRide;
  39. extern int g_GlobalTickValue;
  40. extern int g_CheckIfMetabaseValueWasWritten;
  41. extern HSPFILEQ g_GlobalFileQueueHandle;
  42. extern int g_GlobalFileQueueHandle_ReturnError;
  43. const TCHAR PARSE_ERROR_ENTRY_TO_BIG[] = _T("ProcessEntry_Entry:ParseError:%1!s!:%2!s! -- entry to big. FAIL.\n");
  44. const TCHAR csz101_NOT_SPECIFIED[] = _T("%s():101 Required for this 100 type and not specified, fail. entry=%s. Section=%s.\n");
  45. const TCHAR csz102_NOT_SPECIFIED[] = _T("%s():102 Required for this 100 type and not specified, fail. entry=%s. Section=%s.\n");
  46. const TCHAR csz103_NOT_SPECIFIED[] = _T("%s():103 Required for this 100 type and not specified, fail. entry=%s. Section=%s.\n");
  47. const TCHAR csz104_NOT_SPECIFIED[] = _T("%s():104 Required for this 100 type and not specified, fail. entry=%s. Section=%s.\n");
  48. const TCHAR csz105_NOT_SPECIFIED[] = _T("%s():105 Required for this 100 type and not specified, fail. entry=%s. Section=%s.\n");
  49. const TCHAR csz805_NOT_SPECIFIED[] = _T("%s():805 Required for this 100 type and not specified, fail. entry=%s. Section=%s.\n");
  50. typedef struct _MTS_ERROR_CODE_STRUCT
  51. {
  52. int iMtsThingWeWereDoing;
  53. DWORD dwErrorCode;
  54. } MTS_ERROR_CODE_STRUCT;
  55. MTS_ERROR_CODE_STRUCT gTempMTSError;
  56. const TCHAR ThingToDoNumType_100[] = _T("100=");
  57. const TCHAR ThingToDoNumType_101[] = _T("101=");
  58. const TCHAR ThingToDoNumType_102[] = _T("102=");
  59. const TCHAR ThingToDoNumType_103[] = _T("103=");
  60. const TCHAR ThingToDoNumType_104[] = _T("104=");
  61. const TCHAR ThingToDoNumType_105[] = _T("105=");
  62. const TCHAR ThingToDoNumType_106[] = _T("106=");
  63. const TCHAR ThingToDoNumType_200[] = _T("200=");
  64. const TCHAR ThingToDoNumType_701[] = _T("701=");
  65. const TCHAR ThingToDoNumType_702[] = _T("702=");
  66. const TCHAR ThingToDoNumType_703[] = _T("703=");
  67. const TCHAR ThingToDoNumType_801[] = _T("801=");
  68. const TCHAR ThingToDoNumType_802[] = _T("802=");
  69. const TCHAR ThingToDoNumType_803[] = _T("803=");
  70. const TCHAR ThingToDoNumType_804[] = _T("804=");
  71. const TCHAR ThingToDoNumType_805[] = _T("805=");
  72. typedef struct _ThingToDo {
  73. TCHAR szType[20];
  74. TCHAR szFileName[_MAX_PATH];
  75. TCHAR szData1[_MAX_PATH + _MAX_PATH];
  76. TCHAR szData2[_MAX_PATH];
  77. TCHAR szData3[_MAX_PATH];
  78. TCHAR szData4[_MAX_PATH];
  79. TCHAR szChangeDir[_MAX_PATH];
  80. TCHAR szOS[10];
  81. TCHAR szPlatformArchitecture[10];
  82. TCHAR szEnterprise[10];
  83. TCHAR szErrIfFileNotFound[10];
  84. TCHAR szMsgBoxBefore[10];
  85. TCHAR szMsgBoxAfter[10];
  86. TCHAR szDoNotDisplayErrIfFunctionFailed[10];
  87. TCHAR szProgressTitle[100];
  88. } ThingToDo;
  89. extern OCMANAGER_ROUTINES gHelperRoutines;
  90. extern int g_GlobalDebugLevelFlag;
  91. extern int g_GlobalDebugLevelFlag_WasSetByUnattendFile;
  92. extern int g_GlobalDebugCallValidateHeap;
  93. extern int g_GlobalDebugCrypto;
  94. extern int g_GlobalFastLoad;
  95. // Our Global List of Warnings to display after setup is completed.
  96. CStringList gcstrListOfWarnings;
  97. CStringList gcstrProgressBarTextStack;
  98. CStringList gcstrListOfOleInits;
  99. #define FUNCTION_PARAMS_NONE 0
  100. #define FUNCTION_PARAMS_HMODULE 1
  101. #define MAX_FAKE_METABASE_STRING_LEN 500
  102. LCID g_MyTrueThreadLocale;
  103. DWORD WINAPI GetNewlyCreatedThreadLocale(LPVOID lpParameter)
  104. {
  105. g_MyTrueThreadLocale = GetThreadLocale ();
  106. return 0;
  107. }
  108. int CheckForWriteAccess(LPCTSTR szFile)
  109. {
  110. int iReturn = FALSE;
  111. // check if the file exists
  112. // if it doesn't then return true!
  113. if (IsFileExist(szFile) != TRUE)
  114. {
  115. // we've got write access!
  116. return TRUE;
  117. }
  118. // try to open the file for write; if we can't, the file is read-only
  119. HANDLE hFile = CreateFile(szFile, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
  120. if (hFile != INVALID_HANDLE_VALUE)
  121. {
  122. // we've got write access!
  123. iReturn = TRUE;
  124. CloseHandle (hFile);
  125. }
  126. return iReturn;
  127. }
  128. /////////////////////////////////////////////////////////////////////////////
  129. //++
  130. // Return Value:
  131. // TRUE - the operating system is NTS Enterprise
  132. // FALSE - the operating system is not correct.
  133. //--
  134. /////////////////////////////////////////////////////////////////////////////
  135. int iReturnTrueIfEnterprise(void)
  136. {
  137. BOOL fReturnValue;
  138. OSVERSIONINFOEX osiv;
  139. ZeroMemory( &osiv, sizeof( OSVERSIONINFOEX ) );
  140. osiv.dwOSVersionInfoSize = sizeof( OSVERSIONINFOEX );
  141. osiv.dwMajorVersion = 5;
  142. osiv.dwMinorVersion = 0;
  143. osiv.wServicePackMajor = 0;
  144. osiv.wSuiteMask = VER_SUITE_ENTERPRISE;
  145. DWORDLONG dwlConditionMask;
  146. dwlConditionMask = (DWORDLONG) 0L;
  147. VER_SET_CONDITION( dwlConditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL );
  148. VER_SET_CONDITION( dwlConditionMask, VER_MINORVERSION, VER_GREATER_EQUAL );
  149. VER_SET_CONDITION( dwlConditionMask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL );
  150. VER_SET_CONDITION( dwlConditionMask, VER_SUITENAME, VER_AND );
  151. fReturnValue = VerifyVersionInfo( &osiv,VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SUITENAME,dwlConditionMask );
  152. if ( fReturnValue != (BOOL) TRUE )
  153. {
  154. DWORD dwErrorCode = GetLastError();
  155. }
  156. return ( fReturnValue );
  157. }
  158. void GlobalOleInitList_Push(int iTrueOrFalse)
  159. {
  160. if (FALSE == iTrueOrFalse)
  161. {
  162. gcstrListOfOleInits.AddTail(_T("TRUE"));
  163. }
  164. else
  165. {
  166. gcstrListOfOleInits.AddTail(_T("FALSE"));
  167. }
  168. return;
  169. }
  170. int GlobalOleInitList_Find(void)
  171. {
  172. if (gcstrListOfOleInits.IsEmpty() == TRUE)
  173. {
  174. return FALSE;
  175. }
  176. return TRUE;
  177. }
  178. int GlobalOleInitList_Pop(void)
  179. {
  180. CString csText;
  181. if (gcstrListOfOleInits.IsEmpty() == FALSE)
  182. {
  183. csText = gcstrListOfWarnings.RemoveTail();
  184. if (_tcsicmp(csText, _T("TRUE")) == 0)
  185. {
  186. return TRUE;
  187. }
  188. }
  189. return FALSE;
  190. }
  191. void ProgressBarTextStack_Push(CString csText)
  192. {
  193. gcstrListOfWarnings.AddTail(csText);
  194. if (gHelperRoutines.OcManagerContext)
  195. {
  196. gHelperRoutines.SetProgressText(gHelperRoutines.OcManagerContext,csText);
  197. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("SetProgressText = %s\n"),csText));
  198. }
  199. return;
  200. }
  201. void ProgressBarTextStack_Push(LPTSTR szText)
  202. {
  203. CString csText = szText;
  204. ProgressBarTextStack_Push( csText );
  205. }
  206. void ProgressBarTextStack_Pop(void)
  207. {
  208. int iFoundLastEntry = FALSE;
  209. CString csText;
  210. // Get the last entry off of the stack and display it.
  211. if (gcstrListOfWarnings.IsEmpty() == FALSE)
  212. {
  213. csText = gcstrListOfWarnings.RemoveTail();
  214. if (gcstrListOfWarnings.IsEmpty() == FALSE)
  215. {
  216. csText = gcstrListOfWarnings.GetTail();
  217. if (csText)
  218. {
  219. iFoundLastEntry = TRUE;
  220. }
  221. }
  222. }
  223. if (iFoundLastEntry)
  224. {
  225. if (gHelperRoutines.OcManagerContext)
  226. {
  227. gHelperRoutines.SetProgressText(gHelperRoutines.OcManagerContext,csText);
  228. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("SetProgressText = %s\n"),csText));
  229. }
  230. }
  231. else
  232. {
  233. if (gHelperRoutines.OcManagerContext)
  234. {
  235. gHelperRoutines.SetProgressText(gHelperRoutines.OcManagerContext,_T(" "));
  236. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("SetProgressText = ' '\n")));
  237. }
  238. }
  239. return;
  240. }
  241. void ListOfWarnings_Add(TCHAR * szEntry)
  242. {
  243. //Add entry to the list of warnings if not already there
  244. if (_tcsicmp(szEntry, _T("")) != 0)
  245. {
  246. // Add it if it is not already there.
  247. if (TRUE != IsThisStringInThisCStringList(gcstrListOfWarnings, szEntry))
  248. {
  249. gcstrListOfWarnings.AddTail(szEntry);
  250. }
  251. }
  252. return;
  253. }
  254. void ListOfWarnings_Display(void)
  255. {
  256. if (gcstrListOfWarnings.IsEmpty() == FALSE)
  257. {
  258. iisDebugOut((LOG_TYPE_WARN, _T("************** WARNINGS START **************")));
  259. POSITION pos = NULL;
  260. CString csEntry;
  261. pos = gcstrListOfWarnings.GetHeadPosition();
  262. while (pos)
  263. {
  264. csEntry = gcstrListOfWarnings.GetAt(pos);
  265. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("%1!s!\n"), csEntry));
  266. gcstrListOfWarnings.GetNext(pos);
  267. }
  268. iisDebugOut((LOG_TYPE_WARN, _T("************** WARNINGS END **************")));
  269. }
  270. return;
  271. }
  272. int DebugLevelRegistryOveride(TCHAR * szSectionName, TCHAR * ValueName, int * iValueToSet)
  273. {
  274. int iReturn = FALSE;
  275. CRegKey regKey(HKEY_LOCAL_MACHINE, REG_INETSTP, KEY_READ);
  276. if ((HKEY)regKey)
  277. {
  278. // create the key to lookup
  279. // iis5_SectionName_ValueName
  280. // iis5_SetupInfo_
  281. if (szSectionName && ValueName)
  282. {
  283. TCHAR szTempRegString[255];
  284. DWORD dwValue = 0x0;
  285. _stprintf(szTempRegString, _T("IIS5:%s:%s"), szSectionName, ValueName);
  286. regKey.m_iDisplayWarnings = FALSE;
  287. if (regKey.QueryValue(szTempRegString, dwValue) == ERROR_SUCCESS)
  288. {
  289. if (dwValue <= 32000)
  290. {
  291. *iValueToSet = (int) dwValue;
  292. iReturn = TRUE;
  293. }
  294. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("RegistryINFValuesOveride:%s=%d."),szTempRegString, *iValueToSet));
  295. }
  296. }
  297. }
  298. return iReturn;
  299. }
  300. void GetDebugLevelFromInf(IN HINF hInfFileHandle)
  301. {
  302. int iTempDisplayLogging = FALSE;
  303. INFCONTEXT Context;
  304. TCHAR szTempString[10] = _T("");
  305. //
  306. // DebugLevel
  307. //
  308. if (!g_GlobalDebugLevelFlag_WasSetByUnattendFile)
  309. {
  310. iTempDisplayLogging = FALSE;
  311. g_GlobalDebugLevelFlag = LOG_TYPE_ERROR;
  312. if (SetupFindFirstLine_Wrapped(hInfFileHandle, _T("SetupInfo"), _T("DebugLevel"), &Context) )
  313. {
  314. SetupGetStringField(&Context, 1, szTempString, 10, NULL);
  315. if (IsValidNumber((LPCTSTR)szTempString))
  316. {
  317. g_GlobalDebugLevelFlag = _ttoi((LPCTSTR) szTempString);
  318. iTempDisplayLogging = TRUE;
  319. }
  320. if (g_GlobalDebugLevelFlag >= LOG_TYPE_TRACE_WIN32_API )
  321. {
  322. g_CheckIfMetabaseValueWasWritten = TRUE;
  323. }
  324. }
  325. if (DebugLevelRegistryOveride(_T("SetupInfo"), _T("DebugLevel"), &g_GlobalDebugLevelFlag))
  326. {iTempDisplayLogging = TRUE;}
  327. if (iTempDisplayLogging)
  328. {iisDebugOut((LOG_TYPE_TRACE, _T("DebugLevel=%d."),g_GlobalDebugLevelFlag));}
  329. }
  330. else
  331. {
  332. if (DebugLevelRegistryOveride(_T("SetupInfo"), _T("DebugLevel"), &g_GlobalDebugLevelFlag))
  333. {iTempDisplayLogging = TRUE;}
  334. if (iTempDisplayLogging)
  335. {iisDebugOut((LOG_TYPE_TRACE, _T("DebugLevel=%d."),g_GlobalDebugLevelFlag));}
  336. }
  337. //
  338. // DebugValidateHeap
  339. //
  340. iTempDisplayLogging = FALSE;
  341. g_GlobalDebugCallValidateHeap = TRUE;
  342. if (SetupFindFirstLine_Wrapped(hInfFileHandle, _T("SetupInfo"), _T("DebugValidateHeap"), &Context) )
  343. {
  344. SetupGetStringField(&Context, 1, szTempString, 10, NULL);
  345. if (IsValidNumber((LPCTSTR)szTempString))
  346. {
  347. g_GlobalDebugCallValidateHeap = _ttoi((LPCTSTR) szTempString);
  348. iTempDisplayLogging = TRUE;
  349. }
  350. }
  351. if (DebugLevelRegistryOveride(_T("SetupInfo"), _T("DebugValidateHeap"), &g_GlobalDebugCallValidateHeap))
  352. {iTempDisplayLogging = TRUE;}
  353. if (iTempDisplayLogging)
  354. {iisDebugOut((LOG_TYPE_TRACE, _T("DebugValidateHeap=%d."),g_GlobalDebugCallValidateHeap));}
  355. //
  356. // DebugCrypto
  357. //
  358. iTempDisplayLogging = FALSE;
  359. g_GlobalDebugCrypto = 0;
  360. if (SetupFindFirstLine_Wrapped(hInfFileHandle, _T("SetupInfo"), _T("DebugCrypto"), &Context) )
  361. {
  362. SetupGetStringField(&Context, 1, szTempString, 10, NULL);
  363. if (IsValidNumber((LPCTSTR)szTempString))
  364. {
  365. g_GlobalDebugCrypto = _ttoi((LPCTSTR) szTempString);
  366. iTempDisplayLogging = TRUE;
  367. }
  368. }
  369. if (DebugLevelRegistryOveride(_T("SetupInfo"), _T("DebugCrypto"), &g_GlobalDebugCrypto))
  370. {iTempDisplayLogging = TRUE;}
  371. if (iTempDisplayLogging)
  372. {iisDebugOut((LOG_TYPE_TRACE, _T("DebugCrypto=%d."),g_GlobalDebugCrypto));}
  373. //
  374. // FastDllInit
  375. //
  376. iTempDisplayLogging = FALSE;
  377. g_GlobalFastLoad = FALSE;
  378. if (SetupFindFirstLine_Wrapped(hInfFileHandle, _T("SetupInfo"), _T("FastDllInit"), &Context) )
  379. {
  380. SetupGetStringField(&Context, 1, szTempString, 10, NULL);
  381. if (IsValidNumber((LPCTSTR)szTempString))
  382. {
  383. g_GlobalFastLoad = _ttoi((LPCTSTR) szTempString);
  384. iTempDisplayLogging = TRUE;
  385. }
  386. }
  387. if (DebugLevelRegistryOveride(_T("SetupInfo"), _T("FastDllInit"), &g_GlobalFastLoad))
  388. {iTempDisplayLogging = TRUE;}
  389. if (iTempDisplayLogging)
  390. {iisDebugOut((LOG_TYPE_TRACE, _T("GlobalFastLoad=%d."),g_GlobalFastLoad));}
  391. //
  392. // Check if we should display messagebox popups
  393. //
  394. iTempDisplayLogging = FALSE;
  395. if (SetupFindFirstLine_Wrapped(hInfFileHandle, _T("SetupInfo"), _T("DisplayMsgbox"), &Context) )
  396. {
  397. SetupGetStringField(&Context, 1, szTempString, 10, NULL);
  398. if (IsValidNumber((LPCTSTR)szTempString))
  399. {
  400. int iTempNum = 0;
  401. iTempNum = _ttoi((LPCTSTR) szTempString);
  402. if (iTempNum > 0)
  403. {
  404. g_pTheApp->m_bAllowMessageBoxPopups = TRUE;
  405. iTempDisplayLogging = TRUE;
  406. }
  407. }
  408. }
  409. if (DebugLevelRegistryOveride(_T("SetupInfo"), _T("DisplayMsgbox"), &g_pTheApp->m_bAllowMessageBoxPopups))
  410. {iTempDisplayLogging = TRUE;}
  411. if (iTempDisplayLogging)
  412. {iisDebugOut((LOG_TYPE_TRACE, _T("DisplayMsgbox=%d."),g_pTheApp->m_bAllowMessageBoxPopups));}
  413. return;
  414. }
  415. //****************************************************************************
  416. //*
  417. //* This routine will center a dialog in the active windows.
  418. //*
  419. //* ENTRY:
  420. //* hwndDlg - Dialog window.
  421. //*
  422. //****************************************************************************
  423. void uiCenterDialog( HWND hwndDlg )
  424. {
  425. RECT rc;
  426. RECT rcScreen;
  427. int x, y;
  428. int cxDlg, cyDlg;
  429. int cxScreen;
  430. int cyScreen;
  431. SystemParametersInfo(SPI_GETWORKAREA, 0, &rcScreen, 0);
  432. cxScreen = rcScreen.right - rcScreen.left;
  433. cyScreen = rcScreen.bottom - rcScreen.top;
  434. GetWindowRect(hwndDlg,&rc);
  435. x = rc.left; // Default is to leave the dialog where the template
  436. y = rc.top; // was going to place it.
  437. cxDlg = rc.right - rc.left;
  438. cyDlg = rc.bottom - rc.top;
  439. y = rcScreen.top + ((cyScreen - cyDlg) / 2);
  440. x = rcScreen.left + ((cxScreen - cxDlg) / 2);
  441. // Position the dialog.
  442. SetWindowPos(hwndDlg, NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE);
  443. }
  444. /*
  445. //***************************************************************************
  446. //* *
  447. //* SYNOPSIS: Checks if a specific key in the given section and given file*
  448. //* is defined. IF so, get the value. OW return -1 *
  449. //* *
  450. //***************************************************************************
  451. DWORD IsMyKeyExists( LPCTSTR lpSec, LPCTSTR lpKey, LPTSTR lpBuf, UINT uSize, LPCTSTR lpFile )
  452. {
  453. DWORD dwRet;
  454. dwRet = GetPrivateProfileString( lpSec, lpKey, "ZZZZZZ", lpBuf, uSize, lpFile );
  455. if ( !lstrcmp( lpBuf, "ZZZZZZ" ) )
  456. {
  457. // no key defined
  458. dwRet = (DWORD)(-1);
  459. }
  460. return dwRet;
  461. }
  462. //***************************************************************************
  463. //
  464. // FormStrWithoutPlaceHolders( LPTSTR szDst, LPCTSTR szSrc, LPCTSTR lpFile );
  465. //
  466. // This function can be easily described by giving examples of what it
  467. // does:
  468. // Input: GenFormStrWithoutPlaceHolders(dest,"desc=%MS_XYZ%", hinf) ;
  469. // INF file has MS_VGA="Microsoft XYZ" in its [Strings] section!
  470. //
  471. // Output: "desc=Microsoft XYZ" in buffer dest when done.
  472. //
  473. //
  474. // ENTRY:
  475. // szDst - the destination where the string after the substitutions
  476. // for the place holders (the ones enclosed in "%' chars!)
  477. // is placed. This buffer should be big enough (LINE_LEN)
  478. // szSrc - the string with the place holders.
  479. //
  480. // EXIT:
  481. //
  482. // NOTES:
  483. // To use a '%' as such in the string, one would use %% in szSrc!
  484. // For the sake of simplicity, we have placed a restriction that the place
  485. // holder name string cannot have a '%' as part of it! If this is a problem
  486. // for internationalization, we can revisit this and support it too! Also,
  487. // the way it is implemented, if there is only one % in the string, it is
  488. // also used as such! Another point to note is that if the key is not
  489. // found in the [Strings] section, we just use the %strkey% as such in the
  490. // destination. This should really help in debugging.
  491. //
  492. // Get/modified it from setupx: gen1.c
  493. //***************************************************************************
  494. DWORD FormStrWithoutPlaceHolders( LPTSTR szDst, LPCTSTR szSrc, LPCTSTR lpFile)
  495. {
  496. int uCnt ;
  497. DWORD dwRet;
  498. TCHAR *pszTmp;
  499. LPTSTR pszSaveDst;
  500. pszSaveDst = szDst;
  501. // Do until we reach the end of source (null char)
  502. while( (*szDst++ = *szSrc) )
  503. {
  504. // Increment source as we have only incremented destination above
  505. if(*szSrc++ == '%')
  506. {
  507. if (*szSrc == '%')
  508. {
  509. // One can use %% to get a single percentage char in message
  510. szSrc++ ;
  511. continue ;
  512. }
  513. // see if it is well formed -- there should be a '%' delimiter
  514. if ( (pszTmp = strchr( szSrc, '%')) != NULL )
  515. {
  516. szDst--; // get back to the '%' char to replace
  517. // yes, there is a STR_KEY to be looked for in [Strings] sect.
  518. *pszTmp = '\0' ; // replace '%' with a NULL char
  519. dwRet = IsMyKeyExists( _T("Strings"), szSrc, szDst, _MAX_PATH, lpFile );
  520. if ( dwRet == -1 )
  521. {
  522. *pszTmp = '%'; // put back original character
  523. szSrc-- ; // get back to first '%' in Src
  524. uCnt = DIFF(pszTmp - szSrc) + 1; // include 2nd '%'
  525. // UGHHH... It copies 1 less byte from szSrc so that it can put
  526. // in a NULL character, that I don't care about!!!
  527. // Different from the normal API I am used to...
  528. lstrcpyn( szDst, szSrc, uCnt + 1 ) ;
  529. return (DWORD)-1;
  530. }
  531. else
  532. {
  533. // all was well, Dst filled right, but unfortunately count not passed
  534. // back, like it used too... :-( quick fix is a lstrlen()...
  535. uCnt = lstrlen( szDst ) ;
  536. }
  537. *pszTmp = '%' ; // put back original character
  538. szSrc = pszTmp + 1 ; // set Src after the second '%'
  539. szDst += uCnt ; // set Dst also right.
  540. }
  541. // else it is ill-formed -- we use the '%' as such!
  542. else
  543. {
  544. return (DWORD)-1;
  545. }
  546. }
  547. } // while
  548. return (DWORD)lstrlen(pszSaveDst);
  549. }
  550. */
  551. void LogImportantFiles(void)
  552. {
  553. TCHAR buf[_MAX_PATH];
  554. if (g_pTheApp->m_hInfHandle)
  555. {
  556. LogFileVersionsForGroupOfSections(g_pTheApp->m_hInfHandle);
  557. }
  558. // display current files in inetsrv date/version.
  559. CString csTempPath = g_pTheApp->m_csPathInetsrv;
  560. LogFilesInThisDir(csTempPath);
  561. // display the setup iis.dll file
  562. GetSystemDirectory( buf, _MAX_PATH);
  563. csTempPath = buf;
  564. csTempPath = AddPath(csTempPath, _T("iis.dll"));
  565. LogFileVersion(csTempPath, TRUE);
  566. return;
  567. }
  568. #ifndef _CHICAGO_
  569. int CreateIUSRAccount(CString csUsername, CString csPassword, INT* piNewlyCreatedUser)
  570. {
  571. int err;
  572. CString csComment, csFullName;
  573. INT iUserWasDeleted = 0;
  574. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("CreateIUSRAccount(): %1!s!\n"), csUsername));
  575. // delete the old user first
  576. //DeleteGuestUser((LPTSTR)(LPCTSTR)csUsername,&iUserWasDeleted);
  577. // create the new user
  578. MyLoadString(IDS_USER_COMMENT, csComment);
  579. MyLoadString(IDS_USER_FULLNAME, csFullName);
  580. // Create user either returns NERR_Success or err code
  581. err = CreateUser(csUsername, csPassword, csComment, csFullName, FALSE, piNewlyCreatedUser);
  582. if (err == NERR_Success)
  583. {iisDebugOut((LOG_TYPE_TRACE, _T("CreateIUSRAccount(): Return 0x%x Suceess\n"), err));}
  584. else
  585. {
  586. iisDebugOut((LOG_TYPE_ERROR, _T("CreateIUSRAccount(): Return Err=0x%x FAILURE. deleting and retrying.\n"), err));
  587. // try to delete it first then create it.
  588. DeleteGuestUser((LPTSTR)(LPCTSTR)csUsername,&iUserWasDeleted);
  589. err = CreateUser(csUsername, csPassword, csComment, csFullName, FALSE, piNewlyCreatedUser);
  590. iisDebugOut((LOG_TYPE_TRACE, _T("CreateIUSRAccount(): Return 0x%x\n"), err));
  591. }
  592. return err;
  593. }
  594. int CreateIWAMAccount(CString csUsername, CString csPassword,INT* piNewlyCreatedUser)
  595. {
  596. int err;
  597. CString csComment, csFullName;
  598. INT iUserWasDeleted = 0;
  599. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("CreateIWAMAccount(): %1!s!\n"), csUsername));
  600. //iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("CreateIWAMAccount(): %1!s!\n"), csPassword));
  601. // delete the old user first
  602. //DeleteGuestUser((LPTSTR)(LPCTSTR)csUsername,&iUserWasDeleted);
  603. // create the new user
  604. MyLoadString(IDS_WAMUSER_COMMENT, csComment);
  605. MyLoadString(IDS_WAMUSER_FULLNAME, csFullName);
  606. // Create user either returns NERR_Success or err code
  607. err = CreateUser(csUsername, csPassword, csComment, csFullName, TRUE, piNewlyCreatedUser);
  608. if (err == NERR_Success)
  609. {iisDebugOut((LOG_TYPE_TRACE, _T("CreateIWAMAccount(): Return 0x%x Suceess\n"), err));}
  610. else
  611. {
  612. iisDebugOut((LOG_TYPE_ERROR, _T("CreateIWAMAccount(): Return Err=0x%x FAILURE. deleting and retrying.\n"), err));
  613. // try to delete it first then create it.
  614. DeleteGuestUser((LPTSTR)(LPCTSTR)csUsername,&iUserWasDeleted);
  615. err = CreateUser(csUsername, csPassword, csComment, csFullName, TRUE, piNewlyCreatedUser);
  616. iisDebugOut((LOG_TYPE_TRACE, _T("CreateIWAMAccount(): Return 0x%x\n"), err));
  617. }
  618. return err;
  619. }
  620. #endif //_CHICAGO_
  621. INT InstallPerformance(CString nlsRegPerf,CString nlsDll,CString nlsOpen,CString nlsClose,CString nlsCollect )
  622. {
  623. iisDebugOut_Start1(_T("InstallPerformance"),nlsDll);
  624. INT err = NERR_Success;
  625. if (g_pTheApp->m_eOS != OS_W95)
  626. {
  627. CRegKey regPerf( nlsRegPerf, HKEY_LOCAL_MACHINE );
  628. if (regPerf)
  629. {
  630. regPerf.SetValue(_T("Library"), nlsDll );
  631. regPerf.SetValue(_T("Open"), nlsOpen );
  632. regPerf.SetValue(_T("Close"), nlsClose );
  633. regPerf.SetValue(_T("Collect"), nlsCollect );
  634. }
  635. }
  636. iisDebugOut_End1(_T("InstallPerformance"),nlsDll);
  637. return(err);
  638. }
  639. //
  640. // Add eventlog to the registry
  641. //
  642. INT AddEventLog(BOOL fSystem, CString nlsService, CString nlsMsgFile, DWORD dwType)
  643. {
  644. iisDebugOut_Start1(_T("AddEventLog"),nlsMsgFile);
  645. INT err = NERR_Success;
  646. CString nlsLog = (fSystem)? REG_EVENTLOG_SYSTEM : REG_EVENTLOG_APPLICATION;
  647. nlsLog += _T("\\");
  648. nlsLog += nlsService;
  649. CRegKey regService( nlsLog, HKEY_LOCAL_MACHINE );
  650. if ( regService )
  651. {
  652. regService.SetValue( _T("EventMessageFile"), nlsMsgFile, TRUE );
  653. regService.SetValue( _T("TypesSupported"), dwType );
  654. }
  655. iisDebugOut_End1(_T("AddEventLog"),nlsMsgFile);
  656. return(err);
  657. }
  658. //
  659. // Remove eventlog from the registry
  660. //
  661. INT RemoveEventLog( BOOL fSystem, CString nlsService )
  662. {
  663. iisDebugOut_Start1(_T("RemoveEventLog"),nlsService);
  664. INT err = NERR_Success;
  665. CString nlsLog = (fSystem)? REG_EVENTLOG_SYSTEM : REG_EVENTLOG_APPLICATION;
  666. CRegKey regService( HKEY_LOCAL_MACHINE, nlsLog );
  667. if ( regService )
  668. {
  669. regService.DeleteTree( nlsService );
  670. }
  671. iisDebugOut_End1(_T("RemoveEventLog"),nlsService);
  672. return(err);
  673. }
  674. //
  675. // Install SNMP agent to the registry
  676. //
  677. INT InstallAgent( CString nlsName, CString nlsPath )
  678. {
  679. iisDebugOut_Start1(_T("InstallAgent"),nlsPath);
  680. INT err = NERR_Success;
  681. do
  682. {
  683. CString nlsSnmpParam = REG_SNMPPARAMETERS;
  684. CRegKey regSnmpParam( HKEY_LOCAL_MACHINE, nlsSnmpParam );
  685. if ( regSnmpParam == (HKEY)NULL )
  686. break;
  687. CString nlsSoftwareMSFT = _T("Software\\Microsoft");
  688. CRegKey regSoftwareMSFT( HKEY_LOCAL_MACHINE, nlsSoftwareMSFT );
  689. if ( (HKEY) NULL == regSoftwareMSFT )
  690. break;
  691. // add agent key
  692. CRegKey regAgent( nlsName, regSoftwareMSFT );
  693. if ( (HKEY) NULL == regAgent )
  694. break;
  695. CString nlsCurVersion = _T("CurrentVersion");
  696. CRegKey regAgentCurVersion( nlsCurVersion, regAgent );
  697. if ((HKEY) NULL == regAgentCurVersion )
  698. break;
  699. regAgentCurVersion.SetValue(_T("Pathname"), nlsPath );
  700. CRegKey regAgentParam( nlsName, regSnmpParam );
  701. if ((HKEY) NULL == regAgentParam )
  702. break;
  703. CString nlsSnmpExt = REG_SNMPEXTAGENT;
  704. CRegKey regSnmpExt( nlsSnmpExt, HKEY_LOCAL_MACHINE );
  705. if ((HKEY) NULL == regSnmpExt )
  706. break;
  707. // find the first available number slot
  708. for ( INT i=0; ;i++ )
  709. {
  710. CString nlsPos;
  711. nlsPos.Format( _T("%d"),i);
  712. CString nlsValue;
  713. if ( regSnmpExt.QueryValue( nlsPos, nlsValue ) != NERR_Success )
  714. {
  715. // okay, an empty spot
  716. nlsValue.Format(_T("%s\\%s\\%s"),_T("Software\\Microsoft"),(LPCTSTR)nlsName,_T("CurrentVersion") );
  717. regSnmpExt.SetValue( nlsPos, nlsValue );
  718. break;
  719. } else
  720. {
  721. if ( nlsValue.Find( nlsName) != (-1))
  722. {
  723. break;
  724. }
  725. }
  726. }
  727. } while (FALSE);
  728. iisDebugOut_End1(_T("InstallAgent"),nlsPath);
  729. return(err);
  730. }
  731. //
  732. // Remove an SNMP agent from the registry
  733. //
  734. INT RemoveAgent( CString nlsServiceName )
  735. {
  736. iisDebugOut_Start1(_T("RemoveAgent"),nlsServiceName);
  737. INT err = NERR_Success;
  738. do
  739. {
  740. CString nlsSoftwareAgent = _T("Software\\Microsoft");
  741. CRegKey regSoftwareAgent( HKEY_LOCAL_MACHINE, nlsSoftwareAgent );
  742. if ((HKEY)NULL == regSoftwareAgent )
  743. break;
  744. regSoftwareAgent.DeleteTree( nlsServiceName );
  745. CString nlsSnmpParam = REG_SNMPPARAMETERS;
  746. CRegKey regSnmpParam( HKEY_LOCAL_MACHINE, nlsSnmpParam );
  747. if ((HKEY) NULL == regSnmpParam )
  748. break;
  749. regSnmpParam.DeleteTree( nlsServiceName );
  750. CString nlsSnmpExt = REG_SNMPEXTAGENT;
  751. CRegKey regSnmpExt( HKEY_LOCAL_MACHINE, nlsSnmpExt );
  752. if ((HKEY) NULL == regSnmpExt )
  753. break;
  754. CRegValueIter enumSnmpExt( regSnmpExt );
  755. CString strName;
  756. DWORD dwType;
  757. CString csServiceName;
  758. csServiceName = _T("\\") + nlsServiceName;
  759. csServiceName += _T("\\");
  760. while ( enumSnmpExt.Next( &strName, &dwType ) == NERR_Success )
  761. {
  762. CString nlsValue;
  763. regSnmpExt.QueryValue( strName, nlsValue );
  764. if ( nlsValue.Find( csServiceName ) != (-1))
  765. {
  766. // found it
  767. regSnmpExt.DeleteValue( (LPCTSTR)strName );
  768. break;
  769. }
  770. }
  771. } while (FALSE);
  772. iisDebugOut_End1(_T("RemoveAgent"),nlsServiceName);
  773. return(err);
  774. }
  775. void lodctr(LPCTSTR lpszIniFile)
  776. {
  777. #ifndef _CHICAGO_
  778. iisDebugOut_Start1(_T("lodctr"),lpszIniFile);
  779. CString csCmdLine = _T("lodctr ");
  780. csCmdLine += g_pTheApp->m_csSysDir;
  781. csCmdLine += _T("\\");
  782. csCmdLine += lpszIniFile;
  783. iisDebugOut_Start((_T("loadperf.dll:LoadPerfCounterTextStrings")));
  784. LoadPerfCounterTextStrings((LPTSTR)(LPCTSTR)csCmdLine, TRUE);
  785. iisDebugOut_End((_T("loadperf.dll:LoadPerfCounterTextStrings")));
  786. iisDebugOut_End1(_T("lodctr"),lpszIniFile);
  787. #endif
  788. return;
  789. }
  790. void unlodctr(LPCTSTR lpszDriver)
  791. {
  792. #ifndef _CHICAGO_
  793. iisDebugOut_Start1(_T("unlodctr"),lpszDriver);
  794. CString csCmdLine = _T("unlodctr ");
  795. csCmdLine += lpszDriver;
  796. iisDebugOut_Start(_T("loadperf.dll:UnloadPerfCounterTextStrings"));
  797. UnloadPerfCounterTextStrings((LPTSTR)(LPCTSTR)csCmdLine, TRUE);
  798. iisDebugOut_End((_T("loadperf.dll:UnloadPerfCounterTextStrings")));
  799. iisDebugOut_End1(_T("unlodctr"),lpszDriver);
  800. #endif
  801. return;
  802. }
  803. typedef void (*P_SslGenerateRandomBits)( PUCHAR pRandomData, LONG size );
  804. P_SslGenerateRandomBits ProcSslGenerateRandomBits = NULL;
  805. BOOL GenRandom(int *lpGoop, DWORD cbGoop)
  806. {
  807. BOOL fRet = FALSE;
  808. HCRYPTPROV hProv = 0;
  809. if (::CryptAcquireContext(&hProv,NULL,NULL,PROV_RSA_FULL,CRYPT_VERIFYCONTEXT))
  810. if (::CryptGenRandom(hProv,cbGoop,(BYTE *) lpGoop))
  811. {
  812. fRet = TRUE;
  813. }
  814. if (hProv) ::CryptReleaseContext(hProv,0);
  815. return fRet;
  816. }
  817. int GetRandomNum(void)
  818. {
  819. int RandomNum;
  820. UCHAR cRandomByte;
  821. RandomNum = rand();
  822. __try
  823. {
  824. // call the random number function
  825. if (!GenRandom(& RandomNum,1))
  826. {
  827. // if that fails then try this one...
  828. if ( ProcSslGenerateRandomBits != NULL )
  829. {
  830. (*ProcSslGenerateRandomBits)( &cRandomByte, 1 );
  831. RandomNum = cRandomByte;
  832. }
  833. }
  834. }
  835. __except(EXCEPTION_EXECUTE_HANDLER)
  836. {
  837. iisDebugOut((LOG_TYPE_WARN, _T("nException Caught in SCHANNEL.dll:ProcSslGenerateRandomBits()=0x%x.."),GetExceptionCode()));
  838. }
  839. return(RandomNum);
  840. }
  841. void ShuffleCharArray(int iSizeOfTheArray, TCHAR * lptsTheArray)
  842. {
  843. int i;
  844. int iTotal;
  845. int RandomNum;
  846. iTotal = iSizeOfTheArray / sizeof(_TCHAR);
  847. for (i=0; i<iTotal;i++ )
  848. {
  849. // shuffle the array
  850. RandomNum=GetRandomNum();
  851. TCHAR c = lptsTheArray[i];
  852. lptsTheArray[i]=lptsTheArray[RandomNum%iTotal];
  853. lptsTheArray[RandomNum%iTotal]=c;
  854. }
  855. return;
  856. }
  857. // password categories
  858. enum {STRONG_PWD_UPPER=0,
  859. STRONG_PWD_LOWER,
  860. STRONG_PWD_NUM,
  861. STRONG_PWD_PUNC};
  862. #define STRONG_PWD_CATS (STRONG_PWD_PUNC + 1)
  863. #define NUM_LETTERS 26
  864. #define NUM_NUMBERS 10
  865. #define MIN_PWD_LEN 8
  866. // password must contain at least one each of:
  867. // uppercase, lowercase, punctuation and numbers
  868. DWORD CreateGoodPassword(BYTE *szPwd, DWORD dwLen) {
  869. if (dwLen-1 < MIN_PWD_LEN)
  870. return ERROR_PASSWORD_RESTRICTION;
  871. HCRYPTPROV hProv;
  872. DWORD dwErr = 0;
  873. if (CryptAcquireContext(&hProv,NULL,NULL,PROV_RSA_FULL,CRYPT_VERIFYCONTEXT) == FALSE)
  874. return GetLastError();
  875. // zero it out and decrement the size to allow for trailing '\0'
  876. ZeroMemory(szPwd,dwLen);
  877. dwLen--;
  878. // generate a pwd pattern, each byte is in the range
  879. // (0..255) mod STRONG_PWD_CATS
  880. // this indicates which character pool to take a char from
  881. BYTE *pPwdPattern = new BYTE[dwLen];
  882. BOOL fFound[STRONG_PWD_CATS];
  883. do {
  884. // bug!bug! does CGR() ever fail?
  885. CryptGenRandom(hProv,dwLen,pPwdPattern);
  886. fFound[STRONG_PWD_UPPER] =
  887. fFound[STRONG_PWD_LOWER] =
  888. fFound[STRONG_PWD_PUNC] =
  889. fFound[STRONG_PWD_NUM] = FALSE;
  890. for (DWORD i=0; i < dwLen; i++)
  891. fFound[pPwdPattern[i] % STRONG_PWD_CATS] = TRUE;
  892. #ifdef _DEBUG
  893. if (!fFound[STRONG_PWD_UPPER] ||
  894. !fFound[STRONG_PWD_LOWER] ||
  895. !fFound[STRONG_PWD_PUNC] ||
  896. !fFound[STRONG_PWD_NUM]) {
  897. iisDebugOut((LOG_TYPE_TRACE,_T("Oops! Regen pattern required [%d, %d, %d, %d]\n"),
  898. fFound[STRONG_PWD_UPPER],
  899. fFound[STRONG_PWD_LOWER],
  900. fFound[STRONG_PWD_PUNC],
  901. fFound[STRONG_PWD_NUM]));
  902. }
  903. #endif
  904. // check that each character category is in the pattern
  905. } while (!fFound[STRONG_PWD_UPPER] ||
  906. !fFound[STRONG_PWD_LOWER] ||
  907. !fFound[STRONG_PWD_PUNC] ||
  908. !fFound[STRONG_PWD_NUM]);
  909. // populate password with random data
  910. // this, in conjunction with pPwdPattern, is
  911. // used to determine the actual data
  912. CryptGenRandom(hProv,dwLen,szPwd);
  913. for (DWORD i=0; i < dwLen; i++) {
  914. BYTE bChar = 0;
  915. // there is a bias in each character pool because of the % function
  916. switch (pPwdPattern[i] % STRONG_PWD_CATS) {
  917. case STRONG_PWD_UPPER : bChar = 'A' + szPwd[i] % NUM_LETTERS;
  918. break;
  919. case STRONG_PWD_LOWER : bChar = 'a' + szPwd[i] % NUM_LETTERS;
  920. break;
  921. case STRONG_PWD_NUM : bChar = '0' + szPwd[i] % NUM_NUMBERS;
  922. break;
  923. case STRONG_PWD_PUNC :
  924. default: char *szPunc="!@#$%^&*()_-+=[{]};:\'\"<>,./?\\|~`";
  925. DWORD dwLenPunc = lstrlenA(szPunc);
  926. bChar = szPunc[szPwd[i] % dwLenPunc];
  927. break;
  928. }
  929. szPwd[i] = bChar;
  930. #ifdef _DEBUG
  931. 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));
  932. #endif
  933. }
  934. delete pPwdPattern;
  935. if (hProv != NULL)
  936. CryptReleaseContext(hProv,0);
  937. return dwErr;
  938. }
  939. //
  940. // Create a random password
  941. //
  942. void CreatePasswordOld(TCHAR *pszPassword, int iSize)
  943. {
  944. //
  945. // Use Maximum available password length, as
  946. // setting any other length might run afoul
  947. // of the minimum password length setting
  948. //
  949. int nLength = (iSize - 1);
  950. int iTotal = 0;
  951. int RandomNum = 0;
  952. int i;
  953. TCHAR six2pr[64] =
  954. {
  955. _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'),
  956. _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'),
  957. _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'),
  958. _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'),
  959. _T('0'), _T('1'), _T('2'), _T('3'), _T('4'), _T('5'), _T('6'), _T('7'), _T('8'), _T('9'), _T('*'), _T('_')
  960. };
  961. // create a random password
  962. ProcSslGenerateRandomBits = NULL;
  963. HINSTANCE hSslDll = LoadLibraryEx(_T("schannel.dll"), NULL, 0 );
  964. if ( hSslDll )
  965. {
  966. ProcSslGenerateRandomBits = (P_SslGenerateRandomBits)GetProcAddress( hSslDll, "SslGenerateRandomBits");
  967. }
  968. else
  969. {
  970. // check if this file has missing file it's supposed to be linked with.
  971. // or if the file has mismatched import\export dependencies with linked files.
  972. #ifdef _WIN64
  973. // don't call cause it's broken
  974. #else
  975. //Check_File_Dependencies(_T("schannel.dll"));
  976. #endif
  977. }
  978. // See the random number generation for rand() call in GetRandomNum()
  979. time_t timer;
  980. time( &timer );
  981. srand( (unsigned int) timer );
  982. // shuffle around the global six2pr[] array
  983. ShuffleCharArray(sizeof(six2pr), (TCHAR*) &six2pr);
  984. // assign each character of the password array
  985. iTotal = sizeof(six2pr) / sizeof(_TCHAR);
  986. for ( i=0;i<nLength;i++ )
  987. {
  988. RandomNum=GetRandomNum();
  989. pszPassword[i]=six2pr[RandomNum%iTotal];
  990. }
  991. //
  992. // in order to meet a possible
  993. // policy set upon passwords..
  994. //
  995. // replace the last 4 chars with these:
  996. //
  997. // 1) something from !@#$%^&*()-+=
  998. // 2) something from 1234567890
  999. // 3) an uppercase letter
  1000. // 4) a lowercase letter
  1001. //
  1002. TCHAR something1[12] = {_T('!'), _T('@'), _T('#'), _T('$'), _T('^'), _T('&'), _T('*'), _T('('), _T(')'), _T('-'), _T('+'), _T('=')};
  1003. ShuffleCharArray(sizeof(something1), (TCHAR*) &something1);
  1004. TCHAR something2[10] = {_T('0'), _T('1'), _T('2'), _T('3'), _T('4'), _T('5'), _T('6'), _T('7'), _T('8'), _T('9')};
  1005. ShuffleCharArray(sizeof(something2),(TCHAR*) &something2);
  1006. 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')};
  1007. ShuffleCharArray(sizeof(something3),(TCHAR*) &something3);
  1008. 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')};
  1009. ShuffleCharArray(sizeof(something4),(TCHAR*)&something4);
  1010. RandomNum=GetRandomNum();
  1011. iTotal = sizeof(something1) / sizeof(_TCHAR);
  1012. pszPassword[nLength-4]=something1[RandomNum%iTotal];
  1013. RandomNum=GetRandomNum();
  1014. iTotal = sizeof(something2) / sizeof(_TCHAR);
  1015. pszPassword[nLength-3]=something2[RandomNum%iTotal];
  1016. RandomNum=GetRandomNum();
  1017. iTotal = sizeof(something3) / sizeof(_TCHAR);
  1018. pszPassword[nLength-2]=something3[RandomNum%iTotal];
  1019. RandomNum=GetRandomNum();
  1020. iTotal = sizeof(something4) / sizeof(_TCHAR);
  1021. pszPassword[nLength-1]=something4[RandomNum%iTotal];
  1022. pszPassword[nLength]=_T('\0');
  1023. if (hSslDll)
  1024. {FreeLibrary( hSslDll );}
  1025. }
  1026. // Creates a secure password
  1027. // caller must GlobalFree Return pointer
  1028. // iSize = size of password to create
  1029. LPTSTR CreatePassword(int iSize)
  1030. {
  1031. LPTSTR pszPassword = NULL;
  1032. BYTE *szPwd = new BYTE[iSize];
  1033. DWORD dwPwdLen = iSize;
  1034. int i = 0;
  1035. // use the new secure password generator
  1036. // unfortunately this baby doesn't use unicode.
  1037. // so we'll call it and then convert it to unicode afterwards.
  1038. if (0 == CreateGoodPassword(szPwd,dwPwdLen))
  1039. {
  1040. #if defined(UNICODE) || defined(_UNICODE)
  1041. // convert it to unicode and copy it back into our unicode buffer.
  1042. // compute the length
  1043. i = MultiByteToWideChar(CP_ACP, 0, (LPSTR) szPwd, -1, NULL, 0);
  1044. if (i <= 0)
  1045. {goto CreatePassword_Exit;}
  1046. pszPassword = (LPTSTR) GlobalAlloc(GPTR, i * sizeof(TCHAR));
  1047. if (!pszPassword)
  1048. {goto CreatePassword_Exit;}
  1049. i = MultiByteToWideChar(CP_ACP, 0, (LPSTR) szPwd, -1, pszPassword, i);
  1050. if (i <= 0)
  1051. {
  1052. GlobalFree(pszPassword);
  1053. pszPassword = NULL;
  1054. goto CreatePassword_Exit;
  1055. }
  1056. // make sure ends with null
  1057. pszPassword[i - 1] = 0;
  1058. #else
  1059. pszPassword = (LPSTR) GlobalAlloc(GPTR, _tcslen((LPTSTR) szPwd) * sizeof(TCHAR));
  1060. #endif
  1061. }
  1062. else
  1063. {
  1064. iisDebugOut((LOG_TYPE_WARN,_T("CreateGoodPassword FAILED, using other password generator\n")));
  1065. // CreateGoodPassword failed...
  1066. // lets go with one that we know works...
  1067. pszPassword = (LPTSTR) GlobalAlloc(GPTR, iSize * sizeof(TCHAR));
  1068. if (!pszPassword)
  1069. {goto CreatePassword_Exit;}
  1070. CreatePasswordOld(pszPassword,iSize);
  1071. }
  1072. CreatePassword_Exit:
  1073. if (szPwd){delete szPwd;szPwd=NULL;}
  1074. return pszPassword;
  1075. }
  1076. BOOL RunProgram( LPCTSTR pszProgram, LPTSTR CmdLine, BOOL fMinimized , DWORD dwWaitTimeInSeconds, BOOL fCreateNewConsole)
  1077. {
  1078. DWORD dwProcessType = NORMAL_PRIORITY_CLASS;
  1079. STARTUPINFO si;
  1080. ZeroMemory(&si, sizeof(STARTUPINFO));
  1081. si.cb = sizeof( STARTUPINFO );
  1082. if (fMinimized)
  1083. {
  1084. GetStartupInfo(&si);
  1085. si.dwFlags |= STARTF_USESHOWWINDOW;
  1086. si.wShowWindow = SW_HIDE;
  1087. // Per bug #321409
  1088. // if you don't specify sw_hide, then this
  1089. // "accessibility magnifier" app will get funky focus events during setup
  1090. // from this CreateProcess.
  1091. //si.wShowWindow = SW_SHOWMINIMIZED;
  1092. }
  1093. PROCESS_INFORMATION pi;
  1094. if (fCreateNewConsole)
  1095. {
  1096. dwProcessType = CREATE_NEW_CONSOLE | NORMAL_PRIORITY_CLASS;
  1097. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("RunProgram:Start:Exe=%1!s!,Parm=%2!s!,NewConsole"),pszProgram, CmdLine)); }
  1098. else
  1099. {
  1100. // for some reason, a cmd window pops up during setup when we call "iisreset.exe /scm"
  1101. // only way to prevent this is specify DETACHED_PROCESS
  1102. dwProcessType = DETACHED_PROCESS | NORMAL_PRIORITY_CLASS;
  1103. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("RunProgram:Start:Exe=%1!s!,Parm=%2!s!"),pszProgram, CmdLine));
  1104. }
  1105. if (!CreateProcess( pszProgram, CmdLine, NULL, NULL, FALSE, dwProcessType, NULL, NULL, &si, &pi ))
  1106. {
  1107. iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("RunProgram:Failed:Exe=%1!s!\n, Parm=%2!s!"),pszProgram, CmdLine));
  1108. return FALSE;
  1109. }
  1110. if ( pi.hProcess != NULL )
  1111. {
  1112. DWORD dwSecondsToWait;
  1113. if (dwWaitTimeInSeconds == INFINITE)
  1114. {
  1115. dwSecondsToWait = INFINITE;
  1116. }
  1117. else
  1118. {
  1119. dwSecondsToWait = dwWaitTimeInSeconds * 1000;
  1120. }
  1121. DWORD dwEvent = WaitForSingleObject( pi.hProcess, dwSecondsToWait);
  1122. if ( dwEvent != ERROR_SUCCESS )
  1123. {
  1124. // check if wait failed
  1125. if ( dwEvent == WAIT_FAILED )
  1126. {iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("RunProgram:WaitForSingleObject() ERROR.WAIT_FAILED.Err=0x%1!x!."),GetLastError()));}
  1127. else if ( dwEvent == WAIT_ABANDONED )
  1128. {iisDebugOutSafeParams((LOG_TYPE_WARN, _T("RunProgram:WaitForSingleObject() WARNING.WAIT_ABANDONED.Err=0x%1!x!."),dwEvent));}
  1129. else if ( dwEvent == WAIT_OBJECT_0 )
  1130. {iisDebugOutSafeParams((LOG_TYPE_WARN, _T("RunProgram:WaitForSingleObject() WARNING.WAIT_OBJECT_0.Err=0x%1!x!."),dwEvent));}
  1131. else if ( dwEvent == WAIT_TIMEOUT )
  1132. {iisDebugOutSafeParams((LOG_TYPE_WARN, _T("RunProgram:WaitForSingleObject() WARNING.WAIT_TIMEOUT.Err=0x%1!x!."),dwEvent));}
  1133. else
  1134. {iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("RunProgram:WaitForSingleObject() FAILED.Err=0x%1!x!."),dwEvent));}
  1135. TerminateProcess( pi.hProcess, 1 );
  1136. CloseHandle( pi.hThread );
  1137. }
  1138. CloseHandle( pi.hProcess );
  1139. }
  1140. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("RunProgram:End:Exe=%1!s!,Parm=%2!s!"),pszProgram, CmdLine));
  1141. return TRUE;
  1142. }
  1143. void SetAppFriendlyName(LPCTSTR szKeyPath)
  1144. {
  1145. CString csKeyPath, csPath, csDesc;
  1146. CStringArray aPath, aDesc;
  1147. int nArray = 0, i = 0;
  1148. CMDKey cmdKey;
  1149. // szKeyPath is in the form of LM/W3SVC/i
  1150. csKeyPath = szKeyPath;
  1151. csPath = csKeyPath + _T("/Root");
  1152. aPath.Add(csPath);
  1153. MyLoadString(IDS_APP_FRIENDLY_ROOT, csDesc);
  1154. aDesc.Add(csDesc);
  1155. csPath = csKeyPath + _T("/Root/IISADMIN");
  1156. aPath.Add(csPath);
  1157. MyLoadString(IDS_APP_FRIENDLY_IISADMIN, csDesc);
  1158. aDesc.Add(csDesc);
  1159. csPath = csKeyPath + _T("/Root/WEBPUB");
  1160. aPath.Add(csPath);
  1161. MyLoadString(IDS_APP_FRIENDLY_WEBPUB, csDesc);
  1162. aDesc.Add(csDesc);
  1163. csPath = csKeyPath + _T("/Root/IISSAMPLES");
  1164. aPath.Add(csPath);
  1165. MyLoadString(IDS_APP_FRIENDLY_IISSAMPLES, csDesc);
  1166. aDesc.Add(csDesc);
  1167. csPath = csKeyPath + _T("/Root/IISHELP");
  1168. aPath.Add(csPath);
  1169. MyLoadString(IDS_APP_FRIENDLY_IISHELP, csDesc);
  1170. aDesc.Add(csDesc);
  1171. nArray = (int)aPath.GetSize();
  1172. for (i=0; i<nArray; i++)
  1173. {
  1174. cmdKey.OpenNode(aPath[i]);
  1175. if ( (METADATA_HANDLE)cmdKey )
  1176. {
  1177. CString csName;
  1178. TCHAR szName[_MAX_PATH];
  1179. DWORD attr, uType, dType, cbLen;
  1180. BOOL b;
  1181. b = cmdKey.GetData(MD_APP_FRIENDLY_NAME, &attr, &uType, &dType, &cbLen, (PBYTE)szName, _MAX_PATH);
  1182. if (!b || !(*szName))
  1183. {
  1184. csName = aDesc[i];
  1185. cmdKey.SetData(MD_APP_FRIENDLY_NAME,METADATA_INHERIT,IIS_MD_UT_WAM,STRING_METADATA,(csName.GetLength() + 1) * sizeof(TCHAR),(LPBYTE)(LPCTSTR)csName);
  1186. }
  1187. cmdKey.Close();
  1188. }
  1189. }
  1190. return;
  1191. }
  1192. void SetInProc( LPCTSTR szKeyPath)
  1193. {
  1194. CString csKeyPath, csPath;
  1195. CStringArray aPath;
  1196. int nArray = 0, i = 0;
  1197. CMDKey cmdKey;
  1198. // szKeyPath is in the form of LM/W3SVC/i
  1199. csKeyPath = szKeyPath;
  1200. csPath = csKeyPath + _T("/Root/IISSAMPLES");
  1201. aPath.Add(csPath);
  1202. csPath = csKeyPath + _T("/Root/IISHELP");
  1203. aPath.Add(csPath);
  1204. csPath = csKeyPath + _T("/Root/WEBPUB");
  1205. aPath.Add(csPath);
  1206. nArray = (int)aPath.GetSize();
  1207. for (i=0; i<nArray; i++) {
  1208. cmdKey.OpenNode(aPath[i]);
  1209. if ( (METADATA_HANDLE)cmdKey )
  1210. {
  1211. CString csName;
  1212. TCHAR szName[_MAX_PATH];
  1213. DWORD attr, uType, dType, cbLen;
  1214. BOOL b;
  1215. b = cmdKey.GetData(MD_APP_ROOT, &attr, &uType, &dType, &cbLen, (PBYTE)szName, _MAX_PATH);
  1216. cmdKey.Close();
  1217. if (!b || !(*szName))
  1218. {
  1219. CreateInProc_Wrap(aPath[i], TRUE);
  1220. }
  1221. }
  1222. }
  1223. return;
  1224. }
  1225. //------------------------------------------------------------------------------
  1226. // Add a custom error string to the existing custom errors. We are only adding FILE type
  1227. // error so that is assumed.
  1228. // dwCustErr is the ID of the error
  1229. // intSubCode is the sub code of the error. Pass in -1 to get a * for all subcodes
  1230. // szFilePath is the file to link to the custom error
  1231. // szKeyPath is the path in the metabase to write to
  1232. //#define SZ_CUSTOM_ERROR _T("404,*,FILE,%s\\help\\iishelp\\common\\404.htm|")
  1233. void AddCustomError(IN DWORD dwCustErr, IN INT intSubCode, IN LPCTSTR szErrorString, IN LPCTSTR szKeyPath, IN BOOL fOverwriteExisting )
  1234. {
  1235. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("AddCustomError().Start.%d:%d:%s:%s:%d\n"),dwCustErr,intSubCode,szErrorString,szKeyPath,fOverwriteExisting ));
  1236. CMDKey cmdKey;
  1237. PVOID pData = NULL;
  1238. BOOL fFoundExisting = FALSE;
  1239. CString csCustomErrorString;
  1240. // start by building our new error string
  1241. // if intSubCode is < 1 use a * instead of a numerical value
  1242. if ( intSubCode < 0 )
  1243. csCustomErrorString.Format( _T("%d,*,%s"), dwCustErr, szErrorString );
  1244. else
  1245. csCustomErrorString.Format( _T("%d,%d,%s"), dwCustErr, intSubCode, szErrorString );
  1246. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("AddCustomError().part1:%s\n"),csCustomErrorString));
  1247. cmdKey.OpenNode(szKeyPath);
  1248. if ( (METADATA_HANDLE)cmdKey )
  1249. {
  1250. DWORD dwAttr = METADATA_INHERIT;
  1251. DWORD dwUType = IIS_MD_UT_FILE;
  1252. DWORD dwDType = MULTISZ_METADATA;
  1253. DWORD dwLength = 0;
  1254. // we need to start this process by getting the existing multisz data from the metabase
  1255. // first, figure out how much memory we will need to do this
  1256. if (_tcsicmp(szKeyPath,_T("LM/W3SVC/Info")) == 0)
  1257. {
  1258. dwAttr = METADATA_NO_ATTRIBUTES;
  1259. dwUType = IIS_MD_UT_SERVER;
  1260. cmdKey.GetData( MD_CUSTOM_ERROR_DESC,&dwAttr,&dwUType,&dwDType,&dwLength,NULL,0,METADATA_NO_ATTRIBUTES,IIS_MD_UT_SERVER,MULTISZ_METADATA);
  1261. }
  1262. else
  1263. {
  1264. cmdKey.GetData( MD_CUSTOM_ERROR,&dwAttr,&dwUType,&dwDType,&dwLength,NULL,0,METADATA_INHERIT,IIS_MD_UT_FILE,MULTISZ_METADATA);
  1265. }
  1266. // unfortunatly, the above routine only returns TRUE or FALSE. And since we are purposefully
  1267. // passing in a null ponter of 0 size in order to get the length of the data, it will always
  1268. // return 0 whether it was because the metabase is inacessable, or there pointer was NULL,
  1269. // which it is. So - I guess we assume it worked, allocate the buffer and attempt to read it
  1270. // in again.
  1271. TCHAR* pErrors;
  1272. DWORD cbBuffer = dwLength;
  1273. // add enough space to the allocated space that we can just append the string
  1274. cbBuffer += (csCustomErrorString.GetLength() + 4) * sizeof(WCHAR);
  1275. dwLength = cbBuffer;
  1276. // allocate the space, if it fails, we fail
  1277. // note that GPTR causes it to be initialized to zero
  1278. pData = GlobalAlloc( GPTR, cbBuffer );
  1279. if ( !pData )
  1280. {
  1281. cmdKey.Close();
  1282. return;
  1283. }
  1284. pErrors = (TCHAR*)pData;
  1285. // now get the data from the metabase
  1286. BOOL f;
  1287. if (_tcsicmp(szKeyPath,_T("LM/W3SVC/Info")) == 0)
  1288. {
  1289. f = cmdKey.GetData( MD_CUSTOM_ERROR_DESC,&dwAttr,&dwUType,&dwDType,&dwLength,(PUCHAR)pData,cbBuffer,METADATA_NO_ATTRIBUTES,IIS_MD_UT_SERVER,MULTISZ_METADATA );
  1290. }
  1291. else
  1292. {
  1293. f = cmdKey.GetData( MD_CUSTOM_ERROR,&dwAttr,&dwUType,&dwDType,&dwLength,(PUCHAR)pData,cbBuffer,METADATA_INHERIT,IIS_MD_UT_FILE,MULTISZ_METADATA );
  1294. }
  1295. // if we have successfully retrieved the existing custom errors, then we need to scan them
  1296. // and remove or find any duplicates. Then we can add our new custom error. Then we can write it
  1297. // out. If we didn't retrieve it, then we should just try to write out what we have.
  1298. if ( f )
  1299. {
  1300. // got the existing errors, scan them now - pErrors will be pointing at the second end \0
  1301. // when it is time to exit the loop.
  1302. while ( *pErrors )
  1303. {
  1304. CString csError = pErrors;
  1305. CString cs;
  1306. DWORD dwTestErrorID;
  1307. INT intTestSubCode;
  1308. // get the first error ID code
  1309. cs = csError.Left( csError.Find(_T(',')) );
  1310. csError = csError.Right( csError.GetLength() - (cs.GetLength() +1) );
  1311. _stscanf( cs, _T("%d"), &dwTestErrorID );
  1312. // get the second code
  1313. cs = csError.Left( csError.Find(_T(',')) );
  1314. if ( cs == _T('*') )
  1315. intTestSubCode = -1;
  1316. else
  1317. _stscanf( cs, _T("%d"), &intTestSubCode );
  1318. // if it is the same, then chop off this custom error string and do NOT increment pErrors
  1319. if ( (dwTestErrorID == dwCustErr) && (intTestSubCode == intSubCode) )
  1320. {
  1321. fFoundExisting = TRUE;
  1322. // NOTE: if we are not overwriting existing, then just break because we
  1323. // won't be doing anything after all - we found an existing one
  1324. if ( !fOverwriteExisting )
  1325. {
  1326. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("AddCustomError().Do not overwritexisting\n")));
  1327. break;
  1328. }
  1329. // get the location of the next string in the multisz
  1330. TCHAR* pNext = _tcsninc( pErrors, _tcslen(pErrors))+1;
  1331. // Get the length of the data to copy
  1332. DWORD cbCopyLength = cbBuffer - DIFF((PBYTE)pNext - (PBYTE)pData);
  1333. // copy the memory down.
  1334. MoveMemory( pErrors, pNext, cbCopyLength );
  1335. // do not increment the string
  1336. continue;
  1337. }
  1338. // increment pErrors to the next string
  1339. pErrors = _tcsninc( pErrors, _tcslen(pErrors))+1;
  1340. }
  1341. }
  1342. // check if we need to finish this or not
  1343. if ( fOverwriteExisting || !fFoundExisting )
  1344. {
  1345. // append our new error to the end of the list. The value pErrors should be pointing
  1346. // to the correct location to copy it in to
  1347. _tcscpy( pErrors, csCustomErrorString );
  1348. // calculate the correct data length for this thing
  1349. // get the location of the end of the multisz
  1350. TCHAR* pNext = _tcsninc( pErrors, _tcslen(pErrors))+2;
  1351. // Get the length of the data to copy
  1352. cbBuffer = DIFF((PBYTE)pNext - (PBYTE)pData);
  1353. // write the new errors list back out to the metabase
  1354. if (_tcsicmp(szKeyPath,_T("LM/W3SVC/Info")) == 0)
  1355. {
  1356. cmdKey.SetData(MD_CUSTOM_ERROR_DESC,METADATA_NO_ATTRIBUTES,IIS_MD_UT_SERVER,MULTISZ_METADATA,cbBuffer,(PUCHAR)pData);
  1357. }
  1358. else
  1359. {
  1360. cmdKey.SetData(MD_CUSTOM_ERROR,METADATA_INHERIT,IIS_MD_UT_FILE,MULTISZ_METADATA,cbBuffer,(PUCHAR)pData);
  1361. }
  1362. }
  1363. else
  1364. {
  1365. //
  1366. //
  1367. //
  1368. }
  1369. // always close the metabase key
  1370. cmdKey.Close();
  1371. }
  1372. else
  1373. {
  1374. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("AddCustomError().OpenNode failed:%s\n"),szKeyPath));
  1375. }
  1376. // clean up
  1377. if ( pData ){GlobalFree(pData);pData=NULL;}
  1378. iisDebugOut_End((_T("AddCustomError")));
  1379. return;
  1380. }
  1381. ScriptMapNode *AllocNewScriptMapNode(LPTSTR szExt, LPTSTR szProcessor, DWORD dwFlags, LPTSTR szMethods)
  1382. {
  1383. ScriptMapNode *pNew = NULL;
  1384. pNew = (ScriptMapNode *)calloc(1, sizeof(ScriptMapNode));
  1385. if (pNew)
  1386. {
  1387. _tcscpy(pNew->szExt, szExt);
  1388. _tcscpy(pNew->szProcessor, szProcessor);
  1389. pNew->dwFlags = dwFlags;
  1390. _tcscpy(pNew->szMethods, szMethods);
  1391. pNew->prev = NULL;
  1392. pNew->next = NULL;
  1393. }
  1394. return pNew;
  1395. }
  1396. //
  1397. // The script map should not be sored because
  1398. // the order is infact important.
  1399. void InsertScriptMapList(ScriptMapNode *pList, ScriptMapNode *p, BOOL fReplace)
  1400. {
  1401. ScriptMapNode *t;
  1402. int i;
  1403. int bFound = FALSE;
  1404. if (!p) {return;}
  1405. #ifdef SCRIPTMAP_SORTED
  1406. t = pList->next;
  1407. while (t != pList)
  1408. {
  1409. i = _tcsicmp(t->szExt, p->szExt);
  1410. // if the next entry in the list is less than what we have.
  1411. // then
  1412. if (i < 0)
  1413. {
  1414. t = t->next;
  1415. // continue
  1416. }
  1417. if (i == 0)
  1418. {
  1419. if (fReplace)
  1420. {
  1421. // replace t
  1422. p->next = t->next;
  1423. p->prev = t->prev;
  1424. (t->prev)->next = p;
  1425. (t->next)->prev = p;
  1426. free(t);
  1427. }
  1428. else
  1429. {
  1430. // don't replace t
  1431. free(p);
  1432. }
  1433. return;
  1434. }
  1435. if (i > 0)
  1436. {
  1437. // location found: insert before t
  1438. break;
  1439. }
  1440. }
  1441. // insert before t
  1442. p->next = t;
  1443. p->prev = t->prev;
  1444. (t->prev)->next = p;
  1445. t->prev = p;
  1446. #else
  1447. // loop thru the whole list and see if we can find our entry.
  1448. // if we cannot find it then add it to the end.
  1449. // if we can find it then replace it if we need to.
  1450. bFound = FALSE;
  1451. t = pList->next;
  1452. while (t != pList)
  1453. {
  1454. i = _tcsicmp(t->szExt, p->szExt);
  1455. // we found a match, do replace or don't replace
  1456. if (i == 0)
  1457. {
  1458. bFound = TRUE;
  1459. if (fReplace)
  1460. {
  1461. // replace t
  1462. p->next = t->next;
  1463. p->prev = t->prev;
  1464. (t->prev)->next = p;
  1465. (t->next)->prev = p;
  1466. free(t);
  1467. }
  1468. else
  1469. {
  1470. // don't replace t
  1471. free(p);
  1472. }
  1473. return;
  1474. }
  1475. // Go get the next one
  1476. t = t->next;
  1477. }
  1478. // see if we found something
  1479. if (FALSE == bFound)
  1480. {
  1481. // insert before t
  1482. p->next = t;
  1483. p->prev = t->prev;
  1484. (t->prev)->next = p;
  1485. t->prev = p;
  1486. }
  1487. #endif
  1488. return;
  1489. }
  1490. void FreeScriptMapList(ScriptMapNode *pList)
  1491. {
  1492. ScriptMapNode *t = NULL, *p = NULL;
  1493. t = pList->next;
  1494. while (t != pList)
  1495. {
  1496. p = t->next;
  1497. free(t);
  1498. t = p;
  1499. }
  1500. t->prev = t;
  1501. t->next = t;
  1502. return;
  1503. }
  1504. void GetScriptMapListFromRegistry(ScriptMapNode *pList)
  1505. {
  1506. iisDebugOut_Start(_T("GetScriptMapListFromRegistry"), LOG_TYPE_TRACE);
  1507. int iFound = FALSE;
  1508. GetScriptMapListFromClean(pList, _T("ScriptMaps_CleanList"));
  1509. CRegKey regScriptMap( HKEY_LOCAL_MACHINE, _T("System\\CurrentControlSet\\Services\\W3svc\\Parameters\\Script Map"));
  1510. if ((HKEY)regScriptMap )
  1511. {
  1512. // delete mappings of .bat and .cmd
  1513. regScriptMap.DeleteValue( _T(".bat") );
  1514. regScriptMap.DeleteValue( _T(".cmd") );
  1515. CRegValueIter regEnum( regScriptMap );
  1516. CString csExt, csProcessor, csMethods;
  1517. CString csTemp;
  1518. ScriptMapNode *pNode;
  1519. while ( regEnum.Next( &csExt, &csProcessor ) == ERROR_SUCCESS )
  1520. {
  1521. iFound = FALSE;
  1522. csTemp = csProcessor;
  1523. csTemp.MakeLower();
  1524. csMethods = _T("");
  1525. if (csTemp.Right(7) == _T("asp.dll"))
  1526. {
  1527. // Make sure it points to the new location...
  1528. csProcessor = g_pTheApp->m_csPathInetsrv + _T("\\asp.dll");
  1529. // asp has special methods.
  1530. // add PROPFIND,PROPPATCH,MKCOL,COPY,MOVE,LOCK,UNLOCK,MS-SEARCH 6/17 per vanvan for Dav.
  1531. csMethods = _T("PUT,DELETE,OPTIONS,PROPFIND,PROPPATCH,MKCOL,COPY,MOVE,LOCK,UNLOCK,MS-SEARCH");
  1532. }
  1533. if (csTemp.Right(7) == _T("ism.dll"))
  1534. {
  1535. // Make sure it points to the new location...
  1536. // remap since ism.dll has a security hole
  1537. csProcessor = g_pTheApp->m_csPathInetsrv + _T("\\asp.dll");
  1538. }
  1539. if (csTemp.Right(12) == _T("httpodbc.dll"))
  1540. {
  1541. // Make sure it points to the new location...
  1542. csProcessor = g_pTheApp->m_csPathInetsrv + _T("\\httpodbc.dll");
  1543. }
  1544. if (csTemp.Right(9) == _T("ssinc.dll"))
  1545. {
  1546. // Make sure it points to the new location...
  1547. csProcessor = g_pTheApp->m_csPathInetsrv + _T("\\ssinc.dll");
  1548. }
  1549. // Add it to the script map
  1550. pNode = AllocNewScriptMapNode((LPTSTR)(LPCTSTR)csExt, (LPTSTR)(LPCTSTR)csProcessor, MD_SCRIPTMAPFLAG_SCRIPT, _T(""));
  1551. InsertScriptMapList(pList, pNode, FALSE);
  1552. }
  1553. }
  1554. iisDebugOut_End(_T("GetScriptMapListFromRegistry"),LOG_TYPE_TRACE);
  1555. return;
  1556. }
  1557. void GetScriptMapListFromMetabase(ScriptMapNode *pList, int iUpgradeType)
  1558. {
  1559. iisDebugOut_Start(_T("GetScriptMapListFromMetabase"), LOG_TYPE_TRACE);
  1560. //DumpScriptMapList();
  1561. // When upgrading from a metabase we should not add other script maps
  1562. // which the user probably explicitly removed!
  1563. // GetScriptMapListFromClean(pList, _T("ScriptMaps_CleanList"));
  1564. //DumpScriptMapList();
  1565. BOOL bFound = FALSE;
  1566. DWORD attr, uType, dType, cbLen;
  1567. CMDKey cmdKey;
  1568. BUFFER bufData;
  1569. LPTSTR p, rest;
  1570. CString csName, csValue;
  1571. PBYTE pData;
  1572. int BufSize;
  1573. CString csBinPath;
  1574. cmdKey.OpenNode(_T("LM/W3SVC"));
  1575. if ( (METADATA_HANDLE)cmdKey )
  1576. {
  1577. pData = (PBYTE)(bufData.QueryPtr());
  1578. BufSize = bufData.QuerySize();
  1579. cbLen = 0;
  1580. bFound = cmdKey.GetData(MD_SCRIPT_MAPS, &attr, &uType, &dType, &cbLen, pData, BufSize);
  1581. if (!bFound && (cbLen > 0))
  1582. {
  1583. if ( ! (bufData.Resize(cbLen)) )
  1584. {
  1585. cmdKey.Close();
  1586. return; // insufficient memory
  1587. }
  1588. else
  1589. {
  1590. pData = (PBYTE)(bufData.QueryPtr());
  1591. BufSize = cbLen;
  1592. cbLen = 0;
  1593. bFound = cmdKey.GetData(MD_SCRIPT_MAPS, &attr, &uType, &dType, &cbLen, pData, BufSize);
  1594. }
  1595. }
  1596. cmdKey.Close();
  1597. ScriptMapNode *pNode;
  1598. CString csString;
  1599. TCHAR szExt[32], szProcessor[_MAX_PATH], szMethods[_MAX_PATH];
  1600. DWORD dwFlags;
  1601. int i;
  1602. if (bFound && (dType == MULTISZ_METADATA))
  1603. {
  1604. p = (LPTSTR)pData;
  1605. while (*p)
  1606. {
  1607. rest = p + _tcslen(p) + 1;
  1608. // szExt,szProcessor,dwFlags[,szMethods]
  1609. LPTSTR q = p;
  1610. i = 0;
  1611. while ( *q )
  1612. {
  1613. if (*q == _T(','))
  1614. {
  1615. i++;
  1616. *q = _T('\0');
  1617. q = _tcsinc(q);
  1618. if (i == 1)
  1619. _tcscpy(szExt, p);
  1620. if (i == 2)
  1621. _tcscpy(szProcessor, p);
  1622. if (i == 3)
  1623. break;
  1624. p = q;
  1625. }
  1626. else
  1627. {
  1628. q = _tcsinc(q);
  1629. }
  1630. }
  1631. dwFlags = atodw(p);
  1632. _tcscpy(szMethods, q);
  1633. CString csProcessor = szProcessor;
  1634. csProcessor.MakeLower();
  1635. //
  1636. // Check if this is the one for asp.dll
  1637. //
  1638. if (csProcessor.Right(7) == _T("asp.dll"))
  1639. {
  1640. // metabase should now have inclusion list and not exclusion list, so
  1641. // don't do this for UT_50. 2/23/99 aaronl.
  1642. // But UT_40 have a exclusion list.
  1643. // So we have to make sure it have the full exclusion list
  1644. if ( iUpgradeType == UT_40)
  1645. {
  1646. CString csMethods = szMethods;
  1647. csMethods.MakeUpper();
  1648. // changed 4/21/98 aaronl, added 'Options'
  1649. // add PROPFIND,PROPPATCH,MKCOL,COPY,MOVE,LOCK,UNLOCK,MS-SEARCH 6/17 per vanvan for Dav.
  1650. if (csMethods.Find(_T("PUT,DELETE,OPTIONS,PROPFIND,PROPPATCH,MKCOL,COPY,MOVE,LOCK,UNLOCK,MS-SEARCH")) == -1)
  1651. {
  1652. if (csMethods.IsEmpty())
  1653. {
  1654. // if it's empty, then put to the default.
  1655. csMethods = _T("PUT,DELETE,OPTIONS,PROPFIND,PROPPATCH,MKCOL,COPY,MOVE,LOCK,UNLOCK,MS-SEARCH");
  1656. }
  1657. else
  1658. {
  1659. if (csMethods.Find(_T("GET")) == -1)
  1660. {
  1661. // We didn't find the "GET" verb so we can safely say
  1662. // that we are looking at an exclusion list
  1663. CString csMethodsNew;
  1664. csMethodsNew = _T("");
  1665. // is put in there? if not add it
  1666. if (csMethods.Find(_T("PUT")) == -1) {csMethodsNew += _T("PUT,");}
  1667. if (csMethods.Find(_T("DELETE")) == -1) {csMethodsNew += _T("DELETE,");}
  1668. if (csMethods.Find(_T("OPTIONS")) == -1) {csMethodsNew += _T("OPTIONS,");}
  1669. if (csMethods.Find(_T("PROPFIND")) == -1) {csMethodsNew += _T("PROPFIND,");}
  1670. if (csMethods.Find(_T("PROPPATCH")) == -1) {csMethodsNew += _T("PROPPATCH,");}
  1671. if (csMethods.Find(_T("MKCOL")) == -1) {csMethodsNew += _T("MKCOL,");}
  1672. if (csMethods.Find(_T("COPY")) == -1) {csMethodsNew += _T("COPY,");}
  1673. if (csMethods.Find(_T("MOVE")) == -1) {csMethodsNew += _T("MOVE,");}
  1674. if (csMethods.Find(_T("LOCK")) == -1) {csMethodsNew += _T("LOCK,");}
  1675. if (csMethods.Find(_T("UNLOCK")) == -1) {csMethodsNew += _T("UNLOCK,");}
  1676. if (csMethods.Find(_T("MS-SEARCH")) == -1) {csMethodsNew += _T("MS-SEARCH,");}
  1677. // has an extra ',' at the end
  1678. //csMethods = _T("PUT,DELETE,OPTIONS,PROPFIND,PROPPATCH,MKCOL,COPY,MOVE,LOCK,UNLOCK,MS-SEARCH,");
  1679. csMethods = csMethodsNew;
  1680. csMethods += szMethods;
  1681. }
  1682. }
  1683. _tcscpy(szMethods, csMethods);
  1684. }
  1685. }
  1686. // make sure it points to the new asp.dll location
  1687. csBinPath = g_pTheApp->m_csPathInetsrv + _T("\\asp.dll");
  1688. _tcscpy(szProcessor, csBinPath);
  1689. }
  1690. //
  1691. // Check if this is the one for ism.dll
  1692. //
  1693. if (csProcessor.Right(7) == _T("ism.dll"))
  1694. {
  1695. // make sure it points to the new location
  1696. // remap since ism.dll has a security hole
  1697. csBinPath = g_pTheApp->m_csPathInetsrv + _T("\\asp.dll");
  1698. _tcscpy(szProcessor, csBinPath);
  1699. }
  1700. //
  1701. // Check if this is the one for httpodbc.dll
  1702. //
  1703. if (csProcessor.Right(12) == _T("httpodbc.dll"))
  1704. {
  1705. // make sure it points to the new location
  1706. csBinPath = g_pTheApp->m_csPathInetsrv + _T("\\httpodbc.dll");
  1707. _tcscpy(szProcessor, csBinPath);
  1708. }
  1709. //
  1710. // Check if this is the one for ssinc.dll
  1711. //
  1712. if (csProcessor.Right(9) == _T("ssinc.dll"))
  1713. {
  1714. // make sure it points to the new location
  1715. csBinPath = g_pTheApp->m_csPathInetsrv + _T("\\ssinc.dll");
  1716. _tcscpy(szProcessor, csBinPath);
  1717. }
  1718. p = rest; // points to the next string
  1719. pNode = AllocNewScriptMapNode(szExt, szProcessor, dwFlags | MD_SCRIPTMAPFLAG_SCRIPT, szMethods);
  1720. //iisDebugOut((LOG_TYPE_TRACE, _T("Calling InsertScriptMapList=%s:%s:%d:%s.\n"),szExt,szProcessor,dwFlags | MD_SCRIPTMAPFLAG_SCRIPT,szMethods));
  1721. InsertScriptMapList(pList, pNode, TRUE);
  1722. }
  1723. }
  1724. }
  1725. iisDebugOut_End(_T("GetScriptMapListFromMetabase"),LOG_TYPE_TRACE);
  1726. return;
  1727. }
  1728. void DumpScriptMapList()
  1729. {
  1730. BOOL bFound = FALSE;
  1731. DWORD attr, uType, dType, cbLen;
  1732. CMDKey cmdKey;
  1733. BUFFER bufData;
  1734. LPTSTR p, rest;
  1735. CString csName, csValue;
  1736. PBYTE pData;
  1737. int BufSize;
  1738. CString csBinPath;
  1739. cmdKey.OpenNode(_T("LM/W3SVC"));
  1740. if ( (METADATA_HANDLE)cmdKey )
  1741. {
  1742. pData = (PBYTE)(bufData.QueryPtr());
  1743. BufSize = bufData.QuerySize();
  1744. cbLen = 0;
  1745. bFound = cmdKey.GetData(MD_SCRIPT_MAPS, &attr, &uType, &dType, &cbLen, pData, BufSize);
  1746. if (!bFound && (cbLen > 0))
  1747. {
  1748. if ( ! (bufData.Resize(cbLen)) )
  1749. {
  1750. cmdKey.Close();
  1751. return; // insufficient memory
  1752. }
  1753. else
  1754. {
  1755. pData = (PBYTE)(bufData.QueryPtr());
  1756. BufSize = cbLen;
  1757. cbLen = 0;
  1758. bFound = cmdKey.GetData(MD_SCRIPT_MAPS, &attr, &uType, &dType, &cbLen, pData, BufSize);
  1759. }
  1760. }
  1761. cmdKey.Close();
  1762. CString csString;
  1763. TCHAR szExt[32], szProcessor[_MAX_PATH], szMethods[_MAX_PATH];
  1764. DWORD dwFlags;
  1765. int i;
  1766. if (bFound && (dType == MULTISZ_METADATA))
  1767. {
  1768. p = (LPTSTR)pData;
  1769. while (*p)
  1770. {
  1771. rest = p + _tcslen(p) + 1;
  1772. // szExt,szProcessor,dwFlags[,szMethods]
  1773. LPTSTR q = p;
  1774. i = 0;
  1775. while ( *q )
  1776. {
  1777. if (*q == _T(','))
  1778. {
  1779. i++;
  1780. *q = _T('\0');
  1781. q = _tcsinc(q);
  1782. if (i == 1)
  1783. _tcscpy(szExt, p);
  1784. if (i == 2)
  1785. _tcscpy(szProcessor, p);
  1786. if (i == 3)
  1787. break;
  1788. p = q;
  1789. }
  1790. else
  1791. {
  1792. q = _tcsinc(q);
  1793. }
  1794. }
  1795. dwFlags = atodw(p);
  1796. _tcscpy(szMethods, q);
  1797. CString csProcessor = szProcessor;
  1798. csProcessor.MakeLower();
  1799. iisDebugOut((LOG_TYPE_TRACE, _T("DumpScriptMapList=%s,%s,%s\n"),szExt, csProcessor,szMethods));
  1800. p = rest; // points to the next string
  1801. }
  1802. }
  1803. }
  1804. return;
  1805. }
  1806. void WriteScriptMapListToMetabase(ScriptMapNode *pList, LPTSTR szKeyPath, DWORD dwFlags)
  1807. {
  1808. iisDebugOut_Start1(_T("WriteScriptMapListToMetabase"), szKeyPath, LOG_TYPE_TRACE);
  1809. CString csString, csTemp;
  1810. ScriptMapNode *t = NULL;
  1811. int len = 0;
  1812. t = pList->next;
  1813. while (t != pList)
  1814. {
  1815. if ( *(t->szMethods) )
  1816. csTemp.Format( _T("%s,%s,%d,%s|"), t->szExt, t->szProcessor, (t->dwFlags | dwFlags), t->szMethods );
  1817. else
  1818. csTemp.Format( _T("%s,%s,%d|"), t->szExt, t->szProcessor, (t->dwFlags | dwFlags) );
  1819. len += csTemp.GetLength();
  1820. //iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("WriteScriptMapListToMetabase().ADDEntry=%1!s!\n"), csTemp));
  1821. csString += csTemp;
  1822. t = t->next;
  1823. }
  1824. if (len > 0)
  1825. {
  1826. HGLOBAL hBlock = NULL;
  1827. len++;
  1828. hBlock = GlobalAlloc(GPTR, len * sizeof(TCHAR));
  1829. if (hBlock)
  1830. {
  1831. LPTSTR s;
  1832. s = (LPTSTR)hBlock;
  1833. _tcscpy(s, csString);
  1834. while (*s)
  1835. {
  1836. if (*s == _T('|'))
  1837. {*s = _T('\0');}
  1838. s = _tcsinc(s);
  1839. }
  1840. CMDKey cmdKey;
  1841. cmdKey.CreateNode(METADATA_MASTER_ROOT_HANDLE, szKeyPath);
  1842. if ( (METADATA_HANDLE)cmdKey )
  1843. {
  1844. cmdKey.SetData(MD_SCRIPT_MAPS,METADATA_INHERIT,IIS_MD_UT_FILE,MULTISZ_METADATA,len * sizeof(TCHAR),(LPBYTE)hBlock);
  1845. cmdKey.Close();
  1846. }
  1847. }
  1848. }
  1849. iisDebugOut_End1(_T("WriteScriptMapListToMetabase"),szKeyPath,LOG_TYPE_TRACE);
  1850. //DumpScriptMapList();
  1851. return;
  1852. }
  1853. // this function does not use the va_list stuff because if
  1854. // there ever is this case: iisDebugOut("<SYSTEMROOT>") it will hose
  1855. // because it will try to put something in the %s part when there were no
  1856. // variables passed in.
  1857. void iisDebugOutSafe2(int iLogType, TCHAR * acsString)
  1858. {
  1859. // Check what type of log this should be.
  1860. int iProceed = FALSE;
  1861. if (iLogType == LOG_TYPE_ERROR)
  1862. {SetErrorFlag(__FILE__, __LINE__);}
  1863. switch(iLogType)
  1864. {
  1865. case LOG_TYPE_TRACE_WIN32_API:
  1866. if (g_GlobalDebugLevelFlag >= LOG_TYPE_TRACE_WIN32_API)
  1867. {iProceed = TRUE;}
  1868. break;
  1869. case LOG_TYPE_TRACE:
  1870. if (g_GlobalDebugLevelFlag >= LOG_TYPE_TRACE)
  1871. {iProceed = TRUE;}
  1872. break;
  1873. case LOG_TYPE_PROGRAM_FLOW:
  1874. if (g_GlobalDebugLevelFlag >= LOG_TYPE_PROGRAM_FLOW)
  1875. {iProceed = TRUE;}
  1876. break;
  1877. case LOG_TYPE_WARN:
  1878. if (g_GlobalDebugLevelFlag >= LOG_TYPE_WARN)
  1879. {iProceed = TRUE;}
  1880. break;
  1881. case LOG_TYPE_ERROR:
  1882. if (g_GlobalDebugLevelFlag >= LOG_TYPE_ERROR)
  1883. {iProceed = TRUE;}
  1884. break;
  1885. default:
  1886. // this must be an error
  1887. iProceed = TRUE;
  1888. break;
  1889. }
  1890. if (iProceed)
  1891. {
  1892. if (LOG_TYPE_ERROR == iLogType)
  1893. {
  1894. g_MyLogFile.LogFileWrite(_T("!FAIL! "));
  1895. }
  1896. // always output to the log file
  1897. g_MyLogFile.LogFileWrite(_T("%s"), acsString);
  1898. //#if DBG == 1 || DEBUG == 1 || _DEBUG == 1
  1899. // OK. Here is the deal.
  1900. // nt5 does not want to see any OutputDebugString stuff
  1901. // so, we need to remove it for them.
  1902. // Actually we'll check the registry key
  1903. // to see if it is turned on for the ocmanage component.
  1904. // if it is then, set it on for us.
  1905. if (g_GlobalDebugLevelFlag >= LOG_TYPE_TRACE_WIN32_API)
  1906. {
  1907. if (LOG_TYPE_ERROR == iLogType)
  1908. {OutputDebugString(_T("!FAIL!"));}
  1909. // output to screen
  1910. if (g_MyLogFile.m_szLogPreLineInfo) {OutputDebugString(g_MyLogFile.m_szLogPreLineInfo);}
  1911. OutputDebugString(acsString);
  1912. // if it does not end if '\r\n' then make one.
  1913. int nLen = _tcslen(acsString);
  1914. if (acsString[nLen-1] != _T('\n'))
  1915. {OutputDebugString(_T("\r\n"));}
  1916. }
  1917. //#endif // DBG
  1918. }
  1919. return;
  1920. }
  1921. void iisDebugOut2(int iLogType, TCHAR *pszfmt, ...)
  1922. {
  1923. // Check what type of log this should be.
  1924. int iProceed = FALSE;
  1925. switch(iLogType)
  1926. {
  1927. case LOG_TYPE_TRACE_WIN32_API:
  1928. if (g_GlobalDebugLevelFlag >= LOG_TYPE_TRACE_WIN32_API)
  1929. {iProceed = TRUE;}
  1930. break;
  1931. case LOG_TYPE_TRACE:
  1932. if (g_GlobalDebugLevelFlag >= LOG_TYPE_TRACE)
  1933. {iProceed = TRUE;}
  1934. break;
  1935. case LOG_TYPE_PROGRAM_FLOW:
  1936. if (g_GlobalDebugLevelFlag >= LOG_TYPE_PROGRAM_FLOW)
  1937. {iProceed = TRUE;}
  1938. break;
  1939. case LOG_TYPE_WARN:
  1940. if (g_GlobalDebugLevelFlag >= LOG_TYPE_WARN)
  1941. {iProceed = TRUE;}
  1942. break;
  1943. case LOG_TYPE_ERROR:
  1944. if (g_GlobalDebugLevelFlag >= LOG_TYPE_ERROR)
  1945. {iProceed = TRUE;}
  1946. break;
  1947. default:
  1948. // this must be an error
  1949. iProceed = TRUE;
  1950. break;
  1951. }
  1952. if (iProceed)
  1953. {
  1954. TCHAR acsString[1000];
  1955. // Encompass this whole iisdebugout deal in a try-catch.
  1956. // not too good to have this one access violating.
  1957. // when trying to produce a debugoutput!
  1958. __try
  1959. {
  1960. va_list va;
  1961. va_start(va, pszfmt);
  1962. _vstprintf(acsString, pszfmt, va);
  1963. va_end(va);
  1964. }
  1965. __except(EXCEPTION_EXECUTE_HANDLER)
  1966. {
  1967. TCHAR szErrorString[100];
  1968. _stprintf(szErrorString, _T("\r\n\r\nException Caught in iisDebugOut2(). GetExceptionCode()=0x%x.\r\n\r\n"), GetExceptionCode());
  1969. OutputDebugString(szErrorString);
  1970. g_MyLogFile.LogFileWrite(szErrorString);
  1971. }
  1972. // output to log file and the screen.
  1973. iisDebugOutSafe2(iLogType, acsString);
  1974. }
  1975. return;
  1976. }
  1977. // This function requires inputs like this:
  1978. // iisDebugOutSafeParams2("this %1!s! is %2!s! and has %3!d! args", "function", "kool", 3);
  1979. // you must specify the %1 deals. this is so that
  1980. // if something like this is passed in "this %SYSTEMROOT% %1!s!", it will put the string into %1 not %s!
  1981. void iisDebugOutSafeParams2(int iLogType, TCHAR *pszfmt, ...)
  1982. {
  1983. // Check what type of log this should be.
  1984. int iProceed = FALSE;
  1985. switch(iLogType)
  1986. {
  1987. case LOG_TYPE_TRACE_WIN32_API:
  1988. if (g_GlobalDebugLevelFlag >= LOG_TYPE_TRACE_WIN32_API)
  1989. {iProceed = TRUE;}
  1990. break;
  1991. case LOG_TYPE_TRACE:
  1992. if (g_GlobalDebugLevelFlag >= LOG_TYPE_TRACE)
  1993. {iProceed = TRUE;}
  1994. break;
  1995. case LOG_TYPE_PROGRAM_FLOW:
  1996. if (g_GlobalDebugLevelFlag >= LOG_TYPE_PROGRAM_FLOW)
  1997. {iProceed = TRUE;}
  1998. break;
  1999. case LOG_TYPE_WARN:
  2000. if (g_GlobalDebugLevelFlag >= LOG_TYPE_WARN)
  2001. {iProceed = TRUE;}
  2002. break;
  2003. case LOG_TYPE_ERROR:
  2004. if (g_GlobalDebugLevelFlag >= LOG_TYPE_ERROR)
  2005. {iProceed = TRUE;}
  2006. break;
  2007. default:
  2008. // this must be an error
  2009. iProceed = TRUE;
  2010. break;
  2011. }
  2012. if (iProceed)
  2013. {
  2014. // The count of parameters do not match
  2015. va_list va;
  2016. TCHAR *pszFullErrMsg = NULL;
  2017. va_start(va, pszfmt);
  2018. __try
  2019. {
  2020. FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_STRING, (LPCVOID) pszfmt, 0, 0, (LPTSTR) &pszFullErrMsg, 0, &va);
  2021. }
  2022. __except(EXCEPTION_EXECUTE_HANDLER)
  2023. {
  2024. TCHAR szErrorString[100];
  2025. _stprintf(szErrorString, _T("\r\n\r\nException Caught in iisDebugOutSafeParams2(). GetExceptionCode()=0x%x.\r\n\r\n"), GetExceptionCode());
  2026. OutputDebugString(szErrorString);
  2027. g_MyLogFile.LogFileWrite(szErrorString);
  2028. }
  2029. if (pszFullErrMsg)
  2030. {
  2031. // output to log file and the screen.
  2032. iisDebugOutSafe2(iLogType, pszFullErrMsg);
  2033. }
  2034. va_end(va);
  2035. if (pszFullErrMsg) {LocalFree(pszFullErrMsg);pszFullErrMsg=NULL;}
  2036. }
  2037. return;
  2038. }
  2039. void HandleSpecificErrors(DWORD iTheErrorCode, DWORD dwFormatReturn, CString csMsg, TCHAR pMsg[], CString *pcsErrMsg)
  2040. {
  2041. CString csErrMsg;
  2042. CString csExtraMsg;
  2043. switch(iTheErrorCode)
  2044. {
  2045. case NTE_BAD_SIGNATURE:
  2046. // load extra error message for this error!
  2047. MyLoadString(IDS_BAD_SIGNATURE_RELNOTES, csExtraMsg);
  2048. if (dwFormatReturn) {csErrMsg.Format(_T("%s\n\n0x%x=%s\n\n%s"), csMsg, iTheErrorCode, pMsg, csExtraMsg);}
  2049. else{csErrMsg.Format(_T("%s\n\nErrorCode=0x%x.\n\n%s"), csMsg, iTheErrorCode, csExtraMsg);}
  2050. break;
  2051. case CO_E_RUNAS_LOGON_FAILURE:
  2052. // we should get the mts runas user from the registry and display it.
  2053. default:
  2054. // Put everything into csErrMsg
  2055. if (dwFormatReturn) {csErrMsg.Format(_T("%s\n\n0x%x=%s"), csMsg, iTheErrorCode, pMsg);}
  2056. else{csErrMsg.Format(_T("%s\n\nErrorCode=0x%x."), csMsg, iTheErrorCode);}
  2057. break;
  2058. }
  2059. // copy the error string into the passed in CString
  2060. (*pcsErrMsg) = csErrMsg;
  2061. return;
  2062. }
  2063. //***************************************************************************
  2064. //*
  2065. //* purpose:
  2066. //*
  2067. //***************************************************************************
  2068. LPWSTR MakeWideStrFromAnsi(LPSTR psz)
  2069. {
  2070. LPWSTR pwsz;
  2071. int i;
  2072. // arg checking.
  2073. //
  2074. if (!psz)
  2075. return NULL;
  2076. // compute the length
  2077. //
  2078. i = MultiByteToWideChar(CP_ACP, 0, psz, -1, NULL, 0);
  2079. if (i <= 0) return NULL;
  2080. //iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ole32:CoTaskMemAlloc().Start.")));
  2081. pwsz = (LPWSTR) CoTaskMemAlloc(i * sizeof(WCHAR));
  2082. //iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ole32:CoTaskMemAlloc().End.")));
  2083. if (!pwsz) return NULL;
  2084. MultiByteToWideChar(CP_ACP, 0, psz, -1, pwsz, i);
  2085. pwsz[i - 1] = 0;
  2086. return pwsz;
  2087. }
  2088. DWORD CallProcedureInDll_wrap(LPCTSTR lpszDLLFile, LPCTSTR lpszProcedureToCall, BOOL bDisplayMsgOnErrFlag, BOOL bInitOleFlag,BOOL iFunctionPrototypeFlag)
  2089. {
  2090. int bFinishedFlag = FALSE;
  2091. UINT iMsg = NULL;
  2092. DWORD dwReturn = ERROR_SUCCESS;
  2093. TCHAR szExceptionString[50] = _T("");
  2094. LogHeapState(FALSE, __FILE__, __LINE__);
  2095. do
  2096. {
  2097. __try
  2098. {
  2099. dwReturn = CallProcedureInDll(lpszDLLFile, lpszProcedureToCall, bDisplayMsgOnErrFlag, bInitOleFlag, iFunctionPrototypeFlag);
  2100. LogHeapState(FALSE, __FILE__, __LINE__);
  2101. }
  2102. __except(EXCEPTION_EXECUTE_HANDLER)
  2103. {
  2104. iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("ExceptionCaught!:CallProcedureInDll_wrap(): File:%1!s!, Procedure:%2!s!\n"), lpszDLLFile, lpszProcedureToCall));
  2105. switch (GetExceptionCode())
  2106. {
  2107. case EXCEPTION_ACCESS_VIOLATION:
  2108. _tcscpy(szExceptionString, _T("EXCEPTION_ACCESS_VIOLATION"));
  2109. break;
  2110. case EXCEPTION_BREAKPOINT:
  2111. _tcscpy(szExceptionString, _T("EXCEPTION_BREAKPOINT"));
  2112. break;
  2113. case EXCEPTION_DATATYPE_MISALIGNMENT:
  2114. _tcscpy(szExceptionString, _T("EXCEPTION_DATATYPE_MISALIGNMENT"));
  2115. break;
  2116. case EXCEPTION_SINGLE_STEP:
  2117. _tcscpy(szExceptionString, _T("EXCEPTION_SINGLE_STEP"));
  2118. break;
  2119. case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
  2120. _tcscpy(szExceptionString, _T("EXCEPTION_ARRAY_BOUNDS_EXCEEDED"));
  2121. break;
  2122. case EXCEPTION_FLT_DENORMAL_OPERAND:
  2123. _tcscpy(szExceptionString, _T("EXCEPTION_FLT_DENORMAL_OPERAND"));
  2124. break;
  2125. case EXCEPTION_FLT_DIVIDE_BY_ZERO:
  2126. _tcscpy(szExceptionString, _T("EXCEPTION_FLT_DIVIDE_BY_ZERO"));
  2127. break;
  2128. case EXCEPTION_FLT_INEXACT_RESULT:
  2129. _tcscpy(szExceptionString, _T("EXCEPTION_FLT_INEXACT_RESULT"));
  2130. break;
  2131. case EXCEPTION_FLT_INVALID_OPERATION:
  2132. _tcscpy(szExceptionString, _T("EXCEPTION_FLT_INVALID_OPERATION"));
  2133. break;
  2134. case EXCEPTION_FLT_OVERFLOW:
  2135. _tcscpy(szExceptionString, _T("EXCEPTION_FLT_OVERFLOW"));
  2136. break;
  2137. case EXCEPTION_FLT_STACK_CHECK:
  2138. _tcscpy(szExceptionString, _T("EXCEPTION_FLT_STACK_CHECK"));
  2139. break;
  2140. case EXCEPTION_FLT_UNDERFLOW:
  2141. _tcscpy(szExceptionString, _T("EXCEPTION_FLT_UNDERFLOW"));
  2142. break;
  2143. case EXCEPTION_INT_DIVIDE_BY_ZERO:
  2144. _tcscpy(szExceptionString, _T("EXCEPTION_INT_DIVIDE_BY_ZERO"));
  2145. break;
  2146. case EXCEPTION_INT_OVERFLOW:
  2147. _tcscpy(szExceptionString, _T("EXCEPTION_INT_OVERFLOW"));
  2148. break;
  2149. case EXCEPTION_PRIV_INSTRUCTION:
  2150. _tcscpy(szExceptionString, _T("EXCEPTION_PRIV_INSTRUCTION"));
  2151. break;
  2152. case EXCEPTION_NONCONTINUABLE_EXCEPTION:
  2153. _tcscpy(szExceptionString, _T("EXCEPTION_NONCONTINUABLE_EXCEPTION"));
  2154. break;
  2155. default:
  2156. _tcscpy(szExceptionString, _T("Unknown Exception Type"));
  2157. break;
  2158. }
  2159. //MyMessageBox( NULL, IDS_REGSVR_CAUGHT_EXCEPTION, lpszProcedureToCall, lpszDLLFile, GetExceptionCode(), MB_OK | MB_SETFOREGROUND );
  2160. MyMessageBox( NULL, IDS_REGSVR_CAUGHT_EXCEPTION, szExceptionString, lpszProcedureToCall, lpszDLLFile, GetExceptionCode(), MB_OK | MB_SETFOREGROUND );
  2161. dwReturn = ERROR_PROCESS_ABORTED;
  2162. }
  2163. if (dwReturn == ERROR_SUCCESS)
  2164. {
  2165. break;
  2166. }
  2167. else
  2168. {
  2169. if (bDisplayMsgOnErrFlag == TRUE)
  2170. {
  2171. iMsg = MyMessageBox( NULL, IDS_RETRY, MB_ABORTRETRYIGNORE | MB_SETFOREGROUND );
  2172. switch ( iMsg )
  2173. {
  2174. case IDRETRY:
  2175. break;
  2176. case IDIGNORE:
  2177. case IDABORT:
  2178. default:
  2179. // return whatever err happened
  2180. goto CallProcedureInDll_wrap_Exit;
  2181. break;
  2182. }
  2183. }
  2184. else
  2185. {
  2186. // return whatever err happened
  2187. goto CallProcedureInDll_wrap_Exit;
  2188. }
  2189. }
  2190. } while (dwReturn != ERROR_SUCCESS);
  2191. CallProcedureInDll_wrap_Exit:
  2192. return dwReturn;
  2193. }
  2194. void AddOLEAUTRegKey()
  2195. {
  2196. CRegKey regCLSID46(_T("CLSID\\{00020424-0000-0000-C000-000000000046}"),HKEY_CLASSES_ROOT);
  2197. if ((HKEY)regCLSID46)
  2198. {
  2199. #ifdef _CHICAGO_
  2200. regCLSID46.SetValue(_T(""), _T("PSAutomation"));
  2201. #else
  2202. regCLSID46.SetValue(_T(""), _T("PSOAInterface"));
  2203. #endif
  2204. }
  2205. CRegKey regInProcServer(_T("CLSID\\{00020424-0000-0000-C000-000000000046}\\InprocServer"),HKEY_CLASSES_ROOT);
  2206. if ((HKEY)regInProcServer)
  2207. {
  2208. regInProcServer.SetValue(_T(""), _T("ole2disp.dll"));
  2209. }
  2210. CRegKey regInProcServer32(_T("CLSID\\{00020424-0000-0000-C000-000000000046}\\InprocServer32"),HKEY_CLASSES_ROOT);
  2211. if ((HKEY)regInProcServer32)
  2212. {
  2213. regInProcServer32.SetValue(_T(""), _T("oleaut32.dll"));
  2214. regInProcServer32.SetValue(_T("ThreadingModel"), _T("Both"));
  2215. }
  2216. return;
  2217. }
  2218. // Returns:
  2219. // ERROR_SUCCESS if successfull.
  2220. // ERROR_OPERATION_ABORTED if the operation failed and the user wants to abort setup!
  2221. DWORD RegisterOLEControl(LPCTSTR lpszOcxFile, BOOL fAction)
  2222. {
  2223. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("RegisterOLEControl():File=%1!s!, Action=%2!d!\n"), lpszOcxFile, fAction));
  2224. DWORD dwReturn = ERROR_SUCCESS;
  2225. if (fAction)
  2226. {
  2227. dwReturn = CallProcedureInDll_wrap(lpszOcxFile, _T("DllRegisterServer"), TRUE, TRUE, FUNCTION_PARAMS_NONE);
  2228. }
  2229. else
  2230. {
  2231. #if DBG == 1 || DEBUG == 1 || _DEBUG == 1
  2232. // Show errors if this is a debug build
  2233. dwReturn = CallProcedureInDll_wrap(lpszOcxFile, _T("DllUnregisterServer"), TRUE, TRUE, FUNCTION_PARAMS_NONE);
  2234. #else
  2235. // Set 3rd parameter to false so that there are no MyMessageBox popups if any errors
  2236. dwReturn = CallProcedureInDll_wrap(lpszOcxFile, _T("DllUnregisterServer"), FALSE, TRUE, FUNCTION_PARAMS_NONE);
  2237. #endif
  2238. }
  2239. return dwReturn;
  2240. }
  2241. typedef HRESULT (CALLBACK *HCRET)(void);
  2242. typedef HRESULT (*PFUNCTION2)(HMODULE myDllHandle);
  2243. DWORD CallProcedureInDll(LPCTSTR lpszDLLFile, LPCTSTR lpszProcedureToCall, BOOL bDisplayMsgOnErrFlag, BOOL bInitOleFlag, BOOL iFunctionPrototypeFlag)
  2244. {
  2245. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("------------------\n")));
  2246. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("CallProcedureInDll(%1!s!): %2!s!\n"), lpszDLLFile, lpszProcedureToCall));
  2247. DWORD dwReturn = ERROR_SUCCESS;
  2248. HINSTANCE hDll = NULL;
  2249. // Diferent function prototypes...
  2250. HCRET hProc = NULL;
  2251. PFUNCTION2 hProc2 = NULL;
  2252. int iTempProcGood = FALSE;
  2253. HRESULT hRes = 0;
  2254. BOOL bBalanceOLE = FALSE;
  2255. HRESULT hInitRes = NULL;
  2256. int err = NOERROR;
  2257. // Variables to changing and saving dirs
  2258. TCHAR szDirName[_MAX_PATH], szFilePath[_MAX_PATH];
  2259. // Variable to set error string
  2260. TCHAR szErrString[256];
  2261. _tcscpy(szDirName, _T(""));
  2262. _tcscpy(szErrString, _T(""));
  2263. // perform a defensive check
  2264. if ( FAILED(FTestForOutstandingCoInits()) )
  2265. {
  2266. iisDebugOut((LOG_TYPE_WARN, _T("Outstanding CoInit in %s. WARNING."), lpszDLLFile));
  2267. }
  2268. // If we need to initialize the ole library then init it.
  2269. if (bInitOleFlag)
  2270. {
  2271. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ole32(OleInitialize):start.\n")));
  2272. bBalanceOLE = iOleInitialize();
  2273. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ole32(OleInitialize):end.\n")));
  2274. if (FALSE == bBalanceOLE)
  2275. {
  2276. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ole32(OleInitialize):start.\n")));
  2277. hInitRes = OleInitialize(NULL);
  2278. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ole32(OleInitialize):end.\n")));
  2279. // Ole Failed.
  2280. dwReturn = hInitRes;
  2281. SetLastError(dwReturn);
  2282. if (bDisplayMsgOnErrFlag)
  2283. {
  2284. MyMessageBox(NULL, IDS_OLE_INIT_FAILED, lpszDLLFile, hInitRes, MB_OK | MB_SETFOREGROUND);
  2285. }
  2286. goto CallProcedureInDll_Exit;
  2287. }
  2288. }
  2289. // Check if the file exists
  2290. if (!IsFileExist(lpszDLLFile))
  2291. {
  2292. dwReturn = ERROR_FILE_NOT_FOUND;
  2293. if (bDisplayMsgOnErrFlag)
  2294. {
  2295. MyMessageBox(NULL, IDS_FILE_DOES_NOT_EXIST, lpszDLLFile, ERROR_FILE_NOT_FOUND, MB_OK | MB_SETFOREGROUND);
  2296. }
  2297. SetLastError(dwReturn);
  2298. goto CallProcedureInDll_Exit;
  2299. }
  2300. // Change Directory
  2301. GetCurrentDirectory( _MAX_PATH, szDirName );
  2302. InetGetFilePath(lpszDLLFile, szFilePath);
  2303. // Change to The Drive.
  2304. if (-1 == _chdrive( _totupper(szFilePath[0]) - 'A' + 1 )) {}
  2305. if (SetCurrentDirectory(szFilePath) == 0) {}
  2306. // Try to load the module,dll,ocx.
  2307. hDll = LoadLibraryEx(lpszDLLFile, NULL, LOAD_WITH_ALTERED_SEARCH_PATH );
  2308. if (!hDll)
  2309. {
  2310. // Failed to load library, Probably because some .dll file is missing.
  2311. // Show the error message.
  2312. iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("CallProcedureInDll():%1!s!:%2!s!:LoadLibraryEx FAILED.\n"), lpszDLLFile, lpszProcedureToCall));
  2313. if ( GetLastError() != ERROR_SUCCESS )
  2314. {
  2315. dwReturn = GetLastError();
  2316. }
  2317. else
  2318. {
  2319. dwReturn = ERROR_FILE_NOT_FOUND;
  2320. }
  2321. if (bDisplayMsgOnErrFlag)
  2322. {
  2323. MyMessageBox(NULL, IDS_LOADLIBRARY_FAILED, lpszDLLFile, TYPE_E_CANTLOADLIBRARY, MB_OK | MB_SETFOREGROUND);
  2324. }
  2325. SetLastError(dwReturn);
  2326. // check if this file has missing file it's supposed to be linked with.
  2327. // or if the file has mismatched import\export dependencies with linked files.
  2328. #ifdef _WIN64
  2329. // don't call cause it's broken
  2330. #else
  2331. //Check_File_Dependencies(lpszDLLFile);
  2332. #endif
  2333. goto CallProcedureInDll_Exit;
  2334. }
  2335. // Ok module was successfully loaded. now let's try to get the Address of the Procedure
  2336. // Convert the function name to ascii before passing it to GetProcAddress()
  2337. char AsciiProcedureName[255];
  2338. #if defined(UNICODE) || defined(_UNICODE)
  2339. // convert to ascii
  2340. WideCharToMultiByte( CP_ACP, 0, (TCHAR *)lpszProcedureToCall, -1, AsciiProcedureName, 255, NULL, NULL );
  2341. #else
  2342. // the is already ascii so just copy
  2343. strcpy(AsciiProcedureName, lpszProcedureToCall);
  2344. #endif
  2345. iTempProcGood = TRUE;
  2346. if (iFunctionPrototypeFlag == FUNCTION_PARAMS_HMODULE)
  2347. {
  2348. hProc2 = (PFUNCTION2)GetProcAddress(hDll, AsciiProcedureName);
  2349. if (!hProc2){iTempProcGood = FALSE;}
  2350. }
  2351. else
  2352. {
  2353. hProc = (HCRET)GetProcAddress(hDll, AsciiProcedureName);
  2354. if (!hProc){iTempProcGood = FALSE;}
  2355. }
  2356. if (!iTempProcGood)
  2357. {
  2358. // failed to load,find or whatever this function.
  2359. iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("CallProcedureInDll():%1!s!:%2!s!:() FAILED.\n"), lpszDLLFile, lpszProcedureToCall));
  2360. dwReturn = ERROR_PROC_NOT_FOUND;
  2361. if (bDisplayMsgOnErrFlag)
  2362. {
  2363. MyMessageBox(NULL, IDS_UNABLE_TO_LOCATE_PROCEDURE, lpszProcedureToCall, lpszDLLFile, ERROR_PROC_NOT_FOUND, MB_OK | MB_SETFOREGROUND);
  2364. }
  2365. SetLastError(dwReturn);
  2366. goto CallProcedureInDll_Exit;
  2367. }
  2368. // Call the function that we got the handle to
  2369. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("CallProcedureInDll: Calling '%1!s!'.Start\n"), lpszProcedureToCall));
  2370. __try
  2371. {
  2372. if (iFunctionPrototypeFlag == FUNCTION_PARAMS_HMODULE)
  2373. {
  2374. hRes = (*hProc2)((HMODULE) g_MyModuleHandle);
  2375. }
  2376. else
  2377. {
  2378. hRes = (*hProc)();
  2379. }
  2380. }
  2381. __except(EXCEPTION_EXECUTE_HANDLER)
  2382. {
  2383. TCHAR szErrorString[100];
  2384. _stprintf(szErrorString, _T("\r\n\r\nException Caught in CallProcedureInDll(). GetExceptionCode()=0x%x.\r\n\r\n"), GetExceptionCode());
  2385. OutputDebugString(szErrorString);
  2386. g_MyLogFile.LogFileWrite(szErrorString);
  2387. }
  2388. if (FAILED(hRes))
  2389. {
  2390. dwReturn = ERROR_FUNCTION_FAILED;
  2391. if (bDisplayMsgOnErrFlag)
  2392. {
  2393. MyMessageBox(NULL, IDS_ERR_CALLING_DLL_PROCEDURE, lpszProcedureToCall, lpszDLLFile, hRes, MB_OK | MB_SETFOREGROUND);
  2394. }
  2395. iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("CallProcedureInDll: Calling '%1!s!'.End.FAILED. Err=%2!x!.\n"), lpszProcedureToCall, hRes));
  2396. // this function returns E_FAIL but
  2397. // the actual error is in GetLastError()
  2398. // set the last error to whatever was returned from the function call
  2399. SetLastError(hRes);
  2400. }
  2401. else
  2402. {
  2403. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("CallProcedureInDll: Calling '%1!s!'.End.SUCCESS.\n"), lpszProcedureToCall));
  2404. }
  2405. CallProcedureInDll_Exit:
  2406. if (hDll)
  2407. {
  2408. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("FreeLibrary.start.\n")));
  2409. FreeLibrary(hDll);
  2410. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("FreeLibrary.end.\n")));
  2411. }
  2412. else
  2413. {
  2414. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Did not FreeLibrary: %1!s! !!!!!!!!!!!!\n"), lpszDLLFile));
  2415. }
  2416. if (_tcscmp(szDirName, _T("")) != 0){SetCurrentDirectory(szDirName);}
  2417. // To close the library gracefully, each successful call to OleInitialize,
  2418. // including those that return S_FALSE, must be balanced by a corresponding
  2419. // call to the OleUninitialize function.
  2420. iOleUnInitialize(bBalanceOLE);
  2421. // perform a defensive check
  2422. if ( FAILED(FTestForOutstandingCoInits()) )
  2423. {
  2424. iisDebugOut((LOG_TYPE_WARN, _T("Outstanding CoInit in %s. WARNING."), lpszDLLFile));
  2425. }
  2426. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("------------------\n")));
  2427. return dwReturn;
  2428. }
  2429. int IsThisStringInThisCStringList(CStringList &strList, LPCTSTR szStringToLookFor)
  2430. {
  2431. int iReturn = FALSE;
  2432. if (strList.IsEmpty() == FALSE)
  2433. {
  2434. POSITION pos = NULL;
  2435. CString csOurString;
  2436. int nLen = 0;
  2437. pos = strList.GetHeadPosition();
  2438. while (pos)
  2439. {
  2440. csOurString = strList.GetAt(pos);
  2441. nLen += csOurString.GetLength() + 1;
  2442. // check if we have a match.
  2443. if (0 == _tcsicmp(csOurString, szStringToLookFor))
  2444. {
  2445. // we found a match, return true!
  2446. iReturn = TRUE;
  2447. goto IsThisStringInThisCStringList_Exit;
  2448. }
  2449. strList.GetNext(pos);
  2450. }
  2451. }
  2452. IsThisStringInThisCStringList_Exit:
  2453. return iReturn;
  2454. }
  2455. int KillProcess_Wrap(LPCTSTR lpFullPathOrJustFileName)
  2456. {
  2457. int iReturn = FALSE;
  2458. TCHAR szJustTheFileName[_MAX_FNAME];
  2459. // make sure to get only just the filename.
  2460. ReturnFileNameOnly(lpFullPathOrJustFileName, szJustTheFileName);
  2461. // Convert it to ansi for our "kill" function
  2462. char szFile[_MAX_FNAME];
  2463. #if defined(UNICODE) || defined(_UNICODE)
  2464. WideCharToMultiByte( CP_ACP, 0, (WCHAR*)szJustTheFileName, -1, szFile, _MAX_FNAME, NULL, NULL );
  2465. #else
  2466. _tcscpy(szFile, szJustTheFileName);
  2467. #endif
  2468. if (KillProcessNameReturn0(szFile) == 0)
  2469. {
  2470. iReturn = TRUE;
  2471. }
  2472. return iReturn;
  2473. }
  2474. void ProgressBarTextStack_Set(int iStringID)
  2475. {
  2476. CString csText;
  2477. MyLoadString(iStringID, csText);
  2478. ProgressBarTextStack_Push(csText);
  2479. }
  2480. void ProgressBarTextStack_Set(int iStringID, const CString& csFileName)
  2481. {
  2482. CString csText, csPart;
  2483. // configuring the %s deal....
  2484. MyLoadString(iStringID, csPart);
  2485. // configuring the "filename" deal....
  2486. csText.Format(csPart,csFileName);
  2487. ProgressBarTextStack_Push(csText);
  2488. }
  2489. void ProgressBarTextStack_Set(int iStringID, const CString& csString1, const CString& csString2)
  2490. {
  2491. CString csText, csPart;
  2492. // configuring the %s deal....
  2493. MyLoadString(iStringID, csPart);
  2494. // configuring the "filename" deal....
  2495. csText.Format(csPart,csString1, csString2);
  2496. ProgressBarTextStack_Push(csText);
  2497. }
  2498. void ProgressBarTextStack_Set(LPCTSTR szProgressTextString)
  2499. {
  2500. ProgressBarTextStack_Push(szProgressTextString);
  2501. }
  2502. void ProgressBarTextStack_Inst_Set( int ServiceNameID, int iInstanceNum)
  2503. {
  2504. CString csText, csSvcs;
  2505. // Configuring Web Site %d
  2506. MyLoadString(ServiceNameID, csSvcs);
  2507. // Configuring Web Site 1
  2508. csText.Format(csSvcs, iInstanceNum);
  2509. ProgressBarTextStack_Push(csText);
  2510. }
  2511. void ProgressBarTextStack_InstVRoot_Set( int ServiceNameID, int iInstanceNum, CString csVRName)
  2512. {
  2513. CString csText, csSvcs;
  2514. // Configuring Web Site %d, %s
  2515. MyLoadString(ServiceNameID, csSvcs);
  2516. // Configuring Web Site 1, Virtual Dir %s
  2517. csText.Format(csSvcs, iInstanceNum, csVRName);
  2518. ProgressBarTextStack_Push(csText);
  2519. }
  2520. void ProgressBarTextStack_InstInProc_Set( int ServiceNameID, int iInstanceNum, CString csVRName)
  2521. {
  2522. CString csText, csSvcs;
  2523. // Configuring Web Site %d, %s
  2524. MyLoadString(ServiceNameID, csSvcs);
  2525. // Configuring Web Site 1, In process Application %s
  2526. csText.Format(csSvcs, iInstanceNum, csVRName);
  2527. ProgressBarTextStack_Push(csText);
  2528. }
  2529. int ProcessEntry_CheckOS(IN LPCTSTR szOSstring)
  2530. {
  2531. int iTempFlag = TRUE;
  2532. int iOSTypes = 0;
  2533. if (szOSstring)
  2534. {
  2535. // This is workstation, check if we should be installing this on workstation...
  2536. if (g_pTheApp->m_eNTOSType == OT_NTW)
  2537. {
  2538. iTempFlag = FALSE;
  2539. if (IsValidNumber((LPCTSTR)szOSstring))
  2540. {iOSTypes = _ttoi(szOSstring);}
  2541. if (iOSTypes == 0) {iTempFlag = TRUE;}
  2542. if (iOSTypes == 1+2+4) {iTempFlag = TRUE;}
  2543. if (iOSTypes == 1+2) {iTempFlag = TRUE;}
  2544. if (iOSTypes == 2+4) {iTempFlag = TRUE;}
  2545. if (iOSTypes == 2) {iTempFlag = TRUE;}
  2546. }
  2547. if (g_pTheApp->m_eNTOSType == OT_NTS)
  2548. {
  2549. iTempFlag = FALSE;
  2550. if (IsValidNumber((LPCTSTR)szOSstring))
  2551. {iOSTypes = _ttoi(szOSstring);}
  2552. if (iOSTypes == 0) {iTempFlag = TRUE;}
  2553. if (iOSTypes == 1+2+4) {iTempFlag = TRUE;}
  2554. if (iOSTypes == 1+2) {iTempFlag = TRUE;}
  2555. if (iOSTypes == 1+4) {iTempFlag = TRUE;}
  2556. if (iOSTypes == 1) {iTempFlag = TRUE;}
  2557. }
  2558. if (g_pTheApp->m_eNTOSType == OT_PDC_OR_BDC)
  2559. {
  2560. iTempFlag = FALSE;
  2561. if (IsValidNumber((LPCTSTR)szOSstring))
  2562. {iOSTypes = _ttoi(szOSstring);}
  2563. if (iOSTypes == 0) {iTempFlag = TRUE;}
  2564. if (iOSTypes == 1+2+4) {iTempFlag = TRUE;}
  2565. if (iOSTypes == 1+2) {iTempFlag = TRUE;}
  2566. if (iOSTypes == 1+4) {iTempFlag = TRUE;}
  2567. if (iOSTypes == 1) {iTempFlag = TRUE;}
  2568. }
  2569. }
  2570. return iTempFlag;
  2571. }
  2572. int ProcessEntry_CheckEnterprise(IN LPCTSTR szEnterprise)
  2573. {
  2574. int iTempFlag = TRUE;
  2575. int iEnterpriseFlag = 0;
  2576. if (szEnterprise)
  2577. {
  2578. if (IsValidNumber((LPCTSTR)szEnterprise))
  2579. {iEnterpriseFlag = _ttoi(szEnterprise);}
  2580. // This entry should only get installed on enterprise.
  2581. // so check if this machine is an enterprise machine...
  2582. if (iEnterpriseFlag != 0)
  2583. {
  2584. // if this is not an enterprise machine.
  2585. // then return false, since it should not be installed.
  2586. if (TRUE == iReturnTrueIfEnterprise())
  2587. {
  2588. iTempFlag = TRUE;
  2589. }
  2590. else
  2591. {
  2592. iTempFlag = FALSE;
  2593. }
  2594. }
  2595. }
  2596. return iTempFlag;
  2597. }
  2598. int ProcessEntry_PlatArch(IN LPCTSTR szPlatArch)
  2599. {
  2600. int iTempFlag = TRUE;
  2601. int iPlatArchTypes = 0;
  2602. if (szPlatArch)
  2603. {
  2604. // This is x86, then check if we should be installing on x86
  2605. if (_tcsicmp(g_pTheApp->m_csPlatform, _T("x86")) == 0)
  2606. {
  2607. iTempFlag = FALSE;
  2608. if (IsValidNumber((LPCTSTR)szPlatArch))
  2609. {iPlatArchTypes = _ttoi(szPlatArch);}
  2610. if (iPlatArchTypes == 0) {iTempFlag = TRUE;}
  2611. if (iPlatArchTypes == 1+2) {iTempFlag = TRUE;}
  2612. if (iPlatArchTypes == 1) {iTempFlag = TRUE;}
  2613. }
  2614. if (_tcsicmp(g_pTheApp->m_csPlatform, _T("IA64")) == 0)
  2615. {
  2616. iTempFlag = FALSE;
  2617. if (IsValidNumber((LPCTSTR)szPlatArch))
  2618. {iPlatArchTypes = _ttoi(szPlatArch);}
  2619. if (iPlatArchTypes == 0) {iTempFlag = TRUE;}
  2620. if (iPlatArchTypes == 1+2) {iTempFlag = TRUE;}
  2621. if (iPlatArchTypes == 2) {iTempFlag = TRUE;}
  2622. }
  2623. }
  2624. return iTempFlag;
  2625. }
  2626. void ProcessEntry_AskLast(ThingToDo ParsedLine, int iWhichOneToUse)
  2627. {
  2628. if (_tcsicmp(ParsedLine.szMsgBoxAfter, _T("1")) == 0)
  2629. {
  2630. // just incase we have don't display user messagebox off.
  2631. int iSaveOld_AllowMessageBoxPopups = g_pTheApp->m_bAllowMessageBoxPopups;
  2632. // Make sure there are MyMessageBox popups!
  2633. // Make sure there are MyMessageBox popups!
  2634. g_pTheApp->m_bAllowMessageBoxPopups = TRUE;
  2635. if (iWhichOneToUse == 2)
  2636. {MyMessageBox( NULL, IDS_COMPLETED_FILE_CALL,ParsedLine.szData1,MB_OK | MB_SETFOREGROUND );}
  2637. else
  2638. {MyMessageBox( NULL, IDS_COMPLETED_FILE_CALL,ParsedLine.szFileName,MB_OK | MB_SETFOREGROUND );}
  2639. g_pTheApp->m_bAllowMessageBoxPopups = iSaveOld_AllowMessageBoxPopups;
  2640. }
  2641. return;
  2642. }
  2643. int ProcessEntry_AskFirst(ThingToDo ParsedLine, int iWhichOneToUse)
  2644. {
  2645. int iReturn = TRUE;
  2646. int iReturnTemp = 0;
  2647. // check if we need to ask the user if they want to call it for sure.
  2648. if (_tcsicmp(ParsedLine.szMsgBoxBefore, _T("1")) == 0)
  2649. {
  2650. // just incase we have don't display user messagebox off.
  2651. int iSaveOld_AllowMessageBoxPopups = g_pTheApp->m_bAllowMessageBoxPopups;
  2652. // Make sure there are MyMessageBox popups!
  2653. g_pTheApp->m_bAllowMessageBoxPopups = TRUE;
  2654. if (iWhichOneToUse == 2)
  2655. {
  2656. iReturnTemp = MyMessageBox(NULL, IDS_BEFORE_CALLING_FILE, ParsedLine.szData1, MB_YESNO | MB_SETFOREGROUND);
  2657. }
  2658. else
  2659. {
  2660. iReturnTemp = MyMessageBox(NULL, IDS_BEFORE_CALLING_FILE, ParsedLine.szFileName, MB_YESNO | MB_SETFOREGROUND);
  2661. }
  2662. g_pTheApp->m_bAllowMessageBoxPopups = iSaveOld_AllowMessageBoxPopups;
  2663. // display the messagebox
  2664. if (IDYES != iReturnTemp)
  2665. {
  2666. iReturn = FALSE;
  2667. iisDebugOut((LOG_TYPE_TRACE, _T("ProcessEntry_AskFirst:MyMessageBox Response = IDNO. Exiting.\n")));
  2668. }
  2669. }
  2670. return iReturn;
  2671. }
  2672. int ProcessEntry_CheckAll(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  2673. {
  2674. int iReturn = TRUE;
  2675. // Check if we pass for os system
  2676. if (!ProcessEntry_CheckOS(ParsedLine.szOS))
  2677. {
  2678. iReturn = FALSE;
  2679. 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));
  2680. goto ProcessEntry_CheckAll_Exit;
  2681. }
  2682. // check if we pass for platform arch
  2683. if (!ProcessEntry_PlatArch(ParsedLine.szPlatformArchitecture))
  2684. {
  2685. iReturn = FALSE;
  2686. 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));
  2687. goto ProcessEntry_CheckAll_Exit;
  2688. }
  2689. // check if we pass for enterprise
  2690. if (!ProcessEntry_CheckEnterprise(ParsedLine.szEnterprise))
  2691. {
  2692. iReturn = FALSE;
  2693. goto ProcessEntry_CheckAll_Exit;
  2694. }
  2695. ProcessEntry_CheckAll_Exit:
  2696. return iReturn;
  2697. }
  2698. int ProcessEntry_CallDll(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  2699. {
  2700. int iReturn = FALSE;
  2701. int iTempFlag = FALSE;
  2702. int iProgressBarUpdated = FALSE;
  2703. int iShowErrorsOnFail = TRUE;
  2704. TCHAR szDirBefore[_MAX_PATH];
  2705. _tcscpy(szDirBefore, _T(""));
  2706. // Get the type.
  2707. // 100=Type (1=DllFunction,2=DllFunctionInitOle, 2=Executable, 3=RunThisExe, 4=DoSection, 5=DoINFSection)
  2708. if ( _tcsicmp(ParsedLine.szType, _T("1")) != 0 && _tcsicmp(ParsedLine.szType, _T("2")) != 0 )
  2709. {
  2710. goto ProcessEntry_CallDll_Exit;
  2711. }
  2712. // Check if there is other criteria we need to pass
  2713. if (!ProcessEntry_CheckAll(csEntry, szTheSection, ParsedLine ) )
  2714. {
  2715. goto ProcessEntry_CallDll_Exit;
  2716. }
  2717. // Make sure we have a value for the entry point..
  2718. iTempFlag = FALSE;
  2719. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  2720. if (iTempFlag == FALSE)
  2721. {
  2722. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  2723. goto ProcessEntry_CallDll_Exit;
  2724. }
  2725. // make sure we have a filename entry
  2726. iTempFlag = FALSE;
  2727. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  2728. if (iTempFlag == FALSE)
  2729. {
  2730. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  2731. goto ProcessEntry_CallDll_Exit;
  2732. }
  2733. // make sure the szFileName exists
  2734. if (!IsFileExist(ParsedLine.szFileName))
  2735. {
  2736. // The file does not exists.
  2737. // Check if we need to display an error!
  2738. if (_tcsicmp(ParsedLine.szErrIfFileNotFound, _T("1")) == 0)
  2739. {
  2740. // display the messagebox
  2741. MyMessageBox(NULL, IDS_FILE_DOES_NOT_EXIST, ParsedLine.szFileName, ERROR_FILE_NOT_FOUND, MB_OK | MB_SETFOREGROUND);
  2742. }
  2743. else
  2744. {
  2745. iisDebugOut((LOG_TYPE_TRACE, _T("ProcessEntry_CallDll():FileDoesNotExist=%s.\n"),ParsedLine.szFileName));
  2746. }
  2747. //goto ProcessEntry_CallDll_Exit;
  2748. }
  2749. // At this point the file exists...
  2750. iShowErrorsOnFail = TRUE;
  2751. if (_tcsicmp(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T("1")) == 0)
  2752. {iShowErrorsOnFail = FALSE;}
  2753. // update the progress bar if we need to
  2754. if (_tcsicmp(ParsedLine.szProgressTitle, _T("")) != 0)
  2755. {
  2756. ProgressBarTextStack_Set(ParsedLine.szProgressTitle);
  2757. iProgressBarUpdated = TRUE;
  2758. }
  2759. // Check if we need to change to a specific dir first...
  2760. if (ParsedLine.szChangeDir)
  2761. {
  2762. if (IsFileExist(ParsedLine.szChangeDir))
  2763. {
  2764. // save the current dir
  2765. GetCurrentDirectory( _MAX_PATH, szDirBefore);
  2766. // change to this dir
  2767. SetCurrentDirectory(ParsedLine.szChangeDir);
  2768. }
  2769. }
  2770. // check if we need to ask the user if they want to call it for sure.
  2771. if (!ProcessEntry_AskFirst(ParsedLine, 1))
  2772. {
  2773. goto ProcessEntry_CallDll_Exit;
  2774. }
  2775. // Call the function!!!!!
  2776. if (_tcsicmp(ParsedLine.szType, _T("2")) == 0)
  2777. {
  2778. // Initialize OLE
  2779. // check if they want us to pass them the hmodule for this module
  2780. // so they can call our exported functions (for logging)
  2781. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0)
  2782. {
  2783. CallProcedureInDll_wrap(ParsedLine.szFileName, ParsedLine.szData1, iShowErrorsOnFail, TRUE, FUNCTION_PARAMS_HMODULE);
  2784. }
  2785. else
  2786. {
  2787. CallProcedureInDll_wrap(ParsedLine.szFileName, ParsedLine.szData1, iShowErrorsOnFail, TRUE, FUNCTION_PARAMS_NONE);
  2788. }
  2789. }
  2790. else
  2791. {
  2792. // do not initialize ole!
  2793. // check if they want us to pass them the hmodule for this module
  2794. // so they can call our exported functions (for logging)
  2795. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0)
  2796. {
  2797. CallProcedureInDll_wrap(ParsedLine.szFileName, ParsedLine.szData1, iShowErrorsOnFail, FALSE, FUNCTION_PARAMS_HMODULE);
  2798. }
  2799. else
  2800. {
  2801. CallProcedureInDll_wrap(ParsedLine.szFileName, ParsedLine.szData1, iShowErrorsOnFail, FALSE, FUNCTION_PARAMS_NONE);
  2802. }
  2803. }
  2804. iReturn = TRUE;
  2805. if (ParsedLine.szChangeDir)
  2806. {
  2807. if (szDirBefore)
  2808. {
  2809. // change back to the original dir
  2810. SetCurrentDirectory(szDirBefore);
  2811. }
  2812. }
  2813. // display the messagebox that we completed the call...
  2814. ProcessEntry_AskLast(ParsedLine,1);
  2815. ProcessEntry_CallDll_Exit:
  2816. if (TRUE == iProgressBarUpdated){ProgressBarTextStack_Pop();}
  2817. return iReturn;
  2818. }
  2819. int ProcessEntry_Call_Exe(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  2820. {
  2821. int iReturn = FALSE;
  2822. int iTempNotMinimizedFlag = FALSE;
  2823. int iTempFlag = FALSE;
  2824. int iProgressBarUpdated = FALSE;
  2825. int iShowErrorsOnFail = TRUE;
  2826. int iReturnCode = FALSE;
  2827. int iType = 0;
  2828. DWORD dwTimeOut = INFINITE;
  2829. TCHAR szDirBefore[_MAX_PATH];
  2830. _tcscpy(szDirBefore, _T(""));
  2831. // Get the type.
  2832. // 100=Type (1=DllFunction,2=DllFunctionInitOle, 2=Executable, 3=RunThisExe, 4=DoSection, 5=DoINFSection)
  2833. if ( _tcsicmp(ParsedLine.szType, _T("3")) != 0)
  2834. {
  2835. goto ProcessEntry_Call_Exe_Exit;
  2836. }
  2837. // Check if there is other criteria we need to pass
  2838. if (!ProcessEntry_CheckAll(csEntry, szTheSection, ParsedLine) )
  2839. {
  2840. goto ProcessEntry_Call_Exe_Exit;
  2841. }
  2842. // make sure we have a filename entry
  2843. iTempFlag = FALSE;
  2844. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  2845. if (iTempFlag == FALSE)
  2846. {
  2847. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  2848. goto ProcessEntry_Call_Exe_Exit;
  2849. }
  2850. iShowErrorsOnFail = TRUE;
  2851. if (_tcsicmp(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T("1")) == 0)
  2852. {iShowErrorsOnFail = FALSE;}
  2853. if (_tcsicmp(ParsedLine.szProgressTitle, _T("")) != 0)
  2854. {
  2855. ProgressBarTextStack_Set(ParsedLine.szProgressTitle);
  2856. iProgressBarUpdated = TRUE;
  2857. }
  2858. // Check if we need to change to a specific dir first...
  2859. if (ParsedLine.szChangeDir)
  2860. {
  2861. if (IsFileExist(ParsedLine.szChangeDir))
  2862. {
  2863. // save the current dir
  2864. GetCurrentDirectory( _MAX_PATH, szDirBefore);
  2865. // change to this dir
  2866. SetCurrentDirectory(ParsedLine.szChangeDir);
  2867. }
  2868. }
  2869. // check if we need to ask the user if they want to call it for sure.
  2870. if (!ProcessEntry_AskFirst(ParsedLine, 1))
  2871. {
  2872. goto ProcessEntry_Call_Exe_Exit;
  2873. }
  2874. // make sure the szFileName exists
  2875. if (!IsFileExist(ParsedLine.szFileName))
  2876. {
  2877. // The file does not exists.
  2878. // Check if we need to display an error!
  2879. if (_tcsicmp(ParsedLine.szErrIfFileNotFound, _T("1")) == 0)
  2880. {
  2881. // display the messagebox
  2882. MyMessageBox(NULL, IDS_FILE_DOES_NOT_EXIST, ParsedLine.szFileName, ERROR_FILE_NOT_FOUND, MB_OK | MB_SETFOREGROUND);
  2883. }
  2884. else
  2885. {
  2886. iisDebugOut((LOG_TYPE_TRACE, _T("ProcessEntry_Call_Exe():FileDoesNotExist=%s.\n"),ParsedLine.szFileName));
  2887. }
  2888. //goto ProcessEntry_Call_Exe_Exit;
  2889. }
  2890. // Run The Executable...
  2891. // iShowErrorsOnFail
  2892. iReturnCode = FALSE;
  2893. iType = 0;
  2894. TCHAR szFullPathString[_MAX_PATH + _MAX_PATH + _MAX_PATH];
  2895. _tcscpy(szFullPathString, ParsedLine.szFileName);
  2896. _tcscat(szFullPathString, _T(" "));
  2897. _tcscat(szFullPathString, ParsedLine.szData1);
  2898. // Check if they specified timeout in sections.
  2899. dwTimeOut = INFINITE;
  2900. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0)
  2901. {dwTimeOut = atodw(ParsedLine.szData2);}
  2902. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0)
  2903. {iType = _ttoi(ParsedLine.szData3);}
  2904. if (_tcsicmp(ParsedLine.szData4, _T("")) != 0)
  2905. {iTempNotMinimizedFlag = TRUE;}
  2906. if (ParsedLine.szData1 && _tcsicmp(ParsedLine.szData1, _T("")) != 0)
  2907. {
  2908. switch (iType)
  2909. {
  2910. case 1:
  2911. iReturnCode = RunProgram(ParsedLine.szFileName, ParsedLine.szData1, !iTempNotMinimizedFlag, dwTimeOut, FALSE);
  2912. break;
  2913. case 2:
  2914. iReturnCode = RunProgram(szFullPathString, NULL, !iTempNotMinimizedFlag, dwTimeOut, FALSE);
  2915. break;
  2916. default:
  2917. iReturnCode = RunProgram(NULL, szFullPathString, !iTempNotMinimizedFlag, dwTimeOut, FALSE);
  2918. }
  2919. }
  2920. else
  2921. {
  2922. iReturnCode = RunProgram(ParsedLine.szFileName, NULL, !iTempNotMinimizedFlag, dwTimeOut, FALSE);
  2923. }
  2924. if (iReturnCode != TRUE)
  2925. {
  2926. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szFileName, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  2927. else{iisDebugOut((LOG_TYPE_TRACE, _T("RunProgram(%s). Failed. Err=0x%x.\n"), ParsedLine.szFileName, GetLastError() ));}
  2928. }
  2929. iReturn = TRUE;
  2930. // change back to the original dir
  2931. if (ParsedLine.szChangeDir)
  2932. {if (szDirBefore){SetCurrentDirectory(szDirBefore);}}
  2933. // display the messagebox that we completed the call...
  2934. ProcessEntry_AskLast(ParsedLine,1);
  2935. ProcessEntry_Call_Exe_Exit:
  2936. if (TRUE == iProgressBarUpdated){ProgressBarTextStack_Pop();}
  2937. return iReturn;
  2938. }
  2939. // 100=4
  2940. int ProcessEntry_Internal_iisdll(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  2941. {
  2942. int iReturn = FALSE;
  2943. int iTempFlag = FALSE;
  2944. int iProgressBarUpdated = FALSE;
  2945. int iShowErrorsOnFail = TRUE;
  2946. int iReturnCode = FALSE;
  2947. DWORD dwTimeOut = INFINITE;
  2948. int iFound = FALSE;
  2949. TCHAR szDirBefore[_MAX_PATH];
  2950. _tcscpy(szDirBefore, _T(""));
  2951. // Get the type.
  2952. // 100=Type (1=DllFunction,2=DllFunctionInitOle, 2=Executable, 3=RunThisExe, 4=DoSection, 5=DoINFSection)
  2953. if ( _tcsicmp(ParsedLine.szType, _T("4")) != 0)
  2954. {
  2955. goto ProcessEntry_Internal_iisdll_Exit;
  2956. }
  2957. // Check if there is other criteria we need to pass
  2958. if (!ProcessEntry_CheckAll(csEntry, szTheSection, ParsedLine) )
  2959. {
  2960. goto ProcessEntry_Internal_iisdll_Exit;
  2961. }
  2962. // make sure we have a filename entry
  2963. iTempFlag = FALSE;
  2964. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  2965. if (iTempFlag == FALSE)
  2966. {
  2967. iisDebugOut((LOG_TYPE_TRACE, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  2968. goto ProcessEntry_Internal_iisdll_Exit;
  2969. }
  2970. iShowErrorsOnFail = TRUE;
  2971. if (_tcsicmp(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T("1")) == 0)
  2972. {iShowErrorsOnFail = FALSE;}
  2973. if (_tcsicmp(ParsedLine.szProgressTitle, _T("")) != 0)
  2974. {
  2975. ProgressBarTextStack_Set(ParsedLine.szProgressTitle);
  2976. iProgressBarUpdated = TRUE;
  2977. }
  2978. // Check if we need to change to a specific dir first...
  2979. if (ParsedLine.szChangeDir)
  2980. {
  2981. if (IsFileExist(ParsedLine.szChangeDir))
  2982. {
  2983. // save the current dir
  2984. GetCurrentDirectory( _MAX_PATH, szDirBefore);
  2985. // change to this dir
  2986. SetCurrentDirectory(ParsedLine.szChangeDir);
  2987. }
  2988. }
  2989. // check if we need to ask the user if they want to call it for sure.
  2990. if (!ProcessEntry_AskFirst(ParsedLine, 1))
  2991. {
  2992. goto ProcessEntry_Internal_iisdll_Exit;
  2993. }
  2994. // Get the internal function to call...
  2995. if (_tcsicmp(ParsedLine.szFileName, _T("Register_iis_common")) == 0)
  2996. {iReturnCode = Register_iis_common();iFound=TRUE;}
  2997. if (_tcsicmp(ParsedLine.szFileName, _T("Register_iis_core")) == 0)
  2998. {iReturnCode = Register_iis_core();iFound=TRUE;}
  2999. if (_tcsicmp(ParsedLine.szFileName, _T("Register_iis_inetmgr")) == 0)
  3000. {iReturnCode = Register_iis_inetmgr();iFound=TRUE;}
  3001. if (_tcsicmp(ParsedLine.szFileName, _T("Register_iis_pwmgr")) == 0)
  3002. {iReturnCode = Register_iis_pwmgr();iFound=TRUE;}
  3003. if (_tcsicmp(ParsedLine.szFileName, _T("Register_iis_doc")) == 0)
  3004. {iReturnCode = Register_iis_doc();iFound=TRUE;}
  3005. if (_tcsicmp(ParsedLine.szFileName, _T("Register_iis_www")) == 0)
  3006. {iReturnCode = Register_iis_www();iFound=TRUE;}
  3007. if (_tcsicmp(ParsedLine.szFileName, _T("Register_iis_ftp")) == 0)
  3008. {iReturnCode = Register_iis_ftp();iFound=TRUE;}
  3009. if (_tcsicmp(ParsedLine.szFileName, _T("Unregister_old_asp")) == 0)
  3010. {iReturnCode = Unregister_old_asp();iFound=TRUE;}
  3011. if (_tcsicmp(ParsedLine.szFileName, _T("Unregister_iis_common")) == 0)
  3012. {iReturnCode = Unregister_iis_common();iFound=TRUE;}
  3013. if (_tcsicmp(ParsedLine.szFileName, _T("Unregister_iis_core")) == 0)
  3014. {iReturnCode = Unregister_iis_core();iFound=TRUE;}
  3015. if (_tcsicmp(ParsedLine.szFileName, _T("Unregister_iis_inetmgr")) == 0)
  3016. {iReturnCode = Unregister_iis_inetmgr();iFound=TRUE;}
  3017. if (_tcsicmp(ParsedLine.szFileName, _T("Unregister_iis_pwmgr")) == 0)
  3018. {iReturnCode = Unregister_iis_pwmgr();iFound=TRUE;}
  3019. if (_tcsicmp(ParsedLine.szFileName, _T("Unregister_iis_www")) == 0)
  3020. {iReturnCode = Unregister_iis_www();iFound=TRUE;}
  3021. if (_tcsicmp(ParsedLine.szFileName, _T("Unregister_iis_ftp")) == 0)
  3022. {iReturnCode = Unregister_iis_ftp();iFound=TRUE;}
  3023. if (iFound != TRUE)
  3024. {
  3025. iisDebugOut((LOG_TYPE_ERROR, _T("%s():FAILURE. Internal Function Does not exist. entry=%s. Section=%s.\n"), _T("ProcessEntry_Internal_iisdll"), csEntry, szTheSection));
  3026. }
  3027. /*
  3028. if (iReturnCode != TRUE)
  3029. {
  3030. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szFileName, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  3031. else{iisDebugOut((LOG_TYPE_TRACE, _T("RunProgram(%s). Failed. Err=0x%x.\n"), ParsedLine.szFileName, GetLastError() ));}
  3032. }
  3033. */
  3034. iReturn = TRUE;
  3035. // change back to the original dir
  3036. if (ParsedLine.szChangeDir)
  3037. {if (szDirBefore){SetCurrentDirectory(szDirBefore);}}
  3038. // display the messagebox that we completed the call...
  3039. ProcessEntry_AskLast(ParsedLine,1);
  3040. ProcessEntry_Internal_iisdll_Exit:
  3041. if (TRUE == iProgressBarUpdated){ProgressBarTextStack_Pop();}
  3042. return iReturn;
  3043. }
  3044. int ProcessEntry_Call_Section(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  3045. {
  3046. int iReturn = FALSE;
  3047. int iTempFlag = FALSE;
  3048. int iProgressBarUpdated = FALSE;
  3049. int iShowErrorsOnFail = TRUE;
  3050. TCHAR szDirBefore[_MAX_PATH];
  3051. _tcscpy(szDirBefore, _T(""));
  3052. // Get the type.
  3053. // 100=Type (1=DllFunction,2=DllFunctionInitOle, 2=Executable, 3=RunThisExe, 4=DoSection, 5=DoINFSection)
  3054. if ( _tcsicmp(ParsedLine.szType, _T("0")) != 0 && _tcsicmp(ParsedLine.szType, _T("5")) != 0 && _tcsicmp(ParsedLine.szType, _T("6")) != 0 )
  3055. {
  3056. goto ProcessEntry_6_Exit;
  3057. }
  3058. // make sure we have a INF Section
  3059. iTempFlag = FALSE;
  3060. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  3061. if (iTempFlag == FALSE)
  3062. {
  3063. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3064. goto ProcessEntry_6_Exit;
  3065. }
  3066. // Check if there is other criteria we need to pass
  3067. if (!ProcessEntry_CheckAll(csEntry, ParsedLine.szData1, ParsedLine) )
  3068. {
  3069. goto ProcessEntry_6_Exit;
  3070. }
  3071. // set the show erros on fail flag
  3072. iShowErrorsOnFail = TRUE;
  3073. if (_tcsicmp(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T("1")) == 0)
  3074. {iShowErrorsOnFail = FALSE;}
  3075. // update the progress bar if we need to
  3076. if (_tcsicmp(ParsedLine.szProgressTitle, _T("")) != 0)
  3077. {
  3078. ProgressBarTextStack_Set(ParsedLine.szProgressTitle);
  3079. iProgressBarUpdated = TRUE;
  3080. }
  3081. // Check if we need to change to a specific dir first...
  3082. if (ParsedLine.szChangeDir)
  3083. {
  3084. if (IsFileExist(ParsedLine.szChangeDir))
  3085. {
  3086. // save the current dir
  3087. GetCurrentDirectory( _MAX_PATH, szDirBefore);
  3088. // change to this dir
  3089. SetCurrentDirectory(ParsedLine.szChangeDir);
  3090. }
  3091. }
  3092. // check if we need to ask the user if they want to call it for sure.
  3093. if (!ProcessEntry_AskFirst(ParsedLine, 2))
  3094. {
  3095. goto ProcessEntry_6_Exit;
  3096. }
  3097. //
  3098. //
  3099. // Run The INF Section ...
  3100. //
  3101. // ParsedLine.szData1
  3102. //
  3103. if ( _tcsicmp(ParsedLine.szType, _T("5")) == 0)
  3104. {
  3105. //
  3106. // Do another one of these "special" install sections
  3107. //
  3108. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData1));
  3109. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData1);
  3110. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData1, iTempFlag));
  3111. // Check if it failed...
  3112. if (FALSE == iTempFlag)
  3113. {
  3114. iisDebugOut((LOG_TYPE_TRACE, _T("SetupInstallFromInfSection(%s). section missing\n"), ParsedLine.szData1));
  3115. }
  3116. }
  3117. if ( _tcsicmp(ParsedLine.szType, _T("6")) == 0)
  3118. {
  3119. //
  3120. // Do a regular ole inf section
  3121. //
  3122. TSTR strTempSectionName;
  3123. if ( strTempSectionName.Copy( ParsedLine.szData1 ) &&
  3124. GetSectionNameToDo(g_pTheApp->m_hInfHandle, &strTempSectionName)
  3125. )
  3126. {
  3127. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling InstallInfSection:%1!s!:Start.\n"), ParsedLine.szData1));
  3128. iTempFlag = InstallInfSection_NoFiles(g_pTheApp->m_hInfHandle,_T(""),strTempSectionName.QueryStr());
  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. TSTR strTempSectionName;
  3154. if ( strTempSectionName.Copy( ParsedLine.szData1 ) &&
  3155. GetSectionNameToDo(g_pTheApp->m_hInfHandle, &strTempSectionName)
  3156. )
  3157. {
  3158. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("Calling SetupInstallFilesFromInfSection:%1!s!, copytype=%2!d!:Start.\n"), ParsedLine.szData1, iCopyType));
  3159. iTempFlag = SetupInstallFilesFromInfSection(g_pTheApp->m_hInfHandle,NULL,g_GlobalFileQueueHandle,strTempSectionName.QueryStr(),NULL,iCopyType);
  3160. g_GlobalFileQueueHandle_ReturnError = iTempFlag;
  3161. }
  3162. }
  3163. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling SetupInstallFilesFromInfSection:%1!s!:End.\n"), ParsedLine.szData1));
  3164. // Check if it failed...
  3165. if (FALSE == iTempFlag)
  3166. {
  3167. // the call failed..
  3168. iisDebugOut((LOG_TYPE_WARN, _T("SetupInstallFromInfSection(%s). Failed. Err=0x%x.\n"), ParsedLine.szData1, GetLastError() ));
  3169. }
  3170. }
  3171. iReturn = TRUE;
  3172. if (ParsedLine.szChangeDir)
  3173. {
  3174. if (szDirBefore)
  3175. {
  3176. // change back to the original dir
  3177. SetCurrentDirectory(szDirBefore);
  3178. }
  3179. }
  3180. // display the messagebox that we completed the call...
  3181. ProcessEntry_AskLast(ParsedLine,2);
  3182. ProcessEntry_6_Exit:
  3183. if (TRUE == iProgressBarUpdated){ProgressBarTextStack_Pop();}
  3184. return iReturn;
  3185. }
  3186. int ProcessEntry_Misc1(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  3187. {
  3188. int iReturn = FALSE;
  3189. int iTempFlag = FALSE;
  3190. int iProgressBarUpdated = FALSE;
  3191. int iShowErrorsOnFail = TRUE;
  3192. TCHAR szDirBefore[_MAX_PATH];
  3193. _tcscpy(szDirBefore, _T(""));
  3194. // Get the type.
  3195. if ( _tcsicmp(ParsedLine.szType, _T("7")) != 0 && _tcsicmp(ParsedLine.szType, _T("8")) != 0 &&
  3196. _tcsicmp(ParsedLine.szType, _T("9")) != 0 && _tcsicmp(ParsedLine.szType, _T("10")) != 0 &&
  3197. _tcsicmp(ParsedLine.szType, _T("11")) != 0 && _tcsicmp(ParsedLine.szType, _T("12")) != 0 &&
  3198. _tcsicmp(ParsedLine.szType, _T("12")) != 0 && _tcsicmp(ParsedLine.szType, _T("13")) != 0 &&
  3199. _tcsicmp(ParsedLine.szType, _T("14")) != 0 && _tcsicmp(ParsedLine.szType, _T("17")) != 0 &&
  3200. _tcsicmp(ParsedLine.szType, _T("18")) != 0
  3201. )
  3202. {
  3203. goto ProcessEntry_Misc1_Exit;
  3204. }
  3205. // Check if there is other criteria we need to pass
  3206. if (!ProcessEntry_CheckAll(csEntry, szTheSection, ParsedLine) )
  3207. {
  3208. goto ProcessEntry_Misc1_Exit;
  3209. }
  3210. // make sure we have a filename entry
  3211. iTempFlag = FALSE;
  3212. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  3213. if (iTempFlag == FALSE)
  3214. {
  3215. // type 10
  3216. // type 12 do not need filename
  3217. if ( _tcsicmp(ParsedLine.szType, _T("10")) != 0 && _tcsicmp(ParsedLine.szType, _T("12")) != 0)
  3218. {
  3219. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3220. goto ProcessEntry_Misc1_Exit;
  3221. }
  3222. }
  3223. //
  3224. // Counters.ini files are always in the system dir
  3225. // tack on the extra stuff, and make sure the file exists...
  3226. //
  3227. if ( _tcsicmp(ParsedLine.szType, _T("7")) == 0)
  3228. {
  3229. CString csFullFilePath;
  3230. csFullFilePath = g_pTheApp->m_csSysDir;
  3231. csFullFilePath += _T("\\");
  3232. csFullFilePath += ParsedLine.szFileName;
  3233. // make sure the szFileName exists
  3234. if (!IsFileExist(csFullFilePath))
  3235. {
  3236. // The file does not exists.
  3237. // Check if we need to display an error!
  3238. if (_tcsicmp(ParsedLine.szErrIfFileNotFound, _T("1")) == 0)
  3239. {
  3240. // display the messagebox
  3241. MyMessageBox(NULL, IDS_FILE_DOES_NOT_EXIST, csFullFilePath, ERROR_FILE_NOT_FOUND, MB_OK | MB_SETFOREGROUND);
  3242. }
  3243. else
  3244. {
  3245. iisDebugOut((LOG_TYPE_TRACE, _T("ProcessEntry_Misc1():FileDoesNotExist=%s.\n"),csFullFilePath));
  3246. }
  3247. goto ProcessEntry_Misc1_Exit;
  3248. }
  3249. }
  3250. //
  3251. // Check if the binary exists for addevent log!
  3252. //
  3253. if ( _tcsicmp(ParsedLine.szType, _T("9")) == 0)
  3254. {
  3255. // make sure the szFileName exists
  3256. if (!IsFileExist(ParsedLine.szFileName))
  3257. {
  3258. // The file does not exists.
  3259. // Check if we need to display an error!
  3260. if (_tcsicmp(ParsedLine.szErrIfFileNotFound, _T("1")) == 0)
  3261. {
  3262. // display the messagebox
  3263. MyMessageBox(NULL, IDS_FILE_DOES_NOT_EXIST, ParsedLine.szFileName, ERROR_FILE_NOT_FOUND, MB_OK | MB_SETFOREGROUND);
  3264. }
  3265. else
  3266. {
  3267. iisDebugOut((LOG_TYPE_TRACE, _T("ProcessEntry_Misc1():FileDoesNotExist=%s.\n"),ParsedLine.szFileName));
  3268. }
  3269. goto ProcessEntry_Misc1_Exit;
  3270. }
  3271. }
  3272. // if this is for addevent log, then check for the other information...
  3273. // AddEventLog( TRUE, _T("W3SVC"), csBinPath, 0x0 );
  3274. // InstallPerformance(REG_WWWPERFORMANCE, _T("w3ctrs.DLL"), _T("OpenW3PerformanceData"), _T("CloseW3PerformanceData"), _T("CollectW3PerformanceData"));
  3275. if ( _tcsicmp(ParsedLine.szType, _T("9")) == 0 || _tcsicmp(ParsedLine.szType, _T("13")) == 0)
  3276. {
  3277. // make sure we have a szData1 entry (
  3278. iTempFlag = FALSE;
  3279. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  3280. if (iTempFlag == FALSE)
  3281. {
  3282. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3283. goto ProcessEntry_Misc1_Exit;
  3284. }
  3285. // make sure we have a szData2 entry
  3286. iTempFlag = FALSE;
  3287. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  3288. if (iTempFlag == FALSE)
  3289. {
  3290. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3291. goto ProcessEntry_Misc1_Exit;
  3292. }
  3293. // make sure we have a szData3 entry
  3294. iTempFlag = FALSE;
  3295. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {iTempFlag = TRUE;}
  3296. if (iTempFlag == FALSE)
  3297. {
  3298. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3299. goto ProcessEntry_Misc1_Exit;
  3300. }
  3301. if ( _tcsicmp(ParsedLine.szType, _T("13")) == 0)
  3302. {
  3303. // make sure we have a szData4 entry
  3304. iTempFlag = FALSE;
  3305. if (_tcsicmp(ParsedLine.szData4, _T("")) != 0) {iTempFlag = TRUE;}
  3306. if (iTempFlag == FALSE)
  3307. {
  3308. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz105_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3309. goto ProcessEntry_Misc1_Exit;
  3310. }
  3311. }
  3312. }
  3313. // if this is for addevent log, then check for the other information...
  3314. //RemoveEventLog( FALSE, _T("W3Ctrs") );
  3315. if ( _tcsicmp(ParsedLine.szType, _T("10")) == 0)
  3316. {
  3317. // make sure we have a szData1 entry
  3318. iTempFlag = FALSE;
  3319. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  3320. if (iTempFlag == FALSE)
  3321. {
  3322. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3323. goto ProcessEntry_Misc1_Exit;
  3324. }
  3325. // make sure we have a szData2 entry
  3326. iTempFlag = FALSE;
  3327. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  3328. if (iTempFlag == FALSE)
  3329. {
  3330. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3331. goto ProcessEntry_Misc1_Exit;
  3332. }
  3333. }
  3334. // if this is for installAgent, check for other data..
  3335. //
  3336. // INT InstallAgent( CString nlsName, CString nlsPath )
  3337. // INT RemoveAgent( CString nlsServiceName )
  3338. //
  3339. if ( _tcsicmp(ParsedLine.szType, _T("11")) == 0 || _tcsicmp(ParsedLine.szType, _T("12")) == 0)
  3340. {
  3341. // make sure we have a szData1 entry
  3342. iTempFlag = FALSE;
  3343. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  3344. if (iTempFlag == FALSE)
  3345. {
  3346. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3347. goto ProcessEntry_Misc1_Exit;
  3348. }
  3349. }
  3350. iShowErrorsOnFail = TRUE;
  3351. if (_tcsicmp(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T("1")) == 0)
  3352. {iShowErrorsOnFail = FALSE;}
  3353. if (_tcsicmp(ParsedLine.szProgressTitle, _T("")) != 0)
  3354. {
  3355. ProgressBarTextStack_Set(ParsedLine.szProgressTitle);
  3356. iProgressBarUpdated = TRUE;
  3357. }
  3358. // Check if we need to change to a specific dir first...
  3359. if (ParsedLine.szChangeDir)
  3360. {
  3361. if (IsFileExist(ParsedLine.szChangeDir))
  3362. {
  3363. // save the current dir
  3364. GetCurrentDirectory( _MAX_PATH, szDirBefore);
  3365. // change to this dir
  3366. SetCurrentDirectory(ParsedLine.szChangeDir);
  3367. }
  3368. }
  3369. // check if we need to ask the user if they want to call it for sure.
  3370. if (!ProcessEntry_AskFirst(ParsedLine, 1))
  3371. {
  3372. goto ProcessEntry_Misc1_Exit;
  3373. }
  3374. //
  3375. // send this to the lodctr function...
  3376. // lodctr(_T("w3ctrs.ini"));
  3377. //
  3378. // see if it's lodctr or unlodctr ....
  3379. //
  3380. if ( _tcsicmp(ParsedLine.szType, _T("7")) == 0)
  3381. {
  3382. lodctr(ParsedLine.szFileName);
  3383. }
  3384. // if this is a unlodctr, should look like this....
  3385. //
  3386. // unlodctr( _T("W3SVC") );
  3387. //
  3388. if ( _tcsicmp(ParsedLine.szType, _T("8")) == 0)
  3389. {
  3390. unlodctr(ParsedLine.szFileName);
  3391. }
  3392. // if this is a AddEventLog, should look like this...
  3393. //
  3394. // AddEventLog( TRUE, _T("W3SVC"), csBinPath, 0x0 );
  3395. //
  3396. if ( _tcsicmp(ParsedLine.szType, _T("9")) == 0)
  3397. {
  3398. int iTempSystemFlag = 0;
  3399. int dwTempEventLogtype = 0;
  3400. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0){iTempSystemFlag = 1;}
  3401. dwTempEventLogtype = atodw(ParsedLine.szData3);
  3402. // Call event log registration function
  3403. AddEventLog( iTempSystemFlag, ParsedLine.szData1, ParsedLine.szFileName, dwTempEventLogtype);
  3404. }
  3405. // if this is a RemoveEventLog, should look like this...
  3406. //
  3407. // RemoveEventLog( FALSE, _T("W3Ctrs") );
  3408. //
  3409. if ( _tcsicmp(ParsedLine.szType, _T("10")) == 0)
  3410. {
  3411. int iTempSystemFlag = 0;
  3412. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0){iTempSystemFlag = 1;}
  3413. // Call event log registration function
  3414. RemoveEventLog(iTempSystemFlag, ParsedLine.szData1);
  3415. }
  3416. // if this is installagent
  3417. //
  3418. // INT InstallAgent( CString nlsName, CString nlsPath )
  3419. // INT RemoveAgent( CString nlsServiceName )
  3420. //
  3421. if ( _tcsicmp(ParsedLine.szType, _T("11")) == 0)
  3422. {
  3423. InstallAgent(ParsedLine.szData1, ParsedLine.szFileName);
  3424. }
  3425. if ( _tcsicmp(ParsedLine.szType, _T("12")) == 0)
  3426. {
  3427. RemoveAgent(ParsedLine.szData1);
  3428. }
  3429. if ( _tcsicmp(ParsedLine.szType, _T("13")) == 0)
  3430. {
  3431. InstallPerformance(ParsedLine.szData1, ParsedLine.szFileName, ParsedLine.szData2, ParsedLine.szData3, ParsedLine.szData4);
  3432. }
  3433. if ( _tcsicmp(ParsedLine.szType, _T("14")) == 0)
  3434. {
  3435. CString csPath = ParsedLine.szFileName;
  3436. CreateLayerDirectory(csPath);
  3437. }
  3438. if ( _tcsicmp(ParsedLine.szType, _T("17")) == 0)
  3439. {
  3440. int iUseWildCards = FALSE;
  3441. if (_tcsicmp(ParsedLine.szData1, _T("1")) == 0){iUseWildCards = TRUE;}
  3442. CString csPath = ParsedLine.szFileName;
  3443. if (iUseWildCards)
  3444. {
  3445. TCHAR szTempDir[_MAX_DRIVE + _MAX_PATH];
  3446. TCHAR szTempFileName[_MAX_PATH + _MAX_EXT];
  3447. if (ReturnFilePathOnly(csPath,szTempDir))
  3448. {
  3449. if (TRUE == ReturnFileNameOnly(csPath, szTempFileName))
  3450. {DeleteFilesWildcard(szTempDir,szTempFileName);}
  3451. }
  3452. }
  3453. else
  3454. {
  3455. InetDeleteFile(csPath);
  3456. }
  3457. }
  3458. if ( _tcsicmp(ParsedLine.szType, _T("18")) == 0)
  3459. {
  3460. int iTempDeleteEvenIfFull = FALSE;
  3461. if (_tcsicmp(ParsedLine.szData1, _T("1")) == 0){iTempDeleteEvenIfFull = 1;}
  3462. CString csPath = ParsedLine.szFileName;
  3463. if (iTempDeleteEvenIfFull)
  3464. {
  3465. RecRemoveDir(csPath);
  3466. }
  3467. else
  3468. {
  3469. RecRemoveEmptyDir(csPath);
  3470. }
  3471. }
  3472. // We called the function, so return true.
  3473. iReturn = TRUE;
  3474. // change back to the original dir
  3475. if (ParsedLine.szChangeDir){if (szDirBefore){SetCurrentDirectory(szDirBefore);}}
  3476. ProcessEntry_AskLast(ParsedLine, 1);
  3477. ProcessEntry_Misc1_Exit:
  3478. if (TRUE == iProgressBarUpdated){ProgressBarTextStack_Pop();}
  3479. return iReturn;
  3480. }
  3481. int ProcessEntry_SVC_Clus(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  3482. {
  3483. int iReturn = FALSE;
  3484. int iReturnTemp = FALSE;
  3485. int iTempFlag = FALSE;
  3486. int iProgressBarUpdated = FALSE;
  3487. int iShowErrorsOnFail = TRUE;
  3488. DWORD dwFailed = ERROR_SUCCESS;
  3489. // Get the type.
  3490. if ( _tcsicmp(ParsedLine.szType, _T("50")) != 0 && _tcsicmp(ParsedLine.szType, _T("51")) != 0 &&
  3491. _tcsicmp(ParsedLine.szType, _T("52")) != 0 && _tcsicmp(ParsedLine.szType, _T("53")) != 0 &&
  3492. _tcsicmp(ParsedLine.szType, _T("54")) != 0 && _tcsicmp(ParsedLine.szType, _T("55")) != 0 &&
  3493. _tcsicmp(ParsedLine.szType, _T("56")) != 0 && _tcsicmp(ParsedLine.szType, _T("57")) != 0 &&
  3494. _tcsicmp(ParsedLine.szType, _T("58")) != 0 && _tcsicmp(ParsedLine.szType, _T("59")) != 0 &&
  3495. _tcsicmp(ParsedLine.szType, _T("60")) != 0 && _tcsicmp(ParsedLine.szType, _T("61")) != 0 &&
  3496. _tcsicmp(ParsedLine.szType, _T("62")) != 0 && _tcsicmp(ParsedLine.szType, _T("63")) != 0 &&
  3497. _tcsicmp(ParsedLine.szType, _T("64")) != 0 && _tcsicmp(ParsedLine.szType, _T("65")) != 0 &&
  3498. _tcsicmp(ParsedLine.szType, _T("66")) != 0 && _tcsicmp(ParsedLine.szType, _T("67")) != 0 &&
  3499. _tcsicmp(ParsedLine.szType, _T("68")) != 0 && _tcsicmp(ParsedLine.szType, _T("69")) != 0
  3500. )
  3501. {
  3502. goto ProcessEntry_SVC_Clus_Exit;
  3503. }
  3504. // Check if there is other criteria we need to pass
  3505. if (!ProcessEntry_CheckAll(csEntry, szTheSection, ParsedLine) )
  3506. {
  3507. goto ProcessEntry_SVC_Clus_Exit;
  3508. }
  3509. if (_tcsicmp(ParsedLine.szType, _T("66")) == 0 || _tcsicmp(ParsedLine.szType, _T("67")) == 0)
  3510. {
  3511. // make sure not to require 102 parameter for 66 or 67
  3512. }
  3513. else
  3514. {
  3515. // make sure we have a szData1 entry
  3516. iTempFlag = FALSE;
  3517. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  3518. if (iTempFlag == FALSE)
  3519. {
  3520. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3521. goto ProcessEntry_SVC_Clus_Exit;
  3522. }
  3523. }
  3524. if ( _tcsicmp(ParsedLine.szType, _T("50")) == 0 || _tcsicmp(ParsedLine.szType, _T("52")) == 0)
  3525. {
  3526. // make sure we have a filename entry
  3527. iTempFlag = FALSE;
  3528. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  3529. if (iTempFlag == FALSE)
  3530. {
  3531. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3532. goto ProcessEntry_SVC_Clus_Exit;
  3533. }
  3534. CString csFullFilePath;
  3535. // Check if the file exists....
  3536. if ( _tcsicmp(ParsedLine.szType, _T("50")) == 0)
  3537. {
  3538. csFullFilePath = g_pTheApp->m_csSysDir;
  3539. csFullFilePath += _T("\\Drivers\\");
  3540. csFullFilePath += ParsedLine.szFileName;
  3541. }
  3542. else
  3543. {
  3544. csFullFilePath = ParsedLine.szFileName;
  3545. }
  3546. // make sure the szFileName exists
  3547. if (!IsFileExist(csFullFilePath))
  3548. {
  3549. // The file does not exists.
  3550. // Check if we need to display an error!
  3551. if (_tcsicmp(ParsedLine.szErrIfFileNotFound, _T("1")) == 0)
  3552. {
  3553. // display the messagebox
  3554. MyMessageBox(NULL, IDS_FILE_DOES_NOT_EXIST, csFullFilePath, ERROR_FILE_NOT_FOUND, MB_OK | MB_SETFOREGROUND);
  3555. goto ProcessEntry_SVC_Clus_Exit;
  3556. }
  3557. else
  3558. {
  3559. iisDebugOut((LOG_TYPE_TRACE, _T("o ProcessEntry_SVC_Clus():FileDoesNotExist=%s.\n"),csFullFilePath));
  3560. }
  3561. }
  3562. // make sure we have a szData2 entry
  3563. iTempFlag = FALSE;
  3564. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  3565. if (iTempFlag == FALSE)
  3566. {
  3567. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3568. goto ProcessEntry_SVC_Clus_Exit;
  3569. }
  3570. }
  3571. iShowErrorsOnFail = TRUE;
  3572. if (_tcsicmp(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T("1")) == 0)
  3573. {iShowErrorsOnFail = FALSE;}
  3574. if (_tcsicmp(ParsedLine.szProgressTitle, _T("")) != 0)
  3575. {
  3576. ProgressBarTextStack_Set(ParsedLine.szProgressTitle);
  3577. iProgressBarUpdated = TRUE;
  3578. }
  3579. // check if we need to ask the user if they want to call it for sure.
  3580. if (!ProcessEntry_AskFirst(ParsedLine, 1))
  3581. {
  3582. goto ProcessEntry_SVC_Clus_Exit;
  3583. }
  3584. // Run The Executable...
  3585. // iShowErrorsOnFail
  3586. dwFailed = ERROR_SUCCESS;
  3587. // Call the function!!!!!
  3588. if (_tcsicmp(ParsedLine.szType, _T("50")) == 0)
  3589. {
  3590. // Create the driver, retry if failed...
  3591. dwFailed = CreateDriver_Wrap(ParsedLine.szData1, ParsedLine.szData2, ParsedLine.szFileName, TRUE);
  3592. if (dwFailed != ERROR_SUCCESS)
  3593. {
  3594. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szFileName, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  3595. else{iisDebugOut((LOG_TYPE_ERROR, _T("CreateDriver(%s). Failed. Err=0x%x.\n"), ParsedLine.szFileName, GetLastError() ));}
  3596. }
  3597. else
  3598. {
  3599. iReturn = TRUE;
  3600. }
  3601. }
  3602. if (_tcsicmp(ParsedLine.szType, _T("51")) == 0)
  3603. {
  3604. // Remove driver.
  3605. dwFailed = InetDeleteService( ParsedLine.szData1 );
  3606. if (dwFailed != 0)
  3607. {
  3608. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szData1, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  3609. else{iisDebugOut((LOG_TYPE_ERROR, _T("InetDeleteService(%s). Failed. Err=0x%x.\n"), ParsedLine.szData1, GetLastError() ));}
  3610. }
  3611. else
  3612. {
  3613. iReturn = TRUE;
  3614. }
  3615. // flag the reboot flag.
  3616. SetRebootFlag();
  3617. }
  3618. if (_tcsicmp(ParsedLine.szType, _T("52")) == 0)
  3619. {
  3620. // Create the service, retry if failed...
  3621. dwFailed = CreateService_wrap(ParsedLine.szData1, ParsedLine.szData2, ParsedLine.szFileName, ParsedLine.szData3, ParsedLine.szData4, TRUE);
  3622. if (dwFailed != ERROR_SUCCESS)
  3623. {
  3624. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szFileName, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  3625. else{iisDebugOut((LOG_TYPE_ERROR, _T("CreateService(%s). Failed. Err=0x%x.\n"), ParsedLine.szFileName, GetLastError() ));}
  3626. }
  3627. else
  3628. {
  3629. iReturn = TRUE;
  3630. }
  3631. }
  3632. if (_tcsicmp(ParsedLine.szType, _T("53")) == 0)
  3633. {
  3634. // Remove Service.
  3635. dwFailed = InetDeleteService( ParsedLine.szData1 );
  3636. if (dwFailed != 0 && dwFailed != ERROR_SERVICE_DOES_NOT_EXIST)
  3637. {
  3638. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szData1, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  3639. else{iisDebugOut((LOG_TYPE_ERROR, _T("InetDeleteService(%s). Failed. Err=0x%x.\n"), ParsedLine.szData1, GetLastError() ));}
  3640. }
  3641. else
  3642. {
  3643. iReturn = TRUE;
  3644. }
  3645. }
  3646. if (_tcsicmp(ParsedLine.szType, _T("54")) == 0)
  3647. {
  3648. // Start Service
  3649. dwFailed = InetStartService(ParsedLine.szData1);
  3650. if (dwFailed == 0 || dwFailed == ERROR_SERVICE_ALREADY_RUNNING)
  3651. {
  3652. // yeah, the service started.
  3653. iReturn = TRUE;
  3654. }
  3655. else
  3656. {
  3657. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szData1, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  3658. else{iisDebugOut((LOG_TYPE_WARN, _T("InetStartService(%s). Unable to start. Err=0x%x.\n"), ParsedLine.szData1, GetLastError() ));}
  3659. }
  3660. }
  3661. if (_tcsicmp(ParsedLine.szType, _T("55")) == 0)
  3662. {
  3663. int iAddToRestartList=FALSE;
  3664. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0) {iAddToRestartList=TRUE;}
  3665. // Stop Service
  3666. dwFailed = StopServiceAndDependencies(ParsedLine.szData1, iAddToRestartList);
  3667. if (dwFailed == FALSE)
  3668. {
  3669. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szData1, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  3670. else{iisDebugOut((LOG_TYPE_ERROR, _T("StopServiceAndDependencies(%s). Failed. Err=0x%x.\n"), ParsedLine.szData1, GetLastError() ));}
  3671. }
  3672. else
  3673. {
  3674. // yeah, the service stopped.
  3675. iReturn = TRUE;
  3676. }
  3677. }
  3678. if (_tcsicmp(ParsedLine.szType, _T("56")) == 0 || _tcsicmp(ParsedLine.szType, _T("57")) == 0)
  3679. {
  3680. int iAdd = FALSE;
  3681. if (_tcsicmp(ParsedLine.szType, _T("56")) == 0) {iAdd = TRUE;}
  3682. // map/unmap to HTTP
  3683. InetRegisterService( g_pTheApp->m_csMachineName, ParsedLine.szData1, &g_HTTPGuid, 0, 80, iAdd);
  3684. iReturn = TRUE;
  3685. }
  3686. if (_tcsicmp(ParsedLine.szType, _T("58")) == 0 || _tcsicmp(ParsedLine.szType, _T("59")) == 0)
  3687. {
  3688. int iAdd = FALSE;
  3689. if (_tcsicmp(ParsedLine.szType, _T("58")) == 0) {iAdd = TRUE;}
  3690. // map/unmap to FTP
  3691. InetRegisterService( g_pTheApp->m_csMachineName, ParsedLine.szData1, &g_FTPGuid, 0, 21, iAdd);
  3692. iReturn = TRUE;
  3693. }
  3694. if (_tcsicmp(ParsedLine.szType, _T("60")) == 0 || _tcsicmp(ParsedLine.szType, _T("61")) == 0)
  3695. {
  3696. int iAdd = FALSE;
  3697. if (_tcsicmp(ParsedLine.szType, _T("60")) == 0) {iAdd = TRUE;}
  3698. // map/unmap to Gopher
  3699. InetRegisterService( g_pTheApp->m_csMachineName, ParsedLine.szData1, &g_GopherGuid, 0, 70, iAdd);
  3700. iReturn = TRUE;
  3701. }
  3702. if (_tcsicmp(ParsedLine.szType, _T("62")) == 0 || _tcsicmp(ParsedLine.szType, _T("63")) == 0)
  3703. {
  3704. int iAdd = FALSE;
  3705. if (_tcsicmp(ParsedLine.szType, _T("62")) == 0) {iAdd = TRUE;}
  3706. // map/unmap to Inetinfo
  3707. InetRegisterService( g_pTheApp->m_csMachineName, ParsedLine.szData1, &g_InetInfoGuid, 0x64e, 0x558, iAdd);
  3708. iReturn = TRUE;
  3709. }
  3710. if (_tcsicmp(ParsedLine.szType, _T("64")) == 0 || _tcsicmp(ParsedLine.szType, _T("65")) == 0)
  3711. {
  3712. iReturn = TRUE;
  3713. // make sure we have everything
  3714. iTempFlag = FALSE;
  3715. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  3716. if (iTempFlag == FALSE)
  3717. {
  3718. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3719. goto ProcessEntry_SVC_Clus_Exit;
  3720. }
  3721. iTempFlag = FALSE;
  3722. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  3723. if (iTempFlag == FALSE)
  3724. {
  3725. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3726. goto ProcessEntry_SVC_Clus_Exit;
  3727. }
  3728. if (_tcsicmp(ParsedLine.szType, _T("64")) == 0)
  3729. {
  3730. iTempFlag = FALSE;
  3731. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  3732. if (iTempFlag == FALSE)
  3733. {
  3734. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3735. goto ProcessEntry_SVC_Clus_Exit;
  3736. }
  3737. iTempFlag = FALSE;
  3738. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {iTempFlag = TRUE;}
  3739. if (iTempFlag == FALSE)
  3740. {
  3741. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3742. goto ProcessEntry_SVC_Clus_Exit;
  3743. }
  3744. // this function only takes wide characters...
  3745. #ifndef _CHICAGO_
  3746. iReturn = RegisterIisServerInstanceResourceType(ParsedLine.szFileName,ParsedLine.szData1,ParsedLine.szData2,ParsedLine.szData3);
  3747. #else
  3748. iisDebugOut((LOG_TYPE_TRACE, _T("RegisterIisServerInstanceResourceType(): not supported under ansi. only unicode.") ));
  3749. #endif
  3750. }
  3751. else
  3752. {
  3753. iTempFlag = FALSE;
  3754. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0) {iTempFlag = TRUE;}
  3755. // this function only takes wide characters...
  3756. #ifndef _CHICAGO_
  3757. iReturn = UnregisterIisServerInstanceResourceType(ParsedLine.szFileName,ParsedLine.szData1,iTempFlag,TRUE);
  3758. #else
  3759. iisDebugOut((LOG_TYPE_TRACE, _T("UnregisterIisServerInstanceResourceType(): not supported under ansi. only unicode.") ));
  3760. #endif
  3761. }
  3762. // iReturn = TRUE;
  3763. }
  3764. if (_tcsicmp(ParsedLine.szType, _T("66")) == 0)
  3765. {
  3766. #ifndef _CHICAGO_
  3767. DWORD dwReturn = 0;
  3768. dwReturn = BringALLIISClusterResourcesOffline();
  3769. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("BringALLIISClusterResourcesOffline ret=%d\n"),dwReturn));
  3770. #endif
  3771. iReturn = TRUE;
  3772. }
  3773. if (_tcsicmp(ParsedLine.szType, _T("67")) == 0)
  3774. {
  3775. #ifndef _CHICAGO_
  3776. DWORD dwReturn = 0;
  3777. dwReturn = BringALLIISClusterResourcesOnline();
  3778. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("BringALLIISClusterResourcesOnline ret=%d\n"),dwReturn));
  3779. #endif
  3780. iReturn = TRUE;
  3781. }
  3782. // Add/remove interactive flag to/from service
  3783. if (_tcsicmp(ParsedLine.szType, _T("68")) == 0 || _tcsicmp(ParsedLine.szType, _T("69")) == 0)
  3784. {
  3785. int iAdd = FALSE;
  3786. if (_tcsicmp(ParsedLine.szType, _T("68")) == 0) {iAdd = TRUE;}
  3787. InetConfigServiceInteractive(ParsedLine.szData1, iAdd);
  3788. iReturn = TRUE;
  3789. }
  3790. // display the messagebox that we completed the call...
  3791. ProcessEntry_AskLast(ParsedLine,1);
  3792. ProcessEntry_SVC_Clus_Exit:
  3793. if (TRUE == iProgressBarUpdated){ProgressBarTextStack_Pop();}
  3794. return iReturn;
  3795. }
  3796. int ProcessEntry_Dcom(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  3797. {
  3798. int iReturn = FALSE;
  3799. int iTempFlag = FALSE;
  3800. int iProgressBarUpdated = FALSE;
  3801. int iShowErrorsOnFail = TRUE;
  3802. DWORD dwFailed = ERROR_SUCCESS;
  3803. // Get the type.
  3804. if ( _tcsicmp(ParsedLine.szType, _T("70")) != 0 && _tcsicmp(ParsedLine.szType, _T("71")) != 0 &&
  3805. _tcsicmp(ParsedLine.szType, _T("72")) != 0 && _tcsicmp(ParsedLine.szType, _T("73")) != 0 &&
  3806. _tcsicmp(ParsedLine.szType, _T("74")) != 0 && _tcsicmp(ParsedLine.szType, _T("75")) != 0 &&
  3807. _tcsicmp(ParsedLine.szType, _T("76")) != 0 && _tcsicmp(ParsedLine.szType, _T("77")) != 0
  3808. )
  3809. {
  3810. goto ProcessEntry_Dcom_Exit;
  3811. }
  3812. // Check if there is other criteria we need to pass
  3813. if (!ProcessEntry_CheckAll(csEntry, szTheSection, ParsedLine) )
  3814. {
  3815. goto ProcessEntry_Dcom_Exit;
  3816. }
  3817. // make sure we have a szData1 entry
  3818. iTempFlag = FALSE;
  3819. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  3820. if (iTempFlag == FALSE)
  3821. {
  3822. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3823. goto ProcessEntry_Dcom_Exit;
  3824. }
  3825. if (_tcsicmp(ParsedLine.szType, _T("74")) == 0 ||
  3826. _tcsicmp(ParsedLine.szType, _T("75")) == 0 ||
  3827. _tcsicmp(ParsedLine.szType, _T("76")) == 0 ||
  3828. _tcsicmp(ParsedLine.szType, _T("77")) == 0)
  3829. {
  3830. // make sure we have a filename entry
  3831. iTempFlag = FALSE;
  3832. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  3833. if (iTempFlag == FALSE)
  3834. {
  3835. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  3836. goto ProcessEntry_Dcom_Exit;
  3837. }
  3838. }
  3839. iShowErrorsOnFail = TRUE;
  3840. if (_tcsicmp(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T("1")) == 0)
  3841. {iShowErrorsOnFail = FALSE;}
  3842. if (_tcsicmp(ParsedLine.szProgressTitle, _T("")) != 0)
  3843. {
  3844. ProgressBarTextStack_Set(ParsedLine.szProgressTitle);
  3845. iProgressBarUpdated = TRUE;
  3846. }
  3847. // check if we need to ask the user if they want to call it for sure.
  3848. if (!ProcessEntry_AskFirst(ParsedLine, 1))
  3849. {
  3850. goto ProcessEntry_Dcom_Exit;
  3851. }
  3852. // Run The Executable...
  3853. // iShowErrorsOnFail
  3854. dwFailed = ERROR_SUCCESS;
  3855. // Call the function!!!!!
  3856. // Set dcom launch and access permissions
  3857. if (_tcsicmp(ParsedLine.szType, _T("70")) == 0 || _tcsicmp(ParsedLine.szType, _T("71")) == 0)
  3858. {
  3859. BOOL bDumbCall = FALSE;
  3860. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0)
  3861. {bDumbCall = TRUE;}
  3862. if (_tcsicmp(ParsedLine.szType, _T("70")) == 0)
  3863. {
  3864. dwFailed = ChangeDCOMLaunchACL((LPTSTR)(LPCTSTR)ParsedLine.szData1, TRUE, TRUE, bDumbCall);
  3865. }
  3866. else
  3867. {
  3868. dwFailed = ChangeDCOMLaunchACL((LPTSTR)(LPCTSTR)ParsedLine.szData1, FALSE, FALSE, bDumbCall);
  3869. }
  3870. if (dwFailed != ERROR_SUCCESS)
  3871. {
  3872. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szData1, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  3873. else{iisDebugOut((LOG_TYPE_ERROR, _T("ChangeDCOMAccessACL(%s). Failed. Err=0x%x.\n"), ParsedLine.szData1, GetLastError() ));}
  3874. }
  3875. else
  3876. {
  3877. iReturn = TRUE;
  3878. }
  3879. }
  3880. if (_tcsicmp(ParsedLine.szType, _T("72")) == 0 || _tcsicmp(ParsedLine.szType, _T("73")) == 0)
  3881. {
  3882. BOOL bDumbCall = FALSE;
  3883. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0)
  3884. {bDumbCall = TRUE;}
  3885. if (_tcsicmp(ParsedLine.szType, _T("72")) == 0)
  3886. {
  3887. dwFailed = ChangeDCOMAccessACL((LPTSTR)(LPCTSTR)ParsedLine.szData1, TRUE, TRUE, bDumbCall);
  3888. }
  3889. else
  3890. {
  3891. dwFailed = ChangeDCOMAccessACL((LPTSTR)(LPCTSTR)ParsedLine.szData1, FALSE, FALSE, bDumbCall);
  3892. }
  3893. if (dwFailed != ERROR_SUCCESS)
  3894. {
  3895. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szData1, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  3896. else{iisDebugOut((LOG_TYPE_ERROR, _T("ChangeDCOMAccessACL(%s). Failed. Err=0x%x.\n"), ParsedLine.szData1, GetLastError() ));}
  3897. }
  3898. else
  3899. {
  3900. iReturn = TRUE;
  3901. }
  3902. }
  3903. // dcom launch and access permissions
  3904. if (_tcsicmp(ParsedLine.szType, _T("74")) == 0 || _tcsicmp(ParsedLine.szType, _T("75")) == 0)
  3905. {
  3906. BOOL bDumbCall = FALSE;
  3907. BOOL bAddInteractivebyDefault = TRUE;
  3908. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0)
  3909. {bDumbCall = TRUE;}
  3910. if (_tcsicmp(ParsedLine.szData3, _T("0")) == 0)
  3911. {bAddInteractivebyDefault = FALSE;}
  3912. if (_tcsicmp(ParsedLine.szType, _T("74")) == 0)
  3913. {
  3914. dwFailed = ChangeAppIDLaunchACL(ParsedLine.szFileName, (LPTSTR)(LPCTSTR) ParsedLine.szData1, TRUE, TRUE, bDumbCall,bAddInteractivebyDefault);
  3915. }
  3916. else
  3917. {
  3918. dwFailed = ChangeAppIDLaunchACL(ParsedLine.szFileName, (LPTSTR)(LPCTSTR) ParsedLine.szData1, FALSE, FALSE, bDumbCall,bAddInteractivebyDefault);
  3919. }
  3920. if (dwFailed != ERROR_SUCCESS)
  3921. {
  3922. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szData1, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  3923. else{iisDebugOut((LOG_TYPE_ERROR, _T("ChangeAppIDLaunchACL(%s). Failed. Err=0x%x.\n"), ParsedLine.szData1, GetLastError() ));}
  3924. }
  3925. else
  3926. {
  3927. iReturn = TRUE;
  3928. }
  3929. }
  3930. // dcom launch and access permissions
  3931. if (_tcsicmp(ParsedLine.szType, _T("76")) == 0 || _tcsicmp(ParsedLine.szType, _T("77")) == 0)
  3932. {
  3933. BOOL bDumbCall = FALSE;
  3934. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0)
  3935. {bDumbCall = TRUE;}
  3936. if (_tcsicmp(ParsedLine.szType, _T("76")) == 0)
  3937. {
  3938. dwFailed = ChangeAppIDAccessACL(ParsedLine.szFileName, (LPTSTR)(LPCTSTR) ParsedLine.szData1, TRUE, TRUE, bDumbCall);
  3939. }
  3940. else
  3941. {
  3942. dwFailed = ChangeAppIDAccessACL(ParsedLine.szFileName, (LPTSTR)(LPCTSTR) ParsedLine.szData1, FALSE, FALSE, bDumbCall);
  3943. }
  3944. if (dwFailed != ERROR_SUCCESS)
  3945. {
  3946. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szData1, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  3947. else{iisDebugOut((LOG_TYPE_ERROR, _T("ChangeAppIDAccessACL(%s). Failed. Err=0x%x.\n"), ParsedLine.szData1, GetLastError() ));}
  3948. }
  3949. else
  3950. {
  3951. iReturn = TRUE;
  3952. }
  3953. }
  3954. // display the messagebox that we completed the call...
  3955. ProcessEntry_AskLast(ParsedLine,1);
  3956. // We called the function, so return true.
  3957. iReturn = TRUE;
  3958. ProcessEntry_Dcom_Exit:
  3959. return iReturn;
  3960. }
  3961. // function: IsMachineInDomain
  3962. //
  3963. // Test to see if the machine is in a domain, or if it
  3964. // is in a workstation
  3965. //
  3966. // Return Values:
  3967. // TRUE - In a domain
  3968. // FALSE - Not in a domain
  3969. //
  3970. int IsMachineInDomain()
  3971. {
  3972. DWORD dwRet;
  3973. LPBYTE pDomain = NULL;
  3974. // Retrieve the domain which this computer trusts.
  3975. // Hence: success->in a domain; error->not in a domain
  3976. dwRet = NetGetAnyDCName(NULL,NULL,&pDomain);
  3977. if (pDomain)
  3978. {
  3979. NetApiBufferFree(pDomain);
  3980. }
  3981. if (dwRet == NERR_Success)
  3982. {
  3983. return TRUE;
  3984. }
  3985. // Default Return Value is FALSE
  3986. return FALSE;
  3987. }
  3988. // function: RetrieveDomain
  3989. //
  3990. // Retrieve the domain that the current machine is in
  3991. //
  3992. // Parameters:
  3993. // [out] csDomainName - The name of the domain
  3994. //
  3995. // Return:
  3996. // TRUE - It worked
  3997. // FALSE - It Failed
  3998. //
  3999. int RetrieveDomain(CString &csDomainName)
  4000. {
  4001. PDOMAIN_CONTROLLER_INFO pDci;
  4002. if ( NO_ERROR != DsGetDcName( NULL, // Localhost
  4003. NULL, // No specific domain
  4004. NULL, // No Guid Specified
  4005. NULL, // No Site
  4006. 0, // No Flags
  4007. &pDci)
  4008. )
  4009. {
  4010. return FALSE;
  4011. }
  4012. // Copy string into csDomainName
  4013. csDomainName = pDci->DomainName;
  4014. NetApiBufferFree(pDci);
  4015. return TRUE;
  4016. }
  4017. int ProcessEntry_If(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  4018. {
  4019. int iReturn = FALSE;
  4020. int iTempFlag = FALSE;
  4021. int iTempFlag2 = FALSE;
  4022. int ifTrueStatementExists = FALSE;
  4023. int ifFalseStatementExists = FALSE;
  4024. // Get the type.
  4025. if (_tcsicmp(ParsedLine.szType, _T("39")) != 0 &&
  4026. _tcsicmp(ParsedLine.szType, _T("40")) != 0 && _tcsicmp(ParsedLine.szType, _T("41")) != 0 &&
  4027. _tcsicmp(ParsedLine.szType, _T("42")) != 0 && _tcsicmp(ParsedLine.szType, _T("43")) != 0 &&
  4028. _tcsicmp(ParsedLine.szType, _T("44")) != 0 && _tcsicmp(ParsedLine.szType, _T("45")) != 0 &&
  4029. _tcsicmp(ParsedLine.szType, _T("46")) != 0 && _tcsicmp(ParsedLine.szType, _T("47")) != 0 &&
  4030. _tcsicmp(ParsedLine.szType, _T("48")) != 0 && _tcsicmp(ParsedLine.szType, _T("49")) != 0 &&
  4031. _tcsicmp(ParsedLine.szType, _T("100")) != 0 && _tcsicmp(ParsedLine.szType, _T("119")) != 0
  4032. )
  4033. {
  4034. goto ProcessEntry_If_Exit;
  4035. }
  4036. // Check if there is other criteria we need to pass
  4037. if (!ProcessEntry_CheckAll(csEntry, szTheSection, ParsedLine) )
  4038. {
  4039. goto ProcessEntry_If_Exit;
  4040. }
  4041. if ( _tcsicmp(ParsedLine.szType, _T("40")) == 0)
  4042. {
  4043. // make sure we have a filename entry
  4044. iTempFlag = FALSE;
  4045. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4046. if (iTempFlag == FALSE)
  4047. {
  4048. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4049. goto ProcessEntry_If_Exit;
  4050. }
  4051. iTempFlag = FALSE;
  4052. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  4053. if (iTempFlag == FALSE)
  4054. {
  4055. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4056. goto ProcessEntry_If_Exit;
  4057. }
  4058. // make sure there is a szData3 or a szData4.
  4059. ifTrueStatementExists = FALSE;
  4060. ifFalseStatementExists = FALSE;
  4061. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4062. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4063. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4064. {
  4065. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4066. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4067. goto ProcessEntry_If_Exit;
  4068. }
  4069. // okay we have either szData3 or szData4
  4070. HKEY hRootKeyType = HKEY_LOCAL_MACHINE;
  4071. // check if the registry key exists...
  4072. if ( _tcsicmp(ParsedLine.szFileName, _T("HKLM")) == 0){hRootKeyType = HKEY_LOCAL_MACHINE;}
  4073. if ( _tcsicmp(ParsedLine.szFileName, _T("HKCR")) == 0){hRootKeyType = HKEY_CLASSES_ROOT;}
  4074. if ( _tcsicmp(ParsedLine.szFileName, _T("HKCU")) == 0){hRootKeyType = HKEY_CURRENT_USER;}
  4075. if ( _tcsicmp(ParsedLine.szFileName, _T("HKU")) == 0){hRootKeyType = HKEY_USERS;}
  4076. iTempFlag = FALSE;
  4077. CRegKey regTheKey(hRootKeyType, ParsedLine.szData1,KEY_READ);
  4078. if ((HKEY) regTheKey) {iTempFlag = TRUE;}
  4079. if (iTempFlag == TRUE)
  4080. {
  4081. // the result was true
  4082. // the key exists, so let's do the section...
  4083. if (ifTrueStatementExists)
  4084. {
  4085. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  4086. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  4087. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  4088. }
  4089. }
  4090. else
  4091. {
  4092. // the result was false
  4093. if (ifFalseStatementExists)
  4094. {
  4095. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData3));
  4096. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData3);
  4097. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData3, iTempFlag));
  4098. }
  4099. }
  4100. }
  4101. if ( _tcsicmp(ParsedLine.szType, _T("41")) == 0)
  4102. {
  4103. // make sure we have a filename entry
  4104. iTempFlag = FALSE;
  4105. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4106. if (iTempFlag == FALSE)
  4107. {
  4108. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4109. goto ProcessEntry_If_Exit;
  4110. }
  4111. iTempFlag = FALSE;
  4112. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  4113. if (iTempFlag == FALSE)
  4114. {
  4115. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4116. goto ProcessEntry_If_Exit;
  4117. }
  4118. iTempFlag = FALSE;
  4119. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  4120. if (iTempFlag == FALSE)
  4121. {
  4122. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4123. goto ProcessEntry_If_Exit;
  4124. }
  4125. // make sure there is a szData3 or a szData4.
  4126. ifTrueStatementExists = FALSE;
  4127. ifFalseStatementExists = FALSE;
  4128. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4129. if (_tcsicmp(ParsedLine.szData4, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4130. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4131. {
  4132. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4133. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz105_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4134. goto ProcessEntry_If_Exit;
  4135. }
  4136. // okay we have either szData3 or szData4
  4137. HKEY hRootKeyType = HKEY_LOCAL_MACHINE;
  4138. // check if the registry key exists...
  4139. if ( _tcsicmp(ParsedLine.szFileName, _T("HKLM")) == 0){hRootKeyType = HKEY_LOCAL_MACHINE;}
  4140. if ( _tcsicmp(ParsedLine.szFileName, _T("HKCR")) == 0){hRootKeyType = HKEY_CLASSES_ROOT;}
  4141. if ( _tcsicmp(ParsedLine.szFileName, _T("HKCU")) == 0){hRootKeyType = HKEY_CURRENT_USER;}
  4142. if ( _tcsicmp(ParsedLine.szFileName, _T("HKU")) == 0){hRootKeyType = HKEY_USERS;}
  4143. iTempFlag = FALSE;
  4144. CRegKey regTheKey(hRootKeyType, ParsedLine.szData1,KEY_READ);
  4145. CString strReturnQueryValue;
  4146. if ((HKEY) regTheKey)
  4147. {
  4148. if (ERROR_SUCCESS == regTheKey.QueryValue(ParsedLine.szData2, strReturnQueryValue))
  4149. {iTempFlag = TRUE;}
  4150. // If we failed to read it as a string, try a dword
  4151. if (FALSE == iTempFlag)
  4152. {
  4153. DWORD dwTheReturnDword = 0;
  4154. if (ERROR_SUCCESS == regTheKey.QueryValue(ParsedLine.szData2, dwTheReturnDword))
  4155. {iTempFlag = TRUE;}
  4156. }
  4157. // If we failed to read it as dword, try a binary
  4158. if (FALSE == iTempFlag)
  4159. {
  4160. CByteArray baData;
  4161. if (ERROR_SUCCESS == regTheKey.QueryValue(ParsedLine.szData2, baData))
  4162. {iTempFlag = TRUE;}
  4163. }
  4164. }
  4165. if (iTempFlag == TRUE)
  4166. {
  4167. if (ifTrueStatementExists)
  4168. {
  4169. // the key exists, so let's do the section...
  4170. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData3));
  4171. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData3);
  4172. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData3, iTempFlag));
  4173. }
  4174. }
  4175. else
  4176. {
  4177. if (ifFalseStatementExists)
  4178. {
  4179. // the key exists, so let's do the section...
  4180. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData4));
  4181. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData4);
  4182. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData4, iTempFlag));
  4183. }
  4184. }
  4185. }
  4186. if ( _tcsicmp(ParsedLine.szType, _T("42")) == 0)
  4187. {
  4188. // make sure we have a filename entry
  4189. iTempFlag = FALSE;
  4190. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4191. if (iTempFlag == FALSE)
  4192. {
  4193. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4194. goto ProcessEntry_If_Exit;
  4195. }
  4196. // make sure there is a szData1 or a szData2
  4197. ifTrueStatementExists = FALSE;
  4198. ifFalseStatementExists = FALSE;
  4199. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4200. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4201. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4202. {
  4203. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4204. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4205. goto ProcessEntry_If_Exit;
  4206. }
  4207. // okay we have either szData1 or szData2
  4208. // Check if the filename or dir exists...
  4209. iTempFlag = FALSE;
  4210. if (IsFileExist(ParsedLine.szFileName))
  4211. {iTempFlag = TRUE;}
  4212. if (iTempFlag == TRUE)
  4213. {
  4214. // the result was true
  4215. // the key exists, so let's do the section...
  4216. if (ifTrueStatementExists)
  4217. {
  4218. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData1));
  4219. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData1);
  4220. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData1, iTempFlag));
  4221. }
  4222. }
  4223. else
  4224. {
  4225. // the result was false
  4226. if (ifFalseStatementExists)
  4227. {
  4228. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  4229. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  4230. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  4231. }
  4232. }
  4233. }
  4234. if ( _tcsicmp(ParsedLine.szType, _T("43")) == 0)
  4235. {
  4236. // make sure we have a filename entry
  4237. iTempFlag = FALSE;
  4238. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4239. if (iTempFlag == FALSE)
  4240. {
  4241. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4242. goto ProcessEntry_If_Exit;
  4243. }
  4244. iTempFlag = FALSE;
  4245. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  4246. if (iTempFlag == FALSE)
  4247. {
  4248. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4249. goto ProcessEntry_If_Exit;
  4250. }
  4251. iTempFlag = FALSE;
  4252. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  4253. if (iTempFlag == FALSE)
  4254. {
  4255. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4256. goto ProcessEntry_If_Exit;
  4257. }
  4258. // make sure there is a szData3 or a szData4.
  4259. ifTrueStatementExists = FALSE;
  4260. ifFalseStatementExists = FALSE;
  4261. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4262. if (_tcsicmp(ParsedLine.szData4, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4263. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4264. {
  4265. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4266. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz105_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4267. goto ProcessEntry_If_Exit;
  4268. }
  4269. // okay we have either szData3 or szData4
  4270. HKEY hRootKeyType = HKEY_LOCAL_MACHINE;
  4271. // check if the registry key exists...
  4272. if ( _tcsicmp(ParsedLine.szFileName, _T("HKLM")) == 0){hRootKeyType = HKEY_LOCAL_MACHINE;}
  4273. if ( _tcsicmp(ParsedLine.szFileName, _T("HKCR")) == 0){hRootKeyType = HKEY_CLASSES_ROOT;}
  4274. if ( _tcsicmp(ParsedLine.szFileName, _T("HKCU")) == 0){hRootKeyType = HKEY_CURRENT_USER;}
  4275. if ( _tcsicmp(ParsedLine.szFileName, _T("HKU")) == 0){hRootKeyType = HKEY_USERS;}
  4276. // ParsedLine.szData1 = Software\Microsoft\etc..\TheValueToCheck
  4277. // so take off the last one and use that as the value to look up.
  4278. TCHAR theRegValuePart[100];
  4279. LPTSTR pszTempPointer = NULL;
  4280. pszTempPointer = _tcsrchr((LPTSTR) ParsedLine.szData1, _T('\\'));
  4281. if (pszTempPointer)
  4282. {
  4283. *pszTempPointer = _T('\0');
  4284. //set the "\" to a null
  4285. // increment to after the pointer
  4286. pszTempPointer = _tcsninc( pszTempPointer, _tcslen(pszTempPointer))+1;
  4287. _tcscpy(theRegValuePart, pszTempPointer );
  4288. }
  4289. //iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Var:Key=%1!s!:Value=%2!s!.\n"), ParsedLine.szData1, theRegValuePart));
  4290. iTempFlag = FALSE;
  4291. CRegKey regTheKey(hRootKeyType, ParsedLine.szData1,KEY_READ);
  4292. DWORD dwTheReturnDword = 0;
  4293. if ((HKEY) regTheKey)
  4294. {
  4295. if (ERROR_SUCCESS == regTheKey.QueryValue(theRegValuePart, dwTheReturnDword))
  4296. {
  4297. // Check against the value they want to check against.
  4298. DWORD dwCheckDword = atodw(ParsedLine.szData2);
  4299. if (dwTheReturnDword == dwCheckDword)
  4300. {
  4301. iTempFlag = TRUE;
  4302. }
  4303. }
  4304. }
  4305. if (iTempFlag == TRUE)
  4306. {
  4307. if (ifTrueStatementExists)
  4308. {
  4309. // the key exists, so let's do the section...
  4310. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData3));
  4311. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData3);
  4312. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData3, iTempFlag));
  4313. }
  4314. }
  4315. else
  4316. {
  4317. if (ifFalseStatementExists)
  4318. {
  4319. // the key exists, so let's do the section...
  4320. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData4));
  4321. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData4);
  4322. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData4, iTempFlag));
  4323. }
  4324. }
  4325. }
  4326. if ( _tcsicmp(ParsedLine.szType, _T("44")) == 0)
  4327. {
  4328. // make sure we have a filename entry
  4329. iTempFlag = FALSE;
  4330. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4331. if (iTempFlag == FALSE)
  4332. {
  4333. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4334. goto ProcessEntry_If_Exit;
  4335. }
  4336. iTempFlag = FALSE;
  4337. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  4338. if (iTempFlag == FALSE)
  4339. {
  4340. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4341. goto ProcessEntry_If_Exit;
  4342. }
  4343. iTempFlag = FALSE;
  4344. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  4345. if (iTempFlag == FALSE)
  4346. {
  4347. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4348. goto ProcessEntry_If_Exit;
  4349. }
  4350. // make sure there is a szData3 or a szData4.
  4351. ifTrueStatementExists = FALSE;
  4352. ifFalseStatementExists = FALSE;
  4353. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4354. if (_tcsicmp(ParsedLine.szData4, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4355. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4356. {
  4357. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4358. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz105_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4359. goto ProcessEntry_If_Exit;
  4360. }
  4361. // okay we have either szData3 or szData4
  4362. HKEY hRootKeyType = HKEY_LOCAL_MACHINE;
  4363. // check if the registry key exists...
  4364. if ( _tcsicmp(ParsedLine.szFileName, _T("HKLM")) == 0){hRootKeyType = HKEY_LOCAL_MACHINE;}
  4365. if ( _tcsicmp(ParsedLine.szFileName, _T("HKCR")) == 0){hRootKeyType = HKEY_CLASSES_ROOT;}
  4366. if ( _tcsicmp(ParsedLine.szFileName, _T("HKCU")) == 0){hRootKeyType = HKEY_CURRENT_USER;}
  4367. if ( _tcsicmp(ParsedLine.szFileName, _T("HKU")) == 0){hRootKeyType = HKEY_USERS;}
  4368. // ParsedLine.szData1 = Software\Microsoft\etc..\TheValueToCheck
  4369. // so take off the last one and use that as the value to look up.
  4370. TCHAR theRegValuePart[100];
  4371. LPTSTR pszTempPointer = NULL;
  4372. pszTempPointer = _tcsrchr((LPTSTR) ParsedLine.szData1, _T('\\'));
  4373. if (pszTempPointer)
  4374. {
  4375. *pszTempPointer = _T('\0');
  4376. //set the "\" to a null
  4377. // increment to after the pointer
  4378. pszTempPointer = _tcsninc( pszTempPointer, _tcslen(pszTempPointer))+1;
  4379. _tcscpy(theRegValuePart, pszTempPointer );
  4380. }
  4381. //iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Var:Key=%1!s!:Value=%2!s!.\n"), ParsedLine.szData1, theRegValuePart));
  4382. iTempFlag = FALSE;
  4383. CRegKey regTheKey(hRootKeyType, ParsedLine.szData1,KEY_READ);
  4384. CString strReturnQueryValue;
  4385. if ((HKEY) regTheKey)
  4386. {
  4387. if (ERROR_SUCCESS == regTheKey.QueryValue(theRegValuePart, strReturnQueryValue))
  4388. {
  4389. if (_tcsicmp(strReturnQueryValue,ParsedLine.szData2) == 0)
  4390. {
  4391. iTempFlag = TRUE;
  4392. }
  4393. }
  4394. }
  4395. if (iTempFlag == TRUE)
  4396. {
  4397. if (ifTrueStatementExists)
  4398. {
  4399. // the key exists, so let's do the section...
  4400. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData3));
  4401. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData3);
  4402. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData3, iTempFlag));
  4403. }
  4404. }
  4405. else
  4406. {
  4407. if (ifFalseStatementExists)
  4408. {
  4409. // the key exists, so let's do the section...
  4410. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData4));
  4411. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData4);
  4412. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData4, iTempFlag));
  4413. }
  4414. }
  4415. }
  4416. if ( _tcsicmp(ParsedLine.szType, _T("45")) == 0)
  4417. {
  4418. // make sure we have a filename entry
  4419. iTempFlag = FALSE;
  4420. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4421. if (iTempFlag == FALSE)
  4422. {
  4423. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4424. goto ProcessEntry_If_Exit;
  4425. }
  4426. // make sure there is a szData1 or a szData2
  4427. ifTrueStatementExists = FALSE;
  4428. ifFalseStatementExists = FALSE;
  4429. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4430. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4431. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4432. {
  4433. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4434. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4435. goto ProcessEntry_If_Exit;
  4436. }
  4437. // okay we have either szData1 or szData2
  4438. // Check if the Service exists...
  4439. iTempFlag = FALSE;
  4440. if (CheckifServiceExist(ParsedLine.szFileName) == 0 )
  4441. {
  4442. // yes the service exists..
  4443. iTempFlag = TRUE;
  4444. }
  4445. if (iTempFlag == TRUE)
  4446. {
  4447. // the result was true
  4448. // the key exists, so let's do the section...
  4449. if (ifTrueStatementExists)
  4450. {
  4451. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData1));
  4452. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData1);
  4453. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData1, iTempFlag));
  4454. }
  4455. }
  4456. else
  4457. {
  4458. // the result was false
  4459. if (ifFalseStatementExists)
  4460. {
  4461. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  4462. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  4463. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  4464. }
  4465. }
  4466. }
  4467. if ( _tcsicmp(ParsedLine.szType, _T("46")) == 0)
  4468. {
  4469. // make sure we have a filename entry
  4470. iTempFlag = FALSE;
  4471. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4472. if (iTempFlag == FALSE)
  4473. {
  4474. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4475. goto ProcessEntry_If_Exit;
  4476. }
  4477. // make sure there is a szData1 or a szData2
  4478. ifTrueStatementExists = FALSE;
  4479. ifFalseStatementExists = FALSE;
  4480. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4481. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4482. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4483. {
  4484. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4485. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4486. goto ProcessEntry_If_Exit;
  4487. }
  4488. // okay we have either szData1 or szData2
  4489. // Check if the Service exists...and is running..
  4490. iTempFlag = FALSE;
  4491. if (InetQueryServiceStatus(ParsedLine.szFileName) == SERVICE_RUNNING)
  4492. {
  4493. // yes the service exists..and is running...
  4494. iTempFlag = TRUE;
  4495. }
  4496. if (iTempFlag == TRUE)
  4497. {
  4498. // the result was true
  4499. // the key exists, so let's do the section...
  4500. if (ifTrueStatementExists)
  4501. {
  4502. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData1));
  4503. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData1);
  4504. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData1, iTempFlag));
  4505. }
  4506. }
  4507. else
  4508. {
  4509. // the result was false
  4510. if (ifFalseStatementExists)
  4511. {
  4512. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  4513. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  4514. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  4515. }
  4516. }
  4517. }
  4518. if ( _tcsicmp(ParsedLine.szType, _T("47")) == 0)
  4519. {
  4520. // make sure we have a filename entry
  4521. iTempFlag = FALSE;
  4522. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4523. if (iTempFlag == FALSE)
  4524. {
  4525. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4526. goto ProcessEntry_If_Exit;
  4527. }
  4528. iTempFlag = FALSE;
  4529. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  4530. if (iTempFlag == FALSE)
  4531. {
  4532. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4533. goto ProcessEntry_If_Exit;
  4534. }
  4535. // make sure there is a szData3 or a szData4.
  4536. ifTrueStatementExists = FALSE;
  4537. ifFalseStatementExists = FALSE;
  4538. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4539. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4540. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4541. {
  4542. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4543. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4544. goto ProcessEntry_If_Exit;
  4545. }
  4546. // okay we have either szData3 or szData4
  4547. // Check if the values match.
  4548. iTempFlag = FALSE;
  4549. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("ProcessEntry_If:check if [%1!s!=%2!s!]\n"), ParsedLine.szFileName, ParsedLine.szData1));
  4550. if ( _tcsicmp(ParsedLine.szFileName, ParsedLine.szData1) == 0)
  4551. {
  4552. iTempFlag = TRUE;
  4553. }
  4554. if (iTempFlag == TRUE)
  4555. {
  4556. // the result was true
  4557. // the key exists, so let's do the section...
  4558. if (ifTrueStatementExists)
  4559. {
  4560. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  4561. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  4562. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  4563. }
  4564. }
  4565. else
  4566. {
  4567. // the result was false
  4568. if (ifFalseStatementExists)
  4569. {
  4570. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData3));
  4571. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData3);
  4572. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData3, iTempFlag));
  4573. }
  4574. }
  4575. }
  4576. if ( _tcsicmp(ParsedLine.szType, _T("48")) == 0)
  4577. {
  4578. // make sure we have a filename entry
  4579. iTempFlag = FALSE;
  4580. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4581. if (iTempFlag == FALSE)
  4582. {
  4583. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4584. goto ProcessEntry_If_Exit;
  4585. }
  4586. // make sure there is a szData1 or a szData2
  4587. ifTrueStatementExists = FALSE;
  4588. ifFalseStatementExists = FALSE;
  4589. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4590. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4591. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4592. {
  4593. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4594. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4595. goto ProcessEntry_If_Exit;
  4596. }
  4597. // okay we have either szData1 or szData2
  4598. // Check if the language specified in the .inf corresponds to
  4599. // our systems language.
  4600. iTempFlag = FALSE;
  4601. // Get our language
  4602. // set iTempFlag to true if it matches the same language they specified.
  4603. DWORD thid;
  4604. LCID ThisThreadsLocale = GetThreadLocale();
  4605. LCID SystemDefaultLocale = GetSystemDefaultLCID();
  4606. LCID UserDefaultLocale = GetUserDefaultLCID();
  4607. HANDLE hHackThread = CreateThread (NULL,0,GetNewlyCreatedThreadLocale,NULL,0,&thid);
  4608. if (hHackThread)
  4609. {
  4610. // wait for 10 secs only
  4611. DWORD res = WaitForSingleObject (hHackThread,10*1000);
  4612. if (res == WAIT_TIMEOUT)
  4613. {
  4614. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ERROR GetNewlyCreatedThreadLocale thread never finished...\n")));
  4615. // iTempFlag will be false.
  4616. }
  4617. else
  4618. {
  4619. iisDebugOut((LOG_TYPE_TRACE, _T("ThisThreadsLocale=%0x, GetNewlyCreatedThreadLocale=%0x\n"),ThisThreadsLocale,g_MyTrueThreadLocale));
  4620. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("SystemDefaultLocale=%0x, UserDefaultLocale=%0x\n"),SystemDefaultLocale,UserDefaultLocale));
  4621. CloseHandle (hHackThread);
  4622. // Check if g_MyTrueThreadLocale matches the one in the .inf file!
  4623. DWORD dwTheLocaleSpecifiedinINF = 0;
  4624. dwTheLocaleSpecifiedinINF = atodw(ParsedLine.szFileName);
  4625. if (g_MyTrueThreadLocale == dwTheLocaleSpecifiedinINF)
  4626. {
  4627. iTempFlag = TRUE;
  4628. }
  4629. else if (ThisThreadsLocale == dwTheLocaleSpecifiedinINF)
  4630. {
  4631. iTempFlag = TRUE;
  4632. }
  4633. else if (SystemDefaultLocale == dwTheLocaleSpecifiedinINF)
  4634. {
  4635. iTempFlag = TRUE;
  4636. }
  4637. else if (UserDefaultLocale == dwTheLocaleSpecifiedinINF)
  4638. {
  4639. iTempFlag = TRUE;
  4640. }
  4641. }
  4642. }
  4643. else
  4644. {
  4645. iisDebugOut((LOG_TYPE_ERROR, _T("Failed to start GetNewlyCreatedThreadLocale thread. error =%0x\n"),GetLastError()));
  4646. }
  4647. if (iTempFlag == TRUE)
  4648. {
  4649. // the result was true
  4650. // the key exists, so let's do the section...
  4651. if (ifTrueStatementExists)
  4652. {
  4653. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData1));
  4654. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData1);
  4655. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData1, iTempFlag));
  4656. }
  4657. }
  4658. else
  4659. {
  4660. // the result was false
  4661. if (ifFalseStatementExists)
  4662. {
  4663. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  4664. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  4665. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  4666. }
  4667. }
  4668. }
  4669. if ( _tcsicmp(ParsedLine.szType, _T("49")) == 0)
  4670. {
  4671. BOOL bOperator_EqualTo = 0;
  4672. BOOL bOperator_GreaterThan = 0;
  4673. BOOL bOperator_LessThan = 0;
  4674. // make sure we have a filename entry
  4675. iTempFlag = FALSE;
  4676. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4677. if (iTempFlag == FALSE)
  4678. {
  4679. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4680. goto ProcessEntry_If_Exit;
  4681. }
  4682. // make sure there is an operator "=,>,<,>=,<="
  4683. iTempFlag = FALSE;
  4684. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  4685. if (iTempFlag == FALSE)
  4686. {
  4687. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4688. goto ProcessEntry_If_Exit;
  4689. }
  4690. iTempFlag = FALSE;
  4691. LPTSTR pchResult;
  4692. pchResult = _tcschr( ParsedLine.szData1, _T('=') );
  4693. if(pchResult){bOperator_EqualTo = TRUE;iTempFlag = TRUE;}
  4694. pchResult = NULL;
  4695. pchResult = _tcschr( ParsedLine.szData1, _T('>') );
  4696. if(pchResult){bOperator_GreaterThan = TRUE;iTempFlag = TRUE;}
  4697. pchResult = NULL;
  4698. pchResult = _tcschr( ParsedLine.szData1, _T('<') );
  4699. if(pchResult){bOperator_LessThan = TRUE;iTempFlag = TRUE;}
  4700. if (iTempFlag == FALSE)
  4701. {
  4702. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4703. goto ProcessEntry_If_Exit;
  4704. }
  4705. // make sure the version to compare it to is specified
  4706. iTempFlag = FALSE;
  4707. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  4708. if (iTempFlag == FALSE)
  4709. {
  4710. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4711. goto ProcessEntry_If_Exit;
  4712. }
  4713. // make sure there is a szData3 or a szData4.
  4714. ifTrueStatementExists = FALSE;
  4715. ifFalseStatementExists = FALSE;
  4716. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4717. if (_tcsicmp(ParsedLine.szData4, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4718. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4719. {
  4720. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4721. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz105_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4722. goto ProcessEntry_If_Exit;
  4723. }
  4724. // make sure to return true from here on!
  4725. iReturn = TRUE;
  4726. // check if the file exists
  4727. // Check if the filename or dir exists...
  4728. if (!IsFileExist(ParsedLine.szFileName))
  4729. {goto ProcessEntry_If_Exit;}
  4730. BOOL bThisIsABinary = FALSE;
  4731. TCHAR szExtensionOnly[_MAX_EXT] = _T("");
  4732. _tsplitpath(ParsedLine.szFileName, NULL, NULL, NULL, szExtensionOnly);
  4733. // Get version info for dll,exe,ocx only
  4734. if (_tcsicmp(szExtensionOnly, _T(".exe")) == 0){bThisIsABinary=TRUE;}
  4735. if (_tcsicmp(szExtensionOnly, _T(".dll")) == 0){bThisIsABinary=TRUE;}
  4736. if (_tcsicmp(szExtensionOnly, _T(".ocx")) == 0){bThisIsABinary=TRUE;}
  4737. if (FALSE == bThisIsABinary)
  4738. {
  4739. // no version, bail
  4740. goto ProcessEntry_If_Exit;
  4741. }
  4742. DWORD dwMSVer, dwLSVer = 0;
  4743. TCHAR szLocalizedVersion[100] = _T("");
  4744. // the file exists, lets get the file version and compare it with
  4745. // the inputed version, if the fileversion is <= inputversion, then do TRUE section,
  4746. // otherwise to FALSE section
  4747. // get the fileinformation
  4748. MyGetVersionFromFile(ParsedLine.szFileName, &dwMSVer, &dwLSVer, szLocalizedVersion);
  4749. if (!dwMSVer)
  4750. {
  4751. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("ProcessEntry_If:No Version in %1!s!, or filenot found\n"), ParsedLine.szFileName));
  4752. // no version, leave
  4753. goto ProcessEntry_If_Exit;
  4754. }
  4755. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("ProcessEntry_If:check if [%1!s! (%2!s! %3!s! %4!s!)]\n"), ParsedLine.szFileName, szLocalizedVersion, ParsedLine.szData1));
  4756. int iTempVerValue = 0;
  4757. iTempVerValue = VerCmp(szLocalizedVersion,ParsedLine.szData1);
  4758. if (0 == iTempVerValue)
  4759. {
  4760. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("ProcessEntry_If:VerCmp=%d\n"), iTempVerValue));
  4761. goto ProcessEntry_If_Exit;
  4762. }
  4763. iTempFlag = FALSE;
  4764. if (bOperator_EqualTo)
  4765. {
  4766. // check if the above operation was equal
  4767. if (1 == iTempVerValue){iTempFlag = TRUE;}
  4768. }
  4769. if (bOperator_GreaterThan)
  4770. {
  4771. // check if the above operation was greater than
  4772. if (2 == iTempVerValue){iTempFlag = TRUE;}
  4773. }
  4774. if (bOperator_LessThan)
  4775. {
  4776. // check if the above operation was less than
  4777. if (3 == iTempVerValue){iTempFlag = TRUE;}
  4778. }
  4779. if (iTempFlag == TRUE)
  4780. {
  4781. // the result was true
  4782. // the key exists, so let's do the section...
  4783. if (ifTrueStatementExists)
  4784. {
  4785. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData3));
  4786. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData3);
  4787. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData3, iTempFlag));
  4788. }
  4789. }
  4790. else
  4791. {
  4792. // the result was false
  4793. if (ifFalseStatementExists)
  4794. {
  4795. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData4));
  4796. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData4);
  4797. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData4, iTempFlag));
  4798. }
  4799. }
  4800. }
  4801. if ( _tcsicmp(ParsedLine.szType, _T("39")) == 0)
  4802. {
  4803. BOOL bOperator_EqualTo = 0;
  4804. BOOL bOperator_GreaterThan = 0;
  4805. BOOL bOperator_LessThan = 0;
  4806. // make sure we have a filename entry
  4807. iTempFlag = FALSE;
  4808. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4809. if (iTempFlag == FALSE)
  4810. {
  4811. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4812. goto ProcessEntry_If_Exit;
  4813. }
  4814. // make sure the description string to comprare it to is specified
  4815. iTempFlag = FALSE;
  4816. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  4817. if (iTempFlag == FALSE)
  4818. {
  4819. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4820. goto ProcessEntry_If_Exit;
  4821. }
  4822. ifTrueStatementExists = FALSE;
  4823. ifFalseStatementExists = FALSE;
  4824. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4825. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4826. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4827. {
  4828. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4829. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4830. goto ProcessEntry_If_Exit;
  4831. }
  4832. // make sure to return true from here on!
  4833. iReturn = TRUE;
  4834. // check if the file exists
  4835. // Check if the filename or dir exists...
  4836. if (!IsFileExist(ParsedLine.szFileName))
  4837. {goto ProcessEntry_If_Exit;}
  4838. TCHAR szFileDescriptionInfo[_MAX_PATH] = _T("");
  4839. // Get the file description info
  4840. // get the DescriptionInfo
  4841. if (!MyGetDescriptionFromFile(ParsedLine.szFileName, szFileDescriptionInfo))
  4842. {
  4843. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("ProcessEntry_If:No file desc in %1!s!, or filenot found\n"), ParsedLine.szFileName));
  4844. goto ProcessEntry_If_Exit;
  4845. }
  4846. iTempFlag = FALSE;
  4847. if ( _tcsicmp(szFileDescriptionInfo,ParsedLine.szData1) == 0)
  4848. {
  4849. // if they match the do the true!
  4850. iTempFlag = TRUE;
  4851. }
  4852. if (iTempFlag == TRUE)
  4853. {
  4854. // the result was true
  4855. // the key exists, so let's do the section...
  4856. if (ifTrueStatementExists)
  4857. {
  4858. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  4859. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  4860. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  4861. }
  4862. }
  4863. else
  4864. {
  4865. // the result was false
  4866. if (ifFalseStatementExists)
  4867. {
  4868. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData3));
  4869. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData3);
  4870. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData3, iTempFlag));
  4871. }
  4872. }
  4873. }
  4874. if ( _tcsicmp(ParsedLine.szType, _T("100")) == 0)
  4875. {
  4876. TCHAR buf[_MAX_PATH];
  4877. GetSystemDirectory(buf, _MAX_PATH);
  4878. // make sure there is a szData1 or a szData2
  4879. ifTrueStatementExists = FALSE;
  4880. ifFalseStatementExists = FALSE;
  4881. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  4882. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  4883. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  4884. {
  4885. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4886. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4887. goto ProcessEntry_If_Exit;
  4888. }
  4889. // okay we have either szData1 or szData2
  4890. // Check if the Service exists...
  4891. iTempFlag = FALSE;
  4892. if (IsThisDriveNTFS(buf) == 0 )
  4893. {
  4894. // yes it is FAT
  4895. iTempFlag = TRUE;
  4896. }
  4897. if (iTempFlag == TRUE)
  4898. {
  4899. // the result was true
  4900. // the key exists, so let's do the section...
  4901. if (ifTrueStatementExists)
  4902. {
  4903. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData1));
  4904. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData1);
  4905. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData1, iTempFlag));
  4906. }
  4907. }
  4908. else
  4909. {
  4910. // the result was false
  4911. if (ifFalseStatementExists)
  4912. {
  4913. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  4914. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  4915. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  4916. }
  4917. }
  4918. }
  4919. if ( _tcsicmp(ParsedLine.szType, _T("119")) == 0)
  4920. {
  4921. if ( IsMachineInDomain() )
  4922. {
  4923. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0 )
  4924. {
  4925. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  4926. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  4927. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  4928. }
  4929. }
  4930. else
  4931. {
  4932. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0 )
  4933. {
  4934. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData3));
  4935. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData3);
  4936. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData3, iTempFlag));
  4937. }
  4938. }
  4939. }
  4940. // We called the function, so return true.
  4941. iReturn = TRUE;
  4942. ProcessEntry_If_Exit:
  4943. return iReturn;
  4944. }
  4945. int ProcessEntry_Metabase(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  4946. {
  4947. int iShowErrorsOnFail = TRUE;
  4948. int iReturn = FALSE;
  4949. int iTempFlag = FALSE;
  4950. // Get the type.
  4951. if ( _tcsicmp(ParsedLine.szType, _T("82")) != 0 && _tcsicmp(ParsedLine.szType, _T("83")) != 0 &&
  4952. _tcsicmp(ParsedLine.szType, _T("84")) != 0 && _tcsicmp(ParsedLine.szType, _T("85")) != 0
  4953. )
  4954. {
  4955. goto ProcessEntry_Metabase_Exit;
  4956. }
  4957. // Check if there is other criteria we need to pass
  4958. if (!ProcessEntry_CheckAll(csEntry, szTheSection, ParsedLine) )
  4959. {
  4960. goto ProcessEntry_Metabase_Exit;
  4961. }
  4962. iShowErrorsOnFail = TRUE;
  4963. if (_tcsicmp(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T("1")) == 0)
  4964. {iShowErrorsOnFail = FALSE;}
  4965. if ( _tcsicmp(ParsedLine.szType, _T("82")) == 0)
  4966. {
  4967. // make sure we have a filename entry
  4968. iTempFlag = FALSE;
  4969. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  4970. if (iTempFlag == FALSE)
  4971. {
  4972. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4973. goto ProcessEntry_Metabase_Exit;
  4974. }
  4975. iTempFlag = FALSE;
  4976. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  4977. if (iTempFlag == FALSE)
  4978. {
  4979. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  4980. goto ProcessEntry_Metabase_Exit;
  4981. }
  4982. // Check if hte szData1 includes a "/*"
  4983. // if it does, then that means to do it for every server instance.
  4984. iTempFlag = FALSE;
  4985. if (_tcsstr(ParsedLine.szFileName, _T("/*")))
  4986. {iTempFlag = TRUE;}
  4987. // Check if we need to do this for every server instance.
  4988. if (iTempFlag)
  4989. {
  4990. CString csTempString;
  4991. CString BeforeString;
  4992. CString AfterString;
  4993. csTempString = ParsedLine.szFileName;
  4994. BeforeString = csTempString;
  4995. AfterString = _T("");
  4996. // Find the "/*" and get the stuff before it.
  4997. int iWhere = 0;
  4998. iWhere = csTempString.Find(_T("/*"));
  4999. if (-1 != iWhere)
  5000. {
  5001. // there is a '/*' in the string
  5002. BeforeString = csTempString.Left(iWhere);
  5003. // Get the after comma vlues
  5004. CString csVeryTemp;
  5005. csVeryTemp = _T("/*");
  5006. AfterString = csTempString.Right( csTempString.GetLength() - (iWhere + csVeryTemp.GetLength()));
  5007. }
  5008. CStringArray arrayInstance;
  5009. int nArray = 0, i = 0;
  5010. if (CheckifServiceExist(_T("IISADMIN")) == 0 )
  5011. {
  5012. CMDKey cmdKey;
  5013. //cmdKey.OpenNode(ParsedLine.szFileName);
  5014. cmdKey.OpenNode(BeforeString);
  5015. if ( (METADATA_HANDLE) cmdKey )
  5016. {
  5017. // enumerate thru this key for other keys...
  5018. CMDKeyIter cmdKeyEnum(cmdKey);
  5019. CString csKeyName;
  5020. while (cmdKeyEnum.Next(&csKeyName) == ERROR_SUCCESS)
  5021. {
  5022. // make sure that it's a number that we are adding.
  5023. if (IsValidNumber(csKeyName))
  5024. {
  5025. arrayInstance.Add(csKeyName);
  5026. }
  5027. }
  5028. cmdKey.Close();
  5029. nArray = (int)arrayInstance.GetSize();
  5030. for (i=0; i<nArray; i++)
  5031. {
  5032. /*
  5033. // Recurse Thru This nodes entries
  5034. // Probably look something like these...
  5035. [/W3SVC]
  5036. [/W3SVC/1/ROOT/IISSAMPLES/ExAir]
  5037. [/W3SVC/1/ROOT/IISADMIN]
  5038. [/W3SVC/1/ROOT/IISHELP]
  5039. [/W3SVC/1/ROOT/specs]
  5040. [/W3SVC/2/ROOT]
  5041. [/W3SVC/2/ROOT/IISADMIN]
  5042. [/W3SVC/2/ROOT/IISHELP]
  5043. etc...
  5044. */
  5045. CString csPath;
  5046. csPath = BeforeString;
  5047. csPath += _T("/");
  5048. csPath += arrayInstance[i];
  5049. csPath += AfterString;
  5050. // delete the metabase node.
  5051. cmdKey.OpenNode(csPath);
  5052. if ( (METADATA_HANDLE)cmdKey )
  5053. {
  5054. cmdKey.DeleteNode(ParsedLine.szData1);
  5055. cmdKey.Close();
  5056. }
  5057. }
  5058. }
  5059. }
  5060. }
  5061. else
  5062. {
  5063. // delete the metabase node.
  5064. if (CheckifServiceExist(_T("IISADMIN")) == 0 )
  5065. {
  5066. CMDKey cmdKey;
  5067. cmdKey.OpenNode(ParsedLine.szFileName);
  5068. if ( (METADATA_HANDLE)cmdKey )
  5069. {
  5070. cmdKey.DeleteNode(ParsedLine.szData1);
  5071. cmdKey.Close();
  5072. }
  5073. }
  5074. }
  5075. }
  5076. if ( _tcsicmp(ParsedLine.szType, _T("83")) == 0)
  5077. {
  5078. // make sure we have a filename entry
  5079. iTempFlag = FALSE;
  5080. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5081. if (iTempFlag == FALSE)
  5082. {
  5083. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5084. goto ProcessEntry_Metabase_Exit;
  5085. }
  5086. iTempFlag = FALSE;
  5087. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  5088. if (iTempFlag == FALSE)
  5089. {
  5090. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5091. goto ProcessEntry_Metabase_Exit;
  5092. }
  5093. iTempFlag = FALSE;
  5094. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  5095. if (iTempFlag == FALSE)
  5096. {
  5097. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5098. goto ProcessEntry_Metabase_Exit;
  5099. }
  5100. // Check if hte szData1 includes a "/*"
  5101. // if it does, then that means to do it for every server instance.
  5102. iTempFlag = FALSE;
  5103. if (_tcsstr(ParsedLine.szFileName, _T("/*")))
  5104. {iTempFlag = TRUE;}
  5105. // Check if we need to do this for every server instance.
  5106. if (iTempFlag)
  5107. {
  5108. CString csTempString;
  5109. CString BeforeString;
  5110. CString AfterString;
  5111. csTempString = ParsedLine.szFileName;
  5112. BeforeString = csTempString;
  5113. AfterString = _T("");
  5114. // Find the "/*" and get the stuff before it.
  5115. int iWhere = 0;
  5116. iWhere = csTempString.Find(_T("/*"));
  5117. if (-1 != iWhere)
  5118. {
  5119. // there is a '/*' in the string
  5120. BeforeString = csTempString.Left(iWhere);
  5121. // Get the after comma vlues
  5122. CString csVeryTemp;
  5123. csVeryTemp = _T("/*");
  5124. AfterString = csTempString.Right( csTempString.GetLength() - (iWhere + csVeryTemp.GetLength()));
  5125. }
  5126. CStringArray arrayInstance;
  5127. int nArray = 0, i = 0;
  5128. if (CheckifServiceExist(_T("IISADMIN")) == 0 )
  5129. {
  5130. CMDKey cmdKey;
  5131. //cmdKey.OpenNode(ParsedLine.szFileName);
  5132. cmdKey.OpenNode(BeforeString);
  5133. if ( (METADATA_HANDLE) cmdKey )
  5134. {
  5135. // enumerate thru this key for other keys...
  5136. CMDKeyIter cmdKeyEnum(cmdKey);
  5137. CString csKeyName;
  5138. while (cmdKeyEnum.Next(&csKeyName) == ERROR_SUCCESS)
  5139. {
  5140. // make sure that it's a number that we are adding.
  5141. if (IsValidNumber(csKeyName))
  5142. {
  5143. arrayInstance.Add(csKeyName);
  5144. }
  5145. }
  5146. cmdKey.Close();
  5147. nArray = (int)arrayInstance.GetSize();
  5148. for (i=0; i<nArray; i++)
  5149. {
  5150. /*
  5151. // Recurse Thru This nodes entries
  5152. // Probably look something like these...
  5153. [/W3SVC]
  5154. [/W3SVC/1/ROOT/IISSAMPLES/ExAir]
  5155. [/W3SVC/1/ROOT/IISADMIN]
  5156. [/W3SVC/1/ROOT/IISHELP]
  5157. [/W3SVC/1/ROOT/specs]
  5158. [/W3SVC/2/ROOT]
  5159. [/W3SVC/2/ROOT/IISADMIN]
  5160. [/W3SVC/2/ROOT/IISHELP]
  5161. etc...
  5162. */
  5163. CString csPath;
  5164. csPath = BeforeString;
  5165. csPath += _T("/");
  5166. csPath += arrayInstance[i];
  5167. csPath += AfterString;
  5168. // DO WHATEVER YOU NEED TO DO.
  5169. int arrayInstanceNum = _ttoi(arrayInstance[i]);
  5170. // Add the virtual root
  5171. iTempFlag = FALSE;
  5172. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {iTempFlag = TRUE;}
  5173. // make sure it ParsedLine.szData1 starts with a "/"
  5174. TCHAR szTempString[_MAX_PATH];
  5175. SafeCopy(szTempString, ParsedLine.szData1, sizeof(szTempString)/sizeof(TCHAR));
  5176. if (szTempString[0] != _T('/'))
  5177. {_stprintf(ParsedLine.szData1, _T("/%s"), szTempString);}
  5178. if (iTempFlag)
  5179. {
  5180. AddMDVRootTree(csPath, ParsedLine.szData1, ParsedLine.szData2, ParsedLine.szData3, arrayInstanceNum);
  5181. }
  5182. else
  5183. {
  5184. AddMDVRootTree(csPath, ParsedLine.szData1, ParsedLine.szData2, NULL, arrayInstanceNum);
  5185. }
  5186. }
  5187. }
  5188. }
  5189. }
  5190. else
  5191. {
  5192. // Add the virtual root
  5193. if (CheckifServiceExist(_T("IISADMIN")) == 0 )
  5194. {
  5195. iTempFlag = FALSE;
  5196. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {iTempFlag = TRUE;}
  5197. // make sure it ParsedLine.szData1 starts with a "/"
  5198. TCHAR szTempString[_MAX_PATH];
  5199. SafeCopy(szTempString, ParsedLine.szData1, sizeof(szTempString)/sizeof(TCHAR));
  5200. if (szTempString[0] != _T('/'))
  5201. {_stprintf(ParsedLine.szData1, _T("/%s"), szTempString);}
  5202. if (iTempFlag)
  5203. {
  5204. AddMDVRootTree(ParsedLine.szFileName, ParsedLine.szData1, ParsedLine.szData2, ParsedLine.szData3, 0);
  5205. }
  5206. else
  5207. {
  5208. AddMDVRootTree(ParsedLine.szFileName, ParsedLine.szData1, ParsedLine.szData2, NULL, 0);
  5209. }
  5210. }
  5211. }
  5212. }
  5213. if ( _tcsicmp(ParsedLine.szType, _T("84")) == 0)
  5214. {
  5215. // make sure we have a filename entry
  5216. iTempFlag = FALSE;
  5217. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5218. if (iTempFlag == FALSE)
  5219. {
  5220. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5221. goto ProcessEntry_Metabase_Exit;
  5222. }
  5223. // call that particular migration section
  5224. TSTR strTheSection;
  5225. if ( strTheSection.Copy( ParsedLine.szFileName ) &&
  5226. GetSectionNameToDo(g_pTheApp->m_hInfHandle, &strTheSection )
  5227. )
  5228. {
  5229. MigrateInfSectionToMD(g_pTheApp->m_hInfHandle, strTheSection.QueryStr() );
  5230. }
  5231. }
  5232. #ifndef _CHICAGO_
  5233. if ( _tcsicmp(ParsedLine.szType, _T("85")) == 0)
  5234. {
  5235. int iTheReturn = TRUE;
  5236. // make sure we have a filename entry
  5237. iTempFlag = FALSE;
  5238. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5239. if (iTempFlag == FALSE)
  5240. {
  5241. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5242. goto ProcessEntry_Metabase_Exit;
  5243. }
  5244. iTempFlag = FALSE;
  5245. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  5246. if (iTempFlag == FALSE)
  5247. {
  5248. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5249. goto ProcessEntry_Metabase_Exit;
  5250. }
  5251. iTheReturn = ChangeUserPassword(ParsedLine.szFileName,ParsedLine.szData1);
  5252. if (FALSE == iTheReturn)
  5253. {
  5254. if (iShowErrorsOnFail){MyMessageBox(NULL, _T("ChangeUserPassword failed"), ParsedLine.szFileName, MB_OK | MB_SETFOREGROUND);}
  5255. else{iisDebugOut((LOG_TYPE_ERROR, _T("ChangeUserPassword(%s). Failed..\n"), ParsedLine.szFileName));}
  5256. }
  5257. }
  5258. #endif
  5259. // We called the function, so return true.
  5260. iReturn = TRUE;
  5261. ProcessEntry_Metabase_Exit:
  5262. return iReturn;
  5263. }
  5264. int ProcessEntry_Misc2(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  5265. {
  5266. int iReturn = FALSE;
  5267. int iTempFlag = FALSE;
  5268. // Get the type.
  5269. if ( _tcsicmp(ParsedLine.szType, _T("15")) != 0 && _tcsicmp(ParsedLine.szType, _T("16")) != 0 &&
  5270. _tcsicmp(ParsedLine.szType, _T("78")) != 0 && _tcsicmp(ParsedLine.szType, _T("79")) != 0 &&
  5271. _tcsicmp(ParsedLine.szType, _T("80")) != 0 && _tcsicmp(ParsedLine.szType, _T("81")) != 0 &&
  5272. _tcsicmp(ParsedLine.szType, _T("86")) != 0 && _tcsicmp(ParsedLine.szType, _T("87")) != 0 &&
  5273. _tcsicmp(ParsedLine.szType, _T("88")) != 0 && _tcsicmp(ParsedLine.szType, _T("89")) != 0 &&
  5274. _tcsicmp(ParsedLine.szType, _T("90")) != 0 && _tcsicmp(ParsedLine.szType, _T("91")) != 0 &&
  5275. _tcsicmp(ParsedLine.szType, _T("92")) != 0 && _tcsicmp(ParsedLine.szType, _T("93")) != 0 &&
  5276. _tcsicmp(ParsedLine.szType, _T("94")) != 0 && _tcsicmp(ParsedLine.szType, _T("95")) != 0 &&
  5277. _tcsicmp(ParsedLine.szType, _T("96")) != 0 && _tcsicmp(ParsedLine.szType, _T("97")) != 0 &&
  5278. _tcsicmp(ParsedLine.szType, _T("98")) != 0 && _tcsicmp(ParsedLine.szType, _T("99")) != 0
  5279. )
  5280. {
  5281. goto ProcessEntry_Misc2_Exit;
  5282. }
  5283. // Check if there is other criteria we need to pass
  5284. if (!ProcessEntry_CheckAll(csEntry, szTheSection, ParsedLine) )
  5285. {
  5286. goto ProcessEntry_Misc2_Exit;
  5287. }
  5288. // make sure we have a progresstitle
  5289. if ( _tcsicmp(ParsedLine.szType, _T("15")) == 0)
  5290. {
  5291. iTempFlag = FALSE;
  5292. if (_tcsicmp(ParsedLine.szProgressTitle, _T("")) != 0) {iTempFlag = TRUE;}
  5293. if (iTempFlag == FALSE)
  5294. {
  5295. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz805_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5296. goto ProcessEntry_Misc2_Exit;
  5297. }
  5298. }
  5299. if ( _tcsicmp(ParsedLine.szType, _T("15")) == 0)
  5300. {
  5301. ProgressBarTextStack_Set(ParsedLine.szProgressTitle);
  5302. }
  5303. if ( _tcsicmp(ParsedLine.szType, _T("16")) == 0)
  5304. {
  5305. ProgressBarTextStack_Pop();
  5306. }
  5307. if ( _tcsicmp(ParsedLine.szType, _T("78")) == 0)
  5308. {
  5309. iTempFlag = FALSE;
  5310. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5311. if (iTempFlag == FALSE)
  5312. {
  5313. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5314. goto ProcessEntry_Misc2_Exit;
  5315. }
  5316. if (!IsFileExist(ParsedLine.szFileName))
  5317. {
  5318. iisDebugOut((LOG_TYPE_TRACE, _T("ProcessEntry_other():'%s' does not exist.\n"),ParsedLine.szFileName));
  5319. goto ProcessEntry_Misc2_Exit;
  5320. }
  5321. MakeSureDirAclsHaveAtLeastRead((LPTSTR) ParsedLine.szFileName);
  5322. }
  5323. if ( _tcsicmp(ParsedLine.szType, _T("79")) == 0)
  5324. {
  5325. int ifTrueStatementExists = FALSE;
  5326. int ifFalseStatementExists = FALSE;
  5327. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  5328. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  5329. iTempFlag = FALSE;
  5330. iTempFlag = IsMetabaseCorrupt();
  5331. if (iTempFlag == TRUE)
  5332. {
  5333. // the result was true
  5334. // the key exists, so let's do the section...
  5335. if (ifTrueStatementExists)
  5336. {
  5337. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szFileName));
  5338. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szFileName);
  5339. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szFileName, iTempFlag));
  5340. }
  5341. }
  5342. else
  5343. {
  5344. // the result was false
  5345. if (ifFalseStatementExists)
  5346. {
  5347. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData1));
  5348. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData1);
  5349. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData1, iTempFlag));
  5350. }
  5351. }
  5352. }
  5353. if ( _tcsicmp(ParsedLine.szType, _T("80")) == 0)
  5354. {
  5355. // initialize ole
  5356. iisDebugOut_Start((_T("ole32:OleInitialize")));
  5357. int iBalanceOLE = iOleInitialize();
  5358. iisDebugOut_End((_T("ole32:OleInitialize")));
  5359. // add it to the stack of ole inits and uninits...
  5360. GlobalOleInitList_Push(iBalanceOLE);
  5361. }
  5362. if ( _tcsicmp(ParsedLine.szType, _T("81")) == 0)
  5363. {
  5364. // Uninitialize ole.
  5365. // Check if there is a corresponding oleinit, if there is,
  5366. // then uninit, else uninit anyways.
  5367. // Grab the last thing on the stack...
  5368. // if there is one, then do whatever it is.
  5369. // if there is none, then OleUninitialize anyway
  5370. if (GlobalOleInitList_Find() == TRUE)
  5371. {
  5372. if (TRUE == GlobalOleInitList_Pop())
  5373. {
  5374. iOleUnInitialize(TRUE);
  5375. }
  5376. else
  5377. {
  5378. iOleUnInitialize(FALSE);
  5379. }
  5380. }
  5381. else
  5382. {
  5383. iOleUnInitialize(TRUE);
  5384. }
  5385. }
  5386. if ( _tcsicmp(ParsedLine.szType, _T("86")) == 0)
  5387. {
  5388. // See if there is an extra param in the other field
  5389. int iTicksToAdvance = 1;
  5390. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0)
  5391. {
  5392. if (IsValidNumber((LPCTSTR)ParsedLine.szFileName))
  5393. {iTicksToAdvance = _ttoi((LPCTSTR)ParsedLine.szFileName);}
  5394. }
  5395. AdvanceProgressBarTickGauge(iTicksToAdvance);
  5396. }
  5397. if ( _tcsicmp(ParsedLine.szType, _T("87")) == 0)
  5398. {
  5399. LogFilesInThisDir(ParsedLine.szFileName);
  5400. }
  5401. if ( _tcsicmp(ParsedLine.szType, _T("88")) == 0)
  5402. {
  5403. LogFileVersion(ParsedLine.szFileName, TRUE);
  5404. }
  5405. if ( _tcsicmp(ParsedLine.szType, _T("89")) == 0)
  5406. {
  5407. // make sure the metabase writes all the information to disk now.
  5408. WriteToMD_ForceMetabaseToWriteToDisk();
  5409. }
  5410. if ( _tcsicmp(ParsedLine.szType, _T("90")) == 0)
  5411. {
  5412. iTempFlag = FALSE;
  5413. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5414. if (iTempFlag == FALSE)
  5415. {
  5416. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5417. goto ProcessEntry_Misc2_Exit;
  5418. }
  5419. DWORD dwTheID = _ttol(ParsedLine.szFileName);
  5420. //iisDebugOut((LOG_TYPE_ERROR, _T("Values: %s, %d"), ParsedLine.szFileName, dwTheID));
  5421. if ( ( dwTheID == 32802 ) && // DomainName
  5422. ( _tcsicmp(ParsedLine.szData1, _T("")) == 0)
  5423. )
  5424. {
  5425. CString DomainName;
  5426. if ( RetrieveDomain(DomainName) )
  5427. {
  5428. SetupSetStringId_Wrapper(g_pTheApp->m_hInfHandle,dwTheID,DomainName.GetBuffer(0));
  5429. }
  5430. }
  5431. else
  5432. {
  5433. SetupSetStringId_Wrapper(g_pTheApp->m_hInfHandle,dwTheID,ParsedLine.szData1);
  5434. }
  5435. }
  5436. if ( _tcsicmp(ParsedLine.szType, _T("91")) == 0)
  5437. {
  5438. iTempFlag = FALSE;
  5439. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5440. if (iTempFlag == FALSE)
  5441. {
  5442. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5443. goto ProcessEntry_Misc2_Exit;
  5444. }
  5445. DWORD dwTheID = atodw(ParsedLine.szFileName);
  5446. SetupSetStringId_Wrapper(g_pTheApp->m_hInfHandle,dwTheID,ParsedLine.szData1);
  5447. }
  5448. if ( _tcsicmp(ParsedLine.szType, _T("92")) == 0)
  5449. {
  5450. // 100=92|101=Inst mode (0,1,2,3)|102=UpgType(UT_10,etc..)|103=UpgTypeHasMetabaseFlag (0|1)|104=AllCompOffByDefaultFlag
  5451. iTempFlag = FALSE;
  5452. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5453. if (iTempFlag == FALSE)
  5454. {
  5455. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5456. goto ProcessEntry_Misc2_Exit;
  5457. }
  5458. iTempFlag = FALSE;
  5459. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  5460. if (iTempFlag == FALSE)
  5461. {
  5462. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5463. goto ProcessEntry_Misc2_Exit;
  5464. }
  5465. iTempFlag = FALSE;
  5466. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  5467. if (iTempFlag == FALSE)
  5468. {
  5469. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5470. goto ProcessEntry_Misc2_Exit;
  5471. }
  5472. iTempFlag = FALSE;
  5473. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {iTempFlag = TRUE;}
  5474. if (iTempFlag == FALSE)
  5475. {
  5476. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5477. goto ProcessEntry_Misc2_Exit;
  5478. }
  5479. //m_eInstallMode = IM_FRESH;
  5480. //m_eUpgradeType = UT_NONE;
  5481. //m_bUpgradeTypeHasMetabaseFlag = FALSE;
  5482. //m_bPleaseDoNotInstallByDefault = TRUE;
  5483. if (_tcsicmp(ParsedLine.szFileName, _T("1")) == 0)
  5484. {g_pTheApp->m_eInstallMode = IM_FRESH;}
  5485. if (_tcsicmp(ParsedLine.szFileName, _T("2")) == 0)
  5486. {g_pTheApp->m_eInstallMode = IM_UPGRADE;}
  5487. if (_tcsicmp(ParsedLine.szFileName, _T("3")) == 0)
  5488. {g_pTheApp->m_eInstallMode = IM_MAINTENANCE;}
  5489. if (_tcsicmp(ParsedLine.szData1, _T("UT_NONE")) == 0)
  5490. {g_pTheApp->m_eUpgradeType = UT_NONE;}
  5491. if (_tcsicmp(ParsedLine.szData1, _T("UT_351")) == 0)
  5492. {g_pTheApp->m_eUpgradeType = UT_351;}
  5493. if (_tcsicmp(ParsedLine.szData1, _T("UT_10")) == 0)
  5494. {g_pTheApp->m_eUpgradeType = UT_10;}
  5495. if (_tcsicmp(ParsedLine.szData1, _T("UT_20")) == 0)
  5496. {g_pTheApp->m_eUpgradeType = UT_20;}
  5497. if (_tcsicmp(ParsedLine.szData1, _T("UT_30")) == 0)
  5498. {g_pTheApp->m_eUpgradeType = UT_30;}
  5499. if (_tcsicmp(ParsedLine.szData1, _T("UT_40")) == 0)
  5500. {g_pTheApp->m_eUpgradeType = UT_40;}
  5501. if (_tcsicmp(ParsedLine.szData1, _T("UT_50")) == 0)
  5502. {g_pTheApp->m_eUpgradeType = UT_50;}
  5503. if (_tcsicmp(ParsedLine.szData1, _T("UT_51")) == 0)
  5504. {g_pTheApp->m_eUpgradeType = UT_51;}
  5505. if (_tcsicmp(ParsedLine.szData1, _T("UT_60")) == 0)
  5506. {g_pTheApp->m_eUpgradeType = UT_60;}
  5507. if (_tcsicmp(ParsedLine.szData1, _T("UT_10_W95")) == 0)
  5508. {g_pTheApp->m_eUpgradeType = UT_10_W95;}
  5509. g_pTheApp->m_bUpgradeTypeHasMetabaseFlag = FALSE;
  5510. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0)
  5511. {g_pTheApp->m_bUpgradeTypeHasMetabaseFlag = TRUE;}
  5512. g_pTheApp->m_bPleaseDoNotInstallByDefault = FALSE;
  5513. if (_tcsicmp(ParsedLine.szData3, _T("1")) == 0)
  5514. {g_pTheApp->m_bPleaseDoNotInstallByDefault = TRUE;}
  5515. }
  5516. if ( _tcsicmp(ParsedLine.szType, _T("93")) == 0)
  5517. {
  5518. iTempFlag = FALSE;
  5519. if (_tcsicmp(ParsedLine.szFileName, _T("1")) == 0) {iTempFlag = TRUE;}
  5520. StopAllServicesRegardless(iTempFlag);
  5521. }
  5522. if ( _tcsicmp(ParsedLine.szType, _T("94")) == 0)
  5523. {
  5524. DisplayActionsForAllOurComponents(g_pTheApp->m_hInfHandle);
  5525. }
  5526. if ( _tcsicmp(ParsedLine.szType, _T("95")) == 0)
  5527. {
  5528. // Check if the specified file has a version >= iis4.
  5529. // if it does then rename the file.
  5530. // make sure it has a 101
  5531. iTempFlag = FALSE;
  5532. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5533. if (iTempFlag == FALSE)
  5534. {
  5535. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5536. goto ProcessEntry_Misc2_Exit;
  5537. }
  5538. // make sure the file exists.
  5539. if (!IsFileExist(ParsedLine.szFileName))
  5540. {
  5541. iisDebugOut((LOG_TYPE_TRACE, _T("ProcessEntry_other():'%s' does not exist.\n"),ParsedLine.szFileName));
  5542. goto ProcessEntry_Misc2_Exit;
  5543. }
  5544. DWORD dwMajorVersion = 0x0;
  5545. DWORD dwMinorVersion = 0x0;
  5546. // make sure it has a 102
  5547. iTempFlag = FALSE;
  5548. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  5549. if (iTempFlag == FALSE)
  5550. {
  5551. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5552. goto ProcessEntry_Misc2_Exit;
  5553. }
  5554. // make sure it has a 103
  5555. iTempFlag = FALSE;
  5556. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  5557. if (iTempFlag == FALSE)
  5558. {
  5559. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5560. goto ProcessEntry_Misc2_Exit;
  5561. }
  5562. else
  5563. {
  5564. dwMajorVersion = atodw(ParsedLine.szData2);
  5565. }
  5566. // make sure it has a 104
  5567. iTempFlag = FALSE;
  5568. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {iTempFlag = TRUE;}
  5569. if (iTempFlag == FALSE)
  5570. {
  5571. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5572. goto ProcessEntry_Misc2_Exit;
  5573. }
  5574. else
  5575. {
  5576. dwMinorVersion = atodw(ParsedLine.szData3);
  5577. }
  5578. // Check if the file has a larger version.
  5579. //DWORD dwNtopMSVer = 0x40002;
  5580. //DWORD dwNtopLSVer = 0x26e0001;
  5581. if (FALSE == IsFileLessThanThisVersion(ParsedLine.szFileName, dwMajorVersion, dwMinorVersion))
  5582. {
  5583. // ok, this is a 'special' built file that the user built themselves.
  5584. // let's rename it to something else.
  5585. // check if the "to" filename exists.
  5586. iTempFlag = FALSE;
  5587. int I1 = 0;
  5588. TCHAR szTempFileName[_MAX_PATH];
  5589. SafeCopy(szTempFileName, ParsedLine.szData1, _MAX_PATH);
  5590. do
  5591. {
  5592. if (!IsFileExist(szTempFileName) || (I1 > 10))
  5593. {
  5594. iTempFlag = TRUE;
  5595. // rename it
  5596. if (MoveFileEx( ParsedLine.szFileName, szTempFileName, MOVEFILE_COPY_ALLOWED|MOVEFILE_WRITE_THROUGH|MOVEFILE_REPLACE_EXISTING))
  5597. {iisDebugOut((LOG_TYPE_WARN, _T("%s was renamed to %s for safety because it is probably a user compiled file. WARNING."),ParsedLine.szFileName, szTempFileName));}
  5598. else
  5599. {iisDebugOut((LOG_TYPE_ERROR, _T("Rename of %s to %s for safety because it is probably a user compiled file. FAILED."),ParsedLine.szFileName, szTempFileName));}
  5600. }
  5601. else
  5602. {
  5603. // add on some other stuff.
  5604. I1++;
  5605. _stprintf(szTempFileName, _T("%s%d"), ParsedLine.szData1, I1);
  5606. }
  5607. } while (iTempFlag == FALSE);
  5608. }
  5609. }
  5610. if ( _tcsicmp(ParsedLine.szType, _T("96")) == 0)
  5611. {
  5612. // show messagebox
  5613. int iSaveOld_AllowMessageBoxPopups = g_pTheApp->m_bAllowMessageBoxPopups;
  5614. g_pTheApp->m_bAllowMessageBoxPopups = TRUE;
  5615. MyMessageBox(NULL, ParsedLine.szData1, ParsedLine.szFileName, MB_OK | MB_SETFOREGROUND);
  5616. g_pTheApp->m_bAllowMessageBoxPopups = iSaveOld_AllowMessageBoxPopups;
  5617. }
  5618. if ( _tcsicmp(ParsedLine.szType, _T("97")) == 0)
  5619. {
  5620. // do nothing...
  5621. }
  5622. if ( _tcsicmp(ParsedLine.szType, _T("98")) == 0)
  5623. {
  5624. //Reboot
  5625. SetRebootFlag();
  5626. }
  5627. if ( _tcsicmp(ParsedLine.szType, _T("99")) == 0)
  5628. {
  5629. // dump internal variables
  5630. g_pTheApp->DumpAppVars();
  5631. int iDoExtraStuff = 0;
  5632. if (ParsedLine.szFileName && _tcsicmp(ParsedLine.szFileName, _T("")) != 0)
  5633. {
  5634. if (IsValidNumber((LPCTSTR)ParsedLine.szFileName))
  5635. {
  5636. iDoExtraStuff = _ttoi((LPCTSTR)ParsedLine.szFileName);
  5637. }
  5638. }
  5639. if (g_GlobalDebugLevelFlag >= LOG_TYPE_TRACE)
  5640. {
  5641. if (iDoExtraStuff >= 2)
  5642. {
  5643. // display locked dlls by setup
  5644. LogThisProcessesDLLs();
  5645. // display running processes
  5646. LogCurrentProcessIDs();
  5647. // free some memory used for the task list
  5648. FreeTaskListMem();
  5649. UnInit_Lib_PSAPI();
  5650. }
  5651. // display running services
  5652. if (iDoExtraStuff >= 1)
  5653. {
  5654. LogEnumServicesStatus();
  5655. }
  5656. // log file versions
  5657. LogImportantFiles();
  5658. // check if temp dir is writeable
  5659. LogCheckIfTempDirWriteable();
  5660. }
  5661. }
  5662. // We called the function, so return true.
  5663. iReturn = TRUE;
  5664. ProcessEntry_Misc2_Exit:
  5665. return iReturn;
  5666. }
  5667. // function: SafeCopy
  5668. //
  5669. // - Copy a string from one to another.
  5670. // - This function takes the length of the destination to make sure we don't
  5671. // copy too much.
  5672. // - This will always make sure that it is null terminated
  5673. //
  5674. // Return
  5675. // A pointer to the destination string
  5676. //
  5677. LPTSTR
  5678. SafeCopy( LPTSTR szDestination, LPTSTR szSource, DWORD dwSize)
  5679. {
  5680. LPTSTR szRet;
  5681. // This is an assumption, so lets make sure it is true
  5682. ASSERT( dwSize != 0 );
  5683. szRet = _tcsncpy( szDestination, szSource, dwSize); // Copy string
  5684. szDestination[dwSize - 1] = '\0'; // NULL Terminate
  5685. return szRet;
  5686. }
  5687. // function: SafeCat
  5688. //
  5689. // - Concatanate one string onto another
  5690. // - This function takes the length of the destination to make sure we don't
  5691. // copy too much.
  5692. // - This will always make sure that it is null terminated
  5693. //
  5694. // Return
  5695. // A pointer to the destination string
  5696. //
  5697. LPTSTR
  5698. SafeCat( LPTSTR szDestination, LPTSTR szSource, DWORD dwSize)
  5699. {
  5700. LPTSTR szRet;
  5701. // This is an assumption, so lets make sure it is true
  5702. ASSERT( dwSize != 0 );
  5703. szRet = _tcsncat( szDestination, szSource, dwSize); // Copy string
  5704. szDestination[dwSize - 1] = '\0'; // NULL Terminate
  5705. return szRet;
  5706. }
  5707. int ProcessEntry_Misc3(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  5708. {
  5709. int iReturn = FALSE;
  5710. int iTempFlag = FALSE;
  5711. int ifTrueStatementExists = FALSE;
  5712. int ifFalseStatementExists = FALSE;
  5713. int iShowErrorsOnFail = TRUE;
  5714. if (_tcsicmp(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T("1")) == 0)
  5715. {iShowErrorsOnFail = FALSE;}
  5716. // Get the type.
  5717. if ( _tcsicmp(ParsedLine.szType, _T("101")) != 0 && _tcsicmp(ParsedLine.szType, _T("102")) != 0 &&
  5718. _tcsicmp(ParsedLine.szType, _T("103")) != 0 && _tcsicmp(ParsedLine.szType, _T("104")) != 0 &&
  5719. _tcsicmp(ParsedLine.szType, _T("105")) != 0 && _tcsicmp(ParsedLine.szType, _T("106")) != 0 &&
  5720. _tcsicmp(ParsedLine.szType, _T("107")) != 0 && _tcsicmp(ParsedLine.szType, _T("108")) != 0 &&
  5721. _tcsicmp(ParsedLine.szType, _T("109")) != 0 && _tcsicmp(ParsedLine.szType, _T("110")) != 0 &&
  5722. _tcsicmp(ParsedLine.szType, _T("111")) != 0 && _tcsicmp(ParsedLine.szType, _T("112")) != 0 &&
  5723. _tcsicmp(ParsedLine.szType, _T("113")) != 0 && _tcsicmp(ParsedLine.szType, _T("114")) != 0 &&
  5724. _tcsicmp(ParsedLine.szType, _T("115")) != 0 && _tcsicmp(ParsedLine.szType, _T("116")) != 0 &&
  5725. _tcsicmp(ParsedLine.szType, _T("117")) != 0 && _tcsicmp(ParsedLine.szType, _T("118")) != 0 &&
  5726. _tcsicmp(ParsedLine.szType, _T("119")) != 0
  5727. )
  5728. {
  5729. goto ProcessEntry_Misc3_Exit;
  5730. }
  5731. // Check if there is other criteria we need to pass
  5732. if (!ProcessEntry_CheckAll(csEntry, szTheSection, ParsedLine) )
  5733. {
  5734. goto ProcessEntry_Misc3_Exit;
  5735. }
  5736. if ( _tcsicmp(ParsedLine.szType, _T("101")) == 0)
  5737. {
  5738. // Remove filter
  5739. // make sure we have a filename entry
  5740. iTempFlag = FALSE;
  5741. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5742. if (iTempFlag == FALSE)
  5743. {
  5744. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5745. goto ProcessEntry_Misc3_Exit;
  5746. }
  5747. // Check for extra flag
  5748. iTempFlag = FALSE;
  5749. if (_tcsicmp(ParsedLine.szData1, _T("1")) == 0){iTempFlag = TRUE;}
  5750. // Remove the filter
  5751. RemoveMetabaseFilter(ParsedLine.szFileName, iTempFlag);
  5752. }
  5753. if ( _tcsicmp(ParsedLine.szType, _T("102")) == 0)
  5754. {
  5755. // Remove bad filters
  5756. // make sure we have a filename entry
  5757. iTempFlag = FALSE;
  5758. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5759. if (iTempFlag == FALSE)
  5760. {
  5761. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5762. goto ProcessEntry_Misc3_Exit;
  5763. }
  5764. // Check for extra flag
  5765. iTempFlag = FALSE;
  5766. if (_tcsicmp(ParsedLine.szData1, _T("1")) == 0){iTempFlag = TRUE;}
  5767. // Remove the filter
  5768. RemoveIncompatibleMetabaseFilters(ParsedLine.szFileName,iTempFlag);
  5769. }
  5770. if ( _tcsicmp(ParsedLine.szType, _T("103")) == 0)
  5771. {
  5772. // Compile mof file
  5773. // make sure we have a filename entry
  5774. iTempFlag = FALSE;
  5775. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5776. if (iTempFlag == FALSE)
  5777. {
  5778. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5779. goto ProcessEntry_Misc3_Exit;
  5780. }
  5781. // Remove the filter
  5782. HRESULT hres = MofCompile(ParsedLine.szFileName);
  5783. if (FAILED(hres))
  5784. {
  5785. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, ParsedLine.szFileName, hres, MB_OK | MB_SETFOREGROUND);}
  5786. else{iisDebugOut((LOG_TYPE_ERROR, _T("MofCompile(%s). Failed. Err=0x%x.\n"), ParsedLine.szFileName,hres));}
  5787. }
  5788. }
  5789. if ( _tcsicmp(ParsedLine.szType, _T("104")) == 0)
  5790. {
  5791. // make sure we have a filename entry
  5792. iTempFlag = FALSE;
  5793. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5794. if (iTempFlag == FALSE)
  5795. {
  5796. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5797. goto ProcessEntry_Misc3_Exit;
  5798. }
  5799. // Make sure we have a value for the entry point..
  5800. iTempFlag = FALSE;
  5801. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  5802. if (iTempFlag == FALSE)
  5803. {
  5804. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5805. goto ProcessEntry_Misc3_Exit;
  5806. }
  5807. // make sure there is a szData3 or a szData4.
  5808. ifTrueStatementExists = FALSE;
  5809. ifFalseStatementExists = FALSE;
  5810. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  5811. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  5812. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  5813. {
  5814. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5815. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5816. goto ProcessEntry_Misc3_Exit;
  5817. }
  5818. // okay we have either szData3 or szData4
  5819. // Check Entry point exists
  5820. iTempFlag = FALSE;
  5821. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("ProcessEntry_If:check for entrypoint [%1!s! (%2!s!)]\n"), ParsedLine.szFileName, ParsedLine.szData1));
  5822. // check if entry point exists
  5823. DWORD dwReturn = DoesEntryPointExist(ParsedLine.szFileName,ParsedLine.szData1);
  5824. if (ERROR_SUCCESS == dwReturn)
  5825. {
  5826. iTempFlag = TRUE;
  5827. }
  5828. else
  5829. {
  5830. if (ERROR_FILE_NOT_FOUND == dwReturn)
  5831. {
  5832. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("FileNot found:[%1!s!]\n"), ParsedLine.szFileName));
  5833. }
  5834. }
  5835. if (iTempFlag == TRUE)
  5836. {
  5837. // the result was true
  5838. // the key exists, so let's do the section...
  5839. if (ifTrueStatementExists)
  5840. {
  5841. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  5842. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  5843. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  5844. }
  5845. }
  5846. else
  5847. {
  5848. // the result was false
  5849. if (ifFalseStatementExists)
  5850. {
  5851. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData3));
  5852. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData3);
  5853. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData3, iTempFlag));
  5854. }
  5855. }
  5856. }
  5857. if ( _tcsicmp(ParsedLine.szType, _T("105")) == 0)
  5858. {
  5859. // make sure we have a filename entry
  5860. iTempFlag = FALSE;
  5861. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5862. if (iTempFlag == FALSE)
  5863. {
  5864. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5865. goto ProcessEntry_Misc3_Exit;
  5866. }
  5867. // Make sure we have a value for the entry point..
  5868. iTempFlag = FALSE;
  5869. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  5870. if (iTempFlag == FALSE)
  5871. {
  5872. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5873. goto ProcessEntry_Misc3_Exit;
  5874. }
  5875. // see if we got the extra param
  5876. iTempFlag = FALSE;
  5877. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  5878. if (iTempFlag == FALSE)
  5879. {
  5880. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5881. goto ProcessEntry_Misc3_Exit;
  5882. }
  5883. // see if we got the extra param to say -- do this for the special group
  5884. INT iTempFlag2 = FALSE;
  5885. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {iTempFlag2 = TRUE;}
  5886. // call function to CreateGroup
  5887. #ifndef _CHICAGO_
  5888. HRESULT hr;
  5889. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0)
  5890. {
  5891. // add group
  5892. hr = CreateGroup(ParsedLine.szFileName,ParsedLine.szData1,TRUE, iTempFlag2);
  5893. if (FAILED(hr))
  5894. {
  5895. iisDebugOut((LOG_TYPE_WARN, _T("CreateGroup:%s,%s.failed.code=0x%x\n"),ParsedLine.szFileName, ParsedLine.szData1,hr));
  5896. }
  5897. }
  5898. else
  5899. {
  5900. // remove group
  5901. hr = CreateGroup(ParsedLine.szFileName,ParsedLine.szData1,FALSE, iTempFlag2);
  5902. if (FAILED(hr))
  5903. {
  5904. iisDebugOut((LOG_TYPE_WARN, _T("DeleteGroup:%s,%s.failed.code=0x%x\n"),ParsedLine.szFileName, ParsedLine.szData1,hr));
  5905. }
  5906. }
  5907. #endif
  5908. }
  5909. if ( _tcsicmp(ParsedLine.szType, _T("106")) == 0)
  5910. {
  5911. // make sure we have a filename entry
  5912. iTempFlag = FALSE;
  5913. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5914. if (iTempFlag == FALSE)
  5915. {
  5916. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5917. goto ProcessEntry_Misc3_Exit;
  5918. }
  5919. // Make sure we have a value for the entry point..
  5920. iTempFlag = FALSE;
  5921. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  5922. if (iTempFlag == FALSE)
  5923. {
  5924. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5925. goto ProcessEntry_Misc3_Exit;
  5926. }
  5927. // call function to CreateGroup
  5928. DWORD dwPermissions = MD_ACR_ENUM_KEYS;
  5929. dwPermissions = atodw(ParsedLine.szData1);
  5930. #ifndef _CHICAGO_
  5931. iTempFlag = TRUE;
  5932. if (g_pTheApp->m_bUpgradeTypeHasMetabaseFlag)
  5933. {
  5934. if (DoesAdminACLExist(ParsedLine.szFileName) == TRUE)
  5935. {iTempFlag = FALSE;}
  5936. }
  5937. // if this is upgrading from win95, then make sure to write the acl...
  5938. if (g_pTheApp->m_bWin95Migration){iTempFlag = TRUE;}
  5939. if (iTempFlag)
  5940. {
  5941. SetAdminACL_wrap(ParsedLine.szFileName,dwPermissions,TRUE);
  5942. }
  5943. #endif
  5944. }
  5945. if ( _tcsicmp(ParsedLine.szType, _T("107")) == 0)
  5946. {
  5947. // Run the ftp, upgrade code to move registry stuff to the metabase
  5948. FTP_Upgrade_RegToMetabase(g_pTheApp->m_hInfHandle);
  5949. }
  5950. if ( _tcsicmp(ParsedLine.szType, _T("108")) == 0)
  5951. {
  5952. // Run the w3svc, upgrade code to move registry stuff to the metabase
  5953. WWW_Upgrade_RegToMetabase(g_pTheApp->m_hInfHandle);
  5954. }
  5955. if ( _tcsicmp(ParsedLine.szType, _T("109")) == 0)
  5956. {
  5957. iTempFlag = FALSE;
  5958. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5959. if (iTempFlag == FALSE)
  5960. {
  5961. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5962. goto ProcessEntry_Misc3_Exit;
  5963. }
  5964. UpgradeFilters(ParsedLine.szFileName);
  5965. }
  5966. if ( _tcsicmp(ParsedLine.szType, _T("110")) == 0)
  5967. {
  5968. iTempFlag = FALSE;
  5969. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  5970. if (iTempFlag == FALSE)
  5971. {
  5972. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5973. goto ProcessEntry_Misc3_Exit;
  5974. }
  5975. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  5976. if (iTempFlag == FALSE)
  5977. {
  5978. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  5979. goto ProcessEntry_Misc3_Exit;
  5980. }
  5981. #ifndef _CHICAGO_
  5982. if (_tcsicmp(ParsedLine.szData1, _T("1")) == 0)
  5983. {
  5984. // add
  5985. RegisterAccountToLocalGroup(_T("system"),ParsedLine.szFileName,TRUE);
  5986. RegisterAccountToLocalGroup(_T("service"),ParsedLine.szFileName,TRUE);
  5987. RegisterAccountToLocalGroup(_T("networkservice"),ParsedLine.szFileName,TRUE);
  5988. }
  5989. else
  5990. {
  5991. // remove
  5992. RegisterAccountToLocalGroup(_T("system"),ParsedLine.szFileName,FALSE);
  5993. RegisterAccountToLocalGroup(_T("service"),ParsedLine.szFileName,FALSE);
  5994. RegisterAccountToLocalGroup(_T("networkservice"),ParsedLine.szFileName,FALSE);
  5995. }
  5996. #endif
  5997. }
  5998. if ( _tcsicmp(ParsedLine.szType, _T("111")) == 0)
  5999. {
  6000. iTempFlag = FALSE;
  6001. DWORD dwAccessMask = 0x0;
  6002. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6003. if (iTempFlag == FALSE)
  6004. {
  6005. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6006. goto ProcessEntry_Misc3_Exit;
  6007. }
  6008. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  6009. if (iTempFlag == FALSE)
  6010. {
  6011. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6012. goto ProcessEntry_Misc3_Exit;
  6013. }
  6014. if ( _tcsicmp(ParsedLine.szData2, _T("")) != 0 )
  6015. {
  6016. // Get access mask if it is available
  6017. dwAccessMask = atodw(ParsedLine.szData2);
  6018. }
  6019. #ifndef _CHICAGO_
  6020. AddUserToMetabaseACL_Rec(ParsedLine.szFileName,ParsedLine.szData1, dwAccessMask);
  6021. #endif
  6022. }
  6023. if ( _tcsicmp(ParsedLine.szType, _T("112")) == 0)
  6024. {
  6025. iTempFlag = FALSE;
  6026. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6027. if (iTempFlag == FALSE)
  6028. {
  6029. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6030. goto ProcessEntry_Misc3_Exit;
  6031. }
  6032. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  6033. if (iTempFlag == FALSE)
  6034. {
  6035. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6036. goto ProcessEntry_Misc3_Exit;
  6037. }
  6038. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  6039. if (iTempFlag == FALSE)
  6040. {
  6041. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6042. goto ProcessEntry_Misc3_Exit;
  6043. }
  6044. #ifndef _CHICAGO_
  6045. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0)
  6046. {
  6047. // add
  6048. RegisterAccountToLocalGroup(ParsedLine.szData1,ParsedLine.szFileName,TRUE);
  6049. }
  6050. else
  6051. {
  6052. // remove
  6053. RegisterAccountToLocalGroup(ParsedLine.szData1,ParsedLine.szFileName,FALSE);
  6054. }
  6055. #endif
  6056. }
  6057. if ( _tcsicmp(ParsedLine.szType, _T("113")) == 0)
  6058. {
  6059. iTempFlag = FALSE;
  6060. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6061. if (iTempFlag == FALSE)
  6062. {
  6063. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6064. goto ProcessEntry_Misc3_Exit;
  6065. }
  6066. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  6067. if (iTempFlag == FALSE)
  6068. {
  6069. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6070. goto ProcessEntry_Misc3_Exit;
  6071. }
  6072. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  6073. if (iTempFlag == FALSE)
  6074. {
  6075. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6076. goto ProcessEntry_Misc3_Exit;
  6077. }
  6078. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {iTempFlag = TRUE;}
  6079. if (iTempFlag == FALSE)
  6080. {
  6081. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6082. goto ProcessEntry_Misc3_Exit;
  6083. }
  6084. HKEY hRootKeyType = HKEY_LOCAL_MACHINE;
  6085. // check if the registry key exists...
  6086. if ( _tcsicmp(ParsedLine.szFileName, _T("HKLM")) == 0){hRootKeyType = HKEY_LOCAL_MACHINE;}
  6087. if ( _tcsicmp(ParsedLine.szFileName, _T("HKCR")) == 0){hRootKeyType = HKEY_CLASSES_ROOT;}
  6088. if ( _tcsicmp(ParsedLine.szFileName, _T("HKCU")) == 0){hRootKeyType = HKEY_CURRENT_USER;}
  6089. if ( _tcsicmp(ParsedLine.szFileName, _T("HKU")) == 0){hRootKeyType = HKEY_USERS;}
  6090. #ifndef _CHICAGO_
  6091. DWORD dwAccessMask = atodw(ParsedLine.szData3);
  6092. DWORD dwInheritMask = CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE;
  6093. SetRegistryKeySecurity(hRootKeyType,ParsedLine.szData1,ParsedLine.szData2,dwAccessMask,dwInheritMask,TRUE,ParsedLine.szData4);
  6094. #endif
  6095. }
  6096. if ( _tcsicmp(ParsedLine.szType, _T("114")) == 0)
  6097. {
  6098. iTempFlag = FALSE;
  6099. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6100. if (iTempFlag == FALSE)
  6101. {
  6102. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6103. goto ProcessEntry_Misc3_Exit;
  6104. }
  6105. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  6106. if (iTempFlag == FALSE)
  6107. {
  6108. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6109. goto ProcessEntry_Misc3_Exit;
  6110. }
  6111. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  6112. if (iTempFlag == FALSE)
  6113. {
  6114. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6115. goto ProcessEntry_Misc3_Exit;
  6116. }
  6117. // rename the metabase node.
  6118. if (CheckifServiceExist(_T("IISADMIN")) == 0 )
  6119. {
  6120. CMDKey cmdKey;
  6121. cmdKey.OpenNode(ParsedLine.szFileName);
  6122. if ( (METADATA_HANDLE)cmdKey )
  6123. {
  6124. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("RenameNode:%s=%s\n"),ParsedLine.szData1,ParsedLine.szData2));
  6125. cmdKey.RenameNode(ParsedLine.szData1, ParsedLine.szData2);
  6126. cmdKey.Close();
  6127. }
  6128. }
  6129. }
  6130. if ( _tcsicmp(ParsedLine.szType, _T("115")) == 0)
  6131. {
  6132. // make sure we have a filename entry
  6133. iTempFlag = FALSE;
  6134. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6135. if (iTempFlag == FALSE)
  6136. {
  6137. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6138. goto ProcessEntry_Misc3_Exit;
  6139. }
  6140. // make sure there is a szData1 or a szData2
  6141. ifTrueStatementExists = FALSE;
  6142. ifFalseStatementExists = FALSE;
  6143. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  6144. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  6145. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  6146. {
  6147. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6148. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6149. goto ProcessEntry_Misc3_Exit;
  6150. }
  6151. // okay we have either szData1 or szData2
  6152. // Check if the language specified in the .inf corresponds to
  6153. // our systems language.
  6154. iTempFlag = FALSE;
  6155. // Get our language
  6156. // set iTempFlag to true if it matches the same language they specified.
  6157. DWORD dwCodePage = GetACP();
  6158. DWORD dwTheCodePageSpecifiedinINF = 0;
  6159. dwTheCodePageSpecifiedinINF = atodw(ParsedLine.szFileName);
  6160. iisDebugOut((LOG_TYPE_TRACE, _T("CodePage=0x%x,%d\n"),dwCodePage,dwCodePage));
  6161. if (dwTheCodePageSpecifiedinINF == dwCodePage)
  6162. {
  6163. iTempFlag = TRUE;
  6164. }
  6165. if (iTempFlag == TRUE)
  6166. {
  6167. // the result was true
  6168. // the key exists, so let's do the section...
  6169. if (ifTrueStatementExists)
  6170. {
  6171. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData1));
  6172. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData1);
  6173. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData1, iTempFlag));
  6174. }
  6175. }
  6176. else
  6177. {
  6178. // the result was false
  6179. if (ifFalseStatementExists)
  6180. {
  6181. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  6182. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  6183. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  6184. }
  6185. }
  6186. }
  6187. if ( _tcsicmp(ParsedLine.szType, _T("116")) == 0)
  6188. {
  6189. iisDebugOut((LOG_TYPE_TRACE, _T("CreateDummyMetabaseBin\n")));
  6190. CreateDummyMetabaseBin();
  6191. }
  6192. if ( _tcsicmp(ParsedLine.szType, _T("117")) == 0)
  6193. {
  6194. // make sure we have a filename entry
  6195. iTempFlag = FALSE;
  6196. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6197. if (iTempFlag == FALSE)
  6198. {
  6199. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6200. goto ProcessEntry_Misc3_Exit;
  6201. }
  6202. // make sure there is a szData1 or a szData2
  6203. ifTrueStatementExists = FALSE;
  6204. ifFalseStatementExists = FALSE;
  6205. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {ifTrueStatementExists = TRUE;}
  6206. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {ifFalseStatementExists = TRUE;}
  6207. if (ifTrueStatementExists == FALSE && ifFalseStatementExists == FALSE)
  6208. {
  6209. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6210. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6211. goto ProcessEntry_Misc3_Exit;
  6212. }
  6213. // okay we have either szData1 or szData2
  6214. iTempFlag = CheckForWriteAccess(ParsedLine.szFileName);
  6215. if (iTempFlag == TRUE)
  6216. {
  6217. // the result was true
  6218. // the key exists, so let's do the section...
  6219. if (ifTrueStatementExists)
  6220. {
  6221. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData1));
  6222. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData1);
  6223. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData1, iTempFlag));
  6224. }
  6225. }
  6226. else
  6227. {
  6228. // the result was false
  6229. if (ifFalseStatementExists)
  6230. {
  6231. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:Start.\n"), ParsedLine.szData2));
  6232. iTempFlag = ProcessSection(g_pTheApp->m_hInfHandle,ParsedLine.szData2);
  6233. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Calling ProcessSection:%1!s!:End.return=%2!d!\n"), ParsedLine.szData2, iTempFlag));
  6234. }
  6235. }
  6236. }
  6237. if ( _tcsicmp(ParsedLine.szType, _T("118")) == 0)
  6238. {
  6239. iTempFlag = FALSE;
  6240. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6241. if (iTempFlag == FALSE)
  6242. {
  6243. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6244. goto ProcessEntry_Misc3_Exit;
  6245. }
  6246. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  6247. if (iTempFlag == FALSE)
  6248. {
  6249. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6250. goto ProcessEntry_Misc3_Exit;
  6251. }
  6252. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  6253. if (iTempFlag == FALSE)
  6254. {
  6255. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6256. goto ProcessEntry_Misc3_Exit;
  6257. }
  6258. #ifndef _CHICAGO_
  6259. if (_tcsicmp(ParsedLine.szData4, _T("")) != 0) {iTempFlag = TRUE;}
  6260. if (iTempFlag == FALSE)
  6261. {
  6262. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6263. goto ProcessEntry_Misc3_Exit;
  6264. }
  6265. if ( _ttoi(ParsedLine.szData4) == 1 )
  6266. {
  6267. RemovePrincipalFromFileAcl(ParsedLine.szFileName,ParsedLine.szData1);
  6268. }
  6269. else
  6270. {
  6271. // don't remove any iheritance, keep all inheritance
  6272. BOOL DontInheritFromParentAndOverWriteAccess = FALSE;
  6273. DWORD dwInheritMask = 0;
  6274. INT iAceType = ACCESS_ALLOWED_ACE_TYPE;
  6275. DWORD dwAccessMask = atodw(ParsedLine.szData2);
  6276. // see if the "special" parameter was passed in...
  6277. // we had to use szData4 since we don't have a szData5 :-(
  6278. if ( _ttoi(ParsedLine.szData4) == 2 )
  6279. {
  6280. DontInheritFromParentAndOverWriteAccess = TRUE;
  6281. dwInheritMask = CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE;
  6282. }
  6283. else
  6284. {
  6285. DontInheritFromParentAndOverWriteAccess = FALSE;
  6286. //dwInheritMask = CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE | INHERITED_ACE;
  6287. dwInheritMask = 0;
  6288. }
  6289. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0)
  6290. {
  6291. iAceType = _ttoi(ParsedLine.szData3);
  6292. }
  6293. SetDirectorySecurity(ParsedLine.szFileName,ParsedLine.szData1,iAceType,dwAccessMask,dwInheritMask,DontInheritFromParentAndOverWriteAccess);
  6294. }
  6295. #endif
  6296. }
  6297. if ( _tcsicmp(ParsedLine.szType, _T("119")) == 0)
  6298. {
  6299. SetDIRIDforThisInf(g_pTheApp->m_hInfHandle,FALSE);
  6300. }
  6301. // We called the function, so return true.
  6302. iReturn = TRUE;
  6303. ProcessEntry_Misc3_Exit:
  6304. return iReturn;
  6305. }
  6306. int ProcessEntry_other(IN CString csEntry,IN LPCTSTR szTheSection,ThingToDo ParsedLine)
  6307. {
  6308. int iReturn = FALSE;
  6309. int iTempFlag = FALSE;
  6310. int iProgressBarUpdated = FALSE;
  6311. int iShowErrorsOnFail = TRUE;
  6312. TCHAR szDirBefore[_MAX_PATH];
  6313. _tcscpy(szDirBefore, _T(""));
  6314. // Get the type.
  6315. if ( _tcsicmp(ParsedLine.szType, _T("19")) != 0 && _tcsicmp(ParsedLine.szType, _T("20")) != 0 &&
  6316. _tcsicmp(ParsedLine.szType, _T("21")) != 0 && _tcsicmp(ParsedLine.szType, _T("22")) != 0 &&
  6317. _tcsicmp(ParsedLine.szType, _T("23")) != 0 && _tcsicmp(ParsedLine.szType, _T("24")) != 0 &&
  6318. _tcsicmp(ParsedLine.szType, _T("25")) != 0 && _tcsicmp(ParsedLine.szType, _T("26")) != 0 &&
  6319. _tcsicmp(ParsedLine.szType, _T("27")) != 0 && _tcsicmp(ParsedLine.szType, _T("28")) != 0 &&
  6320. _tcsicmp(ParsedLine.szType, _T("29")) != 0 && _tcsicmp(ParsedLine.szType, _T("30")) != 0 &&
  6321. _tcsicmp(ParsedLine.szType, _T("31")) != 0 && _tcsicmp(ParsedLine.szType, _T("32")) != 0 &&
  6322. _tcsicmp(ParsedLine.szType, _T("33")) != 0 && _tcsicmp(ParsedLine.szType, _T("34")) != 0 &&
  6323. _tcsicmp(ParsedLine.szType, _T("35")) != 0 && _tcsicmp(ParsedLine.szType, _T("36")) != 0 &&
  6324. _tcsicmp(ParsedLine.szType, _T("37")) != 0 && _tcsicmp(ParsedLine.szType, _T("38")) != 0 &&
  6325. _tcsicmp(ParsedLine.szType, _T("120"))
  6326. )
  6327. {
  6328. goto ProcessEntry_other_Exit;
  6329. }
  6330. // Check if there is other criteria we need to pass
  6331. if (!ProcessEntry_CheckAll(csEntry, szTheSection, ParsedLine) )
  6332. {
  6333. goto ProcessEntry_other_Exit;
  6334. }
  6335. if (_tcsicmp(ParsedLine.szType, _T("28")) != 0)
  6336. {
  6337. if (_tcsicmp(ParsedLine.szType, _T("37")) != 0)
  6338. {
  6339. // make sure we have a filename entry
  6340. iTempFlag = FALSE;
  6341. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6342. if (iTempFlag == FALSE)
  6343. {
  6344. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6345. goto ProcessEntry_other_Exit;
  6346. }
  6347. }
  6348. }
  6349. iShowErrorsOnFail = TRUE;
  6350. if (_tcsicmp(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T("1")) == 0)
  6351. {iShowErrorsOnFail = FALSE;}
  6352. if (_tcsicmp(ParsedLine.szProgressTitle, _T("")) != 0)
  6353. {
  6354. ProgressBarTextStack_Set(ParsedLine.szProgressTitle);
  6355. iProgressBarUpdated = TRUE;
  6356. }
  6357. // Check if we need to change to a specific dir first...
  6358. if (ParsedLine.szChangeDir)
  6359. {
  6360. if (IsFileExist(ParsedLine.szChangeDir))
  6361. {
  6362. // save the current dir
  6363. GetCurrentDirectory( _MAX_PATH, szDirBefore);
  6364. // change to this dir
  6365. SetCurrentDirectory(ParsedLine.szChangeDir);
  6366. }
  6367. }
  6368. // check if we need to ask the user if they want to call it for sure.
  6369. if (!ProcessEntry_AskFirst(ParsedLine, 1))
  6370. {
  6371. goto ProcessEntry_other_Exit;
  6372. }
  6373. if ( _tcsicmp(ParsedLine.szType, _T("19")) == 0)
  6374. {
  6375. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("MyAddGroup:%1!s!\n"),ParsedLine.szFileName));
  6376. MyAddGroup(ParsedLine.szFileName);
  6377. }
  6378. if ( _tcsicmp(ParsedLine.szType, _T("20")) == 0)
  6379. {
  6380. if ( _tcsicmp(ParsedLine.szData1, _T("1")) == 0)
  6381. {
  6382. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("MyDeleteGroup:%1!s!. even if not empty.\n"),ParsedLine.szFileName));
  6383. MyDeleteGroup(ParsedLine.szFileName);
  6384. }
  6385. else
  6386. {
  6387. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("MyDeleteGroup:%1!s!. only if empty.\n"),ParsedLine.szFileName));
  6388. if (MyIsGroupEmpty(ParsedLine.szFileName)) {MyDeleteGroup(ParsedLine.szFileName);}
  6389. }
  6390. }
  6391. if ( _tcsicmp(ParsedLine.szType, _T("21")) == 0)
  6392. {
  6393. //MyAddItem(csGroupName, csAppName, csProgram, NULL, NULL);
  6394. 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));
  6395. if ( _tcsicmp(ParsedLine.szData3, _T("")) == 0 && _tcsicmp(ParsedLine.szData4, _T("")) == 0)
  6396. {
  6397. MyAddItem(ParsedLine.szFileName, ParsedLine.szData1, ParsedLine.szData2, NULL, NULL, NULL);
  6398. }
  6399. else
  6400. {
  6401. // if ParsedLine.szData4 is a directory, then
  6402. // the start in dir should be used there.
  6403. // if ParsedLine.szData4 is a filename, then
  6404. // the start in dir should be used there.
  6405. // and you ought to use the filename specified for the icon
  6406. if (IsFileExist(ParsedLine.szData4))
  6407. {
  6408. DWORD retCode = GetFileAttributes(ParsedLine.szData4);
  6409. if (retCode & FILE_ATTRIBUTE_DIRECTORY)
  6410. {
  6411. // It is a directory, so pass in only the directory information
  6412. MyAddItem(ParsedLine.szFileName, ParsedLine.szData1, ParsedLine.szData2, ParsedLine.szData3, ParsedLine.szData4, NULL);
  6413. }
  6414. else
  6415. {
  6416. // it is a file so get the directory and pass in the filename as well.
  6417. TCHAR szDirOnly[_MAX_PATH];
  6418. TCHAR szDirOnly2[_MAX_PATH];
  6419. _tcscpy(szDirOnly, _T(""));
  6420. _tcscpy(szDirOnly2, _T(""));
  6421. InetGetFilePath(ParsedLine.szData4, szDirOnly);
  6422. // change e:\winnt\system32 to %systemroot%\system32 if we need to.
  6423. ReverseExpandEnvironmentStrings(szDirOnly, szDirOnly2);
  6424. MyAddItem(ParsedLine.szFileName, ParsedLine.szData1, ParsedLine.szData2, ParsedLine.szData3, szDirOnly2, ParsedLine.szData4);
  6425. }
  6426. }
  6427. else
  6428. {
  6429. MyAddItem(ParsedLine.szFileName, ParsedLine.szData1, ParsedLine.szData2, NULL, NULL, NULL);
  6430. }
  6431. }
  6432. }
  6433. if ( _tcsicmp(ParsedLine.szType, _T("22")) == 0)
  6434. {
  6435. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("MyDeleteItem:%1!s!,%2!s!\n"),ParsedLine.szFileName, ParsedLine.szData1));
  6436. MyDeleteItem(ParsedLine.szFileName, ParsedLine.szData1);
  6437. }
  6438. if ( _tcsicmp(ParsedLine.szType, _T("23")) == 0)
  6439. {
  6440. //MyAddDeskTopItem(csAppName, csProgram, NULL, NULL, csProgram, 7);
  6441. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("MyAddDeskTopItem:Type=%1!s!,%2!s!,%3!s!\n"),ParsedLine.szFileName, ParsedLine.szData1, ParsedLine.szData2));
  6442. if ( _tcsicmp(ParsedLine.szData2, _T("")) == 0)
  6443. {
  6444. // icon number not specified
  6445. MyAddDeskTopItem(ParsedLine.szFileName, ParsedLine.szData1, NULL, NULL, ParsedLine.szData1, 7);
  6446. }
  6447. else
  6448. {
  6449. // icon specified use what they said to use
  6450. int iIconIndex = 7 ;
  6451. if (IsValidNumber((LPCTSTR)ParsedLine.szData2))
  6452. {iIconIndex = _ttoi((LPCTSTR)ParsedLine.szData2);}
  6453. MyAddDeskTopItem(ParsedLine.szFileName, ParsedLine.szData1, NULL, NULL, ParsedLine.szData1, iIconIndex);
  6454. }
  6455. }
  6456. if ( _tcsicmp(ParsedLine.szType, _T("24")) == 0)
  6457. {
  6458. // Check which version they want....
  6459. iTempFlag = FALSE;
  6460. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0)
  6461. {
  6462. BOOL bDeleteItsDirToo = _ttoi(ParsedLine.szData1);
  6463. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("MyDeleteDeskTopItem2:%1!s!,%2!d!\n"),ParsedLine.szFileName,bDeleteItsDirToo));
  6464. MyDeleteDeskTopItem2(ParsedLine.szFileName, bDeleteItsDirToo);
  6465. }
  6466. else
  6467. {
  6468. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("MyDeleteDeskTopItem:%1!s!\n"),ParsedLine.szFileName));
  6469. MyDeleteDeskTopItem(ParsedLine.szFileName);
  6470. }
  6471. }
  6472. if ( _tcsicmp(ParsedLine.szType, _T("120")) == 0)
  6473. {
  6474. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("DeleteFromGroup:%1!s!\n"),ParsedLine.szFileName));
  6475. DeleteFromGroup(ParsedLine.szFileName, ParsedLine.szData1);
  6476. }
  6477. if ( _tcsicmp(ParsedLine.szType, _T("25")) == 0)
  6478. {
  6479. //MyAddSendToItem(csAppName, csProgram, NULL, NULL);
  6480. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("MyAddSendToItem:Type=%1!s!,%2!s!\n"),ParsedLine.szFileName, ParsedLine.szData1));
  6481. MyAddSendToItem(ParsedLine.szFileName, ParsedLine.szData1, NULL, NULL);
  6482. }
  6483. if ( _tcsicmp(ParsedLine.szType, _T("26")) == 0)
  6484. {
  6485. //MyDeleteSendToItem(csAppName);
  6486. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("MyDeleteSendToItem:%1!s!\n"),ParsedLine.szFileName));
  6487. MyDeleteSendToItem(ParsedLine.szFileName);
  6488. }
  6489. if ( _tcsicmp(ParsedLine.szType, _T("27")) == 0)
  6490. {
  6491. if (ParsedLine.szFileName)
  6492. {
  6493. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0)
  6494. {
  6495. INT iUserWasNewlyCreated = 0;
  6496. //CreateIUSRAccount(g_pTheApp->m_csWWWAnonyName, g_pTheApp->m_csWWWAnonyPassword);
  6497. #ifndef _CHICAGO_
  6498. CreateIUSRAccount( (LPTSTR)(LPCTSTR) ParsedLine.szFileName, (LPTSTR)(LPCTSTR) ParsedLine.szData1,&iUserWasNewlyCreated);
  6499. #endif //_CHICAGO_
  6500. }
  6501. }
  6502. }
  6503. if ( _tcsicmp(ParsedLine.szType, _T("28")) == 0)
  6504. {
  6505. if (ParsedLine.szFileName)
  6506. {
  6507. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0)
  6508. {
  6509. #ifndef _CHICAGO_
  6510. int iUserWasDeleted = 0;
  6511. DeleteGuestUser( (LPTSTR)(LPCTSTR) ParsedLine.szFileName,&iUserWasDeleted);
  6512. // if the user was deleted, then remove it
  6513. // from the uninstall list!
  6514. if (1 == iUserWasDeleted)
  6515. {
  6516. g_pTheApp->UnInstallList_DelData(ParsedLine.szFileName);
  6517. }
  6518. #endif
  6519. }
  6520. }
  6521. }
  6522. // move location of directory recursive
  6523. if ( _tcsicmp(ParsedLine.szType, _T("29")) == 0)
  6524. {
  6525. if (ParsedLine.szFileName && _tcsicmp(ParsedLine.szFileName, _T("")) != 0)
  6526. {
  6527. // Check if the from directory even exist...
  6528. // see if the file exists
  6529. if (IsFileExist(ParsedLine.szFileName))
  6530. {
  6531. if (ParsedLine.szData1 && _tcsicmp(ParsedLine.szData1, _T("")) != 0)
  6532. {
  6533. if (TRUE == MoveFileEx( ParsedLine.szFileName, ParsedLine.szData1, MOVEFILE_COPY_ALLOWED|MOVEFILE_WRITE_THROUGH ))
  6534. {
  6535. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("MoveFileEx:%1!s! to %2!s!. success.\n"),ParsedLine.szFileName, ParsedLine.szData1));
  6536. }
  6537. else
  6538. {
  6539. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("MoveFileEx:%1!s! to %2!s!. failed.\n"),ParsedLine.szFileName, ParsedLine.szData1));
  6540. }
  6541. }
  6542. }
  6543. }
  6544. }
  6545. if ( _tcsicmp(ParsedLine.szType, _T("30")) == 0)
  6546. {
  6547. if (ParsedLine.szFileName && _tcsicmp(ParsedLine.szFileName, _T("")) != 0)
  6548. {
  6549. BOOL b;
  6550. BOOL bInstalled = FALSE;
  6551. CString csFile;
  6552. b = AddFontResource(ParsedLine.szFileName);
  6553. if (!b)
  6554. {
  6555. csFile = g_pTheApp->m_csWinDir + _T("\\Fonts\\");
  6556. csFile += ParsedLine.szFileName;
  6557. b = AddFontResource((LPCTSTR)csFile);
  6558. if (!b)
  6559. {
  6560. iisDebugOut((LOG_TYPE_ERROR, _T("AddFontResource:FAILED:, csFile=%s, err=0x%x,\n"), csFile, GetLastError()));
  6561. }
  6562. }
  6563. if (b)
  6564. {
  6565. SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
  6566. }
  6567. }
  6568. }
  6569. if ( _tcsicmp(ParsedLine.szType, _T("31")) == 0)
  6570. {
  6571. iTempFlag = FALSE;
  6572. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6573. if (iTempFlag == FALSE)
  6574. {
  6575. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6576. goto ProcessEntry_other_Exit;
  6577. }
  6578. iTempFlag = FALSE;
  6579. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  6580. if (iTempFlag == FALSE)
  6581. {
  6582. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6583. goto ProcessEntry_other_Exit;
  6584. }
  6585. iTempFlag = FALSE;
  6586. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  6587. if (iTempFlag == FALSE)
  6588. {
  6589. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6590. goto ProcessEntry_other_Exit;
  6591. }
  6592. AddURLShortcutItem( ParsedLine.szFileName, ParsedLine.szData1, ParsedLine.szData2);
  6593. }
  6594. if ( _tcsicmp(ParsedLine.szType, _T("32")) == 0)
  6595. {
  6596. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("MyAddItem:Type=%1!s!,%2!s!,%3!s!\n"),ParsedLine.szFileName, ParsedLine.szData1, ParsedLine.szData2));
  6597. MyAddItemInfoTip(ParsedLine.szFileName, ParsedLine.szData1, ParsedLine.szData2);
  6598. }
  6599. if ( _tcsicmp(ParsedLine.szType, _T("33")) == 0)
  6600. {
  6601. CString strUseThisFileName;
  6602. int iShowErrorsOnFail = TRUE;
  6603. if (_tcsicmp(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T("1")) == 0)
  6604. {iShowErrorsOnFail = FALSE;}
  6605. // the user can specify a filename or
  6606. // they can specify a registry location to get the filename from
  6607. // if the registry location is not there then use the filename.
  6608. // make sure we have a filename entry
  6609. iTempFlag = FALSE;
  6610. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6611. if (iTempFlag == FALSE)
  6612. {
  6613. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6614. goto ProcessEntry_other_Exit;
  6615. }
  6616. strUseThisFileName = ParsedLine.szFileName;
  6617. // if we have a valid registry entry then use that.
  6618. iTempFlag = FALSE;
  6619. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0)
  6620. {
  6621. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0)
  6622. {
  6623. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0)
  6624. {
  6625. // try to get the filename stored there.
  6626. HKEY hRootKeyType = HKEY_LOCAL_MACHINE;
  6627. // check if the registry key exists...
  6628. if ( _tcsicmp(ParsedLine.szData1, _T("HKLM")) == 0){hRootKeyType = HKEY_LOCAL_MACHINE;}
  6629. if ( _tcsicmp(ParsedLine.szData1, _T("HKCR")) == 0){hRootKeyType = HKEY_CLASSES_ROOT;}
  6630. if ( _tcsicmp(ParsedLine.szData1, _T("HKCU")) == 0){hRootKeyType = HKEY_CURRENT_USER;}
  6631. if ( _tcsicmp(ParsedLine.szData1, _T("HKU")) == 0){hRootKeyType = HKEY_USERS;}
  6632. iTempFlag = FALSE;
  6633. CRegKey regTheKey(hRootKeyType, ParsedLine.szData2,KEY_READ);
  6634. CString strReturnQueryValue;
  6635. if ((HKEY) regTheKey)
  6636. {
  6637. if (ERROR_SUCCESS == regTheKey.QueryValue(ParsedLine.szData3, strReturnQueryValue))
  6638. {
  6639. strUseThisFileName = strReturnQueryValue;
  6640. iTempFlag = TRUE;
  6641. }
  6642. }
  6643. }
  6644. }
  6645. }
  6646. // check if the the filename we want to use
  6647. // needs to get expanded "%windir%\myfile" or something.
  6648. if (-1 != strUseThisFileName.Find(_T('%')) )
  6649. {
  6650. // there is a '%' in the string
  6651. TCHAR szTempDir[_MAX_PATH];
  6652. _tcscpy(szTempDir, strUseThisFileName);
  6653. if (ExpandEnvironmentStrings( (LPCTSTR)strUseThisFileName, szTempDir, sizeof(szTempDir)/sizeof(TCHAR)))
  6654. {
  6655. strUseThisFileName = szTempDir;
  6656. }
  6657. }
  6658. if (TRUE == iTempFlag)
  6659. {
  6660. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("CreateAnEmptyFile:%1!s!. From Registry location.\n"),strUseThisFileName));
  6661. }
  6662. else
  6663. {
  6664. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("CreateAnEmptyFile:%1!s!\n"),strUseThisFileName));
  6665. }
  6666. if (TRUE != CreateAnEmptyFile(strUseThisFileName))
  6667. {
  6668. if (iShowErrorsOnFail){MyMessageBox(NULL, IDS_RUN_PROG_FAILED, strUseThisFileName, GetLastError(), MB_OK | MB_SETFOREGROUND);}
  6669. else{iisDebugOut((LOG_TYPE_TRACE, _T("CreateAnEmptyFile(%s). Failed. Err=0x%x.\n"), strUseThisFileName, GetLastError() ));}
  6670. }
  6671. }
  6672. if ( _tcsicmp(ParsedLine.szType, _T("34")) == 0)
  6673. {
  6674. CString strUseThisFileName;
  6675. TCHAR szUseThisFileName[_MAX_PATH];
  6676. iTempFlag = FALSE;
  6677. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6678. if (iTempFlag == FALSE)
  6679. {
  6680. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6681. goto ProcessEntry_other_Exit;
  6682. }
  6683. iTempFlag = FALSE;
  6684. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  6685. if (iTempFlag == FALSE)
  6686. {
  6687. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6688. goto ProcessEntry_other_Exit;
  6689. }
  6690. strUseThisFileName = ParsedLine.szFileName;
  6691. // if we have a valid registry entry then use that.
  6692. iTempFlag = FALSE;
  6693. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0)
  6694. {
  6695. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0)
  6696. {
  6697. if (_tcsicmp(ParsedLine.szData4, _T("")) != 0)
  6698. {
  6699. // try to get the filename stored there.
  6700. HKEY hRootKeyType = HKEY_LOCAL_MACHINE;
  6701. // check if the registry key exists...
  6702. if ( _tcsicmp(ParsedLine.szData2, _T("HKLM")) == 0){hRootKeyType = HKEY_LOCAL_MACHINE;}
  6703. if ( _tcsicmp(ParsedLine.szData2, _T("HKCR")) == 0){hRootKeyType = HKEY_CLASSES_ROOT;}
  6704. if ( _tcsicmp(ParsedLine.szData2, _T("HKCU")) == 0){hRootKeyType = HKEY_CURRENT_USER;}
  6705. if ( _tcsicmp(ParsedLine.szData2, _T("HKU")) == 0){hRootKeyType = HKEY_USERS;}
  6706. iTempFlag = FALSE;
  6707. CRegKey regTheKey(hRootKeyType, ParsedLine.szData3, KEY_READ);
  6708. CString strReturnQueryValue;
  6709. if ((HKEY) regTheKey)
  6710. {
  6711. if (ERROR_SUCCESS == regTheKey.QueryValue(ParsedLine.szData4, strReturnQueryValue))
  6712. {
  6713. strUseThisFileName = strReturnQueryValue;
  6714. iTempFlag = TRUE;
  6715. }
  6716. }
  6717. }
  6718. }
  6719. }
  6720. // check if the the filename we want to use
  6721. // needs to get expanded "%windir%\myfile" or something.
  6722. if (-1 != strUseThisFileName.Find(_T('%')) )
  6723. {
  6724. // there is a '%' in the string
  6725. TCHAR szTempDir[_MAX_PATH];
  6726. _tcscpy(szTempDir, strUseThisFileName);
  6727. if (ExpandEnvironmentStrings( (LPCTSTR)strUseThisFileName, szTempDir, sizeof(szTempDir)/sizeof(TCHAR)))
  6728. {
  6729. strUseThisFileName = szTempDir;
  6730. }
  6731. }
  6732. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("GrantUserAccessToFile:%1!s!,%2!s!\n"),strUseThisFileName, ParsedLine.szData1));
  6733. _tcscpy(szUseThisFileName, strUseThisFileName);
  6734. GrantUserAccessToFile(szUseThisFileName, ParsedLine.szData1);
  6735. }
  6736. if ( _tcsicmp(ParsedLine.szType, _T("35")) == 0)
  6737. {
  6738. DWORD dwID = 0;
  6739. DWORD dwAttrib = 0;
  6740. DWORD dwUserType = 0;
  6741. DWORD dwTheData = 0;
  6742. INT iOverwriteFlag = FALSE;
  6743. iTempFlag = FALSE;
  6744. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6745. if (iTempFlag == FALSE)
  6746. {
  6747. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz101_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6748. goto ProcessEntry_other_Exit;
  6749. }
  6750. iTempFlag = FALSE;
  6751. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  6752. if (iTempFlag == FALSE)
  6753. {
  6754. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6755. goto ProcessEntry_other_Exit;
  6756. }
  6757. // make sure we have a szData2 entry
  6758. iTempFlag = FALSE;
  6759. if (_tcsicmp(ParsedLine.szData2, _T("")) != 0) {iTempFlag = TRUE;}
  6760. if (iTempFlag == FALSE)
  6761. {
  6762. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz103_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6763. goto ProcessEntry_other_Exit;
  6764. }
  6765. // make sure we have a szData3 entry
  6766. iTempFlag = FALSE;
  6767. if (_tcsicmp(ParsedLine.szData3, _T("")) != 0) {iTempFlag = TRUE;}
  6768. if (iTempFlag == FALSE)
  6769. {
  6770. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz104_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6771. goto ProcessEntry_other_Exit;
  6772. }
  6773. dwID = atodw(ParsedLine.szData1);
  6774. dwAttrib = METADATA_INHERIT;
  6775. dwUserType = atodw(ParsedLine.szData2);
  6776. dwTheData = atodw(ParsedLine.szData3);
  6777. iOverwriteFlag = FALSE;
  6778. if (_tcsicmp(ParsedLine.szData4, _T("1")) == 0)
  6779. {iOverwriteFlag = TRUE;}
  6780. if (CheckifServiceExist(_T("IISADMIN")) == 0 )
  6781. {
  6782. WriteToMD_DwordEntry(ParsedLine.szFileName, dwID, dwAttrib, dwUserType, dwTheData, iOverwriteFlag);
  6783. }
  6784. }
  6785. if ( _tcsicmp(ParsedLine.szType, _T("36")) == 0)
  6786. {
  6787. // Functionality removed because no longer used
  6788. iisDebugOut((LOG_TYPE_ERROR, _T("1==36 is no longer supported") ));
  6789. }
  6790. if ( _tcsicmp(ParsedLine.szType, _T("37")) == 0)
  6791. {
  6792. iTempFlag = FALSE;
  6793. if (_tcsicmp(ParsedLine.szFileName, _T("")) != 0) {iTempFlag = TRUE;}
  6794. if (iTempFlag == TRUE)
  6795. {
  6796. int MyLogErrorType = LOG_TYPE_TRACE;
  6797. if (_tcsicmp(ParsedLine.szData1, _T("0")) == 0)
  6798. {MyLogErrorType = LOG_TYPE_ERROR;}
  6799. if (_tcsicmp(ParsedLine.szData1, _T("1")) == 0)
  6800. {MyLogErrorType = LOG_TYPE_WARN;}
  6801. if (_tcsicmp(ParsedLine.szData1, _T("2")) == 0)
  6802. {MyLogErrorType = LOG_TYPE_PROGRAM_FLOW;}
  6803. if (_tcsicmp(ParsedLine.szData1, _T("3")) == 0)
  6804. {MyLogErrorType = LOG_TYPE_TRACE;}
  6805. if (_tcsicmp(ParsedLine.szData1, _T("4")) == 0)
  6806. {MyLogErrorType = LOG_TYPE_TRACE_WIN32_API;}
  6807. iisDebugOut((MyLogErrorType, _T("%s"), ParsedLine.szFileName));
  6808. }
  6809. }
  6810. if ( _tcsicmp(ParsedLine.szType, _T("38")) == 0)
  6811. {
  6812. BOOL bOK = FALSE;
  6813. BOOL bDeleteOld = FALSE;
  6814. BOOL bOverWriteToFile = FALSE;
  6815. // make sure we have a szData1 entry
  6816. iTempFlag = FALSE;
  6817. if (_tcsicmp(ParsedLine.szData1, _T("")) != 0) {iTempFlag = TRUE;}
  6818. if (iTempFlag == FALSE)
  6819. {
  6820. iisDebugOut((LOG_TYPE_ERROR, (TCHAR *) csz102_NOT_SPECIFIED, _T(".."), csEntry, szTheSection));
  6821. goto ProcessEntry_other_Exit;
  6822. }
  6823. bDeleteOld = FALSE;
  6824. if (_tcsicmp(ParsedLine.szData2, _T("1")) == 0) {bDeleteOld = TRUE;}
  6825. bOverWriteToFile = FALSE;
  6826. if (_tcsicmp(ParsedLine.szData3, _T("1")) == 0) {bOverWriteToFile = TRUE;}
  6827. if (IsFileExist(ParsedLine.szFileName))
  6828. {
  6829. //Save file attributes so they can be restored after we are done.
  6830. DWORD dwSourceAttrib = GetFileAttributes(ParsedLine.szFileName);
  6831. //Now set the file attributes to normal to ensure file ops succeed.
  6832. SetFileAttributes(ParsedLine.szFileName, FILE_ATTRIBUTE_NORMAL);
  6833. //from=ParsedLine.szFileName
  6834. //to=ParsedLine.szData1
  6835. // check if the 'to' filename exists.
  6836. if (!IsFileExist(ParsedLine.szData1))
  6837. {
  6838. // go ahead and try to copy it over
  6839. bOK = CopyFile(ParsedLine.szFileName, ParsedLine.szData1, FALSE);
  6840. if (bOK)
  6841. {
  6842. SetFileAttributes(ParsedLine.szData1, dwSourceAttrib);
  6843. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("%1!s! copied to %2!s!.\n"), ParsedLine.szFileName, ParsedLine.szData1));
  6844. // the file was copied. let's delete it now.
  6845. if (bDeleteOld)
  6846. {
  6847. if(!DeleteFile(ParsedLine.szFileName))
  6848. {
  6849. MoveFileEx(ParsedLine.szFileName, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
  6850. }
  6851. }
  6852. else
  6853. {
  6854. // set this files attribs back to what it was
  6855. SetFileAttributes(ParsedLine.szFileName, dwSourceAttrib);
  6856. }
  6857. }
  6858. else
  6859. {
  6860. // we were unable to copy the file over!
  6861. // don't delete the old one.
  6862. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("unabled to copy %1!s! to %2!s!.\n"), ParsedLine.szFileName, ParsedLine.szData1));
  6863. }
  6864. }
  6865. else
  6866. {
  6867. // the 'to' file exists, shall we overwrite it?
  6868. if (bOverWriteToFile)
  6869. {
  6870. if(DeleteFile(ParsedLine.szData1))
  6871. {
  6872. bOK = FALSE;
  6873. bOK = CopyFile(ParsedLine.szFileName, ParsedLine.szData1, FALSE);
  6874. if (bOK)
  6875. {
  6876. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("%1!s! copied to %2!s!.\n"), ParsedLine.szFileName, ParsedLine.szData1));
  6877. // the file was copied. let's delete it now.
  6878. if (bDeleteOld)
  6879. {
  6880. if(!DeleteFile(ParsedLine.szFileName))
  6881. {
  6882. MoveFileEx(ParsedLine.szFileName, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
  6883. }
  6884. }
  6885. else
  6886. {
  6887. // set this files attribs back to what it was
  6888. SetFileAttributes(ParsedLine.szFileName, dwSourceAttrib);
  6889. }
  6890. }
  6891. else
  6892. {
  6893. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("unabled to copy %1!s! to %2!s!.\n"), ParsedLine.szFileName, ParsedLine.szData1));
  6894. }
  6895. }
  6896. else
  6897. {
  6898. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("unabled to copy %1!s! to %2!s!. file#2 cannot be deleted.\n"), ParsedLine.szFileName, ParsedLine.szData1));
  6899. }
  6900. }
  6901. else
  6902. {
  6903. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("unabled to copy %1!s! to %2!s!. file#2 already exists.\n"), ParsedLine.szFileName, ParsedLine.szData1));
  6904. }
  6905. }
  6906. }
  6907. }
  6908. // We called the function, so return true.
  6909. iReturn = TRUE;
  6910. // change back to the original dir
  6911. if (ParsedLine.szChangeDir){if (szDirBefore){SetCurrentDirectory(szDirBefore);}}
  6912. ProcessEntry_AskLast(ParsedLine, 1);
  6913. ProcessEntry_other_Exit:
  6914. if (TRUE == iProgressBarUpdated){ProgressBarTextStack_Pop();}
  6915. return iReturn;
  6916. }
  6917. int ProcessEntry_Entry(IN HINF hFile, IN LPCTSTR szTheSection, IN CString csOneParseableLine)
  6918. {
  6919. iisDebugOutSafeParams((LOG_TYPE_TRACE_WIN32_API, _T("ProcessEntry_Entry:%1!s!, %2!s!\n"),szTheSection, csOneParseableLine));
  6920. int iReturn = FALSE;
  6921. int iReturnTemp = FALSE;
  6922. int iTempFlag = FALSE;
  6923. ThingToDo ParsedLine;
  6924. _tcscpy(ParsedLine.szType, _T(""));
  6925. _tcscpy(ParsedLine.szFileName, _T(""));
  6926. _tcscpy(ParsedLine.szData1, _T(""));
  6927. _tcscpy(ParsedLine.szData2, _T(""));
  6928. _tcscpy(ParsedLine.szData3, _T(""));
  6929. _tcscpy(ParsedLine.szData4, _T(""));
  6930. _tcscpy(ParsedLine.szChangeDir, _T(""));
  6931. _tcscpy(ParsedLine.szOS, _T(""));
  6932. _tcscpy(ParsedLine.szPlatformArchitecture, _T(""));
  6933. _tcscpy(ParsedLine.szEnterprise, _T(""));
  6934. _tcscpy(ParsedLine.szErrIfFileNotFound, _T(""));
  6935. _tcscpy(ParsedLine.szMsgBoxBefore, _T(""));
  6936. _tcscpy(ParsedLine.szMsgBoxAfter, _T(""));
  6937. _tcscpy(ParsedLine.szDoNotDisplayErrIfFunctionFailed, _T(""));
  6938. _tcscpy(ParsedLine.szProgressTitle, _T(""));
  6939. // parse the line and put into another big cstring list
  6940. CStringList strListOrderImportant;
  6941. //
  6942. // Parse the long string and put into another list
  6943. //
  6944. LPTSTR lpBuffer = NULL;
  6945. lpBuffer = (LPTSTR) LocalAlloc(LPTR, (csOneParseableLine.GetLength() + 1) * sizeof(TCHAR) );
  6946. if ( !lpBuffer )
  6947. {
  6948. iisDebugOut((LOG_TYPE_ERROR, _T("ProcessEntry_Entry:Failed to allocate memory.")));
  6949. return iReturn;
  6950. }
  6951. _tcscpy(lpBuffer, csOneParseableLine);
  6952. TCHAR *token = NULL;
  6953. token = _tcstok(lpBuffer, _T("|"));
  6954. while (token != NULL)
  6955. {
  6956. strListOrderImportant.AddTail(token);
  6957. token = _tcstok(NULL, _T("|"));
  6958. }
  6959. // Loop thru the new list and set variables
  6960. int i = 0;
  6961. int iFoundMatch = FALSE;
  6962. POSITION pos = NULL;
  6963. CString csEntry;
  6964. int iEntryLen = 0;
  6965. pos = strListOrderImportant.GetHeadPosition();
  6966. while (pos)
  6967. {
  6968. iFoundMatch = FALSE;
  6969. csEntry = strListOrderImportant.GetAt(pos);
  6970. iEntryLen=(csEntry.GetLength() + 1) * sizeof(TCHAR);
  6971. // Look for "100:"
  6972. // 100=Type (1=DllFunction,2=DllFunctionInitOle, 2=Executable, 3=RunThisExe, 4=DoSection, 5=DoINFSection)
  6973. if (csEntry.Left(4) == ThingToDoNumType_100 && iFoundMatch != TRUE)
  6974. {
  6975. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  6976. if (iEntryLen <= sizeof(ParsedLine.szType)) {_tcscpy(ParsedLine.szType, csEntry);}
  6977. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_100,csEntry));}
  6978. iFoundMatch = TRUE;
  6979. }
  6980. // 101=File
  6981. if (csEntry.Left(4) == ThingToDoNumType_101 && iFoundMatch != TRUE)
  6982. {
  6983. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  6984. if (iEntryLen <= sizeof(ParsedLine.szFileName)) {_tcscpy(ParsedLine.szFileName, csEntry);}
  6985. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_101, csEntry));}
  6986. if (-1 != csEntry.Find(_T('<')) )
  6987. {
  6988. // there is a < in the string
  6989. int iWhere = 0;
  6990. CString csValue2;
  6991. csEntry.MakeUpper();
  6992. if (csEntry.Find(_T("<SYSTEMROOT>")) != (-1) )
  6993. {
  6994. // We Found the cheesy <SYSTEMROOT> deal. Now replace it with the real SYSTEMROOT
  6995. iWhere = csEntry.Find(_T("<SYSTEMROOT>"));
  6996. iWhere = iWhere + _tcslen(_T("<SYSTEMROOT>"));
  6997. csValue2 = g_pTheApp->m_csWinDir + csEntry.Right( csEntry.GetLength() - (iWhere) );
  6998. csEntry = csValue2;
  6999. if (iEntryLen <= sizeof(ParsedLine.szFileName)) {_tcscpy(ParsedLine.szFileName, csEntry);}
  7000. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("ProcessEntry_Entry:ParseError:%s.1:%1!s! -- entry to big\n"),ThingToDoNumType_101,csEntry));}
  7001. }
  7002. if (csEntry.Find(_T("<SYSTEMDRIVE>")) != (-1) )
  7003. {
  7004. // We Found the cheesy <SYSTEMDRIVE> deal. Now replace it with the real systemdrive
  7005. iWhere = csEntry.Find(_T("<SYSTEMDRIVE>"));
  7006. iWhere = iWhere + _tcslen(_T("<SYSTEMDRIVE>"));
  7007. csValue2 = g_pTheApp->m_csSysDrive + csEntry.Right( csEntry.GetLength() - (iWhere) );
  7008. csEntry = csValue2;
  7009. if (iEntryLen <= sizeof(ParsedLine.szFileName)) {_tcscpy(ParsedLine.szFileName, csEntry);}
  7010. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_101,csEntry));}
  7011. }
  7012. }
  7013. iFoundMatch = TRUE;
  7014. }
  7015. // ThingToDoNumType_102=szData1
  7016. if (csEntry.Left(4) == ThingToDoNumType_102 && iFoundMatch != TRUE)
  7017. {
  7018. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  7019. if (iEntryLen <= sizeof(ParsedLine.szData1)) {_tcscpy(ParsedLine.szData1, csEntry);}
  7020. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_102,csEntry));}
  7021. iFoundMatch = TRUE;
  7022. if (-1 != csEntry.Find(_T('<')) )
  7023. {
  7024. // there is a < in the string
  7025. int iWhere = 0;
  7026. CString csValue2;
  7027. csEntry.MakeUpper();
  7028. if (csEntry.Find(_T("<SYSTEMROOT>")) != (-1) )
  7029. {
  7030. // We Found the cheesy <SYSTEMROOT> deal. Now replace it with the real SYSTEMROOT
  7031. iWhere = csEntry.Find(_T("<SYSTEMROOT>"));
  7032. iWhere = iWhere + _tcslen(_T("<SYSTEMROOT>"));
  7033. csValue2 = g_pTheApp->m_csWinDir + csEntry.Right( csEntry.GetLength() - (iWhere) );
  7034. csEntry = csValue2;
  7035. if (iEntryLen <= sizeof(ParsedLine.szData1)) {_tcscpy(ParsedLine.szData1, csEntry);}
  7036. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("ProcessEntry_Entry:ParseError:%s.1:%1!s! -- entry to big\n"),ThingToDoNumType_102, csEntry));}
  7037. }
  7038. if (csEntry.Find(_T("<SYSTEMDRIVE>")) != (-1) )
  7039. {
  7040. // We Found the cheesy <SYSTEMDRIVE> deal. Now replace it with the real SYSTEMROOT
  7041. iWhere = csEntry.Find(_T("<SYSTEMDRIVE>"));
  7042. iWhere = iWhere + _tcslen(_T("<SYSTEMDRIVE>"));
  7043. csValue2 = g_pTheApp->m_csSysDrive + csEntry.Right( csEntry.GetLength() - (iWhere) );
  7044. csEntry = csValue2;
  7045. if (iEntryLen <= sizeof(ParsedLine.szData1)) {_tcscpy(ParsedLine.szData1, csEntry);}
  7046. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_102,csEntry));}
  7047. }
  7048. }
  7049. }
  7050. // ThingToDoNumType_103=szData2
  7051. if (csEntry.Left(4) == ThingToDoNumType_103 && iFoundMatch != TRUE)
  7052. {
  7053. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  7054. if (iEntryLen <= sizeof(ParsedLine.szData2)) {_tcscpy(ParsedLine.szData2, csEntry);}
  7055. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_103,csEntry));}
  7056. iFoundMatch = TRUE;
  7057. }
  7058. // ThingToDoNumType_104=szData3
  7059. if (csEntry.Left(4) == ThingToDoNumType_104 && iFoundMatch != TRUE)
  7060. {
  7061. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  7062. if (iEntryLen <= sizeof(ParsedLine.szData3)) {_tcscpy(ParsedLine.szData3, csEntry);}
  7063. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_104,csEntry));}
  7064. iFoundMatch = TRUE;
  7065. }
  7066. // ThingToDoNumType_105=szData4
  7067. if (csEntry.Left(4) == ThingToDoNumType_105 && iFoundMatch != TRUE)
  7068. {
  7069. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  7070. if (iEntryLen <= sizeof(ParsedLine.szData4)) {_tcscpy(ParsedLine.szData4, csEntry);}
  7071. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_105,csEntry));}
  7072. iFoundMatch = TRUE;
  7073. }
  7074. // 200=ChangeToThisDirFirst
  7075. if (csEntry.Left(4) == ThingToDoNumType_200 && iFoundMatch != TRUE)
  7076. {
  7077. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  7078. if (iEntryLen <= sizeof(ParsedLine.szChangeDir)) {_tcscpy(ParsedLine.szChangeDir, csEntry);}
  7079. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_200,csEntry));}
  7080. iFoundMatch = TRUE;
  7081. if (-1 != csEntry.Find(_T('<')) )
  7082. {
  7083. // there is a < in the string
  7084. int iWhere = 0;
  7085. CString csValue2;
  7086. csEntry.MakeUpper();
  7087. if (csEntry.Find(_T("<SYSTEMROOT>")) != (-1) )
  7088. {
  7089. // We Found the cheesy <SYSTEMROOT> deal. Now replace it with the real SYSTEMROOT
  7090. iWhere = csEntry.Find(_T("<SYSTEMROOT>"));
  7091. iWhere = iWhere + _tcslen(_T("<SYSTEMROOT>"));
  7092. csValue2 = g_pTheApp->m_csWinDir + csEntry.Right( csEntry.GetLength() - (iWhere) );
  7093. csEntry = csValue2;
  7094. if (iEntryLen <= sizeof(ParsedLine.szChangeDir)) {_tcscpy(ParsedLine.szChangeDir, csEntry);}
  7095. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("ProcessEntry_Entry:ParseError:%s.1:%1!s! -- entry to big\n"),ThingToDoNumType_200,csEntry));}
  7096. }
  7097. if (csEntry.Find(_T("<SYSTEMDRIVE>")) != (-1) )
  7098. {
  7099. // We Found the cheesy <SYSTEMDRIVE> deal. Now replace it with the real SYSTEMROOT
  7100. iWhere = csEntry.Find(_T("<SYSTEMDRIVE>"));
  7101. iWhere = iWhere + _tcslen(_T("<SYSTEMDRIVE>"));
  7102. csValue2 = g_pTheApp->m_csSysDrive + csEntry.Right( csEntry.GetLength() - (iWhere) );
  7103. csEntry = csValue2;
  7104. if (iEntryLen <= sizeof(ParsedLine.szChangeDir)) {_tcscpy(ParsedLine.szChangeDir, csEntry);}
  7105. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_200,csEntry));}
  7106. }
  7107. }
  7108. }
  7109. // 701=OS (0=ALL,1=NTS,2=NTW,4=NTDC)
  7110. if (csEntry.Left(4) == ThingToDoNumType_701 && iFoundMatch != TRUE)
  7111. {
  7112. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  7113. if (iEntryLen <= sizeof(ParsedLine.szOS)) {_tcscpy(ParsedLine.szOS, csEntry);}
  7114. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_701,csEntry));}
  7115. iFoundMatch = TRUE;
  7116. }
  7117. // 702=PlatformArchitecture (0=ALL,1=x86,2=alpha)
  7118. if (csEntry.Left(4) == ThingToDoNumType_702 && iFoundMatch != TRUE)
  7119. {
  7120. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  7121. if (iEntryLen <= sizeof(ParsedLine.szPlatformArchitecture)) {_tcscpy(ParsedLine.szPlatformArchitecture, csEntry);}
  7122. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_702,csEntry));}
  7123. iFoundMatch = TRUE;
  7124. }
  7125. // 703=Enterprise (1=yes,0=no)
  7126. if (csEntry.Left(4) == ThingToDoNumType_703 && iFoundMatch != TRUE)
  7127. {
  7128. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  7129. if (iEntryLen <= sizeof(ParsedLine.szEnterprise)) {_tcscpy(ParsedLine.szEnterprise, csEntry);}
  7130. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_703,csEntry));}
  7131. iFoundMatch = TRUE;
  7132. }
  7133. // 801=ErrIfFileNotFound (1=Show error if filenot found, 0=don't show error)
  7134. if (csEntry.Left(4) == ThingToDoNumType_801 && iFoundMatch != TRUE)
  7135. {
  7136. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  7137. if (iEntryLen <= sizeof(ParsedLine.szErrIfFileNotFound)) {_tcscpy(ParsedLine.szErrIfFileNotFound, csEntry);}
  7138. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_801,csEntry));}
  7139. iFoundMatch = TRUE;
  7140. }
  7141. // 802=Ask User if they want to call this function with msgbox (1=yes,0=no)
  7142. if (csEntry.Left(4) == ThingToDoNumType_802 && iFoundMatch != TRUE)
  7143. {
  7144. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  7145. if (iEntryLen <= sizeof(ParsedLine.szMsgBoxBefore)) {_tcscpy(ParsedLine.szMsgBoxBefore, csEntry);}
  7146. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_802,csEntry));}
  7147. iFoundMatch = TRUE;
  7148. }
  7149. // 803=notify use after calling the function (1=yes,0=no)
  7150. if (csEntry.Left(4) == ThingToDoNumType_803 && iFoundMatch != TRUE)
  7151. {
  7152. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  7153. if (iEntryLen <= sizeof(ParsedLine.szMsgBoxAfter)) {_tcscpy(ParsedLine.szMsgBoxAfter, csEntry);}
  7154. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_803,csEntry));}
  7155. iFoundMatch = TRUE;
  7156. }
  7157. // 804=szDoNotDisplayErrIfFunctionFailed (1= dont Show error , 0=show error)
  7158. if (csEntry.Left(4) == ThingToDoNumType_804 && iFoundMatch != TRUE)
  7159. {
  7160. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  7161. if (iEntryLen <= sizeof(ParsedLine.szDoNotDisplayErrIfFunctionFailed)) {_tcscpy(ParsedLine.szDoNotDisplayErrIfFunctionFailed, csEntry);}
  7162. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_804,csEntry));}
  7163. iFoundMatch = TRUE;
  7164. }
  7165. // 805=szProgressTitle
  7166. if (csEntry.Left(4) == ThingToDoNumType_805 && iFoundMatch != TRUE)
  7167. {
  7168. csEntry = csEntry.Right( csEntry.GetLength() - 4);
  7169. if (iEntryLen <= sizeof(ParsedLine.szProgressTitle)) {_tcscpy(ParsedLine.szProgressTitle, csEntry);}
  7170. else {iisDebugOutSafeParams((LOG_TYPE_ERROR, (TCHAR *) PARSE_ERROR_ENTRY_TO_BIG,ThingToDoNumType_805,csEntry));}
  7171. iFoundMatch = TRUE;
  7172. }
  7173. if (iFoundMatch != TRUE)
  7174. {
  7175. // We didn't find a match, so output the problem to the logs..
  7176. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("ProcessEntry_Entry():UnknownOption '%1!s!'. Section=%2!s!..\n"),csEntry, szTheSection));
  7177. }
  7178. // Get next value
  7179. strListOrderImportant.GetNext(pos);
  7180. i++;
  7181. }
  7182. iFoundMatch = FALSE;
  7183. /*
  7184. 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"),
  7185. ParsedLine.szType,
  7186. ParsedLine.szFileName,
  7187. ParsedLine.szData1,
  7188. ParsedLine.szOS,
  7189. ParsedLine.szPlatformArchitecture,
  7190. ParsedLine.szEnterprise
  7191. ParsedLine.szErrIfFileNotFound,
  7192. ParsedLine.szMsgBoxBefore,
  7193. ParsedLine.szMsgBoxAfter,
  7194. ParsedLine.szDoNotDisplayErrIfFunctionFailed
  7195. ));
  7196. */
  7197. if (i >= 1)
  7198. {
  7199. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("...ProcessEntry:100=%1!s!...\n"),ParsedLine.szType));
  7200. // Get the type.
  7201. //
  7202. // 100=Type (1=DllFunction,2=DllFunctionInitOle, 2=Executable, 3=RunThisExe, 4=DoSection, 5=DoINFSection)
  7203. //
  7204. if ( _tcsicmp(ParsedLine.szType, _T("1")) == 0 || _tcsicmp(ParsedLine.szType, _T("2")) == 0 )
  7205. {
  7206. // 100=1=DllFunction,2=DllFunctionInitOle
  7207. // We are doing a call to a function in a DLL.
  7208. iReturnTemp = ProcessEntry_CallDll(csEntry,szTheSection,ParsedLine);
  7209. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7210. iFoundMatch = TRUE;
  7211. }
  7212. // 100=7,8,9,10,11,12,13,14
  7213. if ( _tcsicmp(ParsedLine.szType, _T("7")) == 0 || _tcsicmp(ParsedLine.szType, _T("8")) == 0 ||
  7214. _tcsicmp(ParsedLine.szType, _T("9")) == 0 || _tcsicmp(ParsedLine.szType, _T("10")) == 0 ||
  7215. _tcsicmp(ParsedLine.szType, _T("11")) == 0 || _tcsicmp(ParsedLine.szType, _T("12")) == 0 ||
  7216. _tcsicmp(ParsedLine.szType, _T("13")) == 0 || _tcsicmp(ParsedLine.szType, _T("14")) == 0 ||
  7217. _tcsicmp(ParsedLine.szType, _T("17")) == 0 || _tcsicmp(ParsedLine.szType, _T("18")) == 0
  7218. )
  7219. {
  7220. iReturnTemp = ProcessEntry_Misc1(csEntry,szTheSection,ParsedLine);
  7221. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7222. iFoundMatch = TRUE;
  7223. }
  7224. if ( _tcsicmp(ParsedLine.szType, _T("19")) == 0 || _tcsicmp(ParsedLine.szType, _T("20")) == 0 ||
  7225. _tcsicmp(ParsedLine.szType, _T("21")) == 0 || _tcsicmp(ParsedLine.szType, _T("22")) == 0 ||
  7226. _tcsicmp(ParsedLine.szType, _T("23")) == 0 || _tcsicmp(ParsedLine.szType, _T("24")) == 0 ||
  7227. _tcsicmp(ParsedLine.szType, _T("25")) == 0 || _tcsicmp(ParsedLine.szType, _T("26")) == 0 ||
  7228. _tcsicmp(ParsedLine.szType, _T("27")) == 0 || _tcsicmp(ParsedLine.szType, _T("28")) == 0 ||
  7229. _tcsicmp(ParsedLine.szType, _T("29")) == 0 || _tcsicmp(ParsedLine.szType, _T("30")) == 0 ||
  7230. _tcsicmp(ParsedLine.szType, _T("31")) == 0 || _tcsicmp(ParsedLine.szType, _T("32")) == 0 ||
  7231. _tcsicmp(ParsedLine.szType, _T("33")) == 0 || _tcsicmp(ParsedLine.szType, _T("34")) == 0 ||
  7232. _tcsicmp(ParsedLine.szType, _T("35")) == 0 || _tcsicmp(ParsedLine.szType, _T("36")) == 0 ||
  7233. _tcsicmp(ParsedLine.szType, _T("37")) == 0 || _tcsicmp(ParsedLine.szType, _T("38")) == 0 ||
  7234. _tcsicmp(ParsedLine.szType, _T("120")) == 0
  7235. )
  7236. {
  7237. iReturnTemp = ProcessEntry_other(csEntry,szTheSection,ParsedLine);
  7238. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7239. iFoundMatch = TRUE;
  7240. }
  7241. if ( _tcsicmp(ParsedLine.szType, _T("39")) == 0 ||
  7242. _tcsicmp(ParsedLine.szType, _T("40")) == 0 || _tcsicmp(ParsedLine.szType, _T("41")) == 0 ||
  7243. _tcsicmp(ParsedLine.szType, _T("42")) == 0 || _tcsicmp(ParsedLine.szType, _T("43")) == 0 ||
  7244. _tcsicmp(ParsedLine.szType, _T("44")) == 0 || _tcsicmp(ParsedLine.szType, _T("45")) == 0 ||
  7245. _tcsicmp(ParsedLine.szType, _T("46")) == 0 || _tcsicmp(ParsedLine.szType, _T("47")) == 0 ||
  7246. _tcsicmp(ParsedLine.szType, _T("48")) == 0 || _tcsicmp(ParsedLine.szType, _T("49")) == 0 ||
  7247. _tcsicmp(ParsedLine.szType, _T("100")) == 0 || _tcsicmp(ParsedLine.szType, _T("119")) == 0
  7248. )
  7249. {
  7250. iReturnTemp = ProcessEntry_If(csEntry,szTheSection,ParsedLine);
  7251. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7252. iFoundMatch = TRUE;
  7253. }
  7254. if ( _tcsicmp(ParsedLine.szType, _T("50")) == 0 || _tcsicmp(ParsedLine.szType, _T("51")) == 0 ||
  7255. _tcsicmp(ParsedLine.szType, _T("52")) == 0 || _tcsicmp(ParsedLine.szType, _T("53")) == 0 ||
  7256. _tcsicmp(ParsedLine.szType, _T("54")) == 0 || _tcsicmp(ParsedLine.szType, _T("55")) == 0 ||
  7257. _tcsicmp(ParsedLine.szType, _T("56")) == 0 || _tcsicmp(ParsedLine.szType, _T("57")) == 0 ||
  7258. _tcsicmp(ParsedLine.szType, _T("58")) == 0 || _tcsicmp(ParsedLine.szType, _T("59")) == 0 ||
  7259. _tcsicmp(ParsedLine.szType, _T("60")) == 0 || _tcsicmp(ParsedLine.szType, _T("61")) == 0 ||
  7260. _tcsicmp(ParsedLine.szType, _T("62")) == 0 || _tcsicmp(ParsedLine.szType, _T("63")) == 0 ||
  7261. _tcsicmp(ParsedLine.szType, _T("64")) == 0 || _tcsicmp(ParsedLine.szType, _T("65")) == 0 ||
  7262. _tcsicmp(ParsedLine.szType, _T("66")) == 0 || _tcsicmp(ParsedLine.szType, _T("67")) == 0 ||
  7263. _tcsicmp(ParsedLine.szType, _T("68")) == 0 || _tcsicmp(ParsedLine.szType, _T("69")) == 0
  7264. )
  7265. {
  7266. iReturnTemp = ProcessEntry_SVC_Clus(csEntry,szTheSection,ParsedLine);
  7267. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7268. iFoundMatch = TRUE;
  7269. }
  7270. if ( _tcsicmp(ParsedLine.szType, _T("70")) == 0 || _tcsicmp(ParsedLine.szType, _T("71")) == 0 ||
  7271. _tcsicmp(ParsedLine.szType, _T("72")) == 0 || _tcsicmp(ParsedLine.szType, _T("73")) == 0 ||
  7272. _tcsicmp(ParsedLine.szType, _T("74")) == 0 || _tcsicmp(ParsedLine.szType, _T("75")) == 0 ||
  7273. _tcsicmp(ParsedLine.szType, _T("76")) == 0 || _tcsicmp(ParsedLine.szType, _T("77")) == 0
  7274. )
  7275. {
  7276. iReturnTemp = ProcessEntry_Dcom(csEntry,szTheSection,ParsedLine);
  7277. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7278. iFoundMatch = TRUE;
  7279. }
  7280. if ( _tcsicmp(ParsedLine.szType, _T("82")) == 0 || _tcsicmp(ParsedLine.szType, _T("83")) == 0 ||
  7281. _tcsicmp(ParsedLine.szType, _T("84")) == 0 || _tcsicmp(ParsedLine.szType, _T("85")) == 0
  7282. )
  7283. {
  7284. iReturnTemp = ProcessEntry_Metabase(csEntry,szTheSection,ParsedLine);
  7285. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7286. iFoundMatch = TRUE;
  7287. }
  7288. if ( _tcsicmp(ParsedLine.szType, _T("15")) == 0 || _tcsicmp(ParsedLine.szType, _T("16")) == 0 ||
  7289. _tcsicmp(ParsedLine.szType, _T("78")) == 0 || _tcsicmp(ParsedLine.szType, _T("79")) == 0 ||
  7290. _tcsicmp(ParsedLine.szType, _T("80")) == 0 || _tcsicmp(ParsedLine.szType, _T("81")) == 0 ||
  7291. _tcsicmp(ParsedLine.szType, _T("86")) == 0 || _tcsicmp(ParsedLine.szType, _T("87")) == 0 ||
  7292. _tcsicmp(ParsedLine.szType, _T("88")) == 0 || _tcsicmp(ParsedLine.szType, _T("89")) == 0 ||
  7293. _tcsicmp(ParsedLine.szType, _T("90")) == 0 || _tcsicmp(ParsedLine.szType, _T("91")) == 0 ||
  7294. _tcsicmp(ParsedLine.szType, _T("92")) == 0 || _tcsicmp(ParsedLine.szType, _T("93")) == 0 ||
  7295. _tcsicmp(ParsedLine.szType, _T("94")) == 0 || _tcsicmp(ParsedLine.szType, _T("95")) == 0 ||
  7296. _tcsicmp(ParsedLine.szType, _T("96")) == 0 || _tcsicmp(ParsedLine.szType, _T("97")) == 0 ||
  7297. _tcsicmp(ParsedLine.szType, _T("98")) == 0 || _tcsicmp(ParsedLine.szType, _T("99")) == 0
  7298. )
  7299. {
  7300. iReturnTemp = ProcessEntry_Misc2(csEntry,szTheSection,ParsedLine);
  7301. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7302. iFoundMatch = TRUE;
  7303. }
  7304. if ( _tcsicmp(ParsedLine.szType, _T("101")) == 0 || _tcsicmp(ParsedLine.szType, _T("102")) == 0 ||
  7305. _tcsicmp(ParsedLine.szType, _T("103")) == 0 || _tcsicmp(ParsedLine.szType, _T("104")) == 0 ||
  7306. _tcsicmp(ParsedLine.szType, _T("105")) == 0 || _tcsicmp(ParsedLine.szType, _T("106")) == 0 ||
  7307. _tcsicmp(ParsedLine.szType, _T("107")) == 0 || _tcsicmp(ParsedLine.szType, _T("108")) == 0 ||
  7308. _tcsicmp(ParsedLine.szType, _T("109")) == 0 || _tcsicmp(ParsedLine.szType, _T("110")) == 0 ||
  7309. _tcsicmp(ParsedLine.szType, _T("111")) == 0 || _tcsicmp(ParsedLine.szType, _T("112")) == 0 ||
  7310. _tcsicmp(ParsedLine.szType, _T("113")) == 0 || _tcsicmp(ParsedLine.szType, _T("114")) == 0 ||
  7311. _tcsicmp(ParsedLine.szType, _T("115")) == 0 || _tcsicmp(ParsedLine.szType, _T("116")) == 0 ||
  7312. _tcsicmp(ParsedLine.szType, _T("117")) == 0 || _tcsicmp(ParsedLine.szType, _T("118")) == 0
  7313. )
  7314. {
  7315. iReturnTemp = ProcessEntry_Misc3(csEntry,szTheSection,ParsedLine);
  7316. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7317. iFoundMatch = TRUE;
  7318. }
  7319. //
  7320. // 100= 3=Executable
  7321. //
  7322. if ( _tcsicmp(ParsedLine.szType, _T("3")) == 0)
  7323. {
  7324. iReturnTemp = ProcessEntry_Call_Exe(csEntry,szTheSection,ParsedLine);
  7325. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7326. iFoundMatch = TRUE;
  7327. }
  7328. //
  7329. // 100= 4=Call InternalSectionInIISDll
  7330. //
  7331. if ( _tcsicmp(ParsedLine.szType, _T("4")) == 0)
  7332. {
  7333. iReturnTemp = ProcessEntry_Internal_iisdll(csEntry,szTheSection,ParsedLine);
  7334. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7335. iFoundMatch = TRUE;
  7336. }
  7337. //
  7338. // 100= 0=DoINFSection queue file ops special
  7339. // 100= 5=DoSection
  7340. // 100= 6=DoINFSection
  7341. //
  7342. if ( _tcsicmp(ParsedLine.szType, _T("0")) == 0 || _tcsicmp(ParsedLine.szType, _T("5")) == 0 || _tcsicmp(ParsedLine.szType, _T("6")) == 0 )
  7343. {
  7344. iReturnTemp = ProcessEntry_Call_Section(csEntry,szTheSection,ParsedLine);
  7345. if (iReturnTemp == FALSE) (iReturn = FALSE);
  7346. iFoundMatch = TRUE;
  7347. }
  7348. if (TRUE != iFoundMatch)
  7349. {
  7350. iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("ProcessEntry_Entry:ExecuteThing:Unknown Type:%1!s! FAILURE.\n"),ParsedLine.szType));
  7351. }
  7352. }
  7353. if (lpBuffer) {LocalFree(lpBuffer);lpBuffer=NULL;}
  7354. return iReturn;
  7355. }
  7356. int DoesThisSectionExist(IN HINF hFile, IN LPCTSTR szTheSection)
  7357. {
  7358. int iReturn = FALSE;
  7359. INFCONTEXT Context;
  7360. // go to the beginning of the section in the INF file
  7361. if (SetupFindFirstLine_Wrapped(hFile, szTheSection, NULL, &Context))
  7362. {iReturn = TRUE;}
  7363. return iReturn;
  7364. }
  7365. // DoesTheInstallDrivePreserveAcls
  7366. //
  7367. // Does the drive that we are installing to preserve the ACL's
  7368. // that we set on stuff (ie. Is it NTFS)
  7369. //
  7370. // Parameters:
  7371. // pbPreservesAcls [out] - Are ACL's preserved or not
  7372. //
  7373. // Return Values
  7374. // TRUE - Successfully did query
  7375. // FALSE - Failed to do query
  7376. BOOL
  7377. DoesTheInstallDrivePreserveAcls( LPBOOL pbPreservesAcls )
  7378. {
  7379. DWORD dwSystemFlags;
  7380. TSTR_PATH strDrivePath;
  7381. static BOOL bAlreadyDidCheck = FALSE;
  7382. static BOOL bPreservesAcls = FALSE;
  7383. if ( !bAlreadyDidCheck )
  7384. {
  7385. // Create Drive path with trailing '\'
  7386. if ( !strDrivePath.Copy( g_pTheApp->m_csSysDrive ) ||
  7387. !strDrivePath.PathAppend( _T("") ) )
  7388. {
  7389. // Failed to create drive path
  7390. return FALSE;
  7391. }
  7392. if ( !GetVolumeInformation( strDrivePath.QueryStr(),
  7393. NULL, // Volume Name Buffer
  7394. 0, // Size of Buffer
  7395. NULL, // Serial Number Buffer
  7396. NULL, // Max Component Lenght
  7397. &dwSystemFlags, // System Flags
  7398. NULL, // FS Type
  7399. 0 ) )
  7400. {
  7401. // Failed to do query
  7402. return FALSE;
  7403. }
  7404. bPreservesAcls = ( dwSystemFlags & FS_PERSISTENT_ACLS ) != 0;
  7405. bAlreadyDidCheck = TRUE;
  7406. }
  7407. // Do not do query more than one, so remember that we did it
  7408. *pbPreservesAcls = bPreservesAcls;
  7409. return TRUE;
  7410. }
  7411. int GetSectionNameToDo(IN HINF hFile, TSTR *pstrSectionName )
  7412. {
  7413. iisDebugOut_Start1(_T("GetSectionNameToDo"), pstrSectionName->QueryStr() );
  7414. int iReturn = FALSE;
  7415. // Check if this section has other sections which have something else appended to it.
  7416. //
  7417. // for example:
  7418. // csTheSection = iis_www_reg_CreateIISPackage
  7419. //
  7420. // could have:
  7421. // iis_www_reg_CreateIISPackage.UT_NONE
  7422. // iis_www_reg_CreateIISPackage.UT_351
  7423. // iis_www_reg_CreateIISPackage.UT_10
  7424. // iis_www_reg_CreateIISPackage.UT_20
  7425. // iis_www_reg_CreateIISPackage.UT_30
  7426. // iis_www_reg_CreateIISPackage.UT_40
  7427. // iis_www_reg_CreateIISPackage.UT_50
  7428. // iis_www_reg_CreateIISPackage.UT_51
  7429. // iis_www_reg_CreateIISPackage.UT_60
  7430. // iis_www_reg_CreateIISPackage.UT_10_W95.GUIMODE
  7431. //
  7432. // In That case, we only want to do the iis_www_reg_CreateIISPackage.UT_40
  7433. // and not do the iis_www_reg_CreateIISPackage one!
  7434. //
  7435. // Check for other upgrade specific sections...
  7436. // if we find one then do that, otherwise, just do the regular section...
  7437. TCHAR szTheSectionToDo[100];
  7438. TCHAR szTheUT[30];
  7439. _tcscpy(szTheUT,_T("UT_NONE"));
  7440. if (g_pTheApp->m_eUpgradeType == UT_351){_tcscpy(szTheUT,_T("UT_351"));}
  7441. if (g_pTheApp->m_eUpgradeType == UT_10){_tcscpy(szTheUT,_T("UT_10"));}
  7442. if (g_pTheApp->m_eUpgradeType == UT_20){_tcscpy(szTheUT,_T("UT_20"));}
  7443. if (g_pTheApp->m_eUpgradeType == UT_30){_tcscpy(szTheUT,_T("UT_30"));}
  7444. if (g_pTheApp->m_eUpgradeType == UT_40){_tcscpy(szTheUT,_T("UT_40"));}
  7445. if (g_pTheApp->m_eUpgradeType == UT_50){_tcscpy(szTheUT,_T("UT_50"));}
  7446. if (g_pTheApp->m_eUpgradeType == UT_51){_tcscpy(szTheUT,_T("UT_51"));}
  7447. if (g_pTheApp->m_eUpgradeType == UT_60){_tcscpy(szTheUT,_T("UT_60"));}
  7448. if (g_pTheApp->m_eUpgradeType == UT_10_W95){_tcscpy(szTheUT,_T("UT_10_W95"));}
  7449. BOOL bSectionFound = FALSE;
  7450. // If this is an upgrade from win95 then tack that one on...
  7451. if (g_pTheApp->m_bWin95Migration)
  7452. {
  7453. // Check for guimode of this...
  7454. if (g_pTheApp->m_fNTGuiMode)
  7455. {
  7456. _stprintf(szTheSectionToDo,TEXT("%s.%s.MIG95.GUIMODE"), pstrSectionName->QueryStr(),szTheUT);
  7457. if (TRUE == DoesThisSectionExist(hFile, szTheSectionToDo)) {bSectionFound = TRUE;}
  7458. }
  7459. if (bSectionFound == FALSE)
  7460. {
  7461. _stprintf(szTheSectionToDo,TEXT("%s.%s.MIG95"), pstrSectionName->QueryStr(),szTheUT);
  7462. if (TRUE == DoesThisSectionExist(hFile, szTheSectionToDo)) {bSectionFound = TRUE;}
  7463. }
  7464. }
  7465. // check with out the extract mig95 thingy
  7466. if (bSectionFound == FALSE)
  7467. {
  7468. if (g_pTheApp->m_fNTGuiMode)
  7469. {
  7470. _stprintf(szTheSectionToDo,TEXT("%s.%s.GUIMODE"), pstrSectionName->QueryStr(),szTheUT);
  7471. if (TRUE == DoesThisSectionExist(hFile, szTheSectionToDo)) {bSectionFound = TRUE;}
  7472. }
  7473. if (bSectionFound == FALSE)
  7474. {
  7475. _stprintf(szTheSectionToDo,TEXT("%s.%s"), pstrSectionName->QueryStr(),szTheUT);
  7476. if (TRUE == DoesThisSectionExist(hFile, szTheSectionToDo)) {bSectionFound = TRUE;}
  7477. }
  7478. }
  7479. // if we didn't find a specific section, then see if this is an upgrade
  7480. // and if there is upgrade type box.
  7481. if (bSectionFound == FALSE)
  7482. {
  7483. if (_tcsicmp(szTheUT, _T("UT_NONE")) != 0)
  7484. {
  7485. if (TRUE == g_pTheApp->m_bUpgradeTypeHasMetabaseFlag)
  7486. {
  7487. if (g_pTheApp->m_fNTGuiMode)
  7488. {
  7489. _stprintf(szTheSectionToDo,TEXT("%s.UT_ANYMETABASEUPGRADE.GUIMODE"), pstrSectionName->QueryStr());
  7490. if (TRUE == DoesThisSectionExist(hFile, szTheSectionToDo)) {bSectionFound = TRUE;}
  7491. }
  7492. if (bSectionFound == FALSE)
  7493. {
  7494. _stprintf(szTheSectionToDo,TEXT("%s.UT_ANYMETABASEUPGRADE"), pstrSectionName->QueryStr());
  7495. if (TRUE == DoesThisSectionExist(hFile, szTheSectionToDo)) {bSectionFound = TRUE;}
  7496. }
  7497. }
  7498. if (bSectionFound == FALSE)
  7499. {
  7500. if (g_pTheApp->m_fNTGuiMode)
  7501. {
  7502. _stprintf(szTheSectionToDo,TEXT("%s.UT_ANYUPGRADE.GUIMODE"), pstrSectionName->QueryStr());
  7503. if (TRUE == DoesThisSectionExist(hFile, szTheSectionToDo)) {bSectionFound = TRUE;}
  7504. }
  7505. if (bSectionFound == FALSE)
  7506. {
  7507. _stprintf(szTheSectionToDo,TEXT("%s.UT_ANYUPGRADE"), pstrSectionName->QueryStr());
  7508. if (TRUE == DoesThisSectionExist(hFile, szTheSectionToDo)) {bSectionFound = TRUE;}
  7509. }
  7510. }
  7511. }
  7512. }
  7513. // if we didn't find a specific section, then turn the regular one.
  7514. if (bSectionFound == FALSE)
  7515. {
  7516. if (g_pTheApp->m_fNTGuiMode)
  7517. {
  7518. _stprintf(szTheSectionToDo,TEXT("%s.GUIMODE"), pstrSectionName->QueryStr());
  7519. if (TRUE == DoesThisSectionExist(hFile, szTheSectionToDo)) {bSectionFound = TRUE;}
  7520. }
  7521. if (bSectionFound == FALSE)
  7522. {
  7523. _tcscpy(szTheSectionToDo, pstrSectionName->QueryStr());
  7524. if (TRUE == DoesThisSectionExist(hFile, szTheSectionToDo)) {bSectionFound = TRUE;}
  7525. }
  7526. }
  7527. if (bSectionFound == FALSE)
  7528. {
  7529. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("GetSectionNameToDo.[%s].Section not found.\n"), pstrSectionName->QueryStr()));
  7530. iReturn = FALSE;
  7531. }
  7532. else
  7533. {
  7534. iReturn = pstrSectionName->Copy( szTheSectionToDo );
  7535. }
  7536. iisDebugOut_End1(_T("GetSectionNameToDo"), pstrSectionName->QueryStr());
  7537. return iReturn;
  7538. }
  7539. int ProcessSection(IN HINF hFile, IN LPCTSTR szTheSection)
  7540. {
  7541. int iReturn = FALSE;
  7542. CStringList strList;
  7543. CParse ParseLine;
  7544. TSTR strTheSection;
  7545. if ( !strTheSection.Copy( szTheSection ) )
  7546. {
  7547. return FALSE;
  7548. }
  7549. if (GetSectionNameToDo(hFile, &strTheSection ))
  7550. {
  7551. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("ProcessSection.[%s].Start.\n"), strTheSection.QueryStr() ));
  7552. if (ERROR_SUCCESS == FillStrListWithListOfSections(hFile, strList, strTheSection.QueryStr() ))
  7553. {
  7554. // loop thru the list returned back
  7555. if (strList.IsEmpty() == FALSE)
  7556. {
  7557. POSITION pos = NULL;
  7558. CString csEntry;
  7559. pos = strList.GetHeadPosition();
  7560. while (pos)
  7561. {
  7562. csEntry = strList.GetAt(pos);
  7563. if ( ( csEntry.GetAt(0) >= _T('0') ) && ( csEntry.GetAt(0) <= _T('9') ) )
  7564. {
  7565. iReturn = ProcessEntry_Entry(hFile, strTheSection.QueryStr() , csEntry);
  7566. }
  7567. else
  7568. {
  7569. ParseLine.ParseLine(&(g_pTheApp->FuncDict),csEntry.GetBuffer(0) );
  7570. }
  7571. strList.GetNext(pos);
  7572. }
  7573. }
  7574. }
  7575. iisDebugOut_End1(_T("ProcessSection"),strTheSection.QueryStr());
  7576. iReturn = TRUE;
  7577. }
  7578. return iReturn;
  7579. }
  7580. int iOleInitialize(void)
  7581. {
  7582. int iBalanceOLE = FALSE;
  7583. HRESULT hInitRes = NULL;
  7584. iisDebugOut_Start((_T("ole32:OleInitialize")));
  7585. hInitRes = OleInitialize(NULL);
  7586. iisDebugOut_End((_T("ole32:OleInitialize")));
  7587. if ( SUCCEEDED(hInitRes) || hInitRes == RPC_E_CHANGED_MODE )
  7588. {
  7589. if ( SUCCEEDED(hInitRes))
  7590. {
  7591. iisDebugOut((LOG_TYPE_TRACE, _T("iOleInitialize: Succeeded: %x. MakeSure to call OleUninitialize.\n"), hInitRes));
  7592. iBalanceOLE = TRUE;
  7593. }
  7594. else
  7595. {
  7596. iisDebugOut((LOG_TYPE_ERROR, _T("iOleInitialize: Failed 0x%x. RPC_E_CHANGED_MODE\n"), hInitRes));
  7597. }
  7598. }
  7599. else
  7600. {iisDebugOut((LOG_TYPE_ERROR, _T("iOleInitialize: Failed 0x%x.\n"), hInitRes));}
  7601. return iBalanceOLE;
  7602. }
  7603. void iOleUnInitialize(int iBalanceOLE)
  7604. {
  7605. // ----------------------------------------------
  7606. //
  7607. // uninit ole if we need to
  7608. //
  7609. // ----------------------------------------------
  7610. if (iBalanceOLE)
  7611. {
  7612. iisDebugOut_Start(_T("ole32:OleInitialize"),LOG_TYPE_TRACE_WIN32_API);
  7613. OleUninitialize();
  7614. iisDebugOut_End(_T("ole32:OleInitialize"),LOG_TYPE_TRACE_WIN32_API);
  7615. }
  7616. return;
  7617. }
  7618. BOOL SetupSetDirectoryId_Wrapper(HINF InfHandle,DWORD Id,LPCTSTR Directory)
  7619. {
  7620. TCHAR szTempDir[_MAX_PATH];
  7621. BOOL bTempFlag;
  7622. // default it with something
  7623. _tcscpy(szTempDir,Directory);
  7624. if (_tcscmp(szTempDir, _T("")) != 0)
  7625. {
  7626. // Check if the passed in parameter looks like this:
  7627. // %systemroot%\system32\inetsrv or something like that...
  7628. LPTSTR pch = NULL;
  7629. pch = _tcschr( (LPTSTR) Directory, _T('%'));
  7630. if (pch)
  7631. {
  7632. if (!ExpandEnvironmentStrings( (LPCTSTR)Directory, szTempDir, sizeof(szTempDir)/sizeof(TCHAR)))
  7633. {_tcscpy(szTempDir,Directory);}
  7634. }
  7635. // Check to see if the old Drive still exists -- it may not because
  7636. // the user could have added/removed a drive so now c:\winnt is really d:\winnt
  7637. if (!IsFileExist(Directory))
  7638. {
  7639. TCHAR szDrive_only[_MAX_DRIVE];
  7640. TCHAR szPath_only[_MAX_PATH];
  7641. _tsplitpath( Directory, szDrive_only, szPath_only, NULL, NULL);
  7642. // See if that drive exists...
  7643. if (!IsFileExist(szDrive_only))
  7644. {
  7645. // the drive doesn't exist.
  7646. // so replace it with the system drive.
  7647. GetSystemDirectory(szTempDir, _MAX_PATH);
  7648. // Get the DriveOnly
  7649. _tsplitpath(szTempDir, szDrive_only, NULL, NULL, NULL);
  7650. // Assemble the full path with the new drive
  7651. _tcscpy(szTempDir, szDrive_only);
  7652. _tcscat(szTempDir, szPath_only);
  7653. // do some extra debug output so we can see what happend.
  7654. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("%1!s! Not exist. Instead use %2!s!\n"), Directory, szTempDir));
  7655. }
  7656. }
  7657. }
  7658. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("%1!d!=%2!s!\n"), Id, szTempDir));
  7659. bTempFlag = SetupSetDirectoryId(InfHandle,Id,szTempDir);
  7660. // check for the alternate .inf file
  7661. if (g_pTheApp->m_hInfHandleAlternate && InfHandle != g_pTheApp->m_hInfHandleAlternate)
  7662. {
  7663. bTempFlag = SetupSetDirectoryId(g_pTheApp->m_hInfHandleAlternate,Id,szTempDir);
  7664. }
  7665. return bTempFlag;
  7666. }
  7667. BOOL SetupSetStringId_Wrapper(HINF InfHandle,DWORD Id,LPCTSTR TheString)
  7668. {
  7669. BOOL bTempFlag;
  7670. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("%1!d!=%2!s!\n"), Id, TheString));
  7671. bTempFlag = SetupSetDirectoryIdEx(InfHandle,Id,TheString,SETDIRID_NOT_FULL_PATH,0,0);
  7672. // check for the alternate .inf file
  7673. if (g_pTheApp->m_hInfHandleAlternate && InfHandle != g_pTheApp->m_hInfHandleAlternate)
  7674. {
  7675. bTempFlag = SetupSetDirectoryIdEx(g_pTheApp->m_hInfHandleAlternate,Id,TheString,SETDIRID_NOT_FULL_PATH,0,0);
  7676. }
  7677. return bTempFlag;
  7678. }
  7679. //-------------------------------------------------------------------------------------
  7680. HRESULT FTestForOutstandingCoInits(void)
  7681. {
  7682. HRESULT hInitRes = ERROR_SUCCESS;
  7683. #if defined(UNICODE) || defined(_UNICODE)
  7684. // perform a defensive check
  7685. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("TestForOutstandingCoInits:...COINIT_MULTITHREADED\n")));
  7686. hInitRes = CoInitializeEx( NULL, COINIT_MULTITHREADED );
  7687. if ( SUCCEEDED(hInitRes) )
  7688. {
  7689. //iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ole32:CoUninitialize().Start.")));
  7690. CoUninitialize();
  7691. //iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ole32:CoUninitialize().End.")));
  7692. }
  7693. else
  7694. {
  7695. goto FTestForOutstandingCoInits_Exit;
  7696. }
  7697. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("TestForOutstandingCoInits:...COINIT_APARTMENTTHREADED\n")));
  7698. hInitRes = CoInitializeEx( NULL, COINIT_APARTMENTTHREADED );
  7699. if ( SUCCEEDED(hInitRes) )
  7700. {
  7701. //iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ole32:CoUninitialize().Start.")));
  7702. CoUninitialize();
  7703. //iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("ole32:CoUninitialize().End.")));
  7704. }
  7705. else
  7706. {
  7707. goto FTestForOutstandingCoInits_Exit;
  7708. }
  7709. #endif
  7710. // it worked out OK
  7711. hInitRes = NOERROR;
  7712. goto FTestForOutstandingCoInits_Exit;
  7713. FTestForOutstandingCoInits_Exit:
  7714. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("TestForOutstandingCoInits:...End. Return=0x%x.\n"), hInitRes));
  7715. return hInitRes;
  7716. }
  7717. void ReturnStringForMetabaseID(DWORD dwMetabaseID, LPTSTR lpReturnString)
  7718. {
  7719. switch (dwMetabaseID)
  7720. {
  7721. case IIS_MD_SERVER_BASE:
  7722. _tcscpy(lpReturnString, _T("IIS_MD_SERVER_BASE"));
  7723. break;
  7724. case MD_KEY_TYPE:
  7725. _tcscpy(lpReturnString, _T("MD_KEY_TYPE"));
  7726. break;
  7727. case MD_MAX_BANDWIDTH_BLOCKED:
  7728. _tcscpy(lpReturnString, _T("MD_MAX_BANDWIDTH_BLOCKED"));
  7729. break;
  7730. case MD_SERVER_COMMAND:
  7731. _tcscpy(lpReturnString, _T("MD_SERVER_COMMAND"));
  7732. break;
  7733. case MD_CONNECTION_TIMEOUT:
  7734. _tcscpy(lpReturnString, _T("MD_CONNECTION_TIMEOUT"));
  7735. break;
  7736. case MD_MAX_CONNECTIONS:
  7737. _tcscpy(lpReturnString, _T("MD_MAX_CONNECTIONS"));
  7738. break;
  7739. case MD_SERVER_COMMENT:
  7740. _tcscpy(lpReturnString, _T("MD_SERVER_COMMENT"));
  7741. break;
  7742. case MD_SERVER_STATE:
  7743. _tcscpy(lpReturnString, _T("MD_SERVER_STATE"));
  7744. break;
  7745. case MD_SERVER_AUTOSTART:
  7746. _tcscpy(lpReturnString, _T("MD_SERVER_AUTOSTART"));
  7747. break;
  7748. case MD_SERVER_SIZE:
  7749. _tcscpy(lpReturnString, _T("MD_SERVER_SIZE"));
  7750. break;
  7751. case MD_SERVER_LISTEN_BACKLOG:
  7752. _tcscpy(lpReturnString, _T("MD_SERVER_LISTEN_BACKLOG"));
  7753. break;
  7754. case MD_SERVER_LISTEN_TIMEOUT:
  7755. _tcscpy(lpReturnString, _T("MD_SERVER_LISTEN_TIMEOUT"));
  7756. break;
  7757. case MD_DOWNLEVEL_ADMIN_INSTANCE:
  7758. _tcscpy(lpReturnString, _T("MD_DOWNLEVEL_ADMIN_INSTANCE"));
  7759. break;
  7760. case MD_LEVELS_TO_SCAN:
  7761. _tcscpy(lpReturnString, _T("MD_LEVELS_TO_SCAN"));
  7762. break;
  7763. case MD_SERVER_BINDINGS:
  7764. _tcscpy(lpReturnString, _T("MD_SERVER_BINDINGS"));
  7765. break;
  7766. case MD_MAX_ENDPOINT_CONNECTIONS:
  7767. _tcscpy(lpReturnString, _T("MD_MAX_ENDPOINT_CONNECTIONS"));
  7768. break;
  7769. case MD_SERVER_CONFIGURATION_INFO:
  7770. _tcscpy(lpReturnString, _T("MD_SERVER_CONFIGURATION_INFO"));
  7771. break;
  7772. case MD_IISADMIN_EXTENSIONS:
  7773. _tcscpy(lpReturnString, _T("MD_IISADMIN_EXTENSIONS"));
  7774. break;
  7775. case IIS_MD_HTTP_BASE:
  7776. _tcscpy(lpReturnString, _T("IIS_MD_HTTP_BASE"));
  7777. break;
  7778. case MD_SECURE_BINDINGS:
  7779. _tcscpy(lpReturnString, _T("MD_SECURE_BINDINGS"));
  7780. break;
  7781. case MD_FILTER_LOAD_ORDER:
  7782. _tcscpy(lpReturnString, _T("MD_FILTER_LOAD_ORDER"));
  7783. break;
  7784. case MD_FILTER_IMAGE_PATH:
  7785. _tcscpy(lpReturnString, _T("MD_FILTER_IMAGE_PATH"));
  7786. break;
  7787. case MD_FILTER_STATE:
  7788. _tcscpy(lpReturnString, _T("MD_FILTER_STATE"));
  7789. break;
  7790. case MD_FILTER_ENABLED:
  7791. _tcscpy(lpReturnString, _T("MD_FILTER_ENABLED"));
  7792. break;
  7793. case MD_FILTER_FLAGS:
  7794. _tcscpy(lpReturnString, _T("MD_FILTER_FLAGS"));
  7795. break;
  7796. case MD_FILTER_DESCRIPTION:
  7797. _tcscpy(lpReturnString, _T("MD_FILTER_DESCRIPTION"));
  7798. break;
  7799. case MD_ADV_NOTIFY_PWD_EXP_IN_DAYS:
  7800. _tcscpy(lpReturnString, _T("MD_ADV_NOTIFY_PWD_EXP_IN_DAYS"));
  7801. break;
  7802. case MD_ADV_CACHE_TTL:
  7803. _tcscpy(lpReturnString, _T("MD_ADV_CACHE_TTL"));
  7804. break;
  7805. case MD_AUTH_CHANGE_FLAGS:
  7806. _tcscpy(lpReturnString, _T("MD_AUTH_CHANGE_FLAGS"));
  7807. break;
  7808. case MD_PROCESS_NTCR_IF_LOGGED_ON:
  7809. _tcscpy(lpReturnString, _T("MD_PROCESS_NTCR_IF_LOGGED_ON"));
  7810. break;
  7811. case MD_FRONTPAGE_WEB:
  7812. _tcscpy(lpReturnString, _T("MD_FRONTPAGE_WEB"));
  7813. break;
  7814. case MD_IN_PROCESS_ISAPI_APPS:
  7815. _tcscpy(lpReturnString, _T("MD_IN_PROCESS_ISAPI_APPS"));
  7816. break;
  7817. case MD_ALLOW_PATH_INFO_FOR_SCRIPT_MAPPINGS:
  7818. _tcscpy(lpReturnString, _T("MD_ALLOW_PATH_INFO_FOR_SCRIPT_MAPPINGS"));
  7819. break;
  7820. case MD_APP_FRIENDLY_NAME:
  7821. _tcscpy(lpReturnString, _T("MD_APP_FRIENDLY_NAME"));
  7822. break;
  7823. case MD_APP_ROOT:
  7824. _tcscpy(lpReturnString, _T("MD_APP_ROOT"));
  7825. break;
  7826. case MD_APP_ISOLATED:
  7827. _tcscpy(lpReturnString, _T("MD_APP_ISOLATED"));
  7828. break;
  7829. case MD_APP_WAM_CLSID:
  7830. _tcscpy(lpReturnString, _T("MD_APP_WAM_CLSID"));
  7831. break;
  7832. case MD_APP_PACKAGE_ID:
  7833. _tcscpy(lpReturnString, _T("MD_APP_PACKAGE_ID"));
  7834. break;
  7835. case MD_APP_PACKAGE_NAME:
  7836. _tcscpy(lpReturnString, _T("MD_APP_PACKAGE_NAME"));
  7837. break;
  7838. case MD_APP_OOP_RECOVER_LIMIT:
  7839. _tcscpy(lpReturnString, _T("MD_APP_OOP_RECOVER_LIMIT"));
  7840. break;
  7841. case MD_ADMIN_INSTANCE:
  7842. _tcscpy(lpReturnString, _T("MD_ADMIN_INSTANCE"));
  7843. break;
  7844. case MD_CUSTOM_ERROR_DESC:
  7845. _tcscpy(lpReturnString, _T("MD_CUSTOM_ERROR_DESC"));
  7846. break;
  7847. case MD_CPU_RESET_INTERVAL:
  7848. _tcscpy(lpReturnString, _T("MD_CPU_RESET_INTERVAL"));
  7849. break;
  7850. case MD_MD_SERVER_SS_AUTH_MAPPING:
  7851. _tcscpy(lpReturnString, _T("MD_MD_SERVER_SS_AUTH_MAPPING"));
  7852. break;
  7853. case MD_HC_COMPRESSION_DIRECTORY:
  7854. _tcscpy(lpReturnString, _T("MD_HC_COMPRESSION_DIRECTORY"));
  7855. break;
  7856. case MD_HC_CACHE_CONTROL_HEADER:
  7857. _tcscpy(lpReturnString, _T("MD_HC_CACHE_CONTROL_HEADER"));
  7858. break;
  7859. case MD_HC_EXPIRES_HEADER:
  7860. _tcscpy(lpReturnString, _T("MD_HC_EXPIRES_HEADER"));
  7861. break;
  7862. case MD_HC_DO_DYNAMIC_COMPRESSION:
  7863. _tcscpy(lpReturnString, _T("MD_HC_DO_DYNAMIC_COMPRESSION"));
  7864. break;
  7865. case MD_HC_DO_STATIC_COMPRESSION:
  7866. _tcscpy(lpReturnString, _T("MD_HC_DO_STATIC_COMPRESSION"));
  7867. break;
  7868. case MD_HC_DO_ON_DEMAND_COMPRESSION:
  7869. _tcscpy(lpReturnString, _T("MD_HC_DO_ON_DEMAND_COMPRESSION"));
  7870. break;
  7871. case MD_HC_DO_DISK_SPACE_LIMITING:
  7872. _tcscpy(lpReturnString, _T("MD_HC_DO_DISK_SPACE_LIMITING"));
  7873. break;
  7874. case MD_HC_NO_COMPRESSION_FOR_HTTP_10:
  7875. _tcscpy(lpReturnString, _T("MD_HC_NO_COMPRESSION_FOR_HTTP_10"));
  7876. break;
  7877. case MD_HC_NO_COMPRESSION_FOR_PROXIES:
  7878. _tcscpy(lpReturnString, _T("MD_HC_NO_COMPRESSION_FOR_PROXIES"));
  7879. break;
  7880. case MD_HC_NO_COMPRESSION_FOR_RANGE:
  7881. _tcscpy(lpReturnString, _T("MD_HC_NO_COMPRESSION_FOR_RANGE"));
  7882. break;
  7883. case MD_HC_SEND_CACHE_HEADERS:
  7884. _tcscpy(lpReturnString, _T("MD_HC_SEND_CACHE_HEADERS"));
  7885. break;
  7886. case MD_HC_MAX_DISK_SPACE_USAGE:
  7887. _tcscpy(lpReturnString, _T("MD_HC_MAX_DISK_SPACE_USAGE"));
  7888. break;
  7889. case MD_HC_IO_BUFFER_SIZE:
  7890. _tcscpy(lpReturnString, _T("MD_HC_IO_BUFFER_SIZE"));
  7891. break;
  7892. case MD_HC_COMPRESSION_BUFFER_SIZE:
  7893. _tcscpy(lpReturnString, _T("MD_HC_COMPRESSION_BUFFER_SIZE"));
  7894. break;
  7895. case MD_HC_MAX_QUEUE_LENGTH:
  7896. _tcscpy(lpReturnString, _T("MD_HC_MAX_QUEUE_LENGTH"));
  7897. break;
  7898. case MD_HC_FILES_DELETED_PER_DISK_FREE:
  7899. _tcscpy(lpReturnString, _T("MD_HC_FILES_DELETED_PER_DISK_FREE"));
  7900. break;
  7901. case MD_HC_MIN_FILE_SIZE_FOR_COMP:
  7902. _tcscpy(lpReturnString, _T("MD_HC_MIN_FILE_SIZE_FOR_COMP"));
  7903. break;
  7904. case MD_HC_COMPRESSION_DLL:
  7905. _tcscpy(lpReturnString, _T("MD_HC_COMPRESSION_DLL"));
  7906. break;
  7907. case MD_HC_FILE_EXTENSIONS:
  7908. _tcscpy(lpReturnString, _T("MD_HC_FILE_EXTENSIONS"));
  7909. break;
  7910. case MD_HC_PRIORITY:
  7911. _tcscpy(lpReturnString, _T("MD_HC_PRIORITY"));
  7912. break;
  7913. case MD_HC_DYNAMIC_COMPRESSION_LEVEL:
  7914. _tcscpy(lpReturnString, _T("MD_HC_DYNAMIC_COMPRESSION_LEVEL"));
  7915. break;
  7916. case MD_HC_ON_DEMAND_COMP_LEVEL:
  7917. _tcscpy(lpReturnString, _T("MD_HC_ON_DEMAND_COMP_LEVEL"));
  7918. break;
  7919. case MD_HC_CREATE_FLAGS:
  7920. _tcscpy(lpReturnString, _T("MD_HC_CREATE_FLAGS"));
  7921. break;
  7922. case MD_WIN32_ERROR:
  7923. _tcscpy(lpReturnString, _T("MD_WIN32_ERROR"));
  7924. break;
  7925. case IIS_MD_VR_BASE:
  7926. _tcscpy(lpReturnString, _T("IIS_MD_VR_BASE"));
  7927. break;
  7928. case MD_VR_PATH:
  7929. _tcscpy(lpReturnString, _T("MD_VR_PATH"));
  7930. break;
  7931. case MD_VR_USERNAME:
  7932. _tcscpy(lpReturnString, _T("MD_VR_USERNAME"));
  7933. break;
  7934. case MD_VR_PASSWORD:
  7935. _tcscpy(lpReturnString, _T("MD_VR_PASSWORD"));
  7936. break;
  7937. case MD_VR_PASSTHROUGH:
  7938. _tcscpy(lpReturnString, _T("MD_VR_PASSTHROUGH"));
  7939. break;
  7940. case MD_LOG_TYPE:
  7941. _tcscpy(lpReturnString, _T("MD_LOG_TYPE"));
  7942. break;
  7943. case MD_LOGFILE_DIRECTORY:
  7944. _tcscpy(lpReturnString, _T("MD_LOGFILE_DIRECTORY"));
  7945. break;
  7946. case MD_LOG_UNUSED1:
  7947. _tcscpy(lpReturnString, _T("MD_LOG_UNUSED1"));
  7948. break;
  7949. case MD_LOGFILE_PERIOD:
  7950. _tcscpy(lpReturnString, _T("MD_LOGFILE_PERIOD"));
  7951. break;
  7952. case MD_LOGFILE_TRUNCATE_SIZE:
  7953. _tcscpy(lpReturnString, _T("MD_LOGFILE_TRUNCATE_SIZE"));
  7954. break;
  7955. case MD_LOG_PLUGIN_MOD_ID:
  7956. _tcscpy(lpReturnString, _T("MD_LOG_PLUGIN_MOD_ID"));
  7957. break;
  7958. case MD_LOG_PLUGIN_UI_ID:
  7959. _tcscpy(lpReturnString, _T("MD_LOG_PLUGIN_UI_ID"));
  7960. break;
  7961. case MD_LOGSQL_DATA_SOURCES:
  7962. _tcscpy(lpReturnString, _T("MD_LOGSQL_DATA_SOURCES"));
  7963. break;
  7964. case MD_LOGSQL_TABLE_NAME:
  7965. _tcscpy(lpReturnString, _T("MD_LOGSQL_TABLE_NAME"));
  7966. break;
  7967. case MD_LOGSQL_USER_NAME:
  7968. _tcscpy(lpReturnString, _T("MD_LOGSQL_USER_NAME"));
  7969. break;
  7970. case MD_LOGSQL_PASSWORD:
  7971. _tcscpy(lpReturnString, _T("MD_LOGSQL_PASSWORD"));
  7972. break;
  7973. case MD_LOG_PLUGIN_ORDER:
  7974. _tcscpy(lpReturnString, _T("MD_LOG_PLUGIN_ORDER"));
  7975. break;
  7976. case MD_LOG_PLUGINS_AVAILABLE:
  7977. _tcscpy(lpReturnString, _T("MD_LOG_PLUGINS_AVAILABLE"));
  7978. break;
  7979. case MD_LOGEXT_FIELD_MASK:
  7980. _tcscpy(lpReturnString, _T("MD_LOGEXT_FIELD_MASK"));
  7981. break;
  7982. case MD_LOGEXT_FIELD_MASK2:
  7983. _tcscpy(lpReturnString, _T("MD_LOGEXT_FIELD_MASK2"));
  7984. break;
  7985. case MD_LOGFILE_LOCALTIME_ROLLOVER:
  7986. _tcscpy(lpReturnString, _T("MD_LOGFILE_LOCALTIME_ROLLOVER"));
  7987. break;
  7988. case IIS_MD_LOGCUSTOM_BASE:
  7989. _tcscpy(lpReturnString, _T("IIS_MD_LOGCUSTOM_BASE"));
  7990. break;
  7991. case MD_LOGCUSTOM_PROPERTY_NAME:
  7992. _tcscpy(lpReturnString, _T("MD_LOGCUSTOM_PROPERTY_NAME"));
  7993. break;
  7994. case MD_LOGCUSTOM_PROPERTY_HEADER:
  7995. _tcscpy(lpReturnString, _T("MD_LOGCUSTOM_PROPERTY_HEADER"));
  7996. break;
  7997. case MD_LOGCUSTOM_PROPERTY_ID:
  7998. _tcscpy(lpReturnString, _T("MD_LOGCUSTOM_PROPERTY_ID"));
  7999. break;
  8000. case MD_LOGCUSTOM_PROPERTY_MASK:
  8001. _tcscpy(lpReturnString, _T("MD_LOGCUSTOM_PROPERTY_MASK"));
  8002. break;
  8003. case MD_LOGCUSTOM_PROPERTY_DATATYPE:
  8004. _tcscpy(lpReturnString, _T("MD_LOGCUSTOM_PROPERTY_DATATYPE"));
  8005. break;
  8006. case MD_LOGCUSTOM_SERVICES_STRING:
  8007. _tcscpy(lpReturnString, _T("MD_LOGCUSTOM_SERVICES_STRING"));
  8008. break;
  8009. case IIS_MD_FTP_BASE:
  8010. _tcscpy(lpReturnString, _T("IIS_MD_FTP_BASE"));
  8011. break;
  8012. case MD_EXIT_MESSAGE:
  8013. _tcscpy(lpReturnString, _T("MD_EXIT_MESSAGE"));
  8014. break;
  8015. case MD_GREETING_MESSAGE:
  8016. _tcscpy(lpReturnString, _T("MD_GREETING_MESSAGE"));
  8017. break;
  8018. case MD_MAX_CLIENTS_MESSAGE:
  8019. _tcscpy(lpReturnString, _T("MD_MAX_CLIENTS_MESSAGE"));
  8020. break;
  8021. case MD_MSDOS_DIR_OUTPUT:
  8022. _tcscpy(lpReturnString, _T("MD_MSDOS_DIR_OUTPUT"));
  8023. break;
  8024. case MD_ALLOW_ANONYMOUS:
  8025. _tcscpy(lpReturnString, _T("MD_ALLOW_ANONYMOUS"));
  8026. break;
  8027. case MD_ANONYMOUS_ONLY:
  8028. _tcscpy(lpReturnString, _T("MD_ANONYMOUS_ONLY"));
  8029. break;
  8030. case MD_LOG_ANONYMOUS:
  8031. _tcscpy(lpReturnString, _T("MD_LOG_ANONYMOUS"));
  8032. break;
  8033. case MD_LOG_NONANONYMOUS:
  8034. _tcscpy(lpReturnString, _T("MD_LOG_NONANONYMOUS"));
  8035. break;
  8036. case MD_ALLOW_REPLACE_ON_RENAME:
  8037. _tcscpy(lpReturnString, _T("MD_ALLOW_REPLACE_ON_RENAME"));
  8038. break;
  8039. case MD_SSL_PUBLIC_KEY:
  8040. _tcscpy(lpReturnString, _T("MD_SSL_PUBLIC_KEY"));
  8041. break;
  8042. case MD_SSL_PRIVATE_KEY:
  8043. _tcscpy(lpReturnString, _T("MD_SSL_PRIVATE_KEY"));
  8044. break;
  8045. case MD_SSL_KEY_PASSWORD:
  8046. _tcscpy(lpReturnString, _T("MD_SSL_KEY_PASSWORD"));
  8047. break;
  8048. case MD_SSL_KEY_REQUEST:
  8049. _tcscpy(lpReturnString, _T("MD_SSL_KEY_REQUEST"));
  8050. break;
  8051. case MD_AUTHORIZATION:
  8052. _tcscpy(lpReturnString, _T("MD_AUTHORIZATION"));
  8053. break;
  8054. case MD_REALM:
  8055. _tcscpy(lpReturnString, _T("MD_REALM"));
  8056. break;
  8057. case MD_HTTP_EXPIRES:
  8058. _tcscpy(lpReturnString, _T("MD_HTTP_EXPIRES"));
  8059. break;
  8060. case MD_HTTP_PICS:
  8061. _tcscpy(lpReturnString, _T("MD_HTTP_PICS"));
  8062. break;
  8063. case MD_HTTP_CUSTOM:
  8064. _tcscpy(lpReturnString, _T("MD_HTTP_CUSTOM"));
  8065. break;
  8066. case MD_DIRECTORY_BROWSING:
  8067. _tcscpy(lpReturnString, _T("MD_DIRECTORY_BROWSING"));
  8068. break;
  8069. case MD_DEFAULT_LOAD_FILE:
  8070. _tcscpy(lpReturnString, _T("MD_DEFAULT_LOAD_FILE"));
  8071. break;
  8072. case MD_CUSTOM_ERROR:
  8073. _tcscpy(lpReturnString, _T("MD_CUSTOM_ERROR"));
  8074. break;
  8075. case MD_FOOTER_DOCUMENT:
  8076. _tcscpy(lpReturnString, _T("MD_FOOTER_DOCUMENT"));
  8077. break;
  8078. case MD_FOOTER_ENABLED:
  8079. _tcscpy(lpReturnString, _T("MD_FOOTER_ENABLED"));
  8080. break;
  8081. case MD_HTTP_REDIRECT:
  8082. _tcscpy(lpReturnString, _T("MD_HTTP_REDIRECT"));
  8083. break;
  8084. case MD_DEFAULT_LOGON_DOMAIN:
  8085. _tcscpy(lpReturnString, _T("MD_DEFAULT_LOGON_DOMAIN"));
  8086. break;
  8087. case MD_LOGON_METHOD:
  8088. _tcscpy(lpReturnString, _T("MD_LOGON_METHOD"));
  8089. break;
  8090. case MD_SCRIPT_MAPS:
  8091. _tcscpy(lpReturnString, _T("MD_SCRIPT_MAPS"));
  8092. break;
  8093. case MD_MIME_MAP:
  8094. _tcscpy(lpReturnString, _T("MD_MIME_MAP"));
  8095. break;
  8096. case MD_ACCESS_PERM:
  8097. _tcscpy(lpReturnString, _T("MD_ACCESS_PERM"));
  8098. break;
  8099. case MD_IP_SEC:
  8100. _tcscpy(lpReturnString, _T("MD_IP_SEC"));
  8101. break;
  8102. case MD_ANONYMOUS_USER_NAME:
  8103. _tcscpy(lpReturnString, _T("MD_ANONYMOUS_USER_NAME"));
  8104. break;
  8105. case MD_ANONYMOUS_PWD:
  8106. _tcscpy(lpReturnString, _T("MD_ANONYMOUS_PWD"));
  8107. break;
  8108. case MD_ANONYMOUS_USE_SUBAUTH:
  8109. _tcscpy(lpReturnString, _T("MD_ANONYMOUS_USE_SUBAUTH"));
  8110. break;
  8111. case MD_DONT_LOG:
  8112. _tcscpy(lpReturnString, _T("MD_DONT_LOG"));
  8113. break;
  8114. case MD_ADMIN_ACL:
  8115. _tcscpy(lpReturnString, _T("MD_ADMIN_ACL"));
  8116. break;
  8117. case MD_SSI_EXEC_DISABLED:
  8118. _tcscpy(lpReturnString, _T("MD_SSI_EXEC_DISABLED"));
  8119. break;
  8120. case MD_DO_REVERSE_DNS:
  8121. _tcscpy(lpReturnString, _T("MD_DO_REVERSE_DNS"));
  8122. break;
  8123. case MD_SSL_ACCESS_PERM:
  8124. _tcscpy(lpReturnString, _T("MD_SSL_ACCESS_PERM"));
  8125. break;
  8126. case MD_AUTHORIZATION_PERSISTENCE:
  8127. _tcscpy(lpReturnString, _T("MD_AUTHORIZATION_PERSISTENCE"));
  8128. break;
  8129. case MD_NTAUTHENTICATION_PROVIDERS:
  8130. _tcscpy(lpReturnString, _T("MD_NTAUTHENTICATION_PROVIDERS"));
  8131. break;
  8132. case MD_SCRIPT_TIMEOUT:
  8133. _tcscpy(lpReturnString, _T("MD_SCRIPT_TIMEOUT"));
  8134. break;
  8135. case MD_CACHE_EXTENSIONS:
  8136. _tcscpy(lpReturnString, _T("MD_CACHE_EXTENSIONS"));
  8137. break;
  8138. case MD_CREATE_PROCESS_AS_USER:
  8139. _tcscpy(lpReturnString, _T("MD_CREATE_PROCESS_AS_USER"));
  8140. break;
  8141. case MD_CREATE_PROC_NEW_CONSOLE:
  8142. _tcscpy(lpReturnString, _T("MD_CREATE_PROC_NEW_CONSOLE"));
  8143. break;
  8144. case MD_POOL_IDC_TIMEOUT:
  8145. _tcscpy(lpReturnString, _T("MD_POOL_IDC_TIMEOUT"));
  8146. break;
  8147. case MD_ALLOW_KEEPALIVES:
  8148. _tcscpy(lpReturnString, _T("MD_ALLOW_KEEPALIVES"));
  8149. break;
  8150. case MD_IS_CONTENT_INDEXED:
  8151. _tcscpy(lpReturnString, _T("MD_IS_CONTENT_INDEXED"));
  8152. break;
  8153. case MD_CC_NO_CACHE:
  8154. _tcscpy(lpReturnString, _T("MD_CC_NO_CACHE"));
  8155. break;
  8156. case MD_CC_MAX_AGE:
  8157. _tcscpy(lpReturnString, _T("MD_CC_MAX_AGE"));
  8158. break;
  8159. case MD_CC_OTHER:
  8160. _tcscpy(lpReturnString, _T("MD_CC_OTHER"));
  8161. break;
  8162. case MD_REDIRECT_HEADERS:
  8163. _tcscpy(lpReturnString, _T("MD_REDIRECT_HEADERS"));
  8164. break;
  8165. case MD_UPLOAD_READAHEAD_SIZE:
  8166. _tcscpy(lpReturnString, _T("MD_UPLOAD_READAHEAD_SIZE"));
  8167. break;
  8168. case MD_PUT_READ_SIZE:
  8169. _tcscpy(lpReturnString, _T("MD_PUT_READ_SIZE"));
  8170. break;
  8171. case MD_WAM_USER_NAME:
  8172. _tcscpy(lpReturnString, _T("MD_WAM_USER_NAME"));
  8173. break;
  8174. case MD_WAM_PWD:
  8175. _tcscpy(lpReturnString, _T("MD_WAM_PWD"));
  8176. break;
  8177. case MD_SCHEMA_METAID:
  8178. _tcscpy(lpReturnString, _T("MD_SCHEMA_METAID"));
  8179. break;
  8180. case MD_DISABLE_SOCKET_POOLING:
  8181. _tcscpy(lpReturnString, _T("MD_DISABLE_SOCKET_POOLING"));
  8182. break;
  8183. case MD_METADATA_ID_REGISTRATION:
  8184. _tcscpy(lpReturnString, _T("MD_METADATA_ID_REGISTRATION"));
  8185. break;
  8186. case MD_HC_SCRIPT_FILE_EXTENSIONS:
  8187. _tcscpy(lpReturnString, _T("MD_HC_SCRIPT_FILE_EXTENSIONS"));
  8188. break;
  8189. case MD_SHOW_4_DIGIT_YEAR:
  8190. _tcscpy(lpReturnString, _T("MD_SHOW_4_DIGIT_YEAR"));
  8191. break;
  8192. case MD_SSL_USE_DS_MAPPER:
  8193. _tcscpy(lpReturnString, _T("MD_SSL_USE_DS_MAPPER"));
  8194. break;
  8195. case MD_FILTER_ENABLE_CACHE:
  8196. _tcscpy(lpReturnString, _T("MD_FILTER_ENABLE_CACHE"));
  8197. break;
  8198. case MD_USE_DIGEST_SSP:
  8199. _tcscpy(lpReturnString, _T("MD_USE_DIGEST_SSP"));
  8200. break;
  8201. case MD_APPPOOL_PERIODIC_RESTART_TIME:
  8202. _tcscpy(lpReturnString, _T("MD_APPPOOL_PERIODIC_RESTART_TIME"));
  8203. break;
  8204. case MD_APPPOOL_PERIODIC_RESTART_REQUEST_COUNT:
  8205. _tcscpy(lpReturnString, _T("MD_APPPOOL_PERIODIC_RESTART_REQUEST_COUNT"));
  8206. break;
  8207. case MD_APPPOOL_MAX_PROCESS_COUNT:
  8208. _tcscpy(lpReturnString, _T("MD_APPPOOL_MAX_PROCESS_COUNT"));
  8209. break;
  8210. case MD_APPPOOL_PINGING_ENABLED:
  8211. _tcscpy(lpReturnString, _T("MD_APPPOOL_PINGING_ENABLED"));
  8212. break;
  8213. case MD_APPPOOL_IDLE_TIMEOUT:
  8214. _tcscpy(lpReturnString, _T("MD_APPPOOL_IDLE_TIMEOUT"));
  8215. break;
  8216. case MD_APPPOOL_RAPID_FAIL_PROTECTION_ENABLED:
  8217. _tcscpy(lpReturnString, _T("MD_APPPOOL_RAPID_F_PROTECTION_ENABLED"));
  8218. break;
  8219. case MD_APPPOOL_SMP_AFFINITIZED:
  8220. _tcscpy(lpReturnString, _T("MD_APPPOOL_SMP_AFFINITIZED"));
  8221. break;
  8222. case MD_APPPOOL_SMP_AFFINITIZED_PROCESSOR_MASK:
  8223. _tcscpy(lpReturnString, _T("MD_APPPOOL_SMP_AFFINITIZED_PROCESSOR_MASK"));
  8224. break;
  8225. case MD_APPPOOL_ORPHAN_PROCESSES_FOR_DEBUGGING:
  8226. _tcscpy(lpReturnString, _T("MD_APPPOOL_ORPHAN_PROCESSES_FOR_DEBUGGING"));
  8227. break;
  8228. case MD_APPPOOL_STARTUP_TIMELIMIT:
  8229. _tcscpy(lpReturnString, _T("MD_APPPOOL_STARTUP_TIMELIMIT"));
  8230. break;
  8231. case MD_APPPOOL_SHUTDOWN_TIMELIMIT:
  8232. _tcscpy(lpReturnString, _T("MD_APPPOOL_SHUTDOWN_TIMELIMIT"));
  8233. break;
  8234. case MD_APPPOOL_PING_INTERVAL:
  8235. _tcscpy(lpReturnString, _T("MD_APPPOOL_PING_INTERVAL"));
  8236. break;
  8237. case MD_APPPOOL_PING_RESPONSE_TIMELIMIT:
  8238. _tcscpy(lpReturnString, _T("MD_APPPOOL_PING_RESPONSE_TIMELIMIT"));
  8239. break;
  8240. case MD_APPPOOL_DISALLOW_OVERLAPPING_ROTATION:
  8241. _tcscpy(lpReturnString, _T("MD_APPPOOL_DISALLOW_OVERLAPPING_ROTATION"));
  8242. break;
  8243. case MD_APPPOOL_UL_APPPOOL_QUEUE_LENGTH:
  8244. _tcscpy(lpReturnString, _T("MD_APPPOOL_UL_APPPOOL_QUEUE_LENGTH"));
  8245. break;
  8246. case MD_APPPOOL_DISALLOW_ROTATION_ON_CONFIG_CHANGE:
  8247. _tcscpy(lpReturnString, _T("MD_APPPOOL_DISALLOW_ROTATION_ON_CONFIG_CHANGE"));
  8248. break;
  8249. case MD_APPPOOL_PERIODIC_RESTART_SCHEDULE:
  8250. _tcscpy(lpReturnString, _T("MD_APPPOOL_PERIODIC_RESTART_SCHEDULE"));
  8251. break;
  8252. case MD_APPPOOL_IDENTITY_TYPE:
  8253. _tcscpy(lpReturnString, _T("MD_APPPOOL_IDENTITY_TYPE"));
  8254. break;
  8255. case MD_CPU_ACTION:
  8256. _tcscpy(lpReturnString, _T("MD_CPU_ACTION"));
  8257. break;
  8258. case MD_CPU_LIMIT:
  8259. _tcscpy(lpReturnString, _T("MD_CPU_LIMIT"));
  8260. break;
  8261. case MD_APPPOOL_PERIODIC_RESTART_MEMORY:
  8262. _tcscpy(lpReturnString, _T("MD_APPPOOL_PERIODIC_RESTART_MEMORY"));
  8263. break;
  8264. case MD_APP_APPPOOL_ID:
  8265. _tcscpy(lpReturnString, _T("MD_APP_APPPOOL_ID"));
  8266. break;
  8267. case MD_APP_ALLOW_TRANSIENT_REGISTRATION:
  8268. _tcscpy(lpReturnString, _T("MD_APP_ALLOW_TRANSIENT_REGISTRATION"));
  8269. break;
  8270. case MD_APP_AUTO_START:
  8271. _tcscpy(lpReturnString, _T("MD_APP_AUTO_START"));
  8272. break;
  8273. case MD_APPPOOL_PERIODIC_RESTART_CONNECTIONS:
  8274. _tcscpy(lpReturnString, _T("MD_APPPOOL_PERIODIC_RESTART_CONNECTIONS"));
  8275. break;
  8276. case MD_MAX_GLOBAL_BANDWIDTH:
  8277. _tcscpy(lpReturnString, _T("MD_MAX_GLOBAL_BANDWIDTH"));
  8278. break;
  8279. case MD_GLOBAL_STANDARD_APP_MODE_ENABLED:
  8280. _tcscpy(lpReturnString, _T("MD_GLOBAL_STANDARD_APP_MODE_ENABLED"));
  8281. break;
  8282. case MD_HEADER_WAIT_TIMEOUT:
  8283. _tcscpy(lpReturnString, _T("MD_HEADER_WAIT_TIMEOUT"));
  8284. break;
  8285. case MD_MIN_FILE_BYTES_PER_SEC:
  8286. _tcscpy(lpReturnString, _T("MD_MIN_FILE_BYTES_PER_SEC"));
  8287. break;
  8288. case MD_GLOBAL_LOG_IN_UTF_8:
  8289. _tcscpy(lpReturnString, _T("MD_GLOBAL_LOG_IN_UTF_8"));
  8290. break;
  8291. case MD_ASP_ENABLEPARENTPATHS:
  8292. _tcscpy(lpReturnString, _T("MD_ASP_ENABLEPARENTPATHS"));
  8293. break;
  8294. case ASP_MD_SERVER_BASE:
  8295. case MD_ASP_LOGERRORREQUESTS:
  8296. case MD_ASP_SCRIPTERRORSSENTTOBROWSER:
  8297. case MD_ASP_SCRIPTERRORMESSAGE:
  8298. case MD_ASP_SCRIPTFILECACHESIZE:
  8299. case MD_ASP_SCRIPTENGINECACHEMAX:
  8300. case MD_ASP_SCRIPTTIMEOUT:
  8301. case MD_ASP_SESSIONTIMEOUT:
  8302. case MD_ASP_MEMFREEFACTOR:
  8303. case MD_ASP_MINUSEDBLOCKS:
  8304. case MD_ASP_ALLOWSESSIONSTATE:
  8305. case MD_ASP_SCRIPTLANGUAGE:
  8306. case MD_ASP_QUEUETIMEOUT:
  8307. case MD_ASP_ALLOWOUTOFPROCCOMPONENTS:
  8308. case MD_ASP_EXCEPTIONCATCHENABLE:
  8309. case MD_ASP_CODEPAGE:
  8310. case MD_ASP_SCRIPTLANGUAGELIST:
  8311. case MD_ASP_ENABLESERVERDEBUG:
  8312. case MD_ASP_ENABLECLIENTDEBUG:
  8313. case MD_ASP_TRACKTHREADINGMODEL:
  8314. case MD_ASP_ENABLEASPHTMLFALLBACK:
  8315. case MD_ASP_ENABLECHUNKEDENCODING:
  8316. case MD_ASP_ENABLETYPELIBCACHE:
  8317. case MD_ASP_ERRORSTONTLOG:
  8318. case MD_ASP_PROCESSORTHREADMAX:
  8319. case MD_ASP_REQEUSTQUEUEMAX:
  8320. case MD_ASP_ENABLEAPPLICATIONRESTART:
  8321. case MD_ASP_QUEUECONNECTIONTESTTIME:
  8322. case MD_ASP_SESSIONMAX:
  8323. _tcscpy(lpReturnString, _T("MD_ASP_????"));
  8324. break;
  8325. case WAM_MD_SERVER_BASE:
  8326. _tcscpy(lpReturnString, _T("WAM_MD_SERVER_BASE"));
  8327. break;
  8328. default:
  8329. _stprintf(lpReturnString, _T("%d"), dwMetabaseID);
  8330. break;
  8331. }
  8332. return;
  8333. }
  8334. void SetErrorFlag(char *szFileName, int iLineNumber)
  8335. {
  8336. // set flag to say that there was an error!!!
  8337. g_pTheApp->m_bThereWereErrorsChkLogfile = TRUE;
  8338. return;
  8339. }
  8340. BOOL
  8341. IsContinuedLine(BUFFER *pBuff)
  8342. {
  8343. LPTSTR szContinueChar;
  8344. if (!pBuff)
  8345. {
  8346. return FALSE;
  8347. }
  8348. szContinueChar = _tcsrchr( (LPTSTR)pBuff->QueryPtr(), '\\' );
  8349. if (!szContinueChar)
  8350. {
  8351. return FALSE;
  8352. }
  8353. while ( ( *szContinueChar) &&
  8354. ( (*szContinueChar == ' ') || (*szContinueChar == '\t') )
  8355. )
  8356. {
  8357. szContinueChar++;
  8358. }
  8359. return (*szContinueChar == '\0');
  8360. }
  8361. DWORD FillStrListWithListOfSections(IN HINF hFile, CStringList &strList, IN LPCTSTR szSection)
  8362. {
  8363. DWORD dwReturn = ERROR_SUCCESS;
  8364. DWORD dwRequiredSize;
  8365. BOOL b = FALSE;
  8366. INFCONTEXT Context;
  8367. BUFFER bBuff;
  8368. // go to the beginning of the section in the INF file
  8369. b = SetupFindFirstLine_Wrapped(hFile, szSection, NULL, &Context);
  8370. if (!b)
  8371. {
  8372. dwReturn = ERROR_PATH_NOT_FOUND;
  8373. goto FillStrListWithListOfSections_Exit;
  8374. }
  8375. // loop through the items in the section.
  8376. while (b)
  8377. {
  8378. // get the size of the memory we need for this
  8379. b = SetupGetLineText(&Context, NULL, NULL, NULL, NULL, 0, &dwRequiredSize);
  8380. dwRequiredSize = (dwRequiredSize + 1) * sizeof(TCHAR);
  8381. // prepare the buffer to receive the line
  8382. if (dwRequiredSize > bBuff.QuerySize())
  8383. {
  8384. if (!bBuff.Resize( dwRequiredSize ))
  8385. {
  8386. return dwReturn;
  8387. }
  8388. }
  8389. // get the line from the inf file1
  8390. if (SetupGetLineText(&Context, NULL, NULL, NULL, (LPTSTR) bBuff.QueryPtr(), bBuff.QuerySize()/sizeof(TCHAR), NULL) == FALSE)
  8391. {
  8392. iisDebugOut((LOG_TYPE_ERROR, _T("FillStrListWithListOfSections %s. Failed on SetupGetLineText.\n"), szSection));
  8393. goto FillStrListWithListOfSections_Exit;
  8394. }
  8395. while ( IsContinuedLine(&bBuff) &&
  8396. SetupFindNextLine(&Context, &Context)
  8397. )
  8398. {
  8399. // get the size of the memory we need for this
  8400. b = SetupGetLineText(&Context, NULL, NULL, NULL, NULL, 0, &dwRequiredSize);
  8401. dwRequiredSize = (dwRequiredSize + 1 + _tcslen((LPTSTR) bBuff.QueryPtr())) * sizeof(TCHAR);
  8402. if ( !bBuff.Resize(dwRequiredSize + 2) )
  8403. {
  8404. return dwReturn;
  8405. }
  8406. if (SetupGetLineText(&Context,
  8407. NULL,
  8408. NULL,
  8409. NULL,
  8410. (LPTSTR) bBuff.QueryPtr() + _tcslen((LPTSTR) bBuff.QueryPtr()),
  8411. bBuff.QuerySize()/sizeof(TCHAR)-_tcslen((LPTSTR) bBuff.QueryPtr()),
  8412. NULL) == FALSE)
  8413. {
  8414. iisDebugOut((LOG_TYPE_ERROR, _T("FillStrListWithListOfSections %s. Failed on SetupGetLineText.\n"), szSection));
  8415. goto FillStrListWithListOfSections_Exit;
  8416. }
  8417. }
  8418. // Add it to the list
  8419. strList.AddTail((LPTSTR) bBuff.QueryPtr());
  8420. // find the next line in the section. If there is no next line it should return false
  8421. b = SetupFindNextLine(&Context, &Context);
  8422. }
  8423. FillStrListWithListOfSections_Exit:
  8424. return dwReturn;
  8425. }
  8426. void DisplayStringForMetabaseID(DWORD dwMetabaseID)
  8427. {
  8428. TCHAR lpReturnString[50];
  8429. ReturnStringForMetabaseID(dwMetabaseID, lpReturnString);
  8430. iisDebugOut((LOG_TYPE_TRACE, _T("%d=%s\n"), dwMetabaseID, lpReturnString));
  8431. return;
  8432. }
  8433. DWORD WINAPI MessageBoxFreeThread_MTS(LPVOID p)
  8434. {
  8435. HRESULT nNetErr = (HRESULT) gTempMTSError.dwErrorCode;
  8436. TCHAR pMsg[_MAX_PATH] = _T("");
  8437. DWORD dwFormatReturn = 0;
  8438. dwFormatReturn = FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM,NULL, gTempMTSError.dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT),pMsg, _MAX_PATH, NULL);
  8439. if ( dwFormatReturn == 0)
  8440. {
  8441. if (nNetErr >= NERR_BASE)
  8442. {
  8443. HMODULE hDll = (HMODULE)LoadLibrary(_T("netmsg.dll"));
  8444. if (hDll)
  8445. {
  8446. dwFormatReturn = FormatMessage( FORMAT_MESSAGE_FROM_HMODULE,hDll, gTempMTSError.dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT),pMsg, _MAX_PATH, NULL);
  8447. FreeLibrary(hDll);
  8448. }
  8449. }
  8450. }
  8451. CString csErrorString;
  8452. MyLoadString(IDS_SETUP_ERRORS_ENCOUNTERED_MTS, csErrorString);
  8453. CString csErrArea;
  8454. MyLoadString(gTempMTSError.iMtsThingWeWereDoing, csErrArea);
  8455. CString csTitle;
  8456. MyLoadString(IDS_MTS_ERROR_TITLEBAR, csTitle);
  8457. CString csMsg;
  8458. csMsg.Format(csErrorString, csErrArea);
  8459. CString csErrMsg;
  8460. HandleSpecificErrors(gTempMTSError.dwErrorCode, dwFormatReturn, csMsg, pMsg, &csErrMsg);
  8461. MyMessageBox(NULL, csErrMsg, csTitle, MB_OK | MB_SETFOREGROUND);
  8462. return 0;
  8463. }
  8464. DWORD WINAPI MessageBoxFreeThread_IIS(PVOID p)
  8465. {
  8466. INT_PTR iStringID = (INT_PTR) p;
  8467. MyMessageBox(NULL, (UINT) iStringID, g_MyLogFile.m_szLogFileName_Full, MB_OK | MB_SETFOREGROUND);
  8468. return 0;
  8469. }
  8470. void MesssageBoxErrors_IIS(void)
  8471. {
  8472. if (g_pTheApp->m_bThereWereErrorsChkLogfile == TRUE)
  8473. {
  8474. int iSaveOld_AllowMessageBoxPopups = g_pTheApp->m_bAllowMessageBoxPopups;
  8475. g_pTheApp->m_bAllowMessageBoxPopups = TRUE;
  8476. DWORD id;
  8477. INT_PTR iStringID = IDS_SETUP_ERRORS_ENCOUNTERED;
  8478. // show the messagebox display from another thread, so that setup can continue!
  8479. HANDLE hProc = NULL;
  8480. hProc = CreateThread(NULL, 0, MessageBoxFreeThread_IIS, (PVOID) iStringID, 0, &id);
  8481. g_pTheApp->m_bAllowMessageBoxPopups = iSaveOld_AllowMessageBoxPopups;
  8482. CString csErrMsg;
  8483. TCHAR szErrorString[255] = _T("");
  8484. MyLoadString(IDS_SETUP_ERRORS_ENCOUNTERED, csErrMsg);
  8485. _stprintf(szErrorString, csErrMsg, g_MyLogFile.m_szLogFileName_Full);
  8486. //LogSevInformation 0x00000000
  8487. //LogSevWarning 0x00000001
  8488. //LogSevError 0x00000002
  8489. //LogSevFatalError 0x00000003
  8490. //LogSevMaximum 0x00000004
  8491. // Write it to the setupapi log file!
  8492. if ( *szErrorString )
  8493. {
  8494. SetupLogError(szErrorString, LogSevError);
  8495. }
  8496. }
  8497. return;
  8498. }
  8499. void MesssageBoxErrors_MTS(int iMtsThingWeWereDoing, DWORD dwErrorCode)
  8500. {
  8501. if (!g_pTheApp->m_bThereWereErrorsFromMTS)
  8502. {
  8503. DWORD id;
  8504. int iSaveOld_AllowMessageBoxPopups = g_pTheApp->m_bAllowMessageBoxPopups;
  8505. gTempMTSError.iMtsThingWeWereDoing = iMtsThingWeWereDoing;
  8506. gTempMTSError.dwErrorCode = dwErrorCode;
  8507. g_pTheApp->m_bAllowMessageBoxPopups = TRUE;
  8508. // show the messagebox display from another thread, so that setup can continue!
  8509. HANDLE hProc = NULL;
  8510. hProc = CreateThread(NULL, 0, MessageBoxFreeThread_MTS, 0, 0, &id);
  8511. if ( hProc != NULL )
  8512. {
  8513. CloseHandle( hProc );
  8514. }
  8515. g_pTheApp->m_bAllowMessageBoxPopups = iSaveOld_AllowMessageBoxPopups;
  8516. g_pTheApp->m_bThereWereErrorsFromMTS = TRUE;
  8517. }
  8518. return;
  8519. }
  8520. void PleaseKillOrStopTheseExeFromRunning(LPCTSTR szModuleWhichIsLocked, CStringList &strList)
  8521. {
  8522. if (strList.IsEmpty() == FALSE)
  8523. {
  8524. POSITION pos;
  8525. CString csExeName;
  8526. int nLen = 0;
  8527. TCHAR szReturnedServiceName[_MAX_PATH];
  8528. pos = strList.GetHeadPosition();
  8529. while (pos)
  8530. {
  8531. csExeName = strList.GetAt(pos);
  8532. nLen = 0;
  8533. nLen = csExeName.GetLength();
  8534. if (nLen > 0)
  8535. {
  8536. //iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("%1!s! is locking %2!s! service and is locking %3!s!\n"),csExeName, szModuleWhichIsLocked));
  8537. if (TRUE == InetIsThisExeAService(csExeName, szReturnedServiceName))
  8538. {
  8539. 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));
  8540. // Check if it is the netlogon service, We no don't want to stop this service for sure!!!
  8541. /*
  8542. if (_tcsicmp(szReturnedServiceName, _T("NetLogon")) == 0)
  8543. {
  8544. // no we do not want to stop this service!!!
  8545. 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));
  8546. break;
  8547. }
  8548. */
  8549. // Don't stop any services which are not win32 services
  8550. // Don't stop any system services...
  8551. if (TRUE == IsThisOnNotStopList(g_pTheApp->m_hInfHandle, szReturnedServiceName, TRUE))
  8552. {
  8553. 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));
  8554. }
  8555. else
  8556. {
  8557. // add this service to the list of
  8558. // services we need to restart after setup is done!!
  8559. ServicesRestartList_Add(szReturnedServiceName);
  8560. // Check the list of services which we are sure we do not want to stop!
  8561. // net stop it
  8562. InetStopService(szReturnedServiceName);
  8563. }
  8564. // otherwise go on to the next .exe file
  8565. }
  8566. else
  8567. {
  8568. // This .exe file is not a Service....
  8569. // Should we kill it???????
  8570. if (TRUE == IsThisOnNotStopList(g_pTheApp->m_hInfHandle, csExeName, FALSE))
  8571. {
  8572. iisDebugOutSafeParams((LOG_TYPE_PROGRAM_FLOW, _T("%1!s! is locking it. This process should not be killed\n"),csExeName));
  8573. }
  8574. else
  8575. {
  8576. // Check the list of .exe which we are sure we do not want to kill!
  8577. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("%1!s! is locking %2!s!. Let's kill that process.\n"),csExeName,szModuleWhichIsLocked));
  8578. KillProcess_Wrap(csExeName);
  8579. }
  8580. }
  8581. }
  8582. strList.GetNext(pos);
  8583. }
  8584. }
  8585. return;
  8586. }
  8587. void ShowIfModuleUsedForThisINFSection(IN HINF hFile, IN LPCTSTR szSection, int iUnlockThem)
  8588. {
  8589. LPTSTR szLine = NULL;
  8590. DWORD dwRequiredSize;
  8591. BOOL b = FALSE;
  8592. CString csFile;
  8593. INFCONTEXT Context;
  8594. TCHAR buf[_MAX_PATH];
  8595. GetSystemDirectory( buf, _MAX_PATH);
  8596. // go to the beginning of the section in the INF file
  8597. b = SetupFindFirstLine_Wrapped(hFile, szSection, NULL, &Context);
  8598. if (!b)
  8599. {
  8600. goto ShowIfModuleUsedForThisINFSection_Exit;
  8601. }
  8602. // loop through the items in the section.
  8603. while (b)
  8604. {
  8605. // get the size of the memory we need for this
  8606. b = SetupGetLineText(&Context, NULL, NULL, NULL, NULL, 0, &dwRequiredSize);
  8607. // prepare the buffer to receive the line
  8608. szLine = (LPTSTR)GlobalAlloc( GPTR, dwRequiredSize * sizeof(TCHAR) );
  8609. if ( !szLine )
  8610. {
  8611. goto ShowIfModuleUsedForThisINFSection_Exit;
  8612. }
  8613. // get the line from the inf file1
  8614. if (SetupGetLineText(&Context, NULL, NULL, NULL, szLine, dwRequiredSize, NULL) == FALSE)
  8615. {
  8616. goto ShowIfModuleUsedForThisINFSection_Exit;
  8617. }
  8618. // Attach the path to the from of this...
  8619. // check in this directory:
  8620. // 1. winnt\system32
  8621. // --------------------------------------
  8622. // may look like this "iisrtl.dll,,4"
  8623. // so get rid of the ',,4'
  8624. LPTSTR pch = NULL;
  8625. pch = _tcschr(szLine, _T(','));
  8626. if (pch) {_tcscpy(pch, _T(" "));}
  8627. // Remove any trailing spaces.
  8628. StripLastBackSlash(szLine);
  8629. // Get the system dir
  8630. csFile = buf;
  8631. csFile = AddPath(csFile, szLine);
  8632. CStringList strList;
  8633. strList.RemoveAll();
  8634. LogProcessesUsingThisModule(csFile, strList);
  8635. // if we're supposed to unlock this file, then
  8636. // we'll try it.
  8637. if (iUnlockThem)
  8638. {
  8639. PleaseKillOrStopTheseExeFromRunning(csFile, strList);
  8640. }
  8641. // find the next line in the section. If there is no next line it should return false
  8642. b = SetupFindNextLine(&Context, &Context);
  8643. // free the temporary buffer
  8644. GlobalFree( szLine );
  8645. szLine = NULL;
  8646. }
  8647. // free some memory used for the task list
  8648. FreeTaskListMem();
  8649. UnInit_Lib_PSAPI();
  8650. if (szLine) {GlobalFree(szLine);szLine=NULL;}
  8651. ShowIfModuleUsedForThisINFSection_Exit:
  8652. return;
  8653. }
  8654. void ShowIfModuleUsedForGroupOfSections(IN HINF hFile, int iUnlockThem)
  8655. {
  8656. CStringList strList;
  8657. TSTR strTheSection;
  8658. if ( !strTheSection.Copy( _T("VerifyFileSections_Lockable") ) )
  8659. {
  8660. return;
  8661. }
  8662. if (GetSectionNameToDo(hFile, &strTheSection))
  8663. {
  8664. if (ERROR_SUCCESS == FillStrListWithListOfSections(hFile, strList, strTheSection.QueryStr()))
  8665. {
  8666. // loop thru the list returned back
  8667. if (strList.IsEmpty() == FALSE)
  8668. {
  8669. POSITION pos;
  8670. CString csEntry;
  8671. pos = strList.GetHeadPosition();
  8672. while (pos)
  8673. {
  8674. csEntry = strList.GetAt(pos);
  8675. ShowIfModuleUsedForThisINFSection(hFile, csEntry, iUnlockThem);
  8676. strList.GetNext(pos);
  8677. }
  8678. }
  8679. }
  8680. }
  8681. return;
  8682. }
  8683. int ReadGlobalsFromInf(HINF InfHandle)
  8684. {
  8685. int iReturn = FALSE;
  8686. INFCONTEXT Context;
  8687. TCHAR szTempString[_MAX_PATH] = _T("");
  8688. //
  8689. // Set the m_csAppName
  8690. //
  8691. if (!SetupFindFirstLine_Wrapped(InfHandle, _T("SetupInfo"), _T("AppName"), &Context) )
  8692. {iisDebugOut((LOG_TYPE_ERROR, _T("SetupFindFirstLine_Wrapped(SetupInfo, AppName) FAILED")));}
  8693. if (!SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  8694. {iisDebugOut((LOG_TYPE_ERROR, _T("SetupGetStringField(SetupInfo, AppName) FAILED")));}
  8695. // Set the global.
  8696. g_pTheApp->m_csAppName = szTempString;
  8697. //
  8698. // Set the m_csIISGroupName
  8699. //
  8700. _tcscpy(szTempString, _T(""));
  8701. if (!SetupFindFirstLine_Wrapped(InfHandle, _T("SetupInfo"), _T("StartMenuGroupName"), &Context) )
  8702. {iisDebugOut((LOG_TYPE_ERROR, _T("SetupFindFirstLine_Wrapped(SetupInfo, StartMenuGroupName) FAILED")));}
  8703. if (!SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  8704. {iisDebugOut((LOG_TYPE_ERROR, _T("SetupGetStringField(SetupInfo, StartMenuGroupName) FAILED")));}
  8705. g_pTheApp->m_csIISGroupName = szTempString;
  8706. iReturn = TRUE;
  8707. //
  8708. // Get the value of one tick on the progressbar
  8709. //
  8710. g_GlobalTickValue = 1;
  8711. _tcscpy(szTempString, _T(""));
  8712. SetupFindFirstLine_Wrapped(InfHandle, _T("SetupInfo"), _T("OneTick"), &Context);
  8713. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  8714. {g_GlobalTickValue = _ttoi(szTempString);}
  8715. //
  8716. // See if we want to fake out setup when it's running in add\remove, to think it's actually guimode
  8717. //
  8718. g_GlobalGuiOverRide = 0;
  8719. _tcscpy(szTempString, _T(""));
  8720. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupInfo"), _T("GuiMode"), &Context))
  8721. {
  8722. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  8723. {g_GlobalGuiOverRide = _ttoi(szTempString);}
  8724. }
  8725. return iReturn;
  8726. }
  8727. int CheckIfPlatformMatchesInf(HINF InfHandle)
  8728. {
  8729. int iReturn = TRUE;
  8730. INFCONTEXT Context;
  8731. TCHAR szPlatform[_MAX_PATH] = _T("");
  8732. BOOL fPlatform = FALSE;
  8733. int nPlatform = IDS_INCORRECT_PLATFORM;
  8734. if (!SetupFindFirstLine_Wrapped(InfHandle, _T("SetupInfo"), _T("Platform"), &Context) )
  8735. {iisDebugOut((LOG_TYPE_ERROR, _T("SetupFindFirstLine_Wrapped(SetupInfo, Platform) FAILED")));}
  8736. SetupGetStringField(&Context, 1, szPlatform, _MAX_PATH, NULL);
  8737. // Check if .inf file is for NTS
  8738. if (_tcsicmp(szPlatform, _T("NTS")) == 0)
  8739. {
  8740. if (g_pTheApp->m_eOS == OS_NT && g_pTheApp->m_eNTOSType != OT_NTW)
  8741. {fPlatform = TRUE;}
  8742. else
  8743. {
  8744. if (g_pTheApp->m_fInvokedByNT)
  8745. {
  8746. iisDebugOut((LOG_TYPE_WARN, _T("TemporaryHack. iis.inf=NTS system=NTW, but wait till nt5 fixes. FAIL.\n")));
  8747. g_pTheApp->m_eNTOSType = OT_NTS;
  8748. fPlatform = TRUE;
  8749. }
  8750. else
  8751. {
  8752. nPlatform = IDS_NEED_PLATFORM_NTW;
  8753. }
  8754. }
  8755. }
  8756. // Check if .inf file is for NTW
  8757. if (_tcsicmp(szPlatform, _T("NTW")) == 0)
  8758. {
  8759. if (g_pTheApp->m_eOS == OS_NT && g_pTheApp->m_eNTOSType == OT_NTW){fPlatform = TRUE;}
  8760. else{nPlatform = IDS_NEED_PLATFORM_NTW;}
  8761. }
  8762. /*
  8763. // Check if .inf file is for Windows 95
  8764. if (_tcsicmp(szPlatform, _T("W95")) == 0)
  8765. {
  8766. if (g_pTheApp->m_eOS == OS_W95){fPlatform = TRUE;}
  8767. else{nPlatform = IDS_NEED_PLATFORM_W95;}
  8768. }
  8769. */
  8770. // If We didn't find the specific platform, then produce error message.
  8771. if (!fPlatform)
  8772. {
  8773. MyMessageBox(NULL, nPlatform, MB_OK | MB_SETFOREGROUND);
  8774. iReturn = FALSE;
  8775. }
  8776. return iReturn;
  8777. }
  8778. int CheckSpecificBuildinInf(HINF InfHandle)
  8779. {
  8780. int iReturn = TRUE;
  8781. INFCONTEXT Context;
  8782. // Check for a specific build of nt5...
  8783. if ( g_pTheApp->m_eOS == OS_NT )
  8784. {
  8785. int iBuildNumRequired = 0;
  8786. TCHAR szBuildRequired[20] = _T("");
  8787. // check for Debug Keyword
  8788. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupInfo"), _T("Debug"), &Context) )
  8789. {
  8790. SetupGetStringField(&Context, 1, szBuildRequired, sizeof(szBuildRequired)/sizeof(szBuildRequired[0]), NULL);
  8791. if (IsValidNumber((LPCTSTR)szBuildRequired))
  8792. {
  8793. iBuildNumRequired = _ttoi(szBuildRequired);
  8794. if (iBuildNumRequired >= 1) {g_pTheApp->m_bAllowMessageBoxPopups = TRUE;}
  8795. }
  8796. }
  8797. if (!SetupFindFirstLine_Wrapped(InfHandle, _T("SetupInfo"), _T("OSBuildRequired"), &Context) )
  8798. {iisDebugOut((LOG_TYPE_ERROR, _T("SetupFindFirstLine_Wrapped(SetupInfo, OSBuildRequired) FAILED")));}
  8799. else
  8800. {
  8801. SetupGetStringField(&Context, 1, szBuildRequired, 20, NULL);
  8802. // Since this is nt, we should be able to get the build number
  8803. CRegKey regWindowsNT( HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"),KEY_READ);
  8804. if ( (HKEY)regWindowsNT )
  8805. {
  8806. CString strBuildNumString;
  8807. regWindowsNT.m_iDisplayWarnings = FALSE;
  8808. if (ERROR_SUCCESS == regWindowsNT.QueryValue(_T("CurrentBuildNumber"), strBuildNumString))
  8809. {
  8810. int iBuildNumOS = 0;
  8811. if (IsValidNumber((LPCTSTR)strBuildNumString))
  8812. {iBuildNumOS = _ttoi(strBuildNumString);}
  8813. iisDebugOut((LOG_TYPE_TRACE, _T("NTCurrentBuildNumber=%d\n"), iBuildNumOS));
  8814. // We have a build entry.
  8815. // lets check if it larger than or equal to what the underlying operting system is...
  8816. if (_tcsicmp(szBuildRequired, _T("")) != 0)
  8817. {
  8818. if (IsValidNumber((LPCTSTR)szBuildRequired))
  8819. {iBuildNumRequired = _ttoi(szBuildRequired);}
  8820. if ((iBuildNumOS !=0 && iBuildNumRequired !=0) && (iBuildNumOS < iBuildNumRequired))
  8821. {
  8822. // They don't have a big enough build num
  8823. // give the error message.
  8824. MyMessageBox(NULL, IDS_OS_BUILD_NUM_REQUIREMENT,szBuildRequired, MB_OK | MB_SETFOREGROUND);
  8825. }
  8826. }
  8827. }
  8828. }
  8829. }
  8830. }
  8831. return iReturn;
  8832. }
  8833. int CheckForOldGopher(HINF InfHandle)
  8834. {
  8835. int iReturn = TRUE;
  8836. if ( !(g_pTheApp->m_fUnattended) && g_pTheApp->m_eInstallMode == IM_UPGRADE )
  8837. {
  8838. CRegKey regGopher(HKEY_LOCAL_MACHINE, REG_GOPHERSVC,KEY_READ);
  8839. if ( (HKEY)regGopher )
  8840. {
  8841. iisDebugOut((LOG_TYPE_TRACE, _T("GopherCurrentlyInstalled=YES")));
  8842. if (g_pTheApp->MsgBox(NULL, IDS_REMOVE_GOPHER, MB_OKCANCEL, FALSE) == IDCANCEL)
  8843. {
  8844. // setup should be terminated.
  8845. iReturn = FALSE;
  8846. goto CheckForOldGopher_Exit;
  8847. }
  8848. }
  8849. }
  8850. CheckForOldGopher_Exit:
  8851. return iReturn;
  8852. }
  8853. // IIS publish the following directories to iis partners products
  8854. // Note: Inetpub directory can be customized later, and we'll re-publish
  8855. // those affected directories again later.
  8856. void SetOCGlobalPrivateData(void)
  8857. {
  8858. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("PathInetsrv"),(PVOID)(LPCTSTR)g_pTheApp->m_csPathInetsrv,(g_pTheApp->m_csPathInetsrv.GetLength() + 1) * sizeof(TCHAR),REG_SZ);
  8859. CString csPathIISAdmin = g_pTheApp->m_csPathInetsrv + _T("\\iisadmin");
  8860. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("PathIISAdmin"),(PVOID)(LPCTSTR)csPathIISAdmin,(csPathIISAdmin.GetLength() + 1) * sizeof(TCHAR),REG_SZ);
  8861. CString csPathIISHelp = g_pTheApp->m_csWinDir + _T("\\Help\\iishelp");
  8862. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("PathIISHelp"),(PVOID)(LPCTSTR)csPathIISHelp,(csPathIISHelp.GetLength() + 1) * sizeof(TCHAR),REG_SZ);
  8863. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("PathFTPRoot"),(PVOID)(LPCTSTR)g_pTheApp->m_csPathFTPRoot,(g_pTheApp->m_csPathFTPRoot.GetLength() + 1) * sizeof(TCHAR),REG_SZ);
  8864. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("PathWWWRoot"),(PVOID)(LPCTSTR)g_pTheApp->m_csPathWWWRoot,(g_pTheApp->m_csPathWWWRoot.GetLength() + 1) * sizeof(TCHAR),REG_SZ);
  8865. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("PathIISSamples"),(PVOID)(LPCTSTR)g_pTheApp->m_csPathIISSamples,(g_pTheApp->m_csPathIISSamples.GetLength() + 1) * sizeof(TCHAR),REG_SZ);
  8866. CString csPathScripts = g_pTheApp->m_csPathIISSamples + _T("\\Scripts");
  8867. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("PathScripts"),(PVOID)(LPCTSTR)csPathScripts,(csPathScripts.GetLength() + 1) * sizeof(TCHAR),REG_SZ);
  8868. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("IISProgramGroup"),(PVOID)(LPCTSTR)g_pTheApp->m_csIISGroupName,(g_pTheApp->m_csIISGroupName.GetLength() + 1) * sizeof(TCHAR),REG_SZ);
  8869. DWORD dwUpgradeType = (DWORD)(g_pTheApp->m_eUpgradeType);
  8870. gHelperRoutines.SetPrivateData(gHelperRoutines.OcManagerContext,_T("UpgradeType"),(PVOID)&dwUpgradeType,sizeof(DWORD),REG_DWORD);
  8871. return;
  8872. }
  8873. // STDAPI GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD* dwlength);
  8874. typedef HRESULT (*P_GetCORSystemDirectory)(LPWSTR pBuffer, DWORD ccBuffer, DWORD* dwLength);
  8875. BOOL GetASPNETSystemDir(LPTSTR lpszDir)
  8876. {
  8877. BOOL bRet = FALSE;
  8878. WCHAR wszSystemDir[_MAX_PATH];
  8879. DWORD dwLength;
  8880. P_GetCORSystemDirectory hProcGetSystemPath = NULL;
  8881. _tcscpy(lpszDir,_T(""));
  8882. // try using method#1
  8883. HINSTANCE hMsCoreeDll = LoadLibraryEx(_T("mscoree.dll"), NULL, 0 );
  8884. if (hMsCoreeDll)
  8885. {
  8886. hProcGetSystemPath = (P_GetCORSystemDirectory) GetProcAddress(hMsCoreeDll, "GetCORSystemDirectory");
  8887. if (hProcGetSystemPath)
  8888. {
  8889. // should come back looking like (notice trailing slash):"C:\WINDOWS\Microsoft.NET\Framework\v1.0.3119\"
  8890. HRESULT hRes = (*hProcGetSystemPath)((LPWSTR) wszSystemDir,(DWORD) _MAX_PATH,(DWORD*) &dwLength);
  8891. if (SUCCEEDED(hRes))
  8892. {
  8893. bRet = TRUE;
  8894. #if defined(UNICODE) || defined(_UNICODE)
  8895. _tcscpy(lpszDir,wszSystemDir);
  8896. #else
  8897. char AsciiProcedureName[_MAX_PATH];
  8898. // convert to ascii
  8899. WideCharToMultiByte( CP_ACP, 0, (LPCWSTR) wszSystemDir, -1, AsciiProcedureName, _MAX_PATH, NULL, NULL );
  8900. _tcscpy(lpszDir,AsciiProcedureName);
  8901. #endif
  8902. // Ensure that it ends with a "\"
  8903. LPTSTR pszTempPointer = lpszDir + _tcslen(lpszDir) - 1;
  8904. if (pszTempPointer)
  8905. {
  8906. if (*pszTempPointer != _T('\\'))
  8907. {
  8908. _tcscat(lpszDir, _T("\\"));
  8909. }
  8910. }
  8911. goto GetASPNETSystemDir_Exit;
  8912. }
  8913. }
  8914. }
  8915. // try using method#2
  8916. if (!bRet)
  8917. {
  8918. CRegKey regKeyPath(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\.NETFramework"),KEY_READ);
  8919. if ((HKEY)regKeyPath)
  8920. {
  8921. CString csPathResult;
  8922. CString csPathVersion;
  8923. // get the path
  8924. // should come back looking like: "C:\WINDOWS\Microsoft.NET\Framework\"
  8925. if (regKeyPath.QueryValue(_T("InstallRoot"), csPathResult) != ERROR_SUCCESS)
  8926. {
  8927. goto GetASPNETSystemDir_Exit;
  8928. }
  8929. // do any expansions if we need to
  8930. if (-1 != csPathResult.Find(_T('%')) )
  8931. {
  8932. // there is a '%' in the string
  8933. TCHAR szTempDir[_MAX_PATH];
  8934. _tcscpy(szTempDir, csPathResult);
  8935. if (ExpandEnvironmentStrings( (LPCTSTR)csPathResult, szTempDir, sizeof(szTempDir)/sizeof(TCHAR)))
  8936. {
  8937. csPathResult = szTempDir;
  8938. }
  8939. }
  8940. //key=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\v1.0
  8941. //name=3119
  8942. //value=0-3119
  8943. CRegKey regKey(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\.NETFramework\\policy\\v1.0"),KEY_READ);
  8944. if ((HKEY)regKey)
  8945. {
  8946. // Enum thru the entries in this key
  8947. // since there will be one for every .netframework installation
  8948. // and we want the latest one...
  8949. CRegValueIter regEnum( regKey );
  8950. CString csName, csValue;
  8951. int iTheBiggestNumberYet = 0;
  8952. while ( regEnum.Next( &csName, &csValue ) == ERROR_SUCCESS )
  8953. {
  8954. if (_ttoi(csName) > iTheBiggestNumberYet)
  8955. {
  8956. csPathVersion = csName;
  8957. iTheBiggestNumberYet = _ttoi(csName);
  8958. }
  8959. }
  8960. }
  8961. // Append the biggest version number onto the path...
  8962. // so it looks like:"C:\WINDOWS\Microsoft.NET\Framework\v1.0.3119\"
  8963. // Ensure that it ends with a "\"
  8964. LPTSTR pszTempPointer = csPathResult.GetBuffer(_tcslen(csPathResult)) + _tcslen(csPathResult) - 1;
  8965. csPathResult.ReleaseBuffer();
  8966. if (pszTempPointer)
  8967. {
  8968. if (*pszTempPointer != _T('\\'))
  8969. {
  8970. csPathResult += _T('\\');
  8971. }
  8972. }
  8973. csPathResult = csPathResult + _T("v1.0.") + csPathVersion + _T("\\");
  8974. _tcscpy(lpszDir,csPathResult);
  8975. bRet = TRUE;
  8976. }
  8977. }
  8978. // try getting the filversion of mscoree.dll
  8979. // and using that version to create the path
  8980. if (!bRet)
  8981. {
  8982. TCHAR szSystemDir[_MAX_PATH];
  8983. TCHAR szFullPath[_MAX_PATH];
  8984. DWORD dwMSVer, dwLSVer = 0;
  8985. TCHAR szLocalizedVersion[100] = _T("");
  8986. // get the c:\winnt\system32 dir
  8987. if (0 == GetSystemDirectory(szSystemDir, _MAX_PATH))
  8988. {goto GetASPNETSystemDir_Exit;}
  8989. // Tack on the filename
  8990. _stprintf(szFullPath, _T("%s\\mscoree.dll"),szSystemDir);
  8991. // get the fileversion.
  8992. if (TRUE != IsFileExist(szFullPath))
  8993. {goto GetASPNETSystemDir_Exit;}
  8994. MyGetVersionFromFile(szFullPath, &dwMSVer, &dwLSVer, szLocalizedVersion);
  8995. if (dwMSVer != 0)
  8996. {
  8997. // create the path
  8998. // "C:\WINDOWS\Microsoft.NET\Framework\v1.0.3119\"
  8999. if (0 == GetWindowsDirectory(szSystemDir, _MAX_PATH))
  9000. {goto GetASPNETSystemDir_Exit;}
  9001. _stprintf(lpszDir, _T("%s\\Microsoft.NET\\Framework\\v%d.%d.%d\\"),szSystemDir,HIWORD(dwMSVer), LOWORD(dwMSVer), HIWORD(dwLSVer));
  9002. bRet = TRUE;
  9003. }
  9004. }
  9005. GetASPNETSystemDir_Exit:
  9006. if (hMsCoreeDll){FreeLibrary(hMsCoreeDll);}
  9007. return bRet;
  9008. }
  9009. // UpdateAnonymousUsers
  9010. //
  9011. // Update the inf, with the correct users for removal.
  9012. //
  9013. BOOL
  9014. UpdateAnonymousUsers( HINF InfHandle )
  9015. {
  9016. TSTR strData;
  9017. TSTR strPassword;
  9018. TSTR strAnonymousPrefix;
  9019. BOOL bGuestIsSet = FALSE;
  9020. if ( !strData.Resize( MAX_PATH ) ||
  9021. !strPassword.Resize( MAX_PATH ) ||
  9022. !strAnonymousPrefix.LoadString( IDS_GUEST_NAME ) )
  9023. {
  9024. return FALSE;
  9025. }
  9026. if ( GetDataFromMetabase(METABASEPATH_WWW_ROOT, MD_ANONYMOUS_USER_NAME, (PBYTE)strData.QueryStr(), strData.QuerySize()))
  9027. {
  9028. // Set WWW Info
  9029. g_pTheApp->m_csWWWAnonyName_Remove = strData.QueryStr();
  9030. if ( g_pTheApp->IsUpgrade() &&
  9031. ( _tcsnicmp( strAnonymousPrefix.QueryStr(),
  9032. strData.QueryStr(),
  9033. _tcslen( strAnonymousPrefix.QueryStr() ) ) == 0 ) &&
  9034. GetDataFromMetabase( METABASEPATH_WWW_ROOT,
  9035. MD_ANONYMOUS_PWD,
  9036. (PBYTE)strPassword.QueryStr(),
  9037. strPassword.QuerySize() )
  9038. )
  9039. {
  9040. // The username here is the anonymous user, so lets use it, instead of our
  9041. // newly created one (machines names may have changed)
  9042. g_pTheApp->m_csWWWAnonyName = strData.QueryStr();
  9043. g_pTheApp->m_csGuestName = strData.QueryStr();
  9044. g_pTheApp->m_csGuestPassword = strPassword.QueryStr();
  9045. g_pTheApp->m_csWWWAnonyPassword = strPassword.QueryStr();
  9046. bGuestIsSet = TRUE;
  9047. }
  9048. }
  9049. if ( GetDataFromMetabase(_T("LM/MSFTPSVC"), MD_ANONYMOUS_USER_NAME, (PBYTE)strData.QueryStr(), strData.QuerySize()))
  9050. {
  9051. // Set FTP Info
  9052. g_pTheApp->m_csFTPAnonyName_Remove = strData.QueryStr();
  9053. if ( g_pTheApp->IsUpgrade() &&
  9054. ( _tcsnicmp( strAnonymousPrefix.QueryStr(),
  9055. strData.QueryStr(),
  9056. _tcslen( strAnonymousPrefix.QueryStr() ) ) == 0 ) &&
  9057. GetDataFromMetabase( _T("LM/MSFTPSVC"),
  9058. MD_ANONYMOUS_PWD,
  9059. (PBYTE)strPassword.QueryStr(),
  9060. strPassword.QuerySize())
  9061. )
  9062. {
  9063. // The username here is the anonymous FTP user, so lets use it, instead of our
  9064. // newly created one (machines names may have changed)
  9065. g_pTheApp->m_csFTPAnonyName = strData.QueryStr();
  9066. g_pTheApp->m_csFTPAnonyPassword = strPassword.QueryStr();
  9067. if ( !bGuestIsSet )
  9068. {
  9069. g_pTheApp->m_csGuestName = strData.QueryStr();
  9070. g_pTheApp->m_csGuestPassword = strPassword.QueryStr();
  9071. }
  9072. }
  9073. }
  9074. if ( GetDataFromMetabase(METABASEPATH_WWW_ROOT, MD_WAM_USER_NAME, (PBYTE)strData.QueryStr(), strData.QuerySize()))
  9075. {
  9076. g_pTheApp->m_csWAMAccountName_Remove = strData.QueryStr();
  9077. }
  9078. return TRUE;
  9079. }
  9080. // this will be called during oc_init
  9081. // and right before oc_complete and oc_about_to_commit_queue
  9082. void SetDIRIDforThisInf(HINF InfHandle,BOOL bOCInit)
  9083. {
  9084. BOOL bTempFlag = FALSE;
  9085. TCHAR szTempDir[_MAX_PATH];
  9086. // set everything if bOCInit is specified.
  9087. // but if it's not specified then
  9088. // set ID's which were not available at oc_init time...
  9089. GetASPNETSystemDir(szTempDir);
  9090. bTempFlag = SetupSetDirectoryId_Wrapper(InfHandle, 32781, szTempDir);
  9091. if (FALSE == bOCInit)
  9092. {
  9093. g_pTheApp->ReGetMachineAndAccountNames();
  9094. CString csMachineName = g_pTheApp->m_csMachineName.Right(g_pTheApp->m_csMachineName.GetLength() - 2);
  9095. SetupSetStringId_Wrapper(g_pTheApp->m_hInfHandle, 32800, csMachineName);
  9096. UpdateAnonymousUsers( InfHandle );
  9097. if ( _tcsicmp(g_pTheApp->m_csWAMAccountName_Remove, _T("")) == 0)
  9098. {g_pTheApp->m_csWAMAccountName_Remove = g_pTheApp->m_csWAMAccountName;}
  9099. SetupSetStringId_Wrapper(InfHandle, 33004, g_pTheApp->m_csWAMAccountName_Remove);
  9100. if ( _tcsicmp(g_pTheApp->m_csWWWAnonyName_Remove, _T("")) == 0)
  9101. {g_pTheApp->m_csWWWAnonyName_Remove = g_pTheApp->m_csWWWAnonyName; }
  9102. SetupSetStringId_Wrapper(InfHandle, 33005, g_pTheApp->m_csWWWAnonyName_Remove);
  9103. if ( _tcsicmp(g_pTheApp->m_csWWWAnonyName_Remove, _T("")) == 0)
  9104. {g_pTheApp->m_csFTPAnonyName_Remove = g_pTheApp->m_csFTPAnonyName;}
  9105. SetupSetStringId_Wrapper(InfHandle, 33006, g_pTheApp->m_csFTPAnonyName_Remove);
  9106. SetupSetStringId_Wrapper(InfHandle, 33000, g_pTheApp->m_csGuestName);
  9107. SetupSetStringId_Wrapper(InfHandle, 33002, g_pTheApp->m_csWWWAnonyName);
  9108. SetupSetStringId_Wrapper(InfHandle, 33003, g_pTheApp->m_csFTPAnonyName);
  9109. }
  9110. else
  9111. {
  9112. // Create Directory IDs for the coresponding .inf file
  9113. bTempFlag = SetupSetDirectoryId_Wrapper(InfHandle, 32768, g_pTheApp->m_csPathInetsrv);
  9114. bTempFlag = SetupSetDirectoryId_Wrapper(InfHandle, 32769, g_pTheApp->m_csPathFTPRoot);
  9115. bTempFlag = SetupSetDirectoryId_Wrapper(InfHandle, 32770, g_pTheApp->m_csPathWWWRoot);
  9116. bTempFlag = SetupSetDirectoryId_Wrapper(InfHandle, 32771, g_pTheApp->m_csPathIISSamples);
  9117. bTempFlag = SetupSetDirectoryId_Wrapper(InfHandle, 32772, g_pTheApp->m_csPathScripts);
  9118. bTempFlag = SetupSetDirectoryId_Wrapper(InfHandle, 32773, g_pTheApp->m_csPathInetpub);
  9119. bTempFlag = SetupSetDirectoryId_Wrapper(InfHandle, 32774, g_pTheApp->m_csPathOldInetsrv);
  9120. bTempFlag = SetupSetDirectoryId_Wrapper(InfHandle, 32780, g_pTheApp->m_csSysDrive);
  9121. if (g_pTheApp->m_eUpgradeType == UT_10_W95)
  9122. {
  9123. bTempFlag = SetupSetDirectoryId_Wrapper(InfHandle, 32775, g_pTheApp->m_csPathOldPWSFiles);
  9124. bTempFlag = SetupSetDirectoryId_Wrapper(InfHandle, 32776, g_pTheApp->m_csPathOldPWSSystemFiles);
  9125. }
  9126. GetJavaTLD(szTempDir);
  9127. bTempFlag = SetupSetDirectoryId_Wrapper(InfHandle, 32778, szTempDir);
  9128. SetupSetDirectoryId_Wrapper(InfHandle, 32777, g_pTheApp->m_csPathProgramFiles);
  9129. SetupSetDirectoryId_Wrapper(InfHandle, 32779, g_pTheApp->m_csPathWebPub);
  9130. if (g_pTheApp->m_eUpgradeType == UT_NONE){SetupSetStringId_Wrapper(InfHandle, 32801, _T("UT_NONE"));}
  9131. if (g_pTheApp->m_eUpgradeType == UT_351){SetupSetStringId_Wrapper(InfHandle, 32801, _T("UT_351"));}
  9132. if (g_pTheApp->m_eUpgradeType == UT_10){SetupSetStringId_Wrapper(InfHandle, 32801, _T("UT_10"));}
  9133. if (g_pTheApp->m_eUpgradeType == UT_20){SetupSetStringId_Wrapper(InfHandle, 32801, _T("UT_20"));}
  9134. if (g_pTheApp->m_eUpgradeType == UT_30){SetupSetStringId_Wrapper(InfHandle, 32801, _T("UT_30"));}
  9135. if (g_pTheApp->m_eUpgradeType == UT_40){SetupSetStringId_Wrapper(InfHandle, 32801, _T("UT_40"));} // can also be from win95
  9136. if (g_pTheApp->m_eUpgradeType == UT_50){SetupSetStringId_Wrapper(InfHandle, 32801, _T("UT_50"));}
  9137. if (g_pTheApp->m_eUpgradeType == UT_51){SetupSetStringId_Wrapper(InfHandle, 32801, _T("UT_51"));}
  9138. if (g_pTheApp->m_eUpgradeType == UT_60){SetupSetStringId_Wrapper(InfHandle, 32801, _T("UT_60"));}
  9139. if (g_pTheApp->m_eUpgradeType == UT_10_W95){SetupSetStringId_Wrapper(InfHandle, 32801, _T("UT_10_W95"));}
  9140. CString csMachineName = g_pTheApp->m_csMachineName.Right(g_pTheApp->m_csMachineName.GetLength() - 2);
  9141. SetupSetStringId_Wrapper(InfHandle, 32800, csMachineName);
  9142. SetupSetStringId_Wrapper(InfHandle, 32802, _T(""));
  9143. SetupSetStringId_Wrapper(InfHandle, 33000, g_pTheApp->m_csGuestName);
  9144. SetupSetStringId_Wrapper(InfHandle, 33001, g_pTheApp->m_csWAMAccountName);
  9145. SetupSetStringId_Wrapper(InfHandle, 33002, g_pTheApp->m_csWWWAnonyName);
  9146. SetupSetStringId_Wrapper(InfHandle, 33003, g_pTheApp->m_csFTPAnonyName);
  9147. if ( _tcsicmp(g_pTheApp->m_csWAMAccountName_Remove, _T("")) == 0)
  9148. {g_pTheApp->m_csWAMAccountName_Remove = g_pTheApp->m_csWAMAccountName;}
  9149. SetupSetStringId_Wrapper(InfHandle, 33004, g_pTheApp->m_csWAMAccountName_Remove);
  9150. if ( _tcsicmp(g_pTheApp->m_csWWWAnonyName_Remove, _T("")) == 0)
  9151. {g_pTheApp->m_csWWWAnonyName_Remove = g_pTheApp->m_csWWWAnonyName; }
  9152. SetupSetStringId_Wrapper(InfHandle, 33005, g_pTheApp->m_csWWWAnonyName_Remove);
  9153. if ( _tcsicmp(g_pTheApp->m_csWWWAnonyName_Remove, _T("")) == 0)
  9154. {g_pTheApp->m_csFTPAnonyName_Remove = g_pTheApp->m_csFTPAnonyName;}
  9155. SetupSetStringId_Wrapper(InfHandle, 33006, g_pTheApp->m_csFTPAnonyName_Remove);
  9156. SYSTEM_INFO SystemInfo;
  9157. GetSystemInfo( &SystemInfo );
  9158. TCHAR szSourceCatOSName[20];
  9159. _tcscpy(szSourceCatOSName, _T("\\i386"));
  9160. switch(SystemInfo.wProcessorArchitecture)
  9161. {
  9162. case PROCESSOR_ARCHITECTURE_AMD64:
  9163. _tcscpy(szSourceCatOSName, _T("\\AMD64"));
  9164. break;
  9165. // case PROCESSOR_ARCHITECTURE_IA64:
  9166. // _tcscpy(szSourceCatOSName, _T("\\IA64"));
  9167. // break;
  9168. case PROCESSOR_ARCHITECTURE_INTEL:
  9169. if (IsNEC_98) {_tcscpy(szSourceCatOSName, _T("\\Nec98"));}
  9170. break;
  9171. default:
  9172. break;
  9173. }
  9174. SetupSetStringId_Wrapper(InfHandle, 34000, szSourceCatOSName);
  9175. }
  9176. return;
  9177. }
  9178. BOOL GetJavaTLD(LPTSTR lpszDir)
  9179. {
  9180. CRegKey regKey(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\JAVA VM"),KEY_READ);
  9181. BOOL bFound = FALSE;
  9182. CString csValue;
  9183. CString csValue2;
  9184. int iWhere = -1;
  9185. if ((HKEY)regKey)
  9186. {
  9187. regKey.m_iDisplayWarnings = FALSE;
  9188. if (regKey.QueryValue(_T("TrustedLibsDirectory"), csValue) == ERROR_SUCCESS) {bFound = TRUE;}
  9189. // Warning: we are expecting something like this = "C:\WINNT\java\trustlib"
  9190. // However, recently 12/18 the nt5 "java vm" setup seems to be hosing and passing us:
  9191. // %systemroot%\java\trustlib
  9192. if (-1 != csValue.Find(_T('%')) )
  9193. {
  9194. // there is a '%' in the string
  9195. TCHAR szTempDir[_MAX_PATH];
  9196. _tcscpy(szTempDir, csValue);
  9197. if (ExpandEnvironmentStrings( (LPCTSTR)csValue, szTempDir, sizeof(szTempDir)/sizeof(TCHAR)))
  9198. {
  9199. csValue = szTempDir;
  9200. }
  9201. }
  9202. /*
  9203. // if we see %systemroot% in there then, i'm going to substitute WinDir in place of %Systemroot%
  9204. csValue.MakeUpper();
  9205. if (csValue.Find(_T("%SYSTEMROOT%")) != (-1) )
  9206. {
  9207. // We Found the cheesy %systemroot% deal. Now replace it with the real systemroot
  9208. iWhere = csValue.Find(_T("%SYSTEMROOT%"));
  9209. iWhere = iWhere + _tcslen(_T("%SYSTEMROOT%"));
  9210. csValue2 = g_pTheApp->m_csWinDir + csValue.Right( csValue.GetLength() - (iWhere) );
  9211. csValue = csValue2;
  9212. }
  9213. */
  9214. }
  9215. if (!bFound) {csValue = g_pTheApp->m_csWinDir + _T("\\Java\\TrustLib");}
  9216. _tcscpy(lpszDir, csValue);
  9217. return bFound;
  9218. }
  9219. void ShowStateOfTheseServices(IN HINF hFile)
  9220. {
  9221. CStringList strList;
  9222. DWORD dwStatus;
  9223. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T(" --- Display status of services which are required for IIS to run --- \n")));
  9224. TSTR strTheSection;
  9225. if ( !strTheSection.Copy( _T("VerifyServices") ) )
  9226. {
  9227. return;
  9228. }
  9229. if (GetSectionNameToDo(hFile, &strTheSection))
  9230. {
  9231. if (ERROR_SUCCESS == FillStrListWithListOfSections(hFile, strList, strTheSection.QueryStr() ))
  9232. {
  9233. // loop thru the list returned back
  9234. if (strList.IsEmpty() == FALSE)
  9235. {
  9236. POSITION pos;
  9237. CString csEntry;
  9238. pos = strList.GetHeadPosition();
  9239. while (pos)
  9240. {
  9241. csEntry = strList.GetAt(pos);
  9242. // Display state of this service.
  9243. dwStatus = InetQueryServiceStatus(csEntry);
  9244. switch(dwStatus)
  9245. {
  9246. case SERVICE_STOPPED:
  9247. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("SERVICE_STOPPED [%s].\n"), csEntry));
  9248. break;
  9249. case SERVICE_START_PENDING:
  9250. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("SERVICE_START_PENDING [%s].\n"), csEntry));
  9251. break;
  9252. case SERVICE_STOP_PENDING:
  9253. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("SERVICE_STOP_PENDING [%s].\n"), csEntry));
  9254. break;
  9255. case SERVICE_RUNNING:
  9256. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("SERVICE_RUNNING [%s].\n"), csEntry));
  9257. break;
  9258. case SERVICE_CONTINUE_PENDING:
  9259. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("SERVICE_CONTINUE_PENDING [%s].\n"), csEntry));
  9260. break;
  9261. case SERVICE_PAUSE_PENDING:
  9262. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("SERVICE_PAUSE_PENDING [%s].\n"), csEntry));
  9263. break;
  9264. case SERVICE_PAUSED:
  9265. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("SERVICE_PAUSED [%s].\n"), csEntry));
  9266. break;
  9267. }
  9268. strList.GetNext(pos);
  9269. }
  9270. }
  9271. }
  9272. }
  9273. return;
  9274. }
  9275. #define MD_SIGNATURE_STRINGA "*&$MetaData$&*"
  9276. #define MD_SIGNATURE_STRINGW L##"*&$MetaData$&*"
  9277. int IsMetabaseCorrupt(void)
  9278. {
  9279. // We've had a problem where sometimes the metabase.bin file
  9280. // gets corrupted and set to only spaces...
  9281. // so this function is here to determine where and when the metabase.bin is hosed!
  9282. int iTheMetabaseIsCorrupt = FALSE;
  9283. TCHAR szSystemDir[_MAX_PATH];
  9284. TCHAR szFullPath[_MAX_PATH];
  9285. HANDLE hReadFileHandle = INVALID_HANDLE_VALUE;
  9286. BYTE *chBuffer = NULL;
  9287. DWORD dwSize = 0;
  9288. DWORD dwWideSignatureLen = 0;
  9289. DWORD dwAnsiSignatureLen = 0;
  9290. TCHAR buf[MAX_FAKE_METABASE_STRING_LEN];
  9291. // get the c:\winnt\system32 dir
  9292. if (0 == GetSystemDirectory(szSystemDir, _MAX_PATH))
  9293. {goto IsMetabaseCorrupt_Exit;}
  9294. // Tack on the inf\iis.inf subdir and filename
  9295. _stprintf(szFullPath, _T("%s\\inetsrv\\metabase.bin"),szSystemDir);
  9296. // Check if the file exists
  9297. if (TRUE != IsFileExist(szFullPath))
  9298. {
  9299. iTheMetabaseIsCorrupt = FALSE;
  9300. // this function only works on version less than or equal to iis5
  9301. // since that's the only versions which had a metabase.bin file
  9302. // so just return that the metabase is not corrupt
  9303. goto IsMetabaseCorrupt_Exit;
  9304. }
  9305. // okay, so the metabase.bin file exists...
  9306. // let's open it and see if we can get something out of it.
  9307. //
  9308. // Open the file.
  9309. //
  9310. hReadFileHandle = CreateFile(szFullPath,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
  9311. if (hReadFileHandle == INVALID_HANDLE_VALUE)
  9312. {
  9313. iisDebugOut((LOG_TYPE_WARN, _T("IsMetabaseCorrupt: CreateFile on %s failed with 0x%x!\n"),szFullPath,GetLastError()));
  9314. goto IsMetabaseCorrupt_Exit;
  9315. }
  9316. dwSize = GetFileSize(hReadFileHandle, NULL);
  9317. dwWideSignatureLen = sizeof(MD_SIGNATURE_STRINGW);
  9318. dwAnsiSignatureLen = sizeof(MD_SIGNATURE_STRINGA);
  9319. // get the size of the whole file
  9320. //chBuffer = (BYTE *)HeapAlloc(GetProcessHeap(), 0, dwSize+1 );
  9321. if ((dwSize) >= dwWideSignatureLen)
  9322. {
  9323. chBuffer = (BYTE *)HeapAlloc(GetProcessHeap(), 0, dwWideSignatureLen+1);
  9324. dwSize = dwWideSignatureLen+1;
  9325. }
  9326. else
  9327. {
  9328. if ( dwSize >= dwAnsiSignatureLen)
  9329. {
  9330. chBuffer = (BYTE *)HeapAlloc(GetProcessHeap(), 0, dwAnsiSignatureLen+1 );
  9331. dwSize = dwAnsiSignatureLen+1;
  9332. }
  9333. else
  9334. {
  9335. iisDebugOut((LOG_TYPE_WARN, _T("IsMetabaseCorrupt: ReadFile on %s. Not enough data in there! Less than metabase signature len!\n"),szFullPath));
  9336. // Things are not kool
  9337. // This metabase must be hosed!
  9338. iTheMetabaseIsCorrupt = FALSE;
  9339. goto IsMetabaseCorrupt_Exit;
  9340. }
  9341. }
  9342. if (!chBuffer)
  9343. {
  9344. iisDebugOut((LOG_TYPE_WARN, _T("IsMetabaseCorrupt: HeapAlloc failed to get %d space.\n"),dwWideSignatureLen+1));
  9345. goto IsMetabaseCorrupt_Exit;
  9346. }
  9347. SetFilePointer(hReadFileHandle,0,0,FILE_BEGIN);
  9348. // kool, try to read the file
  9349. if (0 == ReadFile(hReadFileHandle, chBuffer, dwSize, &dwSize, NULL))
  9350. {
  9351. iisDebugOut((LOG_TYPE_WARN, _T("IsMetabaseCorrupt: ReadFile on %s failed with 0x%x!. size=%d\n"),szFullPath,GetLastError(),dwSize));
  9352. goto IsMetabaseCorrupt_Exit;
  9353. }
  9354. //
  9355. // take chBuffer and check if it matches the unicode/ansi signature.
  9356. //
  9357. if (0 == memcmp(MD_SIGNATURE_STRINGW,chBuffer,dwWideSignatureLen))
  9358. {
  9359. // things are kool, and this metabase should not be hosed.
  9360. iTheMetabaseIsCorrupt = FALSE;
  9361. goto IsMetabaseCorrupt_Exit;
  9362. }
  9363. if (0 == memcmp(MD_SIGNATURE_STRINGA,chBuffer,dwAnsiSignatureLen))
  9364. {
  9365. // if not, then check if it matches the ansi signature.
  9366. // things are kool, and this metabase should not be hosed.
  9367. iTheMetabaseIsCorrupt = FALSE;
  9368. goto IsMetabaseCorrupt_Exit;
  9369. }
  9370. // on other check...
  9371. // in iis6 there is a dummy fake metabase.bin put there by setup
  9372. // check if this is that dummy file.
  9373. if (chBuffer)
  9374. {HeapFree(GetProcessHeap(), 0, chBuffer); chBuffer = NULL;}
  9375. memset(buf, 0, _tcslen(buf) * sizeof(TCHAR));
  9376. // this iis.dll is always compiled unicode, so
  9377. // we know that buf is unicode
  9378. if (LoadString((HINSTANCE) g_MyModuleHandle, IDS_FAKE_METABASE_BIN_TEXT, buf, MAX_FAKE_METABASE_STRING_LEN))
  9379. {
  9380. dwSize = _tcslen(buf) * sizeof(TCHAR);
  9381. // add space for the FF and FE bytes
  9382. dwSize = dwSize + 2;
  9383. // open the file
  9384. SetFilePointer(hReadFileHandle,0,0,FILE_BEGIN);
  9385. chBuffer = (BYTE *)HeapAlloc(GetProcessHeap(), 0, dwSize);
  9386. // kool, try to read the file
  9387. if (0 == ReadFile(hReadFileHandle, chBuffer, dwSize, &dwSize, NULL))
  9388. {
  9389. iisDebugOut((LOG_TYPE_WARN, _T("IsMetabaseCorrupt: ReadFile on %s failed with 0x%x!. size=%d\n"),szFullPath,GetLastError(),dwSize));
  9390. goto IsMetabaseCorrupt_Exit;
  9391. }
  9392. // check if the input file is unicode
  9393. if (0xFF == chBuffer[0] && 0xFE == chBuffer[1])
  9394. {
  9395. // skip past these characters
  9396. chBuffer++;
  9397. chBuffer++;
  9398. // Compare what you got with what we think is in there
  9399. if (0 == memcmp(buf,chBuffer,dwSize))
  9400. {
  9401. // things are kool, and this metabase should not be hosed.
  9402. chBuffer--;
  9403. chBuffer--;
  9404. iTheMetabaseIsCorrupt = FALSE;
  9405. goto IsMetabaseCorrupt_Exit;
  9406. }
  9407. chBuffer--;
  9408. chBuffer--;
  9409. }
  9410. }
  9411. // if not then, it must be corrupt!
  9412. // Things are not kool
  9413. // This metabase must be hosed!
  9414. iTheMetabaseIsCorrupt = TRUE;
  9415. iisDebugOut((LOG_TYPE_WARN, _T("IsMetabaseCorrupt: unable to verify signature in Metabase.bin. Corrupt.\n")));
  9416. IsMetabaseCorrupt_Exit:
  9417. if (chBuffer)
  9418. {HeapFree(GetProcessHeap(), 0, chBuffer);}
  9419. if (hReadFileHandle != INVALID_HANDLE_VALUE)
  9420. {CloseHandle(hReadFileHandle);}
  9421. return iTheMetabaseIsCorrupt;
  9422. }
  9423. void iisDebugOut_Start(TCHAR *pszString, int iLogType)
  9424. {
  9425. iisDebugOut((iLogType, _T("%s:Start.\n"),pszString));
  9426. return;
  9427. }
  9428. void iisDebugOut_Start1(TCHAR *pszString1, TCHAR *pszString2, int iLogType)
  9429. {
  9430. iisDebugOut((iLogType, _T("%s:(%s)Start.\n"),pszString1,pszString2));
  9431. return;
  9432. }
  9433. void iisDebugOut_Start1(TCHAR *pszString1, CString pszString2, int iLogType)
  9434. {
  9435. iisDebugOut((iLogType, _T("%s:(%s)Start.\n"),pszString1,pszString2));
  9436. return;
  9437. }
  9438. void iisDebugOut_End(TCHAR *pszString, int iLogType)
  9439. {
  9440. iisDebugOut((iLogType, _T("%s:End.\n"),pszString));
  9441. return;
  9442. }
  9443. void iisDebugOut_End1(TCHAR *pszString1, TCHAR *pszString2, int iLogType)
  9444. {
  9445. iisDebugOut((iLogType, _T("%s(%s):End.\n"),pszString1, pszString2));
  9446. return;
  9447. }
  9448. void iisDebugOut_End1(TCHAR *pszString1, CString pszString2, int iLogType)
  9449. {
  9450. iisDebugOut((iLogType, _T("%s(%s):End.\n"),pszString1,pszString2));
  9451. return;
  9452. }
  9453. BOOL SetupFindFirstLine_Wrapped(
  9454. IN HINF InfHandle,
  9455. IN LPCTSTR Section,
  9456. IN LPCTSTR Key, OPTIONAL
  9457. INFCONTEXT *Context
  9458. )
  9459. {
  9460. BOOL bReturn = FALSE;
  9461. BOOL bGoGetWhatTheyOriginallyWanted = TRUE;
  9462. // check for the alternate .inf file
  9463. if (g_pTheApp->m_hInfHandleAlternate && InfHandle != g_pTheApp->m_hInfHandleAlternate)
  9464. {
  9465. bReturn = SetupFindFirstLine(g_pTheApp->m_hInfHandleAlternate, Section, Key, Context);
  9466. if (bReturn)
  9467. {
  9468. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("Using alternate iis.inf section:[%s]"),Section));
  9469. bGoGetWhatTheyOriginallyWanted = FALSE;
  9470. }
  9471. }
  9472. if (bGoGetWhatTheyOriginallyWanted)
  9473. {bReturn = SetupFindFirstLine(InfHandle, Section, Key, Context);}
  9474. return bReturn;
  9475. }
  9476. int ReadUserConfigurable(HINF InfHandle)
  9477. {
  9478. int iReturn = TRUE;
  9479. INFCONTEXT Context;
  9480. TCHAR szTempString[_MAX_PATH] = _T("");
  9481. DWORD dwValue = 0x0;
  9482. DWORD dwSomethingSpecifiedHere = 0;
  9483. //
  9484. // Get the IUSR name
  9485. //
  9486. _tcscpy(szTempString, _T(""));
  9487. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupConfig"), _T("IUSR"), &Context) )
  9488. {
  9489. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  9490. {
  9491. // WARNING: these values can be changed by a user supplied unattend file
  9492. // The User defined unattend file takes precidence over these!
  9493. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_WWW_USER_NAME))
  9494. {
  9495. g_pTheApp->m_csWWWAnonyName_Unattend = szTempString;
  9496. dwSomethingSpecifiedHere |= USER_SPECIFIED_INFO_WWW_USER_NAME;
  9497. //g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_WWW_USER_NAME;
  9498. iisDebugOut((LOG_TYPE_TRACE, _T("Custom iusr specified for www\n")));
  9499. }
  9500. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_FTP_USER_NAME))
  9501. {
  9502. g_pTheApp->m_csFTPAnonyName_Unattend = szTempString;
  9503. dwSomethingSpecifiedHere |= USER_SPECIFIED_INFO_FTP_USER_NAME;
  9504. //g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_FTP_USER_NAME;
  9505. iisDebugOut((LOG_TYPE_TRACE, _T("Custom iusr specified for ftp\n")));
  9506. }
  9507. }
  9508. }
  9509. /*
  9510. // this stuff should not be configurable from the iis.inf file
  9511. //
  9512. // Get the IUSR password
  9513. //
  9514. _tcscpy(szTempString, _T(""));
  9515. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupConfig"), _T("IUSR_PASS"), &Context) )
  9516. {
  9517. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  9518. {
  9519. // WARNING: these values can be changed by a user supplied unattend file
  9520. // The User defined unattend file takes precidence over these!
  9521. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_WWW_USER_PASS))
  9522. {
  9523. if (_tcsicmp(szTempString, _T("")) != 0)
  9524. {
  9525. if (_tcsicmp(szTempString, _T("(blank)")) == 0)
  9526. {
  9527. _tcscpy(szTempString, _T(""));
  9528. }
  9529. g_pTheApp->m_csWWWAnonyPassword_Unattend = szTempString;
  9530. dwSomethingSpecifiedHere |= USER_SPECIFIED_INFO_WWW_USER_PASS;
  9531. //g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_WWW_USER_PASS;
  9532. iisDebugOut((LOG_TYPE_TRACE, _T("Custom iusr pass specified for www\n")));
  9533. }
  9534. }
  9535. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_FTP_USER_PASS))
  9536. {
  9537. if (_tcsicmp(szTempString, _T("")) != 0)
  9538. {
  9539. if (_tcsicmp(szTempString, _T("(blank)")) == 0)
  9540. {
  9541. _tcscpy(szTempString, _T(""));
  9542. }
  9543. g_pTheApp->m_csFTPAnonyPassword_Unattend = szTempString;
  9544. dwSomethingSpecifiedHere |= USER_SPECIFIED_INFO_FTP_USER_PASS;
  9545. //g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_FTP_USER_PASS;
  9546. iisDebugOut((LOG_TYPE_TRACE, _T("Custom iusr pass specified for ftp\n")));
  9547. }
  9548. }
  9549. }
  9550. }
  9551. */
  9552. //
  9553. // Get the IUSR name for WWW
  9554. //
  9555. _tcscpy(szTempString, _T(""));
  9556. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupConfig"), _T("IUSR_WWW"), &Context) )
  9557. {
  9558. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  9559. {
  9560. // WARNING: these values can be changed by a user supplied unattend file
  9561. // The User defined unattend file takes precidence over these!
  9562. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_WWW_USER_NAME))
  9563. {
  9564. g_pTheApp->m_csWWWAnonyName_Unattend = szTempString;
  9565. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_WWW_USER_NAME;
  9566. iisDebugOut((LOG_TYPE_TRACE, _T("Custom iusr specified for www\n")));
  9567. }
  9568. }
  9569. }
  9570. /*
  9571. // this stuff should not be configurable from the iis.inf file
  9572. //
  9573. // Get the IUSR pass for WWW
  9574. //
  9575. _tcscpy(szTempString, _T(""));
  9576. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupConfig"), _T("IUSR_WWW_PASS"), &Context) )
  9577. {
  9578. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  9579. {
  9580. // WARNING: these values can be changed by a user supplied unattend file
  9581. // The User defined unattend file takes precidence over these!
  9582. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_WWW_USER_PASS))
  9583. {
  9584. if (_tcsicmp(szTempString, _T("")) != 0)
  9585. {
  9586. if (_tcsicmp(szTempString, _T("(blank)")) == 0)
  9587. {
  9588. _tcscpy(szTempString, _T(""));
  9589. }
  9590. g_pTheApp->m_csWWWAnonyPassword_Unattend = szTempString;
  9591. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_WWW_USER_PASS;
  9592. iisDebugOut((LOG_TYPE_TRACE, _T("Custom iusr pass specified for www\n")));
  9593. }
  9594. }
  9595. }
  9596. }
  9597. */
  9598. //
  9599. // Get the IUSR name for FTP
  9600. //
  9601. _tcscpy(szTempString, _T(""));
  9602. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupConfig"), _T("IUSR_FTP"), &Context) )
  9603. {
  9604. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  9605. {
  9606. // WARNING: these values can be changed by a user supplied unattend file
  9607. // The User defined unattend file takes precidence over these!
  9608. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_FTP_USER_NAME))
  9609. {
  9610. g_pTheApp->m_csFTPAnonyName_Unattend = szTempString;
  9611. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_FTP_USER_NAME;
  9612. iisDebugOut((LOG_TYPE_TRACE, _T("Custom iusr specified for ftp\n")));
  9613. }
  9614. }
  9615. }
  9616. /*
  9617. // this stuff should not be configurable from the iis.inf file
  9618. //
  9619. // Get the IUSR password for FTP
  9620. //
  9621. _tcscpy(szTempString, _T(""));
  9622. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupConfig"), _T("IUSR_FTP_PASS"), &Context) )
  9623. {
  9624. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  9625. {
  9626. // WARNING: these values can be changed by a user supplied unattend file
  9627. // The User defined unattend file takes precidence over these!
  9628. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_FTP_USER_PASS))
  9629. {
  9630. if (_tcsicmp(szTempString, _T("")) != 0)
  9631. {
  9632. if (_tcsicmp(szTempString, _T("(blank)")) == 0)
  9633. {
  9634. _tcscpy(szTempString, _T(""));
  9635. }
  9636. g_pTheApp->m_csFTPAnonyPassword_Unattend = szTempString;
  9637. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_FTP_USER_PASS;
  9638. iisDebugOut((LOG_TYPE_TRACE, _T("Custom iusr pass specified for ftp\n")));
  9639. }
  9640. }
  9641. }
  9642. }
  9643. */
  9644. //
  9645. // Get the WAM username
  9646. //
  9647. _tcscpy(szTempString, _T(""));
  9648. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupConfig"), _T("IWAM"), &Context) )
  9649. {
  9650. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  9651. {
  9652. // WARNING: these values can be changed by a user supplied unattend file
  9653. // The User defined unattend file takes precidence over these!
  9654. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_WAM_USER_NAME))
  9655. {
  9656. g_pTheApp->m_csWAMAccountName_Unattend = szTempString;
  9657. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_WAM_USER_NAME;
  9658. iisDebugOut((LOG_TYPE_TRACE, _T("Custom iwam specified for www\n")));
  9659. }
  9660. }
  9661. }
  9662. /*
  9663. // this stuff should not be configurable from the iis.inf file
  9664. //
  9665. // Get the WAM password
  9666. //
  9667. _tcscpy(szTempString, _T(""));
  9668. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupConfig"), _T("IWAM_PASS"), &Context) )
  9669. {
  9670. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  9671. {
  9672. // WARNING: these values can be changed by a user supplied unattend file
  9673. // The User defined unattend file takes precidence over these!
  9674. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_WAM_USER_PASS))
  9675. {
  9676. if (_tcsicmp(szTempString, _T("")) != 0)
  9677. {
  9678. if (_tcsicmp(szTempString, _T("(blank)")) == 0)
  9679. {
  9680. _tcscpy(szTempString, _T(""));
  9681. }
  9682. g_pTheApp->m_csWAMAccountPassword_Unattend = szTempString;
  9683. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_WAM_USER_PASS;
  9684. iisDebugOut((LOG_TYPE_TRACE, _T("Custom iwam pass specified for www\n")));
  9685. }
  9686. }
  9687. }
  9688. }
  9689. */
  9690. //
  9691. // Get Path for Inetpub
  9692. //
  9693. _tcscpy(szTempString, _T(""));
  9694. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupConfig"), _T("PathInetpub"), &Context) )
  9695. {
  9696. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  9697. {
  9698. // WARNING: these values can be changed by a user supplied unattend file
  9699. // The User defined unattend file takes precidence over these!
  9700. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_PATH_INETPUB))
  9701. {
  9702. if (_tcsicmp(szTempString, _T("")) != 0)
  9703. {
  9704. if (IsValidDirectoryName(szTempString))
  9705. {
  9706. iisDebugOut((LOG_TYPE_TRACE, _T("Custom PathInetpub=%s\n"),szTempString));
  9707. g_pTheApp->m_csPathInetpub = szTempString;
  9708. g_pTheApp->SetInetpubDerivatives();
  9709. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_PATH_INETPUB;
  9710. }
  9711. else
  9712. {
  9713. iisDebugOut((LOG_TYPE_WARN, _T("Custom PathInetpub specified (%s), however path not valid.ignoring unattend value. WARNING.\n"),szTempString));
  9714. }
  9715. }
  9716. }
  9717. }
  9718. }
  9719. //
  9720. // Get Path for ftp root
  9721. //
  9722. _tcscpy(szTempString, _T(""));
  9723. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupConfig"), _T("PathFTPRoot"), &Context) )
  9724. {
  9725. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  9726. {
  9727. // WARNING: these values can be changed by a user supplied unattend file
  9728. // The User defined unattend file takes precidence over these!
  9729. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_PATH_FTP))
  9730. {
  9731. if (_tcsicmp(szTempString, _T("")) != 0)
  9732. {
  9733. if (IsValidDirectoryName(szTempString))
  9734. {
  9735. iisDebugOut((LOG_TYPE_TRACE, _T("Custom PathFTPRoot=%s\n"),szTempString));
  9736. CustomFTPRoot(szTempString);
  9737. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_PATH_FTP;
  9738. }
  9739. else
  9740. {
  9741. iisDebugOut((LOG_TYPE_WARN, _T("Custom PathFTPRoot specified (%s), however path not valid.ignoring unattend value. WARNING.\n"),szTempString));
  9742. }
  9743. }
  9744. }
  9745. }
  9746. }
  9747. //
  9748. // Get Path for www root
  9749. //
  9750. _tcscpy(szTempString, _T(""));
  9751. if (SetupFindFirstLine_Wrapped(InfHandle, _T("SetupConfig"), _T("PathWWWRoot"), &Context) )
  9752. {
  9753. if (SetupGetStringField(&Context, 1, szTempString, _MAX_PATH, NULL))
  9754. {
  9755. // WARNING: these values can be changed by a user supplied unattend file
  9756. // The User defined unattend file takes precidence over these!
  9757. if (!(g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_PATH_WWW))
  9758. {
  9759. if (_tcsicmp(szTempString, _T("")) != 0)
  9760. {
  9761. if (IsValidDirectoryName(szTempString))
  9762. {
  9763. iisDebugOut((LOG_TYPE_TRACE, _T("Custom PathWWWRoot=%s\n"),szTempString));
  9764. CustomWWWRoot(szTempString);
  9765. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_PATH_WWW;
  9766. }
  9767. else
  9768. {
  9769. iisDebugOut((LOG_TYPE_WARN, _T("Custom PathWWWRoot specified (%s), however path not valid.ignoring unattend value. WARNING.\n"),szTempString));
  9770. }
  9771. }
  9772. }
  9773. }
  9774. }
  9775. //ReadUserConfigurable_Exit:
  9776. if (dwSomethingSpecifiedHere & USER_SPECIFIED_INFO_WWW_USER_NAME){g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_WWW_USER_NAME;}
  9777. if (dwSomethingSpecifiedHere & USER_SPECIFIED_INFO_FTP_USER_NAME){g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_FTP_USER_NAME;}
  9778. if (dwSomethingSpecifiedHere & USER_SPECIFIED_INFO_WWW_USER_PASS){g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_WWW_USER_PASS;}
  9779. if (dwSomethingSpecifiedHere & USER_SPECIFIED_INFO_FTP_USER_PASS){g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_FTP_USER_PASS;}
  9780. return iReturn;
  9781. }
  9782. INT IsThisOnNotStopList(IN HINF hFile, CString csInputName, BOOL bServiceFlag)
  9783. {
  9784. INT iReturn = FALSE;
  9785. CStringList strList;
  9786. TSTR strTheSection;
  9787. // if the entry is not a service name,
  9788. // then it must be a process filename,
  9789. // so make sure to get just the end of it
  9790. if (!bServiceFlag)
  9791. {
  9792. TCHAR szJustTheFileName[_MAX_FNAME];
  9793. // make sure to get only just the filename.
  9794. if (TRUE == ReturnFileNameOnly(csInputName, szJustTheFileName))
  9795. {
  9796. csInputName = szJustTheFileName;
  9797. }
  9798. }
  9799. if ( strTheSection.Copy( _T("NonStopList") ) &&
  9800. GetSectionNameToDo(hFile, &strTheSection)
  9801. )
  9802. {
  9803. if (ERROR_SUCCESS == FillStrListWithListOfSections(hFile, strList, strTheSection.QueryStr() ))
  9804. {
  9805. // loop thru the list returned back
  9806. if (strList.IsEmpty() == FALSE)
  9807. {
  9808. POSITION pos;
  9809. CString csEntry;
  9810. pos = strList.GetHeadPosition();
  9811. while (pos)
  9812. {
  9813. csEntry = strList.GetAt(pos);
  9814. // check if this entry matchs the entry that was passed in...
  9815. if (_tcsicmp(csEntry, csInputName) == 0)
  9816. {
  9817. // it matches so return TRUE;
  9818. iReturn = TRUE;
  9819. goto IsThisOnNotStopList_Exit;
  9820. }
  9821. strList.GetNext(pos);
  9822. }
  9823. }
  9824. }
  9825. }
  9826. IsThisOnNotStopList_Exit:
  9827. return iReturn;
  9828. }
  9829. HRESULT MofCompile(TCHAR * szPathMofFile)
  9830. {
  9831. HRESULT hRes = E_FAIL;
  9832. WCHAR wszFileName[_MAX_PATH];
  9833. IMofCompiler *pMofComp = NULL;
  9834. WBEM_COMPILE_STATUS_INFO Info;
  9835. hRes = CoInitialize(NULL);
  9836. if (FAILED(hRes))
  9837. {
  9838. goto MofCompile_Exit;
  9839. }
  9840. hRes = CoCreateInstance( CLSID_MofCompiler, NULL, CLSCTX_INPROC_SERVER, IID_IMofCompiler, (LPVOID *)&pMofComp);
  9841. if (FAILED(hRes))
  9842. {
  9843. goto MofCompile_Exit;
  9844. }
  9845. // Ensure that the string is WCHAR.
  9846. #if defined(UNICODE) || defined(_UNICODE)
  9847. _tcscpy(wszFileName, szPathMofFile);
  9848. #else
  9849. MultiByteToWideChar( CP_ACP, 0, szPathMofFile, -1, wszFileName, _MAX_PATH);
  9850. #endif
  9851. pMofComp->CompileFile (
  9852. (LPWSTR) wszFileName,
  9853. NULL, // load into namespace specified in MOF file
  9854. NULL, // use default User
  9855. NULL, // use default Authority
  9856. NULL, // use default Password
  9857. 0, // no options
  9858. 0, // no class flags
  9859. 0, // no instance flags
  9860. &Info);
  9861. pMofComp->Release();
  9862. CoUninitialize();
  9863. MofCompile_Exit:
  9864. return hRes;
  9865. }
  9866. DWORD DoesEntryPointExist(LPCTSTR lpszDLLFile, LPCTSTR lpszProcedure)
  9867. {
  9868. DWORD dwReturn = ERROR_FILE_NOT_FOUND;
  9869. HINSTANCE hDll = NULL;
  9870. HCRET hProc = NULL;
  9871. TCHAR szDirName[_MAX_PATH], szFilePath[_MAX_PATH];
  9872. _tcscpy(szDirName, _T(""));
  9873. // Check if the file exists
  9874. if (!IsFileExist(lpszDLLFile))
  9875. {
  9876. dwReturn = ERROR_FILE_NOT_FOUND;
  9877. goto DoesEntryPointExist_Exit;
  9878. }
  9879. // Change Directory
  9880. GetCurrentDirectory( _MAX_PATH, szDirName );
  9881. InetGetFilePath(lpszDLLFile, szFilePath);
  9882. // Change to The Drive.
  9883. if (-1 == _chdrive( _totupper(szFilePath[0]) - 'A' + 1 )) {}
  9884. if (SetCurrentDirectory(szFilePath) == 0) {}
  9885. // Try to load the module,dll,ocx.
  9886. hDll = LoadLibraryEx(lpszDLLFile, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
  9887. if (!hDll)
  9888. {
  9889. dwReturn = ERROR_FILE_NOT_FOUND;
  9890. goto DoesEntryPointExist_Exit;
  9891. }
  9892. // Ok module was successfully loaded. now let's try to get the Address of the Procedure
  9893. // Convert the function name to ascii before passing it to GetProcAddress()
  9894. char AsciiProcedureName[255];
  9895. #if defined(UNICODE) || defined(_UNICODE)
  9896. // convert to ascii
  9897. WideCharToMultiByte( CP_ACP, 0, (TCHAR *)lpszProcedure, -1, AsciiProcedureName, 255, NULL, NULL );
  9898. #else
  9899. // the is already ascii so just copy
  9900. strcpy(AsciiProcedureName, lpszProcedure);
  9901. #endif
  9902. // see if the entry point exists...
  9903. hProc = (HCRET)GetProcAddress(hDll, AsciiProcedureName);
  9904. if (!hProc)
  9905. {
  9906. // failed to load,find or whatever this function.
  9907. dwReturn = ERROR_PROC_NOT_FOUND;
  9908. goto DoesEntryPointExist_Exit;
  9909. }
  9910. iisDebugOut((LOG_TYPE_TRACE, _T("DoesEntryPointExist:%s=true\n"),lpszProcedure));
  9911. dwReturn = ERROR_SUCCESS;
  9912. DoesEntryPointExist_Exit:
  9913. if (hDll){FreeLibrary(hDll);}
  9914. if (_tcscmp(szDirName, _T("")) != 0){SetCurrentDirectory(szDirName);}
  9915. return dwReturn;
  9916. }
  9917. void CreateDummyMetabaseBin(void)
  9918. {
  9919. TCHAR szFullPath1[_MAX_PATH];
  9920. TCHAR szFullPath2[_MAX_PATH];
  9921. HANDLE hfile = INVALID_HANDLE_VALUE;
  9922. DWORD dwBytesWritten = 0;
  9923. TCHAR buf[MAX_FAKE_METABASE_STRING_LEN];
  9924. BYTE bOneByte = 0;
  9925. // check if there is an existing metabase.bin
  9926. // if there is then rename it to a unique filename.
  9927. // if we cannot rename it because its in use or something, then leave it and get out.
  9928. _stprintf(szFullPath1, _T("%s\\metabase.bin"),g_pTheApp->m_csPathInetsrv);
  9929. if (IsFileExist(szFullPath1))
  9930. {
  9931. // Check to see how big it is.
  9932. DWORD dwFileSize = ReturnFileSize(szFullPath1);
  9933. if (dwFileSize != 0xFFFFFFFF)
  9934. {
  9935. // if it's less than 2k then it must be the fake file already (must be an upgrade)
  9936. // leave it alone and don't replace it with the dummy (since it already is the dummy)
  9937. if (dwFileSize < 2000)
  9938. {
  9939. return;
  9940. }
  9941. }
  9942. int iCount = 0;
  9943. int iFlag = FALSE;
  9944. do
  9945. {
  9946. // check if the new unique file name exists...
  9947. _stprintf(szFullPath2, _T("%s.dfu.%d"),szFullPath1,iCount);
  9948. if (!IsFileExist(szFullPath2))
  9949. {
  9950. iFlag = TRUE;
  9951. }
  9952. } while (iFlag == FALSE && iCount < 9999);
  9953. // this is a unique filename, so let's use it and
  9954. // rename the metabase.bin to it
  9955. if (!MoveFileEx(szFullPath1, szFullPath2, MOVEFILE_COPY_ALLOWED|MOVEFILE_WRITE_THROUGH|MOVEFILE_REPLACE_EXISTING))
  9956. {
  9957. // log the failure at least
  9958. iisDebugOut((LOG_TYPE_WARN, _T("CreateDummyMetabaseBin: unable to rename existing metabase.bin file\n")));
  9959. return;
  9960. }
  9961. }
  9962. // Create a unicode text file named metabase.bin
  9963. // and stick some sting into it (from our setup resource)
  9964. // should be localized when localization localizes the iis.dll
  9965. memset(buf, 0, _tcslen(buf) * sizeof(TCHAR));
  9966. // this iis.dll is always compiled unicode, so
  9967. // we know that buf is unicode
  9968. if (!LoadString((HINSTANCE) g_MyModuleHandle, IDS_FAKE_METABASE_BIN_TEXT, buf, MAX_FAKE_METABASE_STRING_LEN))
  9969. {
  9970. iisDebugOut((LOG_TYPE_WARN, _T("LoadString(%d) Failed.\n"), IDS_FAKE_METABASE_BIN_TEXT));
  9971. return;
  9972. }
  9973. DeleteFile(szFullPath1);
  9974. // create the new metabase.bin file
  9975. hfile = CreateFile((LPTSTR)szFullPath1, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  9976. if( hfile == INVALID_HANDLE_VALUE)
  9977. {
  9978. iisDebugOut((LOG_TYPE_WARN, _T("CreateDummyMetabaseBin:CreateFile on %s failed with 0x%x!\n"),szFullPath1,GetLastError()));
  9979. return;
  9980. }
  9981. // write a couple of bytes to the beginning of the file say that it's "unicode"
  9982. bOneByte = 0xFF;
  9983. WriteFile(hfile, (LPCVOID) &bOneByte, 1, &dwBytesWritten, NULL);
  9984. bOneByte = 0xFE;
  9985. WriteFile(hfile, (LPCVOID) &bOneByte, 1, &dwBytesWritten, NULL);
  9986. if ( WriteFile( hfile, buf, _tcslen(buf) * sizeof(TCHAR), &dwBytesWritten, NULL ) == FALSE )
  9987. {
  9988. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("WriteFile(%1!s!) Failed. Error=0x%2!x!.\n"), szFullPath1, GetLastError()));
  9989. }
  9990. CloseHandle(hfile);
  9991. return;
  9992. }
  9993. //
  9994. // Check whether we are running as administrator on the machine
  9995. // or not
  9996. //
  9997. BOOL RunningAsAdministrator()
  9998. {
  9999. #ifdef _CHICAGO_
  10000. return TRUE;
  10001. #else
  10002. BOOL fReturn = FALSE;
  10003. PSID psidAdmin;
  10004. DWORD err;
  10005. SID_IDENTIFIER_AUTHORITY SystemSidAuthority= SECURITY_NT_AUTHORITY;
  10006. if ( AllocateAndInitializeSid ( &SystemSidAuthority, 2,
  10007. SECURITY_BUILTIN_DOMAIN_RID,
  10008. DOMAIN_ALIAS_RID_ADMINS,
  10009. 0, 0, 0, 0, 0, 0, &psidAdmin) )
  10010. {
  10011. if (!CheckTokenMembership( NULL, psidAdmin, &fReturn )) {
  10012. err = GetLastError();
  10013. iisDebugOut((LOG_TYPE_ERROR, _T("CheckTokenMembership failed on err %d.\n"), err));
  10014. }
  10015. FreeSid ( psidAdmin);
  10016. }
  10017. return ( fReturn );
  10018. #endif //_CHICAGO_
  10019. }
  10020. void StopAllServicesRegardless(int iShowErrorsFlag)
  10021. {
  10022. #ifndef _CHICAGO_
  10023. // important: you must take iis clusters off line before doing anykind of upgrade\installs...
  10024. // but incase the user didn't do this... try to take them off line for the user
  10025. DWORD dwResult = ERROR_SUCCESS;
  10026. dwResult = BringALLIISClusterResourcesOffline();
  10027. if (StopServiceAndDependencies(_T("W3SVC"), FALSE) == FALSE)
  10028. {
  10029. if (iShowErrorsFlag)
  10030. {
  10031. MyMessageBox(NULL, IDS_UNABLE_TO_STOP_SERVICE,_T("W3SVC"), MB_OK | MB_SETFOREGROUND);
  10032. }
  10033. }
  10034. if (StopServiceAndDependencies(_T("MSFTPSVC"), FALSE) == FALSE)
  10035. {
  10036. if (iShowErrorsFlag)
  10037. {
  10038. MyMessageBox(NULL, IDS_UNABLE_TO_STOP_SERVICE,_T("MSFTPSVC"), MB_OK | MB_SETFOREGROUND);
  10039. }
  10040. }
  10041. if (StopServiceAndDependencies(_T("IISADMIN"), TRUE) == FALSE)
  10042. {
  10043. if (iShowErrorsFlag)
  10044. {
  10045. MyMessageBox(NULL, IDS_UNABLE_TO_STOP_SERVICE,_T("IISADMIN"), MB_OK | MB_SETFOREGROUND);
  10046. }
  10047. }
  10048. /*
  10049. DWORD dwStatus = 0;
  10050. dwStatus = InetQueryServiceStatus(_T("MSDTC"));
  10051. if (SERVICE_RUNNING == dwStatus)
  10052. {
  10053. // if the service is running, then let' stop it!
  10054. if (StopServiceAndDependencies(_T("MSDTC"), TRUE) == FALSE)
  10055. {
  10056. if (iShowErrorsFlag){MyMessageBox(NULL, IDS_UNABLE_TO_STOP_SERVICE,_T("MSDTC"), MB_OK | MB_SETFOREGROUND);}
  10057. }
  10058. }
  10059. */
  10060. /*
  10061. dwStatus = InetQueryServiceStatus(_T("SPOOLER"));
  10062. if (SERVICE_RUNNING == dwStatus)
  10063. {
  10064. // if the service is running, then let' stop it!
  10065. if (StopServiceAndDependencies(_T("SPOOLER"), TRUE) == FALSE)
  10066. {
  10067. if (iShowErrorsFlag){MyMessageBox(NULL, IDS_UNABLE_TO_STOP_SERVICE,_T("SPOOLER"), MB_OK | MB_SETFOREGROUND);}
  10068. }
  10069. }
  10070. */
  10071. #endif
  10072. // kill pwstray.exe in case of IIS4.0 Beta2 upgrade, to release admprox.dll
  10073. HWND hwndTray = NULL;
  10074. hwndTray = FindWindow(PWS_TRAY_WINDOW_CLASS, NULL);
  10075. if ( hwndTray ){::PostMessage( hwndTray, WM_CLOSE, 0, 0 );}
  10076. return;
  10077. }