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.

180 lines
2.7 KiB

  1. #include "precomp.h"
  2. BOOL
  3. AreGuidsEqual(
  4. GUID gOldGuid,
  5. GUID gNewGuid
  6. )
  7. {
  8. if (!memcmp(
  9. &(gOldGuid),
  10. &(gNewGuid),
  11. sizeof(GUID))) {
  12. return (TRUE);
  13. }
  14. return (FALSE);
  15. }
  16. VOID
  17. CopyGuid(
  18. GUID gInGuid,
  19. GUID * pgOutGuid
  20. )
  21. {
  22. memcpy(
  23. pgOutGuid,
  24. &gInGuid,
  25. sizeof(GUID)
  26. );
  27. }
  28. DWORD
  29. CopyName(
  30. LPWSTR pszInName,
  31. LPWSTR * ppszOutName
  32. )
  33. {
  34. DWORD dwError = 0;
  35. LPWSTR pszOutName = NULL;
  36. if (pszInName && *(pszInName)) {
  37. dwError = SPDApiBufferAllocate(
  38. wcslen(pszInName)*sizeof(WCHAR) + sizeof(WCHAR),
  39. &pszOutName
  40. );
  41. BAIL_ON_WIN32_ERROR(dwError);
  42. wcscpy(pszOutName, pszInName);
  43. }
  44. *ppszOutName = pszOutName;
  45. return (dwError);
  46. error:
  47. *ppszOutName = NULL;
  48. return (dwError);
  49. }
  50. DWORD
  51. SPDApiBufferAllocate(
  52. DWORD dwByteCount,
  53. LPVOID * ppBuffer
  54. )
  55. {
  56. DWORD dwError = 0;
  57. if (ppBuffer == NULL) {
  58. dwError = ERROR_INVALID_PARAMETER;
  59. BAIL_ON_WIN32_ERROR(dwError);
  60. }
  61. *ppBuffer = NULL;
  62. *ppBuffer = MIDL_user_allocate(dwByteCount);
  63. if (*ppBuffer == NULL) {
  64. dwError = ERROR_OUTOFMEMORY;
  65. BAIL_ON_WIN32_ERROR(dwError);
  66. }
  67. else {
  68. memset((LPBYTE) *ppBuffer, 0, dwByteCount);
  69. }
  70. error:
  71. return (dwError);
  72. }
  73. VOID
  74. SPDApiBufferFree(
  75. LPVOID pBuffer
  76. )
  77. {
  78. if (pBuffer) {
  79. MIDL_user_free(pBuffer);
  80. }
  81. }
  82. BOOL
  83. AreNamesEqual(
  84. LPWSTR pszOldName,
  85. LPWSTR pszNewName
  86. )
  87. {
  88. BOOL bEqual = FALSE;
  89. if (pszOldName && *pszOldName) {
  90. if (!pszNewName || !*pszNewName) {
  91. bEqual = FALSE;
  92. }
  93. else {
  94. if (!_wcsicmp(pszOldName, pszNewName)) {
  95. bEqual = TRUE;
  96. }
  97. else {
  98. bEqual = FALSE;
  99. }
  100. }
  101. }
  102. else {
  103. if (!pszNewName || !*pszNewName) {
  104. bEqual = TRUE;
  105. }
  106. else {
  107. bEqual = FALSE;
  108. }
  109. }
  110. return (bEqual);
  111. }
  112. DWORD
  113. SPDImpersonateClient(
  114. PBOOL pbImpersonating
  115. )
  116. {
  117. DWORD dwError = 0;
  118. dwError = RpcImpersonateClient(NULL);
  119. BAIL_ON_WIN32_ERROR(dwError);
  120. *pbImpersonating = TRUE;
  121. return (dwError);
  122. error:
  123. *pbImpersonating = FALSE;
  124. return (dwError);
  125. }
  126. VOID
  127. SPDRevertToSelf(
  128. BOOL bImpersonating
  129. )
  130. {
  131. if (bImpersonating) {
  132. (VOID) RpcRevertToSelf(); // Possible security bug to review.
  133. }
  134. }