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.

388 lines
13 KiB

  1. #include "pch.h"
  2. HINSTANCE g_hInst;
  3. HINSTANCE g_hDllInst;
  4. LPTSTR g_szInsFile;
  5. TCHAR g_szWorkDir[MAX_PATH];
  6. TCHAR g_szDefInf[MAX_PATH];
  7. TCHAR g_szFrom[5 * MAX_PATH];
  8. HWND g_hDlg;
  9. typedef struct _insdlg
  10. {
  11. LPTSTR DlgId;
  12. LPTSTR szName;
  13. DLGPROC dlgproc;
  14. DWORD hItem;
  15. HRESULT (WINAPI *pfnFinalCopy)(LPCTSTR psczDestDir, DWORD dwFlags, LPDWORD pdwCabState);
  16. } INSDLG, *LPINSDLG;
  17. BOOL g_bInitialize = FALSE;
  18. DWORD g_dwPlatformId = PLATFORM_WIN32;
  19. INT_PTR CALLBACK TitleProc ( HWND, UINT, WPARAM, LPARAM );
  20. INT_PTR CALLBACK LogoProc ( HWND, UINT, WPARAM, LPARAM );
  21. INT_PTR CALLBACK CabSignProc ( HWND, UINT, WPARAM, LPARAM );
  22. INT_PTR CALLBACK SupportProc ( HWND, UINT, WPARAM, LPARAM );
  23. INT_PTR CALLBACK UserAgentProc ( HWND, UINT, WPARAM, LPARAM );
  24. INT_PTR CALLBACK ProxyProc ( HWND, UINT, WPARAM, LPARAM );
  25. INT_PTR CALLBACK BToolbarProc ( HWND, UINT, WPARAM, LPARAM );
  26. INT_PTR CALLBACK FavsProc ( HWND, UINT, WPARAM, LPARAM );
  27. INT_PTR CALLBACK StartSearchProc ( HWND, UINT, WPARAM, LPARAM );
  28. INT_PTR CALLBACK MailProc ( HWND, UINT, WPARAM, LPARAM );
  29. INT_PTR CALLBACK LdapProc ( HWND, UINT, WPARAM, LPARAM );
  30. INT_PTR CALLBACK SignatureProc ( HWND, UINT, WPARAM, LPARAM );
  31. INT_PTR CALLBACK DlgProc ( HWND, UINT, WPARAM, LPARAM );
  32. INT_PTR CALLBACK WallPaperProc ( HWND, UINT, WPARAM, LPARAM );
  33. #define INSDIALOG_COUNT 27
  34. INSDLG dialog[INSDIALOG_COUNT];
  35. int g_nInsDialogsVisible = 0;
  36. BOOL g_fInsDirty = FALSE;
  37. void InitializeInsDialogProcs();
  38. BOOL WINAPI DllMain( HINSTANCE hModule, DWORD fdwReason, LPVOID /*lpReserved*/ )
  39. {
  40. int nIndex = 0;
  41. TCHAR szTitle[MAX_PATH];
  42. TCHAR szMsg[MAX_PATH];
  43. g_hDllInst = hModule;
  44. if(fdwReason == DLL_PROCESS_ATTACH && !g_bInitialize)
  45. {
  46. g_hInst = LoadLibrary(TEXT("ieakui.dll"));
  47. if (g_hInst == NULL)
  48. {
  49. LoadString(g_hInst, IDS_INSDLL_TITLE, szTitle, ARRAYSIZE(szTitle));
  50. LoadString(g_hInst, IDS_IEAKUI_LOADERROR, szMsg, ARRAYSIZE(szMsg));
  51. MessageBox(NULL, szMsg, szTitle, MB_OK | MB_SETFOREGROUND);
  52. return FALSE;
  53. }
  54. ZeroMemory(g_szDefInf, sizeof(g_szDefInf));
  55. InitializeInsDialogProcs();
  56. g_bInitialize = TRUE;
  57. }
  58. else if(fdwReason == DLL_PROCESS_DETACH && g_bInitialize)
  59. {
  60. for(nIndex = 0; nIndex < g_nInsDialogsVisible; nIndex++)
  61. {
  62. if(dialog[nIndex].szName)
  63. {
  64. LocalFree((HLOCAL) dialog[nIndex].szName);
  65. ZeroMemory(&dialog[nIndex], sizeof(dialog[nIndex]));
  66. }
  67. }
  68. g_nInsDialogsVisible = 0;
  69. g_bInitialize = FALSE;
  70. if(g_hInst)
  71. FreeLibrary(g_hInst);
  72. }
  73. return TRUE;
  74. }
  75. INT_PTR CALLBACK DlgProc( HWND /*hWnd*/, UINT msg, WPARAM /*wParam*/, LPARAM /*lParam*/ )
  76. {
  77. switch( msg )
  78. {
  79. case WM_INITDIALOG:
  80. break;
  81. default:
  82. return FALSE;
  83. }
  84. return TRUE;
  85. }
  86. LPINSDLG GetInsDlgStruct( int *nDialogs )
  87. {
  88. *nDialogs = g_nInsDialogsVisible;
  89. return dialog;
  90. }
  91. HWND CreateInsDialog( HWND hWnd, int x, int y, int nIndex, LPTSTR szInsFile, LPTSTR szWorkDir )
  92. {
  93. HWND hDialog;
  94. RECT r;
  95. long lStyle;
  96. PVOID lpTemplate;
  97. g_szInsFile = szInsFile;
  98. ZeroMemory(g_szWorkDir, sizeof(g_szWorkDir));
  99. StrCpy(g_szWorkDir, szWorkDir);
  100. lStyle = DS_CONTROL | DS_3DLOOK | DS_SETFONT | WS_CHILD;
  101. if(PrepareDlgTemplate(g_hInst, PtrToUint(dialog[nIndex].DlgId), (DWORD) lStyle, &lpTemplate) != S_OK)
  102. return NULL;
  103. hDialog = CreateDialogIndirect( g_hInst, (LPCDLGTEMPLATE) lpTemplate, hWnd, dialog[nIndex].dlgproc );
  104. if(hDialog == NULL)
  105. return NULL;
  106. CoTaskMemFree(lpTemplate);
  107. GetWindowRect( hDialog, &r );
  108. MoveWindow( hDialog, x, y, r.right-r.left, r.bottom-r.top, TRUE );
  109. ShowWindow( hDialog, SW_SHOWNORMAL );
  110. return hDialog;
  111. }
  112. void InitializeInsDialogProcs()
  113. {
  114. TCHAR szString[512];
  115. HINSTANCE hShell;
  116. SHELLFLAGSTATE sfs;
  117. int nIndex = 0;
  118. dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_BTITLE );
  119. LoadString(g_hInst, IDS_BTITLE, szString, ARRAYSIZE(szString));
  120. dialog[nIndex].szName = StrDup(szString);
  121. dialog[nIndex].dlgproc = TitleProc;
  122. dialog[nIndex++].pfnFinalCopy = NULL;
  123. dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_CUSTICON );
  124. LoadString(g_hInst, IDS_CUSTICON2, szString, ARRAYSIZE(szString));
  125. dialog[nIndex].szName = StrDup(szString);
  126. dialog[nIndex].dlgproc = LogoProc;
  127. dialog[nIndex++].pfnFinalCopy = NULL;
  128. if (g_dwPlatformId == PLATFORM_WIN32)
  129. {
  130. dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_CABSIGN );
  131. LoadString(g_hInst, IDS_CABSIGN, szString, ARRAYSIZE(szString));
  132. dialog[nIndex].szName = StrDup(szString);
  133. dialog[nIndex].dlgproc = CabSignProc;
  134. dialog[nIndex++].pfnFinalCopy = NULL;
  135. }
  136. /*dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_ONLINESUPPORT );
  137. LoadString(g_hInst, IDS_ONLINESUPPORT, szString, ARRAYSIZE(szString));
  138. dialog[nIndex].szName = StrDup(szString);
  139. dialog[nIndex].dlgproc = SupportProc;
  140. dialog[nIndex++].pfnFinalCopy = NULL;*/
  141. dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_FAVORITES );
  142. LoadString(g_hInst, IDS_FAVORITES2, szString, ARRAYSIZE(szString));
  143. dialog[nIndex].szName = StrDup(szString);
  144. dialog[nIndex].dlgproc = FavsProc;
  145. dialog[nIndex++].pfnFinalCopy = NULL;
  146. dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_BTOOLBARS );
  147. LoadString(g_hInst, IDS_BTOOLBAR, szString, ARRAYSIZE(szString));
  148. dialog[nIndex].szName = StrDup(szString);
  149. dialog[nIndex].dlgproc = BToolbarProc;
  150. dialog[nIndex++].pfnFinalCopy = BToolbarsFinalCopy;
  151. /*if (g_dwPlatformId == PLATFORM_WIN32)
  152. {
  153. dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_DWALLPAPER );
  154. LoadString(g_hInst, IDS_DWALLPAPER, szString, ARRAYSIZE(szString));
  155. dialog[nIndex].szName = StrDup(szString);
  156. dialog[nIndex].dlgproc = WallPaperProc;
  157. dialog[nIndex++].pfnFinalCopy = WallPaperFinalCopy;
  158. }*/
  159. dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_UASTRDLG );
  160. LoadString(g_hInst, IDS_UASTRDLG2, szString, ARRAYSIZE(szString));
  161. dialog[nIndex].szName = StrDup(szString);
  162. dialog[nIndex].dlgproc = UserAgentProc;
  163. dialog[nIndex++].pfnFinalCopy = NULL;
  164. dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_CONNECTSET );
  165. LoadString(g_hInst, IDS_CONNECTSET, szString, ARRAYSIZE(szString));
  166. dialog[nIndex].szName = StrDup(szString);
  167. dialog[nIndex].dlgproc = ConnectionSettingsDlgProc;
  168. dialog[nIndex++].pfnFinalCopy = ConnectionSettingsFinalCopy;
  169. dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_QUERYAUTOCONFIG );
  170. LoadString(g_hInst, IDS_QUERYAUTOCONFIG, szString, ARRAYSIZE(szString));
  171. dialog[nIndex].szName = StrDup(szString);
  172. dialog[nIndex].dlgproc = QueryAutoConfigDlgProc;
  173. dialog[nIndex++].pfnFinalCopy = NULL;
  174. dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_PROXY );
  175. LoadString(g_hInst, IDS_PROXY2, szString, ARRAYSIZE(szString));
  176. dialog[nIndex].szName = StrDup(szString);
  177. dialog[nIndex].dlgproc = ProxyProc;
  178. dialog[nIndex++].pfnFinalCopy = NULL;
  179. dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_STARTSEARCH );
  180. LoadString(g_hInst, IDS_STARTSEARCH2, szString, ARRAYSIZE(szString));
  181. dialog[nIndex].szName = StrDup(szString);
  182. dialog[nIndex].dlgproc = StartSearchProc;
  183. dialog[nIndex++].pfnFinalCopy = NULL;
  184. dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_PROGRAMS );
  185. LoadString(g_hInst, IDS_PROGRAMS, szString, ARRAYSIZE(szString));
  186. dialog[nIndex].szName = StrDup(szString);
  187. dialog[nIndex].dlgproc = ProgramsDlgProc;
  188. dialog[nIndex++].pfnFinalCopy = ProgramsFinalCopy;
  189. dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_MAIL );
  190. LoadString(g_hInst, IDS_MAIL2, szString, ARRAYSIZE(szString));
  191. dialog[nIndex].szName = StrDup(szString);
  192. dialog[nIndex].dlgproc = MailServer;
  193. dialog[nIndex++].pfnFinalCopy = NULL;
  194. dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_IMAP );
  195. LoadString(g_hInst, IDS_IMAP2, szString, ARRAYSIZE(szString));
  196. dialog[nIndex].szName = StrDup(szString);
  197. dialog[nIndex].dlgproc = IMAPSettings;
  198. dialog[nIndex++].pfnFinalCopy = NULL;
  199. dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_OE );
  200. LoadString(g_hInst, IDS_OE2, szString, ARRAYSIZE(szString));
  201. dialog[nIndex].szName = StrDup(szString);
  202. dialog[nIndex].dlgproc = CustomizeOE;
  203. dialog[nIndex++].pfnFinalCopy = OEFinalCopy;
  204. dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_PRECONFIG );
  205. LoadString(g_hInst, IDS_PRECONFIG2, szString, ARRAYSIZE(szString));
  206. dialog[nIndex].szName = StrDup(szString);
  207. dialog[nIndex].dlgproc = PreConfigSettings;
  208. dialog[nIndex++].pfnFinalCopy = NULL;
  209. dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_OEVIEW );
  210. LoadString(g_hInst, IDS_OEVIEW2, szString, ARRAYSIZE(szString));
  211. dialog[nIndex].szName = StrDup(szString);
  212. dialog[nIndex].dlgproc = ViewSettings;
  213. dialog[nIndex++].pfnFinalCopy = NULL;
  214. dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_SIG );
  215. LoadString(g_hInst, IDS_SIG2, szString, ARRAYSIZE(szString));
  216. dialog[nIndex].szName = StrDup(szString);
  217. dialog[nIndex].dlgproc = Signature;
  218. dialog[nIndex++].pfnFinalCopy = NULL;
  219. dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_LDAP );
  220. LoadString(g_hInst, IDS_LDAP2, szString, ARRAYSIZE(szString));
  221. dialog[nIndex].szName = StrDup(szString);
  222. dialog[nIndex].dlgproc = LDAPServer;
  223. dialog[nIndex++].pfnFinalCopy = LDAPFinalCopy;
  224. ZeroMemory(&sfs, sizeof(sfs));
  225. sfs.fWin95Classic = 1;
  226. hShell = LoadLibrary(TEXT("SHELL32.DLL"));
  227. if (hShell)
  228. {
  229. void (WINAPI *pSHGetSet)(LPSHELLFLAGSTATE lpsfs, DWORD dwMask);
  230. sfs.fWin95Classic = TRUE;
  231. pSHGetSet = (void (WINAPI *)(LPSHELLFLAGSTATE lpsfs, DWORD dwMask))
  232. GetProcAddress( hShell, "SHGetSettings" );
  233. if (pSHGetSet)
  234. pSHGetSet(&sfs, SSF_DESKTOPHTML | SSF_WIN95CLASSIC);
  235. FreeLibrary(hShell);
  236. }
  237. dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_SECURITY1 );
  238. LoadString(g_hInst, IDS_SECURITY, szString, ARRAYSIZE(szString));
  239. dialog[nIndex].szName = StrDup(szString);
  240. dialog[nIndex].dlgproc = SecurityZonesDlgProc;
  241. dialog[nIndex++].pfnFinalCopy = ZonesFinalCopy;
  242. if (g_dwPlatformId == PLATFORM_W2K)
  243. {
  244. dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_SECURITYAUTH );
  245. dialog[nIndex].dlgproc = SecurityAuthDlgProc;
  246. dialog[nIndex].pfnFinalCopy = AuthFinalCopy;
  247. }
  248. else
  249. {
  250. dialog[nIndex].DlgId = MAKEINTRESOURCE( IDD_SECURITYCERT );
  251. dialog[nIndex].dlgproc = SecurityCertsDlgProc;
  252. dialog[nIndex].pfnFinalCopy = CertsFinalCopy;
  253. }
  254. LoadString(g_hInst, IDS_SECURITYCERT, szString, ARRAYSIZE(szString));
  255. dialog[nIndex++].szName = StrDup(szString);
  256. g_nInsDialogsVisible = nIndex;
  257. }
  258. void DestroyInsDialog(HWND hDlg)
  259. {
  260. if (hDlg != NULL)
  261. SendMessage(hDlg, WM_CLOSE, 0, 0L);
  262. }
  263. BOOL SaveInsDialog(HWND hDlg, DWORD dwFlags)
  264. {
  265. BOOL fSave = TRUE;
  266. if (hDlg != NULL)
  267. {
  268. if (*g_szInsFile != 0)
  269. {
  270. if (HasFlag(dwFlags, ITEM_SAVE) || HasFlag(dwFlags, ITEM_CHECKDIRTY))
  271. {
  272. BOOL fCheckDirty = HasFlag(dwFlags, ITEM_CHECKDIRTY);
  273. fSave = FALSE;
  274. SendMessage(hDlg, UM_SAVE, (WPARAM)&fSave, (LPARAM)fCheckDirty);
  275. }
  276. }
  277. if (fSave && HasFlag(dwFlags, ITEM_DESTROY))
  278. DestroyInsDialog(hDlg);
  279. }
  280. return fSave;
  281. }
  282. void SetDefaultInf(LPCTSTR szDefInf)
  283. {
  284. ZeroMemory(g_szDefInf, sizeof(g_szDefInf));
  285. if(*szDefInf)
  286. StrCpy(g_szDefInf, szDefInf);
  287. }
  288. void ReInitializeInsDialogProcs()
  289. {
  290. int nIndex;
  291. for(nIndex = 0; nIndex < g_nInsDialogsVisible; nIndex++)
  292. {
  293. if(dialog[nIndex].szName)
  294. {
  295. LocalFree((HLOCAL) dialog[nIndex].szName);
  296. ZeroMemory(&dialog[nIndex], sizeof(dialog[nIndex]));
  297. }
  298. }
  299. g_nInsDialogsVisible = 0;
  300. InitializeInsDialogProcs();
  301. }
  302. void SetPlatformInfo(DWORD dwCurrPlatformId)
  303. {
  304. g_dwPlatformId = dwCurrPlatformId;
  305. }
  306. BOOL WINAPI InsDirty()
  307. {
  308. return g_fInsDirty;
  309. }
  310. void WINAPI ClearInsDirtyFlag()
  311. {
  312. g_fInsDirty = FALSE;
  313. }
  314. // This function informs the caller whether a check for extended characters in a path field
  315. // is required for a particular dialog.
  316. BOOL WINAPI CheckForExChar(int nDialogIndex)
  317. {
  318. switch (PtrToUint(dialog[nDialogIndex].DlgId))
  319. {
  320. case IDD_BTITLE:
  321. case IDD_CUSTICON:
  322. return TRUE;
  323. default:
  324. break;
  325. }
  326. return FALSE;
  327. }