Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

193 lines
4.1 KiB

  1. #include "stdinc.h"
  2. #include "st.h"
  3. #include "stressharness.h"
  4. #include "wfp.h"
  5. #define WFP_INI_SECTION (L"wfp")
  6. #define WFP_INI_KEY_VICTIM (L"Victim")
  7. #define WFP_INI_KEY_MODE (L"Mode")
  8. #define WFP_INI_KEY_USE_SHORTFNAME (L"UseShortnameFile")
  9. #define WFP_INI_KEY_USE_SHORTDNAME (L"UseShortnameDir")
  10. #define WFP_INI_KEY_INSTALL (L"InstallManifest")
  11. #define WFP_INI_KEY_PAUSE_AFTER (L"PauseLength")
  12. #define WFP_INI_KEY_MODE_DELETE_FILES (L"DeleteFiles")
  13. #define WFP_INI_KEY_MODE_TOUCH_FILES (L"TouchFiles")
  14. #define WFP_INI_KEY_MODE_DELETE_DIR (L"DeleteDirectory")
  15. #define WFP_INI_KEY_MODE_DELETE_MAN (L"DeleteManifest")
  16. #define WFP_INI_KEY_MODE_DELETE_CAT (L"DeleteCatalog")
  17. #define WFP_INI_KEY_MODE_HAVOC (L"Havoc")
  18. #define WFP_INI_KEY_MODE_DEFAULT (WFP_INI_KEY_MODE_DELETE_FILES)
  19. CWfpJobEntry::~CWfpJobEntry()
  20. {
  21. }
  22. //
  23. // Defaulted
  24. //
  25. BOOL
  26. CWfpJobEntry::SetupSelfForRun()
  27. {
  28. return TRUE;
  29. }
  30. BOOL
  31. CWfpJobEntry::Cleanup()
  32. {
  33. FN_PROLOG_WIN32
  34. IFW32FALSE_EXIT(CStressJobEntry::Cleanup());
  35. if ( this->m_buffManifestToInstall.Cch() != 0 )
  36. {
  37. //
  38. // Uninstall the assembly that we added
  39. //
  40. SXS_UNINSTALLW Uninstall = { sizeof(Uninstall) };
  41. Uninstall.dwFlags = SXS_UNINSTALL_FLAG_FORCE_DELETE;
  42. Uninstall.lpAssemblyIdentity = this->m_buffVictimAssemblyIdentity;
  43. IFW32FALSE_EXIT(SxsUninstallW(&Uninstall, NULL));
  44. }
  45. FN_EPILOG
  46. }
  47. BOOL
  48. CWfpJobEntry::RunTest(
  49. bool &rfTestSuccessful
  50. )
  51. {
  52. FN_PROLOG_WIN32
  53. //
  54. // Our tests are always successful, because all we're doing is stressing WFP
  55. //
  56. rfTestSuccessful = true;
  57. FN_EPILOG
  58. }
  59. CWfpJobEntry::LoadFromSettingsFile(
  60. PCWSTR pcwszSettingsFile
  61. )
  62. {
  63. FN_PROLOG_WIN32
  64. CSmallStringBuffer buffJunk;
  65. INT iJunk;
  66. //
  67. // Are we using shortnames for files?
  68. //
  69. IFW32FALSE_EXIT(SxspIsPrivateProfileStringEqual(
  70. WFP_INI_SECTION,
  71. WFP_INI_KEY_USE_SHORTFNAME,
  72. L"no",
  73. this->m_fUseShortnameFile,
  74. pcwszSettingsFile));
  75. //
  76. // Are we using shortnames for directories?
  77. //
  78. IFW32FALSE_EXIT(SxspIsPrivateProfileStringEqual(
  79. WFP_INI_SECTION,
  80. WFP_INI_KEY_USE_SHORTDNAME,
  81. L"no",
  82. this->m_fUseShortnameDirectory,
  83. pcwszSettingsFile));
  84. //
  85. // How long are we to wait between twiddling and uninstalling?
  86. //
  87. IFW32FALSE_EXIT(SxspGetPrivateProfileIntW(
  88. WFP_INI_SECTION,
  89. WFP_INI_KEY_PAUSE_AFTER,
  90. 5000,
  91. iJunk,
  92. pcwszSettingsFile));
  93. this->m_dwPauseBetweenTwiddleAndUninstall = iJunk;
  94. //
  95. // The test mode
  96. //
  97. IFW32FALSE_EXIT(SxspGetPrivateProfileStringW(
  98. WFP_INI_SECTION,
  99. WFP_INI_KEY_MODE,
  100. WFP_INI_KEY_MODE_DEFAULT,
  101. buffJunk,
  102. pcwszSettingsFile));
  103. #define TEST_MODE( mds, mdn ) if (FusionpStrCmpI((WFP_INI_KEY_MODE_##mds), buffJunk) == 0) this->m_eChangeMode = mdn
  104. TEST_MODE(DELETE_FILES, eWfpChangeDeleteFile);
  105. TEST_MODE(TOUCH_FILES, eWfpChangeTouchFile);
  106. TEST_MODE(DELETE_DIR, eWfpChangeDeleteDirectory);
  107. TEST_MODE(DELETE_MAN, eWfpChangeDeleteManifest);
  108. TEST_MODE(DELETE_CAT, eWfpChangeDeleteCatalog);
  109. TEST_MODE(HAVOC, eWfpChangeCompleteHavoc);
  110. //
  111. // The victim assembly identity
  112. //
  113. IFW32FALSE_EXIT(SxspGetPrivateProfileStringW(
  114. WFP_INI_SECTION,
  115. WFP_INI_KEY_VICTIM,
  116. L"",
  117. m_buffVictimAssemblyIdentity,
  118. pcwszSettingsFile));
  119. //
  120. // Are we installing an assembly to do this to?
  121. //
  122. IFW32FALSE_EXIT(SxspGetPrivateProfileStringW(
  123. WFP_INI_SECTION,
  124. WFP_INI_KEY_INSTALL,
  125. L"",
  126. this->m_buffManifestToInstall,
  127. pcwszSettingsFile));
  128. FN_EPILOG
  129. }
  130. CWfpJobManager::CWfpJobManager()
  131. {
  132. //
  133. // Nothing
  134. //
  135. }
  136. CWfpJobManager::~CWfpJobManager()
  137. {
  138. //
  139. // Nothing
  140. //
  141. }
  142. BOOL
  143. CWfpJobManager::CreateJobEntry(
  144. CStressJobEntry* &rpJobEntry
  145. )
  146. {
  147. FN_PROLOG_WIN32
  148. rpJobEntry = NULL;
  149. rpJobEntry = FUSION_NEW_SINGLETON(CWfpJobEntry(this));
  150. FN_EPILOG
  151. }