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.

176 lines
2.4 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 = MIDL_user_allocate(dwByteCount);
  62. if (*ppBuffer == NULL) {
  63. dwError = ERROR_OUTOFMEMORY;
  64. BAIL_ON_WIN32_ERROR(dwError);
  65. }
  66. error:
  67. return (dwError);
  68. }
  69. VOID
  70. SPDApiBufferFree(
  71. LPVOID pBuffer
  72. )
  73. {
  74. if (pBuffer) {
  75. MIDL_user_free(pBuffer);
  76. }
  77. }
  78. BOOL
  79. AreNamesEqual(
  80. LPWSTR pszOldName,
  81. LPWSTR pszNewName
  82. )
  83. {
  84. BOOL bEqual = FALSE;
  85. if (pszOldName && *pszOldName) {
  86. if (!pszNewName || !*pszNewName) {
  87. bEqual = FALSE;
  88. }
  89. else {
  90. if (!_wcsicmp(pszOldName, pszNewName)) {
  91. bEqual = TRUE;
  92. }
  93. else {
  94. bEqual = FALSE;
  95. }
  96. }
  97. }
  98. else {
  99. if (!pszNewName || !*pszNewName) {
  100. bEqual = TRUE;
  101. }
  102. else {
  103. bEqual = FALSE;
  104. }
  105. }
  106. return (bEqual);
  107. }
  108. DWORD
  109. SPDImpersonateClient(
  110. PBOOL pbImpersonating
  111. )
  112. {
  113. DWORD dwError = 0;
  114. dwError = RpcImpersonateClient(NULL);
  115. BAIL_ON_WIN32_ERROR(dwError);
  116. *pbImpersonating = TRUE;
  117. return (dwError);
  118. error:
  119. *pbImpersonating = FALSE;
  120. return (dwError);
  121. }
  122. VOID
  123. SPDRevertToSelf(
  124. BOOL bImpersonating
  125. )
  126. {
  127. if (bImpersonating) {
  128. RpcRevertToSelf();
  129. }
  130. }