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.

117 lines
2.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: domain.cxx
  7. //
  8. // Contents: GuidToUlong - converts Cairo GUID into a ULONG
  9. //
  10. //
  11. // Functions:
  12. //
  13. // History: 6-28-93 MikeSw Created
  14. //
  15. //
  16. //----------------------------------------------------------------------------
  17. #include <secpch2.hxx>
  18. #pragma hdrstop
  19. extern "C"
  20. VOID
  21. DomainGroupName(PWCHAR pwszDomain,
  22. PCHAR psGroup)
  23. {
  24. LONG cDomLen;
  25. CHAR szDom[MAX_PATH];
  26. PCHAR psSep;
  27. (VOID)wcstombs(szDom, pwszDomain, MAX_PATH * sizeof(WCHAR));
  28. strlwr(szDom); // eliminate case mismatches
  29. *psGroup = szDom[0]; // copy the first
  30. psSep = strrchr(szDom, '\\');
  31. if(!psSep)
  32. {
  33. psSep = szDom;
  34. }
  35. else
  36. {
  37. psSep++;
  38. }
  39. cDomLen = min(14, strlen(psSep)); // fill bytes if necessary
  40. memset(&psGroup[cDomLen + 1], 0x20, 14 - cDomLen);
  41. memcpy(&psGroup[1], psSep, cDomLen);
  42. psGroup[15] = 0x1c; // make it an internet group
  43. }
  44. //
  45. // Get an internet group name for a GUID.
  46. // The strategy is to drop of high-byte of the time field. This changes
  47. // infrequently (every 50 years or so) so it likely won't cause a problem.
  48. //
  49. #if 0
  50. extern "C"
  51. VOID
  52. SqueezeGUID( GUID * pgGUID,
  53. PCHAR psGroup)
  54. {
  55. /*
  56. * Turn a GUID into an internet group name
  57. */
  58. PCHAR psGUID = (PCHAR)pgGUID;
  59. memcpy(psGroup, psGUID, 7);
  60. memcpy(&psGroup[7], &psGUID[8], 8);
  61. psGroup[15] = 0x1c;
  62. }
  63. #else
  64. //
  65. // Get an internet group name for a GUID.
  66. // The strategy is to form a binary string made up of the adapter address
  67. // plus a XSUM byye, ASCIIZE it, and append a " <1c>". Ta da.
  68. //
  69. extern "C"
  70. VOID
  71. SqueezeGUID( GUID * pgGUID,
  72. PCHAR psGroup)
  73. {
  74. /*
  75. * Turn a GUID into an internet group name
  76. */
  77. PCHAR psGUID = (PCHAR)pgGUID;
  78. UCHAR bXSUM;
  79. ULONG ulX;
  80. //
  81. // compute XSUM
  82. //
  83. for(bXSUM = 0, ulX = 0; ulX <= 15; psGUID++, ulX++)
  84. {
  85. bXSUM += (UCHAR)((ULONG)*psGUID + ulX);
  86. }
  87. sprintf(psGroup, "Z%02X%02X%02X%02X%02X%02X%02x",
  88. pgGUID->Data4[2], pgGUID->Data4[3], pgGUID->Data4[4],
  89. pgGUID->Data4[5], pgGUID->Data4[6], pgGUID->Data4[7],
  90. bXSUM);
  91. psGroup[15] = 0x1c;
  92. }
  93. #endif