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.

75 lines
1.5 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. dpapi.c
  5. Abstract:
  6. WMI data provider api set
  7. Author:
  8. 16-Jan-1997 AlanWar
  9. Revision History:
  10. --*/
  11. #include <nt.h>
  12. #include "wmiump.h"
  13. #include "trcapi.h"
  14. ULONG EtwpCopyStringToCountedUnicode(
  15. LPCWSTR String,
  16. PWCHAR CountedString,
  17. ULONG *BytesUsed,
  18. BOOLEAN ConvertFromAnsi
  19. )
  20. /*++
  21. Routine Description:
  22. This routine will copy an ansi ro unicode C string to a counted unicode
  23. string.
  24. Arguments:
  25. String is the ansi or unicode incoming string
  26. Counted string is a pointer to where to write counted unicode string
  27. *BytesUsed returns number of bytes used to build counted unicode string
  28. ConvertFromAnsi is TRUE if String is an ANSI string
  29. Return Value:
  30. ERROR_SUCCESS or an error code
  31. --*/
  32. {
  33. USHORT StringSize;
  34. PWCHAR StringPtr = CountedString+1;
  35. ULONG Status;
  36. if (ConvertFromAnsi)
  37. {
  38. StringSize = (strlen((PCHAR)String) +1) * sizeof(WCHAR);
  39. Status = EtwpAnsiToUnicode((PCHAR)String,
  40. &StringPtr);
  41. } else {
  42. StringSize = (wcslen(String) +1) * sizeof(WCHAR);
  43. wcscpy(StringPtr, String);
  44. Status = ERROR_SUCCESS;
  45. }
  46. *CountedString = StringSize;
  47. *BytesUsed = StringSize + sizeof(USHORT);
  48. return(Status);
  49. }