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.

2104 lines
75 KiB

  1. #ifndef _CDL_H_
  2. #define _CDL_H_
  3. #define MAX_DEBUG_STRING_LENGTH 2048
  4. #define MAX_DEBUG_FORMAT_STRING_LENGTH 1024
  5. #define MAX_VERSIONLENGTH 27 // sizeof(2DWORDS)/(log 10 base 2) + 3 (seperators)
  6. // == 64/3 + 3 == 25
  7. // CDL.h
  8. // Code Downloader header file
  9. //
  10. // Read "class descriptions" first for understanding how the
  11. // code downloader works.
  12. #define STRING(x) (((x) != NULL) ? (x) : (L"(null)"))
  13. #ifndef ARRAY_ELEMENTS
  14. #define ARRAY_ELEMENTS(array) \
  15. (sizeof(array)/sizeof(array[0]))
  16. #endif /* ARRAY_ELEMENTS */
  17. #include <safeocx.h>
  18. #include "debmacro.h"
  19. #include <msxml.h>
  20. #include "wvtp.h"
  21. //#include "..\inc\clist.hxx"
  22. #ifndef unix
  23. #include "..\utils\coll.hxx"
  24. #else
  25. #include "../utils/coll.hxx"
  26. #endif /* !unix */
  27. #include "packet.hxx"
  28. #include "shlwapi.h"
  29. #include "strids.h"
  30. #include <pkgmgr.h>
  31. #ifdef WX86
  32. #ifdef __cplusplus // make classes invisible to 'C'
  33. // Support for multiple architectures during code download. This must
  34. // be declared before softdist.hxx can be included.
  35. class CMultiArch {
  36. public:
  37. CMultiArch() { m_RequiredArch = PROCESSOR_ARCHITECTURE_UNKNOWN; };
  38. DWORD GetRequiredArch() { return m_RequiredArch;}
  39. HRESULT RequirePrimaryArch();
  40. HRESULT RequireAlternateArch();
  41. VOID SelectArchitecturePreferences(
  42. char *szNativeArch,
  43. char *szIntelArch,
  44. char **pszPreferredArch,
  45. char **pszAlternateArch);
  46. private:
  47. DWORD m_RequiredArch;
  48. };
  49. #endif
  50. #endif
  51. #include "softdist.hxx"
  52. #include <capi.h>
  53. #define MAX_REGSTR_LEN 1024
  54. #define DU_TAG_SOFTDIST L"SOFTPKG"
  55. #define DU_TAG_NATIVECODE L"msicd::NativeCode"
  56. #define DU_TAG_JAVA L"msicd::Java"
  57. #define DU_TAG_EXPIRE L"msicd::Expire"
  58. #define DU_TAG_UNINSTALL_OLD L"msicd::UninstallOld"
  59. #define INF_TAG_UNINSTALL_OLD "UninstallOld"
  60. #define DU_TAG_CODE L"Code"
  61. #define DU_TAG_CODEBASE L"CodeBase"
  62. #define DU_TAG_PACKAGE L"Package"
  63. #define DU_TAG_TITLE L"TITLE"
  64. #define DU_TAG_ABSTRACT L"ABSTRACT"
  65. #define DU_TAG_LANG L"LANGUAGE"
  66. #define DU_TAG_DEPENDENCY L"Dependency"
  67. #define DU_TAG_PROCESSOR L"Processor"
  68. #define DU_TAG_PLATFORM L"Platform"
  69. #define DU_TAG_CONFIG L"IMPLEMENTATION"
  70. #define DU_TAG_USAGE L"Usage"
  71. #define DU_TAG_OS L"OS"
  72. #define DU_TAG_OSVERSION L"OSVersion"
  73. #define DU_TAG_NAMESPACE L"NameSpace"
  74. #define DU_TAG_DELETEONINSTALL L"DeleteOnInstall"
  75. #define DU_ATTRIB_NAME L"NAME"
  76. #define DU_ATTRIB_FILENAME L"FILENAME"
  77. #define DU_ATTRIB_VALUE L"VALUE"
  78. #define DU_ATTRIB_VERSION L"VERSION"
  79. #define DU_ATTRIB_STYLE L"STYLE"
  80. #define DU_ATTRIB_SIZE L"SIZE"
  81. #define DU_ATTRIB_PRECACHE L"PRECACHE"
  82. #define DU_ATTRIB_AUTOINSTALL L"AUTOINSTALL"
  83. #define DU_ATTRIB_EMAIL L"EMAIL"
  84. #define DU_ATTRIB_HREF L"HREF"
  85. #define DU_ATTRIB_ACTION L"ACTION"
  86. #define DU_ATTRIB_CLSID L"CLASSID"
  87. #define DU_ATTRIB_DL_GROUP L"GROUP"
  88. #define DU_ATTRIB_RANDOM L"RANDOM"
  89. #define DU_STYLE_MSICD "MSICD"
  90. #define DU_STYLE_ACTIVE_SETUP "ActiveSetup"
  91. #define DU_STYLE_MSINSTALL "MSInstall.SoftDist"
  92. #define DU_STYLE_LOGO3 "MSAppLogo5"
  93. #define DU_TAG_SYSTEM L"System"
  94. // Used by JAVA
  95. #define DU_TAG_NEEDSTRUSTEDSOURCE L"NeedsTrustedSource"
  96. #define CHANNEL_ATTRIB_BASE L"BASE"
  97. #define MAX_EXPIRE_DAYS 3650
  98. #ifdef __cplusplus
  99. extern "C" {
  100. #endif
  101. #include "fdi.h"
  102. #ifndef DEB_CODEDL
  103. #define DEB_CODEDL 1
  104. #endif
  105. // JIT Window data
  106. #define JIT_DIALOG_CLASS_NAME "Internet Explorer_TridentDlgFrame"
  107. #define JIT_DIALOG_CAPTION "Internet Explorer Install on Demand"
  108. // return value from the JIT setup page.
  109. #define JITPAGE_RETVAL_SUCCESS 0x0 // successfully installed
  110. #define JITPAGE_RETVAL_CANCELLED 0x1 // was cancelled by user
  111. #define JITPAGE_RETVAL_DONTASK_THISWINDOW 0x2 // don;t ask again in this
  112. // window
  113. #define JITPAGE_RETVAL_DONTASK_EVER 0x3 // don't ask ever. user
  114. // goes to addon page to
  115. // install
  116. #define JITPAGE_RETVAL_NEED_REBOOT ERROR_SUCCESS_REBOOT_REQUIRED
  117. // FaultInIEFeature flags
  118. // urlmon.idl flag definition
  119. // internal flags are here
  120. #define FIEF_FLAG_CHECK_CIFVERSION 0x100 // checks if requested version
  121. // can be installed by JIT
  122. #define REGSTR_PATH_INFODEL_REST "Software\\Policies\\Microsoft\\Internet Explorer\\Infodelivery\\Restrictions"
  123. #define REGVAL_JIT_REST "NoJITSetup"
  124. #define REGKEY_WEBJITURLS "Software\\Microsoft\\Active Setup\\WebJITURLS"
  125. #define REGVAL_WEBJIT_REST "NoWebJITSetup"
  126. #define REGVAL_UI_REST "NoWinVerifyTrustUI"
  127. // registry paths for ModuleUsage
  128. #define REGSTR_PATH_SHAREDDLLS "Software\\Microsoft\\Windows\\CurrentVersion\\SharedDlls"
  129. #define REGSTR_PATH_MODULE_USAGE "Software\\Microsoft\\Windows\\CurrentVersion\\ModuleUsage"
  130. #define REGSTR_PATH_CODE_STORE "Software\\Microsoft\\Code Store Database"
  131. #define REGSTR_PATH_DIST_UNITS "Software\\Microsoft\\Code Store Database\\Distribution Units"
  132. #define REGSTR_PATH_JAVA_PKGS "Software\\Microsoft\\Code Store Database\\Java Packages"
  133. #define REGSTR_PATH_IE_SETTINGS "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"
  134. #define REGSTR_PATH_IE_MAIN "Software\\Microsoft\\Internet Explorer\\Main"
  135. #define REGSTR_PATH_LOGO3_SETTINGS "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
  136. #define REGVAL_LOGO3_MAJORVERSION "VersionMajor"
  137. #define REGVAL_LOGO3_MINORVERSION "VersionMinor"
  138. #define REGSTR_LOGO3_ADVERTISED_VERSION "AdvertisedVersion"
  139. #define REGKEY_LOGO3_AVAILABLE_VERSION "AvailableVersion"
  140. #define REGSTR_PATH_NT5_LOCKDOWN_TEST "Software\\Microsoft\\Code Store Database\\NT5LockDownTest"
  141. #define REGVAL_USE_COINSTALL "UseCoInstall"
  142. // If you modify this then make appropriate entries in urlmon\dll\selfreg.inx
  143. // to clean this out on urlmon dlluninstall
  144. // this key will be renamed before ship of each major release
  145. // so we won't remember the rejected features in PP1 and not prompt for final
  146. // release
  147. #define REGKEY_DECLINED_COMPONENTS "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Declined Components IE5"
  148. #define REGKEY_DECLINED_IOD "Software\\Microsoft\\Active Setup\\Declined Install On Demand IEv5"
  149. #define REGKEY_ACTIVESETUP_COMPONENTS "Software\\Microsoft\\Active Setup\\Installed Components"
  150. #define REGKEY_ACTIVESETUP "Software\\Microsoft\\Active Setup"
  151. #define REGKEY_ACTIVESETUP_CLSIDFEATURE "Software\\Microsoft\\Active Setup\\ClsidFeature"
  152. #define REGKEY_ACTIVESETUP_MIMEFEATURE "Software\\Microsoft\\Active Setup\\MimeFeature"
  153. #define REGKEY_ACTIVESETUP_FEATURECOMPID "Software\\Microsoft\\Active Setup\\FeatureComponentID"
  154. #define REGVAL_VERSION_AVAILABLE "Version available"
  155. #define REGVAL_VERSION_ADVERTISED "Version advertised"
  156. #define REGVAL_ABSTRACT_AVAILABLE "Abstract"
  157. #define REGVAL_TITLE_AVAILABLE "Title available"
  158. #define REGVAL_HREF_AVAILABLE "HREF available"
  159. #define REGVAL_FIRST_HOME_PAGE "First Home Page"
  160. #define REGKEY_MSICD_ADVERTISED_VERSION "AdvertisedVersion"
  161. #define REGVAL_ADSTATE "AdState"
  162. #define DISTUNIT_NAME_IE4 "{89820200-ECBD-11cf-8B85-00AA005B4383}"
  163. // Code Download Setup Flags
  164. // DWORD g_dwCodeDownloadSetupFlags = 0;
  165. typedef enum {
  166. CDSF_INIT,
  167. CDSF_USE_SETUPAPI
  168. } CodeDownloadSetupFlags;
  169. // buffer size for downloads in CBSC::m_cbuffer
  170. #define BUFFERMAX 2048
  171. // File Name List
  172. //
  173. // used as pFilesToExtract to track files in the CAB we need extracted
  174. //
  175. // or a pFileList in PSESSION
  176. //
  177. // We keep track of all files that are in a cabinet
  178. // keeping their names in a list and when the download
  179. // is complete we use this list to delete temp files
  180. struct sFNAME {
  181. LPSTR pszFilename;
  182. struct sFNAME *pNextName;
  183. DWORD status; /* out */
  184. };
  185. typedef struct sFNAME FNAME;
  186. typedef FNAME *PFNAME;
  187. // SFNAME.status: success is 0 or non-zero error code in extraction
  188. #define SFNAME_INIT 1
  189. #define SFNAME_EXTRACTED 0
  190. // FILE extentions we know about
  191. typedef enum {
  192. FILEXTN_NONE,
  193. FILEXTN_UNKNOWN,
  194. FILEXTN_CAB,
  195. FILEXTN_DLL,
  196. FILEXTN_OCX,
  197. FILEXTN_INF,
  198. FILEXTN_EXE,
  199. FILEXTN_OSD,
  200. FILEXTN_CAT
  201. } FILEXTN;
  202. //
  203. // Master State Information for File Extraction: used by extract.c
  204. //
  205. typedef struct {
  206. UINT cbCabSize;
  207. ERF erf;
  208. PFNAME pFileList; // List of Files in CAB
  209. UINT cFiles;
  210. DWORD flags; // flags: see below for list
  211. char achLocation[MAX_PATH]; // Dest Dir
  212. char achFile[MAX_PATH]; // Current File
  213. char achCabPath[MAX_PATH]; // Current Path to cabs
  214. PFNAME pFilesToExtract; // files to extract;null=enumerate only
  215. } SESSION, *PSESSION;
  216. typedef enum {
  217. SESSION_FLAG_NONE = 0x0,
  218. SESSION_FLAG_ENUMERATE = 0x1,
  219. SESSION_FLAG_EXTRACT_ALL = 0x2,
  220. SESSION_FLAG_EXTRACTED_ALL = 0x4
  221. } SESSION_FLAGS;
  222. typedef struct CodeDownloadDataTag {
  223. LPCWSTR szDistUnit; // Distribution unit to look for
  224. LPCWSTR szClassString; // clsid (or class string) of object desired
  225. LPCWSTR szURL; // codebase to download
  226. LPCWSTR szMimeType; // mime type (com translate -> clsid)
  227. LPCWSTR szExtension; // extension (com translate -> clsid)
  228. LPCWSTR szDll; // dll to load object from after download (for zero impact)
  229. DWORD dwFileVersionMS; // file version
  230. DWORD dwFileVersionLS;
  231. DWORD dwFlags; // flags
  232. } CodeDownloadData;
  233. #define chPATH_SEP1 '\\'
  234. #define chPATH_SEP2 '/'
  235. #define chDRIVE_SEP ':'
  236. // size of [Add.Code] section in INF in bytes
  237. #define MAX_INF_SECTIONS_SIZE 1024
  238. // from extract.c
  239. HRESULT Extract(PSESSION psess, LPCSTR lpCabName);
  240. HRESULT ExtractFromCabinet(PSESSION ps, LPCSTR lpCabFileName);
  241. VOID DeleteExtractedFiles(PSESSION psess);
  242. BOOL catDirAndFile(
  243. char *pszResult,
  244. int cbResult,
  245. char *pszDir,
  246. char *pszFile);
  247. #ifdef __cplusplus
  248. }
  249. #endif
  250. #define CHECK_ERROR_EXIT(cond, iResID) if (!(cond)) { \
  251. if (iResID) \
  252. CodeDownloadDebugOut(DEB_CODEDL, TRUE, iResID); \
  253. goto Exit;}
  254. // Download states that a CDownload passes thru from obj creation to done.
  255. typedef enum {
  256. DLSTATE_INIT, // obj constructed
  257. DLSTATE_BINDING, // download in progress
  258. DLSTATE_DOWNLOADED, // at begining of OnStopBinding
  259. DLSTATE_EXTRACTING, // begin CAB extraction (where applicable)
  260. DLSTATE_INF_PROCESSING, // begin ProcessInf (where applicable)
  261. DLSTATE_READY_TO_SETUP, // end of OnStopBinding
  262. DLSTATE_SETUP, // Start DoSetup
  263. DLSTATE_DONE, // all done, ready to free obj,
  264. // delete temp files
  265. DLSTATE_ABORT // aborted this download
  266. } DLSTATE;
  267. // INSTALL_STATE used to give BINDSTATUS_INSTALLING_COMPONENTS OnProgress
  268. // during setup phase
  269. // given as INSTALL_COPY of INSTALL_PHASES, szStatusText pointing to filename
  270. typedef enum {
  271. INSTALL_INIT = 0,
  272. INSTALL_VERIFY = 1,
  273. INSTALL_COPY = 2,
  274. INSTALL_REGISTER =3,
  275. INSTALL_PHASES = 4
  276. } INSTALL_STATE;
  277. #define INSTALL_DONE INSTALL_PHASES
  278. // directions to CSetup on dest dir for file if no prev version exists
  279. typedef enum {
  280. LDID_OCXCACHE=0, // ocxcache dir, now = windows\ocxcache
  281. LDID_WIN=10, // INF convetion to mean windows dir
  282. LDID_SYS=11 // INF convetion to mean sysdir
  283. } DESTINATION_DIR ;
  284. // Software distribution styles
  285. typedef enum {
  286. STYLE_UNKNOWN = -1, // Unknown otherwise.
  287. STYLE_MSICD = 1,
  288. STYLE_ACTIVE_SETUP,
  289. STYLE_LOGO3,
  290. STYLE_MSINSTALL, // Darwin
  291. STYLE_OTHER // Provides own ISoftDistExt interface for access
  292. };
  293. #ifdef __cplusplus // make classes invisible to 'C'
  294. #include "langcode.h"
  295. // <Config> tag processor. Shared by Code Download and CSoftDist.
  296. HRESULT ProcessImplementation(IXMLElement *pConfig,
  297. CList<CCodeBaseHold *, CCodeBaseHold *> *pcbhList,
  298. LCID lcidOverride,
  299. #ifdef WX86
  300. CMultiArch *MultiArch,
  301. #endif
  302. LPWSTR szBaseURL = NULL);
  303. HRESULT ProcessCodeBaseList(IXMLElement *pCodeBase,
  304. CList<CCodeBaseHold *, CCodeBaseHold *> *pcbhList,
  305. LPWSTR szBaseURL = NULL);
  306. // %%Classes: ----------------------------------------------------------------
  307. /*
  308. * class descriptions
  309. *
  310. * CCodeDownload (main class tracking as a whole)
  311. * It has the client's BSC and creates a CClBinding for client.
  312. *
  313. * CClBinding (For client's IBinding for code download)
  314. *
  315. * CDownload (tracks individual downloads) implements a
  316. *
  317. * CBindStatusCallback (BSC)
  318. *
  319. * Csetup obj: zero or more associated with every CDownload obj
  320. * Some CDownload's may have no CSetup (eg. INF file)
  321. *
  322. *
  323. *
  324. *
  325. * We do our code download in 2 stages.
  326. * 1) download stage
  327. * 2) setup and registeration stage
  328. *
  329. * CCodeDownload is the main class for codedownload.
  330. * AsyncGetClassBits() the entry into the Code downloader creates this obj
  331. * for the given CODE, CLSID, FileVersion, BSC (from BindCtx)
  332. * we do not check to see if a code download is already in progress
  333. * in the system at a given moment. Nor we do we keep track of individual
  334. * downloads and possible clashes between various silmultaneous code
  335. * downloads system wide. We leave it to URL moniker (above us) to ensure
  336. * that duplicate calls are not made into AsynGetClassBits. The second
  337. * problem of different code downloads trying to bring down a common
  338. * dependent DLL is POSTPONED to version 2 implementation.
  339. *
  340. * The CodeDownload obj once created is asked to perform its function
  341. * thru CCodeDownload::DoCodeDownload().
  342. * This triggers creation of the first CDownload object for the CODE url
  343. * if a local check for CLSID,FileVersion returns update_needed.
  344. * (note : it is interesting to note here that if a control needs to just
  345. * update a dependent DLL file it still needs to update the FileVersion
  346. * of the primary control file (with CLSID implementation) for triggering
  347. * any download at all!
  348. *
  349. * Once DoCodeDownload determines that an update is in order it creates
  350. * a CClBinding for its client to call client BSC::OnstartBinding with.
  351. *
  352. * It then adds this CDownload obj to its list of downloads.
  353. *
  354. * If the m_url is a CAB or INF we need to download it before we know
  355. * what we need to do next. Otherwise we create a CSetup obj for the
  356. * download and add it to CDownload's list of pending Setup processing for
  357. * stage 2 (setup and registeration). CSetup details later.
  358. *
  359. * CDownload is the basic download obj. It's action entry point is DoDownload
  360. * Here it creates a URL moniker for the given m_url and a bind ctx to go
  361. * with it and then calls pmk->BindToStorage to get the bits. Note how we
  362. * use URL mon's services to get the bits even as URLmon is our client for
  363. * the Code Download. We are its client for individual downloads. CDownload
  364. * has a BSC implementation to track progress and completion. This BSC is
  365. * where the magic of taking us from one state to next occurs.
  366. *
  367. * BSC::OnProgress
  368. * Here we get the master CodeDownload obj to collate progress and report
  369. * cumulative code download progress to client BSC::OnProgress.
  370. *
  371. * BSC::OnDataAvailable
  372. * At the last notification we get the filename URLmon has downloaded the
  373. * m_url data to and rename it to a file in the temp dir.
  374. *
  375. * BSC:: OnStopBinding
  376. * we get here when we have fully downloaded 'this'. this is the place
  377. * to call into WinVerifyTrust api if appropriate
  378. * This triggers a change state in our state machine. Depending on the
  379. * obj we have downloaded (a CAB or INF or DLL/OCX/EXE) we:
  380. *
  381. * OCX:
  382. * Csetup for this download is usually previously created
  383. * mark this download as done and
  384. * call into main CodeDownload::CompleteOne (state analyser)
  385. *
  386. * CAB:
  387. * if we don't have an INF already we look for one in the CAB
  388. * if INF in CAB
  389. * process INF (may trigger further extractions/downloads/Csetup)
  390. * else
  391. * look for primary OCX in CAB and create CSetup or it.
  392. *
  393. * INF:
  394. * Process INF
  395. *
  396. * CCodeDownload::CompleteOne is called whenever a CDownload obj completes
  397. * its download and initiates further downloads if necessary (eg. ProcessInf)
  398. * It does nothing until all pending downloads are complete. Until then it
  399. * just returns and we unwind back to BSC::OnStopBinding
  400. *
  401. * When all downloads completed, we then start processingall the Csetups
  402. * We do this code download in two stages to
  403. * keep capability to back out of entire code download for as late as we can
  404. * until the setup stage calling CClBinding::Abort with IBinding returned by
  405. * code downloader in client's BSC::OnStartBinding will cleanly abort and
  406. * restore initial state.
  407. * We don't honor Abort once in setup stage.
  408. *
  409. * To keep this stage as clean and failsafe as we can we check for
  410. * disk space in the OCX cache as well as check for IN USE OCXes that we
  411. * plan on updating. We abort on either of these two conditions.
  412. *
  413. * CCodeDownload::CompleteOne than proceeds to walk thru all its download objs
  414. * calling DoSetup which in turn causes CSetup::DoSetup() to get invoked
  415. * for every CSetup.
  416. *
  417. * In the guts of Csetup we move the temp OCX file to the dest dir ( usually
  418. * OCXCACHE dir unless upgrading over previous version), and we call
  419. * register OCX (if version info suggests so)
  420. *
  421. * When done with the setup stage CompleteOne calls client's BSC::OnStopBinding
  422. * and then frees all memory and clens up temp files.
  423. *
  424. */
  425. class CLocalComponentInfo {
  426. public:
  427. CLocalComponentInfo();
  428. ~CLocalComponentInfo();
  429. HRESULT MakeDestDir();
  430. BOOL IsPresent() { return (dwLocFVMS | dwLocFVLS); }
  431. BOOL IsLastModifiedTimeAvailable() {
  432. return ( ftLastModified.dwHighDateTime | ftLastModified.dwLowDateTime);
  433. }
  434. FILETIME * GetLastModifiedTime() {
  435. return IsLastModifiedTimeAvailable()?&ftLastModified:NULL;
  436. }
  437. LPSTR GetLocalVersionEtag() { return pbEtag;}
  438. LCID GetLocalVersionLCID() { return lcid; }
  439. // data members
  440. char szExistingFileName[MAX_PATH];
  441. LPSTR pBaseExistingFileName;
  442. LPSTR lpDestDir;
  443. DWORD dwLocFVMS;
  444. DWORD dwLocFVLS;
  445. FILETIME ftLastModified;
  446. LPSTR pbEtag;
  447. LCID lcid;
  448. BOOL bForceLangGetLatest;
  449. DWORD dwAvailMS;
  450. DWORD dwAvailLS;
  451. };
  452. // CModuleUsage: created for every module added to ModuleUsage
  453. // is walked thru and run after all setups are complete in COmpleteAll
  454. // can also be used to optionally rollback a setup
  455. class CModuleUsage {
  456. public:
  457. // constructor
  458. CModuleUsage(LPCSTR lpFileName, DWORD dwFlags, HRESULT *phr);
  459. ~CModuleUsage();
  460. HRESULT Update(LPCSTR szClientName);
  461. LPCSTR GetFileName() {return m_szFileName;}
  462. // data members
  463. LPSTR m_szFileName;
  464. DWORD m_dwFlags;
  465. };
  466. // CSetup: created for every setup item
  467. // each CDownload has zero or more of these linked into a list
  468. typedef enum {
  469. // the default behaviour for
  470. // registering a server is to do
  471. // so only when the version rsrc
  472. // has the string "OleSelfregister"
  473. // the user can override this
  474. // behaviour with setting in .INF
  475. // registerserver=yes/no
  476. CST_FLAG_REGISTERSERVER_OVERRIDE=1, // when set user has overriden
  477. CST_FLAG_REGISTERSERVER=2 // when set along with above
  478. // means user wants us to register
  479. // server
  480. } CST_FLAGS;
  481. class CDownload;
  482. typedef enum {
  483. CJS_FLAG_INIT=0,
  484. CJS_FLAG_NOSETUP=1, // don't setup just mark that this
  485. // java package is used by this dist
  486. // unit.
  487. CJS_FLAG_SYSTEM=2, // system class
  488. CJS_FLAG_NEEDSTRUSTEDSOURCE=4, // need trusted source
  489. };
  490. class CJavaSetup {
  491. public:
  492. CJavaSetup(
  493. CDownload *pdl,
  494. LPCWSTR szPackageName,
  495. LPCWSTR szNameSpace,
  496. IXMLElement *pPackage,
  497. DWORD dwVersionMS,
  498. DWORD dwVersionLS,
  499. DWORD flags,
  500. HRESULT *phr);
  501. ~CJavaSetup();
  502. HRESULT DoSetup();
  503. INSTALL_STATE GetState() const { return m_state;}
  504. VOID SetState(INSTALL_STATE state) { m_state = state;}
  505. LPCWSTR GetPackageName() { return m_szPackageName; }
  506. LPCWSTR GetNameSpace() { return m_szNameSpace; }
  507. void GetPackageVersion(DWORD &dwVersionMS, DWORD &dwVersionLS) {
  508. dwVersionMS = m_dwVersionMS;
  509. dwVersionLS = m_dwVersionLS;
  510. }
  511. DWORD GetPackageFlags() { return m_flags; }
  512. IXMLElement *GetPackageXMLElement() { return m_pPackage; }
  513. private:
  514. INSTALL_STATE m_state; // state of install operation
  515. CDownload* m_pdl;
  516. LPWSTR m_szPackageName;
  517. LPWSTR m_szNameSpace;
  518. IXMLElement * m_pPackage;
  519. DWORD m_dwVersionMS;
  520. DWORD m_dwVersionLS;
  521. DWORD m_flags;
  522. };
  523. class CSetup {
  524. public:
  525. HRESULT DoSetup(CCodeDownload *pcdl, CDownload *pdl);
  526. LPCSTR GetSrcFileName() const {return m_pSrcFileName;}
  527. HRESULT SetSrcFileName(LPCSTR pSrcFileName);
  528. FILEXTN GetExtn() const {return m_extn;}
  529. CSetup *GetNext() const { return m_pSetupnext;}
  530. VOID SetNext(CSetup *pSetupnext) { m_pSetupnext = pSetupnext;}
  531. INSTALL_STATE GetState() const { return m_state;}
  532. VOID SetState(INSTALL_STATE state) { m_state = state;}
  533. LPCSTR GetBaseFileName() const { return m_pBaseFileName; }
  534. // constructor
  535. CSetup(LPCSTR pSrcFileName, LPCSTR pBaseFileName, FILEXTN extn, LPCSTR pDestDir, HRESULT *phr, DESTINATION_DIR dest = LDID_OCXCACHE);
  536. ~CSetup();
  537. HRESULT GetDestDir(CCodeDownload *pcdl, LPSTR szDestDir, int iLen);
  538. HRESULT CheckForNameCollision(CCodeDownload *pcdl, LPCSTR szCacheDir);
  539. HRESULT InstallFile(
  540. CCodeDownload *pcdl,
  541. LPSTR szDestDir,
  542. int iLen,
  543. LPWSTR szStatusText,
  544. LPUINT pcbStatusText);
  545. VOID SetCopyFlags(DWORD dwcf) {
  546. m_advcopyflags = dwcf;
  547. }
  548. VOID SetUserOverrideRegisterServer(BOOL fRegister) {
  549. m_flags |= CST_FLAG_REGISTERSERVER_OVERRIDE;
  550. if (fRegister) {
  551. m_flags |= CST_FLAG_REGISTERSERVER;
  552. }
  553. }
  554. BOOL UserOverrideRegisterServer() {
  555. return (m_flags & CST_FLAG_REGISTERSERVER_OVERRIDE);
  556. }
  557. BOOL WantsRegisterServer() {
  558. return (m_flags & CST_FLAG_REGISTERSERVER);
  559. }
  560. void SetExactVersion(BOOL bFlag) {m_bExactVersion = bFlag;}
  561. private:
  562. CSetup* m_pSetupnext;
  563. LPSTR m_pSrcFileName; // fully qualified src file name
  564. LPSTR m_pBaseFileName; // base filename
  565. FILEXTN m_extn;
  566. LPCSTR m_pExistDir; // dest dir for setting up obj
  567. // if null default to ocxcache dir
  568. INSTALL_STATE m_state; // state of install operation
  569. DESTINATION_DIR m_dest;
  570. DWORD m_flags; // overrides for register server
  571. DWORD m_advcopyflags; // flags for AdvInstallFile
  572. BOOL m_bExactVersion;
  573. };
  574. // CClBinding to pass to client of CodeDownload in client's BSC::OnStartBinding
  575. class CClBinding : public IBinding {
  576. public:
  577. // IUnknown methods
  578. STDMETHODIMP QueryInterface(REFIID riid,void ** ppv);
  579. STDMETHODIMP_(ULONG) AddRef();
  580. STDMETHODIMP_(ULONG) Release();
  581. // IBinding methods
  582. STDMETHOD(Abort)( void);
  583. STDMETHOD(Suspend)( void);
  584. STDMETHOD(Resume)( void);
  585. STDMETHOD(SetPriority)(LONG nPriority);
  586. STDMETHOD(GetPriority)(LONG *pnPriority);
  587. STDMETHOD(GetBindResult)(CLSID *pclsidProtocol, DWORD *pdwResult, LPWSTR *pszResult,DWORD *pdwReserved);
  588. CClBinding::CClBinding(
  589. CCodeDownload *pcdl,
  590. IBindStatusCallback *pAssClientBSC,
  591. IBindCtx *pAssClientBC,
  592. REFCLSID rclsid,
  593. DWORD dwClsContext,
  594. LPVOID pvReserved,
  595. REFIID riid,
  596. IInternetHostSecurityManager* m_pHostSecurityManager);
  597. ~CClBinding();
  598. HRESULT InstantiateObjectAndReport(CCodeDownload *pcdl);
  599. REFCLSID GetClsid() const { return m_clsid;}
  600. HRESULT ReleaseClient();
  601. DWORD GetState() const { return m_dwState;}
  602. VOID SetState(DWORD dwState) { m_dwState = dwState;}
  603. IBindStatusCallback* GetAssBSC() {return m_pAssClientBSC;}
  604. IBindCtx* GetAssBC() {return m_pAssClientBC;}
  605. ICodeInstall* GetICodeInstall(); // side-effect: sets m_pCodeInstall!
  606. IWindowForBindingUI* GetIWindowForBindingUI(); // side-effect: sets m_pWindowForBindingUI!
  607. IBindHost* GetIBindHost(); // side-effect: sets m_pBindHost!
  608. IInternetHostSecurityManager* GetHostSecurityManager();
  609. HWND GetHWND(REFGUID rguidReason = IID_ICodeInstall);
  610. HRESULT SetClassString(LPCWSTR pszClassString);
  611. const LPWSTR GetClassString();
  612. private:
  613. CLSID m_clsid;
  614. // foll: for CoGetClassObject
  615. DWORD m_dwClsContext; // CLSCTX flags
  616. LPVOID m_pvReserved; // Must be NULL
  617. REFIID m_riid; // Usually IID_IClassFactory
  618. DWORD m_cRef;
  619. LONG m_nPriority; // priority of this binding
  620. DWORD m_dwState; // state of operation
  621. CCodeDownload* m_pcdl;
  622. IBindStatusCallback* m_pAssClientBSC; // associated Client BSC
  623. IBindCtx* m_pAssClientBC; // associated client bind ctx
  624. IBindHost* m_pBindHost; // IBindHost
  625. IWindowForBindingUI* m_pWindowForBindingUI; // IWindowForBindingUI
  626. // passed in by client
  627. // to pass in hwnd for
  628. // WinVerifyTrust as well
  629. IInternetHostSecurityManager* m_pHostSecurityManager;
  630. ICodeInstall* m_pCodeInstall; // ICodeInstall
  631. // passed in by client
  632. // to pass in hwnd for
  633. // WinVerifyTrust as well
  634. // as handle module update
  635. // contingencies like
  636. // out of disk space and
  637. // permission to update
  638. // existing file with newer ver
  639. HWND m_hWnd; // client hwnd obtained thru
  640. // ICodeInstall
  641. // ::NeedVerificationUI
  642. // safe to cache this?
  643. LPWSTR m_wszClassString;
  644. };
  645. // CodeDownload states
  646. typedef enum
  647. {
  648. CDL_NoOperation = 0, // operation did not start yet
  649. CDL_Downloading, // downloading in progress
  650. CDL_Suspend, // operation suspended
  651. CDL_Aborted, // operation aborted
  652. CDL_ReadyToSetup, // ready to setup
  653. CDL_Setup, // setup in progress
  654. CDL_SetupDone, // setup done
  655. CDL_Completed // done, and complete signalled CompleteAll
  656. } CDL_STATE;
  657. // values for CCodeDownload::m_flags
  658. // these will be defined in objbase.h. For now make sure they are defined so we don't break the build
  659. #ifndef CD_FLAGS_DEFINED
  660. #define CD_FLAGS_DEFINED
  661. typedef enum {
  662. CD_FLAGS_INIT = 0x0,
  663. CD_FLAGS_FORCE_DOWNLOAD = 0x1,
  664. CD_FLAGS_PEEK_STATE = 0x2,
  665. CD_FLAGS_NEED_CLASSFACTORY = 0x4,
  666. CD_FLAGS_PARANOID_VERSION_CHECK = 0x8,
  667. CD_FLAGS_SKIP_DECLINED_LIST_CHECK = 0x20,
  668. CD_FLAGS_USE_CODEBASE_ONLY = 0x80, // Set by OLE32 Class Store
  669. CD_FLAGS_HINT_JAVA = 0x100, // to turn off advance
  670. // disabling of code download
  671. // if ActiveX Signed+Unsigned
  672. // is off unless this flag is
  673. // passed any distunit that looks
  674. // like a clsid will not code
  675. // download if ActiveX is off
  676. CD_FLAGS_HINT_ACTIVEX = 0x200,
  677. CD_FLAGS_FORCE_INTERNET_DOWNLOAD = 0x400, // For OLE32 CoInstall
  678. // below are internal flags
  679. CD_FLAGS_WAITING_FOR_EXE = 0x40,
  680. CD_FLAGS_SILENTOPERATION = 0x800,
  681. CD_FLAGS_NEED_REBOOT = 0x1000,
  682. CD_FLAGS_BITS_IN_CACHE = 0x2000,
  683. CD_FLAGS_NEW_CONTEXT_MONIKER = 0x4000,
  684. CD_FLAGS_FAKE_SUCCESS = 0x8000,
  685. CD_FLAGS_DELETE_EXE = 0x10000,
  686. CD_FLAGS_UNSAFE_ABORT = 0x20000,
  687. CD_FLAGS_USER_CANCELLED = 0x40000,
  688. CD_FLAGS_HAVE_INF = 0x80000,
  689. CD_FLAGS_ONSTACK = 0x100000,
  690. CD_FLAGS_USED_CODE_URL = 0x200000,
  691. CD_FLAGS_EXACT_VERSION = 0x400000,
  692. CD_FLAGS_TRUST_SOME_FAILED = 0x800000
  693. } CD_FLAGS;
  694. #endif // CD_FLAGS_DEFINED
  695. #define CD_FLAGS_EXTERNAL_MASK (CD_FLAGS_FORCE_DOWNLOAD| \
  696. CD_FLAGS_PEEK_STATE| \
  697. CD_FLAGS_NEED_CLASSFACTORY| \
  698. CD_FLAGS_PARANOID_VERSION_CHECK| \
  699. CD_FLAGS_SKIP_DECLINED_LIST_CHECK| \
  700. CD_FLAGS_USE_CODEBASE_ONLY| \
  701. CD_FLAGS_HINT_JAVA| \
  702. CD_FLAGS_HINT_ACTIVEX| \
  703. CD_FLAGS_FORCE_INTERNET_DOWNLOAD)
  704. class CDownload;
  705. class DebugLogElement;
  706. class CDLDebugLog;
  707. // main class
  708. class CCodeDownload {
  709. public:
  710. // constructor
  711. CCodeDownload(
  712. LPCWSTR szDistUnit,
  713. LPCWSTR szURL,
  714. LPCWSTR szType,
  715. LPCWSTR szExt,
  716. DWORD dwFileVersionMS,
  717. DWORD dwFileVersionLS,
  718. HRESULT *phr);
  719. ~CCodeDownload();
  720. HRESULT DoCodeDownload(
  721. CLocalComponentInfo *plci,
  722. DWORD flags);
  723. HRESULT CCodeDownload::CreateClientBinding(
  724. CClBinding **ppClientBinding,
  725. IBindCtx* pClientBC,
  726. IBindStatusCallback* pClientbsc,
  727. REFCLSID rclsid,
  728. DWORD dwClsContext,
  729. LPVOID pvReserved,
  730. REFIID riid,
  731. BOOL fAddHead,
  732. IInternetHostSecurityManager *pHostSecurityManager);
  733. int GetCountClientBindings() const {
  734. return m_pClientbinding.GetCount();
  735. }
  736. CClBinding* GetClientBinding() const {
  737. return m_pClientbinding.GetHead();
  738. }
  739. IBindStatusCallback* GetClientBSC() const {
  740. return (GetClientBinding())->GetAssBSC();
  741. }
  742. IBindCtx* GetClientBC() const {
  743. return (GetClientBinding())->GetAssBC();
  744. }
  745. REFCLSID GetClsid() const {
  746. return (GetClientBinding())->GetClsid();
  747. }
  748. CDownload* GetDownloadHead() const {
  749. return m_pDownloads.GetHead();
  750. }
  751. VOID AddDownloadToList(CDownload *pdl);
  752. HRESULT FindDupCABInThread(IMoniker *pmk, CDownload **ppdlMatch);
  753. HRESULT FindCABInDownloadList(LPCWSTR szURL, CDownload *pdlHint, CDownload **ppdlMatch);
  754. VOID CompleteOne(CDownload *pdl, HRESULT hrOSB, HRESULT hrStatus, HRESULT hrResponseHdr, LPCWSTR szError);
  755. VOID CompleteAll(HRESULT hr, LPCWSTR szError);
  756. STDMETHODIMP_(ULONG) AddRef();
  757. STDMETHODIMP_(ULONG) Release();
  758. HRESULT ProcessHooks(CDownload *pdl);
  759. HRESULT ProcessHookSection(LPCSTR lpCurHook, CDownload *pdl);
  760. HRESULT GetSatelliteName( LPSTR lpCurCode, int iLen);
  761. BOOL IsSectionInINF(LPCSTR lpCurCode);
  762. HRESULT GetInfCodeLocation( LPCSTR lpCurCode, LPSTR szURL);
  763. HRESULT GetInfSectionInfo(
  764. LPSTR lpCurCode,
  765. int iLen,
  766. LPSTR szURL,
  767. LPCLSID *plpClsid,
  768. LPDWORD pdwFileVersionMS,
  769. LPDWORD pdwFileVersionLS,
  770. DESTINATION_DIR *pdest,
  771. LPDWORD pdwRegisterServer,
  772. LPDWORD pdwCopyFlags,
  773. BOOL *pbDestDir
  774. );
  775. HRESULT SetupInf(const char *szInf, char *szInfBaseName,CDownload *pdl);
  776. VOID ProcessInf(CDownload *pdl);
  777. HRESULT ParseOSD(const char *szOSD, char *szOSDBaseName, CDownload *pdl);
  778. HRESULT QueueModuleUsage( LPCSTR szFileName, LONG muFlags);
  779. HRESULT UpdateModuleUsage();
  780. HRESULT StartDownload(
  781. LPSTR szCurCode,
  782. CDownload *pdl,
  783. LPSTR szURL,
  784. DESTINATION_DIR dest,
  785. LPSTR szDestDir,
  786. DWORD dwRegisterServer,
  787. DWORD dwCopyFlags,
  788. CList <CCodeBaseHold *, CCodeBaseHold *> *pcbhList = NULL);
  789. BOOL HaveManifest() {return (HaveInf() || GetOSD());}
  790. BOOL NeedToReboot() const {return (m_flags & CD_FLAGS_NEED_REBOOT);}
  791. VOID SetRebootRequired() {m_flags |= CD_FLAGS_NEED_REBOOT;}
  792. BOOL IsSilentMode() const {return (m_flags & CD_FLAGS_SILENTOPERATION);}
  793. VOID SetSilentMode() {m_flags |= CD_FLAGS_SILENTOPERATION;}
  794. BOOL IsAllTrusted() const {return ((m_flags & CD_FLAGS_TRUST_SOME_FAILED) == 0);}
  795. VOID SetTrustSomeFailed() {m_flags |= CD_FLAGS_TRUST_SOME_FAILED;}
  796. BOOL ForceDownload() const {return (m_flags & CD_FLAGS_FORCE_DOWNLOAD);}
  797. BOOL HaveInf() const {return (m_flags & CD_FLAGS_HAVE_INF);}
  798. VOID SetHaveInf() {m_flags |= CD_FLAGS_HAVE_INF;}
  799. BOOL UsedCodeURL() const {return (m_flags & CD_FLAGS_USED_CODE_URL);}
  800. VOID SetUsedCodeURL() {m_flags |= CD_FLAGS_USED_CODE_URL;}
  801. BOOL SafeToAbort() const {return ((m_flags & CD_FLAGS_UNSAFE_ABORT) == 0);}
  802. VOID SetUnsafeToAbort() {m_flags |= CD_FLAGS_UNSAFE_ABORT;}
  803. BOOL BitsInCache() const {return (m_flags & CD_FLAGS_BITS_IN_CACHE);}
  804. VOID SetBitsInCache() {m_flags |= CD_FLAGS_BITS_IN_CACHE;}
  805. BOOL FakeSuccess() const {return (m_flags & CD_FLAGS_FAKE_SUCCESS);}
  806. VOID SetFakeSuccess() {m_flags |= CD_FLAGS_FAKE_SUCCESS;}
  807. HRESULT HandleUnSafeAbort();
  808. BOOL NeedObject() const {return (m_flags & CD_FLAGS_NEED_CLASSFACTORY);}
  809. VOID SetNeedObject(DWORD fl) { m_flags |= (fl & CD_FLAGS_NEED_CLASSFACTORY);}
  810. BOOL UseCodebaseOnly() const {return (m_flags & CD_FLAGS_USE_CODEBASE_ONLY);}
  811. VOID SetUseCodebaseOnly(DWORD fl) { m_flags |= (fl & CD_FLAGS_USE_CODEBASE_ONLY);}
  812. BOOL RelContextMk() {return (m_flags & CD_FLAGS_NEW_CONTEXT_MONIKER);}
  813. VOID MarkNewContextMoniker() {m_flags |= CD_FLAGS_NEW_CONTEXT_MONIKER;}
  814. VOID ResetNewContextMoniker() {m_flags &= ~CD_FLAGS_NEW_CONTEXT_MONIKER;}
  815. BOOL WaitingForEXE() {return (m_flags & CD_FLAGS_WAITING_FOR_EXE);}
  816. VOID SetNotWaitingForEXE() {m_flags &= ~CD_FLAGS_WAITING_FOR_EXE;}
  817. BOOL UserCancelled() {return (m_flags & CD_FLAGS_USER_CANCELLED);}
  818. VOID SetUserCancelled() {m_flags |= CD_FLAGS_USER_CANCELLED;}
  819. BOOL IsOnStack() const {return (m_flags & CD_FLAGS_ONSTACK);}
  820. BOOL SetOnStack() {
  821. if (IsOnStack()) {
  822. return FALSE;
  823. } else {
  824. m_flags |= CD_FLAGS_ONSTACK;
  825. return TRUE;
  826. }
  827. }
  828. VOID ResetOnStack() {m_flags &= ~CD_FLAGS_ONSTACK;}
  829. BOOL SkipDeclinedListCheck() const {return (m_flags & CD_FLAGS_SKIP_DECLINED_LIST_CHECK);}
  830. BOOL DeleteEXEWhenDone() {return (m_flags & CD_FLAGS_DELETE_EXE);}
  831. VOID SetDeleteEXEWhenDone() {m_flags |= CD_FLAGS_DELETE_EXE;}
  832. VOID ResetDeleteEXEWhenDone() {m_flags &= ~CD_FLAGS_DELETE_EXE;}
  833. HRESULT SetWaitingForEXE(LPCSTR szStatusText, BOOL bDeleteEXEWhenDone);
  834. VOID SetWaitingForEXEHandle(HANDLE hEXE) {m_pi.hProcess = hEXE;}
  835. LPSTR GetDestDirHint() const { return m_plci->lpDestDir;}
  836. BOOL LocalVersionPresent() const { return m_plci->IsPresent();}
  837. FILETIME * GetLastModifiedTime() { return m_plci->GetLastModifiedTime();}
  838. VOID InitLastModifiedFromDistUnit();
  839. IMoniker* GetContextMoniker() const {return m_pmkContext;}
  840. VOID SetContextMoniker(IMoniker* pmk) {m_pmkContext = pmk;}
  841. ICodeInstall* GetICodeInstall() const {
  842. return GetClientBinding()->GetICodeInstall();
  843. }
  844. LPCWSTR GetMainURL() const { return m_url;}
  845. LPCWSTR GetMainDistUnit() const { return m_szDistUnit;}
  846. LPCWSTR GetMainType() const { return m_szType;}
  847. LPCWSTR GetMainExt() const { return m_szExt;}
  848. LPCSTR GetCacheDir() const { return m_szCacheDir;}
  849. HRESULT ResolveCacheDirNameConflicts();
  850. void SetExactVersion(BOOL bExactVersion) { m_bExactVersion = bExactVersion;
  851. if (m_bExactVersion) {
  852. m_bUninstallOld = TRUE; // implied
  853. }
  854. }
  855. VOID SetListCookie(LISTPOSITION pos) {m_ListCookie = pos;}
  856. LISTPOSITION GetListCookie() const {return m_ListCookie;}
  857. HRESULT AcquireSetupCookie();
  858. HRESULT RelinquishSetupCookie();
  859. HRESULT PiggybackDupRequest(
  860. IBindStatusCallback *pDupClientBSC,
  861. IBindCtx *pbc,
  862. REFCLSID rclsid,
  863. DWORD dwClsContext,
  864. LPVOID pvReserved,
  865. REFIID riid);
  866. BOOL GenerateErrStrings(HRESULT hr, char **ppszErrMsg, WCHAR **ppwszError);
  867. static HRESULT CCodeDownload::AnyCodeDownloadsInThread();
  868. static HRESULT CCodeDownload::HasUserDeclined(
  869. LPCWSTR szDistUnit,
  870. LPCWSTR szType,
  871. LPCWSTR szExt,
  872. IBindStatusCallback *pClientBSC,
  873. IInternetHostSecurityManager *pHostSecurityManager);
  874. static HRESULT CCodeDownload::HandleDuplicateCodeDownloads(
  875. LPCWSTR szURL,
  876. LPCWSTR szType,
  877. LPCWSTR szExt,
  878. REFCLSID rclsid,
  879. LPCWSTR szDistUnit,
  880. DWORD dwClsContext,
  881. LPVOID pvReserved,
  882. REFIID riid,
  883. IBindCtx* pbc,
  884. IBindStatusCallback *pDupClientBSC,
  885. DWORD dwFlags,
  886. IInternetHostSecurityManager *pHostSecurityManager);
  887. HRESULT CCodeDownload::SetUserDeclined();
  888. HRESULT IsDuplicateHook(LPCSTR szHook);
  889. HRESULT IsDuplicateJavaSetup( LPCWSTR szPackage);
  890. HRESULT ProcessJavaManifest(IXMLElement *pJava, const char *szOSD, char *szOSDBaseName, CDownload *pdl);
  891. HRESULT ProcessDependency(CDownload *pdl, IXMLElement *pDepend);
  892. HRESULT ProcessNativeCode(CDownload *pdl, IXMLElement *pCode);
  893. HRESULT ExtractInnerCAB(CDownload *pdl, LPSTR szCABFile);
  894. HRESULT AddDistUnitList(LPWSTR szDistUnit);
  895. VOID DoSetup();
  896. HRESULT DealWithExistingFile(
  897. LPSTR szExistingFile,
  898. DWORD cbExistingFile,
  899. LPSTR pBaseExistingName,
  900. LPSTR *ppDestDir,
  901. LPDWORD pdwLocFVMS,
  902. LPDWORD pdwLocFVLS,
  903. FILETIME *pftLastModified = NULL);
  904. BOOL NeedLatestVersion() {
  905. return (( m_dwFileVersionMS == -1) && (m_dwFileVersionLS == -1));
  906. }
  907. LPSTR GetEtag() { return m_pbEtag;}
  908. VOID SetEtag(LPSTR szEtag) { m_pbEtag = szEtag;}
  909. LPSTR GetLocalVersionEtag() { return m_plci->GetLocalVersionEtag();}
  910. LPSTR GetLastMod() { return m_szLastMod[0]?m_szLastMod:NULL;}
  911. VOID SetLastModifiedTime(LPCSTR szLastMod) {
  912. lstrcpy(m_szLastMod, szLastMod);
  913. }
  914. HRESULT DelayRegisterOCX(LPCSTR pszSrcFileName, FILEXTN extn);
  915. HRESULT InstallOCX(LPCSTR lpSrcFileName, FILEXTN extn, BOOL fLocalServer);
  916. HRESULT RegisterPEDll( LPCSTR lpSrcFileName);
  917. #ifdef WX86
  918. HRESULT RegisterWx86Dll( LPCSTR lpSrcFileName);
  919. CMultiArch *GetMultiArch() { return &m_MultiArch; }
  920. #endif
  921. // BUGBUG: put these three in a SearchPath class
  922. HRESULT SetupCODEUrl(LPWSTR *ppDownloadURL, FILEXTN *pextn);
  923. HRESULT GetNextComponent( LPSTR szList, LPSTR *ppCur);
  924. HRESULT GetNextOnInternetSearchPath(
  925. REFCLSID rclsid,
  926. HGLOBAL *phPostData,
  927. DWORD *pcbPostData,
  928. LPWSTR szURL,
  929. DWORD dwSize,
  930. LPWSTR *ppDownloadURL,
  931. FILEXTN *pextn);
  932. HRESULT SelfRegEXETimeout();
  933. HRESULT AbortBinding(CClBinding *pbinding);
  934. BOOL WeAreReadyToSetup();
  935. LPCSTR GetMainInf() { return m_szInf;}
  936. LPCSTR GetOSD() { return m_szOSD;}
  937. LCID GetLCID() { return m_lcid;}
  938. BOOL VersionFromManifest(LPSTR szVersionInManifest, int iLen);
  939. HRESULT SetManifest(FILEXTN extn, LPCSTR szManifest);
  940. CLangInfo *GetLangInfo() { return &m_langinfo;}
  941. void CodeDownloadDebugOut(int iOption, BOOL fOperationFailed,
  942. UINT iResId, ...);
  943. HRESULT IsPackageLocallyInstalled(LPCWSTR szPackageName, LPCWSTR szNameSpace, DWORD dwVersionMS, DWORD dwVersionLS);
  944. IJavaPackageManager * GetPackageManager() { return m_pPackageManager;}
  945. HRESULT SetCatalogFile(LPSTR szCatalogFile);
  946. LPSTR GetCatalogFile();
  947. HRESULT SetMainCABJavaTrustPermissions(PJAVA_TRUST pbJavaTrust);
  948. PJAVA_TRUST GetJavaTrust();
  949. void SetDebugLog(CDLDebugLog * debuglog);
  950. void SetCatalogInstalled()
  951. {
  952. m_bCatalogInstalled = TRUE;
  953. }
  954. BOOL IsCatalogInstalled()
  955. {
  956. return m_bCatalogInstalled;
  957. }
  958. void SetAtom(ATOM atom)
  959. {
  960. if(m_atom)
  961. DeleteAtom(m_atom);
  962. m_atom = atom;
  963. }
  964. HRESULT VerifyFileAgainstSystemCatalog(LPCSTR pFileName, LPWSTR pwszFullCatalogPath, DWORD* pdwBuffer)
  965. {
  966. return m_wvt.VerifyFileAgainstSystemCatalog(pFileName, pwszFullCatalogPath, pdwBuffer);
  967. }
  968. BOOL FileProtectionCheckSucceeded(LPCSTR lpszExistingFileName);
  969. BOOL IsFileProtected(LPCSTR pFileName);
  970. private:
  971. CDL_STATE GetState() const { return m_state;}
  972. VOID SetState(CDL_STATE state) { m_state = state;}
  973. HRESULT UpdateFileList(HKEY hKeyContains);
  974. HRESULT UpdateDependencyList(HKEY hKeyContains);
  975. HRESULT UpdateJavaList(HKEY hKeyContains);
  976. HRESULT UpdateDistUnit(CLocalComponentInfo *plci);
  977. HRESULT UpdateLanguageCheck(CLocalComponentInfo *plci);
  978. void DumpDebugLog(char *szCacheFileName, LPTSTR szErrorMsg, HRESULT hrError);
  979. void DestroyPCBHList(CList<CCodeBaseHold *, CCodeBaseHold *> *pcbhList);
  980. DWORD m_cRef;
  981. CDL_STATE m_state; // state of code download
  982. LPWSTR m_url;
  983. LPWSTR m_szDistUnit;
  984. LPWSTR m_szType;
  985. LPWSTR m_szExt;
  986. LPSTR m_szDisplayName;
  987. LPSTR m_szVersionInManifest;
  988. IMoniker* m_pmkContext; // first download's pmk
  989. // becomes the context
  990. // for handling subsequent
  991. // relative URLs
  992. DWORD m_dwFileVersionMS; // little quirky that
  993. DWORD m_dwFileVersionLS; // this really the primary
  994. // control's fileversion
  995. // can really be something
  996. // else if deemed appropriate
  997. // eg: subversion of clsid
  998. LCID m_lcid; // cache lcid client needs
  999. // this is pulled out of the
  1000. // bindctx (BIND_OPTS2)
  1001. CList<CModuleUsage*,CModuleUsage*> // linked list of module usage
  1002. m_ModuleUsage; // entries to add
  1003. CList<CClBinding*,CClBinding*> // linked list of client
  1004. m_pClientbinding; // IBindings
  1005. CList<CDownload*,CDownload*> // linked list of CDownload
  1006. m_pDownloads; // pieces
  1007. CList<LPWSTR,LPWSTR> // linked list of dependent
  1008. m_pDependencies; // distribution units
  1009. DWORD m_flags; // provision for hacks :)
  1010. // used internally now to
  1011. // mark if we have an INF file
  1012. // and if safe to abort
  1013. LPSTR m_szInf; // INF filename if one exists
  1014. LPSTR m_szOSD; // INF filename if one exists
  1015. LPSTR m_szCacheDir; // OCCACHE dir that is setup
  1016. // for each code download
  1017. // is usually = g_szOCXCacheDir
  1018. // but if a name conflict arises
  1019. // it can be OCCACHE\CONFLICT.n
  1020. LPSTR m_pAddCodeSection; // Add.Code section in INF
  1021. // bunch of null terminated
  1022. // strings, last one double
  1023. // null terminated (like env)
  1024. LPSTR m_pCurCode; // points at what ProcessInf
  1025. // is pending processing
  1026. HKEY m_hKeySearchPath; // key to REGSTR_PATH_ISP
  1027. LPSTR m_pSearchPath; // List of searchpath comps
  1028. LPSTR m_pSearchPathNextComp; // pointer into list above at
  1029. // current component
  1030. CLangInfo m_langinfo;
  1031. LPSTR m_szWaitForEXE; // str that points to name of
  1032. // self registering EXE that we
  1033. // are waiting now to complete
  1034. // This is used to give
  1035. // detailed CodeInstallProblem
  1036. // when we get a ClientBinding::
  1037. // Abort wahile waiting for an
  1038. // EXE to complete setup/reg
  1039. PROCESS_INFORMATION m_pi; // PI for the currently self-
  1040. // registering EXE that we
  1041. // are running
  1042. LISTPOSITION m_ListCookie; // cookie to remove this
  1043. // download from the per-thread
  1044. // list of CCodeDownload's in
  1045. // progress (CList)
  1046. HRESULT m_hr; // hr to pass to CompleteAll
  1047. // this store away the first
  1048. // real failure code in a
  1049. // multipart code download
  1050. char m_szLastMod[INTERNET_RFC1123_BUFSIZE+1];
  1051. // last modified date of the
  1052. // main URL (typically CODEBASE
  1053. // or the URL redirected by
  1054. // Object Index). We save this
  1055. // with the dist unit DB to use
  1056. // later for Get Latest.
  1057. DWORD m_dwExpire; // number of days before DU eligible
  1058. // for scavenging.
  1059. DWORD m_dwSystemComponent;
  1060. char *m_pbEtag;
  1061. CLocalComponentInfo* m_plci;
  1062. IJavaPackageManager* m_pPackageManager; // Java pkg mgr
  1063. DWORD m_grfBINDF;
  1064. CList<CCodeBaseHold *, CCodeBaseHold *> *m_pcbhList;
  1065. LPSTR m_szCatalogFile;
  1066. BOOL m_bCatalogInstalled;
  1067. ATOM m_atom;
  1068. PJAVA_TRUST m_pbJavaTrust;
  1069. CDLDebugLog * m_debuglog;
  1070. BOOL m_bUninstallOld;
  1071. BOOL m_bExactVersion;
  1072. HMODULE m_hModSFC;
  1073. Cwvt m_wvt;
  1074. #ifdef WX86
  1075. CMultiArch m_MultiArch;
  1076. #endif
  1077. };
  1078. class DebugLogElement {
  1079. public:
  1080. DebugLogElement() : m_szMessage(NULL) {}
  1081. DebugLogElement(LPSTR szMessage);
  1082. DebugLogElement(const DebugLogElement &ref);
  1083. virtual ~DebugLogElement();
  1084. public:
  1085. LPCSTR GetLogMessage() { return m_szMessage; }
  1086. HRESULT SetLogMessage(LPSTR szMessage);
  1087. private:
  1088. LPSTR m_szMessage;
  1089. };
  1090. // Class to make a debug log and pass out error messages
  1091. // Note reguarding wide strings vs. ANSI:
  1092. // For file-write compatiblity, the private strings of CDLDebugLog
  1093. // are stored as multibyte, but the primary accessors (the private
  1094. // variables in CCodeDownLoad) are wide characters. Hence, the
  1095. // return values for the accesors are Multibyte, since these are used
  1096. // primarily by this class, while the set parameters are wide character
  1097. class CDLDebugLog {
  1098. public:
  1099. ~CDLDebugLog();
  1100. // Name accessor functions
  1101. // Return the current value for the requested name (may be "")
  1102. LPCTSTR GetMainClsid() {return m_szMainClsid;}
  1103. LPCTSTR GetMainType() {return m_szMainType;}
  1104. LPCTSTR GetMainExt() {return m_szMainExt;}
  1105. LPCTSTR GetMainUrl() {return m_szMainUrl;}
  1106. LPCTSTR GetFileName() {return m_szFileName;}
  1107. LPCTSTR GetUrlName() {return m_szUrlName;}
  1108. // Functions to access or output error messages
  1109. void DebugOut(int iOption, BOOL fOperationFailed,
  1110. UINT iResId, ...);
  1111. void DebugOutPreFormatted(int iOption, BOOL fOperationFailed,
  1112. LPTSTR szDebugString);
  1113. void DumpDebugLog(LPTSTR pszCacheFileName, int cbBufLen,
  1114. LPTSTR szErrorMsg, HRESULT hrError);
  1115. // Deletion and Initialization functions
  1116. void Clear();
  1117. BOOL Init(CCodeDownload * pcdl);
  1118. BOOL Init(LPCWSTR wszMainClsid, LPCWSTR wszMainType,
  1119. LPCWSTR wszMainExt, LPCWSTR wszMainUrl);
  1120. void MakeFile();
  1121. // Static functions for storing and accessing stored debug logs
  1122. static void AddDebugLog(CDLDebugLog * dlog);
  1123. static void RemoveDebugLog(CDLDebugLog * dlog);
  1124. static CDLDebugLog * GetDebugLog(LPCWSTR wszMainClsid, LPCWSTR wszMainType,
  1125. LPCWSTR wszMainExt, LPCWSTR wszMainUrl);
  1126. // Static functions for saving an error message for the download
  1127. static BOOL SetSavedMessage(LPCTSTR szMessage, BOOL bOverwrite);
  1128. static LPCTSTR GetSavedMessage();
  1129. // Static function for debug log construction
  1130. static CDLDebugLog * MakeDebugLog();
  1131. // Com-type add and release functions
  1132. int AddRef();
  1133. int Release();
  1134. private:
  1135. CDLDebugLog();
  1136. CList<DebugLogElement *, DebugLogElement *>
  1137. m_DebugLogList;
  1138. BOOL m_fAddedDebugLogHead;
  1139. TCHAR m_szFileName[INTERNET_MAX_URL_LENGTH];
  1140. TCHAR m_szUrlName[INTERNET_MAX_URL_LENGTH];
  1141. TCHAR m_szMainClsid[MAX_DEBUG_STRING_LENGTH];
  1142. TCHAR m_szMainType[MAX_DEBUG_STRING_LENGTH];
  1143. TCHAR m_szMainExt[MAX_DEBUG_STRING_LENGTH];
  1144. TCHAR m_szMainUrl[INTERNET_MAX_URL_LENGTH];
  1145. // Support addref and release
  1146. int m_iRefCount;
  1147. // List and mutex for stored CDLDebugLog's
  1148. static CList<CDLDebugLog *, CDLDebugLog *>
  1149. s_dlogList;
  1150. static CMutexSem s_mxsDLogList;
  1151. static CMutexSem s_mxsMessage;
  1152. // Saved error message
  1153. static TCHAR s_szMessage[];
  1154. static BOOL s_bMessage;
  1155. };
  1156. // values for CDownload::m_flags
  1157. typedef enum {
  1158. DL_FLAGS_INIT = 0x0,
  1159. DL_FLAGS_TRUST_VERIFIED= 0x1,
  1160. DL_FLAGS_EXTRACT_ALL= 0x2,
  1161. DL_FLAGS_CDL_PROTOCOL= 0x4 // using cdl:// to kick off DL
  1162. } DL_FLAGS;
  1163. class CParentCDL {
  1164. public:
  1165. CParentCDL(CCodeDownload *pcdl) {m_pcdl = pcdl;m_bCompleteSignalled = FALSE;}
  1166. CCodeDownload* m_pcdl;
  1167. BOOL m_bCompleteSignalled;
  1168. };
  1169. class CBindStatusCallback;
  1170. class CSetupHook;
  1171. // one for each individual downloads
  1172. class CDownload {
  1173. public:
  1174. // constructor
  1175. CDownload(LPCWSTR szURL, FILEXTN extn, HRESULT *phr);
  1176. ~CDownload();
  1177. void CDownload::CleanUp();
  1178. HRESULT AddParent(CCodeDownload *pcdl);
  1179. HRESULT ReleaseParent(CCodeDownload *pcdl);
  1180. HRESULT CompleteSignal(HRESULT hrOSB, HRESULT hrStatus, HRESULT hrResponseHdr, LPCWSTR szError);
  1181. HRESULT DoDownload(LPMONIKER *ppmkContext, DWORD grfBINDF,
  1182. CList<CCodeBaseHold *, CCodeBaseHold *> *pcbhList = NULL);
  1183. HRESULT Abort(CCodeDownload *pcdl);
  1184. BOOL IsSignalled(CCodeDownload *pcdl);
  1185. // for each in list CSetup::DoSetup
  1186. HRESULT DoSetup();
  1187. BOOL IsDuplicateSetup(LPCSTR pBaseFileName);
  1188. // called by CBSC::OnStopBinding as soon as the binding completes
  1189. VOID ProcessPiece();
  1190. // for each in list CSetup::CheckForNameCollision
  1191. HRESULT CheckForNameCollision(LPCSTR szCacheDir);
  1192. HRESULT CleanupFiles();
  1193. CDownload *GetNext() const { return m_pdlnext;}
  1194. VOID SetNext(CDownload *pdlnext) { m_pdlnext = pdlnext;}
  1195. CSetup* GetSetupHead() const {return m_pSetuphead;}
  1196. VOID AddSetupToList(CSetup *pSetup);
  1197. HRESULT RemoveSetupFromList(CSetup *pSetup);
  1198. HRESULT AddHook(
  1199. LPCSTR szHook,
  1200. LPCSTR szInf,
  1201. LPCSTR szInfSection,
  1202. DWORD flags);
  1203. HRESULT AddSetupToExistingCAB(
  1204. char *lpCode,
  1205. const char * szDestDir,
  1206. DESTINATION_DIR dest,
  1207. DWORD dwRegisterServer,
  1208. DWORD dwCopyFlags);
  1209. CCodeDownload* GetCodeDownload() const { return (m_ParentCDL.GetHead())->m_pcdl;}
  1210. CBindStatusCallback* GetBSC() const { return m_pbsc;}
  1211. IBindCtx* GetBindCtx() const { return m_pbc;}
  1212. VOID SetUnkForCacheFileRelease(IUnknown *pUnk) {m_pUnkForCacheFileRelease = pUnk;}
  1213. LPCSTR GetFileName() const { return m_pFileName;}
  1214. VOID SetFileName(LPSTR pFileName) { m_pFileName = pFileName;}
  1215. HRESULT IsDownloadedVersionRequired();
  1216. LPCWSTR GetURL() const { return m_url;}
  1217. HRESULT GetFriendlyName(LPSTR szUrlPath, LPSTR *ppBaseFileName);
  1218. IMoniker* GetMoniker() const {return m_pmk;}
  1219. HRESULT SetURLAndExtn(LPCWSTR szURL, FILEXTN extn);
  1220. HRESULT SniffType();
  1221. FILEXTN GetExtn() const {return m_extn;}
  1222. PFNAME GetFilesToExtract() const { return m_pFilesToExtract;}
  1223. DLSTATE GetDLState() const { return m_state;}
  1224. VOID SetDLState(DLSTATE state)
  1225. {
  1226. m_state = state;
  1227. }
  1228. VOID SetProgress(ULONG ulProgress, ULONG ulProgressMax) { m_ulProgress = ulProgress; m_ulProgressMax = ulProgressMax;}
  1229. VOID SumProgress(ULONG *pulProgress, ULONG *pulProgressMax) { *pulProgress += m_ulProgress; *pulProgressMax += m_ulProgressMax;}
  1230. PSESSION GetSession() const { return m_psess;}
  1231. VOID SetSession(PSESSION psess) { m_psess = psess;}
  1232. HGLOBAL GetPostData(DWORD *pcbPostData) const {
  1233. *pcbPostData = m_cbPostData;
  1234. return m_hPostData;
  1235. }
  1236. VOID SetPostData(HGLOBAL hPostData, DWORD cbPostData) {
  1237. m_hPostData = hPostData;
  1238. m_cbPostData = cbPostData;
  1239. }
  1240. BOOL DoPost() const { return (m_hPostData != NULL);}
  1241. HRESULT GetResponseHeaderStatus() const {return m_hrResponseHdr;}
  1242. VOID SetResponseHeaderStatus( HRESULT hrResponseHdr) {
  1243. m_hrResponseHdr = hrResponseHdr;}
  1244. VOID VerifyTrust();
  1245. BOOL TrustVerified() const {return (m_flags & DL_FLAGS_TRUST_VERIFIED);}
  1246. VOID SetTrustVerified() {m_flags |= DL_FLAGS_TRUST_VERIFIED;}
  1247. BOOL NeedToExtractAllFiles() const {return(m_flags & DL_FLAGS_EXTRACT_ALL);}
  1248. VOID SetNeedToExtractAll() {m_flags |= DL_FLAGS_EXTRACT_ALL;}
  1249. BOOL UsingCdlProtocol() const {return(m_flags & DL_FLAGS_CDL_PROTOCOL);}
  1250. HRESULT SetUsingCdlProtocol(LPWSTR szDistUnit);
  1251. LPWSTR GetDistUnitName() const {return(m_wszDistUnit);}
  1252. HRESULT ExtractManifest(FILEXTN extn, LPSTR szFileName, LPSTR& pBaseFileName);
  1253. CSetupHook* FindHook(LPCSTR szHook);
  1254. CJavaSetup* FindJavaSetup(LPCWSTR szPackageName);
  1255. HRESULT AddJavaSetup(LPCWSTR szPackageName, LPCWSTR szNameSpace, IXMLElement *pPackage, DWORD dwVersionMS, DWORD dwVersionLS, DWORD flags);
  1256. CList<CJavaSetup*,CJavaSetup*> *GetJavaSetupList() { return &m_JavaSetupList;}
  1257. BOOL HasJavaPermissions();
  1258. BOOL HasAllActiveXPermissions();
  1259. PJAVA_TRUST GetJavaTrust() {return m_pbJavaTrust;}
  1260. HRESULT PerformVirusScan(LPSTR szFileName);
  1261. STDMETHODIMP DownloadRedundantCodeBase();
  1262. HRESULT SetMainCABJavaTrustPermissions(PJAVA_TRUST pbJavaTrust);
  1263. void SetExactVersion(BOOL bFlag) {m_bExactVersion = bFlag;}
  1264. private:
  1265. LPWSTR m_url;
  1266. FILEXTN m_extn;
  1267. LPSTR m_pFileName; // filename in temp once downloaded
  1268. IMoniker* m_pmk;
  1269. IBindCtx* m_pbc;
  1270. IUnknown* m_pUnkForCacheFileRelease;
  1271. CBindStatusCallback* m_pbsc;
  1272. CDownload* m_pdlnext;
  1273. CList<CParentCDL *,CParentCDL *> // linked list of CCodeDownloads
  1274. m_ParentCDL; // that have interest in us
  1275. ULONG m_ulProgress;
  1276. ULONG m_ulProgressMax;
  1277. DLSTATE m_state;
  1278. PSESSION m_psess; // CAB extraction struc
  1279. PFNAME m_pFilesToExtract; // applicable only for CAB objs
  1280. CSetup* m_pSetuphead; // list of CSetup's for this dwld
  1281. DWORD m_flags; // provision for hacks :)
  1282. HGLOBAL m_hPostData; // has the query for the clsid
  1283. DWORD m_cbPostData; // has size of post data
  1284. BOOL m_bCompleteSignalled;
  1285. LPWSTR m_wszDistUnit; // name of distribution for cdl:// dl
  1286. HRESULT m_hrOSB; // this is the hr we got
  1287. // from OnStopBinding
  1288. HRESULT m_hrStatus; // this is the hr we got
  1289. // URLMON for the binding
  1290. HRESULT m_hrResponseHdr; // this is the hr we got
  1291. // from the response headers
  1292. // when querying for this clsid
  1293. // this is to make sure we have the
  1294. // right error status even when
  1295. // urlmon does not pass back right
  1296. // OnError.
  1297. PJAVA_TRUST m_pbJavaTrust;
  1298. CList<CSetupHook*,CSetupHook*> // linked list of setup hooks
  1299. m_SetupHooks;
  1300. CList<CJavaSetup*,CJavaSetup*> // linked list of Java setups
  1301. m_JavaSetupList;
  1302. Cwvt m_wvt; // WinVerifyTrust delay load
  1303. // magic in this class
  1304. CList<CCodeBaseHold *, CCodeBaseHold *> *m_pcbhList;
  1305. DWORD m_grfBINDF;
  1306. LPMONIKER *m_ppmkContext;
  1307. BOOL m_bExactVersion;
  1308. };
  1309. // BSC for our indiv. CDownloads
  1310. class CBindStatusCallback : public IBindStatusCallback
  1311. ,public IHttpNegotiate
  1312. ,public IWindowForBindingUI
  1313. ,public IServiceProvider
  1314. ,public ICatalogFileInfo
  1315. {
  1316. public:
  1317. // IUnknown methods
  1318. STDMETHODIMP QueryInterface(REFIID riid,void ** ppv);
  1319. STDMETHODIMP_(ULONG) AddRef();
  1320. STDMETHODIMP_(ULONG) Release();
  1321. // IBindStatusCallback methods
  1322. STDMETHODIMP GetBindInfo(DWORD* pgrfBINDF, BINDINFO* pbindinfo);
  1323. STDMETHODIMP OnDataAvailable(DWORD grfBSCF, DWORD dwSize, FORMATETC *pFmtetc, STGMEDIUM __RPC_FAR *pstgmed);
  1324. STDMETHODIMP OnObjectAvailable( REFIID riid, IUnknown* punk);
  1325. STDMETHODIMP OnStartBinding(DWORD grfBSCOPTION,IBinding* pbinding);
  1326. STDMETHODIMP GetPriority(LONG* pnPriority);
  1327. STDMETHODIMP OnLowResource(DWORD dwReserved);
  1328. STDMETHODIMP OnProgress(ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode,
  1329. LPCWSTR pwzStatusText);
  1330. STDMETHODIMP OnStopBinding(HRESULT hrResult, LPCWSTR szError);
  1331. // *** IHttpNegotiate methods ***
  1332. STDMETHOD(BeginningTransaction) (
  1333. LPCWSTR szURL,
  1334. LPCWSTR szHeaders,
  1335. DWORD dwReserved,
  1336. LPWSTR *pszAdditionalHeaders);
  1337. STDMETHOD(OnResponse) (
  1338. DWORD dwResponseCode,
  1339. LPCWSTR szResponseHeaders,
  1340. LPCWSTR szRequestHeaders,
  1341. LPWSTR *pszAdditionalRequestHeaders);
  1342. // *** IWindowForBindingUI methods ***
  1343. STDMETHOD(GetWindow) (
  1344. REFGUID rguidreason,
  1345. HWND *phWnd);
  1346. // *** IServiceProvider ***
  1347. STDMETHOD(QueryService) (
  1348. REFGUID guidService,
  1349. REFIID riid,
  1350. LPVOID *ppv);
  1351. // *** ICatalogFileInfo ***
  1352. STDMETHODIMP GetCatalogFile(LPSTR *ppszCatalogFile);
  1353. STDMETHODIMP GetJavaTrust(void **ppJavaTrust);
  1354. // constructor
  1355. CBindStatusCallback(CDownload *pdl, DWORD grfBINDF);
  1356. ~CBindStatusCallback();
  1357. IBinding* GetBinding() const {return m_pbinding;}
  1358. private:
  1359. DWORD m_cRef;
  1360. IBinding* m_pbinding;
  1361. CDownload* m_pdl; // point up into download obj
  1362. DWORD m_grfBINDF;
  1363. BYTE m_cbBuffer[BUFFERMAX];
  1364. };
  1365. class CSetupHook {
  1366. public:
  1367. CSetupHook(
  1368. CDownload *pdl,
  1369. LPCSTR szHook,
  1370. LPCSTR szInf,
  1371. LPCSTR szInfSection,
  1372. DWORD flags,
  1373. HRESULT *phr);
  1374. ~CSetupHook();
  1375. HRESULT Run();
  1376. static HRESULT ExpandCommandLine(
  1377. LPSTR szSrc,
  1378. LPSTR szBuf,
  1379. DWORD cbBuffer,
  1380. const char * szVars[], // array of variable names eg. %EXTRACT_DIR%
  1381. const char * szValues[]); // corresponding values to expand of vars
  1382. static HRESULT ExpandVar(
  1383. LPSTR& pchSrc, // passed by ref!
  1384. LPSTR& pchOut, // passed by ref!
  1385. DWORD& cbLen, // passed by ref!
  1386. DWORD cbBuffer, // size of out buffer
  1387. const char * szVars[], // array of variable names eg. %EXTRACT_DIR%
  1388. const char * szValues[]);// corresponding values to expand of vars
  1389. HRESULT TranslateString();
  1390. INSTALL_STATE GetState() const { return m_state;}
  1391. VOID SetState(INSTALL_STATE state) { m_state = state;}
  1392. LPSTR GetHookName() { return m_szHook; }
  1393. const char * GetObjectDir() {
  1394. if (m_pdl && m_pdl->GetCodeDownload())
  1395. return m_pdl->GetCodeDownload()->GetCacheDir();
  1396. else
  1397. return NULL;
  1398. }
  1399. LPCWSTR GetSrcURL() {
  1400. if (m_pdl) {
  1401. return m_pdl->GetURL();
  1402. }
  1403. else {
  1404. return NULL;
  1405. }
  1406. }
  1407. LPSTR GetHookDir() {
  1408. if (m_pdl && m_pdl->GetSession())
  1409. return m_pdl->GetSession()->achLocation;
  1410. else
  1411. return NULL;
  1412. }
  1413. private:
  1414. INSTALL_STATE m_state; // state of install operation
  1415. CDownload* m_pdl;
  1416. LPSTR m_szHook;
  1417. LPSTR m_szInf;
  1418. LPSTR m_szInfSection;
  1419. DWORD m_flags;
  1420. };
  1421. HRESULT SetCodeDownloadTLSVars();
  1422. // private helpers
  1423. // from isctrl.cxx
  1424. HRESULT IsControlLocallyInstalled(
  1425. LPSTR lpCurCode,
  1426. const LPCLSID lpclsid,
  1427. LPCWSTR szDistUnit,
  1428. DWORD dwFileVersionMS,
  1429. DWORD dwFileVersionLS,
  1430. CLocalComponentInfo *plci,
  1431. LPSTR szDestDirHint,
  1432. BOOL bExactVersion = FALSE);
  1433. // from isctrl.cxx
  1434. HRESULT IsCLSIDLocallyInstalled(
  1435. LPSTR lpCurCode,
  1436. const LPCLSID lpclsid,
  1437. LPCWSTR szDistUnit,
  1438. DWORD dwFileVersionMS,
  1439. DWORD dwFileVersionLS,
  1440. CLocalComponentInfo *plci,
  1441. LPSTR szDestDirHint,
  1442. HRESULT *pHrExtra,
  1443. BOOL bExactVersion
  1444. );
  1445. HRESULT
  1446. IsDistUnitLocallyInstalled(
  1447. LPCWSTR szDistUnit,
  1448. DWORD dwFileVersionMS,
  1449. DWORD dwFileVersionLS,
  1450. CLocalComponentInfo *plci,
  1451. LPSTR szDestDirHint,
  1452. LPBOOL pbParanoidCheck,
  1453. DWORD flags);
  1454. HRESULT
  1455. IsPackageLocallyInstalled(
  1456. IJavaPackageManager **ppPackageManager,
  1457. LPCWSTR szPackageName,
  1458. LPCWSTR szNameSpace,
  1459. DWORD dwVersionMS,
  1460. DWORD dwVersionLS);
  1461. HRESULT LocalVersionOK(
  1462. HKEY hkeyClsid,
  1463. CLocalComponentInfo *plci,
  1464. DWORD dwFileVersionMS,
  1465. DWORD dwFileVersionLS,
  1466. BOOL bExactVersion
  1467. );
  1468. HRESULT GetFileVersion(
  1469. CLocalComponentInfo *plci,
  1470. LPDWORD pdwFileVersionMS,
  1471. LPDWORD pdwFileVersionLS);
  1472. HRESULT GetVersionFromString(
  1473. const char *szBuf,
  1474. LPDWORD pdwFileVersionMS,
  1475. LPDWORD pdwFileVersionLS,
  1476. char cSeperator = ',');
  1477. BOOL AdviseForceDownload( const LPCLSID lpclsid, DWORD dwClsContext);
  1478. // flags for UpdateModuleUsage
  1479. #define MU_CLIENT 0 // mark us as a client
  1480. #define MU_OWNER 1 // mark us as the owner (iff no prev ver exists)
  1481. HRESULT
  1482. UpdateModuleUsage(
  1483. LPCSTR szFileName,
  1484. LPCSTR szClientName,
  1485. LPCSTR szClientPath,
  1486. LONG muFlags);
  1487. HRESULT UpdateSharedDlls( LPCSTR szFileName);
  1488. BOOL SupportsSelfRegister(LPSTR szFileName);
  1489. BOOL WantsAutoExpire(LPSTR szFileName, DWORD *pnExpireDays );
  1490. // from wvt.cxx
  1491. HRESULT GetActivePolicy(IInternetHostSecurityManager* pZoneManager,
  1492. LPCWSTR pwszZone,
  1493. DWORD dwUrlAction,
  1494. DWORD& dwPolicy,
  1495. BOOL fEnforceRestricted);
  1496. // from peldr.cxx
  1497. HRESULT IsCompatibleFile(const char *szFileName, LPDWORD lpdwMachineType=NULL);
  1498. HRESULT IsRegisterableDLL(const char *szFileName);
  1499. // fro, softdist.cxx
  1500. HRESULT GetLangString(LCID localeID, char *szThisLang, int iLen);
  1501. HRESULT InitBrowserLangStrings();
  1502. // from duman.cxx
  1503. HRESULT GetSoftDistFromOSD(LPCSTR szFile, IXMLElement **ppSoftDist);
  1504. HRESULT GetFirstChildTag(IXMLElement *pRoot, LPCWSTR szTag, IXMLElement **ppChildReq);
  1505. HRESULT GetNextChildTag(IXMLElement *pRoot, LPCWSTR szTag, IXMLElement **ppChildReq, int &nLastChild);
  1506. HRESULT GetAttribute(IXMLElement *pElem, LPWSTR szAttribName, VARIANT *pvProp);
  1507. HRESULT GetAttributeA(IXMLElement *pElem, LPWSTR szAttribName, LPSTR pAttribValue, DWORD dwBufferLen);
  1508. HRESULT DupAttributeA(IXMLElement *pElem, LPWSTR szAttribName, LPSTR *ppszRet);
  1509. HRESULT DupAttribute(IXMLElement *pElem, LPWSTR szAttribName, LPWSTR *ppszRet);
  1510. HRESULT GetTextContent(IXMLElement *pRoot, LPCWSTR szTag, LPWSTR *ppszContent);
  1511. // from jit.cxx
  1512. HRESULT
  1513. GetIEFeatureFromMime(LPWSTR *ppwszIEFeature, LPCWSTR pwszMimeType, QUERYCONTEXT *pQuery, QUERYCONTEXT *pQueryRec=NULL);
  1514. HRESULT
  1515. GetIEFeatureFromClass(LPWSTR *ppwszIEFeature, REFCLSID clsid, QUERYCONTEXT *pQuery, QUERYCONTEXT *pQueryRec=NULL);
  1516. // from client.cxx
  1517. IInternetHostSecurityManager* GetHostSecurityManager(IBindStatusCallback *pclientbsc);
  1518. // from helpers.cxx
  1519. HRESULT CheckFileImplementsCLSID(const char *pszFileName, REFCLSID rClsid);
  1520. FILEXTN GetExtnAndBaseFileName( char *szName, char **plpBaseFileName);
  1521. HRESULT MakeUniqueTempDirectory(LPCSTR szTempDir, LPSTR szUniqueTempDir, int iLen);
  1522. HRESULT ComposeHackClsidFromMime(LPSTR szHackMimeType, int iLen, LPCSTR szClsid);
  1523. HRESULT GetHeaderValue (
  1524. LPCWSTR szResponseHeadersBuffer,
  1525. DWORD cbResponseHeadersBuffer,
  1526. LPCWSTR lpcszHeaderName,
  1527. LPWSTR pHeaderValue,
  1528. DWORD cbHeaderValue);
  1529. HRESULT
  1530. GetClsidFromExtOrMime(
  1531. REFCLSID rclsid,
  1532. CLSID &clsidout,
  1533. LPCWSTR szExt,
  1534. LPCWSTR szTYPE,
  1535. LPSTR *ppFileName);
  1536. STDAPI
  1537. AsyncGetClassBitsEx(
  1538. REFCLSID rclsid, // CLSID
  1539. CodeDownloadData * pcdd, // Contains requested object's descriptors
  1540. IBindCtx *pbc, // bind ctx: should contain BSC
  1541. DWORD dwClsContext, // CLSCTX flags
  1542. LPVOID pvReserved, // Must be NULL
  1543. REFIID riid); // Usually IID_IClassFactory
  1544. STDAPI
  1545. AsyncGetClassBits2Ex(
  1546. LPCWSTR szClientID, // client ID, root object if NULL
  1547. CodeDownloadData * pcdd, // Contains requested object's descriptors
  1548. IBindCtx *pbc, // bind ctx
  1549. DWORD dwClsContext, // CLSCTX flags
  1550. LPVOID pvReserved, // Must be NULL
  1551. REFIID riid, // Usually IID_IClassFactory
  1552. IUnknown **pUnk);
  1553. STDAPI
  1554. AsyncInstallDistributionUnitEx(
  1555. CodeDownloadData * pcdd, // Contains requested object's descriptors
  1556. IBindCtx *pbc, // bind ctx
  1557. REFIID riid,
  1558. IUnknown **pUnk,
  1559. LPVOID pvReserved); // Must be NULL
  1560. // backwards compatability
  1561. STDAPI
  1562. AsyncGetClassBits(
  1563. REFCLSID rclsid, // CLSID
  1564. LPCWSTR szType, // MIME type
  1565. LPCWSTR szExtension, // or Extension
  1566. // as alternate
  1567. // if CLSID == CLSID_NULL
  1568. DWORD dwFileVersionMS, // CODE=http://foo#Version=a,b,c,d
  1569. DWORD dwFileVersionLS, // MAKEDWORD(c,b) of above
  1570. LPCWSTR szURL, // CODEBASE= in OBJECT tag
  1571. IBindCtx *pbc, // bind ctx: should contain BSC
  1572. DWORD dwClsContext, // CLSCTX flags
  1573. LPVOID pvReserved, // Must be NULL
  1574. REFIID riid, // Usually IID_IClassFactory
  1575. DWORD flags);
  1576. STDAPI
  1577. AsyncInstallDistributionUnit(
  1578. LPCWSTR szDistUnit,
  1579. LPCWSTR szTYPE,
  1580. LPCWSTR szExt,
  1581. DWORD dwFileVersionMS, // CODEBASE=http://foo#Version=a,b,c,d
  1582. DWORD dwFileVersionLS, // MAKEDWORD(c,b) of above
  1583. LPCWSTR szURL, // CODEBASE
  1584. IBindCtx *pbc, // bind ctx
  1585. LPVOID pvReserved, // Must be NULL
  1586. DWORD flags);
  1587. STDAPI
  1588. AsyncGetClassBits2(
  1589. LPCWSTR szClientID, // client ID, root object if NULL
  1590. LPCWSTR szDistUnit, // CLSID, can be an arbit unique str
  1591. LPCWSTR szTYPE,
  1592. LPCWSTR szExt,
  1593. DWORD dwFileVersionMS, // CODE=http://foo#Version=a,b,c,d
  1594. DWORD dwFileVersionLS, // MAKEDWORD(c,b) of above
  1595. LPCWSTR szURL, // CODE= in INSERT tag
  1596. IBindCtx *pbc, // bind ctx
  1597. DWORD dwClsContext, // CLSCTX flags
  1598. LPVOID pvReserved, // Must be NULL
  1599. REFIID riid, // Usually IID_IClassFactory
  1600. DWORD flags);
  1601. #ifdef unix
  1602. extern "C"
  1603. #endif /* unix */
  1604. STDAPI_(DWORD)
  1605. CDLGetLongPathNameA(
  1606. LPSTR lpszLong,
  1607. LPCSTR lpszShort,
  1608. DWORD cchBuffer
  1609. );
  1610. #ifdef unix
  1611. extern "C"
  1612. #endif /* unix */
  1613. STDAPI_(DWORD)
  1614. CDLGetLongPathNameW(
  1615. LPWSTR lpszLongPath,
  1616. LPCWSTR lpszShortPath,
  1617. DWORD cchBuffer
  1618. );
  1619. HRESULT
  1620. GetActiveXSafetyProvider(
  1621. IActiveXSafetyProvider **ppProvider
  1622. );
  1623. extern int g_CPUType;
  1624. extern BOOL g_fRunningOnNT;
  1625. extern BOOL g_bNT5OrGreater;
  1626. #ifdef WX86
  1627. extern BOOL g_fWx86Present;
  1628. #endif
  1629. VOID
  1630. DetermineOSAndCPUVersion();
  1631. #ifdef UNICODE
  1632. #define CDLGetLongPathName CDLGetLongPathNameW
  1633. #else
  1634. #define CDLGetLongPathName CDLGetLongPathNameA
  1635. #endif // !UNICODE
  1636. #endif /* end hide classes from 'C' */
  1637. #endif // _CDL_H_