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.

183 lines
4.7 KiB

  1. #include "sxspool.h"
  2. // save data into pool and set the index table
  3. NTSTATUS SXS_STRING_POOL::GetDataFromPoolBasedOnIndexTable(
  4. IN SXS_STRING_POOL_INDEX_ENTRY & indexData,
  5. OUT SXS_STRING_POOL_DATA & pooldata
  6. )
  7. {
  8. NTSTATUS Status = STATUS_SUCCESS;
  9. FN_TRACE_NTSTATUS(Status);
  10. IF_NOT_NTSTATUS_SUCCESS_EXIT(pooldata.NtAssign(m_pbPool + indexData.GetOffset(), indexData.GetLength()));
  11. FN_EPILOG;
  12. }
  13. NTSTATUS SXS_GUID_POOL::GetDataFromPoolBasedOnIndexTable(
  14. IN SXS_GUID_POOL_INDEX_ENTRY & indexData,
  15. OUT SXS_GUID_POOL_DATA & pooldata
  16. )
  17. {
  18. NTSTATUS Status = STATUS_SUCCESS;
  19. FN_TRACE_NTSTATUS(Status);
  20. pooldata.SetValue(*((GUID*)m_pbPool + indexData.GetOffset() / sizeof(GUID)));
  21. FN_EPILOG;
  22. }
  23. NTSTATUS SXS_GUID_POOL::HashData(
  24. IN DWORD dwFlags,
  25. IN const GUID& data,
  26. OUT ULONG& ulHashValue
  27. )
  28. {
  29. NTSTATUS Status = STATUS_SUCCESS;
  30. FN_TRACE_NTSTATUS(Status);
  31. PARAMETER_CHECK(dwFlags == 0);
  32. IF_NOT_NTSTATUS_SUCCESS_EXIT(SxspHashGUID(data, ulHashValue));
  33. FN_EPILOG;
  34. }
  35. NTSTATUS SXS_STRING_POOL::HashData(
  36. IN DWORD dwFlags,
  37. IN const SXS_STRING_POOL_INPUT_DATA& data,
  38. OUT ULONG& ulHash
  39. )
  40. {
  41. NTSTATUS Status = STATUS_SUCCESS;
  42. FN_TRACE_NTSTATUS(Status);
  43. PARAMETER_CHECK(dwFlags == 0);
  44. IF_NOT_NTSTATUS_SUCCESS_EXIT(
  45. SxspHashString(data.GetStr(), data.GetCch(), &ulHash, m_ePooltype == SXS_POOL_TYPE_CASE_INSENSITIVE_STRING ? true : false));
  46. FN_EPILOG;
  47. }
  48. NTSTATUS SXS_STRING_POOL::ConvertPoolDataToOutputData(
  49. IN DWORD dwFlags,
  50. IN SXS_STRING_POOL_DATA & dataInPool,
  51. OUT SXS_STRING_POOL_INPUT_DATA & dataOut
  52. )
  53. {
  54. NTSTATUS Status = STATUS_SUCCESS;
  55. FN_TRACE_NTSTATUS(Status);
  56. DWORD len = dataOut.GetCch();
  57. PARAMETER_CHECK(dwFlags == 0);
  58. IF_NOT_NTSTATUS_SUCCESS_EXIT(SxspUTF82StringToUCS2String(
  59. 0, dataInPool.GetPtr(), dataInPool.GetCch(), dataOut.GetBuffer(), &len));
  60. FN_EPILOG;
  61. }
  62. NTSTATUS SXS_GUID_POOL::ConvertPoolDataToOutputData(
  63. IN DWORD dwFlags,
  64. IN SXS_GUID_POOL_DATA & dataInPool,
  65. OUT GUID & dataOut
  66. )
  67. {
  68. NTSTATUS Status = STATUS_SUCCESS;
  69. FN_TRACE_NTSTATUS(Status);
  70. PARAMETER_CHECK(dwFlags == 0);
  71. dataInPool.GetValue(dataOut);
  72. FN_EPILOG;
  73. }
  74. NTSTATUS SXS_STRING_POOL::ConverInputDataIntoPoolData(
  75. IN DWORD dwFlags,
  76. IN const SXS_STRING_POOL_INPUT_DATA & dataInput,
  77. OUT SXS_STRING_POOL_DATA & dataInPool
  78. )
  79. {
  80. NTSTATUS Status = STATUS_SUCCESS;
  81. FN_TRACE_NTSTATUS(Status);
  82. IF_NOT_NTSTATUS_SUCCESS_EXIT(dataInPool.NtAssign(dataInput.GetStr(), dataInput.GetCch()));
  83. FN_EPILOG;
  84. }
  85. NTSTATUS SXS_GUID_POOL::ConverInputDataIntoPoolData(
  86. IN DWORD dwFlags,
  87. IN const GUID & dataInput,
  88. OUT SXS_GUID_POOL_DATA & dataInPool
  89. )
  90. {
  91. NTSTATUS Status = STATUS_SUCCESS;
  92. FN_TRACE_NTSTATUS(Status);
  93. dataInPool.SetValue(dataInput);
  94. FN_EPILOG;
  95. }
  96. NTSTATUS SXS_STRING_DATA<WCHAR>::NtAssign(PCWSTR Str, DWORD Cch)
  97. {
  98. NTSTATUS Status = STATUS_SUCCESS;
  99. FN_TRACE_NTSTATUS(Status);
  100. INTERNAL_ERROR_CHECK(m_fValueAssigned == false);
  101. m_fValueAssigned = true;
  102. m_pstrData = const_cast<WCHAR *>(Str);
  103. m_Cch = Cch;
  104. FN_EPILOG;
  105. }
  106. NTSTATUS SXS_STRING_DATA<WCHAR>::NtAssign(PBYTE Str, DWORD Ccb)
  107. {
  108. NTSTATUS Status = STATUS_SUCCESS;
  109. FN_TRACE_NTSTATUS(Status);
  110. INTERNAL_ERROR_CHECK(m_fValueAssigned == false);
  111. m_fValueAssigned = true;
  112. IF_NOT_NTSTATUS_SUCCESS_EXIT(SxspUTF82StringToUCS2String(0, Str, Ccb, NULL, &m_Cch));
  113. IFALLOCFAILED_EXIT(m_pstrData = FUSION_NEW_ARRAY(WCHAR, m_Cch));
  114. m_fMemoryAllocatedInside = true;
  115. IF_NOT_NTSTATUS_SUCCESS_EXIT(SxspUTF82StringToUCS2String(0, Str, Ccb, m_pstrData, &m_Cch));
  116. FN_EPILOG;
  117. }
  118. NTSTATUS SXS_STRING_DATA<BYTE>::NtAssign(PCWSTR Str, DWORD Cch)
  119. {
  120. NTSTATUS Status = STATUS_SUCCESS;
  121. FN_TRACE_NTSTATUS(Status);
  122. INTERNAL_ERROR_CHECK(m_fValueAssigned == false);
  123. m_fValueAssigned = true;
  124. IF_NOT_NTSTATUS_SUCCESS_EXIT(SxspUCS2StringToUTF8String(0, Str, Cch, NULL, &m_Cch));
  125. IFALLOCFAILED_EXIT(m_pstrData = FUSION_NEW_ARRAY(BYTE, m_Cch));
  126. m_fMemoryAllocatedInside = true;
  127. IF_NOT_NTSTATUS_SUCCESS_EXIT(SxspUCS2StringToUTF8String(0, Str, Cch, m_pstrData, &m_Cch));
  128. FN_EPILOG;
  129. }
  130. NTSTATUS SXS_STRING_DATA<BYTE>::NtAssign(PBYTE Str, DWORD Ccb)
  131. {
  132. NTSTATUS Status = STATUS_SUCCESS;
  133. FN_TRACE_NTSTATUS(Status);
  134. INTERNAL_ERROR_CHECK(m_fValueAssigned == false);
  135. m_fValueAssigned = true;
  136. m_pstrData = Str;
  137. m_Cch = Ccb;
  138. FN_EPILOG;
  139. }