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.

111 lines
2.1 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. Path.c
  5. Abstract:
  6. Contains image path functions:
  7. ScIsValidImagePath
  8. ScImagePathsMatch
  9. Author:
  10. John Rogers (JohnRo) 10-Apr-1992
  11. Environment:
  12. User Mode -Win32
  13. Revision History:
  14. 10-Apr-1992 JohnRo
  15. Created.
  16. 20-May-1992 JohnRo
  17. Use CONST where possible.
  18. --*/
  19. #include <scpragma.h>
  20. #include <nt.h>
  21. #include <ntrtl.h>
  22. #include <nturtl.h>
  23. #include <windef.h>
  24. #include <scdebug.h> // SC_ASSERT().
  25. #include <sclib.h> // My prototypes.
  26. #include <valid.h> // SERVICE_TYPE_INVALID().
  27. #include <stdlib.h> // _wcsicmp().
  28. #include <winsvc.h> // SERVICE_ equates.
  29. BOOL
  30. ScIsValidImagePath(
  31. IN LPCWSTR ImagePathName,
  32. IN DWORD ServiceType
  33. )
  34. /*++
  35. Routine Description:
  36. This function validates a given image path name.
  37. It makes sure the path name is consistent with the service type.
  38. For instance, a file name of .SYS is used for SERVICE_DRIVER only.
  39. Arguments:
  40. ImagePathName - Supplies the image path name to be validated.
  41. ServiceType - Tells which kind of service the path name must be
  42. consistent with. ServiceType must be valid.
  43. Return Value:
  44. TRUE - The name is valid.
  45. FALSE - The name is invalid.
  46. --*/
  47. {
  48. if (ImagePathName == NULL) {
  49. return (FALSE); // Not valid.
  50. } else if ( (*ImagePathName) == L'\0' ) {
  51. return (FALSE); // Not valid.
  52. }
  53. SC_ASSERT( !SERVICE_TYPE_INVALID( ServiceType ) );
  54. return TRUE;
  55. } // ScIsValidImagePath
  56. BOOL
  57. ScImagePathsMatch(
  58. IN LPCWSTR OnePath,
  59. IN LPCWSTR TheOtherPath
  60. )
  61. {
  62. SC_ASSERT( OnePath != NULL );
  63. SC_ASSERT( TheOtherPath != NULL );
  64. SC_ASSERT( (*OnePath) != L'\0' );
  65. SC_ASSERT( (*TheOtherPath) != L'\0' );
  66. if ( _wcsicmp( OnePath, TheOtherPath ) == 0 ) {
  67. return (TRUE); // They match.
  68. } else {
  69. return (FALSE); // They don't match.
  70. }
  71. } // ScImagePathsMatch