2
* Copyright (c) 2004 Massachusetts Institute of Technology
2
* Copyright (c) 2005 Massachusetts Institute of Technology
3
* Copyright (c) 2006 Secure Endpoints Inc.
4
5
* Permission is hereby granted, free of charge, to any person
5
6
* obtaining a copy of this software and associated documentation
98
99
if(!plugin || wcschr(plugin, L'/') || wcschr(plugin, L'\\'))
99
return KHM_ERROR_INVALID_PARM;
100
return KHM_ERROR_INVALID_PARAM;
101
102
if(KHM_FAILED(kmm_get_plugins_config(flags, &csplugins)))
102
103
return KHM_ERROR_UNKNOWN;
120
121
if(!module || wcschr(module, L'/') || wcschr(module, L'\\'))
121
return KHM_ERROR_INVALID_PARM;
122
return KHM_ERROR_INVALID_PARAM;
123
124
if(KHM_FAILED(kmm_get_modules_config(flags, &csmodules)))
124
125
return KHM_ERROR_UNKNOWN;
143
144
config_flags &= ~KHM_FLAG_CREATE;
145
146
if((plugin == NULL) ||
146
(plugin->dependencies &&
147
KHM_FAILED(multi_string_length_cch(plugin->dependencies, KMM_MAXCCH_DEPS, &cch))) ||
148
FAILED(StringCchLength(plugin->module, KMM_MAXCCH_NAME - 1, &cch)) ||
149
(plugin->description &&
150
FAILED(StringCchLength(plugin->description, KMM_MAXCCH_DESC - 1, &cch))) ||
151
FAILED(StringCchLength(plugin->name, KMM_MAXCCH_NAME - 1, &cch)))
147
(plugin->dependencies &&
148
KHM_FAILED(multi_string_length_cch(plugin->dependencies,
149
KMM_MAXCCH_DEPS, &cch))) ||
150
FAILED(StringCchLength(plugin->module, KMM_MAXCCH_NAME, &cch)) ||
151
(plugin->description &&
152
FAILED(StringCchLength(plugin->description,
153
KMM_MAXCCH_DESC, &cch))) ||
154
FAILED(StringCchLength(plugin->name, KMM_MAXCCH_NAME, &cch)))
153
return KHM_ERROR_INVALID_PARM;
156
return KHM_ERROR_INVALID_PARAM;
156
159
/* note that we are retaining the length of the plugin name in
177
180
rv = khc_write_string(csp_plugin, L"Description", plugin->description);
180
184
if(plugin->dependencies) {
181
rv = khc_write_multi_string(csp_plugin, L"Dependencies", plugin->dependencies);
185
rv = khc_write_multi_string(csp_plugin, L"Dependencies",
186
plugin->dependencies);
184
190
rv = khc_write_int32(csp_plugin, L"Type", plugin->type);
186
rv = khc_write_int32(csp_plugin, L"Flags", plugin->flags);
192
rv = khc_write_int32(csp_plugin, L"Disabled",
193
!!(plugin->flags & KMM_PLUGIN_FLAG_DISABLED));
194
201
rv = khc_read_multi_string(csp_module, L"PluginList", NULL, &cb);
195
if(rv != KHM_ERROR_TOO_LONG)
202
if(rv != KHM_ERROR_TOO_LONG) {
203
if (rv == KHM_ERROR_NOT_FOUND) {
205
scb = cb = cch * sizeof(wchar_t);
207
multi_string_init(pl, cb);
208
rv = KHM_ERROR_SUCCESS;
210
goto add_plugin_to_list;
198
217
cb += cch * sizeof(wchar_t);
203
rv = khc_read_multi_string(csp_module, L"PluginList", NULL, &cb);
222
rv = khc_read_multi_string(csp_module, L"PluginList", pl, &cb);
204
223
if(KHM_FAILED(rv)) {
210
231
if(!multi_string_find(pl, plugin->name, 0)) {
211
232
multi_string_append(pl, &scb, plugin->name);
212
233
rv = khc_write_multi_string(csp_module, L"PluginList", pl);
238
259
if((module == NULL) ||
239
FAILED(StringCchLength(module->name, KMM_MAXCCH_NAME - 1, &cch)) ||
260
FAILED(StringCchLength(module->name, KMM_MAXCCH_NAME, &cch)) ||
240
261
(module->description &&
241
FAILED(StringCchLength(module->description, KMM_MAXCCH_DESC - 1, &cch))) ||
262
FAILED(StringCchLength(module->description,
263
KMM_MAXCCH_DESC, &cch))) ||
242
264
FAILED(StringCchLength(module->path, MAX_PATH, &cch)) ||
243
(module->n_plugins > 0 && module->plugin_reg_info == NULL))
245
return KHM_ERROR_INVALID_PARM;
265
(module->n_plugins > 0 && module->plugin_reg_info == NULL)) {
266
return KHM_ERROR_INVALID_PARAM;
248
269
#define CKRV if(KHM_FAILED(rv)) goto _exit
250
rv = kmm_get_module_config(module->name, config_flags | KHM_FLAG_CREATE, &csp_module);
271
rv = kmm_get_module_config(module->name, config_flags | KHM_FLAG_CREATE,
253
if(module->description) {
254
rv = khc_write_string(csp_module, L"Description", module->description);
257
275
rv = khc_write_string(csp_module, L"ImagePath", module->path);
260
rv = khc_write_int32(csp_module, L"Flags", 0);
278
rv = khc_write_int32(csp_module, L"Disabled", 0);
263
281
/* FileVersion and ProductVersion will be set when the module
264
282
is loaded for the first time */
266
284
for(i=0; i<module->n_plugins; i++) {
267
rv = kmm_register_plugin(module->plugin_reg_info + i, config_flags);
285
rv = kmm_register_plugin(&(module->plugin_reg_info[i]), config_flags);
279
297
KHMEXP khm_int32 KHMAPI
280
298
kmm_unregister_plugin(wchar_t * plugin, khm_int32 config_flags)
282
/*TODO: implement this */
283
return KHM_ERROR_NOT_IMPLEMENTED;
300
khm_handle csp_plugin = NULL;
301
khm_int32 rv = KHM_ERROR_SUCCESS;
303
rv = kmm_get_plugin_config(plugin, config_flags, &csp_plugin);
308
rv = khc_remove_space(csp_plugin);
313
khc_close_space(csp_plugin);
286
318
KHMEXP khm_int32 KHMAPI
287
319
kmm_unregister_module(wchar_t * module, khm_int32 config_flags)
289
/*TODO: implement this */
290
return KHM_ERROR_NOT_IMPLEMENTED;
321
khm_handle csp_module = NULL;
322
khm_int32 rv = KHM_ERROR_SUCCESS;
324
rv = kmm_get_module_config(module, config_flags, &csp_module);
329
rv = khc_remove_space(csp_module);
333
khc_close_space(csp_module);