Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

259 lines
6.8 KiB

  1. #include "priv.h"
  2. #include <iethread.h>
  3. #include "hnfblock.h"
  4. #ifdef UNIX
  5. #include "unixstuff.h"
  6. #endif
  7. BOOL _GetToken(LPCWSTR *ppszCmdLine, LPWSTR szToken, UINT cchMax)
  8. {
  9. LPCWSTR pszCmdLine = *ppszCmdLine;
  10. WCHAR chTerm = L' ';
  11. if (*pszCmdLine == L'"') {
  12. chTerm = L'"';
  13. pszCmdLine++;
  14. }
  15. UINT ichToken = 0;
  16. WCHAR ch;
  17. while((ch=*pszCmdLine) && (ch != chTerm)) {
  18. if (ichToken < cchMax-1) {
  19. szToken[ichToken++] = ch;
  20. }
  21. pszCmdLine++;
  22. }
  23. szToken[ichToken] = L'\0';
  24. if (chTerm == L'"' && ch == L'"') {
  25. pszCmdLine++;
  26. }
  27. // skip trailing spaces
  28. while(*pszCmdLine == L' ')
  29. pszCmdLine++;
  30. *ppszCmdLine = pszCmdLine;
  31. TraceMsgW(TF_SHDAUTO, "_GetToken returning %s (+%s)", szToken, pszCmdLine);
  32. return szToken[0];
  33. }
  34. BOOL _CheckForOptionOnCmdLine(LPCWSTR *ppszCmdLine, LPCWSTR pszOption)
  35. {
  36. LPCWSTR pszCmdLine = *ppszCmdLine;
  37. int cch = lstrlenW(pszOption);
  38. if (0 == StrCmpNIW(pszCmdLine, pszOption, cch))
  39. {
  40. pszCmdLine+= cch;
  41. while(*pszCmdLine == L' ')
  42. pszCmdLine++;
  43. *ppszCmdLine = pszCmdLine;
  44. return TRUE;
  45. }
  46. return FALSE;
  47. }
  48. BOOL IsCalleeIEAK()
  49. {
  50. // APPCOMPAT: this is hack so as to allow IEAK CD install to continue without
  51. // any security restrictions. If the IEAK CD install window name changes
  52. // the name change should also reflect here.
  53. return (FindWindow(TEXT("IECD"), NULL) != NULL);
  54. }
  55. BOOL SHParseIECommandLine(LPCWSTR *ppwszCmdLine, IETHREADPARAM * piei)
  56. {
  57. ASSERT(ppwszCmdLine);
  58. ASSERT(*ppwszCmdLine);
  59. LPCWSTR pszCmdLine = *ppwszCmdLine;
  60. #ifdef UNIX
  61. if( CheckForInvalidOptions( *ppwszCmdLine ) == FALSE )
  62. {
  63. piei->fShouldStart = FALSE;
  64. return FALSE;
  65. }
  66. // Options valid.
  67. piei->fShouldStart = TRUE;
  68. #endif
  69. TraceMsg(TF_SHDAUTO, "SHParseIECommandLine called with %s", pszCmdLine);
  70. BOOL fDontLookForPidl = FALSE; // A flag option is set, so don't go looking for an open window
  71. // with the same pidl
  72. // FEATURE: (dli) what if there is a window opened with the same flags?
  73. while (*pszCmdLine == L'-')
  74. {
  75. fDontLookForPidl = TRUE;
  76. //Note: (dli)These flags are supposed to be set to FALSE at initialization
  77. // check if -nohome was passed in!
  78. //
  79. if (_CheckForOptionOnCmdLine(&pszCmdLine, L"-slf") && !IsOS(OS_WIN2000ORGREATER) && IsCalleeIEAK())
  80. piei->fNoLocalFileWarning = TRUE;
  81. else if (_CheckForOptionOnCmdLine(&pszCmdLine, L"-nohome"))
  82. piei->fDontUseHomePage = TRUE;
  83. else if (_CheckForOptionOnCmdLine(&pszCmdLine, L"-k"))
  84. {
  85. piei->fFullScreen = TRUE;
  86. piei->fNoDragDrop = TRUE;
  87. }
  88. else if (_CheckForOptionOnCmdLine(&pszCmdLine, L"-embedding"))
  89. {
  90. piei->fAutomation = TRUE;
  91. // if we're started as an embedding, we don't want to go to our start page
  92. piei->fDontUseHomePage = TRUE;
  93. }
  94. #ifndef UNIX
  95. else if (_CheckForOptionOnCmdLine(&pszCmdLine, L"-channelband"))
  96. {
  97. piei->fDesktopChannel = TRUE;
  98. }
  99. else if (_CheckForOptionOnCmdLine(&pszCmdLine, L"-e"))
  100. {
  101. piei->uFlags |= COF_EXPLORE;
  102. }
  103. #else
  104. else if (_CheckForOptionOnCmdLine(&pszCmdLine, L"-help"))
  105. {
  106. piei->fShouldStart = FALSE;
  107. PrintIEHelp();
  108. break;
  109. }
  110. else if (_CheckForOptionOnCmdLine(&pszCmdLine, L"-v") ||
  111. _CheckForOptionOnCmdLine(&pszCmdLine, L"-version"))
  112. {
  113. piei->fShouldStart = FALSE;
  114. PrintIEVersion();
  115. break;
  116. }
  117. #endif
  118. else if (_CheckForOptionOnCmdLine(&pszCmdLine, L"-root"))
  119. {
  120. ASSERT(piei->pidlRoot==NULL);
  121. WCHAR szRoot[MAX_PATH];
  122. if (_GetToken(&pszCmdLine, szRoot, ARRAYSIZE(szRoot)))
  123. {
  124. CLSID clsid, *pclsid = NULL;
  125. TraceMsgW(TF_SHDAUTO, "SHParseIECommandLine got token for /root %s", szRoot);
  126. if (GUIDFromString(szRoot, &clsid))
  127. {
  128. pclsid = &clsid;
  129. _GetToken(&pszCmdLine, szRoot, ARRAYSIZE(szRoot));
  130. }
  131. if (szRoot[0])
  132. {
  133. LPITEMIDLIST pidlRoot = ILCreateFromPathW(szRoot);
  134. if (pidlRoot)
  135. {
  136. piei->pidl = ILRootedCreateIDList(pclsid, pidlRoot);
  137. ILFree(pidlRoot);
  138. }
  139. }
  140. }
  141. }
  142. else
  143. {
  144. #ifdef UNIX
  145. piei->fShouldStart = FALSE;
  146. #endif
  147. // unknown option..
  148. fDontLookForPidl = FALSE;
  149. break;
  150. }
  151. }
  152. *ppwszCmdLine = pszCmdLine;
  153. return fDontLookForPidl;
  154. }
  155. IETHREADPARAM* SHCreateIETHREADPARAM(LPCWSTR pszCmdLineIn, int nCmdShowIn, ITravelLog *ptlIn, IEFreeThreadedHandShake* piehsIn)
  156. {
  157. IETHREADPARAM *piei = (IETHREADPARAM *)LocalAlloc(LPTR, sizeof(IETHREADPARAM));
  158. if (piei)
  159. {
  160. piei->pszCmdLine = pszCmdLineIn; // careful, aliased pointer
  161. piei->nCmdShow = nCmdShowIn;
  162. piei->ptl = ptlIn;
  163. piei->piehs = piehsIn;
  164. if (piehsIn)
  165. piehsIn->AddRef();
  166. if (ptlIn)
  167. ptlIn->AddRef();
  168. #ifdef UNIX
  169. piei->fShouldStart = TRUE;
  170. #endif
  171. #ifdef NO_MARSHALLING
  172. piei->fOnIEThread = TRUE;
  173. #endif
  174. }
  175. return piei;
  176. }
  177. IETHREADPARAM* SHCloneIETHREADPARAM(IETHREADPARAM* pieiIn)
  178. {
  179. IETHREADPARAM *piei = (IETHREADPARAM *)LocalAlloc(LPTR, sizeof(IETHREADPARAM));
  180. if (piei)
  181. {
  182. *piei = *pieiIn;
  183. // convert aliased pointers into refs
  184. if (piei->pidl)
  185. piei->pidl = ILClone(piei->pidl);
  186. if (piei->pidlSelect)
  187. piei->pidlSelect = ILClone(piei->pidlSelect);
  188. if (piei->pidlRoot)
  189. piei->pidlRoot = ILClone(piei->pidlRoot);
  190. if (piei->psbCaller)
  191. piei->psbCaller->AddRef();
  192. if (piei->ptl)
  193. piei->ptl->Clone(&piei->ptl);
  194. }
  195. return piei;
  196. }
  197. void SHDestroyIETHREADPARAM(IETHREADPARAM* piei)
  198. {
  199. if (piei)
  200. {
  201. if (piei->pidl)
  202. ILFree(piei->pidl);
  203. if (piei->pidlSelect)
  204. ILFree(piei->pidlSelect);
  205. if (((piei->uFlags & COF_HASHMONITOR) == 0) && piei->pidlRoot)
  206. ILFree(piei->pidlRoot);
  207. if (piei->piehs)
  208. piei->piehs->Release(); // note, this is not a COM object, don't ATOMICRELEASE();
  209. ATOMICRELEASE(piei->psbCaller);
  210. ATOMICRELEASE(piei->pSplash);
  211. ATOMICRELEASE(piei->ptl);
  212. ATOMICRELEASE(piei->punkRefProcess);
  213. LocalFree(piei);
  214. }
  215. }