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.

1411 lines
52 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1997.
  5. //
  6. // File: libmain.cxx
  7. //
  8. // Contents: LibMain for iisext.dll
  9. //
  10. // Functions: LibMain, DllGetClassObject
  11. //
  12. // History: 25-1-98 sophiac Created.
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "iisext.hxx"
  16. #pragma hdrstop
  17. HINSTANCE g_hInst = NULL;
  18. //
  19. // Global Data
  20. //
  21. WIN32_CRITSEC * g_pGlobalLock = NULL;
  22. SERVER_CACHE * g_pServerCache = NULL;
  23. DECLARE_DEBUG_PRINTS_OBJECT()
  24. #ifdef _NO_TRACING_
  25. DECLARE_DEBUG_VARIABLE();
  26. #endif
  27. //---------------------------------------------------------------------------
  28. // ADs debug print, mem leak and object tracking-related stuff
  29. //---------------------------------------------------------------------------
  30. DECLARE_INFOLEVEL(ADs)
  31. //+---------------------------------------------------------------------------
  32. //
  33. // Function: ShutDown
  34. //
  35. // Synopsis: Function to handle printing out heap debugging display
  36. //
  37. //----------------------------------------------------------------------------
  38. inline VOID ShutDown()
  39. {
  40. #if DBG==1
  41. #ifndef MSVC
  42. DUMP_TRACKING_INFO_DELETE();
  43. DeleteCriticalSection(&g_csOT);
  44. DeleteCriticalSection(&g_csMem);
  45. #endif // ifndef MSVC
  46. DeleteCriticalSection(&g_csDP);
  47. #endif
  48. }
  49. extern "C" DWORD heapInfoLevel;
  50. extern "C" DWORD OtInfoLevel;
  51. extern "C" DWORD ADsInfoLevel;
  52. //+---------------------------------------------------------------------------
  53. //
  54. // Function: GetINIHeapInfoLevel
  55. //
  56. // Synopsis: Gets various infolevel values from win.ini
  57. //
  58. //----------------------------------------------------------------------------
  59. inline VOID GetINIHeapInfoLevel()
  60. {
  61. #if DBG==1
  62. const INT MAXINFOLEN=11;
  63. WCHAR awcs[MAXINFOLEN];
  64. #ifndef MSVC
  65. if (GetProfileString(L"IISEXT",L"heapInfoLevel", L"00000003", awcs,MAXINFOLEN))
  66. heapInfoLevel = wcstoul(awcs, NULL, 16);
  67. if (GetProfileString(L"IISEXT",L"Ot", L"00000003", awcs, MAXINFOLEN))
  68. OtInfoLevel = wcstoul(awcs, NULL, 16);
  69. #endif // MSVC
  70. if (GetProfileString(L"IISEXT",L"ADsInfoLevel", L"00000003", awcs,MAXINFOLEN))
  71. ADsInfoLevel = wcstoul(awcs, NULL, 16);
  72. #endif
  73. }
  74. // Globals
  75. ULONG g_ulObjCount = 0; // Number of objects alive in oleds.dll
  76. //+------------------------------------------------------------------------
  77. //
  78. // Macro that calculates the number of elements in a statically-defined
  79. // array.
  80. //
  81. // Note - I swiped this from ADsary.cxx - A type-safe array class. Remember
  82. // to swipe the whole thing as required.
  83. //-------------------------------------------------------------------------
  84. #define ARRAY_SIZE(_a) (sizeof(_a) / sizeof(_a[0]))
  85. CIISComputerCF g_cfComputer;
  86. CIISServerCF g_cfServer;
  87. CIISAppCF g_cfApp;
  88. CIISDsCrMapCF g_cfDsCrMap;
  89. CIISApplicationPoolCF g_cfApplicationPool;
  90. CIISApplicationPoolsCF g_cfApplicationPools;
  91. CIISWebServiceCF g_cfWebService;
  92. //+------------------------------------------------------------------------
  93. //
  94. // oleds class factories
  95. //
  96. //-------------------------------------------------------------------------
  97. struct CLSCACHE
  98. {
  99. const CLSID * pclsid;
  100. IClassFactory * pCF;
  101. };
  102. CLSCACHE g_aclscache[] =
  103. {
  104. &CLSID_IISExtComputer, &g_cfComputer,
  105. &CLSID_IISExtServer, &g_cfServer,
  106. &CLSID_IISExtApp, &g_cfApp,
  107. &CLSID_IISExtDsCrMap, &g_cfDsCrMap,
  108. &CLSID_IISExtApplicationPool, &g_cfApplicationPool,
  109. &CLSID_IISExtApplicationPools, &g_cfApplicationPools,
  110. &CLSID_IISExtWebService, &g_cfWebService
  111. };
  112. //+---------------------------------------------------------------
  113. //
  114. // Function: DllGetClassObject
  115. //
  116. // Synopsis: Standard DLL entrypoint for locating class factories
  117. //
  118. //----------------------------------------------------------------
  119. STDAPI
  120. DllGetClassObject(REFCLSID clsid, REFIID iid, LPVOID FAR* ppv)
  121. {
  122. HRESULT hr;
  123. size_t i;
  124. for (i = 0; i < ARRAY_SIZE(g_aclscache); i++)
  125. {
  126. if (IsEqualCLSID(clsid, *g_aclscache[i].pclsid))
  127. {
  128. hr = g_aclscache[i].pCF->QueryInterface(iid, ppv);
  129. RRETURN(hr);
  130. }
  131. }
  132. *ppv = NULL;
  133. //
  134. // Add Debugging Code to indicate that the oleds.DllGetClassObject has been called with an unknown CLSID.
  135. //
  136. return E_NOINTERFACE;
  137. }
  138. //+---------------------------------------------------------------
  139. //
  140. // Function: DllCanUnloadNow
  141. //
  142. // Synopsis: Standard DLL entrypoint to determine if DLL can be unloaded
  143. //
  144. //---------------------------------------------------------------
  145. STDAPI
  146. DllCanUnloadNow(void)
  147. {
  148. HRESULT hr;
  149. hr = S_FALSE;
  150. return hr;
  151. }
  152. //+---------------------------------------------------------------
  153. //
  154. // Function: LibMain
  155. //
  156. // Synopsis: Standard DLL initialization entrypoint
  157. //
  158. //---------------------------------------------------------------
  159. EXTERN_C BOOL __cdecl
  160. LibMain(HINSTANCE hInst, ULONG ulReason, LPVOID pvReserved)
  161. {
  162. HRESULT hr;
  163. switch (ulReason)
  164. {
  165. case DLL_PROCESS_ATTACH:
  166. DisableThreadLibraryCalls(hInst);
  167. g_pGlobalLock = new WIN32_CRITSEC();
  168. g_pServerCache = new SERVER_CACHE();
  169. g_hInst = hInst;
  170. #if DBG==1
  171. #ifndef MSVC
  172. InitializeCriticalSection(&g_csOT);
  173. InitializeCriticalSection(&g_csMem);
  174. #endif
  175. InitializeCriticalSection(&g_csDP);
  176. #endif
  177. #ifdef _NO_TRACING_
  178. CREATE_DEBUG_PRINT_OBJECT("iisext");
  179. SET_DEBUG_FLAGS(DEBUG_ERROR);
  180. #endif
  181. break;
  182. case DLL_PROCESS_DETACH:
  183. #ifdef _NO_TRACING_
  184. DELETE_DEBUG_PRINT_OBJECT();
  185. #endif
  186. ShutDown();
  187. delete(g_pGlobalLock);
  188. delete(g_pServerCache);
  189. break;
  190. default:
  191. break;
  192. }
  193. return TRUE;
  194. }
  195. //+---------------------------------------------------------------------------
  196. //
  197. // Function: DllMain
  198. //
  199. // Synopsis: entry point for NT - post .546
  200. //
  201. //----------------------------------------------------------------------------
  202. BOOL
  203. DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
  204. {
  205. return LibMain((HINSTANCE)hDll, dwReason, lpReserved);
  206. }
  207. //+------------------------------------------------------------------------
  208. //
  209. // Function: GetCachedClsidIndex
  210. //
  211. // Synopsis: Returns the index of the given CLSID in the cache, or
  212. // -1 if the CLSID is not present in the cache
  213. //
  214. // Arguments: [clsid]
  215. //
  216. // Returns: int
  217. //
  218. //-------------------------------------------------------------------------
  219. int
  220. GetCachedClsidIndex(REFCLSID clsid)
  221. {
  222. int i;
  223. CLSCACHE * pclscache;
  224. for (i = 0, pclscache = g_aclscache;
  225. i < ARRAY_SIZE(g_aclscache);
  226. i ++, pclscache++)
  227. {
  228. if (IsEqualCLSID(*pclscache->pclsid, clsid))
  229. return i;
  230. }
  231. return -1;
  232. }
  233. //+------------------------------------------------------------------------
  234. //
  235. // Function: GetCachedClassFactory
  236. //
  237. // Synopsis: Returns the cached class factory with the given index.
  238. // The pointer returned has been AddRef'd.
  239. //
  240. // Arguments: [iclsid]
  241. //
  242. // Returns: IClassFactory *
  243. //
  244. //-------------------------------------------------------------------------
  245. IClassFactory *
  246. GetCachedClassFactory(int iclsid)
  247. {
  248. IClassFactory * pCF;
  249. // Assert(iclsid >= 0);
  250. // Assert(iclsid < ARRAY_SIZE(g_aclscache));
  251. pCF = g_aclscache[iclsid].pCF;
  252. pCF->AddRef();
  253. return pCF;
  254. }
  255. //+------------------------------------------------------------------------
  256. //
  257. // Function: GetCachedClsid
  258. //
  259. // Synopsis: Returns the CLSID corresponding to the given index.
  260. // Normally, code should call GetCachedClassFactory to get
  261. // the class factory directly.
  262. //
  263. // Arguments: [iclsid] -- Clsid index
  264. // [pclsid] -- Matching clsid returned in *pclsid
  265. //
  266. //-------------------------------------------------------------------------
  267. void
  268. GetCachedClsid(int iclsid, CLSID * pclsid)
  269. {
  270. // Assert(iclsid >= 0);
  271. // Assert(iclsid < ARRAY_SIZE(g_aclscache));
  272. *pclsid = *g_aclscache[iclsid].pclsid;
  273. }
  274. //+------------------------------------------------------------------------
  275. //
  276. // Function: DllRegisterServer
  277. //
  278. // Synopsis: Register registry keys for adsiis
  279. //
  280. // Arguments: None
  281. //
  282. //-------------------------------------------------------------------------
  283. STDAPI DllRegisterServer(
  284. )
  285. {
  286. HKEY hKeyCLSID, hKeyTemp;
  287. DWORD dwDisposition;
  288. HMODULE hModule;
  289. HRESULT hr;
  290. ITypeLib *pITypeLib;
  291. WCHAR pszName[MAX_PATH +1];
  292. int i;
  293. hModule=GetModuleHandle(TEXT("IISEXT.DLL"));
  294. if (!hModule) {
  295. return E_UNEXPECTED;
  296. }
  297. if (GetModuleFileName(hModule, pszName, (sizeof pszName)/(sizeof pszName[0]) ) ==0) {
  298. return E_UNEXPECTED;
  299. }
  300. DWORD dwNameSize = (wcslen(pszName) + 1) * sizeof(WCHAR);
  301. hr=LoadTypeLibEx(pszName, REGKIND_REGISTER, &pITypeLib);
  302. if (FAILED(hr)) {
  303. return E_UNEXPECTED;
  304. }
  305. pITypeLib->Release();
  306. if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,
  307. TEXT("Software\\Microsoft\\ADs\\Providers\\IIS\\Extensions\\IIsCertMapper\\{bc36cde8-afeb-11d1-9868-00a0c922e703}"),
  308. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  309. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  310. return E_UNEXPECTED;
  311. }
  312. if (RegSetValueEx(hKeyTemp, TEXT("Interfaces"), NULL, REG_MULTI_SZ,
  313. (BYTE*) TEXT("{edcd6a60-b053-11d0-a62f-00a0c922e752}"),
  314. sizeof(TEXT("{edcd6a60-b053-11d0-a62f-00a0c922e752}")))!=ERROR_SUCCESS) {
  315. RegCloseKey(hKeyTemp);
  316. return E_UNEXPECTED;
  317. }
  318. RegCloseKey(hKeyTemp);
  319. if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,
  320. TEXT("Software\\Microsoft\\ADs\\Providers\\IIS\\Extensions\\IIsComputer\\{91ef9258-afec-11d1-9868-00a0c922e703}"),
  321. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  322. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  323. return E_UNEXPECTED;
  324. }
  325. if (RegSetValueEx(hKeyTemp, TEXT("Interfaces"), NULL, REG_MULTI_SZ,
  326. (BYTE*) TEXT("{CF87A2E0-078B-11d1-9C3D-00A0C922E703}"),
  327. sizeof(TEXT("{CF87A2E0-078B-11d1-9C3D-00A0C922E703}")))!=ERROR_SUCCESS) {
  328. RegCloseKey(hKeyTemp);
  329. return E_UNEXPECTED;
  330. }
  331. RegCloseKey(hKeyTemp);
  332. if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,
  333. TEXT("Software\\Microsoft\\ADs\\Providers\\IIS\\Extensions\\IIsApplicationPool\\{E99F9D0C-FB39-402b-9EEB-AA185237BD34}"),
  334. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  335. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  336. return E_UNEXPECTED;
  337. }
  338. if (RegSetValueEx(hKeyTemp, TEXT("Interfaces"), NULL, REG_MULTI_SZ,
  339. (BYTE*) TEXT("{0B3CB1E1-829A-4c06-8B09-F56DA1894C88}"),
  340. sizeof(TEXT("{0B3CB1E1-829A-4c06-8B09-F56DA1894C88}")))!=ERROR_SUCCESS) {
  341. RegCloseKey(hKeyTemp);
  342. return E_UNEXPECTED;
  343. }
  344. RegCloseKey(hKeyTemp);
  345. if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,
  346. TEXT("Software\\Microsoft\\ADs\\Providers\\IIS\\Extensions\\IIsApplicationPools\\{95863074-A389-406a-A2D7-D98BFC95B905}"),
  347. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  348. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  349. return E_UNEXPECTED;
  350. }
  351. if (RegSetValueEx(hKeyTemp, TEXT("Interfaces"), NULL, REG_MULTI_SZ,
  352. (BYTE*) TEXT("{587F123F-49B4-49dd-939E-F4547AA3FA75}"),
  353. sizeof(TEXT("{587F123F-49B4-49dd-939E-F4547AA3FA75}")))!=ERROR_SUCCESS) {
  354. RegCloseKey(hKeyTemp);
  355. return E_UNEXPECTED;
  356. }
  357. RegCloseKey(hKeyTemp);
  358. if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,
  359. TEXT("Software\\Microsoft\\ADs\\Providers\\IIS\\Extensions\\IIsWebService\\{40B8F873-B30E-475d-BEC5-4D0EBB0DBAF3}"),
  360. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  361. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  362. return E_UNEXPECTED;
  363. }
  364. if (RegSetValueEx(hKeyTemp, TEXT("Interfaces"), NULL, REG_MULTI_SZ,
  365. (BYTE*) TEXT("{EE46D40C-1B38-4a02-898D-358E74DFC9D2}"),
  366. sizeof(TEXT("{EE46D40C-1B38-4a02-898D-358E74DFC9D2}")))!=ERROR_SUCCESS) {
  367. RegCloseKey(hKeyTemp);
  368. return E_UNEXPECTED;
  369. }
  370. RegCloseKey(hKeyTemp);
  371. if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,
  372. TEXT("Software\\Microsoft\\ADs\\Providers\\IIS\\Extensions\\IIsApp\\{b4f34438-afec-11d1-9868-00a0c922e703}"),
  373. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  374. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  375. return E_UNEXPECTED;
  376. }
  377. // if (RegSetValueEx(hKeyTemp, TEXT("Interfaces"), NULL, REG_MULTI_SZ,
  378. // (BYTE*) TEXT("{46FBBB80-0192-11d1-9C39-00A0C922E703}"),
  379. // sizeof(TEXT("{46FBBB80-0192-11d1-9C39-00A0C922E703}")))!=ERROR_SUCCESS) {
  380. // RegCloseKey(hKeyTemp);
  381. // return E_UNEXPECTED;
  382. // }
  383. TCHAR appInterfaces[] =
  384. TEXT("{46FBBB80-0192-11d1-9C39-00A0C922E703}\0{603DCBEA-7350-11d2-A7BE-0000F8085B95}\0{2812b639-8fac-4510-96c5-71ddbd1f54fc}\0\0");
  385. if (RegSetValueEx(hKeyTemp, TEXT("Interfaces"), NULL, REG_MULTI_SZ,
  386. (BYTE*) appInterfaces, sizeof(appInterfaces))!=ERROR_SUCCESS)
  387. {
  388. RegCloseKey(hKeyTemp);
  389. return E_UNEXPECTED;
  390. }
  391. RegCloseKey(hKeyTemp);
  392. if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,
  393. TEXT("Software\\Microsoft\\ADs\\Providers\\IIS\\Extensions\\IIsServer\\{c3b32488-afec-11d1-9868-00a0c922e703}"),
  394. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  395. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  396. return E_UNEXPECTED;
  397. }
  398. if (RegSetValueEx(hKeyTemp, TEXT("Interfaces"), NULL, REG_MULTI_SZ,
  399. (BYTE*) TEXT("{5d7b33f0-31ca-11cf-a98a-00aa006bc149}"),
  400. sizeof(TEXT("{5d7b33f0-31ca-11cf-a98a-00aa006bc149}")))!=ERROR_SUCCESS) {
  401. RegCloseKey(hKeyTemp);
  402. return E_UNEXPECTED;
  403. }
  404. RegCloseKey(hKeyTemp);
  405. if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
  406. TEXT("IISExtDsCrMap\\CLSID"),
  407. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  408. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  409. return E_UNEXPECTED;
  410. }
  411. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  412. (BYTE*) TEXT("{bc36cde8-afeb-11d1-9868-00a0c922e703}"),
  413. sizeof(TEXT("{bc36cde8-afeb-11d1-9868-00a0c922e703}")))!=ERROR_SUCCESS) {
  414. RegCloseKey(hKeyTemp);
  415. return E_UNEXPECTED;
  416. }
  417. RegCloseKey(hKeyTemp);
  418. //
  419. // register CLSID
  420. //
  421. if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
  422. TEXT("CLSID\\{bc36cde8-afeb-11d1-9868-00a0c922e703}"),
  423. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  424. &hKeyCLSID, &dwDisposition)!=ERROR_SUCCESS) {
  425. return E_UNEXPECTED;
  426. }
  427. if (RegSetValueEx(hKeyCLSID, TEXT(""), NULL, REG_SZ,
  428. (BYTE*) TEXT("IIS Cert Map Extension"),
  429. sizeof(TEXT("IIS Cert Map Extension")))!=ERROR_SUCCESS) {
  430. RegCloseKey(hKeyCLSID);
  431. return E_UNEXPECTED;
  432. }
  433. if (RegCreateKeyEx(hKeyCLSID,
  434. TEXT("InprocServer32"),
  435. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  436. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  437. RegCloseKey(hKeyCLSID);
  438. return E_UNEXPECTED;
  439. }
  440. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  441. (BYTE*) pszName,
  442. dwNameSize)!=ERROR_SUCCESS) {
  443. RegCloseKey(hKeyTemp);
  444. RegCloseKey(hKeyCLSID);
  445. return E_UNEXPECTED;
  446. }
  447. if (RegSetValueEx(hKeyTemp, TEXT("ThreadingModel"), NULL, REG_SZ,
  448. (BYTE*) TEXT("Both"),
  449. sizeof(TEXT("Both")))!=ERROR_SUCCESS) {
  450. RegCloseKey(hKeyTemp);
  451. RegCloseKey(hKeyCLSID);
  452. return E_UNEXPECTED;
  453. }
  454. RegCloseKey(hKeyTemp);
  455. if (RegCreateKeyEx(hKeyCLSID,
  456. TEXT("ProgID"),
  457. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  458. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  459. RegCloseKey(hKeyCLSID);
  460. return E_UNEXPECTED;
  461. }
  462. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  463. (BYTE*) TEXT("IISExtDsCrMap"),
  464. sizeof(TEXT("IISExtDsCrMap")))!=ERROR_SUCCESS) {
  465. RegCloseKey(hKeyTemp);
  466. RegCloseKey(hKeyCLSID);
  467. return E_UNEXPECTED;
  468. }
  469. RegCloseKey(hKeyTemp);
  470. if (RegCreateKeyEx(hKeyCLSID,
  471. TEXT("TypeLib"),
  472. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  473. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  474. RegCloseKey(hKeyCLSID);
  475. return E_UNEXPECTED;
  476. }
  477. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  478. (BYTE*) TEXT("{2a56ea30-afeb-11d1-9868-00a0c922e703}"),
  479. sizeof(TEXT("{2a56ea30-afeb-11d1-9868-00a0c922e703}")))!=ERROR_SUCCESS) {
  480. RegCloseKey(hKeyTemp);
  481. RegCloseKey(hKeyCLSID);
  482. return E_UNEXPECTED;
  483. }
  484. RegCloseKey(hKeyTemp);
  485. if (RegCreateKeyEx(hKeyCLSID,
  486. TEXT("Version"),
  487. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  488. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  489. RegCloseKey(hKeyCLSID);
  490. return E_UNEXPECTED;
  491. }
  492. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  493. (BYTE*) TEXT("0.0"),
  494. sizeof(TEXT("0.0")))!=ERROR_SUCCESS) {
  495. RegCloseKey(hKeyTemp);
  496. RegCloseKey(hKeyCLSID);
  497. return E_UNEXPECTED;
  498. }
  499. RegCloseKey(hKeyTemp);
  500. RegCloseKey(hKeyCLSID);
  501. if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
  502. TEXT("IISExtComputer\\CLSID"),
  503. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  504. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  505. return E_UNEXPECTED;
  506. }
  507. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  508. (BYTE*) TEXT("{91ef9258-afec-11d1-9868-00a0c922e703}"),
  509. sizeof(TEXT("{91ef9258-afec-11d1-9868-00a0c922e703}")))!=ERROR_SUCCESS) {
  510. RegCloseKey(hKeyTemp);
  511. return E_UNEXPECTED;
  512. }
  513. RegCloseKey(hKeyTemp);
  514. //
  515. // register CLSID
  516. //
  517. if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
  518. TEXT("CLSID\\{91ef9258-afec-11d1-9868-00a0c922e703}"),
  519. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  520. &hKeyCLSID, &dwDisposition)!=ERROR_SUCCESS) {
  521. return E_UNEXPECTED;
  522. }
  523. if (RegSetValueEx(hKeyCLSID, TEXT(""), NULL, REG_SZ,
  524. (BYTE*) TEXT("IIS Computer Extension"),
  525. sizeof(TEXT("IIS Computer Extension")))!=ERROR_SUCCESS) {
  526. RegCloseKey(hKeyCLSID);
  527. return E_UNEXPECTED;
  528. }
  529. if (RegCreateKeyEx(hKeyCLSID,
  530. TEXT("InprocServer32"),
  531. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  532. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  533. RegCloseKey(hKeyCLSID);
  534. return E_UNEXPECTED;
  535. }
  536. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  537. (BYTE*) pszName,
  538. dwNameSize)!=ERROR_SUCCESS) {
  539. RegCloseKey(hKeyTemp);
  540. RegCloseKey(hKeyCLSID);
  541. return E_UNEXPECTED;
  542. }
  543. if (RegSetValueEx(hKeyTemp, TEXT("ThreadingModel"), NULL, REG_SZ,
  544. (BYTE*) TEXT("Both"),
  545. sizeof(TEXT("Both")))!=ERROR_SUCCESS) {
  546. RegCloseKey(hKeyTemp);
  547. RegCloseKey(hKeyCLSID);
  548. return E_UNEXPECTED;
  549. }
  550. RegCloseKey(hKeyTemp);
  551. if (RegCreateKeyEx(hKeyCLSID,
  552. TEXT("ProgID"),
  553. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  554. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  555. RegCloseKey(hKeyCLSID);
  556. return E_UNEXPECTED;
  557. }
  558. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  559. (BYTE*) TEXT("IISExtComputer"),
  560. sizeof(TEXT("IISExtComputer")))!=ERROR_SUCCESS) {
  561. RegCloseKey(hKeyTemp);
  562. RegCloseKey(hKeyCLSID);
  563. return E_UNEXPECTED;
  564. }
  565. RegCloseKey(hKeyTemp);
  566. if (RegCreateKeyEx(hKeyCLSID,
  567. TEXT("TypeLib"),
  568. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  569. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  570. RegCloseKey(hKeyCLSID);
  571. return E_UNEXPECTED;
  572. }
  573. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  574. (BYTE*) TEXT("{2a56ea30-afeb-11d1-9868-00a0c922e703}"),
  575. sizeof(TEXT("{2a56ea30-afeb-11d1-9868-00a0c922e703}")))!=ERROR_SUCCESS) {
  576. RegCloseKey(hKeyTemp);
  577. RegCloseKey(hKeyCLSID);
  578. return E_UNEXPECTED;
  579. }
  580. RegCloseKey(hKeyTemp);
  581. if (RegCreateKeyEx(hKeyCLSID,
  582. TEXT("Version"),
  583. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  584. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  585. RegCloseKey(hKeyCLSID);
  586. return E_UNEXPECTED;
  587. }
  588. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  589. (BYTE*) TEXT("0.0"),
  590. sizeof(TEXT("0.0")))!=ERROR_SUCCESS) {
  591. RegCloseKey(hKeyTemp);
  592. RegCloseKey(hKeyCLSID);
  593. return E_UNEXPECTED;
  594. }
  595. RegCloseKey(hKeyTemp);
  596. RegCloseKey(hKeyCLSID);
  597. if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
  598. TEXT("IISExtApplicationPool\\CLSID"),
  599. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  600. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  601. return E_UNEXPECTED;
  602. }
  603. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  604. (BYTE*) TEXT("{E99F9D0C-FB39-402b-9EEB-AA185237BD34}"),
  605. sizeof(TEXT("{E99F9D0C-FB39-402b-9EEB-AA185237BD34}")))!=ERROR_SUCCESS) {
  606. RegCloseKey(hKeyTemp);
  607. return E_UNEXPECTED;
  608. }
  609. RegCloseKey(hKeyTemp);
  610. //
  611. // register CLSID
  612. //
  613. if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
  614. TEXT("CLSID\\{E99F9D0C-FB39-402b-9EEB-AA185237BD34}"),
  615. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  616. &hKeyCLSID, &dwDisposition)!=ERROR_SUCCESS) {
  617. return E_UNEXPECTED;
  618. }
  619. if (RegSetValueEx(hKeyCLSID, TEXT(""), NULL, REG_SZ,
  620. (BYTE*) TEXT("IIS ApplicationPool Extension"),
  621. sizeof(TEXT("IIS ApplicationPool Extension")))!=ERROR_SUCCESS) {
  622. RegCloseKey(hKeyCLSID);
  623. return E_UNEXPECTED;
  624. }
  625. if (RegCreateKeyEx(hKeyCLSID,
  626. TEXT("InprocServer32"),
  627. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  628. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  629. RegCloseKey(hKeyCLSID);
  630. return E_UNEXPECTED;
  631. }
  632. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  633. (BYTE*) pszName,
  634. dwNameSize)!=ERROR_SUCCESS) {
  635. RegCloseKey(hKeyTemp);
  636. RegCloseKey(hKeyCLSID);
  637. return E_UNEXPECTED;
  638. }
  639. if (RegSetValueEx(hKeyTemp, TEXT("ThreadingModel"), NULL, REG_SZ,
  640. (BYTE*) TEXT("Both"),
  641. sizeof(TEXT("Both")))!=ERROR_SUCCESS) {
  642. RegCloseKey(hKeyTemp);
  643. RegCloseKey(hKeyCLSID);
  644. return E_UNEXPECTED;
  645. }
  646. RegCloseKey(hKeyTemp);
  647. if (RegCreateKeyEx(hKeyCLSID,
  648. TEXT("ProgID"),
  649. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  650. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  651. RegCloseKey(hKeyCLSID);
  652. return E_UNEXPECTED;
  653. }
  654. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  655. (BYTE*) TEXT("IISExtApplicationPool"),
  656. sizeof(TEXT("IISExtApplicationPool")))!=ERROR_SUCCESS) {
  657. RegCloseKey(hKeyTemp);
  658. RegCloseKey(hKeyCLSID);
  659. return E_UNEXPECTED;
  660. }
  661. RegCloseKey(hKeyTemp);
  662. if (RegCreateKeyEx(hKeyCLSID,
  663. TEXT("TypeLib"),
  664. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  665. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  666. RegCloseKey(hKeyCLSID);
  667. return E_UNEXPECTED;
  668. }
  669. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  670. (BYTE*) TEXT("{2a56ea30-afeb-11d1-9868-00a0c922e703}"),
  671. sizeof(TEXT("{2a56ea30-afeb-11d1-9868-00a0c922e703}")))!=ERROR_SUCCESS) {
  672. RegCloseKey(hKeyTemp);
  673. RegCloseKey(hKeyCLSID);
  674. return E_UNEXPECTED;
  675. }
  676. RegCloseKey(hKeyTemp);
  677. if (RegCreateKeyEx(hKeyCLSID,
  678. TEXT("Version"),
  679. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  680. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  681. RegCloseKey(hKeyCLSID);
  682. return E_UNEXPECTED;
  683. }
  684. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  685. (BYTE*) TEXT("0.0"),
  686. sizeof(TEXT("0.0")))!=ERROR_SUCCESS) {
  687. RegCloseKey(hKeyTemp);
  688. RegCloseKey(hKeyCLSID);
  689. return E_UNEXPECTED;
  690. }
  691. RegCloseKey(hKeyTemp);
  692. RegCloseKey(hKeyCLSID);
  693. if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
  694. TEXT("IISExtApplicationPools\\CLSID"),
  695. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  696. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  697. return E_UNEXPECTED;
  698. }
  699. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  700. (BYTE*) TEXT("{95863074-A389-406a-A2D7-D98BFC95B905}"),
  701. sizeof(TEXT("{95863074-A389-406a-A2D7-D98BFC95B905}")))!=ERROR_SUCCESS) {
  702. RegCloseKey(hKeyTemp);
  703. return E_UNEXPECTED;
  704. }
  705. RegCloseKey(hKeyTemp);
  706. if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
  707. TEXT("CLSID\\{95863074-A389-406a-A2D7-D98BFC95B905}"),
  708. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  709. &hKeyCLSID, &dwDisposition)!=ERROR_SUCCESS) {
  710. return E_UNEXPECTED;
  711. }
  712. if (RegSetValueEx(hKeyCLSID, TEXT(""), NULL, REG_SZ,
  713. (BYTE*) TEXT("IIS ApplicationPools Extension"),
  714. sizeof(TEXT("IIS ApplicationPools Extension")))!=ERROR_SUCCESS) {
  715. RegCloseKey(hKeyCLSID);
  716. return E_UNEXPECTED;
  717. }
  718. if (RegCreateKeyEx(hKeyCLSID,
  719. TEXT("InprocServer32"),
  720. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  721. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  722. RegCloseKey(hKeyCLSID);
  723. return E_UNEXPECTED;
  724. }
  725. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  726. (BYTE*) pszName,
  727. dwNameSize)!=ERROR_SUCCESS) {
  728. RegCloseKey(hKeyTemp);
  729. RegCloseKey(hKeyCLSID);
  730. return E_UNEXPECTED;
  731. }
  732. if (RegSetValueEx(hKeyTemp, TEXT("ThreadingModel"), NULL, REG_SZ,
  733. (BYTE*) TEXT("Both"),
  734. sizeof(TEXT("Both")))!=ERROR_SUCCESS) {
  735. RegCloseKey(hKeyTemp);
  736. RegCloseKey(hKeyCLSID);
  737. return E_UNEXPECTED;
  738. }
  739. RegCloseKey(hKeyTemp);
  740. if (RegCreateKeyEx(hKeyCLSID,
  741. TEXT("ProgID"),
  742. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  743. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  744. RegCloseKey(hKeyCLSID);
  745. return E_UNEXPECTED;
  746. }
  747. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  748. (BYTE*) TEXT("IISExtApplicationPools"),
  749. sizeof(TEXT("IISExtApplicationPools")))!=ERROR_SUCCESS) {
  750. RegCloseKey(hKeyTemp);
  751. RegCloseKey(hKeyCLSID);
  752. return E_UNEXPECTED;
  753. }
  754. RegCloseKey(hKeyTemp);
  755. if (RegCreateKeyEx(hKeyCLSID,
  756. TEXT("TypeLib"),
  757. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  758. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  759. RegCloseKey(hKeyCLSID);
  760. return E_UNEXPECTED;
  761. }
  762. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  763. (BYTE*) TEXT("{2a56ea30-afeb-11d1-9868-00a0c922e703}"),
  764. sizeof(TEXT("{2a56ea30-afeb-11d1-9868-00a0c922e703}")))!=ERROR_SUCCESS) {
  765. RegCloseKey(hKeyTemp);
  766. RegCloseKey(hKeyCLSID);
  767. return E_UNEXPECTED;
  768. }
  769. RegCloseKey(hKeyTemp);
  770. if (RegCreateKeyEx(hKeyCLSID,
  771. TEXT("Version"),
  772. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  773. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  774. RegCloseKey(hKeyCLSID);
  775. return E_UNEXPECTED;
  776. }
  777. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  778. (BYTE*) TEXT("0.0"),
  779. sizeof(TEXT("0.0")))!=ERROR_SUCCESS) {
  780. RegCloseKey(hKeyTemp);
  781. RegCloseKey(hKeyCLSID);
  782. return E_UNEXPECTED;
  783. }
  784. RegCloseKey(hKeyTemp);
  785. RegCloseKey(hKeyCLSID);
  786. if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
  787. TEXT("IISWebService\\CLSID"),
  788. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  789. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  790. return E_UNEXPECTED;
  791. }
  792. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  793. (BYTE*) TEXT("{40B8F873-B30E-475d-BEC5-4D0EBB0DBAF3}"),
  794. sizeof(TEXT("{40B8F873-B30E-475d-BEC5-4D0EBB0DBAF3}")))!=ERROR_SUCCESS) {
  795. RegCloseKey(hKeyTemp);
  796. return E_UNEXPECTED;
  797. }
  798. RegCloseKey(hKeyTemp);
  799. if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
  800. TEXT("CLSID\\{40B8F873-B30E-475d-BEC5-4D0EBB0DBAF3}"),
  801. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  802. &hKeyCLSID, &dwDisposition)!=ERROR_SUCCESS) {
  803. return E_UNEXPECTED;
  804. }
  805. if (RegSetValueEx(hKeyCLSID, TEXT(""), NULL, REG_SZ,
  806. (BYTE*) TEXT("IIS Web Service Extension"),
  807. sizeof(TEXT("IIS Web Service Extension")))!=ERROR_SUCCESS) {
  808. RegCloseKey(hKeyCLSID);
  809. return E_UNEXPECTED;
  810. }
  811. if (RegCreateKeyEx(hKeyCLSID,
  812. TEXT("InprocServer32"),
  813. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  814. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  815. RegCloseKey(hKeyCLSID);
  816. return E_UNEXPECTED;
  817. }
  818. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  819. (BYTE*) pszName,
  820. dwNameSize)!=ERROR_SUCCESS) {
  821. RegCloseKey(hKeyTemp);
  822. RegCloseKey(hKeyCLSID);
  823. return E_UNEXPECTED;
  824. }
  825. if (RegSetValueEx(hKeyTemp, TEXT("ThreadingModel"), NULL, REG_SZ,
  826. (BYTE*) TEXT("Both"),
  827. sizeof(TEXT("Both")))!=ERROR_SUCCESS) {
  828. RegCloseKey(hKeyTemp);
  829. RegCloseKey(hKeyCLSID);
  830. return E_UNEXPECTED;
  831. }
  832. RegCloseKey(hKeyTemp);
  833. if (RegCreateKeyEx(hKeyCLSID,
  834. TEXT("ProgID"),
  835. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  836. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  837. RegCloseKey(hKeyCLSID);
  838. return E_UNEXPECTED;
  839. }
  840. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  841. (BYTE*) TEXT("IISExtWebService"),
  842. sizeof(TEXT("IISExtWebService")))!=ERROR_SUCCESS) {
  843. RegCloseKey(hKeyTemp);
  844. RegCloseKey(hKeyCLSID);
  845. return E_UNEXPECTED;
  846. }
  847. RegCloseKey(hKeyTemp);
  848. if (RegCreateKeyEx(hKeyCLSID,
  849. TEXT("TypeLib"),
  850. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  851. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  852. RegCloseKey(hKeyCLSID);
  853. return E_UNEXPECTED;
  854. }
  855. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  856. (BYTE*) TEXT("{2a56ea30-afeb-11d1-9868-00a0c922e703}"),
  857. sizeof(TEXT("{2a56ea30-afeb-11d1-9868-00a0c922e703}")))!=ERROR_SUCCESS) {
  858. RegCloseKey(hKeyTemp);
  859. RegCloseKey(hKeyCLSID);
  860. return E_UNEXPECTED;
  861. }
  862. RegCloseKey(hKeyTemp);
  863. if (RegCreateKeyEx(hKeyCLSID,
  864. TEXT("Version"),
  865. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  866. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  867. RegCloseKey(hKeyCLSID);
  868. return E_UNEXPECTED;
  869. }
  870. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  871. (BYTE*) TEXT("0.0"),
  872. sizeof(TEXT("0.0")))!=ERROR_SUCCESS) {
  873. RegCloseKey(hKeyTemp);
  874. RegCloseKey(hKeyCLSID);
  875. return E_UNEXPECTED;
  876. }
  877. RegCloseKey(hKeyTemp);
  878. RegCloseKey(hKeyCLSID);
  879. if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
  880. TEXT("IISExtApp\\CLSID"),
  881. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  882. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  883. return E_UNEXPECTED;
  884. }
  885. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  886. (BYTE*) TEXT("{b4f34438-afec-11d1-9868-00a0c922e703}"),
  887. sizeof(TEXT("{b4f34438-afec-11d1-9868-00a0c922e703}")))!=ERROR_SUCCESS) {
  888. RegCloseKey(hKeyTemp);
  889. return E_UNEXPECTED;
  890. }
  891. RegCloseKey(hKeyTemp);
  892. //
  893. // register CLSID
  894. //
  895. if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
  896. TEXT("CLSID\\{b4f34438-afec-11d1-9868-00a0c922e703}"),
  897. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  898. &hKeyCLSID, &dwDisposition)!=ERROR_SUCCESS) {
  899. return E_UNEXPECTED;
  900. }
  901. if (RegSetValueEx(hKeyCLSID, TEXT(""), NULL, REG_SZ,
  902. (BYTE*) TEXT("IIS App Extension"),
  903. sizeof(TEXT("IIS App Extension")))!=ERROR_SUCCESS) {
  904. RegCloseKey(hKeyCLSID);
  905. return E_UNEXPECTED;
  906. }
  907. if (RegCreateKeyEx(hKeyCLSID,
  908. TEXT("InprocServer32"),
  909. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  910. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  911. RegCloseKey(hKeyCLSID);
  912. return E_UNEXPECTED;
  913. }
  914. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  915. (BYTE*) pszName,
  916. dwNameSize)!=ERROR_SUCCESS) {
  917. RegCloseKey(hKeyTemp);
  918. RegCloseKey(hKeyCLSID);
  919. return E_UNEXPECTED;
  920. }
  921. if (RegSetValueEx(hKeyTemp, TEXT("ThreadingModel"), NULL, REG_SZ,
  922. (BYTE*) TEXT("Both"),
  923. sizeof(TEXT("Both")))!=ERROR_SUCCESS) {
  924. RegCloseKey(hKeyTemp);
  925. RegCloseKey(hKeyCLSID);
  926. return E_UNEXPECTED;
  927. }
  928. RegCloseKey(hKeyTemp);
  929. if (RegCreateKeyEx(hKeyCLSID,
  930. TEXT("ProgID"),
  931. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  932. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  933. RegCloseKey(hKeyCLSID);
  934. return E_UNEXPECTED;
  935. }
  936. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  937. (BYTE*) TEXT("IISExtApp"),
  938. sizeof(TEXT("IISExtApp")))!=ERROR_SUCCESS) {
  939. RegCloseKey(hKeyTemp);
  940. RegCloseKey(hKeyCLSID);
  941. return E_UNEXPECTED;
  942. }
  943. RegCloseKey(hKeyTemp);
  944. if (RegCreateKeyEx(hKeyCLSID,
  945. TEXT("TypeLib"),
  946. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  947. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  948. RegCloseKey(hKeyCLSID);
  949. return E_UNEXPECTED;
  950. }
  951. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  952. (BYTE*) TEXT("{2a56ea30-afeb-11d1-9868-00a0c922e703}"),
  953. sizeof(TEXT("{2a56ea30-afeb-11d1-9868-00a0c922e703}")))!=ERROR_SUCCESS) {
  954. RegCloseKey(hKeyTemp);
  955. RegCloseKey(hKeyCLSID);
  956. return E_UNEXPECTED;
  957. }
  958. RegCloseKey(hKeyTemp);
  959. if (RegCreateKeyEx(hKeyCLSID,
  960. TEXT("Version"),
  961. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  962. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  963. RegCloseKey(hKeyCLSID);
  964. return E_UNEXPECTED;
  965. }
  966. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  967. (BYTE*) TEXT("0.0"),
  968. sizeof(TEXT("0.0")))!=ERROR_SUCCESS) {
  969. RegCloseKey(hKeyTemp);
  970. RegCloseKey(hKeyCLSID);
  971. return E_UNEXPECTED;
  972. }
  973. RegCloseKey(hKeyTemp);
  974. RegCloseKey(hKeyCLSID);
  975. if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
  976. TEXT("IISExtServer\\CLSID"),
  977. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  978. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  979. return E_UNEXPECTED;
  980. }
  981. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  982. (BYTE*) TEXT("{c3b32488-afec-11d1-9868-00a0c922e703}"),
  983. sizeof(TEXT("{c3b32488-afec-11d1-9868-00a0c922e703}")))!=ERROR_SUCCESS) {
  984. RegCloseKey(hKeyTemp);
  985. return E_UNEXPECTED;
  986. }
  987. RegCloseKey(hKeyTemp);
  988. //
  989. // register CLSID
  990. //
  991. if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
  992. TEXT("CLSID\\{c3b32488-afec-11d1-9868-00a0c922e703}"),
  993. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  994. &hKeyCLSID, &dwDisposition)!=ERROR_SUCCESS) {
  995. return E_UNEXPECTED;
  996. }
  997. if (RegSetValueEx(hKeyCLSID, TEXT(""), NULL, REG_SZ,
  998. (BYTE*) TEXT("IIS Server Extension"),
  999. sizeof(TEXT("IIS Server Extension")))!=ERROR_SUCCESS) {
  1000. RegCloseKey(hKeyCLSID);
  1001. return E_UNEXPECTED;
  1002. }
  1003. if (RegCreateKeyEx(hKeyCLSID,
  1004. TEXT("InprocServer32"),
  1005. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  1006. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  1007. RegCloseKey(hKeyCLSID);
  1008. return E_UNEXPECTED;
  1009. }
  1010. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  1011. (BYTE*) pszName,
  1012. dwNameSize)!=ERROR_SUCCESS) {
  1013. RegCloseKey(hKeyTemp);
  1014. RegCloseKey(hKeyCLSID);
  1015. return E_UNEXPECTED;
  1016. }
  1017. if (RegSetValueEx(hKeyTemp, TEXT("ThreadingModel"), NULL, REG_SZ,
  1018. (BYTE*) TEXT("Both"),
  1019. sizeof(TEXT("Both")))!=ERROR_SUCCESS) {
  1020. RegCloseKey(hKeyTemp);
  1021. RegCloseKey(hKeyCLSID);
  1022. return E_UNEXPECTED;
  1023. }
  1024. RegCloseKey(hKeyTemp);
  1025. if (RegCreateKeyEx(hKeyCLSID,
  1026. TEXT("ProgID"),
  1027. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  1028. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  1029. RegCloseKey(hKeyCLSID);
  1030. return E_UNEXPECTED;
  1031. }
  1032. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  1033. (BYTE*) TEXT("IISExtServer"),
  1034. sizeof(TEXT("IISExtServer")))!=ERROR_SUCCESS) {
  1035. RegCloseKey(hKeyTemp);
  1036. RegCloseKey(hKeyCLSID);
  1037. return E_UNEXPECTED;
  1038. }
  1039. RegCloseKey(hKeyTemp);
  1040. if (RegCreateKeyEx(hKeyCLSID,
  1041. TEXT("TypeLib"),
  1042. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  1043. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  1044. RegCloseKey(hKeyCLSID);
  1045. return E_UNEXPECTED;
  1046. }
  1047. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  1048. (BYTE*) TEXT("{2a56ea30-afeb-11d1-9868-00a0c922e703}"),
  1049. sizeof(TEXT("{2a56ea30-afeb-11d1-9868-00a0c922e703}")))!=ERROR_SUCCESS) {
  1050. RegCloseKey(hKeyTemp);
  1051. RegCloseKey(hKeyCLSID);
  1052. return E_UNEXPECTED;
  1053. }
  1054. RegCloseKey(hKeyTemp);
  1055. if (RegCreateKeyEx(hKeyCLSID,
  1056. TEXT("Version"),
  1057. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  1058. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  1059. RegCloseKey(hKeyCLSID);
  1060. return E_UNEXPECTED;
  1061. }
  1062. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  1063. (BYTE*) TEXT("0.0"),
  1064. sizeof(TEXT("0.0")))!=ERROR_SUCCESS) {
  1065. RegCloseKey(hKeyTemp);
  1066. RegCloseKey(hKeyCLSID);
  1067. return E_UNEXPECTED;
  1068. }
  1069. RegCloseKey(hKeyTemp);
  1070. RegCloseKey(hKeyCLSID);
  1071. return NOERROR;
  1072. }
  1073. //+------------------------------------------------------------------------
  1074. //
  1075. // Function: DllUnregisterServer
  1076. //
  1077. // Synopsis: Register registry keys for adsiis
  1078. //
  1079. // Arguments: None
  1080. //
  1081. //+------------------------------------------------------------------------
  1082. /* #pragma INTRINSA suppress=all */
  1083. STDAPI DllUnregisterServer(void) {
  1084. UnRegisterTypeLib(LIBID_IISExt,
  1085. 1,
  1086. 0,
  1087. 0,
  1088. SYS_WIN32);
  1089. RegDeleteKey(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\ADs\\Providers\\IIS\\Extensions\\IIsCertMapper\\{bc36cde8-afeb-11d1-9868-00a0c922e703}"));
  1090. RegDeleteKey(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\ADs\\Providers\\IIS\\Extensions\\IIsCertMapper"));
  1091. RegDeleteKey(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\ADs\\Providers\\IIS\\Extensions\\IIsComputer\\{91ef9258-afec-11d1-9868-00a0c922e703}"));
  1092. RegDeleteKey(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\ADs\\Providers\\IIS\\Extensions\\IIsComputer"));
  1093. RegDeleteKey(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\ADs\\Providers\\IIS\\Extensions\\IIsApplicationPool\\{E99F9D0C-FB39-402b-9EEB-AA185237BD34}"));
  1094. RegDeleteKey(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\ADs\\Providers\\IIS\\Extensions\\IIsApplicationPool"));
  1095. RegDeleteKey(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\ADs\\Providers\\IIS\\Extensions\\IIsWebService\\{40B8F873-B30E-475d-BEC5-4D0EBB0DBAF3}"));
  1096. RegDeleteKey(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\ADs\\Providers\\IIS\\Extensions\\IIsWebService"));
  1097. RegDeleteKey(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\ADs\\Providers\\IIS\\Extensions\\IIsApplicationPools\\{95863074-A389-406a-A2D7-D98BFC95B905}"));
  1098. RegDeleteKey(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\ADs\\Providers\\IIS\\Extensions\\IIsApplicationPools"));
  1099. RegDeleteKey(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\ADs\\Providers\\IIS\\Extensions\\IIsApp\\{b4f34438-afec-11d1-9868-00a0c922e703}"));
  1100. RegDeleteKey(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\ADs\\Providers\\IIS\\Extensions\\IIsApp"));
  1101. RegDeleteKey(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\ADs\\Providers\\IIS\\Extensions\\IIsServer\\{c3b32488-afec-11d1-9868-00a0c922e703}"));
  1102. RegDeleteKey(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\ADs\\Providers\\IIS\\Extensions\\IIsServer"));
  1103. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("IISExtDsCrMap\\CLSID"));
  1104. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("IISExtDsCrMap"));
  1105. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{bc36cde8-afeb-11d1-9868-00a0c922e703}\\InprocServer32"));
  1106. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{bc36cde8-afeb-11d1-9868-00a0c922e703}\\ProgID"));
  1107. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{bc36cde8-afeb-11d1-9868-00a0c922e703}\\TypeLib"));
  1108. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{bc36cde8-afeb-11d1-9868-00a0c922e703}\\Version"));
  1109. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{bc36cde8-afeb-11d1-9868-00a0c922e703}"));
  1110. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("IISExtComputer\\CLSID"));
  1111. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("IISExtComputer"));
  1112. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{91ef9258-afec-11d1-9868-00a0c922e703}\\InprocServer32"));
  1113. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{91ef9258-afec-11d1-9868-00a0c922e703}\\ProgID"));
  1114. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{91ef9258-afec-11d1-9868-00a0c922e703}\\TypeLib"));
  1115. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{91ef9258-afec-11d1-9868-00a0c922e703}\\Version"));
  1116. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{91ef9258-afec-11d1-9868-00a0c922e703}"));
  1117. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("IISExtApplicationPool\\CLSID"));
  1118. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("IISExtApplicationPool"));
  1119. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{E99F9D0C-FB39-402b-9EEB-AA185237BD34}\\InprocServer32"));
  1120. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{E99F9D0C-FB39-402b-9EEB-AA185237BD34}\\ProgID"));
  1121. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{E99F9D0C-FB39-402b-9EEB-AA185237BD34}\\TypeLib"));
  1122. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{E99F9D0C-FB39-402b-9EEB-AA185237BD34}\\Version"));
  1123. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{E99F9D0C-FB39-402b-9EEB-AA185237BD34}"));
  1124. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("IISExtApplicationPools\\CLSID"));
  1125. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("IISExtApplicationPools"));
  1126. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{95863074-A389-406a-A2D7-D98BFC95B905}\\InprocServer32"));
  1127. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{95863074-A389-406a-A2D7-D98BFC95B905}\\ProgID"));
  1128. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{95863074-A389-406a-A2D7-D98BFC95B905}\\TypeLib"));
  1129. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{95863074-A389-406a-A2D7-D98BFC95B905}\\Version"));
  1130. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{95863074-A389-406a-A2D7-D98BFC95B905}"));
  1131. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("IISExtWebService\\CLSID"));
  1132. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("IISExtWebService"));
  1133. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{40B8F873-B30E-475d-BEC5-4D0EBB0DBAF3}\\InprocServer32"));
  1134. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{40B8F873-B30E-475d-BEC5-4D0EBB0DBAF3}\\ProgID"));
  1135. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{40B8F873-B30E-475d-BEC5-4D0EBB0DBAF3}\\TypeLib"));
  1136. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{40B8F873-B30E-475d-BEC5-4D0EBB0DBAF3}\\Version"));
  1137. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{40B8F873-B30E-475d-BEC5-4D0EBB0DBAF3}"));
  1138. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("IISExtApp\\CLSID"));
  1139. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("IISExtApp"));
  1140. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{91ef9258-afec-11d1-9868-00a0c922e703}\\InprocServer32"));
  1141. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{91ef9258-afec-11d1-9868-00a0c922e703}\\ProgID"));
  1142. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{91ef9258-afec-11d1-9868-00a0c922e703}\\TypeLib"));
  1143. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{91ef9258-afec-11d1-9868-00a0c922e703}\\Version"));
  1144. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{91ef9258-afec-11d1-9868-00a0c922e703}"));
  1145. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("IISExtServer\\CLSID"));
  1146. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("IISExtServer"));
  1147. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{c3b32488-afec-11d1-9868-00a0c922e703}\\InprocServer32"));
  1148. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{c3b32488-afec-11d1-9868-00a0c922e703}\\ProgID"));
  1149. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{c3b32488-afec-11d1-9868-00a0c922e703}\\TypeLib"));
  1150. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{c3b32488-afec-11d1-9868-00a0c922e703}\\Version"));
  1151. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{c3b32488-afec-11d1-9868-00a0c922e703}"));
  1152. return NOERROR;
  1153. }