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.

7311 lines
210 KiB

  1. /*----------------------------------------------------------------------------
  2. isignup.cpp
  3. This is the "main" file for the internet signup "wizard".
  4. Copyright (C) 1995-96 Microsoft Corporation
  5. All right reserved
  6. Authors:
  7. MMaclin Mark Maclin
  8. History:
  9. Sat 10-Mar-1996 23:50:40 -by- Mark MacLin [mmaclin]
  10. 8/2/96 ChrisK Ported to Win32
  11. 9/27/96 jmazner Modified to use OLE Automation to control IE
  12. ----------------------------------------------------------------------------*/
  13. #include "isignup.h"
  14. #include "icw.h"
  15. #ifdef WIN32
  16. #include "icwacct.h"
  17. #include "isignole.h"
  18. #include "enumodem.h"
  19. #include "..\inc\semaphor.h"
  20. #include <shlobj.h>
  21. #include <math.h>
  22. #include <stdlib.h>
  23. #endif
  24. #include "..\inc\icwdial.h"
  25. #ifndef WIN32
  26. #include <string.h>
  27. #include <direct.h>
  28. #include <time.h>
  29. #include <io.h>
  30. DWORD GetFullPathName(
  31. LPCTSTR lpFileName,
  32. DWORD nBufferLength,
  33. LPTSTR lpBuffer,
  34. LPTSTR FAR *lpFilePart);
  35. BOOL SetCurrentDirectory(
  36. LPCTSTR lpPathName);
  37. BOOL ShutDownIEDial(HWND hWnd);
  38. #endif
  39. const TCHAR g_szICWCONN1[] = TEXT("ICWCONN1.EXE");
  40. const TCHAR g_szRestoreDesktop[] = TEXT("/restoredesktop");
  41. #ifdef WIN32
  42. #define SETUPSTACK 1
  43. #endif
  44. // Signup Entry Flags
  45. #define SEF_RUNONCE 0x0001
  46. #define SEF_PROGRESS 0x0002
  47. #define SEF_SPLASH 0x0004
  48. // 3/14/97 jmazner TEMP
  49. // temporary hack until we can work with IE for a better solution
  50. #define SEF_NOSECURITYBACKUP 0x0008
  51. // Signup eXit Flags
  52. #define SXF_RESTOREAUTODIAL 0x0001
  53. #define SXF_RUNEXECUTABLE 0x0002
  54. #define SXF_WAITEXECUTABLE 0x0004
  55. #define SXF_KEEPCONNECTION 0x0008
  56. #define SXF_KEEPBROWSER 0x0010
  57. #define SXF_RESTOREDEFCHECK 0x0020
  58. // 8/21/96 jmazner Normandy 4592
  59. #define SXF_RESTOREIEWINDOWPLACEMENT 0x0040
  60. extern void Dprintf(LPCSTR pcsz, ...);
  61. /*** moved to isignup.h
  62. typedef enum
  63. {
  64. UNKNOWN_FILE,
  65. INS_FILE,
  66. ISP_FILE,
  67. HTML_FILE
  68. } INET_FILETYPE;
  69. */
  70. #define WAIT_TIME 20 // time in seconds to wait after exec'ing browser
  71. // before checking if it has gone away.
  72. #define MAX_RETRIES 3 // number of times the dialer with attempt automatic redials
  73. #pragma data_seg(".rdata")
  74. static const TCHAR szBrowserClass1[] = TEXT("IExplorer_Frame");
  75. static const TCHAR szBrowserClassIE4[] = TEXT("CabinetWClass");
  76. static const TCHAR szBrowserClass2[] = TEXT("Internet Explorer_Frame");
  77. static const TCHAR szBrowserClass3[] = TEXT("IEFrame");
  78. static const TCHAR cszURLSection[] = TEXT("URL");
  79. static const TCHAR cszSignupURL[] = TEXT("Signup");
  80. static const TCHAR cszExtINS[] = TEXT(".ins");
  81. static const TCHAR cszExtISP[] = TEXT(".isp");
  82. static const TCHAR cszExtHTM[] = TEXT(".htm");
  83. static const TCHAR cszExtHTML[] = TEXT(".html");
  84. static const TCHAR cszEntrySection[] = TEXT("Entry");
  85. static const TCHAR cszEntryName[] = TEXT("Entry_Name");
  86. static const TCHAR cszCancel[] = TEXT("Cancel");
  87. static const TCHAR cszHangup[] = TEXT("Hangup");
  88. static const TCHAR cszRun[] = TEXT("Run");
  89. static const TCHAR cszArgument[] = TEXT("Argument");
  90. static const TCHAR cszConnect2[] = TEXT("icwconn2.exe");
  91. static const TCHAR cszClientSetupSection[] = TEXT("ClientSetup");
  92. static const TCHAR cszUserSection[] = TEXT("User");
  93. static const TCHAR cszRequiresLogon[] = TEXT("Requires_Logon");
  94. static const TCHAR cszCustomSection[] = TEXT("Custom");
  95. static const TCHAR cszKeepConnection[] = TEXT("Keep_Connection");
  96. static const TCHAR cszKeepBrowser[] = TEXT("Keep_Browser");
  97. static const TCHAR cszBrandingSection[] = TEXT("Branding");
  98. static const TCHAR cszBrandingFlags[] = TEXT("Flags");
  99. static const TCHAR cszBrandingServerless[] = TEXT("Serverless");
  100. static const TCHAR cszHTTPS[] = TEXT("https:");
  101. // code relies on these two being the same length
  102. static const TCHAR cszHTTP[] = TEXT("http:");
  103. static const TCHAR cszFILE[] = TEXT("file:");
  104. #if defined(WIN16)
  105. // "-d" disables the security warnings
  106. static const TCHAR cszKioskMode[] = TEXT("-d -k ");
  107. #else
  108. static const CHAR cszKioskMode[] = "-k ";
  109. #endif
  110. static const TCHAR cszOpen[] = TEXT("open");
  111. static const TCHAR cszBrowser[] = TEXT("iexplore.exe");
  112. static const TCHAR szNull[] = TEXT("");
  113. static const TCHAR cszYes[] = TEXT("yes");
  114. static const TCHAR cszNo[] = TEXT("no");
  115. // UNDONE: finish porting warnings disable
  116. static const TCHAR cszDEFAULT_BROWSER_KEY[] = TEXT("Software\\Microsoft\\Internet Explorer\\Main");
  117. static const TCHAR cszDEFAULT_BROWSER_VALUE[] = TEXT("check_associations");
  118. // 8/21/96 jmazner Normandy #4592
  119. static const TCHAR cszIEWINDOW_PLACEMENT[] = TEXT("Window_Placement");
  120. // Registry keys which will contain News and Mail settings
  121. //#define MAIL_KEY "SOFTWARE\\Microsoft\\Internet Mail and News\\Mail"
  122. //#define MAIL_POP3_KEY "SOFTWARE\\Microsoft\\Internet Mail and News\\Mail\\POP3\\"
  123. //#define MAIL_SMTP_KEY "SOFTWARE\\Microsoft\\Internet Mail and News\\Mail\\SMTP\\"
  124. //#define NEWS_KEY "SOFTWARE\\Microsoft\\Internet Mail and News\\News"
  125. //#define MAIL_NEWS_INPROC_SERVER32 "CLSID\\{89292102-4755-11cf-9DC2-00AA006C2B84}\\InProcServer32"
  126. #define ICWSETTINGSPATH TEXT("Software\\Microsoft\\Internet Connection Wizard")
  127. #define ICWCOMPLETEDKEY TEXT("Completed")
  128. #define ICWDESKTOPCHANGED TEXT("DesktopChanged")
  129. //typedef HRESULT (WINAPI *PFNSETDEFAULTNEWSHANDLER)(void);
  130. //
  131. // TEMP TEMP TEMP TEMP TEMP
  132. // 6/4/97 jmazner
  133. // these typedefs live in icwacct.h, but we can't include icwacct.h in 16 bit builds
  134. // just yet because the OLE stuff is all goofy. So, for now, copy these in here to
  135. // make 16 bit build correctly.
  136. #ifdef WIN16
  137. typedef enum
  138. {
  139. CONNECT_LAN = 0,
  140. CONNECT_MANUAL,
  141. CONNECT_RAS
  142. };
  143. typedef struct tagCONNECTINFO
  144. {
  145. DWORD cbSize;
  146. DWORD type;
  147. TCHAR szConnectoid[MAX_PATH];
  148. } CONNECTINFO;
  149. #endif
  150. typedef HRESULT (WINAPI *PFNCREATEACCOUNTSFROMFILEEX)(LPTSTR szFile, CONNECTINFO *pCI, DWORD dwFlags);
  151. // These are the field names from an INS file that will
  152. // determine the mail and news settings
  153. //static const CHAR cszMailSection[] = "Internet_Mail";
  154. //static const CHAR cszEmailName[] = "Email_Name";
  155. //static const CHAR cszEmailAddress[] = "Email_Address";
  156. //static const CHAR cszEntryName[] = "Entry_Name";
  157. //static const CHAR cszPOPServer[] = "POP_Server";
  158. //static const CHAR cszPOPServerPortNumber[] = "POP_Server_Port_Number";
  159. //static const CHAR cszPOPLogonName[] = "POP_Logon_Name";
  160. //static const CHAR cszPOPLogonPassword[] = "POP_Logon_Password";
  161. //static const CHAR cszSMTPServer[] = "SMTP_Server";
  162. //static const CHAR cszSMTPServerPortNumber[] = "SMTP_Server_Port_Number";
  163. //static const CHAR cszNewsSection[] = "Internet_News";
  164. //static const CHAR cszNNTPServer[] = "NNTP_Server";
  165. //static const CHAR cszNNTPServerPortNumber[] = "NNTP_Server_Port_Number";
  166. // 8/19/96 jmazner Normandy #4601
  167. //static const CHAR cszNNTPLogonRequired[] = "Logon_Required";
  168. //static const CHAR cszNNTPLogonName[] = "NNTP_Logon_Name";
  169. //static const CHAR cszNNTPLogonPassword[] = "NNTP_Logon_Password";
  170. //static const CHAR cszUseMSInternetMail[] = "Install_Mail";
  171. //static const CHAR cszUseMSInternetNews[] = "Install_News";
  172. // These are the value names where the INS settings will be saved
  173. // into the registry
  174. /****
  175. static const TCHAR cszMailSenderName[] = TEXT("Sender Name");
  176. static const TCHAR cszMailSenderEMail[] = TEXT("Sender EMail");
  177. static const TCHAR cszMailRASPhonebookEntry[]= TEXT("RAS Phonebook Entry");
  178. static const TCHAR cszMailConnectionType[] = TEXT("Connection Type");
  179. static const TCHAR cszDefaultPOP3Server[] = TEXT("Default POP3 Server");
  180. static const TCHAR cszDefaultSMTPServer[] = TEXT("Default SMTP Server");
  181. static const TCHAR cszPOP3Account[] = TEXT("Account");
  182. static const TCHAR cszPOP3Password[] = TEXT("Password");
  183. static const TCHAR cszPOP3Port[] = TEXT("Port");
  184. static const TCHAR cszSMTPPort[] = TEXT("Port");
  185. static const TCHAR cszNNTPSenderName[] = TEXT("Sender Name");
  186. static const TCHAR cszNNTPSenderEMail[] = TEXT("Sender EMail");
  187. static const TCHAR cszNNTPDefaultServer[] = TEXT("DefaultServer"); // NOTE: NO space between "Default" and "Server".
  188. static const TCHAR cszNNTPAccountName[] = TEXT("Account Name");
  189. static const TCHAR cszNNTPPassword[] = TEXT("Password");
  190. static const TCHAR cszNNTPPort[] = TEXT("Port");
  191. static const TCHAR cszNNTPRasPhonebookEntry[]= TEXT("RAS Phonebook Entry");
  192. static const TCHAR cszNNTPConnectionType[] = TEXT("Connection Type");
  193. ****/
  194. static const TCHAR arBase64[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U',
  195. 'V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p',
  196. 'q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/','='};
  197. #pragma data_seg()
  198. #define BRAND_FAVORITES 1
  199. #define BRAND_STARTSEARCH 2
  200. #define BRAND_TITLE 4
  201. #define BRAND_BITMAPS 8
  202. #define BRAND_MAIL 16
  203. #define BRAND_NEWS 32
  204. #define BRAND_DEFAULT (BRAND_FAVORITES | BRAND_TITLE | BRAND_BITMAPS)
  205. //********* Start of Memory Map File for Share Data ************
  206. #define SCF_SIGNUPCOMPLETED 0x00000001
  207. #define SCF_SYSTEMCONFIGURED 0x00000002
  208. #define SCF_BROWSERLAUNCHED 0x00000004
  209. #define SCF_AUTODIALSAVED 0x00000008
  210. #define SCF_AUTODIALENABLED 0x00000010
  211. #define SCF_PROXYENABLED 0x00000020
  212. #define SCF_LOGONREQUIRED 0x00000040
  213. #if !defined(WIN16)
  214. #define SCF_SAFESET 0x00000080
  215. #define SCF_NEEDBACKUPSECURITY 0x00000100
  216. #define SCF_ISPPROCESSING 0x00000200
  217. #define SCF_RASREADY 0x00000400
  218. #define SCF_RECONNECTTHREADQUITED 0x00000800
  219. #define SCF_HANGUPEXPECTED 0x00001000
  220. #define SCF_ICWCOMPLETEDKEYRESETED 0x00002000
  221. #endif
  222. #define SCF_CANCELINSPROCESSED 0x00004000
  223. #define SCF_HANGUPINSPROCESSED 0x00008000
  224. #define SCF_SILENT 0x00010000
  225. typedef struct tagISign32Share
  226. {
  227. DWORD dwControlFlags;
  228. DWORD dwExitFlags;
  229. DWORD dwBrandFlags;
  230. TCHAR szAutodialConnection[RAS_MaxEntryName + 1];
  231. TCHAR szSignupConnection[RAS_MaxEntryName + 1];
  232. TCHAR szPassword[PWLEN + 1];
  233. TCHAR szCheckAssociations[20];
  234. #if !defined(WIN16)
  235. TCHAR szFile[MAX_PATH + 1];
  236. TCHAR szISPFile[MAX_PATH + 1];
  237. HANDLE hReconnectEvent;
  238. #endif
  239. TCHAR szRunExecutable[_MAX_PATH + 1];
  240. TCHAR szRunArgument[_MAX_PATH + 1];
  241. BYTE pbIEWindowPlacement[_MAX_PATH];
  242. DWORD dwIEWindowPlacementSize;
  243. HWND hwndMain;
  244. HWND hwndBrowser;
  245. HWND hwndLaunch;
  246. } ISIGN32SHARE, *PISIGN32SHARE;
  247. static PISIGN32SHARE pDynShare = NULL;
  248. inline BOOL TestControlFlags(DWORD filter)
  249. {
  250. return ((pDynShare->dwControlFlags & filter) != 0);
  251. }
  252. inline void SetControlFlags(DWORD filter)
  253. {
  254. pDynShare->dwControlFlags |= filter;
  255. }
  256. inline void ClearControlFlags(DWORD filter)
  257. {
  258. pDynShare->dwControlFlags &= (~filter);
  259. }
  260. inline BOOL TestExitFlags(DWORD filter)
  261. {
  262. return (pDynShare->dwExitFlags & (filter)) != 0;
  263. }
  264. inline void SetExitFlags(DWORD filter)
  265. {
  266. pDynShare->dwExitFlags |= (filter);
  267. }
  268. inline void ClearExitFlags(DWORD filter)
  269. {
  270. pDynShare->dwExitFlags &= (~filter);
  271. }
  272. BOOL LibShareEntry(BOOL fInit)
  273. {
  274. static TCHAR szSharedMemName[] = TEXT("ISIGN32_SHAREMEMORY");
  275. static HANDLE hSharedMem = 0;
  276. BOOL retval = FALSE;
  277. if (fInit)
  278. {
  279. DWORD dwErr = ERROR_SUCCESS;
  280. SetLastError(0);
  281. hSharedMem = CreateFileMapping(
  282. INVALID_HANDLE_VALUE,
  283. NULL,
  284. PAGE_READWRITE,
  285. 0,
  286. sizeof(ISIGN32SHARE),
  287. szSharedMemName);
  288. dwErr = GetLastError();
  289. switch (dwErr)
  290. {
  291. case ERROR_ALREADY_EXISTS:
  292. case ERROR_SUCCESS:
  293. pDynShare = (PISIGN32SHARE) MapViewOfFile(
  294. hSharedMem,
  295. FILE_MAP_WRITE,
  296. 0,
  297. 0,
  298. 0);
  299. if (pDynShare != NULL)
  300. {
  301. if (dwErr == ERROR_SUCCESS)
  302. {
  303. pDynShare->dwControlFlags = 0;
  304. pDynShare->dwBrandFlags = BRAND_DEFAULT;
  305. pDynShare->dwExitFlags = 0;
  306. pDynShare->szAutodialConnection[0] = (TCHAR)0;
  307. pDynShare->szCheckAssociations[0] = (TCHAR)0;
  308. #if !defined(WIN16)
  309. pDynShare->szISPFile[0] = (TCHAR)0;
  310. lstrcpyn(
  311. pDynShare->szFile,
  312. TEXT("uninited\0"),
  313. SIZEOF_TCHAR_BUFFER(pDynShare->szFile));
  314. pDynShare->hReconnectEvent = NULL;
  315. SetControlFlags(SCF_NEEDBACKUPSECURITY);
  316. #endif
  317. pDynShare->szSignupConnection[0] = (TCHAR)0;
  318. pDynShare->szPassword[0] = (TCHAR)0;
  319. pDynShare->szRunExecutable[0] = (TCHAR)0;
  320. pDynShare->szRunArgument[0] = (TCHAR)0;
  321. pDynShare->pbIEWindowPlacement[0] = (TCHAR)0;
  322. pDynShare->dwIEWindowPlacementSize = 0;
  323. pDynShare->hwndBrowser = NULL;
  324. pDynShare->hwndMain = NULL;
  325. pDynShare->hwndLaunch = NULL;
  326. }
  327. else // dwErr == ERROR_ALREADY_EXISTS
  328. {
  329. }
  330. retval = TRUE;
  331. }
  332. else
  333. {
  334. Dprintf("MapViewOfFile failed: 0x%08lx", GetLastError());
  335. CloseHandle(hSharedMem);
  336. hSharedMem = 0;
  337. retval = FALSE;
  338. }
  339. break;
  340. default:
  341. Dprintf("CreateFileMapping failed: 0x08lx", dwErr);
  342. hSharedMem = 0;
  343. retval = FALSE;
  344. }
  345. }
  346. else
  347. {
  348. if (pDynShare)
  349. {
  350. UnmapViewOfFile(pDynShare);
  351. pDynShare = NULL;
  352. }
  353. if (hSharedMem)
  354. {
  355. CloseHandle(hSharedMem);
  356. hSharedMem = NULL;
  357. }
  358. retval = TRUE;
  359. }
  360. return retval;
  361. }
  362. //************ End of Memory Map File for Share Data ************
  363. TCHAR FAR cszWndClassName[] = TEXT("Internet Signup\0");
  364. TCHAR FAR cszAppName[MAX_PATH + 1] = TEXT("");
  365. TCHAR FAR cszICWDIAL_DLL[] = TEXT("ICWDIAL.DLL\0");
  366. CHAR FAR cszICWDIAL_DIALDLG[] = "DialingDownloadDialog\0";
  367. CHAR FAR cszICWDIAL_ERRORDLG[] = "DialingErrorDialog\0";
  368. HINSTANCE ghInstance;
  369. #ifdef WIN32
  370. // NOT shared
  371. IWebBrowserApp FAR * g_iwbapp = NULL;
  372. CDExplorerEvents * g_pMySink = NULL;
  373. IConnectionPoint *g_pCP = NULL;
  374. //BOOL g_bISPWaiting = FALSE;
  375. TCHAR g_szISPPath[MAX_URL + 1] = TEXT("not initialized\0");
  376. // For single instance checking.
  377. HANDLE g_hSemaphore = NULL;
  378. //
  379. // ChrisK Olympus 6198 6/10/97
  380. //
  381. #define REG_ZONE3_KEY TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3")
  382. #define REG_ZONE1601_KEY TEXT("1601")
  383. DWORD g_dwZone_1601 = 0;
  384. BOOL g_fReadZone = FALSE;
  385. #endif
  386. static DWORD dwConnectedTime = 0;
  387. static BOOL ProcessCommandLine(LPCTSTR lpszCmdLine, LPDWORD lpdwFlags, LPTSTR lpszFile, DWORD cb);
  388. //static INET_FILETYPE GetInetFileType(LPCTSTR lpszFile);
  389. INET_FILETYPE GetInetFileType(LPCTSTR lpszFile);
  390. static BOOL ProcessHTML(HWND hwnd, LPCTSTR lpszFile);
  391. static BOOL ProcessINS(HWND hwnd, LPCTSTR lpszFile, BOOL fSignup);
  392. //static BOOL ProcessISP(HWND hwnd, LPCTSTR lpszFile);
  393. static DWORD SetRunOnce(LPCTSTR lpszFileName);
  394. static BOOL GetURL(LPCTSTR lpszFile,LPCTSTR lpszKey, LPTSTR lpszURL, DWORD cb);
  395. static void DoExit();
  396. static HWND MainInit(void);
  397. static void SaveAutoDial(void);
  398. static void RestoreAutoDial(void);
  399. static DWORD RunExecutable(BOOL bWait);
  400. static DWORD CreateConnection(LPCTSTR lpszFile);
  401. static DWORD KillConnection(void);
  402. static BOOL ExecBrowser(HWND hwnd, LPCTSTR lpszURL);
  403. VOID RemoveQuotes (LPTSTR pCommandLine); //MKarki -(5/1/97) Fix forBug #4049
  404. #if !defined(WIN16)
  405. // 8/19/96 jmazner Normandy #4571
  406. static BOOL IEInstalled(void);
  407. static BOOL GetAppVersion(PDWORD pdwVerNumMS, PDWORD pdwVerNumLS, LPTSTR lpszAppName);
  408. // 8/21/96 jmazner Normandy #4592
  409. static BOOL RestoreIEWindowPlacement( void );
  410. static BOOL SaveIEWindowPlacement( void );
  411. // 10-9-96 Chrisk 8782
  412. static void InstallScripter(void);
  413. // 10-15-96 ChrisK
  414. static BOOL FGetSystemShutdownPrivledge();
  415. // 10-17-96 ChrisK
  416. static BOOL VerifyRasServicesRunning(HWND hwnd);
  417. // 1/20/97 jmazner Normandy #9403
  418. static BOOL SetStartUpCommand(LPTSTR lpCmd);
  419. static void DeleteStartUpCommand( void );
  420. // 1/28/97 jmazner Normandy #13454
  421. static BOOL GetICWCompleted( DWORD *pdwCompleted );
  422. static BOOL SetICWCompleted( DWORD dwCompleted );
  423. // 2/19/97 jmazner Olympus #1106 -- SAM/SBS integration
  424. TCHAR FAR cszSBSCFG_DLL[] = TEXT("SBSCFG.DLL\0");
  425. CHAR FAR cszSBSCFG_CONFIGURE[] = "Configure\0";
  426. typedef DWORD (WINAPI * SBSCONFIGURE) (HWND hwnd, LPTSTR lpszINSFile, LPTSTR szConnectoidName);
  427. SBSCONFIGURE lpfnConfigure;
  428. // 8/7/97 jmazner Olympus #6059
  429. BOOL CreateSecurityPatchBackup( void );
  430. // 3/11/97 jmazner Olympus #1545
  431. VOID RestoreSecurityPatch( void );
  432. #endif
  433. static HWND FindBrowser(void);
  434. static void KillBrowser(void);
  435. static DWORD ImportBrandingInfo(LPCTSTR lpszFile);
  436. static DWORD MassageFile(LPCTSTR lpszFile);
  437. static HWND LaunchInit(HWND hwndParent);
  438. static HRESULT DialConnection(LPCTSTR lpszFile);
  439. static DWORD ImportMailAndNewsInfo(LPCTSTR lpszFile, BOOL fConnectPhone);
  440. //static HRESULT WriteMailAndNewsKey(HKEY hKey, LPCTSTR lpszSection, LPCTSTR lpszValue, LPTSTR lpszBuff, DWORD dwBuffLen,LPCTSTR lpszSubKey, DWORD dwType, LPCTSTR lpszFile);
  441. static HRESULT PreparePassword(LPTSTR szBuff, DWORD dwBuffLen);
  442. //static BOOL FIsAthenaPresent();
  443. static BOOL FTurnOffBrowserDefaultChecking();
  444. static BOOL FRestoreBrowserDefaultChecking();
  445. static HRESULT DeleteFileKindaLikeThisOne(LPCTSTR lpszFileName);
  446. /*
  447. #ifdef DEBUG
  448. #define DebugOut(sz) OutputDebugString(sz)
  449. #else
  450. #define DebugOut(sz)
  451. #endif
  452. */
  453. LRESULT FAR PASCAL WndProc (HWND, UINT, WPARAM, LPARAM) ;
  454. #if !defined(ERROR_USERCANCEL)
  455. # define ERROR_USERCANCEL 32767
  456. #endif
  457. #if !defined(ERROR_USERBACK)
  458. # define ERROR_USERBACK 32766
  459. #endif
  460. #if !defined(ERROR_USERNEXT)
  461. # define ERROR_USERNEXT 32765
  462. #endif
  463. #define MAX_ERROR_MESSAGE 1024
  464. typedef HRESULT (WINAPI*PFNDIALDLG)(PDIALDLGDATA pDD);
  465. typedef HRESULT (WINAPI*PFNERRORDLG)(PERRORDLGDATA pED);
  466. //
  467. // WIN32 only function prototypes
  468. //
  469. #define DEVICENAMEKEY TEXT("DeviceName")
  470. #define DEVICETYPEKEY TEXT("DeviceType")
  471. static BOOL DeleteUserDeviceSelection(LPTSTR szKey);
  472. VOID WINAPI RasDial1Callback(HRASCONN, UINT, RASCONNSTATE, DWORD, DWORD);
  473. DWORD WINAPI StartNTReconnectThread (HRASCONN hrasconn);
  474. DWORD ConfigRasEntryDevice( LPRASENTRY lpRasEntry );
  475. TCHAR g_szDeviceName[RAS_MaxDeviceName + 1] = TEXT("\0"); //holds the user's modem choice when multiple
  476. TCHAR g_szDeviceType[RAS_MaxDeviceType + 1] = TEXT("\0"); // modems are installed
  477. BOOL IsSingleInstance(BOOL bProcessingINS);
  478. void ReleaseSingleInstance();
  479. #define ISIGNUP_KEY TEXT("Software\\Microsoft\\ISIGNUP")
  480. #if !defined(WIN16)
  481. // There are other headers that contain copies of this structure (AUTODIAL).
  482. // so if you change anything here, you have to go hunt down the other copies.
  483. //
  484. #pragma pack(2)
  485. #define MAX_PROMO 64
  486. #define MAX_OEMNAME 64
  487. #define MAX_AREACODE RAS_MaxAreaCode
  488. #define MAX_EXCHANGE 8
  489. #define MAX_VERSION_LEN 40
  490. typedef struct tagGATHEREDINFO
  491. {
  492. LCID lcid;
  493. DWORD dwOS;
  494. DWORD dwMajorVersion;
  495. DWORD dwMinorVersion;
  496. WORD wArchitecture;
  497. TCHAR szPromo[MAX_PROMO];
  498. TCHAR szOEM[MAX_OEMNAME];
  499. TCHAR szAreaCode[MAX_AREACODE+1];
  500. TCHAR szExchange[MAX_EXCHANGE+1];
  501. DWORD dwCountry;
  502. TCHAR szSUVersion[MAX_VERSION_LEN];
  503. WORD wState;
  504. BYTE fType;
  505. BYTE bMask;
  506. TCHAR szISPFile[MAX_PATH+1];
  507. TCHAR szAppDir[MAX_PATH+1];
  508. } GATHEREDINFO, *PGATHEREDINFO;
  509. #pragma pack()
  510. #endif //!WIN16
  511. #ifdef DEBUG
  512. void _ISIGN32_Assert(LPCTSTR strFile, unsigned uLine)
  513. {
  514. TCHAR buf[512];
  515. wsprintf(buf, TEXT("Assertion failed: %s, line %u"),
  516. strFile, uLine);
  517. OutputDebugString(buf);
  518. }
  519. #endif
  520. #ifdef WIN32
  521. /*******************************************************************
  522. NAME: DllEntryPoint
  523. SYNOPSIS: Entry point for DLL.
  524. NOTES:
  525. ********************************************************************/
  526. extern "C" BOOL APIENTRY LibMain(HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved)
  527. {
  528. BOOL retval = TRUE;
  529. if( fdwReason == DLL_PROCESS_ATTACH )
  530. {
  531. ghInstance = hInstDll;
  532. LoadString(ghInstance, IDS_APP_TITLE, cszAppName, SIZEOF_TCHAR_BUFFER(cszAppName));
  533. retval = LibShareEntry(TRUE);
  534. }
  535. else if ( fdwReason == DLL_PROCESS_DETACH )
  536. {
  537. retval = LibShareEntry(FALSE);
  538. }
  539. return retval;
  540. }
  541. #else
  542. /*******************************************************************
  543. NAME: LibMain
  544. SYNOPSIS: Used to trace NDI messages
  545. ENTRY: hinst - handle of library instance
  546. wDataSeg - library data segment
  547. cbHeapSize - default heap size
  548. lpszCmdLine - command-line arguments
  549. EXIT: returns 1
  550. NOTES:
  551. ********************************************************************/
  552. int CALLBACK LibMain(
  553. HINSTANCE hinst, /* handle of library instance */
  554. WORD wDataSeg, /* library data segment */
  555. WORD cbHeapSize, /* default heap size */
  556. LPTSTR lpszCmdLine /* command-line arguments */
  557. )
  558. {
  559. ghInstance = hinst;
  560. LoadString(ghInstance, IDS_APP_TITLE, cszAppName, SIZEOF_TCHAR_BUFFER(cszAppName));
  561. return LibShareEntry(TRUE);
  562. }
  563. #endif
  564. int EXPORT WINAPI Signup
  565. (
  566. HANDLE hInstance,
  567. HANDLE hPrevInstance,
  568. LPTSTR lpszCmdLine,
  569. int nCmdShow
  570. )
  571. {
  572. HWND hwnd = NULL;
  573. BOOL fRet;
  574. DWORD dwFlags;
  575. TCHAR szFileName[_MAX_PATH + 1];
  576. int iRet = 0;
  577. INET_FILETYPE fileType;
  578. HWND hwndProgress = NULL;
  579. HKEY hKey = NULL;
  580. TCHAR szTemp[4];
  581. BOOL bISetAsSAFE = FALSE;
  582. if (!LoadInetFunctions(pDynShare->hwndMain))
  583. {
  584. return 0;
  585. }
  586. if (!ProcessCommandLine(lpszCmdLine, &dwFlags, szFileName, sizeof(szFileName)))
  587. {
  588. if (0 == lstrlen(lpszCmdLine))
  589. {
  590. ErrorMsg(pDynShare->hwndMain, IDS_NOCMDLINE);
  591. }
  592. else
  593. {
  594. ErrorMsg1(pDynShare->hwndMain, IDS_INVALIDCMDLINE,
  595. lpszCmdLine ? lpszCmdLine : TEXT("\0"));
  596. }
  597. goto exit;
  598. }
  599. if (dwFlags & SEF_RUNONCE)
  600. {
  601. SetControlFlags(SCF_SYSTEMCONFIGURED);
  602. }
  603. fileType = GetInetFileType(szFileName);
  604. switch (fileType)
  605. {
  606. case INS_FILE:
  607. DebugOut("ISIGNUP: Process INS\n");
  608. IsSingleInstance( TRUE );
  609. ProcessINS(pDynShare->hwndMain, szFileName, NULL != pDynShare->hwndMain);
  610. if (NULL == pDynShare->hwndMain)
  611. {
  612. DoExit();
  613. }
  614. goto exit;
  615. case HTML_FILE:
  616. case ISP_FILE:
  617. {
  618. if (!IsSingleInstance(FALSE))
  619. return FALSE;
  620. TCHAR szDrive [_MAX_DRIVE] = TEXT("\0");
  621. TCHAR szDir [_MAX_DIR] = TEXT("\0");
  622. TCHAR szTemp [_MAX_PATH + 1] = TEXT("\0");
  623. _tsplitpath(szFileName, szDrive, szDir, NULL, NULL);
  624. _tmakepath (szTemp, szDrive, szDir, HARDCODED_IEAK_ISP_FILENAME, NULL);
  625. //Examine the isp or htm file to see if they want to run the ICW
  626. if ((GetFileAttributes(szTemp) != 0xFFFFFFFF) && (UseICWForIEAK(szTemp)))
  627. {
  628. //they do .. let's do it.
  629. RunICWinIEAKMode(szTemp);
  630. }
  631. else //else RUN IEXPLORE Kiosk
  632. {
  633. // 8/19/96 jmazner Normandy #4571 and #10293
  634. // Check to ensure that the right version IE is installed before trying to exec it
  635. if ( !IEInstalled() )
  636. {
  637. ErrorMsg( hwnd, IDS_MISSINGIE );
  638. return(FALSE);
  639. }
  640. DWORD dwVerMS, dwVerLS;
  641. if( !GetAppVersion( &dwVerMS, &dwVerLS,IE_PATHKEY ) )
  642. {
  643. ErrorMsg( hwnd, IDS_MISSINGIE );
  644. return (FALSE);
  645. }
  646. if( !( (dwVerMS >= IE_MINIMUM_VERSIONMS) && (dwVerLS >= IE_MINIMUM_VERSIONLS) ) )
  647. {
  648. Dprintf("ISIGN32: user has IE version %d.%d.%d.%d; min ver is %d.%d.%d.%d\n",
  649. HIWORD(dwVerMS), LOWORD(dwVerMS), HIWORD(dwVerLS), LOWORD(dwVerLS),
  650. HIWORD(IE_MINIMUM_VERSIONMS),LOWORD(IE_MINIMUM_VERSIONMS),
  651. HIWORD(IE_MINIMUM_VERSIONLS),LOWORD(IE_MINIMUM_VERSIONLS));
  652. ErrorMsg1( hwnd, IDS_IELOWVERSION, IE_MINIMUM_VERSION_HUMAN_READABLE );
  653. return(FALSE);
  654. }
  655. // 8/21/96 jmazner Normandy #4592
  656. if( !TestControlFlags(SCF_BROWSERLAUNCHED) )
  657. {
  658. if ( SaveIEWindowPlacement() )
  659. {
  660. SetExitFlags(SXF_RESTOREIEWINDOWPLACEMENT);
  661. }
  662. }
  663. // check to see if we are the first window
  664. if (NULL == pDynShare->hwndMain)
  665. {
  666. DebugOut("ISIGNUP: First Window\n");
  667. hwnd = pDynShare->hwndMain = MainInit();
  668. if (dwFlags & SEF_SPLASH)
  669. {
  670. pDynShare->hwndLaunch = LaunchInit(NULL);
  671. }
  672. if (dwFlags & SEF_PROGRESS)
  673. {
  674. // 8/16/96 jmazner Normandy #4593 pass NULL as ProgressInit's parent window
  675. hwndProgress = ProgressInit(NULL);
  676. }
  677. }
  678. // 3/11/97 jmazner Olympus #1545
  679. // -------------------------------------------------------------------------
  680. // The entire section between here and the #endif was added to fix a security
  681. // hole in IE3.01. The problem was based around .INS files being marked as
  682. // safe when in fact they could be used to launch any application if you knew
  683. // the right incantation, and someone figured it out.
  684. //
  685. //
  686. if (FALSE == TestControlFlags(SCF_SAFESET))
  687. {
  688. #define ISIGNUP_PATHKEY TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\ISIGNUP.EXE")
  689. hKey = NULL;
  690. //szPath[0] = '\0';
  691. //hSecureRegFile = INVALID_HANDLE_VALUE;
  692. Dprintf("ISIGN32: Adjusting EditFlags settings\n");
  693. //
  694. // ChrisK Olympus 6198 6/10/97
  695. // Allow HTML form submissions from ICW
  696. //
  697. if (ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER,REG_ZONE3_KEY,&hKey))
  698. {
  699. DWORD dwZoneData;
  700. DWORD dwType;
  701. DWORD dwSize;
  702. g_dwZone_1601 = 0;
  703. dwSize = sizeof(g_dwZone_1601);
  704. dwType = 0;
  705. //
  706. // Read current setting for zone3 1601
  707. //
  708. if (ERROR_SUCCESS == RegQueryValueEx(hKey,
  709. REG_ZONE1601_KEY,
  710. NULL,
  711. &dwType,
  712. (LPBYTE)&g_dwZone_1601,
  713. &dwSize))
  714. {
  715. DebugOut("ISIGN32: Read zone settings succesfully.\n");
  716. g_fReadZone = TRUE;
  717. }
  718. else
  719. {
  720. DebugOut("ISIGN32: Read zone settings failed.\n");
  721. }
  722. RegCloseKey(hKey);
  723. hKey = NULL;
  724. }
  725. //
  726. // 8/7/97 jmazner Olympus #6059
  727. // Due to the way IE 4 shell deals with RunOnce processing,
  728. // don't add any thing to RunOnce until the browser is
  729. // completely initialized (we get a DISPID_NAVIGATECOMPLETE event.)
  730. //
  731. if (!(SEF_NOSECURITYBACKUP & dwFlags))
  732. {
  733. SetControlFlags(SCF_NEEDBACKUPSECURITY);
  734. }
  735. else
  736. {
  737. ClearControlFlags(SCF_NEEDBACKUPSECURITY);
  738. }
  739. // Fix security hole for malious .isp/.ins file combinations
  740. BYTE szBytes[4];
  741. szBytes[0] = (BYTE)0;
  742. szBytes[1] = (BYTE)0;
  743. szBytes[2] = (BYTE)1;
  744. szBytes[3] = (BYTE)0;
  745. // Mark various registry entries as safe.
  746. if (ERROR_SUCCESS == RegOpenKey(HKEY_CLASSES_ROOT,TEXT("x-internet-signup"),&hKey))
  747. {
  748. RegSetValueEx(hKey,TEXT("EditFlags"),(DWORD)NULL,(DWORD)REG_BINARY,(BYTE*)&szBytes[0],(DWORD)4);
  749. RegCloseKey(hKey);
  750. hKey = NULL;
  751. }
  752. if (ERROR_SUCCESS == RegOpenKey(HKEY_CLASSES_ROOT,TEXT(".ins"),&hKey))
  753. {
  754. RegSetValueEx(hKey,TEXT("EditFlags"),(DWORD)NULL,(DWORD)REG_BINARY,(BYTE*)&szBytes[0],(DWORD)4);
  755. RegCloseKey(hKey);
  756. hKey = NULL;
  757. }
  758. if (ERROR_SUCCESS == RegOpenKey(HKEY_CLASSES_ROOT,TEXT(".isp"),&hKey))
  759. {
  760. RegSetValueEx(hKey,TEXT("EditFlags"),(DWORD)NULL,(DWORD)REG_BINARY,(BYTE*)&szBytes[0],(DWORD)4);
  761. RegCloseKey(hKey);
  762. hKey = NULL;
  763. }
  764. bISetAsSAFE=TRUE;
  765. SetControlFlags(SCF_SAFESET);
  766. //
  767. // ChrisK Olympus 6198 6/10/97
  768. // Allow HTML form submissions from ICW
  769. //
  770. if (g_fReadZone &&
  771. ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER,REG_ZONE3_KEY,&hKey))
  772. {
  773. DWORD dwZoneData;
  774. //
  775. // Set value for zone to 0, therefore opening security window
  776. //
  777. dwZoneData = 0;
  778. RegSetValueEx(hKey,
  779. REG_ZONE1601_KEY,
  780. NULL,
  781. REG_DWORD,
  782. (LPBYTE)&dwZoneData,
  783. sizeof(dwZoneData));
  784. RegCloseKey(hKey);
  785. hKey = NULL;
  786. }
  787. }
  788. //EndOfSecurityHandling:
  789. // jmazner 11/5/96 Normandy #8717
  790. // save autodial and clear out proxy _before_ bringing up the
  791. // IE instance.
  792. SaveAutoDial();
  793. SetExitFlags(SXF_RESTOREAUTODIAL);
  794. if (HTML_FILE == fileType)
  795. {
  796. DebugOut("ISIGNUP: Process HTML\n");
  797. fRet = ProcessHTML(pDynShare->hwndMain, szFileName);
  798. }
  799. else
  800. {
  801. DebugOut("ISIGNUP: Process ISP\n");
  802. if (TestControlFlags(SCF_ISPPROCESSING))
  803. {
  804. SetForegroundWindow(pDynShare->hwndMain);
  805. ReleaseSingleInstance();
  806. return FALSE;
  807. }
  808. else
  809. {
  810. SetControlFlags(SCF_ISPPROCESSING);
  811. }
  812. fRet = ProcessISP(pDynShare->hwndMain, szFileName);
  813. SetControlFlags(SCF_ISPPROCESSING);
  814. }
  815. }//end else RUN IEXPLORE Kiosk
  816. break;
  817. }
  818. default:
  819. if (IsSingleInstance(FALSE))
  820. {
  821. ErrorMsg1(pDynShare->hwndMain, IDS_INVALIDFILETYPE, szFileName);
  822. }
  823. if (NULL != pDynShare->hwndMain)
  824. {
  825. PostMessage(pDynShare->hwndMain, WM_CLOSE, 0, 0);
  826. }
  827. break;
  828. }
  829. // if we are the first window
  830. if ((hwnd == pDynShare->hwndMain) && (NULL != hwnd))
  831. {
  832. if (fRet)
  833. {
  834. MSG msg;
  835. SetTimer(hwnd, 0, 1000, NULL);
  836. DebugOut("ISIGNUP: Message loop\n");
  837. while (GetMessage (&msg, NULL, 0, 0))
  838. {
  839. TranslateMessage (&msg) ;
  840. DispatchMessage (&msg) ;
  841. }
  842. iRet = (int)msg.wParam ;
  843. }
  844. DoExit();
  845. if (NULL != hwndProgress)
  846. {
  847. DestroyWindow(hwndProgress);
  848. hwndProgress = NULL;
  849. }
  850. if (NULL != pDynShare->hwndLaunch)
  851. {
  852. DestroyWindow(pDynShare->hwndLaunch);
  853. pDynShare->hwndLaunch = NULL;
  854. }
  855. if (pDynShare->hwndMain)
  856. {
  857. DeleteUserDeviceSelection(DEVICENAMEKEY);
  858. DeleteUserDeviceSelection(DEVICETYPEKEY);
  859. }
  860. pDynShare->hwndMain = NULL;
  861. }
  862. exit:
  863. // 3/11/97 jmazner Olympus #1545
  864. if (TRUE == bISetAsSAFE)
  865. {
  866. RestoreSecurityPatch();
  867. ClearControlFlags(SCF_SAFESET);
  868. }
  869. UnloadInetFunctions();
  870. ReleaseSingleInstance();
  871. return iRet;
  872. }
  873. HWND MainInit()
  874. {
  875. HWND hwnd ;
  876. WNDCLASS wndclass ;
  877. wndclass.style = CS_HREDRAW | CS_VREDRAW ;
  878. wndclass.lpfnWndProc = WndProc ;
  879. wndclass.cbClsExtra = 0 ;
  880. wndclass.cbWndExtra = 0 ;
  881. wndclass.hInstance = ghInstance ;
  882. wndclass.hIcon = LoadIcon (ghInstance, TEXT("ICO_APP")) ;
  883. wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
  884. wndclass.hbrBackground = (HBRUSH)GetStockObject (WHITE_BRUSH) ;
  885. wndclass.lpszMenuName = NULL ;
  886. wndclass.lpszClassName = cszWndClassName;
  887. RegisterClass (&wndclass) ;
  888. hwnd = CreateWindow (cszWndClassName, // window class name
  889. cszAppName, // window caption
  890. WS_POPUP, // window style
  891. CW_USEDEFAULT, // initial x position
  892. CW_USEDEFAULT, // initial y position
  893. CW_USEDEFAULT, // initial x size
  894. CW_USEDEFAULT, // initial y size
  895. NULL, // parent window handle
  896. NULL, // window menu handle
  897. ghInstance, // program instance handle
  898. NULL) ; // creation parameters
  899. return hwnd;
  900. }
  901. LRESULT EXPORT FAR PASCAL WndProc (
  902. HWND hwnd,
  903. UINT message,
  904. WPARAM wParam,
  905. LPARAM lParam)
  906. {
  907. switch (message)
  908. {
  909. #ifdef WIN32
  910. case WM_PROCESSISP:
  911. DebugOut("ISIGNUP: Message loop got WM_PROCESSISP");
  912. if (TestControlFlags(SCF_ISPPROCESSING))
  913. {
  914. DebugOut("ISIGNUP: Received another WM_PROCESSISP message with gbCurrentlyProcessingISP = TRUE\r\n");
  915. SetForegroundWindow(pDynShare->hwndMain);
  916. // that's it, don't do anything else!
  917. }
  918. else
  919. {
  920. SetControlFlags(SCF_ISPPROCESSING);
  921. if ( !ProcessISP(pDynShare->hwndMain, g_szISPPath) )
  922. {
  923. PostMessage(pDynShare->hwndMain, WM_CLOSE, 0, 0);
  924. }
  925. }
  926. break;
  927. #endif
  928. case WM_TIMER:
  929. {
  930. HWND hwndTemp = FindBrowser();
  931. if (NULL == hwndTemp)
  932. {
  933. if (!TestControlFlags(SCF_SIGNUPCOMPLETED))
  934. {
  935. ++dwConnectedTime;
  936. if (pDynShare->hwndBrowser != NULL)
  937. {
  938. // browser went away
  939. KillTimer(hwnd, 0);
  940. KillConnection();
  941. InfoMsg(hwnd, IDS_BROWSERTERMINATED);
  942. PostQuitMessage(0);
  943. }
  944. else if (dwConnectedTime > WAIT_TIME)
  945. {
  946. KillTimer(hwnd, 0);
  947. if (NULL != pDynShare->hwndLaunch)
  948. {
  949. ShowWindow(pDynShare->hwndLaunch, SW_HIDE);
  950. }
  951. InfoMsg(hwnd, IDS_BROWSERNEVERFOUND);
  952. PostQuitMessage(0);
  953. }
  954. }
  955. }
  956. else
  957. {
  958. #ifdef WIN32 // don't do this with OLE automation; we're already full screen, and this causes flicker
  959. //if (NULL == hwndBrowser)
  960. //{
  961. //first time browser has been detected
  962. // ShowWindow(hwndTemp, SW_MAXIMIZE);
  963. //}
  964. #endif
  965. if ((NULL != pDynShare->hwndLaunch) && IsWindowVisible(hwndTemp))
  966. {
  967. ShowWindow(pDynShare->hwndLaunch, SW_HIDE);
  968. }
  969. }
  970. pDynShare->hwndBrowser = hwndTemp;
  971. }
  972. break;
  973. case WM_DESTROY:
  974. #if !defined(WIN16)
  975. if (pDynShare->hReconnectEvent)
  976. {
  977. DebugOut("ISIGN32: Set event to end reconnect thread.\r\n");
  978. SetControlFlags(SCF_RECONNECTTHREADQUITED);
  979. SetEvent(pDynShare->hReconnectEvent);
  980. CloseHandle(pDynShare->hReconnectEvent);
  981. pDynShare->hReconnectEvent = NULL;
  982. }
  983. #endif
  984. PostQuitMessage(0);
  985. return 0 ;
  986. }
  987. return DefWindowProc (hwnd, message, wParam, lParam) ;
  988. }
  989. void DoExit(void)
  990. {
  991. if (TestExitFlags(SXF_RESTOREDEFCHECK))
  992. {
  993. // restore IE check for default browser
  994. FRestoreBrowserDefaultChecking();
  995. }
  996. if (!TestExitFlags(SXF_KEEPCONNECTION))
  997. {
  998. // make sure the connection is closed
  999. KillConnection();
  1000. }
  1001. if (!TestExitFlags(SXF_KEEPBROWSER))
  1002. {
  1003. // make sure the browser is closed
  1004. KillBrowser();
  1005. }
  1006. if (TestExitFlags(SXF_RESTOREAUTODIAL))
  1007. {
  1008. // restore original autodial settings
  1009. RestoreAutoDial();
  1010. }
  1011. #if !defined(WIN16)
  1012. // 8/21/96 jmazner Normandy #4592
  1013. if ( TestExitFlags( SXF_RESTOREIEWINDOWPLACEMENT ))
  1014. {
  1015. RestoreIEWindowPlacement();
  1016. }
  1017. #endif
  1018. if (TestExitFlags(SXF_RUNEXECUTABLE))
  1019. {
  1020. BOOL fWait;
  1021. fWait = TestExitFlags(SXF_WAITEXECUTABLE);
  1022. if (RunExecutable(fWait) != ERROR_SUCCESS)
  1023. {
  1024. // clean up left overs
  1025. if (TestExitFlags(SXF_KEEPCONNECTION))
  1026. {
  1027. // make sure the connection is closed
  1028. KillConnection();
  1029. }
  1030. if (TestExitFlags(SXF_KEEPBROWSER))
  1031. {
  1032. // make sure the browser is closed
  1033. KillBrowser();
  1034. }
  1035. ErrorMsg1(NULL, IDS_EXECFAILED, pDynShare->szRunExecutable);
  1036. return;
  1037. }
  1038. }
  1039. }
  1040. BOOL HasPrefix(LPCTSTR lpszURL)
  1041. {
  1042. TCHAR szTemp[sizeof(cszHTTPS)];
  1043. //
  1044. // Check is the prefix is https
  1045. //
  1046. lstrcpyn(szTemp, lpszURL, lstrlen(cszHTTPS) + 1);
  1047. if (lstrcmp(szTemp, cszHTTPS) == 0)
  1048. return TRUE;
  1049. else
  1050. {
  1051. TCHAR szTemp[sizeof(cszHTTP)];
  1052. lstrcpyn(szTemp, lpszURL, lstrlen(cszHTTP) + 1);
  1053. return ((lstrcmp(szTemp, cszHTTP) == 0) || (lstrcmp(szTemp, cszFILE) == 0));
  1054. }
  1055. }
  1056. #ifdef WIN32
  1057. DWORD FixUpLocalURL(LPCTSTR lpszURL, LPTSTR lpszFullURL, DWORD cb)
  1058. {
  1059. TCHAR szLong[MAX_URL];
  1060. TCHAR szShort[MAX_URL];
  1061. DWORD dwSize;
  1062. if (GetFullPathName(
  1063. lpszURL,
  1064. MAX_URL,
  1065. szLong,
  1066. NULL) != 0)
  1067. {
  1068. NULL_TERM_TCHAR_BUFFER(szLong);
  1069. if (GetShortPathName(
  1070. szLong,
  1071. szShort,
  1072. SIZEOF_TCHAR_BUFFER(szShort)) != 0)
  1073. {
  1074. NULL_TERM_TCHAR_BUFFER(szShort);
  1075. dwSize = sizeof(cszFILE) + lstrlen(szShort);
  1076. if (dwSize < cb)
  1077. {
  1078. lpszFullURL[0] = '\0';
  1079. // Do not prepend file: for local files
  1080. // IE3.0 hack for bug :MSN Systems Bugs #9280
  1081. // lstrcpy(lpszFullURL, cszFILE);
  1082. lstrcat(lpszFullURL, szShort);
  1083. return dwSize;
  1084. }
  1085. }
  1086. }
  1087. return 0;
  1088. }
  1089. #else
  1090. DWORD FixUpLocalURL(LPCTSTR lpszURL, LPTSTR lpszFullURL, DWORD cb)
  1091. {
  1092. TCHAR szPath[MAX_URL];
  1093. DWORD dwSize;
  1094. if (GetFullPathName(
  1095. lpszURL,
  1096. MAX_URL,
  1097. szPath,
  1098. NULL) != 0)
  1099. {
  1100. dwSize = sizeof(cszFILE) + lstrlen(szPath);
  1101. if (dwSize < cb)
  1102. {
  1103. lstrcpy(lpszFullURL, cszFILE);
  1104. lstrcat(lpszFullURL, szPath);
  1105. return dwSize;
  1106. }
  1107. }
  1108. return 0;
  1109. }
  1110. #endif
  1111. DWORD FixUpURL(LPCTSTR lpszURL, LPTSTR lpszFullURL, DWORD cb)
  1112. {
  1113. DWORD dwSize;
  1114. if (HasPrefix(lpszURL))
  1115. {
  1116. dwSize = lstrlen(lpszURL);
  1117. if (dwSize < cb)
  1118. {
  1119. lstrcpyn(lpszFullURL, lpszURL, (int)cb);
  1120. return dwSize;
  1121. }
  1122. else
  1123. {
  1124. return 0;
  1125. }
  1126. }
  1127. else
  1128. {
  1129. return (FixUpLocalURL(lpszURL, lpszFullURL, cb));
  1130. }
  1131. }
  1132. BOOL GetURL(LPCTSTR lpszFile, LPCTSTR lpszKey, LPTSTR lpszURL, DWORD cb)
  1133. {
  1134. return (GetPrivateProfileString(cszURLSection,
  1135. lpszKey,
  1136. szNull,
  1137. lpszURL,
  1138. (int)cb,
  1139. lpszFile) != 0);
  1140. }
  1141. LPTSTR mystrrchr(LPCTSTR lpString, TCHAR ch)
  1142. {
  1143. LPCTSTR lpTemp = lpString;
  1144. LPTSTR lpLast = NULL;
  1145. while (*lpTemp)
  1146. {
  1147. if (*lpTemp == ch)
  1148. {
  1149. lpLast = (LPTSTR)lpTemp;
  1150. }
  1151. lpTemp = CharNext(lpTemp);
  1152. }
  1153. return lpLast;
  1154. }
  1155. #if !defined(WIN16)
  1156. //+----------------------------------------------------------------------------
  1157. // Function CopyUntil
  1158. //
  1159. // Synopsis Copy from source until destination until running out of source
  1160. // or until the next character of the source is the chend character
  1161. //
  1162. // Arguments dest - buffer to recieve characters
  1163. // src - source buffer
  1164. // lpdwLen - length of dest buffer
  1165. // chend - the terminating character
  1166. //
  1167. // Returns FALSE - ran out of room in dest buffer
  1168. //
  1169. // Histroy 10/25/96 ChrisK Created
  1170. //-----------------------------------------------------------------------------
  1171. static BOOL CopyUntil(LPTSTR *dest, LPTSTR *src, LPDWORD lpdwLen, TCHAR chend)
  1172. {
  1173. while (('\0' != **src) && (chend != **src) && (0 != *lpdwLen))
  1174. {
  1175. **dest = **src;
  1176. (*lpdwLen)--;
  1177. (*dest)++;
  1178. (*src)++;
  1179. }
  1180. return (0 != *lpdwLen);
  1181. }
  1182. //+----------------------------------------------------------------------------
  1183. // Function ConvertToLongFilename
  1184. //
  1185. // Synopsis convert a file to the full long file name
  1186. // ie. c:\progra~1\icw-in~1\isignup.exe becomes
  1187. // c:\program files\icw-internet connection wizard\isignup.exe
  1188. //
  1189. // Arguments szOut - output buffer
  1190. // szIn - filename to be converted
  1191. // dwSize - size of the output buffer
  1192. //
  1193. // Returns TRUE - success
  1194. //
  1195. // History 10/25/96 ChrisK Created
  1196. //-----------------------------------------------------------------------------
  1197. static BOOL ConvertToLongFilename(LPTSTR szOut, LPTSTR szIn, DWORD dwSize)
  1198. {
  1199. BOOL bRC = FALSE;
  1200. LPTSTR pCur = szIn;
  1201. LPTSTR pCurOut = szOut;
  1202. LPTSTR pCurOutFilename = NULL;
  1203. WIN32_FIND_DATA fd;
  1204. DWORD dwSizeTemp;
  1205. LPTSTR pTemp = NULL;
  1206. ZeroMemory(pCurOut,dwSize);
  1207. //
  1208. // Validate parameters
  1209. //
  1210. if (NULL != pCurOut && NULL != pCur && 0 != dwSize)
  1211. {
  1212. //
  1213. // Copy drive letter
  1214. //
  1215. if (!CopyUntil(&pCurOut,&pCur,&dwSize,'\\'))
  1216. goto ConvertToLongFilenameExit;
  1217. pCurOut[0] = '\\';
  1218. dwSize--;
  1219. pCur++;
  1220. pCurOut++;
  1221. pCurOutFilename = pCurOut;
  1222. while (*pCur)
  1223. {
  1224. //
  1225. // Copy over possibly short name
  1226. //
  1227. pCurOut = pCurOutFilename;
  1228. dwSizeTemp = dwSize;
  1229. if (!CopyUntil(&pCurOut,&pCur,&dwSize,'\\'))
  1230. goto ConvertToLongFilenameExit;
  1231. ZeroMemory(&fd, sizeof(fd));
  1232. //
  1233. // Get long filename
  1234. //
  1235. if (INVALID_HANDLE_VALUE != FindFirstFile(szOut,&fd))
  1236. {
  1237. //
  1238. // Replace short filename with long filename
  1239. //
  1240. dwSize = dwSizeTemp;
  1241. pTemp = &(fd.cFileName[0]);
  1242. if (!CopyUntil(&pCurOutFilename,&pTemp,&dwSize,'\0'))
  1243. goto ConvertToLongFilenameExit;
  1244. if (*pCur)
  1245. {
  1246. //
  1247. // If there is another section then we just copied a directory
  1248. // name. Append a \ character;
  1249. //
  1250. pTemp = (LPTSTR)memcpy(TEXT("\\X"),TEXT("\\X"),0);
  1251. if (!CopyUntil(&pCurOutFilename,&pTemp,&dwSize,'X'))
  1252. goto ConvertToLongFilenameExit;
  1253. pCur++;
  1254. }
  1255. }
  1256. else
  1257. {
  1258. break;
  1259. }
  1260. }
  1261. //
  1262. // Did we get to the end (TRUE) or fail before that (FALSE)?
  1263. //
  1264. bRC = ('\0' == *pCur);
  1265. }
  1266. ConvertToLongFilenameExit:
  1267. return bRC;
  1268. }
  1269. #endif //!WIN16
  1270. INET_FILETYPE GetInetFileType(LPCTSTR lpszFile)
  1271. {
  1272. LPTSTR lpszExt;
  1273. INET_FILETYPE ft = UNKNOWN_FILE;
  1274. lpszExt = mystrrchr(lpszFile, '.');
  1275. if (NULL != lpszExt)
  1276. {
  1277. if (!lstrcmpi(lpszExt, cszExtINS))
  1278. {
  1279. ft = INS_FILE;
  1280. }
  1281. else if (!lstrcmpi(lpszExt, cszExtISP))
  1282. {
  1283. ft = ISP_FILE;
  1284. }
  1285. else if (!lstrcmpi(lpszExt, cszExtHTM))
  1286. {
  1287. ft = HTML_FILE;
  1288. }
  1289. else if (!lstrcmpi(lpszExt, cszExtHTML))
  1290. {
  1291. ft = HTML_FILE;
  1292. }
  1293. }
  1294. return ft;
  1295. }
  1296. #ifdef SETUPSTACK
  1297. DWORD SetRunOnce(LPCTSTR lpszFileName)
  1298. {
  1299. TCHAR szTemp[MAX_PATH + MAX_PATH + 1];
  1300. TCHAR szTemp2[MAX_PATH + 1];
  1301. DWORD dwRet = ERROR_CANTREAD;
  1302. HKEY hKey;
  1303. LPTSTR lpszFilePart;
  1304. if (GetModuleFileName(NULL,szTemp2,SIZEOF_TCHAR_BUFFER(szTemp2)) != 0)
  1305. {
  1306. NULL_TERM_TCHAR_BUFFER(szTemp2);
  1307. //
  1308. // Will not convert the ShortPathName into LongPathName even in
  1309. // case of NT/Win-95 as START.EXE parses long file names incorrectly
  1310. // on NT (short path names will work fine from Win-95's RUNONCE registry
  1311. // entry too. MKarki - Fix for Bug #346(OLYMPUS) 4/21/97
  1312. //
  1313. #if 0 //!defined(WIN16)
  1314. // szTemp2 contains the module name in short format
  1315. ConvertToLongFilename(szTemp,szTemp2,MAX_PATH);
  1316. // add quotes
  1317. wsprintf(szTemp2,TEXT("\"%s\""),szTemp);
  1318. // copy back into szTemp
  1319. lstrcpy(szTemp,szTemp2);
  1320. #else
  1321. GetShortPathName (szTemp2, szTemp, SIZEOF_TCHAR_BUFFER(szTemp));
  1322. NULL_TERM_TCHAR_BUFFER(szTemp);
  1323. //lstrcpy(szTemp,szTemp2);
  1324. #endif
  1325. // Determine Version
  1326. OSVERSIONINFO osvi;
  1327. ZeroMemory(&osvi,sizeof(OSVERSIONINFO));
  1328. osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  1329. if (!GetVersionEx(&osvi))
  1330. {
  1331. ZeroMemory(&osvi,sizeof(OSVERSIONINFO));
  1332. }
  1333. // 1/20/96 jmazner Normandy #9403
  1334. // For NT only, use the startup menu
  1335. if (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId)
  1336. {
  1337. // 3/14/97 jmazner TEMP
  1338. // temporary hack until we can work with IE for a better solution
  1339. //lstrcat(szTemp, " -r ");
  1340. //
  1341. // adding a -b switch so that when we start again we
  1342. // know that we are starting of a batch file
  1343. // MKarki (5/1/97) -Fix for Bug #4049
  1344. //
  1345. lstrcat(szTemp, TEXT(" -b -r -h "));
  1346. //
  1347. // adding extra quote at the front and end of file
  1348. // as we dont want start.exe to parse the filename
  1349. // MKarki (5/1/97) -Fix for Bug #4049
  1350. //
  1351. lstrcat (szTemp,TEXT("\""));
  1352. lstrcat(szTemp, lpszFileName);
  1353. lstrcat (szTemp,TEXT("\""));
  1354. SetStartUpCommand( szTemp );
  1355. }
  1356. else
  1357. {
  1358. //
  1359. // 3/14/97 jmazner TEMP
  1360. // temporary hack until we can work with IE for a better solution
  1361. //
  1362. // 8/8/97 jmazner Olympus #6059
  1363. // Well, we have a somewhat better solution. The problem here was that
  1364. // isignup without the -h sticks the backup security into the RunOnce key.
  1365. // But if Isignup itself was started from a RunOnce entry, there was a
  1366. // chance that RunOnce would also then execute the backup plan. For 6059
  1367. // the backup plan RunOnce entry has been defered, so it's okay to get
  1368. // rid of the -h now
  1369. //
  1370. lstrcat(szTemp, TEXT(" -r "));
  1371. //lstrcat(szTemp, TEXT(" -r -h "));
  1372. lstrcat(szTemp, lpszFileName);
  1373. dwRet = RegCreateKey(
  1374. HKEY_LOCAL_MACHINE,
  1375. REGSTR_PATH_RUNONCE,
  1376. &hKey);
  1377. if (ERROR_SUCCESS == dwRet)
  1378. {
  1379. dwRet = RegSetValueEx(
  1380. hKey,
  1381. cszAppName,
  1382. 0L,
  1383. REG_SZ,
  1384. (LPBYTE)szTemp,
  1385. MAX_PATH + MAX_PATH + 1);
  1386. RegCloseKey(hKey);
  1387. }
  1388. }
  1389. }
  1390. return dwRet;
  1391. }
  1392. #endif
  1393. static BOOL ProcessCommandLine(
  1394. LPCTSTR lpszCmdLine,
  1395. LPDWORD lpdwfOptions,
  1396. LPTSTR lpszFile,
  1397. DWORD cb)
  1398. {
  1399. LPTSTR lpszCmd = NULL;
  1400. TCHAR szCommandLine[MAX_PATH +1];
  1401. TCHAR szTemp[_MAX_PATH + 1] = TEXT("");
  1402. LPTSTR lpszFilePart = NULL;
  1403. LPTSTR lpszConn = NULL;
  1404. BOOL fEnabled;
  1405. //
  1406. // need to copy the command line into our own buffers
  1407. // as it might be modified
  1408. // MKarki (5/1/97) - Fix for Bug#4049
  1409. //
  1410. CopyMemory (szCommandLine, lpszCmdLine, MAX_PATH);
  1411. lpszCmd = szCommandLine;
  1412. *lpdwfOptions = SEF_SPLASH;
  1413. #ifdef WIN32
  1414. // Determine Version
  1415. OSVERSIONINFO osvi;
  1416. ZeroMemory(&osvi,sizeof(OSVERSIONINFO));
  1417. osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  1418. if (!GetVersionEx(&osvi))
  1419. {
  1420. ZeroMemory(&osvi,sizeof(OSVERSIONINFO));
  1421. }
  1422. #endif
  1423. // check to see if invoked from run once
  1424. while ((*lpszCmd == '-') || (*lpszCmd == '/'))
  1425. {
  1426. ++lpszCmd; // skip '-' or '/'
  1427. switch (*lpszCmd)
  1428. {
  1429. case 'b': // we are running off a batch file
  1430. ++lpszCmd; // skip 'b'
  1431. #ifdef WIN32
  1432. //
  1433. // another thing specific to WINNT is to remove the
  1434. // quotes from front and end of the file name, these
  1435. // have been put so that start.exe does not act smart
  1436. // and start parsing it and find things like & as special
  1437. // chars
  1438. // MKarki (5/1/97) - Fix for Bug #4049
  1439. if (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId)
  1440. {
  1441. RemoveQuotes (lpszCmd);
  1442. }
  1443. #endif
  1444. case 'r':
  1445. ++lpszCmd; // skip 'r'
  1446. *lpdwfOptions |= SEF_RUNONCE;
  1447. #ifdef WIN32
  1448. // 1/20/96 jmazner Normandy #9403
  1449. // clean up the .bat file if we did a run once under NT
  1450. if (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId)
  1451. {
  1452. DeleteStartUpCommand();
  1453. }
  1454. #endif
  1455. break;
  1456. case 'a':
  1457. ++lpszCmd; // skip 'a'
  1458. *lpdwfOptions &= ~SEF_SPLASH;
  1459. SetControlFlags(SCF_AUTODIALSAVED);
  1460. SetExitFlags(SXF_RESTOREAUTODIAL);
  1461. // get the name of the ISBU referal server, we may need it later.
  1462. lpfnInetGetAutodial(
  1463. &fEnabled,
  1464. pDynShare->szSignupConnection,
  1465. sizeof(pDynShare->szSignupConnection));
  1466. if (*lpszCmd++ == '1')
  1467. {
  1468. SetControlFlags(SCF_AUTODIALENABLED);
  1469. }
  1470. break;
  1471. case 'p':
  1472. ++lpszCmd; // skip 'p'
  1473. if (*lpszCmd++ == '1')
  1474. {
  1475. SetControlFlags(SCF_PROXYENABLED);
  1476. }
  1477. break;
  1478. case 'c':
  1479. ++lpszCmd; // skip 'c'
  1480. if (*lpszCmd++ != '"')
  1481. {
  1482. return FALSE;
  1483. }
  1484. lpszConn = pDynShare->szAutodialConnection;
  1485. while(*lpszCmd)
  1486. {
  1487. if (*lpszCmd == '"')
  1488. {
  1489. ++lpszCmd; // skip '"'
  1490. break;
  1491. }
  1492. *lpszConn++ = *lpszCmd++;
  1493. }
  1494. *lpszConn = 0; // terminate string
  1495. break;
  1496. case 'x':
  1497. ++lpszCmd; // skip 'x'
  1498. *lpdwfOptions |= SEF_PROGRESS;
  1499. break;
  1500. #if !defined(WIN16)
  1501. case 's':
  1502. ++lpszCmd; // skip 's'
  1503. SetControlFlags(SCF_SILENT);
  1504. break;
  1505. #endif
  1506. // 3/14/97 jmazner TEMP
  1507. // temporary hack until we can work with IE for a better solution
  1508. case 'h':
  1509. ++lpszCmd; // skip 'h'
  1510. *lpdwfOptions |= SEF_NOSECURITYBACKUP;
  1511. break;
  1512. default:
  1513. break;
  1514. }
  1515. // strip away spaces
  1516. while(*lpszCmd == ' ')
  1517. {
  1518. ++lpszCmd;
  1519. }
  1520. }
  1521. if (0 == GetFullPathName(lpszCmd, _MAX_PATH + 1, szTemp, &lpszFilePart))
  1522. {
  1523. return FALSE;
  1524. }
  1525. // 11/26/96 jmazner Normandy #12142
  1526. // GetFullPathName called with lpszCmd == "c:" will return successfully, but
  1527. // lpszFilePart will be NULL. Check for that case.
  1528. if( !lpszFilePart )
  1529. return FALSE;
  1530. if (lstrlen(szTemp) >= (int)cb)
  1531. {
  1532. return FALSE;
  1533. }
  1534. lstrcpy(lpszFile, szTemp);
  1535. *lpszFilePart = '\0';
  1536. // set the current directory
  1537. // so that relative path will work
  1538. if (!SetCurrentDirectory(szTemp))
  1539. {
  1540. return FALSE;
  1541. }
  1542. return TRUE;
  1543. }
  1544. static BOOL KeepBrowser(LPCTSTR lpszFile)
  1545. {
  1546. TCHAR szTemp[10];
  1547. GetPrivateProfileString(cszCustomSection,
  1548. cszKeepBrowser,
  1549. cszNo,
  1550. szTemp,
  1551. 10,
  1552. lpszFile);
  1553. return (!lstrcmpi(szTemp, cszYes));
  1554. }
  1555. static BOOL KeepConnection(LPCTSTR lpszFile)
  1556. {
  1557. TCHAR szTemp[10];
  1558. GetPrivateProfileString(cszCustomSection,
  1559. cszKeepConnection,
  1560. cszNo,
  1561. szTemp,
  1562. 10,
  1563. lpszFile);
  1564. return (!lstrcmpi(szTemp, cszYes));
  1565. }
  1566. #if defined(WIN16)
  1567. static int CopyFile(LPCTSTR lpcszSrcFile, LPCTSTR lpcszDestFile)
  1568. {
  1569. HFILE hSrcFile, hDestFile;
  1570. UINT uiBytesRead = 0;
  1571. TCHAR szBuf[2048];
  1572. hSrcFile = _lopen(lpcszSrcFile, READ);
  1573. if (HFILE_ERROR == hSrcFile)
  1574. return -1;
  1575. //
  1576. // Create new file or if the file esists truncate it
  1577. //
  1578. hDestFile = _lcreat(lpcszDestFile, 0);
  1579. if (HFILE_ERROR == hDestFile)
  1580. {
  1581. _lclose(hSrcFile);
  1582. return -1;
  1583. }
  1584. do
  1585. {
  1586. uiBytesRead = _lread(hSrcFile, &szBuf[0], 2048);
  1587. if (HFILE_ERROR == uiBytesRead)
  1588. break;
  1589. _lwrite(hDestFile, &szBuf[0], uiBytesRead);
  1590. } while (0 != uiBytesRead);
  1591. _lclose(hSrcFile);
  1592. _lclose(hDestFile);
  1593. return 0;
  1594. }
  1595. #endif
  1596. #if defined(WIN16)
  1597. //+----------------------------------------------------------------------------
  1598. //
  1599. // Function: BackUpINSFile
  1600. //
  1601. // Synopsis: The 3.1 version of IE2.01 will delete the .ins file too soon
  1602. // therefore the ICW will make a backup of the ins file for use
  1603. // later.
  1604. //
  1605. // Arguments: lpszFile - name of INS file
  1606. //
  1607. // Returns: TRUE - success
  1608. // FALSE - failure
  1609. //
  1610. // History: 3/19/97 ChrisK extracted from ProcessINS
  1611. //-----------------------------------------------------------------------------
  1612. BOOL BackUpINSFile(LPCTSTR lpszFile)
  1613. {
  1614. LPTSTR lpszTemp;
  1615. TCHAR szNewFileName[MAX_PATH+2];
  1616. BOOL bRC = FALSE;
  1617. HWND hwnd = NULL;
  1618. ZeroMemory(&szNewFileName[0], MAX_PATH+1);
  1619. //
  1620. // Check if the last character in prefix is 'a'
  1621. // If it is, change it to 'b' in the new file name
  1622. // otherwise, change it to 'a' in the new file name
  1623. // Eg.: C:\iexplore\vetriv.ins --> C:\iexplore\vetria.ins
  1624. // Eg.: C:\iexplore\aaaaa.ins --> C:\iexplore\aaaab.ins
  1625. //
  1626. lpszTemp = strrchr(lpszFile, '.');
  1627. if (NULL == lpszTemp)
  1628. {
  1629. ErrorMsg(hwnd, IDS_CANNOTPROCESSINS);
  1630. goto BackUpINSFileExit;
  1631. }
  1632. lstrcpyn(szNewFileName, lpszFile, lpszTemp - lpszFile);
  1633. if ((*(lpszTemp - 1)) == 'a')
  1634. lstrcat(szNewFileName, TEXT("b.INS"));
  1635. else
  1636. lstrcat(szNewFileName, TEXT("a.INS"));
  1637. //
  1638. // Copy the contents
  1639. //
  1640. if (0 != CopyFile(lpszFile, szNewFileName))
  1641. {
  1642. ErrorMsg(hwnd, IDS_CANNOTPROCESSINS);
  1643. goto BackUpINSFileExit;
  1644. }
  1645. else
  1646. {
  1647. lpszFile = &szNewFileName[0];
  1648. }
  1649. bRC = TRUE;
  1650. BackUpINSFileExit:
  1651. return bRC;
  1652. }
  1653. #endif // WIN16
  1654. //+----------------------------------------------------------------------------
  1655. //
  1656. // Function: IsCancelINSFile
  1657. //
  1658. // Synopsis: This function will determine if the ins file is a cancel
  1659. // file, and if it is this function will handle it accordingly
  1660. //
  1661. // Arguments: lpszFile - name of ins file
  1662. // fSignup - TRUE if part of the signup process
  1663. //
  1664. // Returns: TRUE - ins file is a cancel file
  1665. //
  1666. // History: 3/19/97 ChrisK separated from process INS
  1667. //-----------------------------------------------------------------------------
  1668. BOOL IsCancelINSFile(LPCTSTR lpszFile,BOOL fSignup)
  1669. {
  1670. TCHAR szTemp[_MAX_PATH] = TEXT("XX");
  1671. BOOL bRC = FALSE;
  1672. HWND hwndMsg;
  1673. if (GetPrivateProfileString(cszEntrySection,
  1674. cszCancel,
  1675. szNull,
  1676. szTemp,
  1677. _MAX_PATH,
  1678. lpszFile) != 0)
  1679. {
  1680. bRC = TRUE;
  1681. if (fSignup && !TestControlFlags(SCF_CANCELINSPROCESSED))
  1682. {
  1683. // If this instance is part of a signup process
  1684. #if !defined(WIN16)
  1685. SetControlFlags(SCF_HANGUPEXPECTED);
  1686. #endif // !WIN16
  1687. SetControlFlags(SCF_CANCELINSPROCESSED);
  1688. KillConnection();
  1689. // jmazner 4/17/97 Olympus #2471
  1690. // kill IE window here to prevent user from clicking on cancel.ins link
  1691. // multiple times.
  1692. PostMessage(pDynShare->hwndMain, WM_CLOSE, 0, 0);
  1693. InfoMsg(NULL, IDS_SIGNUPCANCELLED);
  1694. //PostMessage(hwndMain, WM_CLOSE, 0, 0);
  1695. }
  1696. else if (TestControlFlags(SCF_CANCELINSPROCESSED))
  1697. {
  1698. // Bring the ISIGNUP widows to the front
  1699. hwndMsg = FindWindow(TEXT("#32770"),cszAppName);
  1700. if (hwndMsg)
  1701. {
  1702. #if !defined(WIN16)
  1703. SetForegroundWindow (hwndMsg);
  1704. #else // !WIN16
  1705. SetFocus (hwndMsg);
  1706. #endif // !WIN16
  1707. }
  1708. }
  1709. }
  1710. return bRC;
  1711. }
  1712. //+----------------------------------------------------------------------------
  1713. //
  1714. // Function: IsHangupINSFile
  1715. //
  1716. // Synopsis: This function will determine if the ins file is a hangup
  1717. // file, and if it is this function will handle it accordingly
  1718. //
  1719. // Arguments: lpszFile - name of ins file
  1720. // fSignup - TRUE if part of the signup process
  1721. //
  1722. // Returns: TRUE - ins file is a hangup file
  1723. //
  1724. // History: 3/19/97 donaldm
  1725. //-----------------------------------------------------------------------------
  1726. BOOL IsHangupINSFile(LPCTSTR lpszFile,BOOL fSignup)
  1727. {
  1728. TCHAR szTemp[_MAX_PATH] = TEXT("XX");
  1729. BOOL bRC = FALSE;
  1730. HWND hwndMsg;
  1731. if (GetPrivateProfileString(cszEntrySection,
  1732. cszHangup,
  1733. szNull,
  1734. szTemp,
  1735. _MAX_PATH,
  1736. lpszFile) != 0)
  1737. {
  1738. bRC = TRUE;
  1739. if (fSignup && !TestControlFlags(SCF_HANGUPINSPROCESSED))
  1740. {
  1741. // If this instance is part of a signup process
  1742. #if !defined(WIN16)
  1743. SetControlFlags(SCF_HANGUPEXPECTED);
  1744. #endif // !WIN16
  1745. SetControlFlags(SCF_HANGUPINSPROCESSED);
  1746. KillConnection();
  1747. // jmazner 4/17/97 Olympus #2471
  1748. // kill IE window here to prevent user from clicking on cancel.ins link
  1749. // multiple times.
  1750. PostMessage(pDynShare->hwndMain, WM_CLOSE, 0, 0);
  1751. }
  1752. else if (TestControlFlags(SCF_HANGUPINSPROCESSED))
  1753. {
  1754. // Bring the ISIGNUP widows to the front
  1755. hwndMsg = FindWindow(TEXT("#32770"),cszAppName);
  1756. if (hwndMsg)
  1757. {
  1758. #if !defined(WIN16)
  1759. SetForegroundWindow (hwndMsg);
  1760. #else // !WIN16
  1761. SetFocus (hwndMsg);
  1762. #endif // !WIN16
  1763. }
  1764. }
  1765. }
  1766. return bRC;
  1767. }
  1768. //+----------------------------------------------------------------------------
  1769. //
  1770. // Function: ProcessINS
  1771. //
  1772. // Synopsis: This function will process the contents of an .INS file
  1773. //
  1774. // Arguments: hwnd - pointer to parent window for all UI elements
  1775. // lpszFile - name of .INS file
  1776. // fSignup - if TRUE then this INS file is being processed as
  1777. // part a signup
  1778. //
  1779. // Returns: TRUE - success
  1780. // FALSE - failure
  1781. //
  1782. // History: 3/19/97 ChrisK Reworked the function considerbly to clean up
  1783. // a lot of problem with deleting INS files.
  1784. //-----------------------------------------------------------------------------
  1785. BOOL ProcessINS(HWND hwnd, LPCTSTR lpszFile, BOOL fSignup)
  1786. {
  1787. BOOL fNeedsRestart = FALSE;
  1788. LPRASENTRY lpRasEntry = NULL;
  1789. BOOL fConnectoidCreated = FALSE;
  1790. DWORD dwRet = 0xFF;
  1791. TCHAR szTemp[MAX_PATH] = TEXT("XX");
  1792. TCHAR szConnectoidName[RAS_MaxEntryName*2] = TEXT("");
  1793. BOOL fClientSetup = FALSE;
  1794. BOOL bRC = FALSE;
  1795. BOOL fErrMsgShown = FALSE;
  1796. #if !defined(WIN16)
  1797. DWORD dwSBSRet = ERROR_SUCCESS;
  1798. #endif // WIN16
  1799. HKEY hKey = NULL;
  1800. DWORD dwSize = sizeof(DWORD);
  1801. DWORD dwDesktopChanged = 0;
  1802. // 3/11/97 jmazner Olympus #1545
  1803. // close up the security hole ASAP. This will unfortunately also
  1804. // prevent a clever .ins file from bringing the user back to the
  1805. // referall page to choose a different ISP
  1806. #if !defined (WIN16)
  1807. RestoreSecurityPatch();
  1808. #endif // !WIN16
  1809. //
  1810. // Insure that the contents of the file are formatted correctly so
  1811. // that the GetPrivateProfile calls can parse the contents.
  1812. //
  1813. dwRet = MassageFile(lpszFile);
  1814. if (ERROR_SUCCESS != dwRet)
  1815. {
  1816. ErrorMsg(hwnd, IDS_CANNOTPROCESSINS);
  1817. goto ProcessINSExit;
  1818. }
  1819. //
  1820. // Determine if the .INS file is a "cancel" file
  1821. //
  1822. if (FALSE != IsCancelINSFile(lpszFile,fSignup))
  1823. goto ProcessINSExit;
  1824. //
  1825. // Determine if the .INS file is a "hangup" file
  1826. //
  1827. if (FALSE != IsHangupINSFile(lpszFile,fSignup))
  1828. goto ProcessINSExit;
  1829. //
  1830. // Make sure that the RAS services are running before calling any RAS APIs.
  1831. // This only applies to NT, but the function is smart enough to figure that
  1832. // out
  1833. //
  1834. #if !defined(WIN16)
  1835. if (!VerifyRasServicesRunning(hwnd))
  1836. goto ProcessINSExit;
  1837. #endif // !WIN16
  1838. //
  1839. // If we are no in the signup process, warn the user before changing there
  1840. // settings
  1841. //
  1842. if (!fSignup && !TestControlFlags(SCF_SILENT))
  1843. {
  1844. if (!WarningMsg(NULL, IDS_INSFILEWARNING))
  1845. {
  1846. goto ProcessINSExit;
  1847. }
  1848. }
  1849. else
  1850. {
  1851. #if !defined (WIN16)
  1852. // If there is a ClientSetup section, then we know that icwconn2
  1853. // will have to be run after isignup in order to handle the
  1854. // settings
  1855. if (GetPrivateProfileSection(cszClientSetupSection,
  1856. szTemp,
  1857. MAX_PATH,
  1858. lpszFile) != 0)
  1859. fClientSetup = TRUE;
  1860. #endif // !WIN16
  1861. if (fClientSetup || KeepConnection(lpszFile))
  1862. SetExitFlags(SXF_KEEPCONNECTION);
  1863. if (KeepBrowser(lpszFile))
  1864. SetExitFlags(SXF_KEEPBROWSER);
  1865. if (!TestExitFlags(SXF_KEEPCONNECTION))
  1866. KillConnection();
  1867. }
  1868. //
  1869. // Import various information from INS file
  1870. //
  1871. // Import name of executable to be launched after isignup
  1872. ImportCustomInfo(
  1873. lpszFile,
  1874. pDynShare->szRunExecutable,
  1875. SIZEOF_TCHAR_BUFFER(pDynShare->szRunExecutable),
  1876. pDynShare->szRunArgument,
  1877. SIZEOF_TCHAR_BUFFER(pDynShare->szRunArgument));
  1878. // Import RAS log-on script file
  1879. ImportCustomFile(lpszFile);
  1880. // Import network connection settings information and configure client
  1881. // pieces to use them.
  1882. dwRet = ConfigureClient(
  1883. hwnd,
  1884. lpszFile,
  1885. &fNeedsRestart,
  1886. &fConnectoidCreated,
  1887. TestControlFlags(SCF_LOGONREQUIRED),
  1888. szConnectoidName,
  1889. RAS_MaxEntryName);
  1890. //
  1891. // 6/2/97 jmazner Olympus #4573
  1892. // display an appropriate error msg
  1893. //
  1894. if( ERROR_SUCCESS != dwRet )
  1895. {
  1896. // 10/07/98 vyung IE bug#32882 hack.
  1897. // If we do not detect the [Entry] section in the ins file,
  1898. // we will assume it is an OE ins file. Then we will assume
  1899. // we have a autodial connection and pass the INS to OE.
  1900. if (ERROR_NO_MATCH == dwRet)
  1901. {
  1902. ImportMailAndNewsInfo(lpszFile, TRUE);
  1903. return TRUE;
  1904. }
  1905. else
  1906. {
  1907. ErrorMsg(hwnd, IDS_INSTALLFAILED);
  1908. fErrMsgShown = TRUE;
  1909. }
  1910. }
  1911. // Import information used to brand the broswer
  1912. ImportBrandingInfo(lpszFile, szConnectoidName);
  1913. #if !defined(WIN16)
  1914. // If we created a connectoid, tell the world that ICW
  1915. // has left the building...
  1916. SetICWCompleted( (DWORD)1 );
  1917. ClearControlFlags(SCF_ICWCOMPLETEDKEYRESETED);
  1918. // 2/19/97 jmazner Olympus 1106
  1919. // For SBS/SAM integration.
  1920. dwSBSRet = CallSBSConfig(hwnd, lpszFile);
  1921. switch( dwSBSRet )
  1922. {
  1923. case ERROR_SUCCESS:
  1924. break;
  1925. case ERROR_MOD_NOT_FOUND:
  1926. case ERROR_DLL_NOT_FOUND:
  1927. Dprintf("ISIGN32: SBSCFG DLL not found, I guess SAM ain't installed.\n");
  1928. break;
  1929. default:
  1930. ErrorMsg(hwnd, IDS_SBSCFGERROR);
  1931. }
  1932. #endif // !WIN16
  1933. #if defined(WIN16)
  1934. //
  1935. // Since IE 21 deletes the file from cache, we have to make
  1936. // a private copy of it, if we are going to run a 3rd EXE
  1937. //
  1938. if (*(pDynShare->szRunExecutable))
  1939. {
  1940. if (FALSE == BackUpINSFile(lpszFile))
  1941. goto ProcessINSExit;
  1942. }
  1943. #endif // WIN16
  1944. #if !defined (WIN16)
  1945. //
  1946. // If the INS file contains the ClientSetup section, build the commandline
  1947. // arguments for ICWCONN2.exe.
  1948. //
  1949. if (fClientSetup)
  1950. {
  1951. // Check to see if a REBOOT is needed and tell the next application to
  1952. // handle it.
  1953. if (fNeedsRestart)
  1954. {
  1955. wsprintf(pDynShare->szRunArgument,TEXT(" /INS:\"%s\" /REBOOT"),lpszFile);
  1956. fNeedsRestart = FALSE;
  1957. }
  1958. else
  1959. {
  1960. wsprintf(pDynShare->szRunArgument,TEXT(" /INS:\"%s\""),lpszFile);
  1961. }
  1962. }
  1963. #else // !WIN16
  1964. wsprintf(szRunArgument," /INS:\"%s\"",lpszFile);
  1965. #endif // !WIN16
  1966. SetControlFlags(SCF_SIGNUPCOMPLETED);
  1967. if (!TestExitFlags(SXF_KEEPBROWSER))
  1968. KillBrowser();
  1969. #ifdef WIN32
  1970. // humongous hack for ISBU
  1971. if (ERROR_SUCCESS != dwRet && fConnectoidCreated)
  1972. {
  1973. InfoMsg(hwnd, IDS_MAILFAILED);
  1974. dwRet = ERROR_SUCCESS;
  1975. }
  1976. #endif
  1977. //
  1978. // Import settings for mail and new read from INS file (ChrisK, 7/1/96)
  1979. //
  1980. if (ERROR_SUCCESS == dwRet)
  1981. ImportMailAndNewsInfo(lpszFile, fConnectoidCreated);
  1982. //
  1983. // Close up final details and clean up
  1984. //
  1985. if (ERROR_SUCCESS == dwRet)
  1986. {
  1987. // if the connectoid was created, do not restore the old autodial settings
  1988. if (fConnectoidCreated)
  1989. ClearExitFlags(SXF_RESTOREAUTODIAL);
  1990. #ifdef SETUPSTACK
  1991. // Is it necessary to reboot for configuration to take effect?
  1992. if (fNeedsRestart)
  1993. {
  1994. // what do we do if we need to run executable and
  1995. // we need the link or the browser BARF!!
  1996. if (PromptRestart(hwnd))
  1997. {
  1998. // 3/13/97 jmazner Olympus #1682
  1999. // technically, shouldn't need this here since we did it at the start
  2000. // of processINS, but better safe...
  2001. RestoreSecurityPatch();
  2002. FGetSystemShutdownPrivledge();
  2003. ExitWindowsEx(EWX_REBOOT, 0);
  2004. //
  2005. // We will wait for the System to release all
  2006. // resources, 5 minutes should be more than
  2007. // enough for this
  2008. // - MKarki (4/22/97) - MKarki
  2009. // Fix for Bug #3109
  2010. //
  2011. // 7/8/97 jmazner Olympus 4212
  2012. // No, sleeping for 5 minutes turns out not to be such a good idea.
  2013. //Sleep (300000);
  2014. //
  2015. }
  2016. }
  2017. else
  2018. #endif
  2019. {
  2020. if (*(pDynShare->szRunExecutable))
  2021. {
  2022. SetExitFlags(SXF_RUNEXECUTABLE | SXF_WAITEXECUTABLE);
  2023. }
  2024. else
  2025. {
  2026. if (!TestControlFlags(SCF_SILENT))
  2027. InfoMsg(hwnd, IDS_SIGNUPCOMPLETE);
  2028. }
  2029. }
  2030. }
  2031. else
  2032. {
  2033. // In case of an error with network or connection settings
  2034. ClearExitFlags(~SXF_RESTOREAUTODIAL);
  2035. if( !fErrMsgShown )
  2036. {
  2037. ErrorMsg(hwnd, IDS_BADSETTINGS);
  2038. fErrMsgShown = TRUE;
  2039. }
  2040. }
  2041. // If this is part of signup process, then signal the first instance
  2042. // to close
  2043. if (fSignup)
  2044. {
  2045. PostMessage(pDynShare->hwndMain, WM_CLOSE, 0, 0);
  2046. }
  2047. // Restore the desktop icons if we have the newer version of ICWCONN1.EXE,
  2048. // and we previsouly munged them.
  2049. if (ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER,ICWSETTINGSPATH,&hKey))
  2050. {
  2051. RegQueryValueEx(hKey,
  2052. ICWDESKTOPCHANGED,
  2053. 0,
  2054. NULL,
  2055. (BYTE*)&dwDesktopChanged,
  2056. &dwSize);
  2057. RegCloseKey(hKey);
  2058. }
  2059. if (dwDesktopChanged)
  2060. {
  2061. DWORD dwVerMS, dwVerLS;
  2062. if( GetAppVersion( &dwVerMS, &dwVerLS, ICW20_PATHKEY ) )
  2063. {
  2064. // if( ( (dwVerMS >= ICW20_MINIMUM_VERSIONMS) && (dwVerLS >= ICW20_MINIMUM_VERSIONLS) ) )
  2065. if(dwVerMS >= ICW20_MINIMUM_VERSIONMS)
  2066. {
  2067. ShellExecute(NULL, cszOpen, g_szICWCONN1, g_szRestoreDesktop, NULL, SW_HIDE);
  2068. }
  2069. }
  2070. }
  2071. bRC = TRUE;
  2072. ProcessINSExit:
  2073. // 3/11/97 jmazner Olympus #1233, 252
  2074. // if no 3rd exe, and this instance is part of a signup process and
  2075. // SERVERLESS flag is not set for IEAK, then delete the .ins file
  2076. if ( (fSignup) &&
  2077. (('\0' == pDynShare->szRunExecutable[0]) || (ERROR_SUCCESS != dwRet)) )
  2078. {
  2079. if (1 != GetPrivateProfileInt(
  2080. cszBrandingSection,
  2081. cszBrandingServerless,
  2082. 0,
  2083. lpszFile))
  2084. {
  2085. DeleteFileKindaLikeThisOne(lpszFile);
  2086. }
  2087. else
  2088. {
  2089. Dprintf("ISIGN32: Preserving .ins file for SERVERLESS flag\n");
  2090. }
  2091. }
  2092. return bRC;
  2093. }
  2094. static BOOL RequiresLogon(LPCTSTR lpszFile)
  2095. {
  2096. TCHAR szTemp[10];
  2097. GetPrivateProfileString(cszUserSection,
  2098. cszRequiresLogon,
  2099. cszNo,
  2100. szTemp,
  2101. 10,
  2102. lpszFile);
  2103. return (!lstrcmpi(szTemp, cszYes));
  2104. }
  2105. static UINT GetBrandingFlags(LPCTSTR lpszFile)
  2106. {
  2107. return GetPrivateProfileInt(
  2108. cszBrandingSection,
  2109. cszBrandingFlags,
  2110. BRAND_DEFAULT,
  2111. lpszFile);
  2112. }
  2113. //+----------------------------------------------------------------------------
  2114. //
  2115. // Function: SetGlobalOffline
  2116. //
  2117. // Synopsis: Set IE4 into online or offline mode
  2118. //
  2119. // Arguments: fOffline - TRUE to set OFFLINE mode
  2120. // FALSE to set ONLINE mode
  2121. //
  2122. // Returns: none
  2123. //
  2124. // History: 7/15/97 ChrisK imported from DarrenMi's email
  2125. //
  2126. //-----------------------------------------------------------------------------
  2127. typedef struct {
  2128. DWORD dwConnectedState;
  2129. DWORD dwFlags;
  2130. } INTERNET_CONNECTED_INFO, * LPINTERNET_CONNECTED_INFO;
  2131. //
  2132. // the following can be indicated in a state change notification:
  2133. //
  2134. #define INTERNET_STATE_CONNECTED 0x00000001 // connected state (mutually exclusive with disconnected)
  2135. #define INTERNET_STATE_DISCONNECTED 0x00000002 // disconnected from network
  2136. #define INTERNET_STATE_DISCONNECTED_BY_USER 0x00000010 // disconnected by user request
  2137. #define INTERNET_STATE_IDLE 0x00000100 // no network requests being made (by Wininet)
  2138. #define INTERNET_STATE_BUSY 0x00000200 // network requests being made (by Wininet)
  2139. #define ISO_FORCE_DISCONNECTED 0x00000001
  2140. #define INTERNET_OPTION_CONNECTED_STATE 50
  2141. typedef BOOL (WINAPI *PFNSETINTERNETOPTIONA)(LPVOID, DWORD, LPVOID, DWORD);
  2142. void SetGlobalOffline(BOOL fOffline)
  2143. {
  2144. DebugOut("ISIGN32: SetGlobalOffline.\n");
  2145. INTERNET_CONNECTED_INFO ci;
  2146. HMODULE hMod = LoadLibrary(TEXT("wininet.dll"));
  2147. FARPROC fp = NULL;
  2148. BOOL bRC = FALSE;
  2149. ZeroMemory(&ci, sizeof(ci));
  2150. if (NULL == hMod)
  2151. {
  2152. Dprintf("ISIGN32: Wininet.dll did not load. Error:%d.\n",GetLastError());
  2153. goto InternetSetOptionExit;
  2154. }
  2155. #ifdef UNICODE
  2156. if (NULL == (fp = GetProcAddress(hMod,"InternetSetOptionW")))
  2157. #else
  2158. if (NULL == (fp = GetProcAddress(hMod,"InternetSetOptionA")))
  2159. #endif
  2160. {
  2161. Dprintf("ISIGN32: InternetSetOptionA did not load. Error:%d.\n",GetLastError());
  2162. goto InternetSetOptionExit;
  2163. }
  2164. if(fOffline) {
  2165. ci.dwConnectedState = INTERNET_STATE_DISCONNECTED_BY_USER;
  2166. ci.dwFlags = ISO_FORCE_DISCONNECTED;
  2167. } else {
  2168. ci.dwConnectedState = INTERNET_STATE_CONNECTED;
  2169. }
  2170. DebugOut("ISIGN32: Setting offline\\online.\n");
  2171. bRC = ((PFNSETINTERNETOPTIONA)fp) (NULL, INTERNET_OPTION_CONNECTED_STATE, &ci, sizeof(ci));
  2172. #ifdef DEBUG
  2173. if (bRC)
  2174. {
  2175. DebugOut("ISIGN32: GetGlobalOffline returned TRUE.\n");
  2176. }
  2177. else
  2178. {
  2179. DebugOut("ISIGN32: GetGlobalOffline returned FALSE.\n");
  2180. }
  2181. #endif
  2182. InternetSetOptionExit:
  2183. DebugOut("ISIGN32: Exit SetGlobalOffline.\n");
  2184. return;
  2185. }
  2186. BOOL ProcessISP(HWND hwnd, LPCTSTR lpszFile)
  2187. {
  2188. TCHAR szSignupURL[MAX_URL + 1];
  2189. #if !defined(WIN16)
  2190. HKEY hKey;
  2191. GATHEREDINFO gi;
  2192. #endif //!WIN16
  2193. //
  2194. // 4/30/97 jmazner Olympus 3969
  2195. // For security reasons, do not process the [Custom] Run= command in an .isp
  2196. // file!
  2197. //
  2198. #if DEBUG
  2199. if (GetPrivateProfileString(
  2200. cszEntrySection,
  2201. cszRun,
  2202. szNull,
  2203. pDynShare->szRunExecutable,
  2204. SIZEOF_TCHAR_BUFFER(pDynShare->szRunExecutable),
  2205. lpszFile) != 0)
  2206. {
  2207. //
  2208. // 4/30/97 jmazner Olympus 3969
  2209. // For security reasons, do not process the [Custom] Run= command in an .isp
  2210. // file!
  2211. //
  2212. lstrcpyn(pDynShare->szRunExecutable, TEXT("\0"), 1);
  2213. ClearExitFlags(SXF_RUNEXECUTABLE | SXF_WAITEXECUTABLE);
  2214. Dprintf("ISIGN32: The file %s has the [Custom] Run= command!", lpszFile);
  2215. MessageBox( hwnd,
  2216. TEXT("The .isp file you're running contains the [Custom] Run= command.\n\nThis functionality has been removed."),
  2217. TEXT("DEBUG information msgBox -- this is NOT a bug"),
  2218. MB_OK );
  2219. /*****
  2220. dwExitFlags |= (SXF_RUNEXECUTABLE | SXF_WAITEXECUTABLE);
  2221. GetPrivateProfileString(cszEntrySection,
  2222. cszArgument,
  2223. szNull,
  2224. szRunArgument,
  2225. sizeof(szRunArgument),
  2226. lpszFile);
  2227. PostMessage(hwnd, WM_CLOSE, 0, 0);
  2228. return FALSE;
  2229. ******/
  2230. }
  2231. #endif
  2232. #if !defined(WIN16)
  2233. // Make sure the isp file exists before setting up stack.
  2234. if (0xFFFFFFFF == GetFileAttributes(lpszFile))
  2235. {
  2236. DWORD dwFileErr = GetLastError();
  2237. Dprintf("ISIGN32: ProcessISP couldn't GetAttrib for %s, error = %d",
  2238. lpszFile, dwFileErr);
  2239. if( ERROR_FILE_NOT_FOUND == dwFileErr )
  2240. {
  2241. ErrorMsg1(hwnd, IDS_INVALIDCMDLINE, lpszFile);
  2242. }
  2243. ErrorMsg(hwnd, IDS_BADSIGNUPFILE);
  2244. return FALSE;
  2245. }
  2246. #endif
  2247. // Register file extensions if not already registered
  2248. // Configure stack if not already configured.
  2249. // This may required a restart. If so warn the user.
  2250. // We may want to check to see if the user is calling
  2251. // us again without restarting after configuring the stack.
  2252. #ifdef SETUPSTACK
  2253. if (!TestControlFlags(SCF_SYSTEMCONFIGURED))
  2254. {
  2255. DWORD dwRet;
  2256. BOOL fNeedsRestart = FALSE;
  2257. //
  2258. // ChrisK Olympus 4756 5/25/97
  2259. // Do not display busy animation on Win95
  2260. //
  2261. dwRet = lpfnInetConfigSystem(
  2262. hwnd,
  2263. INETCFG_INSTALLRNA |
  2264. INETCFG_INSTALLTCP |
  2265. INETCFG_INSTALLMODEM |
  2266. (IsNT()?INETCFG_SHOWBUSYANIMATION:0) |
  2267. INETCFG_REMOVEIFSHARINGBOUND,
  2268. &fNeedsRestart);
  2269. if (ERROR_SUCCESS == dwRet)
  2270. {
  2271. SetControlFlags(SCF_SYSTEMCONFIGURED);
  2272. InstallScripter();
  2273. if (fNeedsRestart)
  2274. {
  2275. if (PromptRestartNow(hwnd))
  2276. {
  2277. SetRunOnce(lpszFile);
  2278. // 3/13/97 jmazner Olympus #1682
  2279. RestoreSecurityPatch();
  2280. FGetSystemShutdownPrivledge();
  2281. ExitWindowsEx(EWX_REBOOT, 0);
  2282. //
  2283. // We will wait for the System to release all
  2284. // resources, 5 minutes should be more than
  2285. // enough for this
  2286. // - MKarki (4/22/97) - MKarki
  2287. // Fix for Bug #3109
  2288. //
  2289. // 7/8/97 jmazner Olympus 4212
  2290. // No, sleeping for 5 minutes turns out not to be such a good idea.
  2291. //Sleep (300000);
  2292. //
  2293. }
  2294. return FALSE;
  2295. }
  2296. }
  2297. else
  2298. {
  2299. ErrorMsg(hwnd, IDS_INSTALLFAILED);
  2300. return FALSE;
  2301. }
  2302. }
  2303. if (!VerifyRasServicesRunning(hwnd))
  2304. return FALSE;
  2305. #endif
  2306. /******** 11/5/96 jmazner Normandy #8717
  2307. // if the original autodial settings have not been saved
  2308. SaveAutoDial();
  2309. dwExitFlags |= SXF_RESTOREAUTODIAL;
  2310. ********/
  2311. // kill the old connection
  2312. KillConnection();
  2313. // Create a new connectoid and set the autodial
  2314. DWORD dwRC;
  2315. dwRC = CreateConnection(lpszFile);
  2316. if (ERROR_SUCCESS != dwRC)
  2317. {
  2318. //
  2319. // ChrisK Olympus 6083 6/10/97
  2320. // If the user canceled, we have already acknowledged it.
  2321. //
  2322. if (ERROR_CANCELLED != dwRC)
  2323. {
  2324. ErrorMsg(hwnd, IDS_BADSIGNUPFILE);
  2325. }
  2326. return FALSE;
  2327. }
  2328. #ifndef WIN16
  2329. //
  2330. // Dial connectoid
  2331. //
  2332. if (ERROR_USERNEXT != DialConnection(lpszFile))
  2333. {
  2334. SetControlFlags(SCF_BROWSERLAUNCHED);
  2335. KillBrowser();
  2336. return FALSE;
  2337. }
  2338. lstrcpyn(
  2339. pDynShare->szISPFile,
  2340. lpszFile,
  2341. SIZEOF_TCHAR_BUFFER(pDynShare->szISPFile));
  2342. //
  2343. // Tell IE that it is OK to make a connection to the Internet and do not
  2344. // display the dialog asking if the user wants to go online.
  2345. //
  2346. SetGlobalOffline(FALSE);
  2347. #endif
  2348. // Get the URL that we need for signup
  2349. GetURL(lpszFile,
  2350. cszSignupURL,
  2351. szSignupURL,
  2352. MAX_URL + 1);
  2353. #ifdef WIN32
  2354. if (RequiresLogon(lpszFile))
  2355. {
  2356. SetControlFlags(SCF_LOGONREQUIRED);
  2357. if (ERROR_CANCELLED == SignupLogon(hwnd))
  2358. {
  2359. InfoMsg(NULL, IDS_SIGNUPCANCELLED);
  2360. PostMessage(pDynShare->hwndMain, WM_CLOSE, 0, 0);
  2361. return FALSE;
  2362. }
  2363. }
  2364. // OSR 10582
  2365. // We need to pass the name of the ISP file to the autodialer, so that the
  2366. // autodialer can extract the password that may be included
  2367. ZeroMemory(&gi,sizeof(gi));
  2368. hKey = NULL;
  2369. lstrcpyn(gi.szISPFile,lpszFile,MAX_PATH);
  2370. if (ERROR_SUCCESS == RegCreateKey(HKEY_LOCAL_MACHINE,
  2371. ISIGNUP_KEY,&hKey))
  2372. {
  2373. RegSetValueEx(hKey,TEXT("UserInfo"),0,REG_BINARY,(LPBYTE)&gi,sizeof(gi));
  2374. RegCloseKey(hKey);
  2375. hKey = NULL;
  2376. }
  2377. #endif
  2378. pDynShare->dwBrandFlags = GetBrandingFlags(lpszFile);
  2379. return (ExecBrowser(hwnd, szSignupURL));
  2380. }
  2381. //+---------------------------------------------------------------------------
  2382. //
  2383. // Function: WaitForConnectionTermination
  2384. //
  2385. // Synopsis: Waits for the given Ras Connection to complete termination
  2386. //
  2387. // Arguments: hConn - Connection handle of the RAS connection being terminated
  2388. //
  2389. // Returns: TRUE if wait till connection termination was successful
  2390. // FALSE otherwise
  2391. //
  2392. // History: 6/30/96 VetriV Created
  2393. // 8/29/96 VetriV Added code to sleep for a second on WIN 3.1
  2394. //----------------------------------------------------------------------------
  2395. // Normandy #12547 Chrisk 12-18-96
  2396. #define MAX_TIME_FOR_TERMINATION 5
  2397. BOOL WaitForConnectionTermination(HRASCONN hConn)
  2398. {
  2399. RASCONNSTATUS RasConnStatus;
  2400. DWORD dwRetCode;
  2401. // Normandy #12547 Chrisk 12-18-96
  2402. #if !defined(WIN16)
  2403. INT cnt = 0;
  2404. #endif
  2405. //
  2406. // Get Connection status for hConn in a loop until
  2407. // RasGetConnectStatus returns ERROR_INVALID_HANDLE
  2408. //
  2409. do
  2410. {
  2411. //
  2412. // Intialize RASCONNSTATUS struct
  2413. // GetConnectStatus API will fail if dwSize is not set correctly!!
  2414. //
  2415. ZeroMemory(&RasConnStatus, sizeof(RASCONNSTATUS));
  2416. RasConnStatus.dwSize = sizeof(RASCONNSTATUS);
  2417. //
  2418. // Sleep for a second and then get the connection status
  2419. //
  2420. #if defined(WIN16)
  2421. time_t StartTime = time(NULL);
  2422. do
  2423. {
  2424. MSG msg;
  2425. if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  2426. {
  2427. TranslateMessage(&msg);
  2428. DispatchMessage(&msg);
  2429. }
  2430. //
  2431. // Check if we have waited atleast 1 second and less than 2 seconds
  2432. //
  2433. }
  2434. while ((time(NULL) - StartTime) <= 1);
  2435. #else
  2436. Sleep(1000L);
  2437. // Normandy #12547 Chrisk 12-18-96
  2438. cnt++;
  2439. #endif
  2440. if (NULL == lpfnRasGetConnectStatus)
  2441. return FALSE;
  2442. dwRetCode = lpfnRasGetConnectStatus(hConn, &RasConnStatus);
  2443. if (0 != dwRetCode)
  2444. return FALSE;
  2445. #if defined(WIN16)
  2446. } while (RASCS_Disconnected != RasConnStatus.rasconnstate);
  2447. #else
  2448. // Normandy #12547 Chrisk 12-18-96
  2449. } while ((ERROR_INVALID_HANDLE != RasConnStatus.dwError) && (cnt < MAX_TIME_FOR_TERMINATION));
  2450. #endif
  2451. return TRUE;
  2452. }
  2453. BOOL ProcessHTML(HWND hwnd, LPCTSTR lpszFile)
  2454. {
  2455. BOOL fNeedsRestart = FALSE;
  2456. #if SETUPSTACK
  2457. DWORD dwRet;
  2458. if (!TestControlFlags(SCF_SYSTEMCONFIGURED))
  2459. {
  2460. //
  2461. // ChrisK Olympus 4756 5/25/97
  2462. // Do not display busy animation on Win95
  2463. //
  2464. dwRet = lpfnInetConfigSystem(
  2465. hwnd,
  2466. INETCFG_INSTALLRNA |
  2467. INETCFG_INSTALLTCP |
  2468. INETCFG_INSTALLMODEM |
  2469. (IsNT()?INETCFG_SHOWBUSYANIMATION:0) |
  2470. INETCFG_REMOVEIFSHARINGBOUND,
  2471. &fNeedsRestart);
  2472. if (ERROR_SUCCESS == dwRet)
  2473. {
  2474. SetControlFlags(SCF_SYSTEMCONFIGURED);
  2475. InstallScripter();
  2476. if (fNeedsRestart)
  2477. {
  2478. if (PromptRestart(hwnd))
  2479. {
  2480. SetRunOnce(lpszFile);
  2481. // 3/13/97 jmazner Olympus #1682
  2482. RestoreSecurityPatch();
  2483. FGetSystemShutdownPrivledge();
  2484. ExitWindowsEx(EWX_REBOOT, 0);
  2485. //
  2486. // We will wait for the System to release all
  2487. // resources, 5 minutes should be more than
  2488. // enough for this
  2489. // - MKarki (4/22/97) - MKarki
  2490. // Fix for Bug #3109
  2491. //
  2492. // 7/8/97 jmazner Olympus 4212
  2493. // No, sleeping for 5 minutes turns out not to be such a good idea.
  2494. //Sleep (300000);
  2495. //
  2496. }
  2497. return FALSE;
  2498. }
  2499. }
  2500. else
  2501. {
  2502. ErrorMsg(hwnd, IDS_INSTALLFAILED);
  2503. return FALSE;
  2504. }
  2505. }
  2506. if (!VerifyRasServicesRunning(hwnd))
  2507. return FALSE;
  2508. #endif
  2509. return (ExecBrowser(hwnd, lpszFile));
  2510. }
  2511. #ifdef WIN32
  2512. DWORD RunExecutable(BOOL fWait)
  2513. {
  2514. DWORD dwRet;
  2515. SHELLEXECUTEINFO sei;
  2516. sei.cbSize = sizeof(sei);
  2517. sei.fMask = SEE_MASK_NOCLOSEPROCESS;
  2518. sei.hwnd = NULL;
  2519. sei.lpVerb = cszOpen;
  2520. sei.lpFile = pDynShare->szRunExecutable;
  2521. sei.lpParameters = pDynShare->szRunArgument;
  2522. sei.lpDirectory = NULL;
  2523. sei.nShow = SW_SHOWNORMAL;
  2524. sei.hInstApp = NULL;
  2525. // Optional members
  2526. sei.hProcess = NULL;
  2527. if (ShellExecuteEx(&sei))
  2528. {
  2529. if (fWait)
  2530. {
  2531. // WaitForSingleObject(sei.hProcess, INFINITE);
  2532. DWORD iWaitResult = 0;
  2533. // wait for event or msgs. Dispatch msgs. Exit when event is signalled.
  2534. while((iWaitResult=MsgWaitForMultipleObjects(1, &sei.hProcess, FALSE, INFINITE, QS_ALLINPUT))==(WAIT_OBJECT_0 + 1))
  2535. {
  2536. MSG msg ;
  2537. // read all of the messages in this next loop
  2538. // removing each message as we read it
  2539. while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  2540. {
  2541. // how to handle quit message?
  2542. if (msg.message == WM_QUIT)
  2543. {
  2544. CloseHandle(sei.hProcess);
  2545. return NO_ERROR;
  2546. }
  2547. else
  2548. DispatchMessage(&msg);
  2549. }
  2550. }
  2551. }
  2552. CloseHandle(sei.hProcess);
  2553. dwRet = ERROR_SUCCESS;
  2554. }
  2555. else
  2556. {
  2557. dwRet = GetLastError();
  2558. }
  2559. return dwRet;
  2560. }
  2561. #else
  2562. DWORD RunExecutable(BOOL fWait)
  2563. {
  2564. DWORD dwRet;
  2565. dwRet = (DWORD)ShellExecute(
  2566. NULL,
  2567. cszOpen,
  2568. pDynShare->szRunExecutable,
  2569. pDynShare->szRunArgument,
  2570. NULL,
  2571. SW_SHOWNORMAL);
  2572. if (32 < dwRet)
  2573. {
  2574. dwRet = ERROR_SUCCESS;
  2575. }
  2576. else if (0 == dwRet)
  2577. {
  2578. dwRet = ERROR_OUTOFMEMORY;
  2579. }
  2580. return dwRet;
  2581. }
  2582. #endif
  2583. void SaveAutoDial(void)
  2584. {
  2585. // if the original autodial settings have not been saved
  2586. if (!TestControlFlags(SCF_AUTODIALSAVED))
  2587. {
  2588. // save the current autodial settings
  2589. BOOL fEnabled;
  2590. lpfnInetGetAutodial(
  2591. &fEnabled,
  2592. pDynShare->szAutodialConnection,
  2593. sizeof(pDynShare->szAutodialConnection));
  2594. if (fEnabled)
  2595. {
  2596. SetControlFlags(SCF_AUTODIALENABLED);
  2597. }
  2598. else
  2599. {
  2600. ClearControlFlags(SCF_AUTODIALENABLED);
  2601. }
  2602. #ifdef WIN32
  2603. lpfnInetGetProxy(
  2604. &fEnabled,
  2605. NULL, 0,
  2606. NULL, 0);
  2607. if (fEnabled)
  2608. {
  2609. SetControlFlags(SCF_PROXYENABLED);
  2610. }
  2611. else
  2612. {
  2613. ClearControlFlags(SCF_PROXYENABLED);
  2614. }
  2615. // turn off proxy
  2616. lpfnInetSetProxy(FALSE, NULL, NULL);
  2617. #endif
  2618. SetControlFlags(SCF_AUTODIALSAVED);
  2619. }
  2620. }
  2621. void RestoreAutoDial(void)
  2622. {
  2623. if (TestControlFlags(SCF_AUTODIALSAVED))
  2624. {
  2625. // restore original autodial settings
  2626. lpfnInetSetAutodial(
  2627. TestControlFlags(SCF_AUTODIALENABLED),
  2628. pDynShare->szAutodialConnection);
  2629. #ifdef WIN32
  2630. lpfnInetSetProxy(TestControlFlags(SCF_PROXYENABLED), NULL, NULL);
  2631. #endif
  2632. ClearControlFlags(SCF_AUTODIALSAVED);
  2633. }
  2634. }
  2635. DWORD CreateConnection(LPCTSTR lpszFile)
  2636. {
  2637. DWORD dwRet;
  2638. LPICONNECTION pConn;
  2639. // Allocate a buffer for connection object
  2640. //
  2641. pConn = (LPICONNECTION)LocalAlloc(LPTR, sizeof(ICONNECTION));
  2642. if (NULL == pConn)
  2643. {
  2644. return ERROR_OUTOFMEMORY;
  2645. };
  2646. dwRet = ImportConnection(lpszFile, pConn);
  2647. if (ERROR_SUCCESS == dwRet)
  2648. {
  2649. #ifdef WIN32
  2650. if ((0 == *pConn->RasEntry.szAutodialDll) ||
  2651. (0 == *pConn->RasEntry.szAutodialFunc))
  2652. {
  2653. lstrcpy(pConn->RasEntry.szAutodialDll, TEXT("ICWDIAL.dll"));
  2654. lstrcpy(pConn->RasEntry.szAutodialFunc, TEXT("AutoDialHandler"));
  2655. // save the password in case it doesn't get cached
  2656. lstrcpyn(
  2657. pDynShare->szPassword,
  2658. pConn->szPassword,
  2659. SIZEOF_TCHAR_BUFFER(pDynShare->szPassword));
  2660. }
  2661. #endif
  2662. dwRet = lpfnInetConfigClient(
  2663. NULL,
  2664. NULL,
  2665. pConn->szEntryName,
  2666. &pConn->RasEntry,
  2667. pConn->szUserName,
  2668. pConn->szPassword,
  2669. NULL,
  2670. NULL,
  2671. INETCFG_SETASAUTODIAL |
  2672. INETCFG_OVERWRITEENTRY |
  2673. INETCFG_TEMPPHONEBOOKENTRY,
  2674. NULL);
  2675. #if !defined(WIN16)
  2676. LclSetEntryScriptPatch(pConn->RasEntry.szScript,pConn->szEntryName);
  2677. #endif
  2678. if (ERROR_SUCCESS == dwRet)
  2679. {
  2680. lstrcpyn(
  2681. pDynShare->szSignupConnection,
  2682. pConn->szEntryName,
  2683. RAS_MaxEntryName + 1);
  2684. }
  2685. }
  2686. LocalFree(pConn);
  2687. return dwRet;
  2688. }
  2689. DWORD DeleteConnection(void)
  2690. {
  2691. if (*(pDynShare->szSignupConnection))
  2692. {
  2693. // delete the signup entry
  2694. lpfnRasDeleteEntry(NULL, pDynShare->szSignupConnection);
  2695. pDynShare->szSignupConnection[0] = (TCHAR)'\0';
  2696. }
  2697. return ERROR_SUCCESS;
  2698. }
  2699. //+----------------------------------------------------------------------------
  2700. // Function: KillThisConnection
  2701. //
  2702. // Synopsis: Disconnects the connectoid named in lpzConnectoid and waits
  2703. // until the connection is completely torn down. Then the
  2704. // connectoid is deleted.
  2705. //
  2706. // Arguments: lpzConnectoid - name of connection to disconnect
  2707. //
  2708. // Returns: (return) - win32 error code
  2709. //
  2710. // History: 4/27/97 Chrisk Created
  2711. //-----------------------------------------------------------------------------
  2712. DWORD KillThisConnection(LPTSTR lpzConnectoid)
  2713. {
  2714. LPRASCONN pRasConn=NULL;
  2715. DWORD dwSize = sizeof(RASCONN);
  2716. DWORD dwSizeRasConn = dwSize;
  2717. DWORD dwRet = ERROR_SUCCESS;
  2718. if ('\0' == *lpzConnectoid)
  2719. return ERROR_NO_CONNECTION;
  2720. // OK were ready for Rna now
  2721. if (!LoadRnaFunctions(pDynShare->hwndMain))
  2722. return ERROR_NO_CONNECTION;
  2723. if ((pRasConn = (LPRASCONN)LocalAlloc(LPTR, (int)dwSize)) == NULL)
  2724. return ERROR_NOT_ENOUGH_MEMORY;
  2725. pRasConn->dwSize = dwSize;
  2726. dwRet = lpfnRasEnumConnections(pRasConn, &dwSize, &dwSizeRasConn);
  2727. if (ERROR_SUCCESS != dwRet)
  2728. {
  2729. dwRet = ERROR_NO_CONNECTION;
  2730. goto KillThisConnectionExit;
  2731. }
  2732. // check entry name to see if
  2733. // its ours
  2734. #ifndef WIN32
  2735. //
  2736. // Workaround for WIN16 RAS Bug - it sometimes truncates
  2737. // the name of the connectoid
  2738. //
  2739. if (!strncmp(pRasConn->szEntryName, lpzConnectoid,
  2740. lstrlen(pRasConn->szEntryName)))
  2741. #else
  2742. if (!lstrcmp(pRasConn->szEntryName, lpzConnectoid))
  2743. #endif
  2744. {
  2745. // Normandy 12642 ChrisK 12-18-9
  2746. // We don't want the user to reconnect here.
  2747. #if !defined(WIN16)
  2748. SetControlFlags(SCF_HANGUPEXPECTED);
  2749. #endif
  2750. // then hangup
  2751. lpfnRasHangUp(pRasConn->hrasconn);
  2752. WaitForConnectionTermination(pRasConn->hrasconn);
  2753. }
  2754. // delete the signup entry
  2755. lpfnRasDeleteEntry(NULL, lpzConnectoid);
  2756. KillThisConnectionExit:
  2757. if (pRasConn)
  2758. LocalFree(pRasConn);
  2759. return dwRet;
  2760. }
  2761. //+----------------------------------------------------------------------------
  2762. // Function: KillConnection
  2763. //
  2764. // Synopsis: Calls KillThisConnection and passes in the name of the signup
  2765. // connection that is saved in szSignupConnection
  2766. //
  2767. // Arguments: none
  2768. //
  2769. // Returns: (return) - win32 error code
  2770. //
  2771. // History: 4/27/97 Chrisk modified to call KillThisConnection
  2772. //-----------------------------------------------------------------------------
  2773. DWORD KillConnection(void)
  2774. {
  2775. DWORD dwRet;
  2776. dwRet = KillThisConnection(pDynShare->szSignupConnection);
  2777. #if defined(WIN16)
  2778. ShutDownIEDial(pDynShare->hwndMain);
  2779. #endif // WIN16
  2780. pDynShare->szSignupConnection[0] = (TCHAR)'\0';
  2781. UnloadRnaFunctions();
  2782. return dwRet;
  2783. }
  2784. BOOL ExecBrowser(HWND hwnd, LPCTSTR lpszURL)
  2785. {
  2786. HRESULT hresult;
  2787. TCHAR szFullURL[MAX_URL + 1];
  2788. if (!FixUpURL(lpszURL, szFullURL, MAX_URL + 1))
  2789. {
  2790. //
  2791. // ChrisK Olympus 4002 5/26/97
  2792. // If the URL is empty, this error message doesn't make
  2793. // a lot of sense. So use a different message.
  2794. //
  2795. if (lstrlen(lpszURL))
  2796. {
  2797. ErrorMsg1(hwnd, IDS_INVALIDURL, lpszURL);
  2798. }
  2799. else
  2800. {
  2801. ErrorMsg(hwnd, IDS_INVALIDNOURL);
  2802. }
  2803. return FALSE;
  2804. }
  2805. if (TestControlFlags(SCF_BROWSERLAUNCHED))
  2806. {
  2807. #ifdef WIN32
  2808. // No assert macro defined for isign32????
  2809. //Assert(g_iwbapp);
  2810. if( !g_iwbapp )
  2811. {
  2812. DebugOut("ISIGNUP: fatal err, fBrowserLaunched disagrees with g_iwbapp\n");
  2813. return( FALSE );
  2814. }
  2815. // TODO find out what the result codes should be!
  2816. hresult = IENavigate( szFullURL );
  2817. if( FAILED(hresult) )
  2818. {
  2819. DebugOut("ISIGNUP: second Navigate _failed_, hresult was failure\n");
  2820. return FALSE;
  2821. }
  2822. else
  2823. {
  2824. DebugOut("ISIGNUP: second Navigate success!, hresult was success\n");
  2825. }
  2826. //g_iwbapp->put_Visible( TRUE );
  2827. #else
  2828. DDEInit(ghInstance);
  2829. OpenURL(szFullURL);
  2830. DDEClose();
  2831. #endif
  2832. }
  2833. else
  2834. {
  2835. TCHAR szTemp[MAX_URL + sizeof(cszKioskMode)/sizeof(TCHAR)];
  2836. HWND hwndTemp;
  2837. HANDLE hBrowser;
  2838. #ifndef WIN32
  2839. time_t start;
  2840. #endif
  2841. if (NULL != pDynShare->hwndLaunch)
  2842. {
  2843. ShowWindow(pDynShare->hwndLaunch, SW_SHOW);
  2844. UpdateWindow(pDynShare->hwndLaunch);
  2845. }
  2846. // for OLE Autmoation we only want to pass in the URL (no "-k") and then call FullScreen,
  2847. // so only -k for win16
  2848. #ifndef WIN32
  2849. lstrcpy(szTemp, cszKioskMode);
  2850. lstrcat(szTemp, szFullURL);
  2851. // no point in doing this for IE4, which may have lots of windows already open
  2852. hwndTemp = FindBrowser();
  2853. if (NULL != hwndTemp)
  2854. {
  2855. PostMessage(hwndTemp, WM_CLOSE, 0, 0L);
  2856. }
  2857. #endif
  2858. #ifdef WIN32
  2859. // 8/19/96 jmazner Normandy #4571
  2860. // Check to ensure that the right version IE is installed before trying to exec it
  2861. /******** Normandy #10293, do this verification before going through the whole
  2862. dialing process
  2863. if ( !IEInstalled() )
  2864. {
  2865. ErrorMsg( hwnd, IDS_MISSINGIE );
  2866. return(FALSE);
  2867. }
  2868. DWORD dwVerMS, dwVerLS;
  2869. if( !GetAppVersion( &dwVerMS, &dwVerLS,IE_PATHKEY ) )
  2870. return (FALSE);
  2871. if( !( (dwVerMS >= IE_MINIMUM_VERSIONMS) && (dwVerLS >= IE_MINIMUM_VERSIONLS) ) )
  2872. {
  2873. Dprintf("ISIGN32: user has IE version %d.%d.%d.%d; min ver is %d.%d.%d.%d\n",
  2874. HIWORD(dwVerMS), LOWORD(dwVerMS), HIWORD(dwVerLS), LOWORD(dwVerLS),
  2875. HIWORD(IE_MINIMUM_VERSIONMS),LOWORD(IE_MINIMUM_VERSIONMS),
  2876. HIWORD(IE_MINIMUM_VERSIONLS),LOWORD(IE_MINIMUM_VERSIONLS));
  2877. ErrorMsg1( hwnd, IDS_IELOWVERSION, IE_MINIMUM_VERSION_HUMAN_READABLE );
  2878. return(FALSE);
  2879. }
  2880. ***********/
  2881. if (FTurnOffBrowserDefaultChecking())
  2882. {
  2883. SetExitFlags(SXF_RESTOREDEFCHECK);
  2884. }
  2885. /*
  2886. hBrowser = ShellExecute(
  2887. NULL,
  2888. cszOpen,
  2889. cszBrowser,
  2890. szTemp,
  2891. NULL,
  2892. SW_SHOWNORMAL);
  2893. */
  2894. // 1/20/97 jmazner Normandy #13454
  2895. // need make sure the ICW completed reg key is set before trying
  2896. // to browse to an html page with IE
  2897. DWORD dwICWCompleted = 0;
  2898. GetICWCompleted(&dwICWCompleted);
  2899. if( 1 != dwICWCompleted )
  2900. {
  2901. SetControlFlags(SCF_ICWCOMPLETEDKEYRESETED);
  2902. SetICWCompleted( 1 );
  2903. }
  2904. hresult = InitOle();
  2905. if( FAILED(hresult) )
  2906. {
  2907. DebugOut("ISIGNUP: InitOle failed\n");
  2908. ErrorMsg(hwnd, IDS_LAUNCHFAILED);
  2909. return FALSE;
  2910. }
  2911. SetControlFlags(SCF_BROWSERLAUNCHED);
  2912. //
  2913. // we want to hook up the event sink before doing that first navigate!
  2914. //
  2915. /******************* SINK code starts here ***********/
  2916. if (!g_iwbapp)
  2917. return (NULL);
  2918. g_pMySink = new CDExplorerEvents;
  2919. //
  2920. // 5/10/97 ChrisK Windows NT Bug 82032
  2921. //
  2922. g_pMySink->AddRef();
  2923. if ( !g_pMySink )
  2924. {
  2925. DebugOut("Unable to allocate g_pMySink\r\n");
  2926. return FALSE;
  2927. }
  2928. g_pCP = GetConnectionPoint();
  2929. if ( !g_pCP )
  2930. {
  2931. DebugOut("Unable to GetConnectionPoint\r\n");
  2932. return FALSE;
  2933. }
  2934. hresult = g_pCP->Advise(g_pMySink, &(g_pMySink->m_dwCookie));
  2935. if ( FAILED(hresult) )
  2936. {
  2937. DebugOut("Unable to Advise for IConnectionPointContainter:IWebBrowserApp\r\n");
  2938. return FALSE;
  2939. }
  2940. /*************** SINK code ends here *****************/
  2941. // TODO figure out result codes
  2942. hresult = IENavigate( szFullURL );
  2943. if( FAILED(hresult) )
  2944. {
  2945. DebugOut("ISIGNUP: first Navigate _failed_, hresult was failure\n");
  2946. ErrorMsg(hwnd, IDS_LAUNCHFAILED);
  2947. return FALSE;
  2948. }
  2949. else
  2950. {
  2951. DebugOut("ISIGNUP: first Navigate success!, hresult was success\n");
  2952. }
  2953. g_iwbapp->put_FullScreen( TRUE );
  2954. g_iwbapp->put_Visible( TRUE );
  2955. // IE 4 for win95 isn't bringing us up as the foreground window!
  2956. g_iwbapp->get_HWND( (LONG_PTR *)&(pDynShare->hwndBrowser) );
  2957. SetForegroundWindow( pDynShare->hwndBrowser );
  2958. #else
  2959. start = time(NULL);
  2960. if (NULL != hwndTemp)
  2961. {
  2962. MSG msg;
  2963. SetTimer(hwnd, 0, 1000, NULL);
  2964. DebugOut("ISIGNUP: Timer message loop\n");
  2965. while (GetMessage (&msg, NULL, 0, 0))
  2966. {
  2967. if (WM_TIMER == msg.message)
  2968. {
  2969. DebugOut("ISIGNUP: Got timer message\n");
  2970. if (NULL == FindBrowser())
  2971. {
  2972. DebugOut("ISIGNUP: Browser is gone\n");
  2973. break;
  2974. }
  2975. }
  2976. TranslateMessage (&msg) ;
  2977. DispatchMessage (&msg) ;
  2978. }
  2979. KillTimer(hwnd, 0);
  2980. }
  2981. while (((hBrowser = ShellExecute(
  2982. NULL,
  2983. cszOpen,
  2984. cszBrowser,
  2985. szTemp,
  2986. NULL,
  2987. SW_SHOWNORMAL)) == 16) && ((time(NULL) - start) < 180))
  2988. {
  2989. DebugOut("ISIGNUP: Yielding\n");
  2990. Yield();
  2991. }
  2992. #endif
  2993. DebugOut("ISIGNUP: I am back!!\n");
  2994. if (NULL != pDynShare->hwndLaunch)
  2995. {
  2996. ShowWindow(pDynShare->hwndLaunch, SW_HIDE);
  2997. }
  2998. #ifdef WIN16
  2999. if (hBrowser <= (HANDLE)32)
  3000. {
  3001. ErrorMsg(hwnd, IDS_LAUNCHFAILED);
  3002. return FALSE;
  3003. }
  3004. #endif
  3005. SetControlFlags(SCF_BROWSERLAUNCHED);
  3006. }
  3007. return TRUE;
  3008. }
  3009. //+----------------------------------------------------------------------------
  3010. //
  3011. // Function: IEInstalled
  3012. //
  3013. // Synopsis: Tests whether a version of Internet Explorer is installed via registry keys
  3014. //
  3015. // Arguments: None
  3016. //
  3017. // Returns: TRUE - Found the IE executable
  3018. // FALSE - No IE executable found
  3019. //
  3020. // History: jmazner Created 8/19/96 (as fix for Normandy #4571)
  3021. //
  3022. //-----------------------------------------------------------------------------
  3023. #if !defined(WIN16)
  3024. BOOL IEInstalled(void)
  3025. {
  3026. HRESULT hr;
  3027. HKEY hKey = 0;
  3028. HANDLE hFindResult;
  3029. TCHAR szIELocalPath[MAX_PATH + 1] = TEXT("");
  3030. DWORD dwPathSize;
  3031. WIN32_FIND_DATA foundData;
  3032. hr = RegOpenKeyEx(HKEY_LOCAL_MACHINE, IE_PATHKEY,0, KEY_READ, &hKey);
  3033. if (hr != ERROR_SUCCESS) return( FALSE );
  3034. dwPathSize = sizeof (szIELocalPath);
  3035. hr = RegQueryValueEx(hKey, NULL, NULL, NULL, (LPBYTE) szIELocalPath, &dwPathSize);
  3036. RegCloseKey( hKey );
  3037. if (hr != ERROR_SUCCESS) return( FALSE );
  3038. hFindResult = FindFirstFile( szIELocalPath, &foundData );
  3039. FindClose( hFindResult );
  3040. if (INVALID_HANDLE_VALUE == hFindResult) return( FALSE );
  3041. return(TRUE);
  3042. }
  3043. //+----------------------------------------------------------------------------
  3044. //
  3045. // Function: GetAppVersion
  3046. //
  3047. // Synopsis: Gets the major and minor version # of the installed copy of Internet Explorer
  3048. //
  3049. // Arguments: pdwVerNumMS - pointer to a DWORD;
  3050. // On succesful return, the top 16 bits will contain the major version number,
  3051. // and the lower 16 bits will contain the minor version number
  3052. // (this is the data in VS_FIXEDFILEINFO.dwProductVersionMS)
  3053. // pdwVerNumLS - pointer to a DWORD;
  3054. // On succesful return, the top 16 bits will contain the release number,
  3055. // and the lower 16 bits will contain the build number
  3056. // (this is the data in VS_FIXEDFILEINFO.dwProductVersionLS)
  3057. //
  3058. // Returns: TRUE - Success. *pdwVerNumMS and LS contains installed IE version number
  3059. // FALSE - Failure. *pdVerNumMS == *pdVerNumLS == 0
  3060. //
  3061. // History: jmazner Created 8/19/96 (as fix for Normandy #4571)
  3062. // jmazner updated to deal with release.build as well 10/11/96
  3063. //
  3064. //-----------------------------------------------------------------------------
  3065. BOOL GetAppVersion(PDWORD pdwVerNumMS, PDWORD pdwVerNumLS, LPTSTR lpszApp)
  3066. {
  3067. HRESULT hr;
  3068. HKEY hKey = 0;
  3069. LPVOID lpVerInfoBlock;
  3070. VS_FIXEDFILEINFO *lpTheVerInfo;
  3071. UINT uTheVerInfoSize;
  3072. DWORD dwVerInfoBlockSize, dwUnused, dwPathSize;
  3073. TCHAR szIELocalPath[MAX_PATH + 1] = TEXT("");
  3074. *pdwVerNumMS = 0;
  3075. *pdwVerNumLS = 0;
  3076. // get path to the IE executable
  3077. hr = RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpszApp,0, KEY_READ, &hKey);
  3078. if (hr != ERROR_SUCCESS) return( FALSE );
  3079. dwPathSize = sizeof (szIELocalPath);
  3080. hr = RegQueryValueEx(hKey, NULL, NULL, NULL, (LPBYTE) szIELocalPath, &dwPathSize);
  3081. RegCloseKey( hKey );
  3082. if (hr != ERROR_SUCCESS) return( FALSE );
  3083. // now go through the convoluted process of digging up the version info
  3084. dwVerInfoBlockSize = GetFileVersionInfoSize( szIELocalPath, &dwUnused );
  3085. if ( 0 == dwVerInfoBlockSize ) return( FALSE );
  3086. lpVerInfoBlock = GlobalAlloc( GPTR, dwVerInfoBlockSize );
  3087. if( NULL == lpVerInfoBlock ) return( FALSE );
  3088. if( !GetFileVersionInfo( szIELocalPath, NULL, dwVerInfoBlockSize, lpVerInfoBlock ) )
  3089. return( FALSE );
  3090. if( !VerQueryValue(lpVerInfoBlock, TEXT("\\"), (void **)&lpTheVerInfo, &uTheVerInfoSize) )
  3091. return( FALSE );
  3092. *pdwVerNumMS = lpTheVerInfo->dwProductVersionMS;
  3093. *pdwVerNumLS = lpTheVerInfo->dwProductVersionLS;
  3094. GlobalFree( lpVerInfoBlock );
  3095. return( TRUE );
  3096. }
  3097. #endif // !defined(WIN16)
  3098. HWND FindBrowser(void)
  3099. {
  3100. HWND hwnd;
  3101. if ((hwnd = FindWindow(szBrowserClass1, NULL)) == NULL)
  3102. {
  3103. if ((hwnd = FindWindow(szBrowserClass2, NULL)) == NULL)
  3104. {
  3105. if( (hwnd = FindWindow(szBrowserClass3, NULL)) == NULL )
  3106. {
  3107. hwnd = FindWindow(szBrowserClassIE4, NULL);
  3108. }
  3109. }
  3110. }
  3111. return hwnd;
  3112. }
  3113. void KillBrowser(void)
  3114. {
  3115. #ifdef WIN32
  3116. if( TestControlFlags(SCF_ICWCOMPLETEDKEYRESETED) )
  3117. {
  3118. SetICWCompleted( 0 );
  3119. }
  3120. if( g_iwbapp )
  3121. {
  3122. g_iwbapp->Quit();
  3123. }
  3124. KillOle();
  3125. return;
  3126. #else
  3127. // if we launched the browser
  3128. if (TestControlFlags(SCF_BROWSERLAUNCHED))
  3129. {
  3130. HWND hwndBrowser;
  3131. // find it and close it
  3132. hwndBrowser = FindBrowser();
  3133. if (NULL != hwndBrowser)
  3134. {
  3135. PostMessage(hwndBrowser, WM_CLOSE, 0, 0L);
  3136. }
  3137. SetControlFlags(SCF_BROWSERLAUNCHED);
  3138. }
  3139. #endif
  3140. }
  3141. DWORD ImportBrandingInfo(LPCTSTR lpszFile, LPCTSTR lpszConnectoidName)
  3142. {
  3143. TCHAR szPath[_MAX_PATH + 1];
  3144. GetWindowsDirectory(szPath, _MAX_PATH + 1);
  3145. // Load the branding library.
  3146. // Note: if we cannot load the library we just fail quietly and assume
  3147. // we cannot brand
  3148. if (LoadBrandingFunctions())
  3149. {
  3150. #ifdef WIN32
  3151. #ifdef UNICODE
  3152. CHAR szEntry[RAS_MaxEntryName];
  3153. CHAR szFile[_MAX_PATH + 1];
  3154. CHAR szAsiPath[_MAX_PATH + 1];
  3155. wcstombs(szEntry, lpszConnectoidName, RAS_MaxEntryName);
  3156. wcstombs(szFile, lpszFile, _MAX_PATH + 1);
  3157. wcstombs(szAsiPath, szPath, _MAX_PATH + 1);
  3158. lpfnBrandICW(szFile, szAsiPath, pDynShare->dwBrandFlags, szEntry);
  3159. #else
  3160. lpfnBrandICW(lpszFile, szPath, pDynShare->dwBrandFlags, lpszConnectoidName);
  3161. #endif
  3162. #else
  3163. lpfnBrandMe(lpszFile, szPath);
  3164. #endif
  3165. UnloadBrandingFunctions();
  3166. }
  3167. return ERROR_SUCCESS;
  3168. }
  3169. //+----------------------------------------------------------------------------
  3170. //
  3171. // Function: CallSBSConfig
  3172. //
  3173. // Synopsis: Call into the SBSCFG dll's Configure function to allow SBS to
  3174. // process the .ins file as needed
  3175. //
  3176. // Arguements: hwnd -- hwnd of parent, in case sbs wants to put up messages
  3177. // lpszINSFile -- full path to the .ins file
  3178. //
  3179. // Returns: windows error code that sbscfg returns.
  3180. //
  3181. // History: 2/19/97 jmazner Created for Olympus #1106
  3182. //
  3183. //-----------------------------------------------------------------------------
  3184. #if defined(WIN32)
  3185. DWORD CallSBSConfig(HWND hwnd, LPCTSTR lpszINSFile)
  3186. {
  3187. HINSTANCE hSBSDLL = NULL;
  3188. DWORD dwRet = ERROR_SUCCESS;
  3189. TCHAR lpszConnectoidName[RAS_MaxEntryName] = TEXT("nogood\0");
  3190. //
  3191. // Get name of connectoid we created by looking in autodial
  3192. // We need to pass this name into SBSCFG
  3193. // 5/14/97 jmazner Windosw NT Bugs #87209
  3194. //
  3195. BOOL fEnabled = FALSE;
  3196. if( NULL == lpfnInetGetAutodial )
  3197. {
  3198. Dprintf("lpfnInetGetAutodial is NULL!!!!");
  3199. return ERROR_INVALID_FUNCTION;
  3200. }
  3201. dwRet = lpfnInetGetAutodial(&fEnabled,lpszConnectoidName,RAS_MaxEntryName);
  3202. Dprintf("ISIGN32: Calling LoadLibrary on %s\n", cszSBSCFG_DLL);
  3203. hSBSDLL = LoadLibrary(cszSBSCFG_DLL);
  3204. // Load DLL and entry point
  3205. if (NULL != hSBSDLL)
  3206. {
  3207. Dprintf("ISIGN32: Calling GetProcAddress on %s\n", cszSBSCFG_CONFIGURE);
  3208. lpfnConfigure = (SBSCONFIGURE)GetProcAddress(hSBSDLL,cszSBSCFG_CONFIGURE);
  3209. }
  3210. else
  3211. {
  3212. // 4/2/97 ChrisK Olympus 2759
  3213. // If the DLL can't be loaded, pick a specific error message to return.
  3214. dwRet = ERROR_DLL_NOT_FOUND;
  3215. goto CallSBSConfigExit;
  3216. }
  3217. // Call function
  3218. if( hSBSDLL && lpfnConfigure )
  3219. {
  3220. Dprintf("ISIGN32: Calling the Configure entry point: %s, %s\n", lpszINSFile, lpszConnectoidName);
  3221. dwRet = lpfnConfigure(hwnd, (TCHAR *)lpszINSFile, lpszConnectoidName);
  3222. }
  3223. else
  3224. {
  3225. Dprintf("ISIGN32: Unable to call the Configure entry point\n");
  3226. dwRet = GetLastError();
  3227. }
  3228. CallSBSConfigExit:
  3229. if( hSBSDLL )
  3230. FreeLibrary(hSBSDLL);
  3231. if( lpfnConfigure )
  3232. lpfnConfigure = NULL;
  3233. Dprintf("ISIGN32: CallSBSConfig exiting with error code %d \n", dwRet);
  3234. return dwRet;
  3235. }
  3236. #endif
  3237. #if defined(WIN16)
  3238. #define FILE_BUFFER_SIZE 8092
  3239. #else
  3240. #define FILE_BUFFER_SIZE 65534
  3241. #endif
  3242. #ifndef FILE_BEGIN
  3243. #define FILE_BEGIN 0
  3244. #endif
  3245. DWORD MassageFile(LPCTSTR lpszFile)
  3246. {
  3247. LPBYTE lpBufferIn;
  3248. LPBYTE lpBufferOut;
  3249. HFILE hfile;
  3250. DWORD dwRet = ERROR_SUCCESS;
  3251. #ifdef WIN32
  3252. if (!SetFileAttributes(lpszFile, FILE_ATTRIBUTE_NORMAL))
  3253. {
  3254. return GetLastError();
  3255. }
  3256. #endif
  3257. lpBufferIn = (LPBYTE) LocalAlloc(LPTR, 2 * FILE_BUFFER_SIZE);
  3258. if (NULL == lpBufferIn)
  3259. {
  3260. return ERROR_OUTOFMEMORY;
  3261. }
  3262. lpBufferOut = lpBufferIn + FILE_BUFFER_SIZE;
  3263. #ifdef UNICODE
  3264. CHAR szTmp[MAX_PATH+1];
  3265. wcstombs(szTmp, lpszFile, MAX_PATH+1);
  3266. hfile = _lopen(szTmp, OF_READWRITE);
  3267. #else
  3268. hfile = _lopen(lpszFile, OF_READWRITE);
  3269. #endif
  3270. if (HFILE_ERROR != hfile)
  3271. {
  3272. BOOL fChanged = FALSE;
  3273. UINT uBytesOut = 0;
  3274. UINT uBytesIn = _lread(hfile, lpBufferIn, (UINT)(FILE_BUFFER_SIZE - 1));
  3275. // Note: we asume, in our use of lpCharIn, that the file is always less than
  3276. // FILE_BUFFER_SIZE
  3277. if (HFILE_ERROR != uBytesIn)
  3278. {
  3279. LPBYTE lpCharIn = lpBufferIn;
  3280. LPBYTE lpCharOut = lpBufferOut;
  3281. while ((*lpCharIn) && (FILE_BUFFER_SIZE - 2 > uBytesOut))
  3282. {
  3283. *lpCharOut++ = *lpCharIn;
  3284. uBytesOut++;
  3285. if ((0x0d == *lpCharIn) && (0x0a != *(lpCharIn + 1)))
  3286. {
  3287. fChanged = TRUE;
  3288. *lpCharOut++ = 0x0a;
  3289. uBytesOut++;
  3290. }
  3291. lpCharIn++;
  3292. }
  3293. if (fChanged)
  3294. {
  3295. if (HFILE_ERROR != _llseek(hfile, 0, FILE_BEGIN))
  3296. {
  3297. if (HFILE_ERROR ==_lwrite(hfile, (LPCSTR)lpBufferOut, uBytesOut))
  3298. {
  3299. #ifdef WIN32
  3300. dwRet = GetLastError();
  3301. #else
  3302. dwRet = ERROR_CANTWRITE;
  3303. #endif
  3304. }
  3305. }
  3306. else
  3307. {
  3308. #ifdef WIN32
  3309. dwRet = GetLastError();
  3310. #else
  3311. dwRet = ERROR_CANTWRITE;
  3312. #endif
  3313. }
  3314. }
  3315. }
  3316. else
  3317. {
  3318. #ifdef WIN32
  3319. dwRet = GetLastError();
  3320. #else
  3321. dwRet = ERROR_CANTREAD;
  3322. #endif
  3323. }
  3324. _lclose(hfile);
  3325. }
  3326. else
  3327. {
  3328. #ifdef WIN32
  3329. dwRet = GetLastError();
  3330. #else
  3331. dwRet = ERROR_CANTOPEN;
  3332. #endif
  3333. }
  3334. LocalFree(lpBufferIn);
  3335. return dwRet;
  3336. }
  3337. #ifndef WIN32
  3338. // This function only handle formats like
  3339. // drive:\file, drive:\dir1\file, drive:\dir1\dir2\file, etc
  3340. // file, dir1\file, dir1\dir2\file, etc.
  3341. // It does not currently handle
  3342. // drive:file, drive:dir\file, etc.
  3343. // \file, \dir\file, etc.
  3344. // ..\file, ..\dir\file, etc.
  3345. DWORD MakeFullPathName(
  3346. LPCTSTR lpDir,
  3347. LPCTSTR lpFileName,
  3348. DWORD nBufferLength,
  3349. LPTSTR lpBuffer)
  3350. {
  3351. DWORD dwSize;
  3352. // check for unsupported format
  3353. if ('.' == *lpFileName)
  3354. {
  3355. return 0;
  3356. }
  3357. // check for full path name
  3358. // assuming full path if ":" is in path
  3359. if (strchr(lpFileName, ':') != NULL)
  3360. {
  3361. dwSize = lstrlen(lpFileName);
  3362. if (dwSize > nBufferLength)
  3363. {
  3364. return dwSize;
  3365. }
  3366. lstrcpy(lpBuffer, lpFileName);
  3367. }
  3368. else
  3369. {
  3370. lstrcpy(lpBuffer, lpDir);
  3371. // make sure the directory ends in back slash
  3372. if (lpBuffer[lstrlen(lpBuffer) - 1] != '\\')
  3373. {
  3374. lstrcat(lpBuffer, TEXT("\\"));
  3375. }
  3376. dwSize = lstrlen(lpBuffer) + lstrlen(lpFileName);
  3377. if (dwSize > nBufferLength)
  3378. {
  3379. return dwSize;
  3380. }
  3381. lstrcat(lpBuffer, lpFileName);
  3382. }
  3383. return dwSize;
  3384. }
  3385. // This function only handle formats like
  3386. // drive:\file, drive:\dir1\file, drive:\dir1\dir2\file, etc
  3387. // file, dir1\file, dir1\dir2\file, etc.
  3388. // It does not currently handle
  3389. // drive:file, drive:dir\file, etc.
  3390. // \file, \dir\file, etc.
  3391. // ..\file, ..\dir\file, etc.
  3392. DWORD GetFullPathName(
  3393. LPCTSTR lpFileName,
  3394. DWORD nBufferLength,
  3395. LPTSTR lpBuffer,
  3396. LPTSTR FAR *lpFilePart)
  3397. {
  3398. DWORD dwSize;
  3399. TCHAR szDir[_MAX_PATH + 1];
  3400. if (_getcwd(szDir, _MAX_PATH + 1) == NULL)
  3401. {
  3402. return 0;
  3403. }
  3404. dwSize = MakeFullPathName(
  3405. szDir,
  3406. lpFileName,
  3407. nBufferLength,
  3408. lpBuffer);
  3409. if ((0 != dwSize) && (NULL != lpFilePart))
  3410. {
  3411. // find last back slash
  3412. *lpFilePart = strrchr(lpBuffer, '\\');
  3413. if (NULL == *lpFilePart)
  3414. {
  3415. // must have been in the unsupported format of drive:file
  3416. return 0;
  3417. }
  3418. // point to the filename
  3419. *lpFilePart += 1;
  3420. }
  3421. return dwSize;
  3422. }
  3423. BOOL SetCurrentDirectory(
  3424. LPCTSTR lpPathName)
  3425. {
  3426. TCHAR szTemp[_MAX_PATH];
  3427. TCHAR FAR* lpChar;
  3428. lstrcpy(szTemp, lpPathName);
  3429. lpChar = szTemp + lstrlen(szTemp) - 1;
  3430. if (*lpChar == '\\' && *(lpChar - 1) != ':')
  3431. {
  3432. *lpChar = '\0';
  3433. }
  3434. return (0 == _chdir(szTemp));
  3435. }
  3436. #endif
  3437. #ifdef WIN16
  3438. extern "C" BOOL CALLBACK __export LaunchDlgProc(
  3439. #else
  3440. INT_PTR CALLBACK LaunchDlgProc(
  3441. #endif
  3442. HWND hDlg,
  3443. UINT uMsg,
  3444. WPARAM wParam,
  3445. LPARAM lParam);
  3446. HWND LaunchInit(HWND hwndParent)
  3447. {
  3448. HWND hwnd;
  3449. hwnd = CreateDialog (ghInstance, TEXT("Launch"), NULL, LaunchDlgProc);
  3450. if (NULL != hwnd)
  3451. {
  3452. CenterWindow(hwnd, NULL);
  3453. }
  3454. return hwnd;
  3455. }
  3456. #ifdef WIN16
  3457. extern "C" BOOL CALLBACK __export LaunchDlgProc(
  3458. #else
  3459. INT_PTR CALLBACK LaunchDlgProc(
  3460. #endif
  3461. HWND hDlg,
  3462. UINT uMsg,
  3463. WPARAM wParam,
  3464. LPARAM lParam
  3465. )
  3466. {
  3467. return FALSE;
  3468. }
  3469. //+----------------------------------------------------------------------------
  3470. // Function: ReleaseConnectionStructures
  3471. //
  3472. // Synopsis: Free memory allocated for dialing and error dialogs
  3473. //
  3474. // Arguments: pDDD - pointer to dialing dialog data
  3475. // pEDD - pointer to error dialog data
  3476. //
  3477. // Returns: HRESULT - ERROR_SUCCESS indicates success
  3478. //
  3479. // History:
  3480. // 7/23/96 ChrisK Created
  3481. //
  3482. //-----------------------------------------------------------------------------
  3483. HRESULT ReleaseConnectionStructures(LPDIALDLGDATA pDDD, LPERRORDLGDATA pEDD)
  3484. {
  3485. DebugOut("ISIGN32:ReleaseConnectionStructures()\r\n");
  3486. if (pDDD->pszMessage)
  3487. LocalFree(pDDD->pszMessage);
  3488. if (pDDD->pszDunFile)
  3489. LocalFree(pDDD->pszDunFile);
  3490. if (pDDD->pszRasEntryName)
  3491. LocalFree(pDDD->pszRasEntryName);
  3492. if (pEDD->pszRasEntryName)
  3493. LocalFree(pEDD->pszRasEntryName);
  3494. if (pEDD->pszMessage)
  3495. LocalFree(pEDD->pszMessage);
  3496. ZeroMemory(pDDD,sizeof(DIALDLGDATA));
  3497. ZeroMemory(pEDD,sizeof(ERRORDLGDATA));
  3498. return ERROR_SUCCESS;
  3499. }
  3500. //+----------------------------------------------------------------------------
  3501. // Function: FillConnectionStructures
  3502. //
  3503. // Synopsis: Fills in structures for dialing and error dialogs
  3504. //
  3505. // Arguments: lpszFile - ISP file name
  3506. // pDDD - pointer to dialing dialog data
  3507. // pEDD - pointer to error dialog data
  3508. //
  3509. // Returns: HRESULT - ERROR_SUCCESS indicates success
  3510. //
  3511. // History:
  3512. // 7/23/96 ChrisK Created
  3513. //
  3514. //-----------------------------------------------------------------------------
  3515. static HRESULT FillConnectionStructures(LPCTSTR lpszFile,LPDIALDLGDATA pDDD, LPERRORDLGDATA pEDD)
  3516. {
  3517. HRESULT hr = ERROR_SUCCESS;
  3518. DebugOut("ISIGN32:FillConnectionStructures()\r\n");
  3519. //
  3520. // Initialize DDD structure
  3521. //
  3522. ZeroMemory(pDDD,sizeof(DIALDLGDATA));
  3523. pDDD->dwSize = sizeof(DIALDLGDATA);
  3524. pDDD->hInst = ghInstance;
  3525. pDDD->pfnStatusCallback = StatusMessageCallback;
  3526. //
  3527. // Set DUN file, in this case the ISP file contains the contents of a DUN file
  3528. //
  3529. pDDD->pszDunFile = (LPTSTR)LocalAlloc(LPTR,(lstrlen(lpszFile)+1)* sizeof(TCHAR));
  3530. if (0 == pDDD->pszDunFile)
  3531. {
  3532. hr = ERROR_NOT_ENOUGH_MEMORY;
  3533. goto FillConnectionStructuresExit;
  3534. }
  3535. lstrcpy(pDDD->pszDunFile,lpszFile);
  3536. //
  3537. // Load message string
  3538. //
  3539. pDDD->pszMessage = (LPTSTR)LocalAlloc(LPTR,1024* sizeof(TCHAR));
  3540. if (0 == pDDD->pszMessage)
  3541. {
  3542. hr = ERROR_NOT_ENOUGH_MEMORY;
  3543. goto FillConnectionStructuresExit;
  3544. }
  3545. if (0 == LoadString(ghInstance,IDS_ISP_DIAL_MESSAGE,
  3546. pDDD->pszMessage,1024))
  3547. {
  3548. hr = GetLastError();
  3549. goto FillConnectionStructuresExit;
  3550. }
  3551. //
  3552. // Get Connectoid name
  3553. //
  3554. pDDD->pszRasEntryName = (LPTSTR)LocalAlloc(LPTR, (RAS_MaxEntryName + 1)*sizeof(TCHAR));
  3555. if (0 == pDDD->pszRasEntryName)
  3556. {
  3557. hr = ERROR_NOT_ENOUGH_MEMORY;
  3558. goto FillConnectionStructuresExit;
  3559. }
  3560. if( 0 == GetPrivateProfileString(cszEntrySection,cszEntryName,szNull,
  3561. pDDD->pszRasEntryName,RAS_MaxEntryName,lpszFile))
  3562. {
  3563. hr = ERROR_INVALID_PARAMETER;
  3564. goto FillConnectionStructuresExit;
  3565. }
  3566. //
  3567. // Hook in reconnect mechanism
  3568. //
  3569. #if !defined(WIN16)
  3570. pDDD->pfnRasDialFunc1 = RasDial1Callback;
  3571. #endif
  3572. //
  3573. // Initialize EDD structure
  3574. //
  3575. ZeroMemory(pEDD,sizeof(ERRORDLGDATA));
  3576. pEDD->dwSize = sizeof(ERRORDLGDATA);
  3577. //
  3578. // Copy common fields to Error dialog data
  3579. //
  3580. pEDD->hInst = pDDD->hInst;
  3581. pEDD->pszRasEntryName = (LPTSTR)LocalAlloc(LPTR,(lstrlen(pDDD->pszRasEntryName)+1)*sizeof(TCHAR));
  3582. if (NULL == pEDD->pszRasEntryName)
  3583. {
  3584. hr = ERROR_NOT_ENOUGH_MEMORY;
  3585. goto FillConnectionStructuresExit;
  3586. }
  3587. lstrcpy(pEDD->pszRasEntryName,pDDD->pszRasEntryName);
  3588. //
  3589. // Allocate buffer for error messages
  3590. //
  3591. pEDD->pszMessage = (LPTSTR)LocalAlloc(LPTR,MAX_ERROR_MESSAGE*sizeof(TCHAR));
  3592. if (NULL == pEDD->pszMessage)
  3593. {
  3594. hr = ERROR_NOT_ENOUGH_MEMORY;
  3595. goto FillConnectionStructuresExit;
  3596. }
  3597. FillConnectionStructuresExit:
  3598. return hr;
  3599. }
  3600. //+----------------------------------------------------------------------------
  3601. // Function FShouldRetry
  3602. //
  3603. // Synopsis Given a RAS error should the dialer automatically retry
  3604. //
  3605. // Arguments dwErr - RAS error value
  3606. //
  3607. // Returns TRUE - the dialer should automatically retry
  3608. //
  3609. // Histroy 10/16/96 ChrisK Ported from icwconn1
  3610. //
  3611. //-----------------------------------------------------------------------------
  3612. static BOOL FShouldRetry(DWORD dwErr)
  3613. {
  3614. BOOL bRC;
  3615. if (dwErr == ERROR_LINE_BUSY ||
  3616. dwErr == ERROR_VOICE_ANSWER ||
  3617. dwErr == ERROR_NO_ANSWER ||
  3618. dwErr == ERROR_NO_CARRIER ||
  3619. dwErr == ERROR_AUTHENTICATION_FAILURE ||
  3620. dwErr == ERROR_PPP_TIMEOUT ||
  3621. dwErr == ERROR_REMOTE_DISCONNECTION ||
  3622. dwErr == ERROR_AUTH_INTERNAL ||
  3623. dwErr == ERROR_PROTOCOL_NOT_CONFIGURED ||
  3624. dwErr == ERROR_PPP_NO_PROTOCOLS_CONFIGURED)
  3625. {
  3626. bRC = TRUE;
  3627. } else {
  3628. bRC = FALSE;
  3629. }
  3630. return bRC;
  3631. }
  3632. //+----------------------------------------------------------------------------
  3633. //
  3634. // Function: RepairDeviceInfo
  3635. //
  3636. // Synopsis: In some win95 configurations, RasSetEntryProperties will create
  3637. // a connectoid with invalid information about the modem. This
  3638. // function attempts to correct the problem by reading and
  3639. // rewriting the connectoid.
  3640. //
  3641. // Arguments: lpszEntry - name of connectoid
  3642. //
  3643. // Returns: none
  3644. //
  3645. // History: ChrisK 7/25/97 Created
  3646. //
  3647. //-----------------------------------------------------------------------------
  3648. #if !defined(WIN16)
  3649. BOOL RepairDeviceInfo(LPTSTR lpszEntry)
  3650. {
  3651. DWORD dwEntrySize = 0;
  3652. DWORD dwDeviceSize = 0;
  3653. LPRASENTRY lpRasEntry = NULL;
  3654. LPBYTE lpbDevice = NULL;
  3655. OSVERSIONINFO osver;
  3656. TCHAR szTemp[1024];
  3657. BOOL bRC = FALSE;
  3658. RASDIALPARAMS rasdialp;
  3659. BOOL bpassword = FALSE;
  3660. //
  3661. // Validate parameters
  3662. //
  3663. if (NULL == lpszEntry)
  3664. {
  3665. DebugOut("ISIGN32: RepairDevice invalid parameter.\n");
  3666. goto RepairDeviceInfoExit;
  3667. }
  3668. //
  3669. // This fix only applies to golden win95 build 950
  3670. //
  3671. osver.dwOSVersionInfoSize = sizeof(osver);
  3672. GetVersionEx(&osver);
  3673. if (VER_PLATFORM_WIN32_WINDOWS != osver.dwPlatformId ||
  3674. 4 != osver.dwMajorVersion ||
  3675. 0 != osver.dwMinorVersion ||
  3676. 950 != LOWORD(osver.dwBuildNumber))
  3677. {
  3678. DebugOut("ISIGN32: RepairDevice wrong platform.\n");
  3679. wsprintf(szTemp,TEXT("ISIGN32: %d.%d.%d.\n"),
  3680. osver.dwMajorVersion,
  3681. osver.dwMinorVersion,
  3682. LOWORD(osver.dwBuildNumber));
  3683. DebugOut(szTemp);
  3684. goto RepairDeviceInfoExit;
  3685. }
  3686. //
  3687. // Get the RAS Entry
  3688. //
  3689. lpfnRasGetEntryProperties(NULL,
  3690. lpszEntry,
  3691. NULL,
  3692. &dwEntrySize,
  3693. NULL,
  3694. &dwDeviceSize);
  3695. lpRasEntry = (LPRASENTRY)LocalAlloc(LPTR, dwEntrySize);
  3696. lpbDevice = (LPBYTE)LocalAlloc(LPTR,dwDeviceSize);
  3697. if (NULL == lpRasEntry || NULL == lpbDevice)
  3698. {
  3699. DebugOut("ISIGN32: RepairDevice Out of memory.\n");
  3700. goto RepairDeviceInfoExit;
  3701. }
  3702. if (sizeof(RASENTRY) != dwEntrySize)
  3703. {
  3704. DebugOut("ISIGN32: RepairDevice Entry size is not equal to sizeof(RASENTRY).\n");
  3705. }
  3706. lpRasEntry->dwSize = sizeof(RASENTRY);
  3707. if (ERROR_SUCCESS != lpfnRasGetEntryProperties(NULL,
  3708. lpszEntry,
  3709. (LPBYTE)lpRasEntry,
  3710. &dwEntrySize,
  3711. lpbDevice,
  3712. &dwDeviceSize))
  3713. {
  3714. DebugOut("ISIGN32: RepairDevice can not read entry.\n");
  3715. goto RepairDeviceInfoExit;
  3716. }
  3717. //
  3718. // Get the connectoid's user ID and password
  3719. //
  3720. ZeroMemory(&rasdialp,sizeof(rasdialp));
  3721. rasdialp.dwSize = sizeof(rasdialp);
  3722. lstrcpyn(rasdialp.szEntryName,lpszEntry,RAS_MaxEntryName);
  3723. if (ERROR_SUCCESS != lpfnRasGetEntryDialParams(NULL,
  3724. &rasdialp,
  3725. &bpassword))
  3726. {
  3727. DebugOut("ISIGN32: RepairDevice can not read dial params.\n");
  3728. goto RepairDeviceInfoExit;
  3729. }
  3730. //
  3731. // Delete the existing entry
  3732. //
  3733. if (ERROR_SUCCESS != lpfnRasDeleteEntry(NULL,lpszEntry))
  3734. {
  3735. DebugOut("ISIGN32: RepairDevice can not delete entry.\n");
  3736. goto RepairDeviceInfoExit;
  3737. }
  3738. //
  3739. // Rewrite entry with "fixed" device size
  3740. //
  3741. if (ERROR_SUCCESS != lpfnRasSetEntryProperties(NULL,
  3742. lpszEntry,
  3743. (LPBYTE)lpRasEntry,
  3744. dwEntrySize,
  3745. NULL,
  3746. 0))
  3747. {
  3748. DebugOut("ISIGN32: RepairDevice can not write entry.\n");
  3749. goto RepairDeviceInfoExit;
  3750. }
  3751. //
  3752. // Clear unnecessary values
  3753. //
  3754. rasdialp.szPhoneNumber[0] = '\0';
  3755. rasdialp.szCallbackNumber[0] = '\0';
  3756. //
  3757. // Save connectoid's username and password
  3758. //
  3759. if (ERROR_SUCCESS != lpfnRasSetEntryDialParams(NULL,
  3760. &rasdialp,
  3761. FALSE))
  3762. {
  3763. DebugOut("ISIGN32: RepairDevice can not write dial params.\n");
  3764. goto RepairDeviceInfoExit;
  3765. }
  3766. bRC = TRUE;
  3767. RepairDeviceInfoExit:
  3768. if (lpRasEntry)
  3769. {
  3770. LocalFree(lpRasEntry);
  3771. }
  3772. if (lpbDevice)
  3773. {
  3774. LocalFree(lpbDevice);
  3775. }
  3776. return bRC;
  3777. }
  3778. #endif
  3779. //+----------------------------------------------------------------------------
  3780. // Function: DialConnection
  3781. //
  3782. // Synopsis: Dials connectoin created for ISP file
  3783. //
  3784. // Arguments: lpszFile - ISP file name
  3785. //
  3786. // Returns: HRESULT - ERROR_SUCCESS indicates success
  3787. //
  3788. // History:
  3789. // 7/22/96 ChrisK Created
  3790. //
  3791. //-----------------------------------------------------------------------------
  3792. static HRESULT DialConnection(LPCTSTR lpszFile)
  3793. {
  3794. HRESULT hr = ERROR_SUCCESS;
  3795. DIALDLGDATA dddISPDialDlg;
  3796. ERRORDLGDATA eddISPDialDlg;
  3797. HINSTANCE hDialDLL = NULL;
  3798. PFNDIALDLG pfnDial = NULL;
  3799. PFNERRORDLG pfnError = NULL;
  3800. INT iRetry;
  3801. DebugOut("ISIGNUP:DialConnection()\r\n");
  3802. //
  3803. // Initize data structures
  3804. //
  3805. hr = FillConnectionStructures(lpszFile,&dddISPDialDlg, &eddISPDialDlg);
  3806. if (ERROR_SUCCESS != hr)
  3807. goto DialConnectionExit;
  3808. //
  3809. // Load functions
  3810. //
  3811. TCHAR szBuffer[MAX_PATH];
  3812. if (GetSystemDirectory(szBuffer,MAX_PATH))
  3813. {
  3814. lstrcat(szBuffer, TEXT("\\"));
  3815. lstrcat(szBuffer, cszICWDIAL_DLL);
  3816. hDialDLL = LoadLibrary(szBuffer);
  3817. }
  3818. if (!hDialDLL)
  3819. hDialDLL = LoadLibrary(cszICWDIAL_DLL);
  3820. if (NULL != hDialDLL)
  3821. {
  3822. pfnDial = (PFNDIALDLG)GetProcAddress(hDialDLL,cszICWDIAL_DIALDLG);
  3823. if (NULL != pfnDial)
  3824. pfnError = (PFNERRORDLG)GetProcAddress(hDialDLL,cszICWDIAL_ERRORDLG);
  3825. }
  3826. if(!(hDialDLL && pfnDial && pfnError))
  3827. {
  3828. hr = GetLastError();
  3829. goto DialConnectionExit;
  3830. }
  3831. //
  3832. // Dial connection
  3833. //
  3834. iRetry = 0;
  3835. DialConnectionDial:
  3836. hr = pfnDial(&dddISPDialDlg);
  3837. if (1 == hr)
  3838. {
  3839. // This is a special case when the user has killed the browser
  3840. // out from behind the dialer. In this case, shut down and exit
  3841. // as cleanly as possible.
  3842. goto DialConnectionExit;
  3843. }
  3844. else if (ERROR_USERNEXT != hr)
  3845. {
  3846. if ((iRetry < MAX_RETRIES) && FShouldRetry(hr))
  3847. {
  3848. iRetry++;
  3849. goto DialConnectionDial;
  3850. }
  3851. else
  3852. {
  3853. #if !defined(WIN16)
  3854. if (0 == iRetry && ERROR_WRONG_INFO_SPECIFIED == hr)
  3855. {
  3856. DebugOut("ISIGN32: Attempt device info repair.\n");
  3857. if (RepairDeviceInfo(dddISPDialDlg.pszRasEntryName))
  3858. {
  3859. iRetry++;
  3860. goto DialConnectionDial;
  3861. }
  3862. }
  3863. #endif
  3864. iRetry = 0;
  3865. hr = LoadDialErrorString(hr,eddISPDialDlg.pszMessage,MAX_ERROR_MESSAGE);
  3866. hr = pfnError(&eddISPDialDlg);
  3867. if (ERROR_USERCANCEL == hr)
  3868. goto DialConnectionExit;
  3869. else if (ERROR_USERNEXT == hr)
  3870. goto DialConnectionDial;
  3871. else
  3872. goto DialConnectionExit;
  3873. }
  3874. }
  3875. DialConnectionExit:
  3876. ReleaseConnectionStructures(&dddISPDialDlg, &eddISPDialDlg);
  3877. if (hDialDLL)
  3878. {
  3879. FreeLibrary(hDialDLL);
  3880. hDialDLL = NULL;
  3881. pfnDial = NULL;
  3882. pfnError = NULL;
  3883. }
  3884. return hr;
  3885. }
  3886. #ifdef WIN16
  3887. LPVOID MyLocalAlloc(DWORD flag, DWORD size)
  3888. {
  3889. LPVOID lpv;
  3890. lpv = calloc(1, (INT)size);
  3891. return lpv;
  3892. }
  3893. LPVOID MyLocalFree(LPVOID lpv)
  3894. {
  3895. free(lpv);
  3896. return NULL;
  3897. }
  3898. #endif
  3899. // ############################################################################
  3900. //
  3901. // Name: ImportMailAndNewsInfo
  3902. //
  3903. // Description: Import information from INS file and set the associated
  3904. // registry keys for Internet Mail and News (Athena)
  3905. //
  3906. // Input: lpszFile - Fully qualified filename of INS file
  3907. //
  3908. // Return: Error value
  3909. //
  3910. // History: 6/27/96 Created
  3911. // 5/12/97 Updated to use the new CreateAccountsFromFile
  3912. // in Athena's inetcomm.dll. This function was
  3913. // created expresly for us to use here.
  3914. // (See Olympus #266) -- jmazner
  3915. //
  3916. // ############################################################################
  3917. static DWORD ImportMailAndNewsInfo(LPCTSTR lpszFile, BOOL fConnectPhone)
  3918. {
  3919. DWORD dwRet = ERROR_SUCCESS;
  3920. #ifndef WIN16
  3921. TCHAR szAcctMgrPath[MAX_PATH + 1] = TEXT("");
  3922. TCHAR szExpandedPath[MAX_PATH + 1] = TEXT("");
  3923. DWORD dwAcctMgrPathSize = 0;
  3924. HRESULT hr = S_OK;
  3925. HKEY hKey = NULL;
  3926. HINSTANCE hInst = NULL;
  3927. CONNECTINFO connectInfo;
  3928. TCHAR szConnectoidName[RAS_MaxEntryName] = TEXT("nogood\0");
  3929. PFNCREATEACCOUNTSFROMFILEEX fp = NULL;
  3930. // get path to the AcctMgr dll
  3931. dwRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, ACCTMGR_PATHKEY,0, KEY_READ, &hKey);
  3932. if ( (dwRet != ERROR_SUCCESS) || (NULL == hKey) )
  3933. {
  3934. Dprintf("ImportMailAndNewsInfo couldn't open reg key %s\n", ACCTMGR_PATHKEY);
  3935. return( dwRet );
  3936. }
  3937. dwAcctMgrPathSize = sizeof (szAcctMgrPath);
  3938. dwRet = RegQueryValueEx(hKey, ACCTMGR_DLLPATH, NULL, NULL, (LPBYTE) szAcctMgrPath, &dwAcctMgrPathSize);
  3939. RegCloseKey( hKey );
  3940. if ( dwRet != ERROR_SUCCESS )
  3941. {
  3942. Dprintf("ImportMailAndNewsInfo: RegQuery failed with error %d\n", dwRet);
  3943. return( dwRet );
  3944. }
  3945. // 6/18/97 jmazner Olympus #6819
  3946. Dprintf("ImportMailAndNewsInfo: read in DllPath of %s\n", szAcctMgrPath);
  3947. ExpandEnvironmentStrings( szAcctMgrPath, szExpandedPath, MAX_PATH + 1 );
  3948. //
  3949. // 6/4/97 jmazner
  3950. // if we created a connectoid, then get its name and use that as the
  3951. // connection type. Otherwise, assume we're supposed to connect via LAN
  3952. //
  3953. connectInfo.cbSize = sizeof(CONNECTINFO);
  3954. connectInfo.type = CONNECT_LAN;
  3955. if( fConnectPhone && lpfnInetGetAutodial )
  3956. {
  3957. BOOL fEnabled = FALSE;
  3958. dwRet = lpfnInetGetAutodial(&fEnabled,szConnectoidName,RAS_MaxEntryName);
  3959. if( ERROR_SUCCESS==dwRet && szConnectoidName[0] )
  3960. {
  3961. connectInfo.type = CONNECT_RAS;
  3962. #ifdef UNICODE
  3963. wcstombs(connectInfo.szConnectoid, szConnectoidName, MAX_PATH);
  3964. #else
  3965. lstrcpyn( connectInfo.szConnectoid, szConnectoidName, MAX_PATH );
  3966. #endif
  3967. Dprintf("ImportMailAndNewsInfo: setting connection type to RAS with %s\n", szConnectoidName);
  3968. }
  3969. }
  3970. if( CONNECT_LAN == connectInfo.type )
  3971. {
  3972. Dprintf("ImportMailAndNewsInfo: setting connection type to LAN\n");
  3973. #ifdef UNICODE
  3974. wcstombs(connectInfo.szConnectoid, TEXT("I said CONNECT_LAN!"), MAX_PATH);
  3975. #else
  3976. lstrcpy( connectInfo.szConnectoid, TEXT("I said CONNECT_LAN!") );
  3977. #endif
  3978. }
  3979. hInst = LoadLibrary(szExpandedPath);
  3980. if (hInst)
  3981. {
  3982. fp = (PFNCREATEACCOUNTSFROMFILEEX) GetProcAddress(hInst,"CreateAccountsFromFileEx");
  3983. if (fp)
  3984. hr = fp( (TCHAR *)lpszFile, &connectInfo, NULL );
  3985. }
  3986. else
  3987. {
  3988. Dprintf("ImportMailAndNewsInfo unable to LoadLibrary on %s\n", szAcctMgrPath);
  3989. }
  3990. //
  3991. // Clean up and release resourecs
  3992. //
  3993. if( hInst)
  3994. {
  3995. FreeLibrary(hInst);
  3996. hInst = NULL;
  3997. }
  3998. if( fp )
  3999. {
  4000. fp = NULL;
  4001. }
  4002. //ImportMailAndNewsInfoExit:
  4003. #endif
  4004. return dwRet;
  4005. }
  4006. // ############################################################################
  4007. //
  4008. // Name: WriteMailAndNewsKey
  4009. //
  4010. // Description: Read a string value from the given INS file and write it
  4011. // to the registry
  4012. //
  4013. // Input: hKey - Registry key where the data will be written
  4014. // lpszSection - Section name inside of INS file where data is read
  4015. // from
  4016. // lpszValue - Name of value to read from INS file
  4017. // lpszBuff - buffer where data will be read into
  4018. // dwBuffLen - size of lpszBuff
  4019. // lpszSubKey - Value name where information will be written to
  4020. // dwType - data type (Should always be REG_SZ)
  4021. // lpszFileName - Fully qualified filename to INS file
  4022. //
  4023. // Return: Error value
  4024. //
  4025. // Histroy: 6/27/96 Created
  4026. // 5/12/97 Commented out -- no longer needed
  4027. // (See Olympus #266)
  4028. //
  4029. // ############################################################################
  4030. /***
  4031. static HRESULT WriteMailAndNewsKey(HKEY hKey, LPCTSTR lpszSection, LPCTSTR lpszValue,
  4032. LPTSTR lpszBuff, DWORD dwBuffLen,LPCTSTR lpszSubKey,
  4033. DWORD dwType, LPCTSTR lpszFile)
  4034. {
  4035. #ifndef WIN16
  4036. ZeroMemory(lpszBuff,dwBuffLen);
  4037. GetPrivateProfileString(lpszSection,lpszValue,TEXT(""),lpszBuff,dwBuffLen,lpszFile);
  4038. if (lstrlen(lpszBuff))
  4039. {
  4040. return RegSetValueEx(hKey,lpszSubKey,0,dwType,(CONST BYTE*)lpszBuff,
  4041. sizeof(TCHAR)*(lstrlen(lpszBuff)+1));
  4042. }
  4043. else
  4044. {
  4045. DebugOut("ISIGNUP: WriteMailAndNewsKey, missing value in INS file\n");
  4046. return ERROR_NO_MORE_ITEMS;
  4047. }
  4048. #else
  4049. return ERROR_GEN_FAILURE;
  4050. #endif
  4051. }
  4052. ***/
  4053. // ############################################################################
  4054. //
  4055. // Name: PreparePassword
  4056. //
  4057. // Description: Encode given password and return value in place. The
  4058. // encoding is done right to left in order to avoid having
  4059. // to allocate a copy of the data. The encoding uses base64
  4060. // standard as specified in RFC 1341 5.2
  4061. //
  4062. // Input: szBuff - Null terminated data to be encoded
  4063. // dwBuffLen - Full length of buffer, this should exceed the length of
  4064. // the input data by at least 1/3
  4065. //
  4066. // Return: Error value
  4067. //
  4068. // Histroy: 6/27/96 Created
  4069. //
  4070. // ############################################################################
  4071. static HRESULT PreparePassword(LPTSTR szBuff, DWORD dwBuffLen)
  4072. {
  4073. DWORD dw;
  4074. LPTSTR szOut = NULL;
  4075. LPTSTR szNext = NULL;
  4076. HRESULT hr = ERROR_SUCCESS;
  4077. BYTE bTemp = 0;
  4078. DWORD dwLen = 0;
  4079. dwLen = lstrlen(szBuff);
  4080. if (!dwLen)
  4081. {
  4082. hr = ERROR_INVALID_PARAMETER;
  4083. goto PreparePasswordExit;
  4084. }
  4085. // Calculate the size of the buffer that will be needed to hold
  4086. // encoded data
  4087. //
  4088. szNext = &szBuff[dwLen-1];
  4089. dwLen = (((dwLen % 3 ? (3-(dwLen%3)):0) + dwLen) * 4 / 3);
  4090. if (dwBuffLen < dwLen+1)
  4091. {
  4092. hr = ERROR_INVALID_PARAMETER;
  4093. goto PreparePasswordExit;
  4094. }
  4095. szOut = &szBuff[dwLen];
  4096. *szOut-- = '\0';
  4097. // Add padding = characters
  4098. //
  4099. switch (lstrlen(szBuff) % 3)
  4100. {
  4101. case 0:
  4102. // no padding
  4103. break;
  4104. case 1:
  4105. *szOut-- = 64;
  4106. *szOut-- = 64;
  4107. *szOut-- = (*szNext & 0x3) << 4;
  4108. *szOut-- = (*szNext-- & 0xFC) >> 2;
  4109. break;
  4110. case 2:
  4111. *szOut-- = 64;
  4112. *szOut-- = (*szNext & 0xF) << 2;
  4113. *szOut = ((*szNext-- & 0xF0) >> 4);
  4114. *szOut-- |= ((*szNext & 0x3) << 4);
  4115. *szOut-- = (*szNext-- & 0xFC) >> 2;
  4116. }
  4117. // Encrypt data into indicies
  4118. //
  4119. while (szOut > szNext && szNext >= szBuff)
  4120. {
  4121. *szOut-- = *szNext & 0x3F;
  4122. *szOut = ((*szNext-- & 0xC0) >> 6);
  4123. *szOut-- |= ((*szNext & 0xF) << 2);
  4124. *szOut = ((*szNext-- & 0xF0) >> 4);
  4125. *szOut-- |= ((*szNext & 0x3) << 4);
  4126. *szOut-- = (*szNext-- & 0xFC) >> 2;
  4127. }
  4128. // Translate indicies into printable characters
  4129. //
  4130. szNext = szBuff;
  4131. // BUG OSR#10435--if there is a 0 in the generated string of base-64
  4132. // encoded digits (this can happen if the password is "Willypassword"
  4133. // for example), then instead of encoding the 0 to 'A', we just quit
  4134. // at this point, produces an invalid base-64 string.
  4135. // while (*szNext)
  4136. for(dw=0; dw<dwLen; dw++)
  4137. *szNext = arBase64[*szNext++];
  4138. PreparePasswordExit:
  4139. return hr;
  4140. }
  4141. // ############################################################################
  4142. //
  4143. // Name: FIsAthenaPresent
  4144. //
  4145. // Description: Determine if Microsoft Internet Mail And News client (Athena)
  4146. // is installed
  4147. //
  4148. // Input: none
  4149. //
  4150. // Return: TRUE - Athena is installed
  4151. // FALSE - Athena is NOT installed
  4152. //
  4153. // History: 7/1/96 Created
  4154. // 5/14/97 No longer needed after work for Olympus #266
  4155. //
  4156. // ############################################################################
  4157. /****
  4158. static BOOL FIsAthenaPresent()
  4159. {
  4160. #ifndef WIN16
  4161. TCHAR szBuff[MAX_PATH + 1];
  4162. HRESULT hr = ERROR_SUCCESS;
  4163. HINSTANCE hInst = NULL;
  4164. LONG lLen = 0;
  4165. // Get path to Athena client
  4166. //
  4167. lLen = MAX_PATH;
  4168. hr = RegQueryValue(HKEY_CLASSES_ROOT,MAIL_NEWS_INPROC_SERVER32,szBuff,&lLen);
  4169. if (hr == ERROR_SUCCESS)
  4170. {
  4171. // Attempt to load client
  4172. //
  4173. hInst = LoadLibrary(szBuff);
  4174. if (!hInst)
  4175. {
  4176. DebugOut("ISIGNUP: Internet Mail and News server didn't load.\n");
  4177. hr = ERROR_FILE_NOT_FOUND;
  4178. } else {
  4179. FreeLibrary(hInst);
  4180. }
  4181. hInst = NULL;
  4182. }
  4183. return (hr == ERROR_SUCCESS);
  4184. #else
  4185. return FALSE;
  4186. #endif // win16
  4187. }
  4188. *****/
  4189. // ############################################################################
  4190. //
  4191. // Name: FTurnOffBrowserDefaultChecking
  4192. //
  4193. // Description: Turn Off IE checking to see if it is the default browser
  4194. //
  4195. // Input: none
  4196. //
  4197. // Output: TRUE - success
  4198. // FALSE - failed
  4199. //
  4200. // History: 7/2/96 Created
  4201. //
  4202. // ############################################################################
  4203. static BOOL FTurnOffBrowserDefaultChecking()
  4204. {
  4205. BOOL bRC = TRUE;
  4206. #ifndef WIN16
  4207. HKEY hKey = NULL;
  4208. DWORD dwType = 0;
  4209. DWORD dwSize = 0;
  4210. //
  4211. // Open IE settings registry key
  4212. //
  4213. if (RegOpenKey(HKEY_CURRENT_USER,cszDEFAULT_BROWSER_KEY,&hKey))
  4214. {
  4215. bRC = FALSE;
  4216. goto FTurnOffBrowserDefaultCheckingExit;
  4217. }
  4218. //
  4219. // Read current settings for check associations
  4220. //
  4221. dwType = 0;
  4222. dwSize = sizeof(pDynShare->szCheckAssociations);
  4223. ZeroMemory(pDynShare->szCheckAssociations, dwSize);
  4224. RegQueryValueEx(hKey,
  4225. cszDEFAULT_BROWSER_VALUE,
  4226. 0,
  4227. &dwType,
  4228. (LPBYTE)pDynShare->szCheckAssociations,
  4229. &dwSize);
  4230. // ignore return value, even if the calls fails we are going to try
  4231. // to change the setting to "NO"
  4232. //
  4233. // Set value to "no" to turn off checking
  4234. //
  4235. if (RegSetValueEx(hKey,
  4236. cszDEFAULT_BROWSER_VALUE,
  4237. 0,
  4238. REG_SZ,
  4239. (LPBYTE)cszNo,
  4240. sizeof(TCHAR)*(lstrlen(cszNo)+1)))
  4241. {
  4242. bRC = FALSE;
  4243. goto FTurnOffBrowserDefaultCheckingExit;
  4244. }
  4245. //
  4246. // Clean up and return
  4247. //
  4248. FTurnOffBrowserDefaultCheckingExit:
  4249. if (hKey)
  4250. RegCloseKey(hKey);
  4251. if (bRC)
  4252. SetExitFlags(SXF_RESTOREDEFCHECK);
  4253. hKey = NULL;
  4254. #endif
  4255. return bRC;
  4256. }
  4257. // ############################################################################
  4258. //
  4259. // Name: FRestoreBrowserDefaultChecking
  4260. //
  4261. // Description: Restore IE checking to see if it is the default browser
  4262. //
  4263. // Input: none
  4264. //
  4265. // Output: TRUE - success
  4266. // FALSE - failed
  4267. //
  4268. // History: 7/2/96 Created
  4269. //
  4270. // ############################################################################
  4271. static BOOL FRestoreBrowserDefaultChecking()
  4272. {
  4273. BOOL bRC = TRUE;
  4274. #ifndef WIN16
  4275. HKEY hKey = NULL;
  4276. //
  4277. // Open IE settings registry key
  4278. //
  4279. if (RegOpenKey(HKEY_CURRENT_USER,cszDEFAULT_BROWSER_KEY,&hKey))
  4280. {
  4281. bRC = FALSE;
  4282. goto FRestoreBrowserDefaultCheckingExit;
  4283. }
  4284. //
  4285. // Set value to original value
  4286. //
  4287. if (RegSetValueEx(hKey,
  4288. cszDEFAULT_BROWSER_VALUE,
  4289. 0,
  4290. REG_SZ,
  4291. (LPBYTE)pDynShare->szCheckAssociations,
  4292. sizeof(TCHAR)*(lstrlen(pDynShare->szCheckAssociations)+1)))
  4293. {
  4294. bRC = FALSE;
  4295. goto FRestoreBrowserDefaultCheckingExit;
  4296. }
  4297. FRestoreBrowserDefaultCheckingExit:
  4298. if (hKey)
  4299. RegCloseKey(hKey);
  4300. hKey = NULL;
  4301. #endif
  4302. return bRC;
  4303. }
  4304. #if !defined(WIN16)
  4305. //+----------------------------------------------------------------------------
  4306. //
  4307. // Function: SaveIEWindowPlacement
  4308. //
  4309. // Synopsis: Saves the registry value for IE window placement into a global for later restoration
  4310. // Should only be called once in the signup process.
  4311. //
  4312. // Arguments: None, but uses global pbIEWindowPlacement, which it expects to be NULL
  4313. //
  4314. // Returns: TRUE - The value was read and stored
  4315. // FALSE - function failed.
  4316. //
  4317. // History: 8/21/96 jmazner Created (as fix for Normandy #4592)
  4318. // 10/11/96 jmazner updated to dynamicaly determine size of the key
  4319. //
  4320. //-----------------------------------------------------------------------------
  4321. BOOL SaveIEWindowPlacement( void )
  4322. {
  4323. HKEY hKey = NULL;
  4324. //DWORD dwSize = 0;
  4325. LONG lQueryErr = 0xEE; // initialize to something strange
  4326. DWORD dwIEWindowPlacementSize = 0;
  4327. PBYTE pbIEWindowPlacement = NULL;
  4328. // Argh, no Assert defined in isign32!
  4329. if ( pDynShare->dwIEWindowPlacementSize != 0 )
  4330. {
  4331. #if DEBUG
  4332. DebugOut("ISIGN32: SaveIEWindowPlacement called a second time!\n");
  4333. MessageBox(
  4334. hwndMain,
  4335. TEXT("ISIGN32 ERROR: Window_Placement global var is not null --jmazner\n"),
  4336. cszAppName,
  4337. MB_SETFOREGROUND |
  4338. MB_ICONEXCLAMATION |
  4339. MB_OKCANCEL);
  4340. #endif
  4341. DebugOut("ISIGN32: SaveIEWindowPlacement called a second time!\n");
  4342. goto SaveIEWindowPlacementErrExit;
  4343. }
  4344. //
  4345. // Open IE settings registry key
  4346. //
  4347. if ( ERROR_SUCCESS != RegOpenKeyEx(HKEY_CURRENT_USER,
  4348. cszDEFAULT_BROWSER_KEY,
  4349. NULL,
  4350. KEY_READ,
  4351. &hKey) )
  4352. goto SaveIEWindowPlacementErrExit;
  4353. // Determine size of buffer needed to hold the window_placement key
  4354. lQueryErr = RegQueryValueEx(hKey,
  4355. cszIEWINDOW_PLACEMENT,
  4356. NULL,
  4357. NULL,
  4358. NULL,
  4359. &dwIEWindowPlacementSize);
  4360. // for unknown reasons, lQueryErr is ending up as ERROR_SUCCESS after this call!
  4361. // if( ERROR_MORE_DATA != lQueryErr )
  4362. // goto SaveIEWindowPlacementErrExit;
  4363. ISIGN32_ASSERT(sizeof(pDynShare->pbIEWindowPlacement) >= dwIEWindowPlacementSize);
  4364. pbIEWindowPlacement = pDynShare->pbIEWindowPlacement;
  4365. //
  4366. // Read current settings for window_placement
  4367. //
  4368. //dwSize = sizeof(pbIEWindowPlacement);
  4369. //ZeroMemory(pbIEWindowPlacement,dwSize);
  4370. lQueryErr = RegQueryValueEx(hKey,
  4371. cszIEWINDOW_PLACEMENT,
  4372. NULL,
  4373. NULL,
  4374. (LPBYTE)pbIEWindowPlacement,
  4375. &dwIEWindowPlacementSize);
  4376. if (ERROR_SUCCESS != lQueryErr)
  4377. {
  4378. #ifdef DEBUG
  4379. MessageBox(
  4380. hwndMain,
  4381. TEXT("ISIGNUP ERROR: Window_Placement reg key is longer than expected! --jmazner\n"),
  4382. cszAppName,
  4383. MB_SETFOREGROUND |
  4384. MB_ICONEXCLAMATION |
  4385. MB_OKCANCEL);
  4386. #endif
  4387. DebugOut("ISIGN32 ERROR: SaveIEWindowPlacement RegQueryValue failed\n");
  4388. goto SaveIEWindowPlacementErrExit;
  4389. }
  4390. RegCloseKey( hKey );
  4391. pDynShare->dwIEWindowPlacementSize = dwIEWindowPlacementSize;
  4392. return( TRUE );
  4393. SaveIEWindowPlacementErrExit:
  4394. if ( hKey ) RegCloseKey( hKey );
  4395. return( FALSE );
  4396. }
  4397. // note we're still in #if !defined(WIN16)
  4398. //+----------------------------------------------------------------------------
  4399. //
  4400. // Function: RestoreIEWindowPlacement
  4401. //
  4402. // Synopsis: Restores the registry value for IE window placement from a global
  4403. // NOTE: compatability with Nashville/IE 4?
  4404. //
  4405. // Arguments: None
  4406. //
  4407. // Returns: TRUE - The value was restored
  4408. // FALSE - function failed.
  4409. //
  4410. // History: jmazner Created 8/21/96 (as fix for Normandy #4592)
  4411. //
  4412. //-----------------------------------------------------------------------------
  4413. BOOL RestoreIEWindowPlacement( void )
  4414. {
  4415. HKEY hKey = NULL;
  4416. if ( pDynShare->dwIEWindowPlacementSize == 0 )
  4417. {
  4418. DebugOut("ISIGN32: RestoreIEWindowPlacement called with null global!\n");
  4419. return( FALSE );
  4420. }
  4421. //
  4422. // Open IE settings registry key
  4423. //
  4424. if ( ERROR_SUCCESS != RegOpenKeyEx(HKEY_CURRENT_USER,
  4425. cszDEFAULT_BROWSER_KEY,
  4426. NULL,
  4427. KEY_SET_VALUE,
  4428. &hKey) )
  4429. return( FALSE );
  4430. //
  4431. // Write saved settings for window_placement
  4432. //
  4433. if (ERROR_SUCCESS != RegSetValueEx(hKey,
  4434. cszIEWINDOW_PLACEMENT,
  4435. NULL,
  4436. REG_BINARY,
  4437. (LPBYTE)pDynShare->pbIEWindowPlacement,
  4438. pDynShare->dwIEWindowPlacementSize) )
  4439. {
  4440. RegCloseKey( hKey );
  4441. return( FALSE );
  4442. }
  4443. RegCloseKey( hKey );
  4444. pDynShare->pbIEWindowPlacement[0] = (TCHAR) 0;
  4445. pDynShare->dwIEWindowPlacementSize = 0;
  4446. return( TRUE );
  4447. }
  4448. #endif //(!defined win16)
  4449. //+----------------------------------------------------------------------------
  4450. //
  4451. // Function: DeleteFileKindaLikeThisOne
  4452. //
  4453. // Synopsis: This function serve the single function of cleaning up after
  4454. // IE3.0, because IE3.0 will issue multiple POST and get back
  4455. // multiple .INS files. These files contain sensative data that
  4456. // we don't want lying around, so we are going out, guessing what
  4457. // their names are, and deleting them.
  4458. //
  4459. // Arguments: lpszFileName - the full name of the file to delete
  4460. //
  4461. // Returns: error code, ERROR_SUCCESS == success
  4462. //
  4463. // History: 7/96 ChrisK Created
  4464. // 7/96 ChrisK Bug fix for long filenames
  4465. // 8/2/96 ChrisK Port to Win32
  4466. //-----------------------------------------------------------------------------
  4467. static HRESULT DeleteFileKindaLikeThisOne(LPCTSTR lpszFileName)
  4468. {
  4469. HRESULT hr = ERROR_SUCCESS;
  4470. #ifndef WIN16
  4471. LPCTSTR lpNext = NULL;
  4472. WORD wRes = 0;
  4473. HANDLE hFind = NULL;
  4474. WIN32_FIND_DATA sFoundFile;
  4475. TCHAR szPath[MAX_PATH];
  4476. TCHAR szSearchPath[MAX_PATH + 1];
  4477. LPTSTR lpszFilePart = NULL;
  4478. // Validate parameter
  4479. //
  4480. if (!lpszFileName || lstrlen(lpszFileName) <= 4)
  4481. {
  4482. hr = ERROR_INVALID_PARAMETER;
  4483. goto DeleteFileKindaLikeThisOneExit;
  4484. }
  4485. // Determine the directory name where the INS files are located
  4486. //
  4487. ZeroMemory(szPath,MAX_PATH);
  4488. if (GetFullPathName(lpszFileName,MAX_PATH,szPath,&lpszFilePart))
  4489. {
  4490. *lpszFilePart = '\0';
  4491. } else {
  4492. hr = GetLastError();
  4493. goto DeleteFileKindaLikeThisOneExit;
  4494. };
  4495. // Munge filename into search parameters
  4496. //
  4497. lpNext = &lpszFileName[lstrlen(lpszFileName)-4];
  4498. if (CompareString(LOCALE_SYSTEM_DEFAULT,NORM_IGNORECASE,lpNext,4,TEXT(".INS"),4) != 2) goto DeleteFileKindaLikeThisOneExit;
  4499. ZeroMemory(szSearchPath,MAX_PATH + 1);
  4500. lstrcpyn(szSearchPath,szPath,MAX_PATH);
  4501. lstrcat(szSearchPath,TEXT("*.INS"));
  4502. // Start wiping out files
  4503. //
  4504. ZeroMemory(&sFoundFile,sizeof(sFoundFile));
  4505. hFind = FindFirstFile(szSearchPath,&sFoundFile);
  4506. if (hFind)
  4507. {
  4508. do {
  4509. lstrcpy(lpszFilePart,sFoundFile.cFileName);
  4510. SetFileAttributes(szPath,FILE_ATTRIBUTE_NORMAL);
  4511. DeleteFile(szPath);
  4512. ZeroMemory(&sFoundFile,sizeof(sFoundFile));
  4513. } while (FindNextFile(hFind,&sFoundFile));
  4514. FindClose(hFind);
  4515. }
  4516. hFind = NULL;
  4517. DeleteFileKindaLikeThisOneExit:
  4518. #endif
  4519. return hr;
  4520. }
  4521. #if defined(WIN16)
  4522. #define MAIN_WNDCLASS_NAME "IE_DialerMainWnd"
  4523. #define IEDIAL_REGISTER_MSG "IEDialQueryPrevInstance"
  4524. #define IEDIALMSG_QUERY (0)
  4525. #define IEDIALMSG_SHUTDOWN (1)
  4526. #define IEDIAL_SHUTDOWN_TIMER 1001
  4527. //+---------------------------------------------------------------------------
  4528. //
  4529. // Function: ShutDownIEDial()
  4530. //
  4531. // Synopsis: Shutdown the instance IEDial if it running and
  4532. // in disconnected state - otherwise it interfers with dialing
  4533. // from icwconn2
  4534. //
  4535. // Arguments: [hWnd - Window handle (used for creating timer)
  4536. //
  4537. // Returns: TRUE if successful shutdown or instance does not exist
  4538. // FALSE otherwise
  4539. //
  4540. // History: 8/24/96 VetriV Created
  4541. //
  4542. //----------------------------------------------------------------------------
  4543. BOOL ShutDownIEDial(HWND hWnd)
  4544. {
  4545. HINSTANCE hInstance;
  4546. static UINT WM_IEDIAL_INSTANCEQUERY = 0;
  4547. UINT uiAttempts = 0;
  4548. MSG msg;
  4549. //
  4550. // Check if IEDial is running
  4551. //
  4552. hInstance = FindWindow(MAIN_WNDCLASS_NAME, NULL);
  4553. if (NULL != hInstance)
  4554. {
  4555. if (0 == WM_IEDIAL_INSTANCEQUERY)
  4556. WM_IEDIAL_INSTANCEQUERY= RegisterWindowMessage(IEDIAL_REGISTER_MSG);
  4557. //
  4558. // Check if it is in connected state
  4559. //
  4560. if (SendMessage(hInstance, WM_IEDIAL_INSTANCEQUERY,
  4561. IEDIALMSG_QUERY, 0))
  4562. {
  4563. //
  4564. // Not connected - Send quit message
  4565. //
  4566. SendMessage(hInstance, WM_IEDIAL_INSTANCEQUERY,
  4567. IEDIALMSG_SHUTDOWN, 0);
  4568. return TRUE;
  4569. }
  4570. //
  4571. // If IEDIAL is in connected state try for another 3 seconds
  4572. // waiting for 1 second between tries
  4573. // We have to do this because, IEDIAL can take upto 2 seconds
  4574. // to realize it lost the connection!!
  4575. //
  4576. SetTimer(hWnd, IEDIAL_SHUTDOWN_TIMER, 1000, NULL);
  4577. DebugOut("ISIGNUP: IEDIAL Timer message loop\n");
  4578. while (GetMessage (&msg, NULL, 0, 0))
  4579. {
  4580. if (WM_TIMER == msg.message)
  4581. {
  4582. //
  4583. // Check if it is in connected state
  4584. //
  4585. if (SendMessage(hInstance, WM_IEDIAL_INSTANCEQUERY,
  4586. IEDIALMSG_QUERY, 0))
  4587. {
  4588. //
  4589. // Not connected - Send quit message
  4590. //
  4591. SendMessage(hInstance, WM_IEDIAL_INSTANCEQUERY,
  4592. IEDIALMSG_SHUTDOWN, 0);
  4593. break;
  4594. }
  4595. //
  4596. // If we have tried thrice - get out
  4597. //
  4598. if (++uiAttempts > 3)
  4599. break;
  4600. }
  4601. else
  4602. {
  4603. TranslateMessage (&msg) ;
  4604. DispatchMessage (&msg) ;
  4605. }
  4606. }
  4607. KillTimer(hWnd, IEDIAL_SHUTDOWN_TIMER);
  4608. if (uiAttempts > 3)
  4609. return FALSE;
  4610. }
  4611. return TRUE;
  4612. }
  4613. #endif // WIN16
  4614. #if !defined(WIN16)
  4615. //+----------------------------------------------------------------------------
  4616. //
  4617. // Function LclSetEntryScriptPatch
  4618. //
  4619. // Synopsis Softlink to RasSetEntryPropertiesScriptPatch
  4620. //
  4621. // Arguments see RasSetEntryPropertiesScriptPatch
  4622. //
  4623. // Returns see RasSetEntryPropertiesScriptPatch
  4624. //
  4625. // Histroy 10/3/96 ChrisK Created
  4626. //
  4627. //-----------------------------------------------------------------------------
  4628. typedef BOOL (WINAPI* LCLSETENTRYSCRIPTPATCH)(LPTSTR, LPTSTR);
  4629. BOOL LclSetEntryScriptPatch(LPTSTR lpszScript,LPTSTR lpszEntry)
  4630. {
  4631. HINSTANCE hinst = NULL;
  4632. LCLSETENTRYSCRIPTPATCH fp = NULL;
  4633. BOOL bRC = FALSE;
  4634. hinst = LoadLibrary(TEXT("ICWDIAL.DLL"));
  4635. if (hinst)
  4636. {
  4637. fp = (LCLSETENTRYSCRIPTPATCH)GetProcAddress(hinst,"RasSetEntryPropertiesScriptPatch");
  4638. if (fp)
  4639. bRC = (fp)(lpszScript,lpszEntry);
  4640. FreeLibrary(hinst);
  4641. hinst = NULL;
  4642. fp = NULL;
  4643. }
  4644. return bRC;
  4645. }
  4646. #endif //!WIN16
  4647. #if !defined(WIN16)
  4648. //+----------------------------------------------------------------------------
  4649. //
  4650. // Function IsMSDUN12Installed
  4651. //
  4652. // Synopsis Check if MSDUN 1.2 or higher is installed
  4653. //
  4654. // Arguments none
  4655. //
  4656. // Returns TRUE - MSDUN 1.2 is installed
  4657. //
  4658. // History 5/28/97 ChrisK created for Olympus Bug 4392
  4659. //
  4660. //-----------------------------------------------------------------------------
  4661. //
  4662. // 8/5/97 jmazner Olympus #11404
  4663. //
  4664. //#define DUN_12_Version (1.2e0f)
  4665. #define DUN_12_Version ((double)1.2)
  4666. BOOL IsMSDUN12Installed()
  4667. {
  4668. TCHAR szBuffer[MAX_PATH] = {TEXT("\0")};
  4669. HKEY hkey = NULL;
  4670. BOOL bRC = FALSE;
  4671. DWORD dwType = 0;
  4672. DWORD dwSize = sizeof(szBuffer);
  4673. FLOAT flVersion = 0e0f;
  4674. if (ERROR_SUCCESS != RegOpenKey(HKEY_LOCAL_MACHINE,
  4675. TEXT("System\\CurrentControlSet\\Services\\RemoteAccess"),
  4676. &hkey))
  4677. {
  4678. goto IsMSDUN12InstalledExit;
  4679. }
  4680. if (ERROR_SUCCESS != RegQueryValueEx(hkey,
  4681. TEXT("Version"),
  4682. NULL,
  4683. &dwType,
  4684. (LPBYTE)szBuffer,
  4685. &dwSize))
  4686. {
  4687. goto IsMSDUN12InstalledExit;
  4688. }
  4689. #ifdef UNICODE
  4690. CHAR szTmp[MAX_PATH];
  4691. wcstombs(szTmp, szBuffer, MAX_PATH);
  4692. szTmp[MAX_PATH-1] = '\0';
  4693. bRC = DUN_12_Version <= atof(szTmp);
  4694. #else
  4695. bRC = DUN_12_Version <= atof(szBuffer);
  4696. #endif
  4697. IsMSDUN12InstalledExit:
  4698. if (hkey != NULL)
  4699. {
  4700. RegCloseKey(hkey);
  4701. hkey = NULL;
  4702. }
  4703. return bRC;
  4704. }
  4705. //+----------------------------------------------------------------------------
  4706. //
  4707. // Function IsScriptingInstalled
  4708. //
  4709. // Synopsis Check to see if scripting is already installed
  4710. //
  4711. // Arguments none
  4712. //
  4713. // Returns TRUE - scripting has been installed
  4714. //
  4715. // History 10/14/96 ChrisK Creaed
  4716. //
  4717. //-----------------------------------------------------------------------------
  4718. static BOOL IsScriptingInstalled()
  4719. {
  4720. BOOL bRC = FALSE;
  4721. HKEY hkey = NULL;
  4722. DWORD dwSize = 0;
  4723. DWORD dwType = 0;
  4724. LONG lrc = 0;
  4725. HINSTANCE hInst = NULL;
  4726. TCHAR szData[MAX_PATH+1];
  4727. OSVERSIONINFO osver;
  4728. //
  4729. // Check version information
  4730. //
  4731. ZeroMemory(&osver,sizeof(osver));
  4732. osver.dwOSVersionInfoSize = sizeof(osver);
  4733. GetVersionEx(&osver);
  4734. //
  4735. // check for SMMSCRPT.DLL being present
  4736. //
  4737. if (VER_PLATFORM_WIN32_NT == osver.dwPlatformId)
  4738. {
  4739. bRC = TRUE;
  4740. }
  4741. else if (IsMSDUN12Installed())
  4742. {
  4743. bRC = TRUE;
  4744. }
  4745. else
  4746. {
  4747. //
  4748. // Verify scripting by checking for smmscrpt.dll in RemoteAccess registry key
  4749. //
  4750. if (1111 <= (osver.dwBuildNumber & 0xFFFF))
  4751. {
  4752. bRC = TRUE;
  4753. }
  4754. else
  4755. {
  4756. bRC = FALSE;
  4757. hkey = NULL;
  4758. lrc=RegOpenKey(HKEY_LOCAL_MACHINE,TEXT("System\\CurrentControlSet\\Services\\RemoteAccess\\Authentication\\SMM_FILES\\PPP"),&hkey);
  4759. if (ERROR_SUCCESS == lrc)
  4760. {
  4761. dwSize = sizeof(TCHAR)*MAX_PATH;
  4762. lrc = RegQueryValueEx(hkey,TEXT("Path"),0,&dwType,(LPBYTE)szData,&dwSize);
  4763. if (ERROR_SUCCESS == lrc)
  4764. {
  4765. if (0 == lstrcmpi(szData,TEXT("smmscrpt.dll")))
  4766. bRC = TRUE;
  4767. }
  4768. }
  4769. if (hkey)
  4770. RegCloseKey(hkey);
  4771. hkey = NULL;
  4772. }
  4773. //
  4774. // Verify that the DLL can be loaded
  4775. //
  4776. if (bRC)
  4777. {
  4778. hInst = LoadLibrary(TEXT("smmscrpt.dll"));
  4779. if (hInst)
  4780. FreeLibrary(hInst);
  4781. else
  4782. bRC = FALSE;
  4783. hInst = NULL;
  4784. }
  4785. }
  4786. return bRC;
  4787. }
  4788. //+----------------------------------------------------------------------------
  4789. //
  4790. // Function InstallScripter
  4791. //
  4792. // Synopsis Install scripting on win95 950.6 builds (not on OSR2)
  4793. //
  4794. // Arguments none
  4795. //
  4796. // Returns none
  4797. //
  4798. // History 10/9/96 ChrisK Copied from mt.cpp in \\trango sources
  4799. //
  4800. //-----------------------------------------------------------------------------
  4801. static void InstallScripter(void)
  4802. {
  4803. STARTUPINFO si;
  4804. PROCESS_INFORMATION pi;
  4805. MSG msg ;
  4806. DWORD iWaitResult = 0;
  4807. HINSTANCE hInst = LoadLibrary(TEXT("smmscrpt.dll"));
  4808. DebugOut("ISIGN32: Install Scripter.\r\n");
  4809. //
  4810. // Check if we need to install scripting
  4811. //
  4812. if (!IsScriptingInstalled())
  4813. {
  4814. TCHAR szCommandLine[] = TEXT("\"icwscrpt.exe\"");
  4815. memset(&pi, 0, sizeof(pi));
  4816. memset(&si, 0, sizeof(si));
  4817. if(!CreateProcess(NULL, szCommandLine, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi))
  4818. {
  4819. DebugOut("ISIGN32: Cant find ICWSCRPT.EXE\r\n");
  4820. }
  4821. else
  4822. {
  4823. DebugOut("ISIGN32: Launched ICWSCRPT.EXE. Waiting for exit.\r\n");
  4824. //
  4825. // wait for event or msgs. Dispatch msgs. Exit when event is signalled.
  4826. //
  4827. while((iWaitResult=MsgWaitForMultipleObjects(1, &pi.hProcess, FALSE, INFINITE, QS_ALLINPUT))==(WAIT_OBJECT_0 + 1))
  4828. {
  4829. //
  4830. // read all of the messages in this next loop
  4831. // removing each message as we read it
  4832. //
  4833. while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  4834. {
  4835. DebugOut("ISIGN32: Got msg\r\n");
  4836. //
  4837. // how to handle quit message?
  4838. //
  4839. if (msg.message == WM_QUIT)
  4840. {
  4841. DebugOut("ISIGN32: Got quit msg\r\n");
  4842. goto done;
  4843. }
  4844. else
  4845. DispatchMessage(&msg);
  4846. }
  4847. }
  4848. done:
  4849. CloseHandle(pi.hThread);
  4850. CloseHandle(pi.hProcess);
  4851. DebugOut("ISIGN32: ICWSCRPT.EXE done\r\n");
  4852. }
  4853. }
  4854. }
  4855. //+----------------------------------------------------------------------------
  4856. //
  4857. // Function: FGetSystemShutdownPrivledge
  4858. //
  4859. // Synopsis: For windows NT the process must explicitly ask for permission
  4860. // to reboot the system.
  4861. //
  4862. // Arguements: none
  4863. //
  4864. // Return: TRUE - privledges granted
  4865. // FALSE - DENIED
  4866. //
  4867. // History: 8/14/96 ChrisK Created
  4868. //
  4869. // Note: BUGBUG for Win95 we are going to have to softlink to these
  4870. // entry points. Otherwise the app won't even load.
  4871. // Also, this code was originally lifted out of MSDN July96
  4872. // "Shutting down the system"
  4873. //-----------------------------------------------------------------------------
  4874. static BOOL FGetSystemShutdownPrivledge()
  4875. {
  4876. HANDLE hToken = NULL;
  4877. TOKEN_PRIVILEGES tkp;
  4878. BOOL bRC = FALSE;
  4879. OSVERSIONINFO osver;
  4880. ZeroMemory(&osver,sizeof(osver));
  4881. osver.dwOSVersionInfoSize = sizeof(osver);
  4882. if (!GetVersionEx(&osver))
  4883. goto FGetSystemShutdownPrivledgeExit;
  4884. if (VER_PLATFORM_WIN32_NT == osver.dwPlatformId)
  4885. {
  4886. //
  4887. // Get the current process token handle
  4888. // so we can get shutdown privilege.
  4889. //
  4890. if (!OpenProcessToken(GetCurrentProcess(),
  4891. TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
  4892. goto FGetSystemShutdownPrivledgeExit;
  4893. //
  4894. // Get the LUID for shutdown privilege.
  4895. //
  4896. ZeroMemory(&tkp,sizeof(tkp));
  4897. LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
  4898. &tkp.Privileges[0].Luid);
  4899. tkp.PrivilegeCount = 1; /* one privilege to set */
  4900. tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
  4901. //
  4902. // Get shutdown privilege for this process.
  4903. //
  4904. AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
  4905. (PTOKEN_PRIVILEGES) NULL, 0);
  4906. if (ERROR_SUCCESS == GetLastError())
  4907. bRC = TRUE;
  4908. }
  4909. else
  4910. {
  4911. bRC = TRUE;
  4912. }
  4913. FGetSystemShutdownPrivledgeExit:
  4914. if (hToken) CloseHandle(hToken);
  4915. return bRC;
  4916. }
  4917. //+----------------------------------------------------------------------------
  4918. // Function VerifyRasServicesRunning
  4919. //
  4920. // Synopsis Make sure that the RAS services are enabled and running
  4921. //
  4922. // Arguments HWND - parent window
  4923. //
  4924. // Return FALSE - if the services couldn't be started
  4925. //
  4926. // History 10/16/96 ChrisK Created
  4927. //-----------------------------------------------------------------------------
  4928. typedef HRESULT (WINAPI *PFINETSTARTSERVICES)(void);
  4929. #define MAX_STRING 256
  4930. static BOOL VerifyRasServicesRunning(HWND hwnd)
  4931. {
  4932. HINSTANCE hInst = NULL;
  4933. FARPROC fp = NULL;
  4934. BOOL bRC = FALSE;
  4935. HRESULT hr = ERROR_SUCCESS;
  4936. hInst = LoadLibrary(TEXT("INETCFG.DLL"));
  4937. if (hInst)
  4938. {
  4939. fp = GetProcAddress(hInst, "InetStartServices");
  4940. if (fp)
  4941. {
  4942. //
  4943. // Check Services
  4944. //
  4945. hr = ((PFINETSTARTSERVICES)fp)();
  4946. if (ERROR_SUCCESS == hr)
  4947. {
  4948. bRC = TRUE;
  4949. }
  4950. else
  4951. {
  4952. //
  4953. // Report the erorr
  4954. //
  4955. TCHAR szMsg[MAX_STRING + 1];
  4956. LoadString(
  4957. ghInstance,
  4958. IDS_SERVICEDISABLED,
  4959. szMsg,
  4960. SIZEOF_TCHAR_BUFFER(szMsg));
  4961. //
  4962. // we reach here in the condition when
  4963. // 1) user deliberately removes some file
  4964. // 2) Did not reboot after installing RAS
  4965. // MKarki - (5/7/97) - Fix for Bug #4004
  4966. //
  4967. MessageBox(
  4968. hwnd,
  4969. szMsg,
  4970. cszAppName,
  4971. MB_OK| MB_ICONERROR | MB_SETFOREGROUND
  4972. );
  4973. bRC = FALSE;
  4974. }
  4975. }
  4976. FreeLibrary(hInst);
  4977. }
  4978. #if !defined(WIN16)
  4979. if (bRC)
  4980. {
  4981. SetControlFlags(SCF_RASREADY);
  4982. }
  4983. else
  4984. {
  4985. ClearControlFlags(SCF_RASREADY);
  4986. }
  4987. #endif
  4988. return bRC;
  4989. }
  4990. //+----------------------------------------------------------------------------
  4991. //
  4992. // Function GetDeviceSelectedByUser
  4993. //
  4994. // Synopsis Get the name of the RAS device that the user had already picked
  4995. //
  4996. // Arguements szKey - name of sub key
  4997. // szBuf - pointer to buffer
  4998. // dwSize - size of buffer
  4999. //
  5000. // Return TRUE - success
  5001. //
  5002. // History 10/24/96 ChrisK Created
  5003. //-----------------------------------------------------------------------------
  5004. static BOOL GetDeviceSelectedByUser (LPTSTR szKey, LPTSTR szBuf, DWORD dwSize)
  5005. {
  5006. BOOL bRC = FALSE;
  5007. HKEY hkey = NULL;
  5008. DWORD dwType = 0;
  5009. if (ERROR_SUCCESS == RegOpenKey(HKEY_LOCAL_MACHINE,
  5010. ISIGNUP_KEY,&hkey))
  5011. {
  5012. if (ERROR_SUCCESS == RegQueryValueEx(hkey,szKey,0,&dwType,
  5013. (LPBYTE)szBuf,&dwSize))
  5014. bRC = TRUE;
  5015. }
  5016. if (hkey)
  5017. RegCloseKey(hkey);
  5018. return bRC;
  5019. }
  5020. //+----------------------------------------------------------------------------
  5021. // Function SetDeviceSelectedByUser
  5022. //
  5023. // Synopsis Write user's device selection to registry
  5024. //
  5025. // Arguments szKey - name of key
  5026. // szBuf - data to write to key
  5027. //
  5028. // Returns TRUE - success
  5029. //
  5030. // History 10/24/96 ChrisK Created
  5031. //-----------------------------------------------------------------------------
  5032. static BOOL SetDeviceSelectedByUser (LPTSTR szKey, LPTSTR szBuf)
  5033. {
  5034. BOOL bRC = FALSE;
  5035. HKEY hkey = 0;
  5036. if (ERROR_SUCCESS == RegOpenKey(HKEY_LOCAL_MACHINE,
  5037. ISIGNUP_KEY,&hkey))
  5038. {
  5039. if (ERROR_SUCCESS == RegSetValueEx(hkey,szKey,0,REG_SZ,
  5040. (LPBYTE)szBuf,sizeof(TCHAR)*lstrlen(szBuf)))
  5041. bRC = TRUE;
  5042. }
  5043. if (hkey)
  5044. RegCloseKey(hkey);
  5045. return bRC;
  5046. }
  5047. //+----------------------------------------------------------------------------
  5048. // Funciton DeleteUserDeviceSelection
  5049. //
  5050. // Synopsis Remove registry keys with device selection
  5051. //
  5052. // Arguments szKey - name of value to remove
  5053. //
  5054. // Returns TRUE - success
  5055. //
  5056. // History 10/24/96 ChrisK Created
  5057. //-----------------------------------------------------------------------------
  5058. static BOOL DeleteUserDeviceSelection(LPTSTR szKey)
  5059. {
  5060. BOOL bRC = FALSE;
  5061. HKEY hkey = NULL;
  5062. if (ERROR_SUCCESS == RegOpenKey(HKEY_LOCAL_MACHINE,
  5063. ISIGNUP_KEY,&hkey))
  5064. {
  5065. bRC = (ERROR_SUCCESS == RegDeleteValue(hkey,szKey));
  5066. RegCloseKey(hkey);
  5067. }
  5068. return bRC;
  5069. }
  5070. //+---------------------------------------------------------------------------
  5071. //
  5072. // Function: ConfigRasEntryDevice()
  5073. //
  5074. // Synopsis: Checks whether user has already specified a modem to use;
  5075. // If so, verifies that modem is valid.
  5076. // If not, or if modem is invalid, presents user a dialog
  5077. // to choose which modem to use (if only one modem is installed,
  5078. // it automaticaly selects that device and bypasses the dialog)
  5079. //
  5080. // Arguments: lpRasEntry - Pointer to the RasEntry whose szDeviceName and
  5081. // szDeviceType members you wish to verify/configure
  5082. //
  5083. // Returns: ERROR_CANCELLED - Had to bring up "Choose Modem" dialog, and
  5084. // and user hit its "Cancel" button
  5085. // Otherwise returns any error code encountered.
  5086. // ERROR_SUCCESS indicates success.
  5087. //
  5088. // History: 5/18/96 VetriV Created
  5089. //
  5090. //----------------------------------------------------------------------------
  5091. DWORD ConfigRasEntryDevice( LPRASENTRY lpRasEntry )
  5092. {
  5093. DWORD dwRet = ERROR_SUCCESS;
  5094. CEnumModem EnumModem;
  5095. GetDeviceSelectedByUser(DEVICENAMEKEY, g_szDeviceName, sizeof(g_szDeviceName));
  5096. GetDeviceSelectedByUser(DEVICETYPEKEY, g_szDeviceType, sizeof(g_szDeviceType));
  5097. dwRet = EnumModem.GetError();
  5098. if (ERROR_SUCCESS != dwRet)
  5099. {
  5100. return dwRet;
  5101. }
  5102. // If there are no modems, we're horked
  5103. if (0 == EnumModem.GetNumDevices())
  5104. {
  5105. DebugOut("ISIGN32: import.cpp: ConfigRasEntryDevice: ERROR: No modems installed!\n");
  5106. //
  5107. // ChrisK Olympus 6796 6/24/97
  5108. // If there is no modem currently configured, there will be by the time the
  5109. // connectoid is created.
  5110. //
  5111. return ERROR_SUCCESS;
  5112. }
  5113. // Validate the device if possible
  5114. if ( lpRasEntry->szDeviceName[0] && lpRasEntry->szDeviceType[0] )
  5115. {
  5116. // Verify that there is a device with the given name and type
  5117. if (!EnumModem.VerifyDeviceNameAndType(lpRasEntry->szDeviceName,
  5118. lpRasEntry->szDeviceType))
  5119. {
  5120. // There was no device that matched both name and type,
  5121. // so reset the strings and bring up the choose modem UI.
  5122. lpRasEntry->szDeviceName[0] = '\0';
  5123. lpRasEntry->szDeviceType[0] = '\0';
  5124. }
  5125. }
  5126. else if ( lpRasEntry->szDeviceName[0] )
  5127. {
  5128. // Only the name was given. Try to find a matching type.
  5129. // If this fails, fall through to recovery case below.
  5130. LPTSTR szDeviceType =
  5131. EnumModem.GetDeviceTypeFromName(lpRasEntry->szDeviceName);
  5132. if (szDeviceType)
  5133. {
  5134. lstrcpy (lpRasEntry->szDeviceType, szDeviceType);
  5135. }
  5136. }
  5137. else if ( lpRasEntry->szDeviceType[0] )
  5138. {
  5139. // Only the type was given. Try to find a matching name.
  5140. // If this fails, fall through to recovery case below.
  5141. LPTSTR szDeviceName =
  5142. EnumModem.GetDeviceNameFromType(lpRasEntry->szDeviceType);
  5143. if (szDeviceName)
  5144. {
  5145. lstrcpy (lpRasEntry->szDeviceName, szDeviceName);
  5146. }
  5147. }
  5148. // If either name or type is missing, check whether the user has already made a choice.
  5149. // if not, bring up choose modem UI if there
  5150. // are multiple devices, else just get first device.
  5151. // Since we already verified that there was at least one device,
  5152. // we can assume that this will succeed.
  5153. if( !(lpRasEntry->szDeviceName[0]) ||
  5154. !(lpRasEntry->szDeviceType[0]) )
  5155. {
  5156. DebugOut("ISIGN32: ConfigRasEntryDevice: no valid device passed in\n");
  5157. if( g_szDeviceName[0] )
  5158. {
  5159. // it looks like we have already stored the user's choice.
  5160. // store the DeviceName in lpRasEntry, then call GetDeviceTypeFromName
  5161. // to confirm that the deviceName we saved actually exists on the system
  5162. lstrcpy(lpRasEntry->szDeviceName, g_szDeviceName);
  5163. if( 0 == lstrcmp(EnumModem.GetDeviceTypeFromName(lpRasEntry->szDeviceName),
  5164. g_szDeviceType) )
  5165. {
  5166. //DebugOut("ISIGN32: ConfigRasEntryDevice using previously stored choice, '%s'\n",
  5167. // g_szDeviceName);
  5168. lstrcpy(lpRasEntry->szDeviceType, g_szDeviceType);
  5169. return ERROR_SUCCESS;
  5170. }
  5171. else
  5172. {
  5173. // whatever we previously stored has somehow gone bad; fall through to code below
  5174. //DebugOut("ISIGN32: ConfigRasEntryDevice: previously stored choice '%s' is not valid\n",
  5175. // g_szDeviceName);
  5176. }
  5177. }
  5178. if (1 == EnumModem.GetNumDevices())
  5179. {
  5180. // There is just one device installed, so copy the name
  5181. DebugOut("ISIGN32: import.cpp: ConfigRasEntryDevice: only one modem installed, using it\n");
  5182. lstrcpy (lpRasEntry->szDeviceName, EnumModem.Next());
  5183. }
  5184. else
  5185. {
  5186. DebugOut("ISIGN32: import.cpp: ConfigRasEntryDevice: multiple modems detected\n");
  5187. // structure to pass to dialog to fill out
  5188. CHOOSEMODEMDLGINFO ChooseModemDlgInfo;
  5189. // Display a dialog and allow the user to select modem
  5190. // TODO: is g_hWndMain the right thing to use for parent?
  5191. int iRet = (int)DialogBoxParam(
  5192. GetModuleHandle(TEXT("ISIGN32.DLL")),
  5193. MAKEINTRESOURCE(IDD_CHOOSEMODEMNAME),
  5194. pDynShare->hwndMain,
  5195. ChooseModemDlgProc,
  5196. (LPARAM) &ChooseModemDlgInfo);
  5197. if (0 == iRet)
  5198. {
  5199. // user cancelled
  5200. dwRet = ERROR_CANCELLED;
  5201. }
  5202. else if (-1 == iRet)
  5203. {
  5204. // an error occurred.
  5205. dwRet = GetLastError();
  5206. if (ERROR_SUCCESS == dwRet)
  5207. {
  5208. // Error occurred, but the error code was not set.
  5209. dwRet = ERROR_INETCFG_UNKNOWN;
  5210. }
  5211. }
  5212. // Copy the modem name string
  5213. lstrcpy (lpRasEntry->szDeviceName, ChooseModemDlgInfo.szModemName);
  5214. }
  5215. // Now get the type string for this modem
  5216. lstrcpy (lpRasEntry->szDeviceType,
  5217. EnumModem.GetDeviceTypeFromName(lpRasEntry->szDeviceName));
  5218. //Assert(lstrlen(lpRasEntry->szDeviceName));
  5219. //Assert(lstrlen(lpRasEntry->szDeviceType));
  5220. }
  5221. lstrcpy(g_szDeviceName, lpRasEntry->szDeviceName);
  5222. lstrcpy(g_szDeviceType, lpRasEntry->szDeviceType);
  5223. // Save data in registry
  5224. SetDeviceSelectedByUser(DEVICENAMEKEY, g_szDeviceName);
  5225. SetDeviceSelectedByUser (DEVICETYPEKEY, g_szDeviceType);
  5226. return dwRet;
  5227. }
  5228. //+----------------------------------------------------------------------------
  5229. // Function RasDial1Callback
  5230. //
  5231. // Synopsis This function will be called with RAS status information.
  5232. // For most message this function will simply pass the data on to
  5233. // the hwnd in the dialer. However, if the connection is dropped
  5234. // unexpectedly then the function will allow the user to
  5235. // reconnect. Note, the reconnection only applies to NT since
  5236. // win95 machines will automatically handle this.
  5237. //
  5238. // Arguments hrasconn, // handle to RAS connection
  5239. // unMsg, // type of event that has occurred
  5240. // rascs, // connection state about to be entered
  5241. // dwError, // error that may have occurred
  5242. // dwExtendedError // extended error information for some errors
  5243. // (See RasDialFunc for more details)
  5244. //
  5245. // Returns none
  5246. //
  5247. // History 10/28/96 ChrisK Created
  5248. //-----------------------------------------------------------------------------
  5249. VOID WINAPI RasDial1Callback(
  5250. HRASCONN hrasconn, // handle to RAS connection
  5251. UINT unMsg, // type of event that has occurred
  5252. RASCONNSTATE rascs, // connection state about to be entered
  5253. DWORD dwError, // error that may have occurred
  5254. DWORD dwExtendedError // extended error information for some errors
  5255. )
  5256. {
  5257. static BOOL fIsConnected = FALSE;
  5258. static HWND hwndDialDlg = NULL;
  5259. static DWORD dwPlatformId = 0xFFFFFFFF;
  5260. static UINT unRasMsg = 0;
  5261. OSVERSIONINFO osver;
  5262. HANDLE hThread = INVALID_HANDLE_VALUE;
  5263. DWORD dwTID = 0;
  5264. //
  5265. // Initial registration
  5266. //
  5267. if (WM_RegisterHWND == unMsg)
  5268. {
  5269. //
  5270. // dwError actually contains an HWND in this case.
  5271. //
  5272. if (hwndDialDlg)
  5273. {
  5274. DebugOut("ISIGN32: ERROR hwndDialDlg is not NULL.\r\n");
  5275. }
  5276. if (fIsConnected)
  5277. {
  5278. DebugOut("ISIGN32: ERROR fIsConnected is not FALSE.\r\n");
  5279. }
  5280. if (0xFFFFFFFF != dwPlatformId)
  5281. {
  5282. DebugOut("ISIGN32: ERROR dwPlatformId is not initial value.\r\n");
  5283. }
  5284. //
  5285. // Remember HWND value
  5286. //
  5287. hwndDialDlg = (HWND)UlongToPtr(dwError);
  5288. //
  5289. // Determine the current platform
  5290. //
  5291. ZeroMemory(&osver,sizeof(osver));
  5292. osver.dwOSVersionInfoSize = sizeof(osver);
  5293. if (GetVersionEx(&osver))
  5294. dwPlatformId = osver.dwPlatformId;
  5295. //
  5296. // Figure out ras event value
  5297. //
  5298. unRasMsg = RegisterWindowMessageA(RASDIALEVENT);
  5299. if (unRasMsg == 0) unRasMsg = WM_RASDIALEVENT;
  5300. //
  5301. // Don't call into the HWND if this is the initial call
  5302. //
  5303. goto RasDial1CallbackExit;
  5304. }
  5305. //
  5306. // Remember if the connection was successfull
  5307. //
  5308. if (RASCS_Connected == rascs)
  5309. {
  5310. fIsConnected = TRUE;
  5311. if (VER_PLATFORM_WIN32_NT == dwPlatformId)
  5312. {
  5313. hThread = CreateThread(NULL,0,
  5314. (LPTHREAD_START_ROUTINE)StartNTReconnectThread,
  5315. (LPVOID)hrasconn,0,&dwTID);
  5316. if (hThread)
  5317. CloseHandle(hThread);
  5318. else
  5319. DebugOut("ISIGN32: Failed to start reconnect thread.\r\n");
  5320. }
  5321. }
  5322. //
  5323. // Pass the message on to the Dialing dialog
  5324. //
  5325. if (IsWindow(hwndDialDlg))
  5326. {
  5327. if (WM_RASDIALEVENT == unMsg)
  5328. {
  5329. if (0 == unRasMsg)
  5330. {
  5331. DebugOut("ISIGN32: ERROR we are about to send message 0. Very bad...\r\n");
  5332. }
  5333. SendMessage(hwndDialDlg,unRasMsg,(WPARAM)rascs,(LPARAM)dwError);
  5334. }
  5335. else
  5336. {
  5337. SendMessage(hwndDialDlg,unMsg,(WPARAM)rascs,(LPARAM)dwError);
  5338. }
  5339. }
  5340. RasDial1CallbackExit:
  5341. return;
  5342. }
  5343. //+----------------------------------------------------------------------------
  5344. // Function SLRasConnectionNotification
  5345. //
  5346. // Synopsis Soft link to RasConnectionNotification
  5347. //
  5348. // Arguments hrasconn - handle to connection
  5349. // hEvent - handle to event
  5350. // dwFlags - flags to determine the type of notification
  5351. //
  5352. // Returns ERROR_SUCCESS - if successful
  5353. //
  5354. // History 10/29/96 ChrisK Created
  5355. //-----------------------------------------------------------------------------
  5356. typedef DWORD (APIENTRY *PFNRASCONNECTIONNOTIFICATION)( HRASCONN, HANDLE, DWORD );
  5357. // 1/7/96 jmazner already defined in ras2.h
  5358. //#define RASCN_Disconnection 2
  5359. #define CONNECT_CHECK_INTERVAL 500
  5360. static DWORD SLRasConnectionNotification(HRASCONN hrasconn, HANDLE hEvent, DWORD dwFlags)
  5361. {
  5362. DWORD dwRC = ERROR_DLL_NOT_FOUND;
  5363. FARPROC fp = NULL;
  5364. HINSTANCE hinst = NULL;
  5365. if(hinst = LoadLibrary(TEXT("RASAPI32.DLL")))
  5366. #ifdef UNICODE
  5367. if (fp = GetProcAddress(hinst,"RasConnectionNotificationW"))
  5368. #else
  5369. if (fp = GetProcAddress(hinst,"RasConnectionNotificationA"))
  5370. #endif
  5371. dwRC = ((PFNRASCONNECTIONNOTIFICATION)fp)(hrasconn, hEvent, dwFlags);
  5372. if (hinst)
  5373. FreeLibrary(hinst);
  5374. return dwRC;
  5375. }
  5376. //+----------------------------------------------------------------------------
  5377. // Function IsConnectionClosed
  5378. //
  5379. // Synopsis Given a particular connection handle, determine if the
  5380. // connection is still valid
  5381. //
  5382. // Arguments hrasconn - handle to the connection to be checked
  5383. //
  5384. // Returns TRUE - if the connection is closed
  5385. //
  5386. // History 10/29/96 ChrisK Created
  5387. //-----------------------------------------------------------------------------
  5388. static BOOL IsConnectionClosed(HRASCONN hrasconn)
  5389. {
  5390. BOOL bRC = FALSE;
  5391. LPRASCONN lprasconn = NULL;
  5392. DWORD dwSize = 0;
  5393. DWORD cConnections = 0;
  5394. DWORD dwRet = 0;
  5395. //
  5396. // Make sure the DLL is loaded
  5397. //
  5398. if (!lpfnRasEnumConnections)
  5399. if (!LoadRnaFunctions(NULL))
  5400. goto IsConnectionClosedExit;
  5401. //
  5402. // Get list of current connections
  5403. //
  5404. lprasconn = (LPRASCONN)GlobalAlloc(GPTR,sizeof(RASCONN));
  5405. if (!lprasconn)
  5406. goto IsConnectionClosedExit;
  5407. lprasconn->dwSize = dwSize = sizeof(RASCONN);
  5408. cConnections = 0;
  5409. dwRet = lpfnRasEnumConnections(lprasconn, &dwSize, &cConnections);
  5410. if (ERROR_BUFFER_TOO_SMALL == dwRet)
  5411. {
  5412. GlobalFree(lprasconn);
  5413. lprasconn = (LPRASCONN)GlobalAlloc(GPTR,dwSize);
  5414. if (!lprasconn)
  5415. goto IsConnectionClosedExit;
  5416. lprasconn->dwSize = dwSize;
  5417. dwRet = lpfnRasEnumConnections(lprasconn, &dwSize, &cConnections);
  5418. }
  5419. if (ERROR_SUCCESS != dwRet)
  5420. goto IsConnectionClosedExit;
  5421. //
  5422. // Check to see if the handle matches
  5423. //
  5424. while (cConnections)
  5425. {
  5426. if (lprasconn[cConnections-1].hrasconn == hrasconn)
  5427. goto IsConnectionClosedExit; // The connection is still open
  5428. cConnections--;
  5429. }
  5430. bRC = TRUE;
  5431. IsConnectionClosedExit:
  5432. if (lprasconn)
  5433. GlobalFree(lprasconn);
  5434. return bRC;
  5435. }
  5436. //+----------------------------------------------------------------------------
  5437. // Function StartNTReconnectThread
  5438. //
  5439. // Synopsis This function will detect when the connection has been dropped
  5440. // unexpectedly and it will then offer the user a chance to
  5441. // reconnect
  5442. //
  5443. // Arguments hrasconn - the connection to be watched
  5444. //
  5445. // Returns none
  5446. //
  5447. // History 10/29/96 ChrisK Created
  5448. //-----------------------------------------------------------------------------
  5449. DWORD WINAPI StartNTReconnectThread (HRASCONN hrasconn)
  5450. {
  5451. TCHAR szEntryName[RAS_MaxEntryName + 1];
  5452. DWORD dwRC = 0;
  5453. //
  5454. // Validate state
  5455. //
  5456. if (NULL == hrasconn)
  5457. goto StartNTReconnectThreadExit;
  5458. if (TestControlFlags(SCF_RECONNECTTHREADQUITED) != FALSE)
  5459. goto StartNTReconnectThreadExit;
  5460. if (NULL != pDynShare->hReconnectEvent)
  5461. goto StartNTReconnectThreadExit;
  5462. //
  5463. // Register Event
  5464. //
  5465. pDynShare->hReconnectEvent = CreateEvent(NULL,FALSE,FALSE,NULL);
  5466. if (NULL == pDynShare->hReconnectEvent)
  5467. goto StartNTReconnectThreadExit;
  5468. if (0 != SLRasConnectionNotification(hrasconn, pDynShare->hReconnectEvent,RASCN_Disconnection))
  5469. goto StartNTReconnectThreadExit;
  5470. //
  5471. // Wait for event
  5472. //
  5473. do {
  5474. dwRC = WaitForSingleObject(pDynShare->hReconnectEvent,CONNECT_CHECK_INTERVAL);
  5475. if (WAIT_FAILED == dwRC)
  5476. {
  5477. DebugOut("ISIGN32: Quitting reconnect thread because wait failed.\r\n");
  5478. goto StartNTReconnectThreadExit;
  5479. }
  5480. } while ((WAIT_TIMEOUT == dwRC) && !IsConnectionClosed(hrasconn));
  5481. //
  5482. // Clear values
  5483. //
  5484. hrasconn = NULL;
  5485. CloseHandle(pDynShare->hReconnectEvent);
  5486. pDynShare->hReconnectEvent = NULL;
  5487. //
  5488. // Determine if we should offer to reconnect
  5489. //
  5490. if (FALSE != TestControlFlags(SCF_RECONNECTTHREADQUITED))
  5491. {
  5492. DebugOut("ISIGN32: Quitting reconnect thread because app is quitting.\r\n");
  5493. goto StartNTReconnectThreadExit;
  5494. }
  5495. else if (FALSE == TestControlFlags(SCF_HANGUPEXPECTED))
  5496. {
  5497. DebugOut("ISIGN32: Reconnect thread will ask about reconnecting.\r\n");
  5498. TCHAR szMsg[MAX_STRING + 1];
  5499. //
  5500. // Prompt user
  5501. //
  5502. LoadString(ghInstance,IDS_RECONNECT_QUERY,szMsg,SIZEOF_TCHAR_BUFFER(szMsg));
  5503. if (IDYES == MessageBox(
  5504. pDynShare->hwndMain,
  5505. szMsg,
  5506. cszAppName,
  5507. MB_SETFOREGROUND | MB_ICONEXCLAMATION | MB_YESNO))
  5508. {
  5509. //
  5510. // Reconnect
  5511. //
  5512. if (ERROR_USERNEXT != DialConnection(pDynShare->szISPFile))
  5513. {
  5514. DebugOut("ISIGN32: Quitting reconnect thread because user canceled dialing.\r\n");
  5515. KillConnection();
  5516. InfoMsg(NULL, IDS_SIGNUPCANCELLED);
  5517. PostMessage(pDynShare->hwndMain, WM_CLOSE, 0, 0);
  5518. goto StartNTReconnectThreadExit;
  5519. }
  5520. }
  5521. else
  5522. {
  5523. //
  5524. // Forget it, we're out of here (close down signup)
  5525. //
  5526. KillConnection();
  5527. InfoMsg(NULL, IDS_SIGNUPCANCELLED);
  5528. PostMessage(pDynShare->hwndMain, WM_CLOSE, 0, 0);
  5529. DebugOut("ISIGN32: Quitting reconnect thread because user doesn't want to reconnect.\r\n");
  5530. goto StartNTReconnectThreadExit;
  5531. }
  5532. }
  5533. StartNTReconnectThreadExit:
  5534. return 1;
  5535. }
  5536. //+----------------------------------------------------------------------------
  5537. // Function IsSingleInstance and ReleaseSingleInstance
  5538. //
  5539. // Synopsis These two function check to see if another instance of isignup
  5540. // is already running. ISign32 does have to allow mutliple instances
  5541. // to run in order to handle the .INS files, but in other instances
  5542. // there should only be one copy running at a time
  5543. //
  5544. // Arguments bProcessingINS -- are we in the .ins path?
  5545. //
  5546. // Returns IsSingleInstance - TRUE - this is the first instance
  5547. // ReleaseSingleInstance - none
  5548. //
  5549. // History 11/1/96 ChrisK Created
  5550. // 12/3/96 jmazner Modified to allow the processINS path to create
  5551. // a semaphore (to prevent others from running),
  5552. // but to not check whether the create succeeded.
  5553. //-----------------------------------------------------------------------------
  5554. // superceded by definition in semaphor.h
  5555. //#define SEMAPHORE_NAME "Internet Connection Wizard ISIGNUP.EXE"
  5556. BOOL IsSingleInstance(BOOL bProcessingINS)
  5557. {
  5558. g_hSemaphore = CreateSemaphore(NULL, 1, 1, ICW_ELSE_SEMAPHORE);
  5559. DWORD dwErr = GetLastError();
  5560. if( ERROR_ALREADY_EXISTS == dwErr )
  5561. {
  5562. g_hSemaphore = NULL;
  5563. if( !bProcessingINS )
  5564. IsAnotherComponentRunning32( NULL );
  5565. return FALSE;
  5566. }
  5567. return TRUE;
  5568. }
  5569. void ReleaseSingleInstance()
  5570. {
  5571. if (g_hSemaphore)
  5572. {
  5573. CloseHandle(g_hSemaphore);
  5574. g_hSemaphore = NULL;
  5575. }
  5576. return;
  5577. }
  5578. //+---------------------------------------------------------------------------
  5579. //
  5580. // Function: IsAnotherComponentRunning32()
  5581. //
  5582. // Synopsis: Checks if there's another ICW component already
  5583. // running. If so, it will set focus to that component's window.
  5584. //
  5585. // This functionality is needed by all of our .exe's. However,
  5586. // the actual components to check for differ between .exe's.
  5587. // The comment COMPONENT SPECIFIC designates lines of code
  5588. // that vary between components' source code.
  5589. //
  5590. // For ISIGN32, this function only gets called if we couldn't create
  5591. // the ICW_ELSE semaphore, so all we need to do here is find the
  5592. // other running ICW_ELSE component and bring it to the foreground.
  5593. //
  5594. // Arguments: bUnused -- not used in this component
  5595. //
  5596. // Returns: TRUE if another component is already running
  5597. // FALSE otherwise
  5598. //
  5599. // History: 12/3/96 jmazner Created, with help from IsAnotherInstanceRunning
  5600. // in icwconn1\connmain.cpp
  5601. //
  5602. //----------------------------------------------------------------------------
  5603. BOOL IsAnotherComponentRunning32(BOOL bUnused)
  5604. {
  5605. HWND hWnd = NULL;
  5606. HANDLE hSemaphore = NULL;
  5607. DWORD dwErr = 0;
  5608. // for isignup, we only get here if we failed to create the ICW_ELSE semaphore
  5609. // try and bring focus to the IE window if we have one
  5610. if( pDynShare->hwndBrowser )
  5611. {
  5612. SetFocus(pDynShare->hwndBrowser);
  5613. SetForegroundWindow(pDynShare->hwndBrowser);
  5614. }
  5615. else
  5616. {
  5617. // if that didn't work, try finding a conn2 or inetwiz instance
  5618. // Bring the running instance's window to the foreground
  5619. // if conn1 is running, we may accidentaly bring it to the foreground,
  5620. // since it shares a window name with conn2 and inetwiz. oh well.
  5621. hWnd = FindWindow(DIALOG_CLASS_NAME, cszAppName);
  5622. if( hWnd )
  5623. {
  5624. SetFocus(hWnd);
  5625. SetForegroundWindow(hWnd);
  5626. }
  5627. }
  5628. return TRUE;
  5629. /**
  5630. if( hWnd || hwndBrowser )
  5631. {
  5632. return TRUE;
  5633. }
  5634. else
  5635. {
  5636. return FALSE;
  5637. }
  5638. **/
  5639. }
  5640. #endif //!WIN16
  5641. #if !defined(WIN16)
  5642. //+----------------------------------------------------------------------------
  5643. //
  5644. // Function SetStartUpCommand
  5645. //
  5646. // Synopsis On an NT machine the RunOnce method is not reliable. Therefore
  5647. // we will restart the ICW by placing a .BAT file in the common
  5648. // startup directory.
  5649. //
  5650. // Arguments lpCmd - command line used to restart the ICW
  5651. //
  5652. // Returns TRUE if it worked
  5653. // FALSE otherwise.
  5654. //
  5655. // History 1-10-97 ChrisK Created
  5656. //
  5657. //-----------------------------------------------------------------------------
  5658. static const TCHAR cszICW_StartFileName[] = TEXT("ICWStart.bat");
  5659. static const TCHAR cszICW_StartCommand[] = TEXT("@start ");
  5660. static const TCHAR cszICW_DummyWndName[] = TEXT("\"ICW\" ");
  5661. static const TCHAR cszICW_ExitCommand[] = TEXT("\r\n@exit");
  5662. BOOL SetStartUpCommand(LPTSTR lpCmd)
  5663. {
  5664. BOOL bRC = FALSE;
  5665. HANDLE hFile = INVALID_HANDLE_VALUE ;
  5666. DWORD dwWLen; // dummy variable used to make WriteFile happy
  5667. TCHAR szCommandLine[MAX_PATH + 1];
  5668. LPITEMIDLIST lpItemDList = NULL;
  5669. HRESULT hr = ERROR_SUCCESS;
  5670. IMalloc *pMalloc = NULL;
  5671. // build full filename
  5672. // NOTE: the memory allocated for lpItemDList is leaked. We are not real
  5673. // concerned about this since this code is only run once and then the
  5674. // system is restarted. In order to free the memory appropriately
  5675. // this code would have to call SHGetMalloc to retrieve the shell's IMalloc
  5676. // implementation and then free the memory.
  5677. hr = SHGetSpecialFolderLocation(NULL,CSIDL_COMMON_STARTUP,&lpItemDList);
  5678. if (ERROR_SUCCESS != hr)
  5679. goto SetStartUpCommandExit;
  5680. if (FALSE == SHGetPathFromIDList(lpItemDList, szCommandLine))
  5681. goto SetStartUpCommandExit;
  5682. //
  5683. // Free up the memory allocated for LPITEMIDLIST
  5684. // because seems like we are clobberig something later
  5685. // by not freeing this
  5686. //
  5687. hr = SHGetMalloc (&pMalloc);
  5688. if (SUCCEEDED (hr))
  5689. {
  5690. pMalloc->Free (lpItemDList);
  5691. pMalloc->Release ();
  5692. }
  5693. // make sure there is a trailing \ character
  5694. if ('\\' != szCommandLine[lstrlen(szCommandLine)-1])
  5695. lstrcat(szCommandLine,TEXT("\\"));
  5696. lstrcat(szCommandLine,cszICW_StartFileName);
  5697. // Open file
  5698. hFile = CreateFile(szCommandLine,GENERIC_WRITE,0,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL |
  5699. FILE_FLAG_WRITE_THROUGH,NULL);
  5700. if (INVALID_HANDLE_VALUE == hFile)
  5701. goto SetStartUpCommandExit;
  5702. // Write the restart commands to the file
  5703. if (FALSE == WriteFile(hFile,cszICW_StartCommand,lstrlen(cszICW_StartCommand),&dwWLen,NULL))
  5704. goto SetStartUpCommandExit;
  5705. // 1/20/96 jmazner Normandy #13287
  5706. // Start command considers the first thing it sees in quotes to be a window title
  5707. // So, since our path is in quotes, put in a fake window title
  5708. if (FALSE == WriteFile(hFile,cszICW_DummyWndName,lstrlen(cszICW_DummyWndName),&dwWLen,NULL))
  5709. goto SetStartUpCommandExit;
  5710. if (FALSE == WriteFile(hFile,lpCmd,lstrlen(lpCmd),&dwWLen,NULL))
  5711. goto SetStartUpCommandExit;
  5712. if (FALSE == WriteFile(hFile,cszICW_ExitCommand,lstrlen(cszICW_ExitCommand),&dwWLen,NULL))
  5713. goto SetStartUpCommandExit;
  5714. bRC = TRUE;
  5715. SetStartUpCommandExit:
  5716. // Close handle and exit
  5717. if (INVALID_HANDLE_VALUE != hFile)
  5718. CloseHandle(hFile);
  5719. return bRC;
  5720. }
  5721. //+----------------------------------------------------------------------------
  5722. //
  5723. // Function: DeleteStartUpCommand
  5724. //
  5725. // Synopsis: After restart the ICW we need to delete the .bat file from
  5726. // the common startup directory
  5727. //
  5728. // Arguements: None
  5729. //
  5730. // Returns: None
  5731. //
  5732. // History: 1-10-97 ChrisK Created
  5733. //
  5734. //-----------------------------------------------------------------------------
  5735. void DeleteStartUpCommand ()
  5736. {
  5737. TCHAR szStartUpFile[MAX_PATH + 1];
  5738. LPITEMIDLIST lpItemDList = NULL;
  5739. HRESULT hr = ERROR_SUCCESS;
  5740. IMalloc *pMalloc = NULL;
  5741. // build full filename
  5742. // NOTE: the memory allocated for lpItemDList is leaked. We are not real
  5743. // concerned about this since this code is only run once and then the
  5744. // system is restarted. In order to free the memory appropriately
  5745. // this code would have to call SHGetMalloc to retrieve the shell's IMalloc
  5746. // implementation and then free the memory.
  5747. hr = SHGetSpecialFolderLocation(NULL,CSIDL_COMMON_STARTUP,&lpItemDList);
  5748. if (ERROR_SUCCESS != hr)
  5749. goto DeleteStartUpCommandExit;
  5750. if (FALSE == SHGetPathFromIDList(lpItemDList, szStartUpFile))
  5751. goto DeleteStartUpCommandExit;
  5752. //
  5753. // Free up the memory allocated for LPITEMIDLIST
  5754. // because seems like we are clobberig something later
  5755. // by not freeing this
  5756. //
  5757. hr = SHGetMalloc (&pMalloc);
  5758. if (SUCCEEDED (hr))
  5759. {
  5760. pMalloc->Free (lpItemDList);
  5761. pMalloc->Release ();
  5762. }
  5763. // make sure there is a trailing \ character
  5764. if ('\\' != szStartUpFile[lstrlen(szStartUpFile)-1])
  5765. lstrcat(szStartUpFile,TEXT("\\"));
  5766. lstrcat(szStartUpFile,cszICW_StartFileName);
  5767. DeleteFile(szStartUpFile);
  5768. DeleteStartUpCommandExit:
  5769. return;
  5770. }
  5771. #endif //!Win16
  5772. #ifdef WIN32
  5773. BOOL GetICWCompleted( DWORD *pdwCompleted )
  5774. {
  5775. HKEY hKey = NULL;
  5776. DWORD dwSize = sizeof(DWORD);
  5777. HRESULT hr = RegOpenKey(HKEY_CURRENT_USER,ICWSETTINGSPATH,&hKey);
  5778. if (ERROR_SUCCESS == hr)
  5779. {
  5780. hr = RegQueryValueEx(hKey, ICWCOMPLETEDKEY, 0, NULL,
  5781. (BYTE*)pdwCompleted, &dwSize);
  5782. RegCloseKey(hKey);
  5783. }
  5784. if( ERROR_SUCCESS == hr )
  5785. return TRUE;
  5786. else
  5787. return FALSE;
  5788. }
  5789. BOOL SetICWCompleted( DWORD dwCompleted )
  5790. {
  5791. HKEY hKey = NULL;
  5792. HRESULT hr = RegCreateKey(HKEY_CURRENT_USER,ICWSETTINGSPATH,&hKey);
  5793. if (ERROR_SUCCESS == hr)
  5794. {
  5795. hr = RegSetValueEx(hKey, ICWCOMPLETEDKEY, 0, REG_DWORD,
  5796. (CONST BYTE*)&dwCompleted, sizeof(dwCompleted));
  5797. RegCloseKey(hKey);
  5798. }
  5799. if( ERROR_SUCCESS == hr )
  5800. return TRUE;
  5801. else
  5802. return FALSE;
  5803. }
  5804. #endif
  5805. #ifdef WIN32
  5806. //+----------------------------------------------------------------------------
  5807. //
  5808. // Function: CreateSecurityPatchBackup
  5809. //
  5810. // Synopsis: Creates a .reg file to restore security settings, and installs
  5811. // the filenmae into the RunOnce reg keys.
  5812. //
  5813. // Arguements: None
  5814. //
  5815. // Returns: None
  5816. //
  5817. // History: 8/7/97 jmazner Created for Olympus #6059
  5818. //
  5819. //-----------------------------------------------------------------------------
  5820. BOOL CreateSecurityPatchBackup( void )
  5821. {
  5822. Dprintf("ISIGN32: CreateSecurityPatchBackup\n");
  5823. HKEY hKey = NULL;
  5824. TCHAR szPath[MAX_PATH + 1] = TEXT("\0");
  5825. HANDLE hSecureRegFile = INVALID_HANDLE_VALUE;
  5826. TCHAR szRegText[1024];
  5827. TCHAR szRunOnceEntry[1024];
  5828. DWORD dwBytesWritten = 0;
  5829. if (0 == GetTempPath(MAX_PATH,szPath))
  5830. {
  5831. //
  5832. // if GetTempPath Failed, use the current directory
  5833. //
  5834. if (0 == GetCurrentDirectory (MAX_PATH, szPath))
  5835. {
  5836. Dprintf("ISIGN32: unable to get temp path or current directory!\n");
  5837. return FALSE;
  5838. }
  5839. }
  5840. //
  5841. // Get the name of the temporary file
  5842. //
  5843. if (0 == GetTempFileName(szPath, TEXT("hyjk"), 0, pDynShare->szFile))
  5844. {
  5845. //
  5846. // If we failed, probably, the TMP directory does not
  5847. // exist, we should use the current directory
  5848. // MKarki (4/27/97) - Fix for Bug #3504
  5849. //
  5850. if (0 == GetCurrentDirectory (MAX_PATH, szPath))
  5851. {
  5852. return FALSE;
  5853. }
  5854. //
  5855. // try getting the temp file name again
  5856. //
  5857. if (0 == GetTempFileName(szPath, TEXT("hyjk"), 0, pDynShare->szFile))
  5858. {
  5859. return FALSE;
  5860. }
  5861. }
  5862. hSecureRegFile = CreateFile(pDynShare->szFile,
  5863. GENERIC_WRITE,
  5864. 0, //no sharing
  5865. NULL, //no inheritance allowed
  5866. CREATE_ALWAYS,
  5867. FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH,
  5868. NULL //no template file
  5869. );
  5870. if (INVALID_HANDLE_VALUE == hSecureRegFile)
  5871. {
  5872. Dprintf("ISIGN32: unable to createFile secureRegFile %s\n", pDynShare->szFile);
  5873. return FALSE;
  5874. }
  5875. else
  5876. {
  5877. Dprintf("ISIGN32: writing secureRegFile %s\n",pDynShare->szFile );
  5878. ZeroMemory( szRegText, 1023 );
  5879. dwBytesWritten = 0;
  5880. lstrcpy(szRegText, TEXT("REGEDIT4\n\n"));
  5881. lstrcat(szRegText, TEXT("[HKEY_CLASSES_ROOT\\.ins]\n"));
  5882. lstrcat(szRegText, TEXT("\"EditFlags\"=hex:00,00,00,00\n\n"));
  5883. lstrcat(szRegText, TEXT("[HKEY_CLASSES_ROOT\\.isp]\n"));
  5884. lstrcat(szRegText, TEXT("\"EditFlags\"=hex:00,00,00,00\n\n"));
  5885. lstrcat(szRegText, TEXT("[HKEY_CLASSES_ROOT\\x-internet-signup]\n"));
  5886. lstrcat(szRegText, TEXT("\"EditFlags\"=hex:00,00,00,00\n\n"));
  5887. //
  5888. // ChrisK Olympus 6198 6/10/97
  5889. //
  5890. lstrcat(szRegText, TEXT("[HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3]\n"));
  5891. lstrcat(szRegText, TEXT("\"1601\"=dword:"));
  5892. TCHAR szZoneSetting[16];
  5893. wsprintf(szZoneSetting,TEXT("%08x\n\n"),g_dwZone_1601);
  5894. lstrcat(szRegText, szZoneSetting);
  5895. WriteFile(hSecureRegFile, (LPVOID) &szRegText[0], lstrlen(szRegText),
  5896. &dwBytesWritten, NULL );
  5897. CloseHandle(hSecureRegFile);
  5898. hSecureRegFile = INVALID_HANDLE_VALUE;
  5899. Dprintf("ISIGN32: installing security RunOnce entry\n");
  5900. ZeroMemory(szRunOnceEntry, 1023 );
  5901. wsprintf(szRunOnceEntry, TEXT("regedit /s \"%s\""), pDynShare->szFile);
  5902. if (ERROR_SUCCESS == RegOpenKey(HKEY_LOCAL_MACHINE,TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce"),&hKey))
  5903. {
  5904. RegSetValueEx(hKey,TEXT("hyjk"),(DWORD)NULL,(DWORD)REG_SZ,
  5905. (BYTE*)szRunOnceEntry,sizeof(TCHAR)*lstrlen(szRunOnceEntry));
  5906. RegCloseKey(hKey);
  5907. hKey = NULL;
  5908. }
  5909. }
  5910. return TRUE;
  5911. }
  5912. //+----------------------------------------------------------------------------
  5913. //
  5914. // Function: RestoreSecurityPatch
  5915. //
  5916. // Synopsis: Reset the EditFlags for our file types to indicate that these
  5917. // files are not safe. Remove the runOnce we set as a backup.
  5918. //
  5919. // Arguements: None
  5920. //
  5921. // Returns: None
  5922. //
  5923. // History: 3/11/97 jmazner created for Olympus #1545
  5924. //
  5925. //-----------------------------------------------------------------------------
  5926. VOID RestoreSecurityPatch( void )
  5927. {
  5928. HKEY hKey = NULL;
  5929. TCHAR szTemp[4];
  5930. hKey = NULL;
  5931. szTemp[0] = (TCHAR)0;
  5932. szTemp[1] = (TCHAR)0;
  5933. szTemp[2] = (TCHAR)0;
  5934. szTemp[3] = (TCHAR)0;
  5935. Dprintf("ISIGN32: Restoring EditFlags settings\n");
  5936. // Mark various registry entries as unsafe.
  5937. if (ERROR_SUCCESS == RegOpenKey(HKEY_CLASSES_ROOT,TEXT("x-internet-signup"),&hKey))
  5938. {
  5939. RegSetValueEx(hKey,TEXT("EditFlags"),(DWORD)NULL,(DWORD)REG_BINARY,(BYTE*)&szTemp[0],(DWORD)4);
  5940. RegCloseKey(hKey);
  5941. }
  5942. if (ERROR_SUCCESS == RegOpenKey(HKEY_CLASSES_ROOT,TEXT(".ins"),&hKey))
  5943. {
  5944. RegSetValueEx(hKey,TEXT("EditFlags"),(DWORD)NULL,(DWORD)REG_BINARY,(BYTE*)&szTemp[0],(DWORD)4);
  5945. RegCloseKey(hKey);
  5946. }
  5947. if (ERROR_SUCCESS == RegOpenKey(HKEY_CLASSES_ROOT,TEXT(".isp"),&hKey))
  5948. {
  5949. RegSetValueEx(hKey,TEXT("EditFlags"),(DWORD)NULL,(DWORD)REG_BINARY,(BYTE*)&szTemp[0],(DWORD)4);
  5950. RegCloseKey(hKey);
  5951. }
  5952. //
  5953. // ChrisK Olympus 6198 6/10/97
  5954. // replace HTML form submission value.
  5955. //
  5956. if (g_fReadZone &&
  5957. ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER,REG_ZONE3_KEY,&hKey))
  5958. {
  5959. //
  5960. // Set value for zone to initial value.
  5961. //
  5962. RegSetValueEx(hKey,
  5963. REG_ZONE1601_KEY,
  5964. NULL,
  5965. REG_DWORD,
  5966. (LPBYTE)&g_dwZone_1601,
  5967. sizeof(g_dwZone_1601));
  5968. RegCloseKey(hKey);
  5969. }
  5970. // Remove run once key
  5971. if (ERROR_SUCCESS == RegOpenKey(HKEY_LOCAL_MACHINE,TEXT("Software\\microsoft\\Windows\\CurrentVersion\\RunOnce"),&hKey))
  5972. {
  5973. RegDeleteValue(hKey,TEXT("hyjk"));
  5974. RegCloseKey(hKey);
  5975. }
  5976. // Remove reg file
  5977. DeleteFile(pDynShare->szFile);
  5978. }
  5979. #endif
  5980. #ifdef WIN32
  5981. //++--------------------------------------------------------------
  5982. //
  5983. // Function: RemoveQuotes
  5984. //
  5985. // Synopsis: This Function strips the file name in the command
  5986. // line of its quote
  5987. // Fix For Bug #4049
  5988. //
  5989. // Arguments: [IN] PTSTR - pointer to command line
  5990. //
  5991. // Returns: VOID
  5992. //
  5993. // Called By: Signup Function
  5994. //
  5995. // History: MKarki Created 5/1/97
  5996. //
  5997. //----------------------------------------------------------------
  5998. VOID
  5999. RemoveQuotes (
  6000. LPTSTR pCommandLine
  6001. )
  6002. {
  6003. const TCHAR QUOTE = '"';
  6004. const TCHAR SPACE = ' ';
  6005. const TCHAR NIL = '\0';
  6006. TCHAR * pTemp = NULL;
  6007. if (NULL == pCommandLine)
  6008. return;
  6009. //
  6010. // find the starting quote first
  6011. // do we care for MBCS/UNICODE ?
  6012. //
  6013. pTemp = _tcschr (pCommandLine, QUOTE);
  6014. if (NULL != pTemp)
  6015. {
  6016. //
  6017. // replace the quote with a space
  6018. //
  6019. *pTemp = SPACE;
  6020. //
  6021. // search for the ending quote now
  6022. //
  6023. pTemp = _tcsrchr (pCommandLine, QUOTE);
  6024. if (NULL != pTemp)
  6025. {
  6026. //
  6027. // end the string here
  6028. //
  6029. *pTemp = NIL;
  6030. }
  6031. }
  6032. return;
  6033. } // end of RemoveQuotes function
  6034. #endif
  6035. //++--------------------------------------------------------------
  6036. //
  6037. // Function: IEAKProcessISP
  6038. //
  6039. // Synopsis: A hacked version of ProcessISP, intended for use
  6040. // by the IEAK folks. The function will create a
  6041. // connectoid and establish a connection in the same
  6042. // manner as ProcsesISP. However, once the connection
  6043. // is established, we will execute the command in the
  6044. // [Entry] Run= section and exit
  6045. //
  6046. // This function does _not_ wait around for the
  6047. // .exe that it launches, and thus does _not_ kill the
  6048. // dial-up connection. It's up to the calling app to
  6049. // worry about that.
  6050. //
  6051. // Arguments: [IN] hwnd - handle of parent window
  6052. // [IN] LPCTSTR - pointer to path to .isp file
  6053. //
  6054. // Returns: TRUE if able to create the connectoid and dial
  6055. // FALSE otherwise
  6056. //
  6057. //
  6058. // History: 5/23/97 jmazner Created for Olympus #4679
  6059. //
  6060. //----------------------------------------------------------------
  6061. #ifdef WIN16
  6062. extern "C" BOOL WINAPI __export IEAKProcessISP(HWND hwnd, LPCTSTR lpszFile)
  6063. #else
  6064. #ifdef UNICODE
  6065. BOOL EXPORT WINAPI IEAKProcessISPW(HWND, LPCTSTR);
  6066. BOOL EXPORT WINAPI IEAKProcessISPA
  6067. (
  6068. HWND hwnd,
  6069. LPCSTR lpszFile
  6070. )
  6071. {
  6072. TCHAR szFile[MAX_PATH+1];
  6073. mbstowcs(szFile, lpszFile, lstrlenA(lpszFile)+1);
  6074. return IEAKProcessISPW(hwnd, szFile);
  6075. }
  6076. BOOL EXPORT WINAPI IEAKProcessISPW
  6077. #else
  6078. BOOL EXPORT WINAPI IEAKProcessISPA
  6079. #endif
  6080. (
  6081. HWND hwnd,
  6082. LPCTSTR lpszFile
  6083. )
  6084. #endif
  6085. {
  6086. TCHAR szSignupURL[MAX_URL + 1];
  6087. #if !defined(WIN16)
  6088. HKEY hKey;
  6089. GATHEREDINFO gi;
  6090. #endif //!WIN16
  6091. #if !defined(WIN16)
  6092. if (!IsSingleInstance(FALSE))
  6093. return FALSE;
  6094. #endif
  6095. if (!LoadInetFunctions(hwnd))
  6096. {
  6097. Dprintf("ISIGN32: IEAKProcessISP couldn't load INETCFG.DLL!");
  6098. return FALSE;
  6099. }
  6100. #if !defined(WIN16)
  6101. // Make sure the isp file exists before setting up stack.
  6102. if (0xFFFFFFFF == GetFileAttributes(lpszFile))
  6103. {
  6104. DWORD dwFileErr = GetLastError();
  6105. Dprintf("ISIGN32: ProcessISP couldn't GetAttrib for %s, error = %d",
  6106. lpszFile, dwFileErr);
  6107. if( ERROR_FILE_NOT_FOUND == dwFileErr )
  6108. {
  6109. ErrorMsg1(hwnd, IDS_INVALIDCMDLINE, lpszFile);
  6110. }
  6111. ErrorMsg(hwnd, IDS_BADSIGNUPFILE);
  6112. return FALSE;
  6113. }
  6114. #endif
  6115. // Configure stack if not already configured.
  6116. // If this requires a restart, we're in trouble, so
  6117. // just return FALSE.
  6118. #ifdef SETUPSTACK
  6119. if (!TestControlFlags(SCF_SYSTEMCONFIGURED))
  6120. {
  6121. DWORD dwRet;
  6122. BOOL fNeedsRestart = FALSE;
  6123. dwRet = lpfnInetConfigSystem(
  6124. hwnd,
  6125. INETCFG_INSTALLRNA |
  6126. INETCFG_INSTALLTCP |
  6127. INETCFG_INSTALLMODEM |
  6128. INETCFG_SHOWBUSYANIMATION |
  6129. INETCFG_REMOVEIFSHARINGBOUND,
  6130. &fNeedsRestart);
  6131. if (ERROR_SUCCESS == dwRet)
  6132. {
  6133. SetControlFlags(SCF_SYSTEMCONFIGURED);
  6134. InstallScripter();
  6135. if (fNeedsRestart)
  6136. {
  6137. Dprintf("ISIGN32: IEAKProcessISP needs to restart!");
  6138. return FALSE;
  6139. }
  6140. }
  6141. else
  6142. {
  6143. ErrorMsg(hwnd, IDS_INSTALLFAILED);
  6144. return FALSE;
  6145. }
  6146. }
  6147. if (!VerifyRasServicesRunning(hwnd))
  6148. return FALSE;
  6149. #endif
  6150. // kill the old connection
  6151. KillConnection();
  6152. // Create a new connectoid and set the autodial
  6153. if (ERROR_SUCCESS != CreateConnection(lpszFile))
  6154. {
  6155. ErrorMsg(hwnd, IDS_BADSIGNUPFILE);
  6156. return FALSE;
  6157. }
  6158. #ifndef WIN16
  6159. //
  6160. // Dial connectoid
  6161. //
  6162. if (ERROR_USERNEXT != DialConnection(lpszFile))
  6163. {
  6164. Dprintf("ISIGN32: IEAKProcessISP unable to DialConnection!");
  6165. return FALSE;
  6166. }
  6167. #endif
  6168. if (GetPrivateProfileString(cszEntrySection,
  6169. cszRun,
  6170. szNull,
  6171. pDynShare->szRunExecutable,
  6172. SIZEOF_TCHAR_BUFFER(pDynShare->szRunExecutable),
  6173. lpszFile) != 0)
  6174. {
  6175. GetPrivateProfileString(cszEntrySection,
  6176. cszArgument,
  6177. szNull,
  6178. pDynShare->szRunArgument,
  6179. SIZEOF_TCHAR_BUFFER(pDynShare->szRunArgument),
  6180. lpszFile);
  6181. if (RunExecutable(FALSE) != ERROR_SUCCESS)
  6182. {
  6183. // make sure the connection is closed
  6184. KillConnection();
  6185. ErrorMsg1(NULL, IDS_EXECFAILED, pDynShare->szRunExecutable);
  6186. return FALSE;
  6187. }
  6188. }
  6189. DeleteConnection();
  6190. UnloadInetFunctions();
  6191. #if !defined(WIN16)
  6192. ReleaseSingleInstance();
  6193. #endif
  6194. return( TRUE );
  6195. }
  6196. #ifdef WIN16
  6197. CHAR* GetPassword()
  6198. {
  6199. return pDynShare->szPassword;
  6200. }
  6201. #else
  6202. TCHAR* GetPassword()
  6203. {
  6204. return pDynShare->szPassword;
  6205. }
  6206. BOOL IsRASReady()
  6207. {
  6208. return TestControlFlags(SCF_RASREADY);
  6209. }
  6210. #endif
  6211. BOOL IsCurrentlyProcessingISP()
  6212. {
  6213. #if !defined(WIN16)
  6214. return TestControlFlags(SCF_ISPPROCESSING);
  6215. #else
  6216. return FALSE;
  6217. #endif
  6218. }
  6219. BOOL NeedBackupSecurity()
  6220. {
  6221. #if !defined(WIN16)
  6222. return TestControlFlags(SCF_NEEDBACKUPSECURITY);
  6223. #else
  6224. return FALSE;
  6225. #endif
  6226. }
  6227. HWND GetHwndMain()
  6228. {
  6229. return pDynShare->hwndMain;
  6230. }