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
1.6 KiB

  1. // from base\ntos\rtl\rtlvalidateunicodestring.c
  2. // should be gotten from a static .lib
  3. /*++
  4. Copyright (c) Microsoft Corporation
  5. Module Name:
  6. rtlvalidateunicodestring.c
  7. Abstract:
  8. This module implements NLS support functions for NT.
  9. Author:
  10. Mark Lucovsky (markl) 16-Apr-1991
  11. Environment:
  12. Kernel or user-mode
  13. Revision History:
  14. 16-Feb-1993 JulieB Added Upcase Rtl Routines.
  15. 08-Mar-1993 JulieB Moved Upcase Macro to ntrtlp.h.
  16. 02-Apr-1993 JulieB Fixed RtlAnsiCharToUnicodeChar to use transl. tbls.
  17. 02-Apr-1993 JulieB Fixed BUFFER_TOO_SMALL check.
  18. 28-May-1993 JulieB Fixed code to properly handle DBCS.
  19. November 30, 2001 JayKrell broken out of nls.c for easier reuse
  20. --*/
  21. #include "spprecmp.h"
  22. NTSTATUS
  23. RtlValidateUnicodeString(
  24. ULONG Flags,
  25. const UNICODE_STRING *String
  26. )
  27. {
  28. NTSTATUS Status = STATUS_SUCCESS;
  29. ASSERT(Flags == 0);
  30. if (Flags != 0) {
  31. Status = STATUS_INVALID_PARAMETER;
  32. goto Exit;
  33. }
  34. if (String != NULL) {
  35. if (((String->Length % 2) != 0) ||
  36. ((String->MaximumLength % 2) != 0) ||
  37. (String->Length > String->MaximumLength)) {
  38. Status = STATUS_INVALID_PARAMETER;
  39. goto Exit;
  40. }
  41. if (((String->Length != 0) ||
  42. (String->MaximumLength != 0)) &&
  43. (String->Buffer == NULL)) {
  44. Status = STATUS_INVALID_PARAMETER;
  45. goto Exit;
  46. }
  47. }
  48. Status = STATUS_SUCCESS;
  49. Exit:
  50. return Status;
  51. }