2 * Copyright (c) 2000-2001,2003-2004,2011,2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
26 // modload_plugin - loader interface for dynamically loaded plugin modules
28 #include "modload_plugin.h"
35 // During construction, a LoadablePlugin loads itself into memory and locates
36 // the canonical (CDSA defined) four entrypoints. If anything fails, we throw.
38 LoadablePlugin::LoadablePlugin(const char *path
) : LoadableBundle(path
)
40 secdebug("cssm", "LoadablePlugin(%s)", path
);
46 // Loading and unloading devolves directly onto LoadableBundle
48 void LoadablePlugin::load()
50 secdebug("cssm", "LoadablePlugin::load() path %s", path().c_str());
51 LoadableBundle::load();
52 findFunction(mFunctions
.load
, "CSSM_SPI_ModuleLoad");
53 findFunction(mFunctions
.attach
, "CSSM_SPI_ModuleAttach");
54 findFunction(mFunctions
.detach
, "CSSM_SPI_ModuleDetach");
55 findFunction(mFunctions
.unload
, "CSSM_SPI_ModuleUnload");
58 void LoadablePlugin::unload()
60 secdebug("cssm", "LoadablePlugin::unload() path %s", path().c_str());
61 /* skipping for workaround for radar 3774226
62 LoadableBundle::unload(); */
65 bool LoadablePlugin::isLoaded() const
67 return LoadableBundle::isLoaded();
72 // Pass module entry points to the statically linked functions
74 CSSM_RETURN
LoadablePlugin::load(const CSSM_GUID
*CssmGuid
,
75 const CSSM_GUID
*ModuleGuid
,
76 CSSM_SPI_ModuleEventHandler CssmNotifyCallback
,
77 void *CssmNotifyCallbackCtx
)
79 secdebug("cssm", "LoadablePlugin::load(guid,...) path %s", path().c_str());
80 return mFunctions
.load(CssmGuid
, ModuleGuid
,
81 CssmNotifyCallback
, CssmNotifyCallbackCtx
);
84 CSSM_RETURN
LoadablePlugin::unload(const CSSM_GUID
*CssmGuid
,
85 const CSSM_GUID
*ModuleGuid
,
86 CSSM_SPI_ModuleEventHandler CssmNotifyCallback
,
87 void *CssmNotifyCallbackCtx
)
89 secdebug("cssm", "LoadablePlugin::unload(guid,...) path %s", path().c_str());
90 return mFunctions
.unload(CssmGuid
, ModuleGuid
,
91 CssmNotifyCallback
, CssmNotifyCallbackCtx
);
94 CSSM_RETURN
LoadablePlugin::attach(const CSSM_GUID
*ModuleGuid
,
95 const CSSM_VERSION
*Version
,
97 CSSM_SERVICE_TYPE SubServiceType
,
98 CSSM_ATTACH_FLAGS AttachFlags
,
99 CSSM_MODULE_HANDLE ModuleHandle
,
100 CSSM_KEY_HIERARCHY KeyHierarchy
,
101 const CSSM_GUID
*CssmGuid
,
102 const CSSM_GUID
*ModuleManagerGuid
,
103 const CSSM_GUID
*CallerGuid
,
104 const CSSM_UPCALLS
*Upcalls
,
105 CSSM_MODULE_FUNCS_PTR
*FuncTbl
)
107 return mFunctions
.attach(ModuleGuid
, Version
, SubserviceID
, SubServiceType
,
108 AttachFlags
, ModuleHandle
, KeyHierarchy
, CssmGuid
, ModuleManagerGuid
,
109 CallerGuid
, Upcalls
, FuncTbl
);
112 CSSM_RETURN
LoadablePlugin::detach(CSSM_MODULE_HANDLE ModuleHandle
)
114 return mFunctions
.detach(ModuleHandle
);
118 } // end namespace Security