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.

69 lines
2.2 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. ndisutil.cpp
  7. FILE HISTORY:
  8. */
  9. #include "stdafx.h"
  10. #include "ustringp.h"
  11. //-------------------------------------------------------------------
  12. // Function: SetUnicodeString
  13. //
  14. // Purpose: given a UNICODE_STRING initialize it to the given WSTR
  15. //
  16. // Parameters:
  17. // pustr - the UNICODE_STRING to initialize
  18. // psz - the WSTR to use to initialize the UNICODE_STRING
  19. //
  20. // Notes: This differs from the RtlInitUnicodeString in that the
  21. // MaximumLength value contains the terminating null
  22. //
  23. //-------------------------------------------------------------------
  24. void
  25. SetUnicodeString (
  26. IN OUT UNICODE_STRING* pustr,
  27. IN LPCWSTR psz )
  28. {
  29. AssertSz( pustr != NULL, "Invalid Argument" );
  30. AssertSz( psz != NULL, "Invalid Argument" );
  31. pustr->Buffer = const_cast<PWSTR>(psz);
  32. pustr->Length = (USHORT)(lstrlenW(pustr->Buffer) * sizeof(WCHAR));
  33. pustr->MaximumLength = pustr->Length + sizeof(WCHAR);
  34. }
  35. //-------------------------------------------------------------------
  36. // Function: SetUnicodeMultiString
  37. //
  38. // Purpose: given a UNICODE_STRING initialize it to the given WSTR
  39. // multi string buffer
  40. //
  41. // Parameters:
  42. // pustr - the UNICODE_STRING to initialize
  43. // pmsz - the multi sz WSTR to use to initialize the UNICODE_STRING
  44. //
  45. //-------------------------------------------------------------------
  46. void
  47. SetUnicodeMultiString (
  48. IN OUT UNICODE_STRING* pustr,
  49. IN LPCWSTR pmsz )
  50. {
  51. AssertSz( pustr != NULL, "Invalid Argument" );
  52. AssertSz( pmsz != NULL, "Invalid Argument" );
  53. pustr->Buffer = const_cast<PWSTR>(pmsz);
  54. // Note: Length does NOT include terminating NULL
  55. pustr->Length = (USHORT)(StrLenW(pustr->Buffer) * sizeof(WCHAR));
  56. pustr->MaximumLength = pustr->Length;
  57. }