| 844 | //////////////////////////////////////////////////////////// |
| 845 | |
| 846 | bool validateProductSuite (LPCSTR lpszSuiteToValidate) |
| 847 | { |
| 848 | NTRegQuery query; |
| 849 | |
| 850 | // Open the ProductOptions key. |
| 851 | if (!query.openForRead("System\\CurrentControlSet\\Control\\ProductOptions")) |
| 852 | return false; |
| 853 | |
| 854 | // Determine required size of ProductSuite buffer. |
| 855 | // If we get size == 1 it means multi string data with only a terminator. |
| 856 | if (!query.readValueSize("ProductSuite") || query.getDataSize() < 2) |
| 857 | return false; |
| 858 | |
| 859 | // Allocate buffer. |
| 860 | NTLocalString lpszProductSuites(query.getDataSize()); |
| 861 | if (!lpszProductSuites.allocated()) |
| 862 | return false; |
| 863 | |
| 864 | // Retrieve array of product suite strings. |
| 865 | if (!query.readValueData(lpszProductSuites.getString()) || query.getDataType() != REG_MULTI_SZ) |
| 866 | return false; |
| 867 | |
| 868 | query.close(); // explicit but redundant. |
| 869 | |
| 870 | // Search for suite name in array of strings. |
| 871 | bool fValidated = false; |
| 872 | LPCSTR lpszSuite = lpszProductSuites.c_str(); |
| 873 | LPCSTR end = lpszSuite + query.getDataSize(); // paranoid check |
| 874 | while (*lpszSuite && lpszSuite < end) |
| 875 | { |
| 876 | if (lstrcmpA(lpszSuite, lpszSuiteToValidate) == 0) |
| 877 | { |
| 878 | fValidated = true; |
| 879 | break; |
| 880 | } |
| 881 | lpszSuite += (lstrlenA(lpszSuite) + 1); |
| 882 | } |
| 883 | |
| 884 | return fValidated; |
| 885 | } |
| 886 | |
| 887 | #endif // WIN_NT |
| 888 |
no test coverage detected