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.

159 lines
3.8 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996.
  5. //
  6. // File: dsiface.cxx
  7. //
  8. // Contents: ADs calls for Class Store Property Read/Write
  9. //
  10. //
  11. // History: Sep-Oct 96. DebiM
  12. //
  13. //----------------------------------------------------------------------------
  14. #include "cstore.hxx"
  15. #pragma warning ( disable : 4018 )
  16. #pragma warning ( disable : 4244 )
  17. //
  18. // From CSPLATFORM to DS datatype
  19. //
  20. void
  21. UnpackPlatform (DWORD *pdwArch,
  22. CSPLATFORM *pPlatform)
  23. {
  24. unsigned char *pc = (unsigned char *)pdwArch;
  25. *(pc) = (unsigned char)pPlatform->dwPlatformId;
  26. *(++pc) = (unsigned char)pPlatform->dwVersionHi;
  27. *(++pc) = (unsigned char)pPlatform->dwVersionLo;
  28. *(++pc) = (unsigned char)pPlatform->dwProcessorArch;
  29. }
  30. //
  31. // From DS datatype to CSPLATFORM
  32. //
  33. void
  34. PackPlatform (DWORD dwArch,
  35. CSPLATFORM *pPlatform)
  36. {
  37. unsigned char *pc = (unsigned char *)&dwArch;
  38. pPlatform->dwPlatformId = *(pc);
  39. pPlatform->dwVersionHi = *(++pc);
  40. pPlatform->dwVersionLo = *(++pc);
  41. pPlatform->dwProcessorArch = *(++pc);
  42. }
  43. //+-------------------------------------------------------------------------
  44. //
  45. // Function: StringFromGUID
  46. //
  47. //--------------------------------------------------------------------------
  48. int StringFromGUID(REFGUID rguid, LPOLESTR lptsz)
  49. {
  50. swprintf(lptsz, L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
  51. rguid.Data1, rguid.Data2, rguid.Data3,
  52. rguid.Data4[0], rguid.Data4[1],
  53. rguid.Data4[2], rguid.Data4[3],
  54. rguid.Data4[4], rguid.Data4[5],
  55. rguid.Data4[6], rguid.Data4[7]);
  56. return 36;
  57. }
  58. //+-------------------------------------------------------------------------
  59. //
  60. // Function: RdnFromGUID
  61. //
  62. //--------------------------------------------------------------------------
  63. int RDNFromGUID(REFGUID rguid, LPOLESTR lptsz)
  64. {
  65. wcscpy (lptsz, L"CN=");
  66. StringFromGUID(rguid, lptsz+3);
  67. return 3+36;
  68. }
  69. //BUGBUG. This belongs in a common library
  70. void GUIDFromString(
  71. LPOLESTR psz,
  72. GUID *pclsguid)
  73. //
  74. // Converts a Stringified GUID to GUID structure
  75. //
  76. {
  77. WCHAR szC [40];
  78. LPOLESTR szClsId;
  79. LPOLESTR endptr;
  80. memset ((void *)pclsguid, NULL, sizeof (GUID));
  81. if ((!psz) ||
  82. (*psz == NULL))
  83. return;
  84. if (wcslen(psz) < 36)
  85. return;
  86. wcsncpy (&szC [0], psz, 36);
  87. szC[36] = L'\0';
  88. szClsId = &szC[0];
  89. *(szClsId+36) = NULL;
  90. pclsguid->Data4[7] = wcstoul (szClsId+34, &endptr, 16);
  91. *(szClsId+34) = NULL;
  92. pclsguid->Data4[6] = wcstoul (szClsId+32, &endptr, 16);
  93. *(szClsId+32) = NULL;
  94. pclsguid->Data4[5] = wcstoul (szClsId+30, &endptr, 16);
  95. *(szClsId+30) = NULL;
  96. pclsguid->Data4[4] = wcstoul (szClsId+28, &endptr, 16);
  97. *(szClsId+28) = NULL;
  98. pclsguid->Data4[3] = wcstoul (szClsId+26, &endptr, 16);
  99. *(szClsId+26) = NULL;
  100. pclsguid->Data4[2] = wcstoul (szClsId+24, &endptr, 16);
  101. *(szClsId+23) = NULL;
  102. pclsguid->Data4[1] = wcstoul (szClsId+21, &endptr, 16);
  103. *(szClsId+21) = NULL;
  104. pclsguid->Data4[0] = wcstoul (szClsId+19, &endptr, 16);
  105. *(szClsId+18) = NULL;
  106. pclsguid->Data3 = wcstoul (szClsId+14, &endptr, 16);
  107. *(szClsId+13) = NULL;
  108. pclsguid->Data2 = wcstoul (szClsId+9, &endptr, 16);
  109. *(szClsId+8) = NULL;
  110. pclsguid->Data1 = wcstoul (szClsId, &endptr, 16);
  111. }
  112. BOOL IsNullGuid(REFGUID rguid)
  113. {
  114. UINT i;
  115. if (rguid.Data1)
  116. return FALSE;
  117. if (rguid.Data2)
  118. return FALSE;
  119. if (rguid.Data3)
  120. return FALSE;
  121. for (i=0; i < 8; ++i)
  122. {
  123. if (rguid.Data4[i])
  124. return FALSE;
  125. }
  126. return TRUE;
  127. }