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.

145 lines
5.2 KiB

  1. #include "wudetect.h"
  2. ///////////////////////////////////////////////////////////////////////////////////////////
  3. //
  4. // Function IsThisFileDomesticOnly
  5. //-----------------------------------------------------------------------------------------
  6. //
  7. // Return Value --- TRUE if the specified file is for domestic only
  8. // Parameter
  9. // LPTSTR lpFileName --- [IN] filename of the file needed to be examined
  10. ///////////////////////////////////////////////////////////////////////////////////////////
  11. //
  12. // Modified by RogerJ, 03/08/00
  13. // Original Creator Unknown
  14. // Modification --- UNICODE and Win64 ready, other minor modifications
  15. //
  16. ///////////////////////////////////////////////////////////////////////////////////////////
  17. bool IsThisFileDomesticOnly(LPTSTR lpFileName)
  18. {
  19. // string constants have been modified to lower case only to save run time conversion
  20. TCHAR DomesticTag1[] = TEXT(/*"US/Canada Only, Not for Export"*/"us/canada only, not for export");
  21. TCHAR DomesticTag2[] = TEXT(/*"Domestic Use Only"*/"domestic use only");
  22. TCHAR DomesticTag3[] = TEXT(/*"US and Canada Use Only"*/"us and canada use only");
  23. TCHAR Description1[ MAX_PATH ];
  24. DWORD DefLang = 0x04b00409;
  25. DWORD dwLen;
  26. PVOID VersionBlock;
  27. UINT DataLength;
  28. DWORD dwHandle;
  29. LPTSTR Description;
  30. TCHAR ValueTag[ MAX_PATH ];
  31. PDWORD pdwTranslation;
  32. UINT uLen;
  33. bool fDomestic = false;
  34. if ((dwLen = GetFileVersionInfoSize((LPTSTR)lpFileName, &dwHandle)) != 0 )
  35. {
  36. if ((VersionBlock = malloc(dwLen)) != NULL )
  37. {
  38. if (GetFileVersionInfo((LPTSTR)lpFileName, dwHandle, dwLen, VersionBlock))
  39. {
  40. if (!VerQueryValue(VersionBlock, TEXT("\\VarFileInfo\\Translation"), (void **)&pdwTranslation, &uLen))
  41. {
  42. pdwTranslation = &DefLang;
  43. uLen = sizeof(DWORD);
  44. }
  45. wsprintf( ValueTag, TEXT("\\StringFileInfo\\%04x%04x\\FileDescription"),
  46. LOWORD(*pdwTranslation), HIWORD(*pdwTranslation) );
  47. if (VerQueryValue( VersionBlock,
  48. ValueTag,
  49. (void **)&Description,
  50. &DataLength))
  51. {
  52. _tcscpy( Description1, Description );
  53. _tcslwr( Description1 );
  54. /*
  55. // modification made directly to the string to save runtime conversion
  56. _tcslwr( DomesticTag1 );
  57. _tcslwr( DomesticTag2 );
  58. _tcslwr( DomesticTag3 );
  59. */
  60. if (( _tcsstr( Description1, DomesticTag1 )) ||
  61. ( _tcsstr( Description1, DomesticTag2 )) ||
  62. ( _tcsstr( Description1, DomesticTag3 )))
  63. {
  64. fDomestic = true;
  65. }
  66. }
  67. }
  68. }
  69. free(VersionBlock);
  70. dwHandle = 0L;
  71. }
  72. return fDomestic;
  73. }
  74. /////////////////////////////////////////////////////////////////////////////
  75. // CExpressionParser::fDetect40BitSecurity
  76. // Detect if 40-bit security is installed.
  77. //
  78. // Form: E=40BitSec
  79. // Notes:
  80. // If any of the following files are 128 bit, you can assume it's a 128bit system:
  81. //
  82. // (in system32)
  83. // schannel.dll
  84. // security.dll
  85. // ntlmssps.dll
  86. //
  87. // (in system32\drivers)
  88. // ndiswan.sys
  89. //
  90. /////////////////////////////////////////////////////////////////////////////
  91. /////////////////////////////////////////////////////////////////////////////
  92. //
  93. // Class CExpressionParser (declared in expression.h)
  94. // Function fDetect40BitSecurity
  95. //---------------------------------------------------------------------------
  96. //
  97. // Return Value --- true if the system has 40 bit security
  98. // Parameter
  99. // TCHAR* pszBuf --- [IN] ignored
  100. /////////////////////////////////////////////////////////////////////////////
  101. //
  102. // Modified by RogerJ, 03/08/00
  103. // Original Creator Unknown
  104. // Modification --- UNICODE and Win64 ready, other minor modifications
  105. //
  106. /////////////////////////////////////////////////////////////////////////////
  107. bool CExpressionParser::fDetect40BitSecurity(TCHAR * pszBuf)
  108. {
  109. bool fSuccess = true;
  110. TCHAR szSystemDir[MAX_PATH];
  111. TCHAR szFilePath[MAX_PATH];
  112. TCHAR *grFileList[] = { TEXT("schannel.dll"),
  113. TEXT("security.dll"),
  114. TEXT("ntlmssps.dll"),
  115. TEXT("drivers\\ndiswan.sys") };
  116. if ( GetSystemDirectory(szSystemDir, sizeof(szSystemDir)/sizeof(TCHAR)) != 0 )
  117. {
  118. // check see if the last character in szSystemDir is backslash, which will happen if the
  119. // system directory is the root directory
  120. if (szSystemDir[_tcslen(szSystemDir)-1]!='\\')
  121. _tcscat(szSystemDir, TEXT("\\"));
  122. for ( int index = 0;
  123. fSuccess && (index < (sizeof(grFileList)/sizeof(grFileList[0])));
  124. index++ )
  125. {
  126. _tcscpy(szFilePath, szSystemDir);
  127. _tcscat(szFilePath, grFileList[index]);
  128. fSuccess = !IsThisFileDomesticOnly(szFilePath);
  129. }
  130. }
  131. return fSuccess;
  132. }