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.

163 lines
4.7 KiB

  1. // CAPICOM.cpp : Implementation of DLL Exports.
  2. // Note: Proxy/Stub Information
  3. // To build a separate proxy/stub DLL,
  4. // run nmake -f CAPICOMps.mk in the project directory.
  5. //
  6. // Turn off:
  7. //
  8. // - Unreferenced formal parameter warning.
  9. // - Assignment within conditional expression warning.
  10. //
  11. #pragma warning (disable: 4100)
  12. #pragma warning (disable: 4706)
  13. #include "StdAfx.h"
  14. #include "Resource.h"
  15. #include <initguid.h>
  16. #include "CAPICOM.h"
  17. #include "CAPICOM_i.c"
  18. #include "Algorithm.h"
  19. #include "Attribute.h"
  20. #include "Attributes.h"
  21. #include "BasicConstraints.h"
  22. #include "Certificate.h"
  23. #include "Certificates.h"
  24. #include "CertificatePolicies.h"
  25. #include "CertificateStatus.h"
  26. #include "Chain.h"
  27. #include "EKU.h"
  28. #include "EKUs.h"
  29. #include "EncodedData.h"
  30. #include "EncryptedData.h"
  31. #include "EnvelopedData.h"
  32. #include "ExtendedKeyUsage.h"
  33. #include "ExtendedProperties.h"
  34. #include "ExtendedProperty.h"
  35. #include "Extension.h"
  36. #include "Extensions.h"
  37. #include "HashedData.h"
  38. #include "KeyUsage.h"
  39. #include "NoticeNumbers.h"
  40. #include "OID.h"
  41. #include "PolicyInformation.h"
  42. #include "PrivateKey.h"
  43. #include "PublicKey.h"
  44. #include "Qualifier.h"
  45. #include "Qualifiers.h"
  46. #include "Recipients.h"
  47. #include "Settings.h"
  48. #include "SignedCode.h"
  49. #include "SignedData.h"
  50. #include "Signer2.h"
  51. #include "Signers.h"
  52. #include "Store.h"
  53. #include "Template.h"
  54. #include "Utilities.h"
  55. #include "OIDs.h"
  56. CComModule _Module;
  57. /////////////////////////////////////////////////////////////////////////////
  58. //
  59. // Objec map
  60. //
  61. BEGIN_OBJECT_MAP(ObjectMap)
  62. OBJECT_ENTRY_NON_CREATEABLE(CEKU)
  63. OBJECT_ENTRY_NON_CREATEABLE(CEKUs)
  64. OBJECT_ENTRY_NON_CREATEABLE(CKeyUsage)
  65. OBJECT_ENTRY_NON_CREATEABLE(CExtendedKeyUsage)
  66. OBJECT_ENTRY_NON_CREATEABLE(CBasicConstraints)
  67. OBJECT_ENTRY_NON_CREATEABLE(CCertificateStatus)
  68. OBJECT_ENTRY_NON_CREATEABLE(CAttributes)
  69. OBJECT_ENTRY_NON_CREATEABLE(CSigners)
  70. OBJECT_ENTRY_NON_CREATEABLE(CAlgorithm)
  71. OBJECT_ENTRY_NON_CREATEABLE(CRecipients)
  72. OBJECT_ENTRY(CLSID_Settings, CSettings)
  73. OBJECT_ENTRY(CLSID_Certificate, CCertificate)
  74. OBJECT_ENTRY(CLSID_Certificates, CCertificates)
  75. OBJECT_ENTRY(CLSID_Store, CStore)
  76. OBJECT_ENTRY(CLSID_Chain, CChain)
  77. OBJECT_ENTRY(CLSID_Attribute, CAttribute)
  78. OBJECT_ENTRY(CLSID_Signer, CSigner)
  79. OBJECT_ENTRY(CLSID_SignedData, CSignedData)
  80. OBJECT_ENTRY(CLSID_EnvelopedData, CEnvelopedData)
  81. OBJECT_ENTRY(CLSID_EncryptedData, CEncryptedData)
  82. //
  83. // CAPICOM v2.0
  84. //
  85. OBJECT_ENTRY(CLSID_OID, COID)
  86. OBJECT_ENTRY_NON_CREATEABLE(COIDs)
  87. OBJECT_ENTRY_NON_CREATEABLE(CNoticeNumbers)
  88. OBJECT_ENTRY_NON_CREATEABLE(CQualifier)
  89. OBJECT_ENTRY_NON_CREATEABLE(CQualifiers)
  90. OBJECT_ENTRY_NON_CREATEABLE(CPolicyInformation)
  91. OBJECT_ENTRY_NON_CREATEABLE(CCertificatePolicies)
  92. OBJECT_ENTRY_NON_CREATEABLE(CEncodedData)
  93. OBJECT_ENTRY_NON_CREATEABLE(CTemplate)
  94. OBJECT_ENTRY_NON_CREATEABLE(CPublicKey)
  95. OBJECT_ENTRY(CLSID_PrivateKey, CPrivateKey)
  96. OBJECT_ENTRY_NON_CREATEABLE(CExtension)
  97. OBJECT_ENTRY_NON_CREATEABLE(CExtensions)
  98. OBJECT_ENTRY(CLSID_ExtendedProperty, CExtendedProperty)
  99. OBJECT_ENTRY_NON_CREATEABLE(CExtendedProperties)
  100. OBJECT_ENTRY(CLSID_SignedCode, CSignedCode)
  101. OBJECT_ENTRY(CLSID_HashedData, CHashedData)
  102. OBJECT_ENTRY(CLSID_Utilities, CUtilities)
  103. END_OBJECT_MAP()
  104. /////////////////////////////////////////////////////////////////////////////
  105. //
  106. // DLL Entry Point
  107. //
  108. extern "C"
  109. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  110. {
  111. if (dwReason == DLL_PROCESS_ATTACH)
  112. {
  113. _Module.Init(ObjectMap, hInstance, &LIBID_CAPICOM);
  114. DisableThreadLibraryCalls(hInstance);
  115. }
  116. else if (dwReason == DLL_PROCESS_DETACH)
  117. _Module.Term();
  118. return TRUE; // ok
  119. }
  120. /////////////////////////////////////////////////////////////////////////////
  121. // Used to determine whether the DLL can be unloaded by OLE
  122. STDAPI DllCanUnloadNow(void)
  123. {
  124. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  125. }
  126. /////////////////////////////////////////////////////////////////////////////
  127. // Returns a class factory to create an object of the requested type
  128. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  129. {
  130. return _Module.GetClassObject(rclsid, riid, ppv);
  131. }
  132. /////////////////////////////////////////////////////////////////////////////
  133. // DllRegisterServer - Adds entries to the system registry
  134. STDAPI DllRegisterServer(void)
  135. {
  136. // registers object, typelib and all interfaces in typelib
  137. return _Module.RegisterServer(TRUE);
  138. }
  139. /////////////////////////////////////////////////////////////////////////////
  140. // DllUnregisterServer - Removes entries from the system registry
  141. STDAPI DllUnregisterServer(void)
  142. {
  143. return _Module.UnregisterServer(TRUE);
  144. }