Source code of Windows XP (NT5)
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.

94 lines
2.3 KiB

  1. /* Copyright (c) 1994, Microsoft Corporation, all rights reserved
  2. **
  3. ** encrypt.c
  4. ** Remote Access
  5. ** Encryption check routine
  6. **
  7. ** 06/16/94 Steve Cobb
  8. **
  9. ** Note: This is in a separate file because it requires version.lib which is
  10. ** not otherwise needed by many utility library users.
  11. */
  12. #include <windows.h>
  13. #include <stdlib.h>
  14. #include <string.h>
  15. #define INCL_ENCRYPT
  16. #include <ppputil.h>
  17. BOOL
  18. IsEncryptionPermitted()
  19. /* Returns true if encryption is permitted in this version of the product,
  20. ** false if not. Currently encryption is allowed unless the NT shell
  21. ** language(s) include French for France. If any errors occur attempting
  22. ** to retrieve the information, encryption is not allowed.
  23. */
  24. {
  25. BOOL fStatus = FALSE;
  26. CHAR szUser32DllPath[ MAX_PATH + 1 ];
  27. DWORD dwUnused;
  28. CHAR* pVersionInfo = NULL;
  29. DWORD cbVersionInfo;
  30. WORD* pTranslationInfo;
  31. DWORD cbTranslationInfo;
  32. DWORD cTranslations;
  33. DWORD i;
  34. do
  35. {
  36. /* Find the path to USER32.DLL.
  37. */
  38. if (GetSystemDirectory( szUser32DllPath, MAX_PATH + 1 ) == 0)
  39. break;
  40. strcat( szUser32DllPath, "\\USER32.DLL" );
  41. /* Retrieve the version information for USER32.DLL.
  42. */
  43. cbVersionInfo = GetFileVersionInfoSize( szUser32DllPath, &dwUnused );
  44. if (!(pVersionInfo = malloc( cbVersionInfo )))
  45. break;
  46. if (!GetFileVersionInfo(
  47. szUser32DllPath, 0, cbVersionInfo, pVersionInfo ))
  48. {
  49. break;
  50. }
  51. /* Find the table of language/char-set identifier pairs indicating the
  52. ** language(s) available in the file.
  53. */
  54. if (!VerQueryValue(
  55. pVersionInfo, "\\VarFileInfo\\Translation",
  56. (LPVOID )&pTranslationInfo, &cbTranslationInfo ))
  57. {
  58. break;
  59. }
  60. /* Scan the table for French for France.
  61. */
  62. cTranslations = cbTranslationInfo / sizeof(DWORD);
  63. for (i = 0; i < cTranslations; ++i)
  64. {
  65. if (pTranslationInfo[ i * 2 ] == 0x040C)
  66. break;
  67. }
  68. if (i < cTranslations)
  69. break;
  70. /* No French for France so encryption is permitted.
  71. */
  72. fStatus = TRUE;
  73. }
  74. while (FALSE);
  75. if (pVersionInfo)
  76. free( pVersionInfo );
  77. return fStatus;
  78. }