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.

259 lines
10 KiB

  1. #include <string.h>
  2. #include <ntverp.h>
  3. #include "priv.h"
  4. #include "ids.h"
  5. #define SECURITY_WIN32
  6. #include <schnlsp.h> // for UNISP_NAME_A
  7. #include <sspi.h> // for SCHANNEL.dll api -- to obtain encryption key size
  8. #include <mluisupp.h>
  9. #include <wininet.h> // INTERNET_MAX_URL_LENGTH
  10. typedef PSecurityFunctionTableA (APIENTRY *INITSECURITYINTERFACE_FN_A)(void);
  11. // Returns the maximum cipher strength
  12. DWORD GetCipherStrength()
  13. {
  14. static DWORD dwKeySize = (DWORD)-1;
  15. if (dwKeySize == (DWORD)-1)
  16. {
  17. HINSTANCE hSecurity;
  18. dwKeySize = 0;
  19. hSecurity = LoadLibrary(TEXT("security.dll"));
  20. if (hSecurity)
  21. {
  22. INITSECURITYINTERFACE_FN_A pfnInitSecurityInterfaceA;
  23. // Get the SSPI dispatch table
  24. pfnInitSecurityInterfaceA = (INITSECURITYINTERFACE_FN_A)GetProcAddress(hSecurity, "InitSecurityInterfaceA");
  25. if (pfnInitSecurityInterfaceA)
  26. {
  27. PSecurityFunctionTableA pSecFuncTable;
  28. pSecFuncTable = pfnInitSecurityInterfaceA();
  29. if (pSecFuncTable &&
  30. pSecFuncTable->AcquireCredentialsHandleA &&
  31. pSecFuncTable->QueryCredentialsAttributesA)
  32. {
  33. TimeStamp tsExpiry;
  34. CredHandle chCred;
  35. SecPkgCred_CipherStrengths cs;
  36. if (SEC_E_OK == (*pSecFuncTable->AcquireCredentialsHandleA)(NULL,
  37. UNISP_NAME_A, // Package
  38. SECPKG_CRED_OUTBOUND,
  39. NULL,
  40. NULL,
  41. NULL,
  42. NULL,
  43. &chCred, // Handle
  44. &tsExpiry))
  45. {
  46. if (SEC_E_OK == (*pSecFuncTable->QueryCredentialsAttributesA)(&chCred, SECPKG_ATTR_CIPHER_STRENGTHS, &cs))
  47. {
  48. dwKeySize = cs.dwMaximumCipherStrength;
  49. }
  50. // Free the handle if we can
  51. if (pSecFuncTable->FreeCredentialsHandle)
  52. {
  53. (*pSecFuncTable->FreeCredentialsHandle)(&chCred);
  54. }
  55. }
  56. }
  57. }
  58. FreeLibrary(hSecurity);
  59. }
  60. }
  61. return dwKeySize;
  62. }
  63. typedef struct
  64. {
  65. WCHAR szVersion[64];
  66. WCHAR szVBLVersion[64];
  67. WCHAR szCustomizedVersion[3];
  68. WCHAR szUserName[256];
  69. WCHAR szCompanyName[256];
  70. DWORD dwKeySize;
  71. WCHAR szProductId[256];
  72. WCHAR szUpdateUrl[INTERNET_MAX_URL_LENGTH];
  73. WCHAR szIEAKStr[256];
  74. } SHABOUTINFOW;
  75. BOOL SHAboutInfoW(LPWSTR pszInfo, DWORD cchInfo)
  76. {
  77. HRESULT hr = E_FAIL;
  78. if (cchInfo > 0)
  79. {
  80. SHABOUTINFOW* pInfo;
  81. pszInfo[0] = L'\0';
  82. pInfo = (SHABOUTINFOW*)LocalAlloc(LPTR, sizeof(SHABOUTINFOW));
  83. if (pInfo)
  84. {
  85. DWORD cbSize;
  86. if (GetModuleHandle(TEXT("EXPLORER.EXE")) || GetModuleHandle(TEXT("IEXPLORE.EXE")))
  87. {
  88. // get the Version number (version string is in the following format 5.00.xxxx.x)
  89. cbSize = sizeof(pInfo->szVersion);
  90. SHRegGetValueW(HKEY_LOCAL_MACHINE,
  91. L"SOFTWARE\\Microsoft\\Internet Explorer",
  92. L"Version",
  93. SRRF_RT_REG_SZ | SRRF_ZEROONFAILURE,
  94. NULL,
  95. pInfo->szVersion,
  96. &cbSize);
  97. // get the VBL version info (vbl string is in the following format 2600.lab.yymmdd)
  98. cbSize = sizeof(pInfo->szVBLVersion);
  99. if (ERROR_SUCCESS == SHRegGetValueW(HKEY_LOCAL_MACHINE,
  100. L"Software\\Microsoft\\Windows NT\\Current Version",
  101. L"BuildLab",
  102. SRRF_RT_REG_SZ | SRRF_ZEROONFAILURE,
  103. NULL,
  104. pInfo->szVBLVersion,
  105. &cbSize))
  106. {
  107. int cchVBLVersion = lstrlenW(pInfo->szVBLVersion);
  108. if (cchVBLVersion > 12) // 12 for "2600.?.yymmdd"
  109. {
  110. // The "BuildLab" reg value contains the VBL build # in the format: "2204.reinerf.010700"
  111. // Since we are only interested in the latter part, we remove the first 4 digits
  112. MoveMemory(pInfo->szVBLVersion, &pInfo->szVBLVersion[4], (cchVBLVersion - 4 + 1) * sizeof(WCHAR));
  113. }
  114. else
  115. {
  116. pInfo->szVBLVersion[0] = L'\0';
  117. }
  118. }
  119. }
  120. else
  121. {
  122. // Not in the explorer or iexplore process so we are doing some side by side stuff so
  123. // reflect this in the version string. Maybe we should get the version out of MSHTML
  124. // but not sure since this still doesn't reflect IE4 or IE5 properly anyway.
  125. MLLoadStringW(IDS_SIDEBYSIDE, pInfo->szVersion, ARRAYSIZE(pInfo->szVersion));
  126. }
  127. // added by pritobla on 9/1/98
  128. // CustomizedVersion contains a 2-letter code that identifies what mode was used
  129. // (CORP, ICP, ISP, etc.) in building this version IE using the IEAK.
  130. cbSize = sizeof(pInfo->szCustomizedVersion);
  131. SHRegGetValueW(HKEY_LOCAL_MACHINE,
  132. L"SOFTWARE\\Microsoft\\Internet Explorer",
  133. L"CustomizedVersion",
  134. SRRF_RT_REG_SZ | SRRF_ZEROONFAILURE,
  135. NULL,
  136. pInfo->szCustomizedVersion,
  137. &cbSize);
  138. // get the User name.
  139. cbSize = sizeof(pInfo->szUserName);
  140. SHRegGetValueW(HKEY_LOCAL_MACHINE,
  141. L"Software\\Microsoft\\Windows NT\\Current Version",
  142. L"RegisteredOwner",
  143. SRRF_RT_REG_SZ | SRRF_ZEROONFAILURE,
  144. NULL,
  145. pInfo->szUserName,
  146. &cbSize);
  147. // get the Organization name.
  148. cbSize = sizeof(pInfo->szCompanyName);
  149. SHRegGetValueW(HKEY_LOCAL_MACHINE,
  150. L"Software\\Microsoft\\Windows NT\\Current Version",
  151. L"RegisteredOrganization",
  152. SRRF_RT_REG_SZ | SRRF_ZEROONFAILURE,
  153. NULL,
  154. pInfo->szCompanyName,
  155. &cbSize);
  156. // get the encription key size
  157. pInfo->dwKeySize = GetCipherStrength();
  158. cbSize = sizeof(pInfo->szProductId);
  159. SHRegGetValueW(HKEY_LOCAL_MACHINE,
  160. L"SOFTWARE\\Microsoft\\Internet Explorer\\Registration",
  161. L"ProductId",
  162. SRRF_RT_REG_SZ | SRRF_ZEROONFAILURE,
  163. NULL,
  164. pInfo->szProductId,
  165. &cbSize);
  166. // get the custom IEAK update url
  167. // (always get from Windows\CurrentVersion because IEAK policy file must be independent)
  168. cbSize = sizeof(pInfo->szUpdateUrl);
  169. SHRegGetValueW(HKEY_LOCAL_MACHINE,
  170. L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion",
  171. L"IEAKUpdateUrl",
  172. SRRF_RT_REG_SZ | SRRF_ZEROONFAILURE,
  173. NULL,
  174. pInfo->szUpdateUrl,
  175. &cbSize);
  176. // get the custom IEAK branded help string
  177. cbSize = sizeof(pInfo->szIEAKStr);
  178. SHRegGetValueW(HKEY_LOCAL_MACHINE,
  179. L"SOFTWARE\\Microsoft\\Internet Explorer\\Registration",
  180. L"IEAKHelpString",
  181. SRRF_RT_REG_SZ | SRRF_ZEROONFAILURE,
  182. NULL,
  183. pInfo->szIEAKStr,
  184. &cbSize);
  185. // glue all of the peices together
  186. hr = StringCchPrintfExW(pszInfo,
  187. cchInfo,
  188. NULL,
  189. NULL,
  190. STRSAFE_NULL_ON_FAILURE,
  191. L"%s%s%s~%s~%s~%d~%s~%s~%s",
  192. pInfo->szVersion,
  193. pInfo->szVBLVersion,
  194. pInfo->szCustomizedVersion,
  195. pInfo->szUserName,
  196. pInfo->szCompanyName,
  197. pInfo->dwKeySize,
  198. pInfo->szProductId,
  199. pInfo->szUpdateUrl,
  200. pInfo->szIEAKStr);
  201. LocalFree(pInfo);
  202. }
  203. }
  204. return SUCCEEDED(hr);
  205. }
  206. BOOL SHAboutInfoA(LPSTR pszInfoA, DWORD cchInfoA)
  207. {
  208. BOOL bRet = FALSE;
  209. LPWSTR pszTemp;
  210. if (cchInfoA > 0)
  211. {
  212. DWORD cchTemp = cchInfoA;
  213. pszInfoA[0] = '\0';
  214. pszTemp = (LPWSTR)LocalAlloc(LPTR, cchTemp * sizeof(WCHAR));
  215. if (pszTemp)
  216. {
  217. bRet = SHAboutInfoW(pszTemp, cchTemp) && SHUnicodeToAnsi(pszTemp, pszInfoA, cchInfoA);
  218. LocalFree(pszTemp);
  219. }
  220. }
  221. return bRet;
  222. }