/*++ Copyright (c) 1992 Microsoft Corporation Module Name: util.c Abstract: Contains miscellaneous utility functions used by the Service Controller: ScIsValidServiceName Author: Rita Wong (ritaw) 15-Mar-1992 Environment: User Mode -Win32 Revision History: 11-Apr-1992 JohnRo Added an assertion check. Include so compiler checks prototypes. 20-May-1992 JohnRo winsvc.h and related file cleanup. --*/ #include #include #include #include #include #include // SC_ASSERT(). #include // My prototype. #include // MAX_SERVICE_NAME_LENGTH BOOL ScIsValidServiceName( IN LPCWSTR ServiceName ) /*++ Routine Description: This function validates a given service name. The name length cannot be greater than 256 characters, and must not contain any forward-slash, or back-slash. Arguments: ServiceName - Supplies the service name to be validated. Return Value: TRUE - The name is valid. FALSE - The name is invalid. --*/ { LPCWSTR IllegalChars = L"\\/"; DWORD NameLength; SC_ASSERT( ServiceName != NULL ); // Avoid memory access fault in wcslen(). if (*ServiceName == 0) { return FALSE; } if ((NameLength = (DWORD) wcslen(ServiceName)) > MAX_SERVICE_NAME_LENGTH) { return FALSE; } if (wcscspn(ServiceName, IllegalChars) < NameLength) { return FALSE; } return TRUE; }