Leaked source code of windows server 2003
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.

156 lines
4.8 KiB

  1. //+-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (c) Microsoft Corporation 2000
  6. //
  7. // File: util.h
  8. //
  9. // Contents: headerfile for util.cxx and parser.cxx
  10. //
  11. //
  12. // History: KDamour 15Mar00 Created
  13. //
  14. //------------------------------------------------------------------------
  15. #ifndef DIGEST_UTIL_H
  16. #define DIGEST_UTIL_H
  17. #ifdef __cplusplus
  18. extern "C"
  19. {
  20. #endif // __cplusplus
  21. // Allocates cb wide chars to UNICODE_STRING Buffer
  22. NTSTATUS UnicodeStringAllocate(IN PUNICODE_STRING pString, IN USHORT cNumWChars);
  23. // Duplicate a UnicodeString (memory alloc and copy)
  24. NTSTATUS UnicodeStringDuplicate(
  25. OUT PUNICODE_STRING DestinationString,
  26. IN OPTIONAL PUNICODE_STRING SourceString);
  27. // Copies a unicode string if destination has enough room to store it
  28. NTSTATUS UnicodeStringCopy(
  29. OUT PUNICODE_STRING DestinationString,
  30. IN OPTIONAL PUNICODE_STRING SourceString);
  31. // Function to duplicate Unicode passwords with padding for cipher
  32. NTSTATUS UnicodeStringDuplicatePassword(
  33. OUT PUNICODE_STRING DestinationString,
  34. IN OPTIONAL PUNICODE_STRING SourceString);
  35. // Clears a UnicodeString and releases the memory
  36. NTSTATUS UnicodeStringClear(OUT PUNICODE_STRING pString);
  37. // Copies a SzUnicodeString to a String (memory alloc and copy)
  38. NTSTATUS UnicodeStringWCharDuplicate(OUT PUNICODE_STRING DestinationString,
  39. IN OPTIONAL WCHAR *szSource,
  40. IN OPTIONAL USHORT uWCharCnt);
  41. // Duplicates a String (memory alloc and copy)
  42. NTSTATUS StringDuplicate(
  43. OUT PSTRING DestinationString,
  44. IN OPTIONAL PSTRING SourceString);
  45. // Copies a string if destination has enough room to store it
  46. NTSTATUS StringCopy(
  47. OUT PSTRING DestinationString,
  48. IN OPTIONAL PSTRING SourceString);
  49. // Reference a String - no buffer memory copied
  50. NTSTATUS StringReference(
  51. OUT PSTRING pDestinationString,
  52. IN PSTRING pSourceString
  53. );
  54. // Reference a Unicode_String - no buffer memory copied
  55. NTSTATUS UnicodeStringReference(
  56. OUT PUNICODE_STRING pDestinationString,
  57. IN PUNICODE_STRING pSourceString
  58. );
  59. // Copies a CzString to a String (memory alloc and copy)
  60. NTSTATUS StringCharDuplicate(
  61. OUT PSTRING DestinationString,
  62. IN OPTIONAL char *czSource,
  63. IN OPTIONAL USHORT uCnt);
  64. // Duplicates a SID (memory alloc and copy)
  65. NTSTATUS SidDuplicate(
  66. OUT PSID * DestinationSid,
  67. IN PSID SourceSid);
  68. NTSTATUS CopyClientString(
  69. IN PWSTR SourceString,
  70. IN ULONG SourceLength,
  71. IN BOOLEAN DoUnicode,
  72. OUT PUNICODE_STRING DestinationString);
  73. // Allocate memory in LSA or user mode
  74. PVOID DigestAllocateMemory(IN ULONG BufferSize);
  75. // De-allocate memory from DigestAllocateMemory
  76. VOID DigestFreeMemory(IN PVOID Buffer);
  77. // Allocates cb bytes to STRING Buffer
  78. NTSTATUS StringAllocate(IN PSTRING pString, IN USHORT cb);
  79. // Clears a String and releases the memory
  80. NTSTATUS StringFree(IN PSTRING pString);
  81. // Quick check on String struct allocations validity
  82. NTSTATUS StringVerify(OUT PSTRING pString);
  83. // Clears a Uniicde_String and releases the memory
  84. NTSTATUS UnicodeStringFree(OUT PUNICODE_STRING pString);
  85. // Hex Encoders and Decoders
  86. VOID BinToHex(LPBYTE pSrc,UINT cSrc, LPSTR pDst);
  87. VOID HexToBin(LPSTR pSrc,UINT cSrc, LPBYTE pDst);
  88. // Scan a Comma Deliminated STRING for an Item
  89. NTSTATUS CheckItemInList(PCHAR pszItem, PSTRING pstrList, BOOL fOneItem);
  90. // determine strlen for a counted string buffer which may or may not be terminated
  91. USHORT strlencounted(const char *string, USHORT maxcnt);
  92. // determine Unicode strlen for a counted string buffer which may or may not be terminated
  93. USHORT ustrlencounted(const short *string, USHORT maxcnt);
  94. // Performs a percent encoding of the source string into the destination string RFC 2396
  95. NTSTATUS BackslashEncodeString(IN PSTRING pstrSrc, OUT PSTRING pstrDst);
  96. // Printout the Hex representation of a buffer
  97. NTSTATUS MyPrintBytes(void *pbuff, USHORT uNumBytes, PSTRING pstrOutput);
  98. // Check SecurityToken for corredct structure format
  99. BOOL ContextIsTokenOK(IN PSecBuffer pTempToken, IN ULONG ulMaxSize);
  100. #ifndef SECURITY_KERNEL
  101. // Print out the date and time from a given TimeStamp (converted to localtime)
  102. NTSTATUS PrintTimeString(TimeStamp tsValue, BOOL fLocalTime);
  103. // Decode a string into Unicode
  104. NTSTATUS DecodeUnicodeString(
  105. IN PSTRING pstrSource,
  106. IN UINT CodePage,
  107. OUT PUNICODE_STRING pustrDestination
  108. );
  109. // Encode a unicode string with a given charset
  110. NTSTATUS EncodeUnicodeString(
  111. IN PUNICODE_STRING pustrSource,
  112. IN UINT CodePage,
  113. OUT PSTRING pstrDestination,
  114. IN OUT PBOOL pfUsedDefaultChar
  115. );
  116. #endif // SECURURITY_KERNEL
  117. #ifdef __cplusplus
  118. }
  119. #endif // __cplusplus
  120. #endif // DIGEST_UTIL_H