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.

180 lines
2.5 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. /*
  29. DWORD
  30. CopyName(
  31. LPWSTR pszInName,
  32. LPWSTR * ppszOutName
  33. )
  34. {
  35. DWORD dwError = 0;
  36. LPWSTR pszOutName = NULL;
  37. if (pszInName && *(pszInName)) {
  38. dwError = SPDApiBufferAllocate(
  39. wcslen(pszInName)*sizeof(WCHAR) + sizeof(WCHAR),
  40. &pszOutName
  41. );
  42. BAIL_ON_WIN32_ERROR(dwError);
  43. wcscpy(pszOutName, pszInName);
  44. }
  45. *ppszOutName = pszOutName;
  46. return (dwError);
  47. error:
  48. *ppszOutName = NULL;
  49. return (dwError);
  50. }
  51. DWORD
  52. SPDApiBufferAllocate(
  53. DWORD dwByteCount,
  54. LPVOID * ppBuffer
  55. )
  56. {
  57. DWORD dwError = 0;
  58. if (ppBuffer == NULL) {
  59. dwError = ERROR_INVALID_PARAMETER;
  60. BAIL_ON_WIN32_ERROR(dwError);
  61. }
  62. *ppBuffer = NULL;
  63. *ppBuffer = MIDL_user_allocate(dwByteCount);
  64. if (*ppBuffer == NULL) {
  65. dwError = ERROR_OUTOFMEMORY;
  66. BAIL_ON_WIN32_ERROR(dwError);
  67. }
  68. else {
  69. memset((LPBYTE) *ppBuffer, 0, dwByteCount);
  70. }
  71. error:
  72. return (dwError);
  73. }
  74. VOID
  75. SPDApiBufferFree(
  76. LPVOID pBuffer
  77. )
  78. {
  79. if (pBuffer) {
  80. MIDL_user_free(pBuffer);
  81. }
  82. }
  83. */
  84. BOOL
  85. AreNamesEqual(
  86. LPWSTR pszOldName,
  87. LPWSTR pszNewName
  88. )
  89. {
  90. BOOL bEqual = FALSE;
  91. if (pszOldName && *pszOldName) {
  92. if (!pszNewName || !*pszNewName) {
  93. bEqual = FALSE;
  94. }
  95. else {
  96. if (!_wcsicmp(pszOldName, pszNewName)) {
  97. bEqual = TRUE;
  98. }
  99. else {
  100. bEqual = FALSE;
  101. }
  102. }
  103. }
  104. else {
  105. if (!pszNewName || !*pszNewName) {
  106. bEqual = TRUE;
  107. }
  108. else {
  109. bEqual = FALSE;
  110. }
  111. }
  112. return (bEqual);
  113. }
  114. DWORD
  115. SPDImpersonateClient(
  116. PBOOL pbImpersonating
  117. )
  118. {
  119. DWORD dwError = 0;
  120. dwError = RpcImpersonateClient(NULL);
  121. BAIL_ON_WIN32_ERROR(dwError);
  122. *pbImpersonating = TRUE;
  123. return (dwError);
  124. error:
  125. *pbImpersonating = FALSE;
  126. return (dwError);
  127. }
  128. VOID
  129. SPDRevertToSelf(
  130. BOOL bImpersonating
  131. )
  132. {
  133. if (bImpersonating) {
  134. RpcRevertToSelf();
  135. }
  136. }