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.

163 lines
3.6 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. dbgutil.c
  5. Abstract:
  6. This module provides all the NetOle/Argus Debugger Extensions.
  7. Author:
  8. Krishna Ganugapati (KrishnaG) 28-December-1994
  9. Revision History:
  10. --*/
  11. #include <stdio.h>
  12. #define NOMINMAX
  13. #include <nt.h>
  14. #include <ntrtl.h>
  15. #include <nturtl.h>
  16. #include <windows.h>
  17. #include <stdlib.h>
  18. #include <math.h>
  19. #include <ntsdexts.h>
  20. #include "dbglocal.h"
  21. DWORD EvalValue(
  22. LPSTR *pptstr,
  23. PNTSD_GET_EXPRESSION EvalExpression,
  24. PNTSD_OUTPUT_ROUTINE Print)
  25. {
  26. LPSTR lpArgumentString;
  27. LPSTR lpAddress;
  28. DWORD dw;
  29. char ach[80];
  30. int cch;
  31. UNREFERENCED_PARAMETER(Print);
  32. lpArgumentString = *pptstr;
  33. while (isspace(*lpArgumentString))
  34. lpArgumentString++;
  35. lpAddress = lpArgumentString;
  36. while ((!isspace(*lpArgumentString)) && (*lpArgumentString != 0))
  37. lpArgumentString++;
  38. cch = lpArgumentString - lpAddress;
  39. if (cch > 79)
  40. cch = 79;
  41. strncpy(ach, lpAddress, cch);
  42. // Print("\"%s\"\n", lpAddress);
  43. dw = (DWORD)EvalExpression(lpAddress);
  44. *pptstr = lpArgumentString;
  45. return dw;
  46. }
  47. VOID
  48. ConvertSidToAsciiString(
  49. PSID pSid,
  50. LPSTR String
  51. )
  52. /*++
  53. Routine Description:
  54. This function generates a printable unicode string representation
  55. of a SID.
  56. The resulting string will take one of two forms. If the
  57. IdentifierAuthority value is not greater than 2^32, then
  58. the SID will be in the form:
  59. S-1-281736-12-72-9-110
  60. ^ ^^ ^^ ^ ^^^
  61. | | | | |
  62. +-----+--+-+--+---- Decimal
  63. Otherwise it will take the form:
  64. S-1-0x173495281736-12-72-9-110
  65. ^^^^^^^^^^^^^^ ^^ ^^ ^ ^^^
  66. Hexidecimal | | | |
  67. +--+-+--+---- Decimal
  68. Arguments:
  69. pSid - opaque pointer that supplies the SID that is to be
  70. converted to Unicode.
  71. Return Value:
  72. If the Sid is successfully converted to a Unicode string, a
  73. pointer to the Unicode string is returned, else NULL is
  74. returned.
  75. --*/
  76. {
  77. UCHAR Buffer[256];
  78. UCHAR i;
  79. ULONG Tmp;
  80. SID_IDENTIFIER_AUTHORITY *pSidIdentifierAuthority;
  81. PUCHAR pSidSubAuthorityCount;
  82. if (!IsValidSid( pSid )) {
  83. *String= '\0';
  84. return;
  85. }
  86. sprintf(Buffer, "S-%u-", (USHORT)(((PISID)pSid)->Revision ));
  87. strcpy(String, Buffer);
  88. pSidIdentifierAuthority = GetSidIdentifierAuthority(pSid);
  89. if ( (pSidIdentifierAuthority->Value[0] != 0) ||
  90. (pSidIdentifierAuthority->Value[1] != 0) ){
  91. sprintf(Buffer, "0x%02hx%02hx%02hx%02hx%02hx%02hx",
  92. (USHORT)pSidIdentifierAuthority->Value[0],
  93. (USHORT)pSidIdentifierAuthority->Value[1],
  94. (USHORT)pSidIdentifierAuthority->Value[2],
  95. (USHORT)pSidIdentifierAuthority->Value[3],
  96. (USHORT)pSidIdentifierAuthority->Value[4],
  97. (USHORT)pSidIdentifierAuthority->Value[5] );
  98. strcat(String, Buffer);
  99. } else {
  100. Tmp = (ULONG)pSidIdentifierAuthority->Value[5] +
  101. (ULONG)(pSidIdentifierAuthority->Value[4] << 8) +
  102. (ULONG)(pSidIdentifierAuthority->Value[3] << 16) +
  103. (ULONG)(pSidIdentifierAuthority->Value[2] << 24);
  104. sprintf(Buffer, "%lu", Tmp);
  105. strcat(String, Buffer);
  106. }
  107. pSidSubAuthorityCount = GetSidSubAuthorityCount(pSid);
  108. for (i=0;i< *(pSidSubAuthorityCount);i++ ) {
  109. sprintf(Buffer, "-%lu", *(GetSidSubAuthority(pSid, i)));
  110. strcat(String, Buffer);
  111. }
  112. }