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.

66 lines
1.5 KiB

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