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.

121 lines
2.5 KiB

  1. #include "pch.h"
  2. #pragma hdrstop
  3. #include "modset.h"
  4. VOID
  5. CModuleListSet::DumpSetToConsole ()
  6. {
  7. static CHAR pszBuf [4096];
  8. CHAR* pch;
  9. ULONG cch;
  10. ULONG cchLeft;
  11. const CModuleList* pScan;
  12. Assert (this);
  13. *pszBuf = 0;
  14. pch = pszBuf;
  15. cchLeft = celems(pszBuf);
  16. for (pScan = begin(); pScan != end(); pScan++)
  17. {
  18. cch = cchLeft - 1;
  19. if (pScan->FDumpToString (pch, &cch))
  20. {
  21. strcat (pch, "\n");
  22. cch++;
  23. Assert (cchLeft >= cch);
  24. pch += cch;
  25. cchLeft -= cch;
  26. }
  27. else
  28. {
  29. // Not enough room, time to flush the buffer.
  30. //
  31. printf(pszBuf);
  32. *pszBuf = 0;
  33. pch = pszBuf;
  34. cchLeft = celems(pszBuf);
  35. // Redo this entry
  36. pScan--;
  37. }
  38. }
  39. if (pch > pszBuf)
  40. {
  41. printf(pszBuf);
  42. }
  43. }
  44. BOOL
  45. CModuleListSet::FContainsModuleList (
  46. IN const CModuleList* pList) const
  47. {
  48. const CModuleList* pScan;
  49. Assert (this);
  50. Assert (pList);
  51. for (pScan = begin(); pScan != end(); pScan++)
  52. {
  53. if (pScan->FIsSameModuleListAs (pList))
  54. {
  55. return TRUE;
  56. }
  57. }
  58. return FALSE;
  59. }
  60. HRESULT
  61. CModuleListSet::HrAddModuleList (
  62. IN const CModuleList* pList,
  63. IN DWORD dwFlags /* INS_FLAGS */)
  64. {
  65. HRESULT hr;
  66. Assert (this);
  67. Assert (pList);
  68. Assert (!pList->empty());
  69. Assert ((dwFlags & INS_ASSERT_IF_DUP) || (dwFlags & INS_IGNORE_IF_DUP));
  70. Assert ((dwFlags & INS_APPEND) || (dwFlags & INS_INSERT));
  71. Assert (!(INS_SORTED & dwFlags) && !(INS_NON_SORTED & dwFlags));
  72. if (FContainsModuleList (pList))
  73. {
  74. // If the caller didn't tell us to ignore duplicates, we assert
  75. // if there is one.
  76. //
  77. // If we have a dup, we want the caller to be aware that it
  78. // is possible, and pass us the flag telling us to ignore it.
  79. // Otherwise, we assert to let them know. (And we still ignore
  80. // it.)
  81. Assert (dwFlags & INS_IGNORE_IF_DUP);
  82. return S_OK;
  83. }
  84. __try
  85. {
  86. // Either insert the bindpath or append it.
  87. //
  88. iterator iter = begin();
  89. if (dwFlags & INS_APPEND)
  90. {
  91. iter = end();
  92. }
  93. insert (iter, *pList);
  94. hr = S_OK;
  95. }
  96. __except(EXCEPTION_EXECUTE_HANDLER)
  97. {
  98. hr = E_OUTOFMEMORY;
  99. }
  100. return hr;
  101. }