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.

128 lines
2.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows NT5.0
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: O E M N U E X . C P P
  7. //
  8. // Contents: Functions needed by OEM DLLs for OEM network upgrade
  9. //
  10. // Notes:
  11. //
  12. // Author: kumarp 16-October-97
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include "kkcwinf.h"
  18. #include "kkutils.h"
  19. #include "oemupgex.h"
  20. extern CWInfFile* g_pwifAnswerFile;
  21. // ----------------------------------------------------------------------
  22. //
  23. // Function: NetUpgradeAddSection
  24. //
  25. // Purpose: Add section to answerfile
  26. //
  27. // Arguments:
  28. // szSectionName [in] name of section to add
  29. //
  30. // Returns: win32 error-code
  31. //
  32. // Author: kumarp 19-December-97
  33. //
  34. // Notes:
  35. //
  36. EXTERN_C LONG __stdcall
  37. NetUpgradeAddSection(IN PCWSTR szSectionName)
  38. {
  39. DefineFunctionName("NetUpgradeAddSection");
  40. DWORD dwError=ERROR_OUTOFMEMORY;
  41. if (IsBadReadPtr(szSectionName, sizeof(*szSectionName)))
  42. {
  43. dwError = ERROR_INVALID_PARAMETER;
  44. TraceTag(ttidError, "%s: [<bad-read-ptr>]", __FUNCNAME__);
  45. }
  46. else if (g_pwifAnswerFile)
  47. {
  48. TraceTag(ttidNetUpgrade, "%s: [%S]", __FUNCNAME__, szSectionName);
  49. CWInfSection* pwis;
  50. pwis = g_pwifAnswerFile->AddSectionIfNotPresent(szSectionName);
  51. if (pwis)
  52. {
  53. dwError = ERROR_SUCCESS;
  54. }
  55. else
  56. {
  57. TraceTag(ttidError, "%s: failed", __FUNCNAME__);
  58. }
  59. }
  60. return dwError;
  61. }
  62. // ----------------------------------------------------------------------
  63. //
  64. // Function: NetUpgradeAddLineToSection
  65. //
  66. // Purpose: Add a line to the specified section in the answerfile
  67. //
  68. // Arguments:
  69. // szSectionName [in] name of section
  70. // szLine [in] line text to add
  71. //
  72. // Returns: win32 error code
  73. //
  74. // Author: kumarp 19-December-97
  75. //
  76. // Notes:
  77. //
  78. EXTERN_C LONG __stdcall
  79. NetUpgradeAddLineToSection(IN PCWSTR szSectionName,
  80. IN PCWSTR szLine)
  81. {
  82. DefineFunctionName("NetUpgradeAddLineToSection");
  83. DWORD dwError=ERROR_OUTOFMEMORY;
  84. if (IsBadReadPtr(szSectionName, sizeof(*szSectionName)) ||
  85. IsBadReadPtr(szSectionName, sizeof(*szLine)))
  86. {
  87. dwError = ERROR_INVALID_PARAMETER;
  88. TraceTag(ttidError, "%s: <bad-read-ptr>", __FUNCNAME__);
  89. }
  90. else if (g_pwifAnswerFile)
  91. {
  92. CWInfSection* pwis;
  93. pwis = g_pwifAnswerFile->FindSection(szSectionName);
  94. if (pwis)
  95. {
  96. TraceTag(ttidNetUpgrade, "%s: [%S] <-- %S", __FUNCNAME__,
  97. szSectionName, szLine);
  98. pwis->AddRawLine(szLine);
  99. dwError = ERROR_SUCCESS;
  100. }
  101. else
  102. {
  103. TraceTag(ttidError, "%s: [%S] not found", __FUNCNAME__,
  104. szSectionName);
  105. dwError = ERROR_SECTION_NOT_FOUND;
  106. }
  107. }
  108. return dwError;
  109. }