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

98 lines
2.3 KiB

  1. // %%Includes: ---------------------------------------------------------------
  2. #define INITGUID
  3. #define INC_OLE2
  4. #define STRICT
  5. extern "C" {
  6. #include <nt.h>
  7. #include <ntrtl.h>
  8. #include <nturtl.h>
  9. }
  10. #include <dbgutil.h>
  11. #include <ole2.h>
  12. #include <windows.h>
  13. #define SECURITY_WIN32
  14. #include <sspi.h>
  15. #include <admex.h>
  16. #include "comobj.hxx"
  17. #include "bootimp.hxx"
  18. DECLARE_PLATFORM_TYPE();
  19. DWORD g_dwComRegister;
  20. DWORD g_bInitialized = FALSE;
  21. // ---------------------------------------------------------------------------
  22. // %%Function: main
  23. // ---------------------------------------------------------------------------
  24. BOOL
  25. InitComAdmindata(BOOL bRunAsExe)
  26. {
  27. HRESULT hr;
  28. BOOL bReturn = TRUE;
  29. //
  30. // if win95, then don't register as service
  31. //
  32. INITIALIZE_PLATFORM_TYPE();
  33. if ( IISGetPlatformType() == PtWindows95 ) {
  34. DBG_ASSERT(bRunAsExe);
  35. DBGPRINTF((DBG_CONTEXT,
  36. "[InitComAdminData] Win95 - not registering as exe\n"));
  37. bRunAsExe = FALSE;
  38. }
  39. {
  40. CADMEXCOMSrvFactory *pADMClassFactory = new CADMEXCOMSrvFactory;
  41. if ( pADMClassFactory == NULL ) {
  42. DBGERROR((DBG_CONTEXT, "[InitComAdmindata] CADMEXCOMSrvFactory failed, error %lx\n",
  43. GetLastError() ));
  44. bReturn = FALSE;
  45. }
  46. else {
  47. // register the class-object with OLE
  48. hr = CoRegisterClassObject(CLSID_MSCryptoAdmEx, pADMClassFactory,
  49. CLSCTX_SERVER, REGCLS_MULTIPLEUSE, &g_dwComRegister);
  50. if (FAILED(hr)) {
  51. DBGERROR((DBG_CONTEXT, "[InitComAdmindata] CoRegisterClassObject failed, error %lx\n",
  52. GetLastError() ));
  53. bReturn = FALSE;
  54. delete pADMClassFactory;
  55. }
  56. }
  57. }
  58. g_bInitialized = bReturn;
  59. if ( bReturn ) {
  60. DBGPRINTF((DBG_CONTEXT, "[InitComAdmindata] success, bRunAsExe=%d\n", bRunAsExe ));
  61. }
  62. return bReturn;
  63. } // main
  64. BOOL
  65. TerminateComAdmindata()
  66. {
  67. DBGPRINTF((DBG_CONTEXT, "[TerminateComAdmindata]\n" ));
  68. if (g_bInitialized) {
  69. g_bInitialized = FALSE;
  70. (VOID)CoRevokeClassObject(g_dwComRegister);
  71. }
  72. return TRUE;
  73. }
  74. // EOF =======================================================================