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.

303 lines
6.3 KiB

  1. /*++
  2. Copyright (c) 1999-2001 Microsoft Corporation
  3. Module Name:
  4. sections.cpp
  5. Abstract:
  6. This module implements routines for section
  7. specific SSR Knowledge Base processing.
  8. Author:
  9. Vishnu Patankar (VishnuP) - Oct 2001
  10. Environment:
  11. User mode only.
  12. Exported Functions:
  13. Revision History:
  14. Created - Oct 2001
  15. --*/
  16. #include "stdafx.h"
  17. #include "kbproc.h"
  18. #include "process.h"
  19. HRESULT
  20. process::SsrpCreatePreprocessorSection(
  21. IN CComPtr<IXMLDOMElement> pXMLDocElemRoot,
  22. IN CComPtr<IXMLDOMDocument> pXMLDocIn,
  23. IN PWSTR pszKbMode,
  24. IN PWSTR pszKBDir)
  25. /*++
  26. Routine Description:
  27. Routine called to process all roles
  28. Arguments:
  29. pXMLDocElemRoot - root of document
  30. pXMLDoc - KB document
  31. pszKbMode - mode value
  32. pszKBDir - KB directory name
  33. Return:
  34. HRESULT error code
  35. ++*/
  36. {
  37. HRESULT hr = S_OK;
  38. DWORD rc;
  39. BSTR bstrLevelName;
  40. CComVariant Type(NODE_ELEMENT);
  41. CComVariant vtRefChild;
  42. CComPtr<IXMLDOMNodeList> pResultList;
  43. CComPtr<IXMLDOMNode> pSecurityLevels;
  44. CComPtr<IXMLDOMNode> pPreprocessorNode;
  45. CComPtr<IXMLDOMNode> pManufacturerNode;
  46. CComPtr<IXMLDOMNode> pVersionNode;
  47. CComPtr<IXMLDOMNode> pInputsNode;
  48. CComPtr<IXMLDOMNode> pKBNode;
  49. CComPtr<IXMLDOMNode> pLevelNode;
  50. CComPtr<IXMLDOMNode> pPolicyNode;
  51. CComPtr<IXMLDOMNode> pXDNodeCreate;
  52. CComPtr<IXMLDOMNode> pXMLNameNode;
  53. //
  54. // get all the Level names since we need to validate the passed in level name
  55. //
  56. hr = pXMLDocElemRoot->selectNodes(L"SecurityLevels/Level/Name", &pResultList);
  57. if (FAILED(hr) || pResultList == NULL ) {
  58. SsrpLogParseError(hr);
  59. goto ExitHandler;
  60. }
  61. hr = pResultList->nextNode(&pXMLNameNode);
  62. if (FAILED(hr)) {
  63. SsrpLogParseError(hr);
  64. goto ExitHandler;
  65. }
  66. BOOL bModeIsValid = FALSE;
  67. while (pXMLNameNode && bModeIsValid == FALSE) {
  68. pXMLNameNode->get_text(&bstrLevelName);
  69. if ( 0 == SsrpICompareBstrPwstr(bstrLevelName, pszKbMode )) {
  70. bModeIsValid = TRUE;
  71. }
  72. pXMLNameNode.Release();
  73. hr = pResultList->nextNode(&pXMLNameNode);
  74. if (FAILED(hr)) {
  75. SsrpLogParseError(hr);
  76. goto ExitHandler;
  77. }
  78. }
  79. if (bModeIsValid == FALSE) {
  80. SsrpLogError(L"The mode value is incorrect\n");
  81. hr = E_INVALIDARG;
  82. goto ExitHandler;
  83. }
  84. hr = pXMLDocIn->createNode(
  85. Type,
  86. L"Preprocessor",
  87. NULL,
  88. &pPreprocessorNode);
  89. if (FAILED(hr) || pPreprocessorNode == NULL) {
  90. SsrpLogParseError(hr);
  91. goto ExitHandler;
  92. }
  93. hr = pXMLDocIn->createNode(
  94. Type,
  95. L"Manufacturer",
  96. NULL,
  97. &pManufacturerNode);
  98. hr = pManufacturerNode->put_text(L"Microsoft");
  99. if (FAILED(hr)) {
  100. SsrpLogParseError(hr);
  101. goto ExitHandler;
  102. }
  103. hr = pPreprocessorNode->appendChild(pManufacturerNode, NULL);
  104. if (FAILED(hr)) {
  105. SsrpLogParseError(hr);
  106. goto ExitHandler;
  107. }
  108. hr = pXMLDocIn->createNode(
  109. Type,
  110. L"Version",
  111. NULL,
  112. &pVersionNode);
  113. hr = pVersionNode->put_text(L"1.0");
  114. if (FAILED(hr)) {
  115. SsrpLogParseError(hr);
  116. goto ExitHandler;
  117. }
  118. hr = pPreprocessorNode->appendChild(pVersionNode, NULL);
  119. if (FAILED(hr)) {
  120. SsrpLogParseError(hr);
  121. goto ExitHandler;
  122. }
  123. hr = pXMLDocIn->createNode(
  124. Type,
  125. L"Inputs",
  126. NULL,
  127. &pInputsNode);
  128. hr = pXMLDocIn->createNode(
  129. Type,
  130. L"KnowledgeBase",
  131. NULL,
  132. &pKBNode);
  133. hr = pKBNode->put_text(pszKBDir);
  134. if (FAILED(hr)) {
  135. SsrpLogParseError(hr);
  136. goto ExitHandler;
  137. }
  138. hr = pInputsNode->appendChild(pKBNode, NULL);
  139. if (FAILED(hr)) {
  140. SsrpLogParseError(hr);
  141. goto ExitHandler;
  142. }
  143. hr = pXMLDocIn->createNode(
  144. Type,
  145. L"SecurityLevel",
  146. NULL,
  147. &pLevelNode);
  148. hr = pKBNode->put_text(pszKbMode);
  149. if (FAILED(hr)) {
  150. SsrpLogParseError(hr);
  151. goto ExitHandler;
  152. }
  153. hr = pInputsNode->appendChild(pLevelNode, NULL);
  154. if (FAILED(hr)) {
  155. SsrpLogParseError(hr);
  156. goto ExitHandler;
  157. }
  158. hr = pXMLDocIn->createNode(
  159. Type,
  160. L"Policy",
  161. NULL,
  162. &pPolicyNode);
  163. hr = pKBNode->put_text(L"");
  164. if (FAILED(hr)) {
  165. SsrpLogParseError(hr);
  166. goto ExitHandler;
  167. }
  168. hr = pInputsNode->appendChild(pPolicyNode, NULL);
  169. if (FAILED(hr)) {
  170. SsrpLogParseError(hr);
  171. goto ExitHandler;
  172. }
  173. hr = pPreprocessorNode->appendChild(pInputsNode, NULL);
  174. if (FAILED(hr)) {
  175. SsrpLogParseError(hr);
  176. goto ExitHandler;
  177. }
  178. hr = pXMLDocElemRoot->selectSingleNode(L"SecurityLevels", &pSecurityLevels);
  179. if (FAILED(hr) || pSecurityLevels == NULL ) {
  180. SsrpLogParseError(hr);
  181. goto ExitHandler;
  182. }
  183. vtRefChild = pSecurityLevels;
  184. hr = pXMLDocElemRoot->insertBefore(pPreprocessorNode,
  185. vtRefChild,
  186. NULL);
  187. if (FAILED(hr)) {
  188. SsrpLogParseError(hr);
  189. goto ExitHandler;
  190. }
  191. hr = pXMLDocElemRoot->removeChild(pSecurityLevels, NULL);
  192. if (FAILED(hr)) {
  193. SsrpLogParseError(hr);
  194. goto ExitHandler;
  195. }
  196. ExitHandler:
  197. return hr;
  198. }