summaryrefslogtreecommitdiffstats
path: root/src/windows/identity/kmm
diff options
context:
space:
mode:
Diffstat (limited to 'src/windows/identity/kmm')
-rw-r--r--src/windows/identity/kmm/Makefile55
-rw-r--r--src/windows/identity/kmm/kmm.c192
-rw-r--r--src/windows/identity/kmm/kmm.h1068
-rw-r--r--src/windows/identity/kmm/kmm_module.c676
-rw-r--r--src/windows/identity/kmm/kmm_plugin.c413
-rw-r--r--src/windows/identity/kmm/kmm_reg.c336
-rw-r--r--src/windows/identity/kmm/kmm_registrar.c1034
-rw-r--r--src/windows/identity/kmm/kmmconfig.csv47
-rw-r--r--src/windows/identity/kmm/kmminternal.h261
-rw-r--r--src/windows/identity/kmm/kmmmain.c160
-rw-r--r--src/windows/identity/kmm/kplugin.h146
-rw-r--r--src/windows/identity/kmm/lang/kmm_msgs.mc259
12 files changed, 0 insertions, 4647 deletions
diff --git a/src/windows/identity/kmm/Makefile b/src/windows/identity/kmm/Makefile
deleted file mode 100644
index 6fd85ad80..000000000
--- a/src/windows/identity/kmm/Makefile
+++ /dev/null
@@ -1,55 +0,0 @@
-#
-# Copyright (c) 2004 Massachusetts Institute of Technology
-# Copyright (c) 2007 Secure Endpoints Inc.
-#
-# Permission is hereby granted, free of charge, to any person
-# obtaining a copy of this software and associated documentation files
-# (the "Software"), to deal in the Software without restriction,
-# including without limitation the rights to use, copy, modify, merge,
-# publish, distribute, sublicense, and/or sell copies of the Software,
-# and to permit persons to whom the Software is furnished to do so,
-# subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-
-
-MODULE=kmm
-!include <../config/Makefile.w32>
-
-INCFILES= \
- $(INCDIR)\kmm.h \
- $(INCDIR)\kplugin.h
-
-OBJFILES= \
- $(OBJ)\kmmmain.obj \
- $(OBJ)\kmm.obj \
- $(OBJ)\kmm_plugin.obj \
- $(OBJ)\kmm_module.obj \
- $(OBJ)\kmm_reg.obj \
- $(OBJ)\kmm_registrar.obj \
- $(OBJ)\kmmconfig.obj
-
-MSGRESFILE=$(OBJ)\kmm_msgs.res
-
-$(OBJ)\kmmconfig.c: kmmconfig.csv $(CONFDIR)\csvschema.cfg
- $(CCSV) $** $@
-
-$(MSGRESFILE): $(OBJ)\kmm_msgs.rc
-
-$(OBJ)\kmm_msgs.rc: lang\kmm_msgs.mc
- $(MC2RC)
-
-all: mkdirs $(INCFILES) $(MSGRESFILE) $(OBJFILES)
-
-clean::
- if exist ..\obj $(RM) $(INCFILES)
diff --git a/src/windows/identity/kmm/kmm.c b/src/windows/identity/kmm/kmm.c
deleted file mode 100644
index e2784e8fd..000000000
--- a/src/windows/identity/kmm/kmm.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/* $Id$ */
-
-#include<kmminternal.h>
-#include<assert.h>
-
-khm_boolean kmmint_load_locale_lib(kmm_module_i * m, kmm_module_locale * l)
-{
- HMODULE h;
-
- if(l->filename != NULL) {
- wchar_t path[MAX_PATH];
- DWORD dw;
-
- /* construct the path name */
- assert(m->h_module != NULL);
-
- dw = PathIsFileSpec(l->filename);
-
- assert(dw);
- if (!dw)
- return FALSE;
-
- dw = GetModuleFileName(m->h_module, path, ARRAYLENGTH(path));
- assert(dw != 0);
- if (dw == 0)
- return FALSE;
-
- PathRemoveFileSpec(path);
- dw = PathAppend(path, l->filename);
- assert(dw);
- if (!dw)
- return FALSE;
-
- h = LoadLibrary(path);
- if(!h)
- return FALSE;
-
- EnterCriticalSection(&cs_kmm);
- m->h_resource = h;
- m->lcid_resource = (WORD) l->language;
- LeaveCriticalSection(&cs_kmm);
-
- return TRUE;
-
- } else {
- /* in this case, the language resources are assumed to be in the
- main module library itself. */
-
- EnterCriticalSection(&cs_kmm);
- m->h_resource = m->h_module;
- m->lcid_resource = (WORD) l->language;
- LeaveCriticalSection(&cs_kmm);
-
- return TRUE;
- }
-}
-
-
-KHMEXP khm_int32 KHMAPI kmm_set_locale_info(kmm_module module, kmm_module_locale * locales, khm_int32 n_locales)
-{
- kmm_module_i * m;
- LANGID lcid;
- int i;
- int * f;
- khm_int32 rv = KHM_ERROR_SUCCESS;
-
- m = kmm_module_from_handle(module);
-
- if(!m || m->state != KMM_MODULE_STATE_INIT)
- return KHM_ERROR_INVALID_OPERATION;
-
- if(!locales || n_locales < 0)
- return KHM_ERROR_INVALID_PARAM;
-
- f = PMALLOC(n_locales * sizeof(int));
- if(!f)
- return KHM_ERROR_UNKNOWN;
- ZeroMemory(f, sizeof(int) * n_locales);
-
- lcid = GetUserDefaultLangID();
-
- /* first search for an exact match */
- for(i=0; i<n_locales; i++) {
- if(locales[i].language == lcid) {
- f[i] = TRUE;
- if(kmmint_load_locale_lib(m, &locales[i]))
- break;
- }
- }
-
- if(i<n_locales)
- goto _exit;
-
- /* ok, that didn't work. Try an inexact match. */
- for(i=0; i<n_locales; i++) {
- if(!f[i] && (PRIMARYLANGID(locales[i].language) == PRIMARYLANGID(lcid))) {
- f[i] = TRUE;
- if(kmmint_load_locale_lib(m,&locales[i]))
- break;
- }
- }
-
- if(i < n_locales)
- goto _exit;
-
- /* hmm. no matches yet. just try to locate the default locale */
- for(i=0; i<n_locales; i++) {
- if(!f[i] && (locales[i].flags & KMM_MLOC_FLAG_DEFAULT)) {
- f[i] = TRUE;
- if(kmmint_load_locale_lib(m,&locales[i]))
- break;
- }
- }
-
- if(i < n_locales)
- goto _exit;
-
- /* give up */
- rv = KHM_ERROR_NOT_FOUND;
-
-_exit:
- PFREE(f);
- return rv;
-}
-
-#ifdef _WIN32
-KHMEXP HMODULE KHMAPI kmm_get_resource_hmodule(kmm_module vm)
-{
- if(!kmm_is_module(vm))
- return NULL;
- else
- return (kmm_module_from_handle(vm))->h_resource;
-}
-#endif
-
-KHMEXP kmm_module KHMAPI
-kmm_this_module(void) {
- kmm_plugin_i * p;
- kmm_module_i * m;
- kmm_module vm;
-
- p = TlsGetValue(tls_kmm);
- if (!kmm_is_plugin(p))
- return NULL;
-
- m = p->module;
- vm = kmm_handle_from_module(m);
-
- kmm_hold_module(vm);
-
- return vm;
-}
-
-KHMEXP kmm_plugin KHMAPI
-kmm_this_plugin(void) {
- kmm_plugin_i * p;
- kmm_plugin vp;
-
- p = TlsGetValue(tls_kmm);
- if (!kmm_is_plugin(p))
- return NULL;
-
- vp = kmm_handle_from_plugin(p);
-
- kmm_hold_plugin(vp);
-
- return vp;
-}
diff --git a/src/windows/identity/kmm/kmm.h b/src/windows/identity/kmm/kmm.h
deleted file mode 100644
index 58e9e1b24..000000000
--- a/src/windows/identity/kmm/kmm.h
+++ /dev/null
@@ -1,1068 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/* $Id$ */
-
-#ifndef __KHIMAIRA_KMM_H
-#define __KHIMAIRA_KMM_H
-
-#include<khdefs.h>
-#include<kmq.h>
-
-/*! \defgroup kmm NetIDMgr Module Manager
-@{*/
-
-/*! \brief A handle to a module.
-*/
-typedef khm_handle kmm_module;
-
-/*! \brief A handle to a plugin.
- */
-typedef khm_handle kmm_plugin;
-
-/*! \name Limits
- @{*/
-
-/*! \brief Maximum number of characters in a name in KMM including the terminating NULL */
-#define KMM_MAXCCH_NAME 256
-
-/*! \brief Maximum number of bytes in a name in KMM including the terminating NULL */
-#define KMM_MAXCB_NAME (sizeof(wchar_t) * KMM_MAXCCH_NAME)
-
-/*! \brief Maximum number of characters in a description in KMM including the terminating NULL */
-#define KMM_MAXCCH_DESC 512
-
-/*! \brief Maximum number of bytes in a description in KMM including the terminating NULL */
-#define KMM_MAXCB_DESC (sizeof(wchar_t) * KMM_MAXCCH_NAME)
-
-/*! \brief Maximum number of characters in a vendor string in KMM including the terminating NULL */
-#define KMM_MAXCCH_VENDOR 256
-
-/*! \brief Maximum number of bytes in a vendor string in KMM including the terminating NULL */
-#define KMM_MAXCB_VENDOR (sizeof(wchar_t) * KMM_MAXCCH_VENDOR)
-
-/*! \brief Maximum number of characters in a support URI in KMM including the terminating NULL */
-#define KMM_MAXCCH_SUPPORT 256
-
-/*! \brief Maximum number of bytes in a vendor string in KMM including the terminating NULL */
-#define KMM_MAXCB_SUPPORT (sizeof(wchar_t) * KMM_MAXCCH_SUPPORT)
-
-/*! \brief Maximum number of dependencies per plugin
-*/
-#define KMM_MAX_DEPENDENCIES 8
-
-/*! \brief Maximum number of dependants per plugin
- */
-#define KMM_MAX_DEPENDANTS 32
-
-/*! \brief Maximum number of characters a dependency string including trailing double NULL */
-#define KMM_MAXCCH_DEPS (KMM_MAXCCH_NAME * KMM_MAX_DEPENDENCIES + 1)
-
-/*! \brief Maximum number of bytes in a dependency string including trailing double NULL */
-#define KMM_MAXCB_DEPS (sizeof(wchar_t) * KMM_MAXCCH_DEPS)
-/*@}*/ /* Limits */
-
-/*! \brief Plugin registration
-
- \see ::khm_cred_provider
-*/
-typedef struct tag_kmm_plugin_reg {
- wchar_t * name; /*!< Name of the plugin. Maximum of
- KMM_MAXCCH_NAME characters
- including the terminating
- NULL. Required. */
-
- wchar_t * module; /*!< Name of module that owns the
- plugin. Maximum of
- KMM_MAXCCH_NAME characters
- including terminating NULL.
- Required. */
-
- khm_int32 type; /*!< Type plugin type. One of
- KHM_PITYPE_*. Required. */
- khm_int32 flags; /*!< Unused. Set to 0 */
- kmq_callback_t msg_proc; /*!< Message processor. Required. */
- wchar_t * dependencies; /*!< Dependencies. Note that this is
- a multi string. (you can use the
- KHC multi string functions to
- manipulate multi strings or to
- convert a comma separated list of
- dependencies to a multi string).
- Each string in the multi string
- is a name of a plugin that this
- plugin depends on. Optional (set
- to NULL if this plugin has no
- dependencies). Maximum of
- KMM_MAXCCH_DEPS characters
- including terminating double
- NULL.*/
-
- wchar_t * description; /*!< Description of the plugin.
- Maximum of KMM_MAXCCH_DESC
- characters including the
- terminating
- NULL. Localized. Optional (set to
- NULL if not provided) */
-#ifdef _WIN32
- HICON icon; /*!< Icon used to represent the
- plugin. Optional. (set to NULL if
- not provided) */
-#endif
-} kmm_plugin_reg;
-
-/*! \brief Plugin information
-*/
-typedef struct tag_kmm_plugin_info {
- kmm_plugin_reg reg; /*!< Registration info */
-
- khm_int32 state; /*!< Current status of the plugin.
- One of ::_kmm_plugin_states */
-
- khm_int32 failure_count; /*!< Number of recorded failures in
- the plugin */
- FILETIME failure_time; /*!< Time of first recorded failure */
- khm_int32 failure_reason; /*!< The reason for the first recorded
- failure */
-
- kmm_plugin h_plugin; /*!< Handle to plugin */
-
- khm_int32 flags; /*!< Flags for the plugin. Currently
- this can only specify
- ::KMM_PLUGIN_FLAG_DISABLED. */
-} kmm_plugin_info;
-
-/*! \brief The plugin is disabled
-
- This flag will be set in the \a flags field of the
- ::kmm_plugin_info structure for a plugin that has been marked as
- disabled. If the plugin is currently running, but marked as
- disabled for future sessions, then this bit will be set in \a
- flags , but the \a state of the plugin will indicate that the
- plugin is running.
- */
-#define KMM_PLUGIN_FLAG_DISABLED 0x00000400
-
-/*! \name Plugin types
-@{*/
-/*! \brief A credentials provider
-
- \see \ref pi_pt_cred for more information.
- */
-#define KHM_PITYPE_CRED 1
-
-/*! \brief A identity provider
-
- \see \ref pi_pt_cred for more information
- */
-#define KHM_PITYPE_IDENT 2
-
-/*! \brief A configuration provider
-
- \see \ref pi_pt_conf for more information.
- */
-#define KHM_PITYPE_CONFIG 3
-
-/*! \brief Undefined plugin type
-
- The plugin doesn't provide any credential type.
- */
-#define KHM_PITYPE_MISC 4
-
-/*@}*/
-
-/*! \brief Plugin states */
-enum _kmm_plugin_states {
- KMM_PLUGIN_STATE_FAIL_INIT = -6, /*!< Failed to initialize */
- KMM_PLUGIN_STATE_FAIL_UNKNOWN = -5, /*!< Failed due to unknown
- reasons */
- KMM_PLUGIN_STATE_FAIL_MAX_FAILURE = -4, /*!< The plugin has
- reached the maximum number
- of failures and cannot be
- initialized until the
- failure count is reset */
- KMM_PLUGIN_STATE_FAIL_NOT_REGISTERED = -3, /*!< Failed because the
- plugin was not registered
- and automatic registration
- failed. */
- KMM_PLUGIN_STATE_FAIL_DISABLED = -2,/*!< Failed because plugin was
- disabled by the user. */
- KMM_PLUGIN_STATE_FAIL_LOAD = -1, /*!< The plugin failed to load
- due to some unknown
- reason. */
- KMM_PLUGIN_STATE_NONE = 0, /*!< Unknown state */
- KMM_PLUGIN_STATE_PLACEHOLDER, /*!< Placeholder. The plugin
- hasn't been provided by
- anyone yet, but the plugin
- record has been created to
- keep track of
- dependencies. */
- KMM_PLUGIN_STATE_REG, /*!< The plugin is registered
- but not initialized */
- KMM_PLUGIN_STATE_PREINIT, /*!< The plugin is in the
- process of being
- initialized */
- KMM_PLUGIN_STATE_HOLD, /*!< On hold. One or more
- dependencies of this plugin
- has not been resolved */
- KMM_PLUGIN_STATE_INIT, /*!< The plugin was initialized */
- KMM_PLUGIN_STATE_RUNNING, /*!< The plugin is running */
- KMM_PLUGIN_STATE_EXITED /*!< The plugin has been stopped. */
-};
-
-/*! \brief Module registration */
-typedef struct tag_kmm_module_reg {
- wchar_t * name; /*!< Identifier for the module */
- wchar_t * path; /*!< Full pathname to module
- binary */
-
- wchar_t * description; /*!< Description of module */
-
- wchar_t * vendor; /*!< Vendor/copyright string */
-
- wchar_t * support; /*!< Support URL/contact */
-
- khm_int32 n_plugins; /*!< Number of plugins that are
- active */
- kmm_plugin_reg * plugin_reg_info; /*!< Array of kmm_plugin_reg
- records for each active
- plugin */
-} kmm_module_reg;
-
-/*! \brief Module information record */
-typedef struct tag_kmm_module_info {
- kmm_module_reg reg; /*!< Registration info */
-
- khm_ui_4 language; /*!< Currently loaded langugage */
-
- khm_int32 state; /*!< Current status of the
- module */
-
- khm_version file_version; /*!< File version for the
- module */
- khm_version product_version; /*!< Product version for the
- module */
-
- khm_int32 failure_count; /*!< Number of times the module
- has failed to load */
- FILETIME failure_time; /*!< Time of first recorded
- failure */
- khm_int32 failure_reason; /*!< Reason for first failure.
- One of the module status
- values */
-
- kmm_module h_module; /*!< Handle to the module. */
-} kmm_module_info;
-
-/*! \brief Module states
-*/
-enum KMM_MODULE_STATES {
- KMM_MODULE_STATE_FAIL_INCOMPAT=-12, /*!< The library containing
- the module was not
- compatible with this version
- of NetIDMgr. */
- KMM_MODULE_STATE_FAIL_INV_MODULE=-11, /*!< The library containing
- the module was invalid. */
- KMM_MODULE_STATE_FAIL_UNKNOWN=-10, /*!< Module could not be
- loaded due to unknown
- reasons. */
- KMM_MODULE_STATE_FAIL_MAX_FAILURE=-9,/*!< The module has failed
- too many times already. Not
- attempting to restart it
- again */
- KMM_MODULE_STATE_FAIL_DUPLICATE=-8, /*!< An attempt was made to
- load the same module
- twice. */
- KMM_MODULE_STATE_FAIL_NOT_REGISTERED=-7, /*!< The module is not
- found among the registered
- module list */
- KMM_MODULE_STATE_FAIL_NO_PLUGINS=-6,/*!< The module provided no
- plugins, or all the plugins
- that are provided are
- disabled */
- KMM_MODULE_STATE_FAIL_DISABLED=-5, /*!< Module is disabled and
- cannot be loaded */
- KMM_MODULE_STATE_FAIL_LOAD=-4, /*!< The module failed to
- initialize */
- KMM_MODULE_STATE_FAIL_INVALID=-3, /*!< The module was invalid.
- Typically caused by the
- required entrypoints not
- being present */
- KMM_MODULE_STATE_FAIL_SIGNATURE=-2, /*!< The module failed to load
- due to an unverifiable
- signature */
- KMM_MODULE_STATE_FAIL_NOT_FOUND=-1, /*!< The module was not
- found */
- KMM_MODULE_STATE_NONE=0, /*!< Unknown state. The handle
- is possibly invalid */
- KMM_MODULE_STATE_PREINIT, /*!< The module is being
- loaded. init_module() hasn't
- been called yet */
- KMM_MODULE_STATE_INIT, /*!< In init_module() */
- KMM_MODULE_STATE_INITPLUG, /*!< Initializing plugins */
- KMM_MODULE_STATE_RUNNING, /*!< Running */
- KMM_MODULE_STATE_EXITPLUG, /*!< Currently exiting plugins */
- KMM_MODULE_STATE_EXIT, /*!< Currently exiting */
- KMM_MODULE_STATE_EXITED /*!< Exited */
-};
-
-/*! \brief Start the Module Manager
-
- \note Only called by the NetIDMgr core.
-*/
-KHMEXP void KHMAPI
-kmm_init(void);
-
-/*! \brief Stop the Module Manager
-
- \note Only called by the NetIDMgr core.
-*/
-KHMEXP void KHMAPI
-kmm_exit(void);
-
-/*! \brief Return the plugin handle for the current plugin
-
- The returned handle represents the plugin which owns the current
- thread. The returned handle must be released by calling
- kmm_release_plugin(). Returns NULL if the current thread is not
- owned by any plugin.
- */
-KHMEXP kmm_plugin KHMAPI
-kmm_this_plugin(void);
-
-/*! \brief Return the module handle for the current module
-
- The returned handle represents the module which owns the current
- thread. The returned handle must be released by calling
- kmm_release_module()
-*/
-KHMEXP kmm_module KHMAPI
-kmm_this_module(void);
-
-/*! \name Flags for kmm_load_module()
-@{*/
-/*!\brief Load synchronously
-
- If this flag is set, then the function waits for the module to be
- loaded. The default is to load the module asynchronously.
-
- When loading a module asynchronously, the kmm_load_module()
- function returns KHM_ERROR_SUCCESS and exits without waiting for
- the module to load. If \a result is not NULL, it will receive a
- valid handle to the module.
-
- When loading a module synchronously, kmm_load_module() will wait
- for the module to completely load. If it fails to load properly,
- it will return an error code and set \a result to NULL.
-*/
-#define KMM_LM_FLAG_SYNC 1
-
-/*! \brief Do not load
-
- Indicates that the module shouldn't actually be loaded. If the
- specified module name identifies a module that has already been
- loaded, then the function returns a held handle to the existing
- module (use kmm_release_module() to free the handle). Otherwise,
- the function returns KHM_ERROR_NOT_FOUND.
-*/
-#define KMM_LM_FLAG_NOLOAD 2
-/*@}*/
-
-/*! \brief Load a module
-
- The \a modulename parameter specifies a module to load. Depending
- on the configuration, not all of the plugins that are provided by
- the module may be loaded. If no plugins are successfully loaded,
- the module will be immediately unloaded.
-
- If the module is currently loaded or is being loaded, then a valid
- handle to the existing module is returned.
-
- When called with KMM_LM_FLAG_SYNC, the function does not return
- until the module and the associated plugins are all initialized,
- or an error occurs.
-
- If the KMM_LM_FLAG_NOLOAD flag is set, then a handle to an
- existing instance of the module will be returned. If the module
- hasn't been loaded yet, then no handle is returned and the
- function returns KHM_ERROR_NOT_FOUND.
-
- See the associated NetIDMgr Module Manager documentation on the
- sequence of events associated with loading a module.
-
- \param[in] modulename Name of the module. The module should have
- been registered under this name prior to the call.
- \param[in] flags Combination of KMM_LM_FLAG_*
- \param[out] result Receives a handle to the loaded module. If the
- result is not required, set this to NULL. If \a result is not
- NULL, and km_load_module() returns KHM_ERROR_SUCCESS, then
- kmm_release_module() must be called to release the handle to
- the module. Otherwise, \a result receives NULL. If a handle
- is returned, it will be valid regardless of whether the module
- fails to load or not. You can use kmm_get_module_state() to
- query the progress of the loading process. See
- ::KMM_LM_FLAG_SYNC.
-
- \retval KHM_ERROR_SUCCESS The call succeeded. If \a
- KMM_LM_FLAG_SYNC was specified, this means that the module was
- successfully loaded. Otherwise, it only means that the module
- has been queued up for loading. Use kmm_get_module_state() to
- determine if it was successfully loaded. If \a result is not
- NULL, a valid handle is returned.
- \retval KHM_ERROR_EXISTS The module is already loaded or has been
- already queued for loading. If \a result is not NULL, a valid
- handle to the existing module instance is returned.
- \retval KHM_ERROR_NOT_FOUND If called with KMM_LM_FLAG_NOLOAD,
- indicates that the module has not been loaded. Otherwise only
- returned when called with KMM_LM_FLAG_SYNC. The module image
- was not found. No handle is returned.
- \retval KHM_ERROR_INVALID_SIGNATURE Only returned when called with
- KMM_LM_FLAG_SYNC. The module was signed with an invalid
- certificate. No handle is returned.
- \retval KHM_ERROR_UNKNOWN Only returned when called with
- KMM_LM_FLAG_SYNC. Some other error has occured. No handle is
- returned.
-
- \see \ref pi_fw_pm_load
- \see ::KMM_LM_FLAG_SYNC, ::KMM_LM_FLAG_NOLOAD
-*/
-KHMEXP khm_int32 KHMAPI
-kmm_load_module(wchar_t * modname, khm_int32 flags, kmm_module * result);
-
-/*! \brief Hold a handle to a module
-
- Use kmm_release_module() to release the hold.
-*/
-KHMEXP khm_int32 KHMAPI
-kmm_hold_module(kmm_module module);
-
-/*! \brief Release a handle to a module
-
- Release a held referece to a module that was returned in a call to
- kmm_load_module().
-*/
-KHMEXP khm_int32 KHMAPI
-kmm_release_module(kmm_module m);
-
-/*! \brief Query the state of a module
-
- When loading a module asynchronously you can query the state of
- the loading process using this. The return value is a status
- indicator.
-
- \return The return value is one of the ::KMM_MODULE_STATES
- enumerations.
-*/
-KHMEXP khm_int32 KHMAPI
-kmm_get_module_state(kmm_module m);
-
-/*! \brief Unload a module
-
- See the associated NetIDMgr Module Manager documentation on the
- sequence of events associated with unloading a module.
-
- \see \ref pi_fw_pm_unload
-*/
-KHMEXP khm_int32 KHMAPI
-kmm_unload_module(kmm_module module);
-
-/*! \brief Loads the default modules as specified in the configuration
-
- The configuration can specify the default set of modules to load.
- This function dispatches the necessary message for loading these
- modules and reutnrs.
-*/
-KHMEXP khm_int32 KHMAPI
-kmm_load_default_modules(void);
-
-/*! \brief Checks whether there are any pending loads
-
- Returns TRUE if there are modules still waiting to be loaded.
-*/
-KHMEXP khm_boolean KHMAPI
-kmm_load_pending(void);
-
-#ifdef _WIN32
-
-/*! \brief Returns the Windows module handle from a handle to a NetIDMgr module.
- Although it is possible to obtain the Windows module handle and
- use it to call Windows API functions, it is not recommended to do
- so. This is because that might cause the state of the module to
- change in ways which are inconsistent from the internal data
- structures that kmm maintains.
- */
-KHMEXP HMODULE KHMAPI
-kmm_get_hmodule(kmm_module m);
-#endif
-
-/*! \brief Hold a plugin
-
- Obtains a hold on a plugin. The plugin handle will remain valid
- until the hold is released with a call to kmm_release_plugin().
- No guarantees are made on the handle once the handle is released.
- */
-KHMEXP khm_int32 KHMAPI
-kmm_hold_plugin(kmm_plugin p);
-
-/*! \brief Release a plugin
-
- Releases a hold on a plugin obtained through a call to
- kmm_hold_plugin(). The plugin handle should no longer be
- considered valied once this is called.
- */
-KHMEXP khm_int32 KHMAPI
-kmm_release_plugin(kmm_plugin p);
-
-/*! \brief Provide a plugin
-
- This function must be called for each plugin that the module
- provides.
-
- Note that this function returns immediately and does not
- initialize the plugin. All plugins that are provided by a
- module will be initialized once the init_module() function
- returns. If the plugin has dependencies, it will be kept in a
- held state until the plugins that it depends on are successfully
- initialized. If the dependencies are not resolved (the dependent
- plugins are not loaded), then plugin will not be initialized.
-
- If the plugin is not registered and \a plugin contains enough
- information to perform the registration, then it will be
- automatically registered. However, if the plugin is not
- registered and cannot be registered using the provided
- information, the plugin will not be initialized properly. Note
- that automatic registration will always register the plugin in the
- user configuration store.
-
- The \a name and \a msg_proc members of \a plugin are required to
- have valid values. The \a icon member may optionally be
- specified. The other fields can be specified if the plugin should
- be automatically registered, however, the \a module field will be
- ignored and will be determined by the \a module handle.
-
- \param[in] module Handle to this module that is providing the plugin.
- \param[in] plugin A plugin descriptor.
-
- \retval KHM_ERROR_SUCCESS Succeeded.
- \retval KHM_ERROR_INVALID_OPERATION The function was not called
- during init_module()
- \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid
- \retval KHM_ERROR_DUPLICATE The plugin was already provided
-
- \note This can only be called when handing init_module()
-*/
-KHMEXP khm_int32 KHMAPI
-kmm_provide_plugin(kmm_module module, kmm_plugin_reg * plugin);
-
-/*! \brief Query the state of a plugin.
-
- \return One of ::_kmm_plugin_states
-*/
-KHMEXP khm_int32 KHMAPI
-kmm_get_plugin_state(wchar_t * plugin);
-
-/*! \defgroup kmm_reg Registration
-
- The functions for managing plugin and module registration. These
- functions are also available as static linked libraries for use by
- external applications which must register or unregister plugins or
- modules.
-@{*/
-
-/*! \brief Obtain the configuration space for a named plugin
-
- Note that the named plugin does not have to actually exist.
- Configuration spaces for plugins are based solely on the plugin
- name and hence can be accessed regardless of whether the specific
- plugin is loaded or not.
-
- \param[in] flags Controls the options for opening the
- configuration space. If KHM_FLAG_CREATE is specified, then
- the configuration space for the plugin named \a plugin wil be
- created if it doesn't already exist. The \a flags parameter
- is directly passed into a call to khc_open_space().
-
- \param[in] plugin Name of the plugin. The name can not contain
- slashes.
-
- \param[out] result Receives a configuration space handle. The
- calling application should free the handle using
- khc_close_space().
-
- \see khc_open_space()
- \see khc_close_space()
- */
-KHMEXP khm_int32 KHMAPI
-kmm_get_plugin_config(wchar_t * plugin, khm_int32 flags, khm_handle * result);
-
-/*! \brief Obtain the configuration space for a named module
-
- The named module does not have to actually exist. Configuration
- spaces for modules are based on the basename of the module
- (including the extension).
-
- \param[in] module Name of the module.
-
- \param[in] flags The flags used to call khc_open_space(). You can
- use this to specify a particular configuration store if
- needed.
-
- \param[out] result Receives the handle to a configuration space if
- successful. Call khc_close_space() to close the handle.
-
- \see khc_open_space()
- \see khc_close_space()
-*/
-KHMEXP khm_int32 KHMAPI
-kmm_get_module_config(wchar_t * module, khm_int32 flags, khm_handle * result);
-
-/*! \brief Retrieve a handle to the configuration space for plugins
-
- The configuration space for plugins is a container which holds the
- configuration subspaces for all the plugins. This is the config
- space which must be used to load a configuration space for a
- plugin.
-
- \param[in] flags The flags to pass in to the call to
- khc_open_space(). The flags can be used to select a specific
- configuration store if needed.
-
- \param[out] result Receives a handle to the configuration
- space. Call khc_close_space() to close the handle
-
- \see khc_open_space()
- \see khc_close_space()
- */
-KHMEXP khm_int32 KHMAPI
-kmm_get_plugins_config(khm_int32 flags, khm_handle * result);
-
-/*! \brief Retrieve the handle to the configuration space for modules
-
- The configuration space for modules is a container which hold the
- configuration subspaces for all the modules. Each module
- registration ends up in this subspace.
-
- \param[in] flags The flags to pass in to the call to
- khc_open_space(). The flags can be used to select a specific
- configuration store if needed.
-
- \param[out] result Receives a handle to the configuration space.
- Call khc_close_space() to close the handle.
-
- \see khc_open_space()
- \see khc_close_space()
- */
-KHMEXP khm_int32 KHMAPI
-kmm_get_modules_config(khm_int32 flags, khm_handle * result);
-
-/*! \brief Return information about a loaded module
-
- The retrieves a block of information about a module. Refer to
- ::kmm_module_info for information about the format of the returned
- data.
-
- Note that the size of the required buffer is actually greater than
- the size of the ::kmm_module_info structure and accomodates the
- ::kmm_plugin_info structures and strings required to complete the
- information block.
-
- Call the function with \a buffer set to NULL and \a cb_buffer
- pointing at a khm_size variable to obtain the required size of the
- buffer.
-
- \param[in] module_name Name of a module
- \param[in] flags Flags indicating which types of information to
- return
- \param[out] buffer Points to a buffer that recieves information.
- Set this to NULL if only the size of the buffer is required.
- \param[in,out] On entry, contains the size of the buffer pointed
- to by \a buffer if \a buffer is not NULL. On exit, contains
- the required size of the buffer or the number of actual bytes
- copied.
-
- \retval KHM_ERROR_SUCCESS The requested information was copied
- \retval KHM_ERROR_INVALID_PARAM One of the parameters was invalid
- \retval KHM_ERROR_TOO_LONG The buffer was not large enough or was
- NULL. The number of bytes requied is in \a cb_buffer.
- \retval KHM_ERROR_NOT_FOUND The specified module is not a
- registered module.
- */
-KHMEXP khm_int32 KHMAPI
-kmm_get_module_info(wchar_t * module_name, khm_int32 flags,
- kmm_module_info * buffer, khm_size * cb_buffer);
-
-/*! \brief Get information about a module
-
- Similar to kmm_get_module_info(), but uses a module handle instead
- of a name, and uses internal buffers for providing string fields.
-
- The information that is returned should be freed using a call to
- kmm_release_module_info_i().
-
- \see kmm_release_module_info_i()
- */
-KHMEXP khm_int32 KHMAPI
-kmm_get_module_info_i(kmm_module module, kmm_module_info * info);
-
-/*! \brief Release module information
-
- Releases the information returned by a previous call to
- kmm_get_module_info_i(). The contents of the ::kmm_module_info
- structure should not have been modified in any way between calling
- kmm_get_module_info_i() and kmm_release_module_info_i().
- */
-KHMEXP khm_int32 KHMAPI
-kmm_release_module_info_i(kmm_module_info * info);
-
-/*! \brief Obtain information about a plugin
-
- Retrieve a block of information about a plugin. See
- ::kmm_plugin_info for details about what information can be
- returned. Note that some fields may not be available if the
- module is not loaded.
-
- Note that the size of the required buffer is greater than the size
- of the ::kmm_plugin_info structure and accounts for strings as
- well. Call kmm_get_plugin_info() with \a buffer set to NULL and
- \a cb_buffer set to point to a variable of type \a khm_size to
- obtain the required size of the structure.
-
- \param[in] plugin_name Name of the plugin
- \param[out] buffer The buffer to receive the plugin information.
- Set to \a NULL if only the size of the buffer is required.
- \param[in,out] cb_buffer On entry, points to variable that
- specifies the size of the buffer pointed to by \a buffer is \a
- buffer is not \a NULL. On exit, holds the number of bytes
- copied or the required size of the buffer.
-
- \retval KHM_ERROR_SUCCESS The requested information was
- successfully copied to the \a buffer
- \retval KHM_ERROR_TOO_LONG The buffer was either \a NULL or
- insufficient to hold the requested information. The required
- size of the buffer was stored in \a cb_buffer
- \retval KHM_ERROR_INVALID_PARAM One or more parameters were
- invlaid.
- \retval KHM_ERROR_NOT_FOUND The specified plugin was not found
- among the registered plugins.
-*/
-KHMEXP khm_int32 KHMAPI
-kmm_get_plugin_info(wchar_t * plugin_name,
- kmm_plugin_info * buffer,
- khm_size * cb_buffer);
-
-/*! \brief Obtain information about a plugin using a plugin handle
-
- Similar to kmm_get_plugin_info() but uses a plugin handle instead
- of a plugin name. If the call is successful, the \a info
- structure will be filled with information about the plugin. The
- returned info should not be modified in any way and may contain
- pointers to internal buffers.
-
- The returned information must be released with a call to
- kmm_release_plugin_info_i().
- */
-KHMEXP khm_int32 KHMAPI
-kmm_get_plugin_info_i(kmm_plugin p, kmm_plugin_info * info);
-
-/*! \brief Release plugin information returned by kmm_get_plugin_info_i
-
- The information returned by kmm_get_plugin_info_i() should not be
- modified in any way before calling kmm_release_plugin_info_i().
- Once the call completes, the contents of \a info will be
- initialized to zero.
- */
-KHMEXP khm_int32 KHMAPI
-kmm_release_plugin_info_i(kmm_plugin_info * info);
-
-/*! \brief Enumerates plugins
-
- Enumerates through known plugins. This list may not include
- plugins which were not loaded by NetIDMgr in this session.
-
- If the call is successful, a handle to the next plugin in the list
- will be placed in \a p_next. The returned handle must be freed
- with a call to kmm_release_plugin().
-
- If the \a p parameter is set to NULL, then the first plugin handle
- will be placed in \a p_next. The handles will not be returned in
- any specific order. In addition, the enumeration may not include
- all known plugins if the list of plugins changes during
- enumeration.
- */
-KHMEXP khm_int32 KHMAPI
-kmm_get_next_plugin(kmm_plugin p, kmm_plugin * p_next);
-
-/*! \brief Enables or disables a plugin
-
- This function currently does not take effect immediately. However
- it marks the plugin as enabled or disabled so that the next time
- NetIDMgr starts, the module manager will act accordingly.
-
- \param[in] p Handle to the plugin
-
- \param[in] enable If non-zero, the plugin will be marked as
- enabled. Otherwise the plugin will be marked as disabled.
- */
-KHMEXP khm_int32 KHMAPI
-kmm_enable_plugin(kmm_plugin p, khm_boolean enable);
-
-/*! \brief Register a plugin
-
- The \a plugin member defines the plugin to be registered. The \a
- msg_proc and \a icon members of the structure are ignored.
-
- At the time kmm_register_plugin() is called, the module specified
- by \a module member of the \a plugin parameter must have been already
- registered. Otherwise the function call fails.
-
- If the plugin has already been registered, then all the fields in
- the plugin registration will be updated to be in sync with the
- information provided in the \a plugin parameter. The failure
- counts and associated statistics will not be reset when the
- configuration information is updated.
-
- If the plugin has not been registered, the a new registration
- entry is created in the configuration space indicated by the \a
- config_flags parameter. In addition, the plugin will be added to
- the list of plugins associated with the owning module.
-
- Note that the module that owns the plugin must be registered in
- the same configuration store as the plugin.
-
- \param[in] plugin Registration info for the plugin. The \a
- msg_proc and \a icon members are ignored. All other fields
- are required. The \a description member should be localized
- to the system locale when registering a plugin in the machine
- configuration store and should be localized to the user locale
- when registering a plugin in the user configuration store.
- \param[in] config_flags Flags for the configuration provider.
- These flags are used verbatim to call khc_open_space(), hence
- they may be used to pick whether or not the registration is
- per machine or per user.
-
- \see kmm_register_module()
- */
-KHMEXP khm_int32 KHMAPI
-kmm_register_plugin(kmm_plugin_reg * plugin, khm_int32 config_flags);
-
-/*! \brief Register a module
-
- The \a module parameter specifies the parameters for the module
- registration.
-
- The \a plugin_info member should point to an array of
- ::kmm_plugin_info structures unless the \a n_plugins member is
- zero, in which case \a plugin_info can be \a NULL. Plugins can be
- registered separately using kmm_register_plugin().
-
- \param[in] module Information about the module. The name and path
- fields are required. The \a plugin_info field can only be \a
- NULL if \a n_plugins is zero.
-
- \param[in] config_flags Flags used to call khc_open_space(). This
- can be used to choose the configuration store in which the
- module registration will be performed.
- */
-KHMEXP khm_int32 KHMAPI
-kmm_register_module(kmm_module_reg * module, khm_int32 config_flags);
-
-/*! \brief Unregister a plugin
-
- Registration information associated with the plugin will be
- removed. In addtion, the plugin will be removed from the list of
- plugins provided by the owner module.
-
- \param[in] plugin Names the plugin to be removed
- \param[in] config_flags Flags used to call khc_open_space(). Can
- be used to choose the configuraiton store that is affected by
- the call.
-
- \note kmm_unregister_plugin() has no effect on whether the plugin
- is loaded or not. The caller must make sure that the plugin
- is unloaded and the associated module is either also unloaded
- or in a state where the plugin can be unregistered.
- */
-KHMEXP khm_int32 KHMAPI
-kmm_unregister_plugin(wchar_t * plugin, khm_int32 config_flags);
-
-/*! \brief Unregister a module
-
- Registration information associated with the module as well as all
- the plugins provided by the module will be removed from the
- configuration store.
-
- \param[in] module Names the module to be removed
-
- \param[in] config_flags Flags used to call khc_open_space(). Can
- be used to choose the configuration store affected by the
- call.
-
- \note kmm_unregister_module() has no effect on the loaded state of
- the module. The caller should make sure that the module is
- unloaded and in a state where it can be unregistered.
- */
-KHMEXP khm_int32 KHMAPI
-kmm_unregister_module(wchar_t * module, khm_int32 config_flags);
-
-/*@}*/ /* kmm_reg */
-
-/*! \defgroup kmm_loc Internationalization support
-
- See \ref pi_localization for more information about
- internationalization.
-
-@{*/
-
-/*! \brief Locale descriptor record
-
- See kmm_set_locale()
-*/
-typedef struct tag_kmm_module_locale {
- khm_ui_4 language; /*!< A language ID. On Windows, you can use the
- MAKELANGID macro to generate this value. */
- wchar_t * filename; /*!< The filename corresponding to this language.
- Use NULL to indicate that resources for this
- language are to be found in the main module. */
- khm_int32 flags; /*!< Flags. Combination of KMM_MLOC_FLAG_* */
-} kmm_module_locale;
-
-#define LOCALE_DEF(language_id, filename, flags) {language_id, filename, flags}
-
-/*! \brief Default (fallback) locale
-*/
-#define KMM_MLOC_FLAG_DEFAULT 1
-
-
-/*! \brief Sets the locale for a loaded module.
-
- The given locale records are searched in the given order until a
- locale that matches the current user locale is found. If no
- locales match, then the first locale with the
- ::KMM_MLOC_FLAG_DEFAULT flag set will be loaded. If no locales
- have that flag set, then the first locale is loaded.
-
- You can obtain a handle to the loaded library using
- kmm_get_resource_hmodule(). This function does not return until a
- matched library is loaded.
-
- Note that the ::kmm_module_locale structure only specifies a
- module name for the resource module. This resource module must
- exist in the same directory as the \a module.
-
- \param[in] module The module handle
- \param[in] locales An array of ::kmm_module_locale objects
- \param[in] n_locales The number of objects in the array pointed to by \a locales
-
- \retval KHM_ERROR_SUCCESS Succeeded.
- \retval KHM_ERROR_NOT_FOUND A matching locale resource library was not found.
- \retval KHM_ERROR_INVALID_OPERATION The function was called on a module which is currently not being initalized.
-
- \see \ref pi_localization
- \see kmm_get_resource_hmodule()
-
- \note This can only be called when handing init_module()
-*/
-KHMEXP khm_int32 KHMAPI
-kmm_set_locale_info(kmm_module module,
- kmm_module_locale * locales,
- khm_int32 n_locales);
-
-#ifdef _WIN32
-
-/*! \brief Return the Windows module handle of the resource library of a NetIDMgr module.
-
- NetIDMgr allows the specification of an alternate resource library
- that will be used to load localized resources from. This function
- returns a handle to this library.
-
- While you can use the convenience macros to access resources in a
- localization library using the module handle, it is recommended,
- for performance reasons, to use this function to obtain the handle
- to the resource library and then use that handle in calls to
- LoadString, LoadImage etc. directly.
-*/
-KHMEXP HMODULE KHMAPI
-kmm_get_resource_hmodule(kmm_module m);
-
-/*! \name Convenience Macros
-@{*/
-/*! \brief Convenience macro for using calling LoadAccelerators using a module handle
-
- \param[in] module A handle to a loaded module. The corresponding resource
- module will be located through a call to kmm_get_resource_hmodule()
-*/
-#define kmm_LoadAccelerators(module, lpTableName) \
- (LoadAccelerators(kmm_get_resource_hmodule(module), lpTableName))
-
-/*! \brief Convenience macro for using calling LoadBitmap using a module handle
-
- \param[in] module A handle to a loaded module. The corresponding resource
- module will be located through a call to kmm_get_resource_hmodule()
-*/
-#define kmm_LoadBitmap(module, lpBitmapName) \
- (LoadBitmap(kmm_get_resource_hmodule(module), lpBitmapName))
-
-/*! \brief Convenience macro for using calling LoadImage using a module handle
-
- \param[in] module A handle to a loaded module. The corresponding resource
- module will be located through a call to kmm_get_resource_hmodule()
-*/
-#define kmm_LoadImage(module, lpszName, uType, cxDesired, cyDesired, fuLoad) \
- (LoadImage(kmm_get_resource_hmodule(module), lpszName, uType, cxDesired, cyDesired, fuLoad))
-
-/*! \brief Convenience macro for using calling LoadCursor using a module handle
-
- \param[in] module A handle to a loaded module. The corresponding resource
- module will be located through a call to kmm_get_resource_hmodule()
-*/
-#define kmm_LoadCursor(module, lpCursorName) \
- (LoadCursor(kmm_get_resource_hmodule(module), lpCursorName))
-
-/*! \brief Convenience macro for using calling LoadIcon using a module handle
-
- \param[in] module A handle to a loaded module. The corresponding resource
- module will be located through a call to kmm_get_resource_hmodule()
-*/
-#define kmm_LoadIcon(module, lpIconName) \
- (LoadIcon(kmm_get_resource_hmodule(module), lpIconName))
-
-/*! \brief Convenience macro for using calling LoadMenu using a module handle
-
- \param[in] module A handle to a loaded module. The corresponding resource
- module will be located through a call to kmm_get_resource_hmodule()
-*/
-#define kmm_LoadMenu(module, lpMenuName) \
- (LoadMenu(kmm_get_resource_hmodule(module), lpMenuName))
-
-/*! \brief Convenience macro for using calling LoadString using a module handle
-
- \param[in] module A handle to a loaded module. The corresponding resource
- module will be located through a call to kmm_get_resource_hmodule()
-*/
-#define kmm_LoadString(module, uID, lpBuffer, nBufferMax) \
- (LoadString(kmm_get_resource_hmodule(module), uID, lpBuffer, nBufferMax))
-/*@}*/ /* Convenience Macros */
-#endif
-/*@}*/ /* group kmm_loc */
-/*@}*/ /* group kmm */
-#endif
diff --git a/src/windows/identity/kmm/kmm_module.c b/src/windows/identity/kmm/kmm_module.c
deleted file mode 100644
index bfa984af5..000000000
--- a/src/windows/identity/kmm/kmm_module.c
+++ /dev/null
@@ -1,676 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/* $Id$ */
-
-#include<kmminternal.h>
-#include<netidmgr_version.h>
-#include<assert.h>
-
-/* should only be accessed from the registrar thread */
-khm_size kmm_active_modules = 0;
-
-kmm_module_i * kmmint_get_module_i(wchar_t * name)
-{
- kmm_module_i * m;
- size_t sz;
-
- if(FAILED(StringCbLength(name, KMM_MAXCB_NAME, &sz)))
- return NULL;
- sz += sizeof(wchar_t);
-
- EnterCriticalSection(&cs_kmm);
- m = (kmm_module_i *) hash_lookup(hash_modules, (void *) name);
-
- if(m == NULL) {
- m = PMALLOC(sizeof(kmm_module_i));
- ZeroMemory(m, sizeof(kmm_module_i));
-
- m->magic = KMM_MODULE_MAGIC;
- m->name = PMALLOC(sz);
- StringCbCopy(m->name, sz, name);
- m->state = KMM_MODULE_STATE_NONE;
-
- hash_add(hash_modules, (void *) m->name, (void *) m);
- LPUSH(&kmm_all_modules, m);
- }
- LeaveCriticalSection(&cs_kmm);
-
- return m;
-}
-
-kmm_module_i * kmmint_find_module_i(wchar_t * name)
-{
- kmm_module_i * m;
-
- EnterCriticalSection(&cs_kmm);
- m = (kmm_module_i *) hash_lookup(hash_modules, (void *) name);
- LeaveCriticalSection(&cs_kmm);
-
- return m;
-}
-
-/* called with cs_kmm held */
-void kmmint_free_module(kmm_module_i * m)
-{
- m->magic = 0;
-
- hash_del(hash_modules, m->name);
- LDELETE(&kmm_all_modules, m);
-
- if (m->name)
- PFREE(m->name);
-
- if (m->description)
- PFREE(m->description);
-
- if (m->path)
- PFREE(m->path);
-
- if (m->vendor)
- PFREE(m->vendor);
-
- if (m->support)
- PFREE(m->support);
-
- if (m->version_info)
- PFREE(m->version_info);
-
- PFREE(m);
-}
-
-KHMEXP khm_int32 KHMAPI kmm_hold_module(kmm_module module)
-{
- if(!kmm_is_module(module))
- return KHM_ERROR_INVALID_PARAM;
- EnterCriticalSection(&cs_kmm);
- kmm_module_from_handle(module)->refcount++;
- LeaveCriticalSection(&cs_kmm);
-
- return KHM_ERROR_SUCCESS;
-}
-
-KHMEXP khm_int32 KHMAPI kmm_release_module(kmm_module vm)
-{
- kmm_module_i * m;
-
- if(!kmm_is_module(vm))
- return KHM_ERROR_INVALID_PARAM;
-
- EnterCriticalSection(&cs_kmm);
- m = kmm_module_from_handle(vm);
- if(! --(m->refcount))
- {
- /* note that a 0 ref count means that there are no active
- plugins */
- kmmint_free_module(m);
- }
- LeaveCriticalSection(&cs_kmm);
- return KHM_ERROR_SUCCESS;
-}
-
-khm_int32
-kmmint_check_api_version(DWORD v) {
- /* for now, we allow API versions in the range
- KH_VERSION_API_MINCOMPAT through KH_VERSION_API, inclusive. In
- the future when we are swamped with so much time that we don't
- know what to do with it, we can actually parse the
- apiversion.txt file and create a compatibility table which we
- can check against the functions used by the module and decide
- whether or not it is compatible. */
-
- if (v < KH_VERSION_API_MINCOMPAT ||
- v > KH_VERSION_API)
- return KHM_ERROR_INCOMPATIBLE;
- else
- return KHM_ERROR_SUCCESS;
-}
-
-struct lang_code {
- WORD language;
- WORD codepage;
-};
-
-khm_int32
-kmmint_read_module_info(kmm_module_i * m) {
- /* the only fields we can count on at this point are m->name and
- m->path */
- DWORD t;
- size_t cb;
- WORD lang;
- khm_int32 rv = KHM_ERROR_SUCCESS;
- struct lang_code *languages;
- int n_languages;
- int i;
- wchar_t resname[256]; /* the resource names are a lot shorter */
- wchar_t * r;
- VS_FIXEDFILEINFO *vff;
- UINT c;
-
- assert(m->name);
- assert(m->path);
-
- t = TRUE;
- cb = GetFileVersionInfoSize(m->path,
- &t);
- /* if successful, cb gets the size in bytes of the version info
- structure and sets t to zero */
- if (t) {
- return KHM_ERROR_NOT_FOUND;
- } else if (cb == 0) {
- _report_mr1(KHERR_WARNING, MSG_RMI_NOT_FOUND, _dupstr(m->path));
- return KHM_ERROR_INVALID_PARAM;
- }
-
- if (m->version_info) {
- PFREE(m->version_info);
- m->version_info = NULL;
- }
-
- m->version_info = PMALLOC(cb);
-#ifdef DEBUG
- assert(m->version_info);
-#endif
-
- if(!GetFileVersionInfo(m->path,
- t, (DWORD) cb, m->version_info)) {
- rv = KHM_ERROR_NOT_FOUND;
- _report_mr1(KHERR_WARNING, MSG_RMI_NOT_FOUND, _dupstr(m->path));
- _location(L"GetFileVersionInfo");
- goto _cleanup;
- }
-
- if(!VerQueryValue(m->version_info,
- L"\\VarFileInfo\\Translation",
- (LPVOID*) &languages,
- &c)) {
- rv = KHM_ERROR_INVALID_PARAM;
- _report_mr1(KHERR_WARNING, MSG_RMI_NO_TRANS, _dupstr(m->path));
- _location(L"VerQueryValue");
- goto _cleanup;
- }
-
- n_languages = (int) (c / sizeof(*languages));
-
- /* Try searching for the user's default language first */
- lang = GetUserDefaultLangID();
- for (i = 0; i < n_languages; i++) {
- if(languages[i].language == lang)
- break;
- }
-
- /* If not, try the system default */
- if (i >= n_languages) {
- lang = GetSystemDefaultLangID();
- for (i=0; i<n_languages; i++)
- if (languages[i].language == lang)
- break;
- }
-
- /* Then try EN_US */
- if (i >= n_languages) {
- lang = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US);
- for (i=0; i<n_languages; i++)
- if (languages[i].language == lang)
- break;
- }
-
- /* Language neutral? */
- if (i >= n_languages) {
- lang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL);
- for (i=0; i<n_languages; i++)
- if (languages[i].language == lang)
- break;
- }
-
- /* Just use the first one? */
- if (i >= n_languages) {
- i = 0;
- }
-
- if (i >= n_languages) {
- rv = KHM_ERROR_INVALID_PARAM;
- _report_mr0(KHERR_WARNING, MSG_RMI_NO_LOCAL);
- goto _cleanup;
- }
-
- /* check module name */
- StringCbPrintf(resname, sizeof(resname),
- L"\\StringFileInfo\\%04x%04x\\" TEXT(NIMV_MODULE),
- languages[i].language,
- languages[i].codepage);
-
- if (!VerQueryValue(m->version_info,
- resname, (LPVOID *) &r, &c)) {
- rv = KHM_ERROR_INVALID_PARAM;
- _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING,
- _cstr(TEXT(NIMV_MODULE)));
- goto _cleanup;
- }
-
- if (c > KMM_MAXCB_NAME ||
- FAILED(StringCbLength(r, KMM_MAXCB_NAME, &cb))) {
- rv = KHM_ERROR_INVALID_PARAM;
- _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG,
- _cstr(TEXT(NIMV_MODULE)));
- goto _cleanup;
- }
-
- if (wcscmp(r, m->name)) {
- rv = KHM_ERROR_INVALID_PARAM;
- _report_mr2(KHERR_WARNING, MSG_RMI_MOD_MISMATCH,
- _dupstr(r), _dupstr(m->name));
- goto _cleanup;
- }
-
- /* check API version */
- StringCbPrintf(resname, sizeof(resname),
- L"\\StringFileInfo\\%04x%04x\\" TEXT(NIMV_APIVER),
- languages[i].language,
- languages[i].codepage);
-
- if (!VerQueryValue(m->version_info,
- resname, (LPVOID *) &r, &c)) {
- rv = KHM_ERROR_INVALID_PARAM;
- _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING,
- _cstr(TEXT(NIMV_APIVER)));
- goto _cleanup;
- }
-
- if (c > KMM_MAXCB_NAME ||
- FAILED(StringCbLength(r, KMM_MAXCB_NAME, &cb))) {
- rv = KHM_ERROR_INVALID_PARAM;
- _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG,
- _cstr(TEXT(NIMV_APIVER)));
- goto _cleanup;
- }
-
- t = wcstol(r, NULL, 10);
-
- rv = kmmint_check_api_version(t);
-
- if (KHM_FAILED(rv)) {
- _report_mr2(KHERR_WARNING, MSG_RMI_API_MISMATCH,
- _int32(t), _int32(KH_VERSION_API));
- goto _cleanup;
- }
-
- /* Looks good. Now load the description, copyright, support URI
- and file versions */
- if (m->description) {
- PFREE(m->description);
- m->description = NULL;
- }
-
- StringCbPrintf(resname, sizeof(resname),
- L"\\StringFileInfo\\%04x%04x\\FileDescription",
- languages[i].language,
- languages[i].codepage);
-
- if (!VerQueryValue(m->version_info,
- resname, (LPVOID *) &r, &c)) {
- rv = KHM_ERROR_INVALID_PARAM;
- _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING,
- _cstr(L"FileDescription"));
- goto _cleanup;
- }
-
- if (c > KMM_MAXCB_DESC ||
- FAILED(StringCbLength(r, KMM_MAXCB_DESC, &cb))) {
- rv = KHM_ERROR_INVALID_PARAM;
- _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG,
- _cstr(L"FileDescription"));
- goto _cleanup;
- }
-
- cb += sizeof(wchar_t);
-
- m->description = PMALLOC(cb);
-#ifdef DEBUG
- assert(m->description);
-#endif
- StringCbCopy(m->description, cb, r);
-
- /* on to the support URI */
- if (m->support) {
- PFREE(m->support);
- m->support = NULL;
- }
-
- StringCbPrintf(resname, sizeof(resname),
- L"\\StringFileInfo\\%04x%04x\\" TEXT(NIMV_SUPPORT),
- languages[i].language,
- languages[i].codepage);
-
- if (!VerQueryValue(m->version_info,
- resname, (LPVOID *) &r, &c)) {
- rv = KHM_ERROR_INVALID_PARAM;
- _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING,
- _cstr(TEXT(NIMV_SUPPORT)));
- goto _cleanup;
- }
-
- if (c > KMM_MAXCB_SUPPORT ||
- FAILED(StringCbLength(r, KMM_MAXCB_SUPPORT, &cb))) {
- rv = KHM_ERROR_INVALID_PARAM;
- _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG,
- _cstr(TEXT(NIMV_SUPPORT)));
- goto _cleanup;
- }
-
- cb += sizeof(wchar_t);
-
- m->support = PMALLOC(cb);
-#ifdef DEBUG
- assert(m->support);
-#endif
- StringCbCopy(m->support, cb, r);
-
- /* the vendor/copyright */
- if (m->vendor) {
- PFREE(m->vendor);
- m->vendor = NULL;
- }
-
- StringCbPrintf(resname, sizeof(resname),
- L"\\StringFileInfo\\%04x%04x\\LegalCopyright",
- languages[i].language,
- languages[i].codepage);
-
- if (!VerQueryValue(m->version_info,
- resname, (LPVOID *) &r, &c)) {
- rv = KHM_ERROR_INVALID_PARAM;
- _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING,
- _cstr(L"LegalCopyright"));
- goto _cleanup;
- }
-
- if (c > KMM_MAXCB_SUPPORT ||
- FAILED(StringCbLength(r, KMM_MAXCB_SUPPORT, &cb))) {
- rv = KHM_ERROR_INVALID_PARAM;
- _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG,
- _cstr(L"LegalCopyright"));
- goto _cleanup;
- }
-
- cb += sizeof(wchar_t);
-
- m->vendor = PMALLOC(cb);
-#ifdef DEBUG
- assert(m->vendor);
-#endif
- StringCbCopy(m->vendor, cb, r);
-
- if (!VerQueryValue(m->version_info,
- L"\\",
- (LPVOID *) &vff, &c) ||
- c != sizeof(*vff)) {
-
- rv = KHM_ERROR_INVALID_PARAM;
- _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING,
- _cstr(L"Fixed Version Info"));
- goto _cleanup;
- }
-
- m->file_version.major = HIWORD(vff->dwFileVersionMS);
- m->file_version.minor = LOWORD(vff->dwFileVersionMS);
- m->file_version.patch = HIWORD(vff->dwFileVersionLS);
- m->file_version.aux = LOWORD(vff->dwFileVersionLS);
-
- m->prod_version.major = HIWORD(vff->dwProductVersionMS);
- m->prod_version.minor = LOWORD(vff->dwProductVersionMS);
- m->prod_version.patch = HIWORD(vff->dwProductVersionLS);
- m->prod_version.aux = LOWORD(vff->dwProductVersionLS);
-
- rv = KHM_ERROR_SUCCESS;
-
- _cleanup:
- if (KHM_FAILED(rv)) {
- if (m->version_info) {
- PFREE(m->version_info);
- m->version_info = NULL;
- }
- }
-
- return rv;
-}
-
-KHMEXP khm_int32 KHMAPI kmm_load_module(wchar_t * modname,
- khm_int32 flags,
- kmm_module * result)
-{
- kmm_module_i * m = NULL;
- kmm_module_i * mi;
- size_t cbsize;
- khm_int32 rv = KHM_ERROR_SUCCESS;
-
- if(FAILED(StringCbLength(modname, KMM_MAXCB_NAME, &cbsize)))
- return KHM_ERROR_INVALID_PARAM;
- cbsize += sizeof(wchar_t);
-
- EnterCriticalSection(&cs_kmm);
- mi = kmmint_find_module_i(modname);
-
- if(mi != NULL) {
- kmm_hold_module(kmm_handle_from_module(mi));
- /* check if the module has either failed to load either or if
- it has been terminated. If so, we try once again to load the
- module. */
- if(!(flags & KMM_LM_FLAG_NOLOAD) &&
- (mi->state < 0 || mi->state == KMM_MODULE_STATE_EXITED))
- {
- mi->state = KMM_MODULE_STATE_PREINIT;
- }
- }
- LeaveCriticalSection(&cs_kmm);
-
- if(flags & KMM_LM_FLAG_NOLOAD) {
- if(result)
- *result = mi;
- else if(mi)
- kmm_release_module(kmm_handle_from_module(mi));
-
- return (mi)? KHM_ERROR_SUCCESS: KHM_ERROR_NOT_FOUND;
- }
-
- if(mi) {
- m = mi;
- } else {
- m = kmmint_get_module_i(modname);
- m->state = KMM_MODULE_STATE_PREINIT;
- kmm_hold_module(kmm_handle_from_module(m));
- }
-
- /* the module is already running or is already being
- worked on by the registrar */
- if(m->state != KMM_MODULE_STATE_PREINIT) {
- if(result)
- *result = kmm_handle_from_module(m);
- else
- kmm_release_module(kmm_handle_from_module(m));
-
- return KHM_ERROR_EXISTS;
- }
-
- kmmint_add_to_module_queue();
-
- if(flags & KMM_LM_FLAG_SYNC) {
- kmm_hold_module(kmm_handle_from_module(m));
- kmq_send_message(KMSG_KMM,
- KMSG_KMM_I_REG,
- KMM_REG_INIT_MODULE,
- (void*) m);
- if(m->state <= 0) {
- /* failed to load ? */
- if(m->state == KMM_MODULE_STATE_FAIL_NOT_FOUND)
- rv = KHM_ERROR_NOT_FOUND;
- else if(m->state == KMM_MODULE_STATE_FAIL_SIGNATURE)
- rv = KHM_ERROR_INVALID_SIGNATURE;
- else
- rv = KHM_ERROR_UNKNOWN;
-
- kmm_release_module(kmm_handle_from_module(m));
- if(result)
- *result = NULL;
- } else {
- if(result)
- *result = kmm_handle_from_module(m);
- else
- kmm_release_module(kmm_handle_from_module(m));
- }
- } else {
- kmm_hold_module(kmm_handle_from_module(m));
- kmq_post_message(KMSG_KMM,
- KMSG_KMM_I_REG,
- KMM_REG_INIT_MODULE,
- (void*) m);
- if(result)
- *result = kmm_handle_from_module(m);
- else
- kmm_release_module(kmm_handle_from_module(m));
- }
-
- return rv;
-}
-
-KHMEXP khm_int32 KHMAPI
-kmm_get_module_state(kmm_module m)
-{
- if(!kmm_is_module(m))
- return KMM_MODULE_STATE_NONE;
- else
- return kmm_module_from_handle(m)->state;
-}
-
-KHMEXP khm_int32 KHMAPI
-kmm_get_module_info_i(kmm_module vm, kmm_module_info * info) {
- kmm_module_i * m;
- khm_int32 rv;
-
- EnterCriticalSection(&cs_kmm);
- if (!kmm_is_module(vm) || !info)
- rv = KHM_ERROR_INVALID_PARAM;
- else {
- m = kmm_module_from_handle(vm);
-
- ZeroMemory(info, sizeof(*info));
-
- info->reg.name = m->name;
- info->reg.path = m->path;
- info->reg.vendor = m->vendor;
-
- info->reg.n_plugins = m->plugin_count;
-
- info->state = m->state;
-
- info->h_module = vm;
-
- info->file_version = m->file_version;
- info->product_version = m->prod_version;
- kmm_hold_module(vm);
-
- rv = KHM_ERROR_SUCCESS;
- }
- LeaveCriticalSection(&cs_kmm);
-
- return rv;
-}
-
-KHMEXP khm_int32 KHMAPI
-kmm_release_module_info_i(kmm_module_info * info) {
- if (info->h_module)
- kmm_release_module(info->h_module);
-
- ZeroMemory(info, sizeof(*info));
-
- return KHM_ERROR_SUCCESS;
-}
-
-
-KHMEXP khm_int32 KHMAPI
-kmm_unload_module(kmm_module module) {
-
- if(!kmm_is_module(module))
- return KHM_ERROR_INVALID_PARAM;
-
- kmm_hold_module(module);
- kmq_post_message(KMSG_KMM,
- KMSG_KMM_I_REG,
- KMM_REG_EXIT_MODULE,
- (void *) kmm_module_from_handle(module));
-
- return KHM_ERROR_SUCCESS;
-}
-
-KHMEXP khm_int32 KHMAPI
-kmm_load_default_modules(void) {
- khm_handle csm = NULL;
- khm_handle cs_mod = NULL;
- khm_int32 rv;
- wchar_t buf[KMM_MAXCCH_NAME];
- khm_size s;
-
- rv = kmm_get_modules_config(0, &csm);
- if(KHM_FAILED(rv))
- return rv;
-
- _begin_task(KHERR_CF_TRANSITIVE);
- _report_mr0(KHERR_NONE, MSG_LOAD_DEFAULT);
- _describe();
-
- kmmint_add_to_module_queue();
-
- while(KHM_SUCCEEDED(khc_enum_subspaces(csm, cs_mod, &cs_mod))) {
-
- s = sizeof(buf);
- if (KHM_FAILED(khc_get_config_space_name(cs_mod, buf, &s)))
- continue;
-
- /* check for schema subspace. This is not an actual module. */
- if (!wcscmp(buf, L"_Schema"))
- continue;
-
- kmm_load_module(buf, 0, NULL);
- }
-
- kmmint_remove_from_module_queue();
-
- if(csm)
- khc_close_space(csm);
-
- _end_task();
-
- return rv;
-}
-
-#ifdef _WIN32
-KHMEXP HMODULE KHMAPI
-kmm_get_hmodule(kmm_module m)
-{
- if(!kmm_is_module(m))
- return NULL;
- else
- return kmm_module_from_handle(m)->h_module;
-}
-#endif
diff --git a/src/windows/identity/kmm/kmm_plugin.c b/src/windows/identity/kmm/kmm_plugin.c
deleted file mode 100644
index e44d59862..000000000
--- a/src/windows/identity/kmm/kmm_plugin.c
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/* $Id$ */
-
-#include<kmminternal.h>
-
-/* Called with no locks held to get a kmm_plugin_i structure
- that matches the name. First we look in the hash table, and
- if one isn't found, we create an empty one.
-*/
-
-kmm_plugin_i *
-kmmint_get_plugin_i(wchar_t * name)
-{
- kmm_plugin_i * p;
- size_t cb;
-
- if(FAILED(StringCbLength(name, KMM_MAXCB_NAME, &cb)))
- return NULL;
- cb += sizeof(wchar_t);
-
- EnterCriticalSection(&cs_kmm);
- p = (kmm_plugin_i *) hash_lookup(hash_plugins, (void *) name);
-
- if(p == NULL) {
- p = PMALLOC(sizeof(kmm_plugin_i));
- ZeroMemory(p, sizeof(kmm_plugin_i));
- p->magic = KMM_PLUGIN_MAGIC;
- p->p.name = PMALLOC(cb);
- StringCbCopy(p->p.name, cb, name);
- p->state = KMM_PLUGIN_STATE_NONE;
-
- hash_add(hash_plugins, (void *) p->p.name, (void *) p);
- kmmint_list_plugin(p);
- }
- LeaveCriticalSection(&cs_kmm);
-
- return p;
-}
-
-kmm_plugin_i *
-kmmint_find_plugin_i(wchar_t * name)
-{
- kmm_plugin_i * p;
- size_t cb;
-
- if(FAILED(StringCbLength(name, KMM_MAXCB_NAME, &cb)))
- return NULL;
-
- EnterCriticalSection(&cs_kmm);
- p = (kmm_plugin_i *) hash_lookup(hash_plugins, (void *) name);
- LeaveCriticalSection(&cs_kmm);
-
- return p;
-}
-
-/* the plugin must be delisted before calling this */
-void
-kmmint_list_plugin(kmm_plugin_i * p)
-{
- EnterCriticalSection(&cs_kmm);
- if((p->flags & KMM_PLUGIN_FLAG_IN_MODLIST) ||
- (p->flags & KMM_PLUGIN_FLAG_IN_LIST))
- {
- RaiseException(2, EXCEPTION_NONCONTINUABLE, 0, NULL);
- }
- p->flags |= KMM_PLUGIN_FLAG_IN_LIST;
- LPUSH(&kmm_listed_plugins, p);
- LeaveCriticalSection(&cs_kmm);
-}
-
-void
-kmmint_delist_plugin(kmm_plugin_i * p)
-{
- EnterCriticalSection(&cs_kmm);
- if(p->flags & KMM_PLUGIN_FLAG_IN_LIST) {
- p->flags &= ~KMM_PLUGIN_FLAG_IN_LIST;
- LDELETE(&kmm_listed_plugins, p);
- }
- if(p->flags & KMM_PLUGIN_FLAG_IN_MODLIST) {
- p->flags &= ~KMM_PLUGIN_FLAG_IN_MODLIST;
- LDELETE(&(p->module->plugins), p);
- }
- LeaveCriticalSection(&cs_kmm);
-}
-
-KHMEXP khm_int32 KHMAPI
-kmm_hold_plugin(kmm_plugin p)
-{
- kmm_plugin_i * pi;
-
- if(!kmm_is_plugin(p))
- return KHM_ERROR_INVALID_PARAM;
-
- EnterCriticalSection(&cs_kmm);
- pi = kmm_plugin_from_handle(p);
- pi->refcount++;
- LeaveCriticalSection(&cs_kmm);
-
- return KHM_ERROR_SUCCESS;
-}
-
-/* called with cs_kmm held */
-void
-kmmint_free_plugin(kmm_plugin_i * pi)
-{
- int i;
- pi->magic = 0;
-
- hash_del(hash_plugins, (void *) pi->p.name);
-
- kmmint_delist_plugin(pi);
-
- for(i=0; i<pi->n_dependants; i++) {
- kmm_release_plugin(kmm_handle_from_plugin(pi->dependants[i]));
- pi->dependants[i] = NULL;
- }
-
- if(pi->module) {
- kmm_release_module(kmm_handle_from_module(pi->module));
- }
-
- pi->module = NULL;
- pi->p.module = NULL;
-
- if(pi->p.name)
- PFREE(pi->p.name);
- pi->p.name = NULL;
-
- if(pi->p.description)
- PFREE(pi->p.description);
- pi->p.description = NULL;
-
- if(pi->p.dependencies)
- PFREE(pi->p.dependencies);
- pi->p.dependencies = NULL;
-
- PFREE(pi);
-}
-
-KHMEXP khm_int32 KHMAPI
-kmm_enable_plugin(kmm_plugin p, khm_boolean enable) {
- kmm_plugin_i * pi;
- khm_int32 rv = KHM_ERROR_NOT_FOUND; /* default to error */
- khm_handle csp_plugin = NULL;
-
- EnterCriticalSection(&cs_kmm);
- if (!kmm_is_plugin(p)) {
- rv = KHM_ERROR_INVALID_PARAM;
- goto _cleanup;
- }
-
- pi = kmm_plugin_from_handle(p);
-
- if (KHM_FAILED(rv = kmm_get_plugin_config(pi->p.name, 0, &csp_plugin))) {
- goto _cleanup;
- }
-
- if (KHM_FAILED(rv = khc_write_int32(csp_plugin, L"Disabled", !enable))) {
- goto _cleanup;
- }
-
- rv = KHM_ERROR_SUCCESS;
-
- _cleanup:
- LeaveCriticalSection(&cs_kmm);
-
- if (csp_plugin)
- khc_close_space(csp_plugin);
-
- return rv;
-}
-
-KHMEXP khm_int32 KHMAPI
-kmm_get_plugin_info_i(kmm_plugin p, kmm_plugin_info * info) {
- khm_int32 rv = KHM_ERROR_SUCCESS;
- kmm_plugin_i * pi;
- khm_handle csp_plugin;
-
- if (!info)
- return KHM_ERROR_INVALID_PARAM;
-
- EnterCriticalSection(&cs_kmm);
- if (!kmm_is_plugin(p)) {
- rv = KHM_ERROR_INVALID_PARAM;
- goto _cleanup;
- }
-
- pi = kmm_plugin_from_handle(p);
-
- ZeroMemory(info, sizeof(*info));
-
- info->reg = pi->p;
- info->reg.msg_proc = NULL;
-
- if (KHM_FAILED(kmm_get_plugin_config(pi->p.name, KHM_PERM_READ,
- &csp_plugin))) {
- info->failure_count = 0;
- *((khm_int64 *)&info->failure_time) = 0;
- info->failure_reason = 0;
- } else {
- if (KHM_FAILED(khc_read_int32(csp_plugin, L"FailureCount",
- &info->failure_count)))
- info->failure_count = 0;
- if (KHM_FAILED(khc_read_int64(csp_plugin, L"FailureTime",
- (khm_int64 *) &info->failure_time)))
- *((khm_int64 *) &info->failure_time) = 0;
- if (KHM_FAILED(khc_read_int32(csp_plugin, L"FailureReason",
- &info->failure_reason)))
- info->failure_reason = 0;
-
- khc_close_space(csp_plugin);
- }
-
- info->state = pi->state;
-
- kmm_hold_plugin(p);
- info->h_plugin = p;
-
- info->flags = (pi->flags & KMM_PLUGIN_FLAG_DISABLED);
-
- _cleanup:
- LeaveCriticalSection(&cs_kmm);
-
- return rv;
-}
-
-KHMEXP khm_int32 KHMAPI
-kmm_release_plugin_info_i(kmm_plugin_info * info) {
- khm_int32 rv;
-
- if (!info || !info->h_plugin)
- return KHM_ERROR_INVALID_PARAM;
-
- rv = kmm_release_plugin(info->h_plugin);
-
- ZeroMemory(info, sizeof(info));
-
- return rv;
-}
-
-KHMEXP khm_int32 KHMAPI
-kmm_get_next_plugin(kmm_plugin p, kmm_plugin * p_next) {
- khm_int32 rv = KHM_ERROR_SUCCESS;
- kmm_plugin_i * pi;
- kmm_plugin_i * pi_next = NULL;
- kmm_module_i * m;
-
- EnterCriticalSection(&cs_kmm);
- if (p == NULL) {
- if (kmm_listed_plugins)
- pi_next = kmm_listed_plugins;
- else {
- for (m = kmm_all_modules; m; m = LNEXT(m)) {
- if (m->plugins) {
- pi_next = m->plugins;
- break;
- }
- }
- }
- } else if (kmm_is_plugin(p)) {
- pi = kmm_plugin_from_handle(p);
- pi_next = LNEXT(pi);
-
- if (!pi_next) {
- /* we have either exhausted the listed plugins or we are
- at the end of the module's plugin list */
- if (pi->module) {
- m = LNEXT(pi->module);
- } else {
- m = kmm_all_modules;
- }
-
- for(; m; m = LNEXT(m)) {
- if (m->plugins) {
- pi_next = m->plugins;
- break;
- }
- }
- }
- }
-
- if (pi_next) {
- *p_next = kmm_handle_from_plugin(pi_next);
- kmm_hold_plugin(*p_next);
- } else {
- *p_next = NULL;
- rv = KHM_ERROR_NOT_FOUND;
- }
-
- LeaveCriticalSection(&cs_kmm);
- return rv;
-}
-
-KHMEXP khm_int32 KHMAPI
-kmm_release_plugin(kmm_plugin p)
-{
- kmm_plugin_i * pi;
-
- if(!kmm_is_plugin(p))
- return KHM_ERROR_INVALID_PARAM;
-
- EnterCriticalSection(&cs_kmm);
- pi = kmm_plugin_from_handle(p);
- pi->refcount--;
- if(pi->refcount == 0) {
- kmmint_free_plugin(pi);
- }
- LeaveCriticalSection(&cs_kmm);
-
- return KHM_ERROR_SUCCESS;
-}
-
-KHMEXP khm_int32 KHMAPI
-kmm_provide_plugin(kmm_module module, kmm_plugin_reg * plugin)
-{
- kmm_module_i * m;
- kmm_plugin_i * p;
- size_t cb_name = 0;
- size_t cb_desc = 0;
- size_t cb_dep = 0;
-
- m = kmm_module_from_handle(module);
-
- /* can only called when handing init_module() */
- if(m->state != KMM_MODULE_STATE_INIT)
- return KHM_ERROR_INVALID_OPERATION;
-
- if(!plugin ||
- FAILED(StringCbLength(plugin->name, KMM_MAXCB_NAME - sizeof(wchar_t),
- &cb_name)) ||
- (plugin->description &&
- FAILED(StringCbLength(plugin->description,
- KMM_MAXCB_DESC - sizeof(wchar_t),
- &cb_desc))) ||
- (plugin->dependencies &&
- KHM_FAILED(multi_string_length_cb(plugin->dependencies,
- KMM_MAXCB_DEPS, &cb_dep)))) {
- return KHM_ERROR_INVALID_PARAM;
- }
-
- cb_name += sizeof(wchar_t);
- cb_desc += sizeof(wchar_t);
-
- p = kmmint_get_plugin_i(plugin->name);
-
- /* released below or in kmmint_init_module() */
- kmm_hold_plugin(kmm_handle_from_plugin(p));
-
- if(p->state != KMM_PLUGIN_STATE_NONE &&
- p->state != KMM_PLUGIN_STATE_PLACEHOLDER)
- {
- kmm_release_plugin(kmm_handle_from_plugin(p));
- return KHM_ERROR_DUPLICATE;
- }
-
- /* released when the plugin quits */
- kmm_hold_module(module);
-
- p->module = m;
- p->p.flags = plugin->flags;
- p->p.msg_proc = plugin->msg_proc;
- p->p.type = plugin->type;
-
- if(plugin->description) {
- p->p.description = PMALLOC(cb_desc);
- StringCbCopy(p->p.description, cb_desc, plugin->description);
- } else
- p->p.description = NULL;
-
- if(plugin->dependencies) {
- p->p.dependencies = PMALLOC(cb_dep);
- multi_string_copy_cb(p->p.dependencies, cb_dep, plugin->dependencies);
- } else
- p->p.dependencies = NULL;
-
- p->p.module = p->module->name;
-
- p->p.icon = plugin->icon;
-
- p->state = KMM_PLUGIN_STATE_REG;
-
- kmmint_delist_plugin(p);
- EnterCriticalSection(&cs_kmm);
- LPUSH(&(m->plugins), p);
- p->flags |= KMM_PLUGIN_FLAG_IN_MODLIST;
- LeaveCriticalSection(&cs_kmm);
-
- /* leave the plugin held because it is in the module's plugin list */
- return KHM_ERROR_SUCCESS;
-}
diff --git a/src/windows/identity/kmm/kmm_reg.c b/src/windows/identity/kmm/kmm_reg.c
deleted file mode 100644
index 00626550f..000000000
--- a/src/windows/identity/kmm/kmm_reg.c
+++ /dev/null
@@ -1,336 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- * Copyright (c) 2006, 2007 Secure Endpoints Inc.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/* $Id$ */
-
-#include<kmminternal.h>
-
-KHMEXP khm_int32 KHMAPI
-kmm_get_module_info(wchar_t * module_name, khm_int32 flags,
- kmm_module_info * buffer, khm_size * cb_buffer)
-{
- /*TODO:Implement this */
- return KHM_ERROR_NOT_IMPLEMENTED;
-}
-
-KHMEXP khm_int32 KHMAPI
-kmm_get_plugin_info(wchar_t * plugin_name,
- kmm_plugin_info * buffer, khm_size * cb_buffer)
-{
- /*TODO:Implement this */
- return KHM_ERROR_NOT_IMPLEMENTED;
-}
-
-KHMEXP khm_int32 KHMAPI
-kmm_get_plugins_config(khm_int32 flags, khm_handle * result) {
- khm_handle csp_root;
- khm_handle csp_plugins;
- khm_int32 rv;
-
- rv = khc_open_space(KHM_INVALID_HANDLE, KMM_CSNAME_ROOT, flags, &csp_root);
-
- if(KHM_FAILED(rv))
- return rv;
-
- rv = khc_open_space(csp_root, KMM_CSNAME_PLUGINS, flags, &csp_plugins);
- khc_close_space(csp_root);
-
- if(KHM_SUCCEEDED(rv))
- *result = csp_plugins;
- else
- *result = NULL;
-
- return rv;
-}
-
-
-KHMEXP khm_int32 KHMAPI
-kmm_get_modules_config(khm_int32 flags, khm_handle * result) {
- khm_handle croot;
- khm_handle kmm_all_modules;
- khm_int32 rv;
-
- rv = khc_open_space(NULL, KMM_CSNAME_ROOT, flags, &croot);
-
- if(KHM_FAILED(rv))
- return rv;
-
- rv = khc_open_space(croot, KMM_CSNAME_MODULES, flags, &kmm_all_modules);
- khc_close_space(croot);
-
- if(KHM_SUCCEEDED(rv))
- *result = kmm_all_modules;
- else
- *result = NULL;
-
- return rv;
-}
-
-
-KHMEXP khm_int32 KHMAPI
-kmm_get_plugin_config(wchar_t * plugin, khm_int32 flags, khm_handle * result)
-{
- khm_handle csplugins;
- khm_handle csplugin;
- khm_int32 rv;
-
- if(!plugin || wcschr(plugin, L'/') || wcschr(plugin, L'\\'))
- return KHM_ERROR_INVALID_PARAM;
-
- if(KHM_FAILED(kmm_get_plugins_config(flags, &csplugins)))
- return KHM_ERROR_UNKNOWN;
-
- rv = khc_open_space(csplugins, plugin, flags, &csplugin);
- *result = csplugin;
-
- khc_close_space(csplugins);
-
- return rv;
-}
-
-
-KHMEXP khm_int32 KHMAPI
-kmm_get_module_config(wchar_t * module, khm_int32 flags, khm_handle * result)
-{
- khm_handle csmodules;
- khm_handle csmodule;
- khm_int32 rv;
-
- if(!module || wcschr(module, L'/') || wcschr(module, L'\\'))
- return KHM_ERROR_INVALID_PARAM;
-
- if(KHM_FAILED(kmm_get_modules_config(flags, &csmodules)))
- return KHM_ERROR_UNKNOWN;
-
- rv = khc_open_space(csmodules, module, flags, &csmodule);
- *result = csmodule;
-
- khc_close_space(csmodules);
-
- return rv;
-}
-
-KHMEXP khm_int32 KHMAPI
-kmm_register_plugin(kmm_plugin_reg * plugin, khm_int32 config_flags)
-{
- khm_int32 rv = KHM_ERROR_SUCCESS;
- khm_handle csp_plugin = NULL;
- khm_handle csp_module = NULL;
- size_t cch;
-
- /* avoid accidently creating the module key if it doesn't exist */
- config_flags &= ~KHM_FLAG_CREATE;
-
- if((plugin == NULL) ||
- (plugin->dependencies &&
- KHM_FAILED(multi_string_length_cch(plugin->dependencies,
- KMM_MAXCCH_DEPS, &cch))) ||
- FAILED(StringCchLength(plugin->module, KMM_MAXCCH_NAME, &cch)) ||
- (plugin->description &&
- FAILED(StringCchLength(plugin->description,
- KMM_MAXCCH_DESC, &cch))) ||
- FAILED(StringCchLength(plugin->name, KMM_MAXCCH_NAME, &cch)))
- {
- return KHM_ERROR_INVALID_PARAM;
- }
-
- /* note that we are retaining the length of the plugin name in
- chars in cch */
- cch ++;
-
-#define CKRV if(KHM_FAILED(rv)) goto _exit
-
- rv = kmm_get_plugin_config(plugin->name,
- config_flags | KHM_FLAG_CREATE, &csp_plugin);
- CKRV;
-
- /* should fail if the module key doesn't exist */
- rv = kmm_get_module_config(plugin->module, config_flags, &csp_module);
- CKRV;
-
- /*TODO: Make sure that the module registration is in the same
- config store as the one in which the plugin is going to be
- registered */
-
- rv = khc_write_string(csp_plugin, L"Module", plugin->module);
- CKRV;
- if(plugin->description) {
- rv = khc_write_string(csp_plugin, L"Description", plugin->description);
- CKRV;
- }
-
- if(plugin->dependencies) {
- rv = khc_write_multi_string(csp_plugin, L"Dependencies",
- plugin->dependencies);
- CKRV;
- }
-
- rv = khc_write_int32(csp_plugin, L"Type", plugin->type);
- CKRV;
- rv = khc_write_int32(csp_plugin, L"Disabled",
- !!(plugin->flags & KMM_PLUGIN_FLAG_DISABLED));
- CKRV;
-
- {
- khm_size cb = 0;
- wchar_t * pl = NULL;
- size_t scb = 0;
-
- rv = khc_read_multi_string(csp_module, L"PluginList", NULL, &cb);
- if(rv != KHM_ERROR_TOO_LONG) {
- if (rv == KHM_ERROR_NOT_FOUND) {
-
- scb = cb = (cch + 1) * sizeof(wchar_t);
- pl = PMALLOC(cb);
- multi_string_init(pl, cb);
- rv = KHM_ERROR_SUCCESS;
-
- goto add_plugin_to_list;
-
- } else {
- goto _exit;
- }
- }
-
- cb += cch * sizeof(wchar_t);
- scb = cb;
-
- pl = PMALLOC(cb);
-
- rv = khc_read_multi_string(csp_module, L"PluginList", pl, &cb);
- if(KHM_FAILED(rv)) {
- if(pl)
- PFREE(pl);
- goto _exit;
- }
-
- add_plugin_to_list:
-
- if(!multi_string_find(pl, plugin->name, 0)) {
- multi_string_append(pl, &scb, plugin->name);
- rv = khc_write_multi_string(csp_module, L"PluginList", pl);
- }
-
- PFREE(pl);
- CKRV;
- }
-
-#undef CKRV
-
-_exit:
- if(csp_plugin)
- khc_close_space(csp_plugin);
- if(csp_module)
- khc_close_space(csp_module);
-
- return rv;
-}
-
-KHMEXP khm_int32 KHMAPI
-kmm_register_module(kmm_module_reg * module, khm_int32 config_flags)
-{
- khm_int32 rv = KHM_ERROR_SUCCESS;
- khm_handle csp_module = NULL;
- size_t cch;
- int i;
-
- if((module == NULL) ||
- FAILED(StringCchLength(module->name, KMM_MAXCCH_NAME, &cch)) ||
- (module->description &&
- FAILED(StringCchLength(module->description,
- KMM_MAXCCH_DESC, &cch))) ||
- FAILED(StringCchLength(module->path, MAX_PATH, &cch)) ||
- (module->n_plugins > 0 && module->plugin_reg_info == NULL)) {
- return KHM_ERROR_INVALID_PARAM;
- }
-
-#define CKRV if(KHM_FAILED(rv)) goto _exit
-
- rv = kmm_get_module_config(module->name, config_flags | KHM_FLAG_CREATE,
- &csp_module);
- CKRV;
-
- rv = khc_write_string(csp_module, L"ImagePath", module->path);
- CKRV;
-
- rv = khc_write_int32(csp_module, L"Disabled", 0);
- CKRV;
-
- /* FileVersion and ProductVersion will be set when the module
- is loaded for the first time */
-
- for(i=0; i<module->n_plugins; i++) {
- rv = kmm_register_plugin(&(module->plugin_reg_info[i]), config_flags);
- CKRV;
- }
-
-#undef CKRV
-_exit:
- if(csp_module)
- khc_close_space(csp_module);
-
- return rv;
-}
-
-KHMEXP khm_int32 KHMAPI
-kmm_unregister_plugin(wchar_t * plugin, khm_int32 config_flags)
-{
- khm_handle csp_plugin = NULL;
- khm_int32 rv = KHM_ERROR_SUCCESS;
-
- rv = kmm_get_plugin_config(plugin, config_flags, &csp_plugin);
-
- if (KHM_FAILED(rv))
- goto _cleanup;
-
- rv = khc_remove_space(csp_plugin);
-
- _cleanup:
-
- if (csp_plugin)
- khc_close_space(csp_plugin);
-
- return rv;
-}
-
-KHMEXP khm_int32 KHMAPI
-kmm_unregister_module(wchar_t * module, khm_int32 config_flags)
-{
- khm_handle csp_module = NULL;
- khm_int32 rv = KHM_ERROR_SUCCESS;
-
- rv = kmm_get_module_config(module, config_flags, &csp_module);
-
- if (KHM_FAILED(rv))
- goto _cleanup;
-
- rv = khc_remove_space(csp_module);
-
- _cleanup:
- if (csp_module)
- khc_close_space(csp_module);
-
- return rv;
-}
diff --git a/src/windows/identity/kmm/kmm_registrar.c b/src/windows/identity/kmm/kmm_registrar.c
deleted file mode 100644
index c3bcdb9a9..000000000
--- a/src/windows/identity/kmm/kmm_registrar.c
+++ /dev/null
@@ -1,1034 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- * Copyright (c) 2007 Secure Endpoints Inc.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/* $Id$ */
-
-#include<kmminternal.h>
-#ifdef DEBUG
-#include<assert.h>
-#endif
-
-static LONG pending_modules = 0;
-static LONG pending_plugins = 0;
-static LONG startup_signal = 0;
-static BOOL load_done = FALSE;
-
-void
-kmmint_check_completion(void) {
- if (pending_modules == 0 &&
- pending_plugins == 0 &&
- InterlockedIncrement(&startup_signal) == 1) {
-
- load_done = TRUE;
-
- /* TODO: check for orphaned plugins */
-
- kmq_post_message(KMSG_KMM, KMSG_KMM_I_DONE, 0, 0);
- }
-}
-
-void
-kmmint_add_to_module_queue(void) {
- InterlockedIncrement(&pending_modules);
-}
-
-void
-kmmint_remove_from_module_queue(void) {
-
- InterlockedDecrement(&pending_modules);
-
- kmmint_check_completion();
-}
-
-void
-kmmint_add_to_plugin_queue(kmm_plugin_i * plugin) {
- EnterCriticalSection(&cs_kmm);
- if (!(plugin->flags & KMM_PLUGIN_FLAG_IN_QUEUE)) {
- InterlockedIncrement(&pending_plugins);
- plugin->flags |= KMM_PLUGIN_FLAG_IN_QUEUE;
- }
- LeaveCriticalSection(&cs_kmm);
-}
-
-void
-kmmint_remove_from_plugin_queue(kmm_plugin_i * plugin) {
- EnterCriticalSection(&cs_kmm);
-
- if (plugin->flags & KMM_PLUGIN_FLAG_IN_QUEUE) {
- InterlockedDecrement(&pending_plugins);
- plugin->flags &= ~KMM_PLUGIN_FLAG_IN_QUEUE;
- }
-
- LeaveCriticalSection(&cs_kmm);
- kmmint_check_completion();
-}
-
-KHMEXP khm_boolean KHMAPI
-kmm_load_pending(void) {
- return !load_done;
-}
-
-/*! \internal
- \brief Message handler for the registrar thread. */
-khm_boolean KHMAPI kmmint_reg_cb(khm_int32 msg_type,
- khm_int32 msg_sub_type,
- khm_ui_4 uparam,
- void *vparam)
-{
- /* we should only be getting <KMSG_KMM,KMSG_KMM_I_REG> anyway */
- if(msg_type != KMSG_KMM || msg_sub_type != KMSG_KMM_I_REG)
- return FALSE;
-
- switch(uparam) {
- case KMM_REG_INIT_MODULE:
- kmmint_init_module((kmm_module_i *) vparam);
- kmm_release_module(kmm_handle_from_module((kmm_module_i *) vparam));
- break;
-
- case KMM_REG_EXIT_MODULE:
- kmmint_exit_module((kmm_module_i *) vparam);
- kmm_release_module(kmm_handle_from_module((kmm_module_i *) vparam));
- break;
-
- case KMM_REG_INIT_PLUGIN:
- kmmint_init_plugin((kmm_plugin_i *) vparam);
- kmm_release_plugin(kmm_handle_from_plugin((kmm_plugin_i *) vparam));
- break;
-
- case KMM_REG_EXIT_PLUGIN:
- kmmint_exit_plugin((kmm_plugin_i *) vparam);
- kmm_release_plugin(kmm_handle_from_plugin((kmm_plugin_i *) vparam));
- break;
- }
- return TRUE;
-}
-
-/*! \internal
- \brief The registrar thread.
-
- The only thing this function does is to dispatch messages to the
- callback routine ( kmmint_reg_cb() ) */
-DWORD WINAPI kmmint_registrar(LPVOID lpParameter)
-{
-
- PDESCTHREAD(L"KMM Registrar", L"KMM");
-
- tid_registrar = GetCurrentThreadId();
-
- kmq_subscribe(KMSG_KMM, kmmint_reg_cb);
- kmq_subscribe(KMSG_SYSTEM, kmmint_reg_cb);
-
- SetEvent(evt_startup);
-
- while(KHM_SUCCEEDED(kmq_dispatch(INFINITE)));
-
- kmq_unsubscribe(KMSG_KMM, kmmint_reg_cb);
- kmq_unsubscribe(KMSG_SYSTEM, kmmint_reg_cb);
-
- ExitThread(0);
-}
-
-/*! \internal
- \brief Manages a plugin message thread.
-
- Each plugin gets its own plugin thread which is used to dispatch
- messages to the plugin. This acts as the thread function for the
- plugin thread.*/
-DWORD WINAPI kmmint_plugin_broker(LPVOID lpParameter)
-{
- DWORD rv = 0;
- kmm_plugin_i * p = (kmm_plugin_i *) lpParameter;
-
- PDESCTHREAD(p->p.name, L"KMM");
-
- _begin_task(0);
- _report_mr1(KHERR_NONE, MSG_PB_START, _cstr(p->p.name));
- _describe();
-
- TlsSetValue(tls_kmm, (LPVOID) p);
-
- kmm_hold_plugin(kmm_handle_from_plugin(p));
-
- p->tid_thread = GetCurrentThreadId();
-
- rv = (*p->p.msg_proc)(KMSG_SYSTEM, KMSG_SYSTEM_INIT,
- 0, (void *) &(p->p));
- _report_mr1(KHERR_INFO, MSG_PB_INIT_RV, _int32(rv));
-
- /* if it fails to initialize, we exit the plugin */
- if(KHM_FAILED(rv)) {
-
- kherr_report(KHERR_ERROR,
- (wchar_t *) MSG_PB_INIT_FAIL_S,
- (wchar_t *) KHERR_FACILITY,
- NULL,
- (wchar_t *) MSG_PB_INIT_FAIL,
- (wchar_t *) MSG_PB_INIT_FAIL_G,
- KHERR_FACILITY_ID,
- KHERR_SUGGEST_NONE,
- _cstr(p->p.name),
- _cstr(p->p.description),
- _cstr(p->module->path),
- _cstr(p->module->support),
- KHERR_RF_MSG_SHORT_DESC |
- KHERR_RF_MSG_LONG_DESC |
- KHERR_RF_MSG_SUGGEST
-#ifdef _WIN32
- ,KHERR_HMODULE
-#endif
- );
- _resolve();
-
- /* exit the plugin first. Otherwise it may not uninitialize correctly */
- (*p->p.msg_proc)(KMSG_SYSTEM, KMSG_SYSTEM_EXIT, 0, (void *) &(p->p));
-
- kmmint_remove_from_plugin_queue(p);
- rv = 1;
- _end_task();
-
- p->state = KMM_PLUGIN_STATE_FAIL_INIT;
- goto _exit;
- }
-
- /* subscribe to default message classes by plugin type */
- if(p->p.type == KHM_PITYPE_CRED) {
- kmq_subscribe(KMSG_SYSTEM, p->p.msg_proc);
- kmq_subscribe(KMSG_KCDB, p->p.msg_proc);
- kmq_subscribe(KMSG_CRED, p->p.msg_proc);
- } else if(p->p.type == KHM_PITYPE_IDENT) {
- khm_handle h = NULL;
-
- kmq_subscribe(KMSG_SYSTEM, p->p.msg_proc);
- kmq_subscribe(KMSG_KCDB, p->p.msg_proc);
-
- kmq_create_subscription(p->p.msg_proc, &h);
- kcdb_identity_set_provider(h);
- /* kcdb deletes the subscription when it's done with it */
- } else if(p->p.type == KHM_PITYPE_CONFIG) {
- /*TODO: subscribe to configuration provider messages here */
- }
-
- p->state = KMM_PLUGIN_STATE_RUNNING;
-
- _report_mr0(KHERR_INFO, MSG_PB_INIT_DONE);
-
- _end_task();
-
- /* if there were any plugins that were waiting for this one to
- start, we should start them too */
- EnterCriticalSection(&cs_kmm);
- do {
- kmm_plugin_i * pd;
- int i;
-
- for(i=0; i < p->n_dependants; i++) {
- pd = p->dependants[i];
-
- pd->n_unresolved--;
-
- if(pd->n_unresolved == 0) {
- kmmint_add_to_plugin_queue(pd);
- kmm_hold_plugin(kmm_handle_from_plugin(pd));
- kmq_post_message(KMSG_KMM, KMSG_KMM_I_REG, KMM_REG_INIT_PLUGIN, (void *) pd);
- }
- }
- } while(FALSE);
- LeaveCriticalSection(&cs_kmm);
-
- kmmint_remove_from_plugin_queue(p);
-
- /* main message loop */
- while(KHM_SUCCEEDED(kmq_dispatch(INFINITE)));
-
- /* unsubscribe from default message classes by plugin type */
- if(p->p.type == KHM_PITYPE_CRED) {
- kmq_unsubscribe(KMSG_SYSTEM, p->p.msg_proc);
- kmq_unsubscribe(KMSG_KCDB, p->p.msg_proc);
- kmq_unsubscribe(KMSG_CRED, p->p.msg_proc);
- } else if (p->p.type == KHM_PITYPE_IDENT) {
- kmq_unsubscribe(KMSG_KCDB, p->p.msg_proc);
- kmq_unsubscribe(KMSG_SYSTEM, p->p.msg_proc);
- kcdb_identity_set_provider(NULL);
- } else if(p->p.type == KHM_PITYPE_CONFIG) {
- /*TODO: unsubscribe from configuration provider messages here */
- }
-
- p->p.msg_proc(KMSG_SYSTEM, KMSG_SYSTEM_EXIT, 0, (void *) &(p->p));
-
- _exit:
- if (p->state >= 0)
- p->state = KMM_PLUGIN_STATE_EXITED;
-
- /* the following call will automatically release the plugin */
- kmq_post_message(KMSG_KMM, KMSG_KMM_I_REG,
- KMM_REG_EXIT_PLUGIN, (void *) p);
-
- TlsSetValue(tls_kmm, (LPVOID) 0);
-
- ExitThread(rv);
-}
-
-/*! \internal
- \brief Initialize a plugin
-
- \note If kmmint_init_plugin() is called on a plugin, then kmmint_exit_plugin()
- \b must be called for the plugin.
-
- \note Should only be called from the context of the registrar thread */
-void kmmint_init_plugin(kmm_plugin_i * p) {
- DWORD dummy;
- khm_handle csp_plugin = NULL;
- khm_handle csp_plugins = NULL;
- khm_int32 t;
-
- /* the following will be undone in kmmint_exit_plugin() */
- kmm_hold_plugin(kmm_handle_from_plugin(p));
-
- EnterCriticalSection(&cs_kmm);
- if(p->state != KMM_PLUGIN_STATE_REG &&
- p->state != KMM_PLUGIN_STATE_HOLD)
- {
- LeaveCriticalSection(&cs_kmm);
- goto _exit;
- }
-
- _begin_task(0);
- _report_mr1(KHERR_NONE, MSG_IP_TASK_DESC, _cstr(p->p.name));
- _describe();
-
- if(p->state == KMM_PLUGIN_STATE_HOLD) {
- /* if this plugin was held, then we already had a hold
- from the initial attempt to start the plugin. Undo
- the hold we did a few lines earlier. */
- kmm_release_plugin(kmm_handle_from_plugin(p));
-
- /* same for the plugin count for the module. */
-#ifdef DEBUG
- assert(p->flags & KMM_PLUGIN_FLAG_IN_MODCOUNT);
-#endif
- p->module->plugin_count--;
- p->flags &= ~KMM_PLUGIN_FLAG_IN_MODCOUNT;
- }
-
- p->state = KMM_PLUGIN_STATE_PREINIT;
-
- kmmint_delist_plugin(p);
- kmmint_list_plugin(p);
-
- LeaveCriticalSection(&cs_kmm);
-
- if(KHM_FAILED(kmm_get_plugins_config(0, &csp_plugins))) {
- _report_mr0(KHERR_ERROR, MSG_IP_GET_CONFIG);
-
- p->state = KMM_PLUGIN_STATE_FAIL_UNKNOWN;
- goto _exit;
- }
-
- if(KHM_FAILED(kmm_get_plugin_config(p->p.name, 0, &csp_plugin))) {
- if(KHM_FAILED(kmm_register_plugin(&(p->p), 0))) {
- _report_mr0(KHERR_ERROR, MSG_IP_NOT_REGISTERED);
-
- p->state = KMM_PLUGIN_STATE_FAIL_NOT_REGISTERED;
- goto _exit;
- }
-
- if(KHM_FAILED(kmm_get_plugin_config(p->p.name, 0, &csp_plugin))) {
- _report_mr0(KHERR_ERROR, MSG_IP_NOT_REGISTERED);
-
- p->state = KMM_PLUGIN_STATE_FAIL_NOT_REGISTERED;
- goto _exit;
- }
- }
-
- if (KHM_SUCCEEDED(khc_read_int32(csp_plugin, L"Disabled", &t)) && t) {
- p->flags |= KMM_PLUGIN_FLAG_DISABLED;
- p->state = KMM_PLUGIN_STATE_FAIL_DISABLED;
- goto _exit;
- }
-
-#if 0
- /*TODO: check the failure count and act accordingly */
- if(KHM_SUCCEEDED(khc_read_int32(csp_plugin, L"FailureCount", &t)) && (t > 0)) {
- }
-#endif
-
- EnterCriticalSection(&cs_kmm);
-
- p->n_depends = 0;
- p->n_unresolved = 0;
-
- do {
- wchar_t * deps = NULL;
- wchar_t * d;
- khm_size sz = 0;
-
- if(khc_read_multi_string(csp_plugin, L"Dependencies",
- NULL, &sz) != KHM_ERROR_TOO_LONG)
- break;
-
- deps = PMALLOC(sz);
- if(KHM_FAILED(khc_read_multi_string(csp_plugin, L"Dependencies",
- deps, &sz))) {
- if(deps)
- PFREE(deps);
- break;
- }
-
- for(d = deps; d && *d; d = multi_string_next(d)) {
- kmm_plugin_i * pd;
- int i;
-
- pd = kmmint_get_plugin_i(d);
-
- if(pd->state == KMM_PLUGIN_STATE_NONE) {
- /* the dependant was not previously known */
- pd->state = KMM_PLUGIN_STATE_PLACEHOLDER;
- }
-
- for(i=0; i < pd->n_dependants; i++) {
- if(pd->dependants[i] == p)
- break;
- }
-
- if(i >= pd->n_dependants) {
- if( pd->n_dependants >= KMM_MAX_DEPENDANTS ) {
- /*TODO: handle this gracefully */
- RaiseException(1, EXCEPTION_NONCONTINUABLE, 0, NULL);
- }
-
- /* released in kmmint_free_plugin() */
- kmm_hold_plugin(kmm_handle_from_plugin(p));
- pd->dependants[pd->n_dependants] = p;
- pd->n_dependants++;
- }
-
- p->n_depends++;
-
- if(pd->state != KMM_PLUGIN_STATE_RUNNING) {
- p->n_unresolved++;
- }
- }
-
- if(p->n_unresolved > 0) {
- p->state = KMM_PLUGIN_STATE_HOLD;
- }
-
- PFREE(deps);
-
- } while(FALSE);
-
-#ifdef DEBUG
- assert(!(p->flags & KMM_PLUGIN_FLAG_IN_MODCOUNT));
-#endif
- p->flags |= KMM_PLUGIN_FLAG_IN_MODCOUNT;
- p->module->plugin_count++;
-
- LeaveCriticalSection(&cs_kmm);
-
- if(p->state == KMM_PLUGIN_STATE_HOLD) {
- _report_mr1(KHERR_INFO, MSG_IP_HOLD, _dupstr(p->p.name));
-
- goto _exit_post;
- }
-
- kmmint_add_to_plugin_queue(p);
-
- p->ht_thread = CreateThread(NULL,
- 0,
- kmmint_plugin_broker,
- (LPVOID) p,
- CREATE_SUSPENDED,
- &dummy);
-
- p->state = KMM_PLUGIN_STATE_INIT;
-
- ResumeThread(p->ht_thread);
-
-_exit_post:
- if(csp_plugin != NULL)
- khc_close_space(csp_plugin);
-
- if(csp_plugins != NULL)
- khc_close_space(csp_plugins);
-
- _report_mr2(KHERR_INFO, MSG_IP_STATE,
- _dupstr(p->p.name), _int32(p->state));
-
- _end_task();
-
- return;
-
- /* jump here if an error condition happens before the plugin
- broker thread starts and the plugin should be unloaded */
-
-_exit:
- if(csp_plugin != NULL)
- khc_close_space(csp_plugin);
- if(csp_plugins != NULL)
- khc_close_space(csp_plugins);
-
- _report_mr2(KHERR_WARNING, MSG_IP_EXITING,
- _dupstr(p->p.name), _int32(p->state));
- _end_task();
-
-
-#ifdef ASYNC_PLUGIN_UNLOAD_ON_FAILURE
-
- kmm_hold_plugin(kmm_handle_from_plugin(p));
-
- kmq_post_message(KMSG_KMM, KMSG_KMM_I_REG, KMM_REG_EXIT_PLUGIN, (void *) p);
-
-#else
-
- kmmint_exit_plugin(p);
-
-#endif
-}
-
-/*! \internal
- \brief Uninitialize a plugin
-
- In addition to terminating the thread, and removing p from the
- linked list and hashtable, it also frees up p.
-
- \note Should only be called from the context of the registrar thread. */
-void kmmint_exit_plugin(kmm_plugin_i * p) {
- int np;
- khm_boolean release_plugin = TRUE;
-
- if(p->state == KMM_PLUGIN_STATE_RUNNING ||
- p->state == KMM_PLUGIN_STATE_INIT) {
-
- kmq_post_thread_quit_message(p->tid_thread, 0, NULL);
- /* when we post the quit message to the plugin thread, the plugin
- broker terminates the plugin and posts a EXIT_PLUGIN message,
- which calls this function again. We just exit here because
- the EXIT_PLUGIN message will end up calling us again momentarily */
- return;
-
- }
-
- if(p->ht_thread) {
- /* wait for the thread to terminate */
- WaitForSingleObject(p->ht_thread, INFINITE);
- p->ht_thread = NULL;
- }
-
- EnterCriticalSection(&cs_kmm);
-
- /* undo reference count done in kmmint_init_plugin() */
- if(p->flags & KMM_PLUGIN_FLAG_IN_MODCOUNT) {
-
- np = --(p->module->plugin_count);
- p->flags &= ~KMM_PLUGIN_FLAG_IN_MODCOUNT;
-
- } else {
- /* the plugin was not included in the module's plugin_count.
- We can't base a decision to unload the module based on this
- plugin exiting. */
- np = TRUE;
- }
-
- /* The plugin is in an error state. We need to keep the plugin
- record intact so that the failure information is kept around.
- Also, we shouldn't release the plugin if it appears that
- kmmint_init_plugin() was never called for it. */
- if (p->state < KMM_PLUGIN_STATE_HOLD) {
- release_plugin = FALSE;
- }
-
- LeaveCriticalSection(&cs_kmm);
-
- if(!np) {
- /* if this is the last plugin to exit, then notify the
- registrar that the module should be removed as well */
- kmm_hold_module(kmm_handle_from_module(p->module));
- kmq_post_message(KMSG_KMM, KMSG_KMM_I_REG, KMM_REG_EXIT_MODULE, (void *) p->module);
- }
-
- /* release the hold obtained in kmmint_init_plugin() */
- if (release_plugin)
- kmm_release_plugin(kmm_handle_from_plugin(p));
-}
-
-/*! \internal
- \brief Initialize a module
-
- \a m is not in the linked list yet.
-
- \note Should only be called from the context of the registrar thread. */
-void kmmint_init_module(kmm_module_i * m) {
- HMODULE hm;
- init_module_t p_init_module;
- kmm_plugin_i * pi;
- khm_int32 rv;
- khm_handle csp_mod = NULL;
- khm_handle csp_mods = NULL;
- khm_size sz;
- khm_int32 i;
-
- /* error condition handling */
- BOOL exit_module = FALSE;
- BOOL release_module = TRUE;
- BOOL record_failure = FALSE;
-
- /* failure handling */
- khm_int32 max_fail_count = 0;
- khm_int64 fail_reset_time = 0;
-
- _begin_task(0);
- _report_mr1(KHERR_NONE, MSG_INIT_MODULE, _cstr(m->name));
- _describe();
-
- kmm_hold_module(kmm_handle_from_module(m));
-
- /* If the module is not in the pre-init state, we can't
- initialize it. */
- if(m->state != KMM_MODULE_STATE_PREINIT) {
- _report_mr1(KHERR_INFO, MSG_IM_NOT_PREINIT, _int32(m->state));
- goto _exit;
- }
-
- if(KHM_FAILED(kmm_get_modules_config(0, &csp_mods))) {
- _report_mr0(KHERR_ERROR, MSG_IM_GET_CONFIG);
- _location(L"kmm_get_modules_config()");
-
- m->state = KMM_MODULE_STATE_FAIL_UNKNOWN;
- goto _exit;
- }
-
- khc_read_int32(csp_mods, L"ModuleMaxFailureCount", &max_fail_count);
- khc_read_int64(csp_mods, L"ModuleFailureCountResetTime", &fail_reset_time);
-
- if(KHM_FAILED(kmm_get_module_config(m->name, 0, &csp_mod))) {
- _report_mr0(KHERR_ERROR, MSG_IM_NOT_REGISTERED);
-
- m->state = KMM_MODULE_STATE_FAIL_NOT_REGISTERED;
- goto _exit;
- }
-
- if(KHM_SUCCEEDED(khc_read_int32(csp_mod, L"Disabled", &i)) && i) {
- _report_mr0(KHERR_INFO, MSG_IM_DISABLED);
-
- m->state = KMM_MODULE_STATE_FAIL_DISABLED;
- goto _exit;
- }
-
- if(KHM_SUCCEEDED(khc_read_int32(csp_mod, L"NoUnload", &i)) && i) {
- m->flags |= KMM_MODULE_FLAG_NOUNLOAD;
- }
-
- if(KHM_SUCCEEDED(khc_read_int32(csp_mod, L"FailureCount", &i))) {
- khm_int64 tm;
- khm_int64 ct;
- FILETIME fct;
- khm_int32 last_reason = 0;
-
- /* reset the failure count if the failure count reset time
- period has elapsed */
- tm = 0;
- khc_read_int64(csp_mod, L"FailureTime", &tm);
- GetSystemTimeAsFileTime(&fct);
-
- ct = (FtToInt(&fct) - tm) / 10000000i64;
-
- if(tm > 0 &&
- ct > fail_reset_time) {
- i = 0;
- khc_write_int32(csp_mod, L"FailureCount", 0);
- khc_write_int64(csp_mod, L"FailureTime", 0);
- }
-
- khc_read_int32(csp_mod, L"FailureReason", &last_reason);
-
- /* did we exceed the max failure count? However, we ignore
- the max failure count if the reason why it didn't load the
- last time was because the module wasn't found. */
- if(i > max_fail_count &&
- last_reason != KMM_MODULE_STATE_FAIL_NOT_FOUND) {
- /* failed too many times */
- _report_mr0(KHERR_INFO, MSG_IM_MAX_FAIL);
-
- m->state = KMM_MODULE_STATE_FAIL_MAX_FAILURE;
- goto _exit;
- }
- }
-
- if(khc_read_string(csp_mod, KMM_VALNAME_IMAGEPATH, NULL, &sz) ==
- KHM_ERROR_TOO_LONG) {
- if(m->path)
- PFREE(m->path);
- m->path = PMALLOC(sz);
- khc_read_string(csp_mod, KMM_VALNAME_IMAGEPATH, m->path, &sz);
- } else {
- /*
- * If there is no image path, then the module has not been
- * installed. Do not report an error and bother the user.
- * _report_mr0(KHERR_ERROR, MSG_IM_NOT_REGISTERED);
- */
-
- m->state = KMM_MODULE_STATE_FAIL_NOT_REGISTERED;
- goto _exit;
- }
-
- rv = kmmint_read_module_info(m);
-
- if (KHM_FAILED(rv)) {
- if (rv == KHM_ERROR_INCOMPATIBLE) {
- _report_mr0(KHERR_ERROR, MSG_IM_INCOMPATIBLE);
-
- m->state = KMM_MODULE_STATE_FAIL_INCOMPAT;
- } else if (rv == KHM_ERROR_NOT_FOUND) {
- _report_mr1(KHERR_ERROR, MSG_IM_NOT_FOUND, _dupstr(m->path));
-
- m->state = KMM_MODULE_STATE_FAIL_NOT_FOUND;
- } else {
- _report_mr0(KHERR_ERROR, MSG_IM_INVALID_MODULE);
-
- m->state = KMM_MODULE_STATE_FAIL_INV_MODULE;
- }
- goto _exit;
- }
-
- /* check again */
- if(m->state != KMM_MODULE_STATE_PREINIT) {
- _report_mr0(KHERR_ERROR, MSG_IM_NOT_PREINIT);
-
- goto _exit;
- }
-
- /* from this point on, we must record any failure codes */
- record_failure = TRUE;
-
- hm = LoadLibrary(m->path);
- if(!hm) {
- m->h_module = NULL;
- m->state = KMM_MODULE_STATE_FAIL_NOT_FOUND;
-
- _report_mr1(KHERR_ERROR, MSG_IM_NOT_FOUND, _dupstr(m->path));
-
- goto _exit;
- }
-
- /* from this point on, we need to discard the module through
- exit_module */
- ResetEvent(evt_exit);
-
- kmm_active_modules++;
-
- release_module = FALSE;
- exit_module = TRUE;
-
- m->flags |= KMM_MODULE_FLAG_LOADED;
- m->h_module = hm;
-
- /* TODO: check signatures */
-
- p_init_module = (init_module_t) GetProcAddress(hm, EXP_INIT_MODULE);
-
- if(!p_init_module) {
- _report_mr1(KHERR_ERROR, MSG_IM_NO_ENTRY, _cstr(EXP_INIT_MODULE));
-
- m->state = KMM_MODULE_STATE_FAIL_INVALID;
- goto _exit;
- }
-
- m->state = KMM_MODULE_STATE_INIT;
-
- /* call init_module() */
- rv = (*p_init_module)(kmm_handle_from_module(m));
-
- m->flags |= KMM_MODULE_FLAG_INITP;
-
- if(KHM_FAILED(rv)) {
- _report_mr1(KHERR_ERROR, MSG_IM_INIT_FAIL, _int32(rv));
-
- m->state = KMM_MODULE_STATE_FAIL_LOAD;
- goto _exit;
- }
-
- if(!m->plugins) {
- _report_mr0(KHERR_ERROR, MSG_IM_NO_PLUGINS);
-
- m->state = KMM_MODULE_STATE_FAIL_NO_PLUGINS;
- record_failure = FALSE;
- goto _exit;
- }
-
- m->state = KMM_MODULE_STATE_INITPLUG;
-
- do {
- LPOP(&(m->plugins), &pi);
- if(pi) {
- pi->flags &= ~KMM_PLUGIN_FLAG_IN_MODLIST;
- kmmint_init_plugin(pi);
-
- /* release the hold obtained in kmm_provide_plugin() */
- kmm_release_plugin(kmm_handle_from_plugin(pi));
- }
- } while(pi);
-
- if(!m->plugin_count) {
- /* We don't want to report this case. This usually means that
- the plugins that were provided by the module were
- disabled. */
-#ifdef REPORT_EMPTY_MODULES
- _report_mr0(KHERR_ERROR, MSG_IM_NO_PLUGINS);
-
- m->state = KMM_MODULE_STATE_FAIL_NO_PLUGINS;
-#endif
- record_failure = FALSE;
- goto _exit;
- }
-
- m->state = KMM_MODULE_STATE_RUNNING;
-
- exit_module = FALSE;
- record_failure = FALSE;
-
- _exit:
- if(csp_mod) {
- if(record_failure) {
- FILETIME fct;
-
- i = 0;
- khc_read_int32(csp_mod, L"FailureCount", &i);
- i++;
- khc_write_int32(csp_mod, L"FailureCount", i);
-
- if(i==1) { /* first fault */
- GetSystemTimeAsFileTime(&fct);
- khc_write_int64(csp_mod, L"FailureTime", FtToInt(&fct));
- }
-
- khc_write_int32(csp_mod, L"FailureReason", m->state);
- }
- khc_close_space(csp_mod);
- }
-
- if(csp_mods)
- khc_close_space(csp_mods);
-
- _report_mr2(KHERR_INFO, MSG_IM_MOD_STATE,
- _dupstr(m->name), _int32(m->state));
-
- kmmint_remove_from_module_queue();
-
- /* if something went wrong after init_module was called on the
- module code, we need to call exit_module */
- if(exit_module)
- kmmint_exit_module(m);
-
- if(release_module)
- kmm_release_module(kmm_handle_from_module(m));
-
- if (kherr_is_error()) {
- kherr_context * c;
- kherr_event * err_e = NULL;
- kherr_event * warn_e = NULL;
- kherr_event * e;
-
- c = kherr_peek_context();
- err_e = kherr_get_err_event(c);
- for(e = kherr_get_first_event(c);
- e;
- e = kherr_get_next_event(e)) {
- if (e != err_e &&
- e->severity == KHERR_WARNING) {
- warn_e = e;
- break;
- }
- }
-
- kherr_evaluate_event(err_e);
- if (warn_e)
- kherr_evaluate_event(warn_e);
-
- kherr_clear_error();
-
- e = kherr_report(KHERR_ERROR,
- (wchar_t *) MSG_IMERR_TITLE,
- KHERR_FACILITY,
- NULL,
- err_e->long_desc,
- ((warn_e)? (wchar_t *)MSG_IMERR_SUGGEST: NULL),
- KHERR_FACILITY_ID,
- KHERR_SUGGEST_NONE,
- _cstr(m->name),
- ((warn_e)? _cstr(warn_e->long_desc):_vnull()),
- _vnull(),_vnull(),
- KHERR_RF_MSG_SHORT_DESC |
- ((warn_e)? KHERR_RF_MSG_SUGGEST: 0),
- KHERR_HMODULE);
-
- kherr_evaluate_event(e);
-
- kherr_release_context(c);
- }
-
- _end_task();
-}
-
-
-/*! \internal
- \brief Uninitializes a module
-
- \note Should only be called from the context of the registrar
- thread */
-void kmmint_exit_module(kmm_module_i * m) {
- kmm_plugin_i * p;
-
- /* Exiting a module happens in two stages.
-
- If the module state is running (there are active plugins) then
- those plugins must be exited. This has to be done from the
- plugin threads. The signal for the plugins to exit must be
- issued from the registrar. Therefore, we post messages to the
- registrar for each plugin we want to remove and exit
- kmmint_exit_module().
-
- When the last plugin is exited, the plugin management code
- automatically signalls the registrar to remove the module.
- kmmint_exit_module() gets called again. This is the second
- stage, where we call exit_module() for the module and start
- unloading everything.
- */
-
- EnterCriticalSection(&cs_kmm);
-
- /* get rid of any dangling uninitialized plugins */
- LPOP(&(m->plugins), &p);
- while(p) {
- p->flags &= ~KMM_PLUGIN_FLAG_IN_MODLIST;
- kmmint_exit_plugin(p);
-
- /* release hold from kmm_provide_plugin() */
- kmm_release_plugin(kmm_handle_from_plugin(p));
-
- LPOP(&(m->plugins), &p);
- }
-
- if(m->state == KMM_MODULE_STATE_RUNNING) {
- int np = 0;
-
- m->state = KMM_MODULE_STATE_EXITPLUG;
-
- p = kmm_listed_plugins;
-
- while(p) {
- if(p->module == m &&
- (p->flags & KMM_PLUGIN_FLAG_IN_MODCOUNT)) {
-
- kmm_hold_plugin(kmm_handle_from_plugin(p));
- kmq_post_message(KMSG_KMM, KMSG_KMM_I_REG,
- KMM_REG_EXIT_PLUGIN, (void *) p);
- np++;
-
- }
-
- p = LNEXT(p);
- }
-
-#ifdef DEBUG
- assert(np == m->plugin_count);
-#endif
-
- if(np > 0) {
- /* we have to go back and wait for the plugins to exit.
- when the last plugin exits, it automatically posts
- EXIT_MODULE. We can pick up from there when this
- happens. */
- LeaveCriticalSection(&cs_kmm);
- return;
- }
-
- } else {
-
-#ifdef DEBUG
- assert(m->plugin_count == 0 ||
- m->state == KMM_MODULE_STATE_EXITPLUG);
-#endif
-
- /* if there are still plug-ins waiting to be unloaded, then we
- have to go back and wait for them to finish. Once they are
- done, kmmint_exit_module() will get called again. */
- if (m->plugin_count > 0) {
- LeaveCriticalSection(&cs_kmm);
- return;
- }
- }
-
- if(m->flags & KMM_MODULE_FLAG_INITP) {
- exit_module_t p_exit_module;
-
- if(m->state > 0)
- m->state = KMM_MODULE_STATE_EXIT;
-
- p_exit_module =
- (exit_module_t) GetProcAddress(m->h_module,
- EXP_EXIT_MODULE);
- if(p_exit_module) {
- LeaveCriticalSection(&cs_kmm);
- (*p_exit_module)(kmm_handle_from_module(m));
- EnterCriticalSection(&cs_kmm);
- }
- }
-
- if(m->state > 0)
- m->state = KMM_MODULE_STATE_EXITED;
-
- LeaveCriticalSection(&cs_kmm);
-
- if(!(m->flags & KMM_MODULE_FLAG_NOUNLOAD) &&
- m->h_module) {
- FreeLibrary(m->h_module);
- }
-
- if(!(m->flags & KMM_MODULE_FLAG_NOUNLOAD) &&
- m->h_resource && (m->h_resource != m->h_module)) {
- FreeLibrary(m->h_resource);
- }
-
- m->h_module = NULL;
- m->h_resource = NULL;
-
- if (m->flags & KMM_MODULE_FLAG_LOADED) {
-#ifdef DEBUG
- assert(kmm_active_modules > 0);
-#endif
- kmm_active_modules--;
- }
-
- m->flags = 0;
-
- /* release the hold obtained in kmmint_init_module() */
- kmm_release_module(kmm_handle_from_module(m));
-
- /* Last but not least, now see if there are any modules left that
- are running. If not, we can safely signal an exit. */
- if (kmm_active_modules == 0) {
- SetEvent(evt_exit);
- }
-}
diff --git a/src/windows/identity/kmm/kmmconfig.csv b/src/windows/identity/kmm/kmmconfig.csv
deleted file mode 100644
index 32c334b26..000000000
--- a/src/windows/identity/kmm/kmmconfig.csv
+++ /dev/null
@@ -1,47 +0,0 @@
-Name,Type,Value,Description
-PluginManager,KC_SPACE,0,Plugin Manager Configuration
- Plugins,KC_SPACE,0,Plugin Specific configuration
- PluginMaxFailureCount,KC_INT32,3,Maximum number of failure counts before plugin is disabled
- PluginFailureCountResetTime,KC_INT64,36000,Time after first failure at which the failure count is reset
- _Schema,KC_SPACE,0,Plugin schema
- Module,KC_STRING,<module name>,The name of the module that registered this plugin
- Description,KC_STRING,<Description>,Description of the plugin
- Dependencies,KC_STRING,<Dependencies>,Multi string of plugin names of plugins that this plugin depends on
- Type,KC_INT32,0,The type of the plugin
-# Flags,KC_INT32,0,Flags (Deprecated)
- Disabled,KC_INT32,0,Plug-in is disabled (Boolean)
- NoUnload,KC_INT32,0,Do not unload the plugin (Boolean)
- FailureCount,KC_INT32,0,Number of failed loads
- FailureTime,KC_INT64,0,FILETIME of first failure
- FailureReason,KC_INT32,0,Reason for first failure. One of the plugin status values.
- Parameters,KC_SPACE,0,Plugin parameters. The schema beyond this is plugin dependent.
- Parameters,KC_ENDSPACE,0,
- _Schema,KC_ENDSPACE,0,
- Plugins,KC_ENDSPACE,0,
- Modules,KC_SPACE,0,Module Specific configuration
- ModuleMaxFailureCount,KC_INT32,3,Maximum number of failure counts before module is disabled
- ModuleFailureCountResetTime,KC_INT64,72000,Time after first failure at which the failure count is reset
- _Schema,KC_SPACE,0,Module schema
- ImagePath,KC_STRING,<Path to the library binary>,Path to the DLL (including DLL name)
-# Flags,KC_INT32,0,Flags (Deprecated)
- Disabled,KC_INT32,0,Module is disabled (Boolean)
- FailureCount,KC_INT32,0,Number of failed loads
- FailureTime,KC_INT64,0,FILETIME of first failure
- FailureReason,KC_INT32,0,Reason for last failure. One of the module status values.
- PluginList,KC_STRING,<plugins>,List of plugins implemented in the module
- _Schema,KC_ENDSPACE,0,
-# The OpenAFS plug-in is installed separately.
-# OpenAFS,KC_SPACE,0,OpenAFS Module
-# ImagePath,KC_STRING,afscred.dll,
-# PluginList,KC_STRING,AfsCred,
-# OpenAFS,KC_ENDSPACE,0,
-# MITKrb5,KC_SPACE,0,MIT Kerberos V
-# ImagePath,KC_STRING,krb5cred.dll,
-# PluginList,KC_STRING,Krb5Cred,
-# MITKrb5,KC_ENDSPACE,0,
-# MITKrb4,KC_SPACE,0,MIT Kerberos IV
-# ImagePath,KC_STRING,krb4cred.dll,
-# PluginList,KC_STRING,Krb4Cred,
-# MITKrb4,KC_ENDSPACE,0,
- Modules,KC_ENDSPACE,0,
-PluginManager,KC_ENDSPACE,0,
diff --git a/src/windows/identity/kmm/kmminternal.h b/src/windows/identity/kmm/kmminternal.h
deleted file mode 100644
index c4109495e..000000000
--- a/src/windows/identity/kmm/kmminternal.h
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/* $Id$ */
-
-#ifndef __KHIMAIRA_KMMINTERNAL_H
-#define __KHIMAIRA_KMMINTERNAL_H
-
-#define _NIMLIB_
-
-#include<windows.h>
-#include<shlwapi.h>
-#include<strsafe.h>
-
-#define KHERR_FACILITY kmm_facility
-#define KHERR_FACILITY_ID KHM_FACILITY_KMM
-#define KHERR_HMODULE ((HMODULE) kmm_hInstance)
-#include<kherr.h>
-
-#include<kmm.h>
-#include<khmsgtypes.h>
-#include<kherror.h>
-#include<kplugin.h>
-
-#define NOEXPORT
-
-#include<utils.h>
-#include<kconfig.h>
-#include<kcreddb.h>
-#include<kmm_msgs.h>
-
-struct kmm_plugin_i_t; /* forward dcl */
-
-typedef struct kmm_module_i_t {
- khm_int32 magic;
-
- wchar_t * name;
- wchar_t * path;
- wchar_t * description;
- wchar_t * vendor;
- wchar_t * support;
-
- khm_version file_version;
- khm_version prod_version;
-
- HMODULE h_module;
-
- HMODULE h_resource;
- WORD lcid_resource;
-
- khm_int32 flags;
- khm_int32 state;
- khm_int32 plugin_count; /* number of active plugins */
-
- void * version_info;
-
- khm_int32 refcount;
-
- struct kmm_plugin_i_t * plugins; /* only used for registration */
-
- LDCL(struct kmm_module_i_t);
-} kmm_module_i;
-
-#define KMM_MODULE_MAGIC 0x482f4e88
-
-#define kmm_is_module(m) ((m) && ((kmm_module_i *)m)->magic == KMM_MODULE_MAGIC)
-
-#define kmm_module_from_handle(m) ((kmm_module_i *) m)
-#define kmm_handle_from_module(m) ((kmm_module) m)
-
-/* LoadLibrary succeeded for module */
-#define KMM_MODULE_FLAG_LOADED 0x00000001
-
-/* init_module entry called */
-#define KMM_MODULE_FLAG_INITP 0x00000002
-
-/* the resources have been loaded */
-#define KMM_MODULE_FLAG_RES_LOADED 0x00000008
-
-/* the signature has been verified */
-#define KMM_MODULE_FLAG_SIG 0x00000010
-
-/* the module is disabled by the user
- (option specified in configuration) */
-#define KMM_MODULE_FLAG_DISABLED 0x00000400
-
-/* the module should not be unloaded
- (option specified in configuration)*/
-#define KMM_MODULE_FLAG_NOUNLOAD 0x00000800
-
-/* the module has been removed from the active modules list. */
-#define KMM_MODULE_FLAG_INACTIVE 0x00001000
-
-typedef struct kmm_plugin_i_t {
- kmm_plugin_reg p;
-
- khm_int32 magic;
-
- kmm_module_i * module;
- HANDLE ht_thread;
- DWORD tid_thread;
-
- khm_int32 state;
- khm_int32 flags;
-
- int refcount;
-
- int n_depends;
- int n_unresolved;
- struct kmm_plugin_i_t * dependants[KMM_MAX_DEPENDANTS];
- int n_dependants;
-
- LDCL(struct kmm_plugin_i_t);
-} kmm_plugin_i;
-
-#define KMM_PLUGIN_MAGIC 0x320e8fb4
-
-#define kmm_is_plugin(p) ((p) && ((kmm_plugin_i *) (p))->magic == KMM_PLUGIN_MAGIC)
-
-#define kmm_handle_from_plugin(p) ((kmm_plugin) p)
-#define kmm_plugin_from_handle(ph) ((kmm_plugin_i *) ph)
-
-/* the plugin has already been marked for unload */
-#define KMM_PLUGIN_FLAG_UNLOAD 0x00000001
-
-/* the plugin is in the kmm_listed_plugins list */
-#define KMM_PLUGIN_FLAG_IN_LIST 0x00000002
-
-/* the plugin is in the module's plugin list */
-#define KMM_PLUGIN_FLAG_IN_MODLIST 0x00000004
-
-/* the plugin has been included in the pending_plugins count. */
-#define KMM_PLUGIN_FLAG_IN_QUEUE 0x00000010
-
-/* the plugin is included in the module's plugin count */
-#define KMM_PLUGIN_FLAG_IN_MODCOUNT 0x00000020
-
-/* the plugin is disabled by the user
- (option specified in configuration) */
-/* (this is defined in kmm.h)
-
- #define KMM_PLUGIN_FLAG_DISABLED 0x00000400
-
-*/
-
-enum kmm_registrar_uparam_t {
- KMM_REG_INIT_MODULE,
- KMM_REG_EXIT_MODULE,
- KMM_REG_INIT_PLUGIN,
- KMM_REG_EXIT_PLUGIN
-};
-
-extern kmm_module_i * kmm_all_modules;
-extern khm_size kmm_active_modules;
-extern kmm_plugin_i * kmm_listed_plugins;
-extern HANDLE ht_registrar;
-extern DWORD tid_registrar;
-extern DWORD tls_kmm;
-
-extern hashtable * hash_plugins;
-extern hashtable * hash_modules;
-
-extern CRITICAL_SECTION cs_kmm;
-extern int ready;
-extern HANDLE evt_startup;
-extern HANDLE evt_exit;
-extern const wchar_t * kmm_facility;
-
-extern HINSTANCE kmm_hInstance;
-
-extern kconf_schema schema_kmmconfig[];
-
-/* Registrar */
-
-khm_boolean KHMAPI
-kmmint_reg_cb(khm_int32 msg_type,
- khm_int32 msg_sub_type,
- khm_ui_4 uparam,
- void *vparam);
-
-DWORD WINAPI kmmint_registrar(LPVOID lpParameter);
-
-DWORD WINAPI kmmint_plugin_broker(LPVOID lpParameter);
-
-void kmmint_init_plugin(kmm_plugin_i * p);
-void kmmint_exit_plugin(kmm_plugin_i * p);
-void kmmint_init_module(kmm_module_i * m);
-void kmmint_exit_module(kmm_module_i * m);
-
-/* Modules */
-kmm_module_i *
-kmmint_get_module_i(wchar_t * name);
-
-kmm_module_i *
-kmmint_find_module_i(wchar_t * name);
-
-void
-kmmint_free_module(kmm_module_i * m);
-
-khm_int32
-kmmint_read_module_info(kmm_module_i * m);
-
-/* Plugins */
-kmm_plugin_i *
-kmmint_get_plugin_i(wchar_t * name);
-
-kmm_plugin_i *
-kmmint_find_plugin_i(wchar_t * name);
-
-void
-kmmint_free_plugin(kmm_plugin_i * pi);
-
-void
-kmmint_list_plugin(kmm_plugin_i * p);
-
-void
-kmmint_delist_plugin(kmm_plugin_i * p);
-
-khm_boolean
-kmmint_load_locale_lib(kmm_module_i * m, kmm_module_locale * l);
-
-#define KMM_CSNAME_ROOT L"PluginManager"
-#define KMM_CSNAME_PLUGINS L"Plugins"
-#define KMM_CSNAME_MODULES L"Modules"
-#define KMM_VALNAME_LOADLIST L"LoadList"
-#define KMM_VALNAME_IMAGEPATH L"ImagePath"
-
-void
-kmmint_add_to_module_queue(void);
-
-void
-kmmint_remove_from_module_queue(void);
-
-#define _WAIT_FOR_START \
- do { \
- if(ready) break; \
- WaitForSingleObject(evt_startup, INFINITE); \
- } while(0)
-
-#endif
diff --git a/src/windows/identity/kmm/kmmmain.c b/src/windows/identity/kmm/kmmmain.c
deleted file mode 100644
index 598c10507..000000000
--- a/src/windows/identity/kmm/kmmmain.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- * Copyright (c) 2007 Secure Endpoints Inc.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/* $Id$ */
-
-#include<kmminternal.h>
-
-kmm_module_i * kmm_all_modules = NULL;
-kmm_plugin_i * kmm_listed_plugins = NULL;
-
-HANDLE ht_registrar = NULL;
-DWORD tid_registrar = 0;
-DWORD tls_kmm = 0;
-
-#define KMM_HASH_SIZE 31
-hashtable * hash_plugins = NULL;
-hashtable * hash_modules = NULL;
-
-CRITICAL_SECTION cs_kmm;
-HANDLE evt_startup = NULL;
-HANDLE evt_exit = NULL;
-int ready = 0;
-
-HINSTANCE kmm_hInstance;
-const wchar_t * kmm_facility = L"KMM";
-
-KHMEXP void KHMAPI kmm_init(void)
-{
- DWORD dummy;
-
- EnterCriticalSection(&cs_kmm);
- kmm_all_modules = NULL;
- kmm_listed_plugins = NULL;
-
- tls_kmm = TlsAlloc();
-
- hash_plugins = hash_new_hashtable(
- KMM_HASH_SIZE,
- hash_string,
- hash_string_comp,
- NULL,
- NULL);
-
- hash_modules = hash_new_hashtable(
- KMM_HASH_SIZE,
- hash_string,
- hash_string_comp,
- NULL,
- NULL);
-
- ht_registrar = CreateThread(
- NULL,
- 0,
- kmmint_registrar,
- NULL,
- 0,
- &dummy);
-
- _WAIT_FOR_START;
-
- khc_load_schema(NULL, schema_kmmconfig);
-
- LeaveCriticalSection(&cs_kmm);
-}
-
-KHMEXP void KHMAPI kmm_exit(void)
-{
- kmm_module_i * m;
- kmm_plugin_i * p;
-
- EnterCriticalSection(&cs_kmm);
-
- p = kmm_listed_plugins;
- while(p) {
- kmm_plugin_i * pn;
-
- pn = LNEXT(p);
- /* plugins that were never resolved should be kicked off the
- list. Flipping the refcount will do that if no other
- references exist for the plugin. The plugins that were
- waiting for unresolved dependencies will automatically get
- freed when the placeholders and other plugins get freed. */
- if(p->state == KMM_PLUGIN_STATE_PLACEHOLDER) {
- kmm_hold_plugin(kmm_handle_from_plugin(p));
- kmm_release_plugin(kmm_handle_from_plugin(p));
- }
-
- p = pn;
- }
-
- m = kmm_all_modules;
- while(m) {
- kmm_unload_module(kmm_handle_from_module(m));
- m = LNEXT(m);
- }
-
- LeaveCriticalSection(&cs_kmm);
- WaitForSingleObject(evt_exit, INFINITE);
-
- kmq_send_thread_quit_message(tid_registrar, 0);
-
- EnterCriticalSection(&cs_kmm);
-
- hash_del_hashtable(hash_plugins);
- hash_del_hashtable(hash_modules);
-
- LeaveCriticalSection(&cs_kmm);
-
- TlsFree(tls_kmm);
-
- tls_kmm = 0;
-}
-
-void kmm_dll_init(void)
-{
- InitializeCriticalSection(&cs_kmm);
- evt_startup = CreateEvent(NULL, TRUE, FALSE, NULL);
- evt_exit = CreateEvent(NULL, TRUE, TRUE, NULL);
-}
-
-void kmm_dll_exit(void)
-{
- DeleteCriticalSection(&cs_kmm);
- if(evt_startup)
- CloseHandle(evt_startup);
- evt_startup = NULL;
-}
-
-void
-kmm_process_attach(HINSTANCE hinstDLL) {
- kmm_hInstance = hinstDLL;
- kmm_dll_init();
-}
-
-void
-kmm_process_detach(void) {
- kmm_dll_exit();
-}
diff --git a/src/windows/identity/kmm/kplugin.h b/src/windows/identity/kmm/kplugin.h
deleted file mode 100644
index 00e3e06ed..000000000
--- a/src/windows/identity/kmm/kplugin.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/* $Id$ */
-
-#ifndef __KHIMAIRA_KPLUGIN_H
-#define __KHIMAIRA_KPLUGIN_H
-
-#include<kmm.h>
-#include<kherror.h>
-
-/*! \addtogroup kmm
-@{*/
-/*! \defgroup kplugin NetIDMgr Plugin Callbacks
-
-See the following related documentation pages for more information
-about NetIDMgr plugins.
-
-These are prototypes of functions that must be implemented by a NetIDMgr
-plugin.
-
-- \ref plugins
-@{*/
-
-/*! \brief Initialize the module
-
- This is the first callback function to be called in a module.
- Perform all the required intialization when this is called. As
- mentioned in \ref plugins, you should not attempt to call any
- NetIDMgr API function from DLLMain or other initialization code
- other than this one.
-
- You should use this call back to register the plugins that will be
- implemented in this module and to notify the plugin manager of any
- resource libraries that this module will use.
-
- Call:
- - kmm_set_locale() : to set the notify the plugin manager of the
- locale specifc resource libraries that are used by this module.
- - kmm_provide_plugin() : to register each plugin that is
- implemented in this module.
-
- This function is called in the context of the current user, from
- the plug-in manager thread. This same thread is used by the
- plug-in manager to load and initialize all the modules for a
- session.
-
- The name of the callback must be init_module(). The calling
- convention is KHMAPI, which is currently __stdcall.
-
- If this function does not register any plugins, the plugin manager
- will immediately call exit_module() and unload the module even if
- the init_module() function completes successfully.
-
- \return Return the following values to indicate whether the module
- successfully initialized or not.
- - KHM_ERROR_SUCCESS : Succeeded. The module manager will call
- init_plugin() for each of the registered plugins for the
- module.
- - any other error code: Signals that the module did not
- successfully initialize. The plugin manager will
- immediately call exit_module() and then unload the module.
-
- \note This callback is required.
-*/
-KHMEXP_EXP khm_int32 KHMAPI init_module(kmm_module h_module);
-
-/*! \brief Type for init_module() */
-typedef khm_int32 (KHMAPI *init_module_t)(kmm_module);
-
-#if defined(_WIN64)
-#define EXP_INIT_MODULE "init_module"
-#elif defined(_WIN32)
-#define EXP_INIT_MODULE "_init_module@4"
-#else
-#error EXP_INIT_MODULE not defined for platform
-#endif
-
-/*! \brief Plugin procedure
-
- This is the message processor for a plugin. See \ref pi_fw_pnm_p
- for more information.
-
- Essentially, this is a message subscriber for KMQ messages.
-*/
-KHMEXP_EXP khm_int32 KHMAPI _plugin_proc(khm_int32 msg_type, khm_int32 msg_subtype, khm_ui_4 uparam, void * vparam);
-
-/*! \brief Type for init_plugin() */
-typedef kmq_callback_t _plugin_proc_t;
-
-/*! \brief Exit a module
-
- This is the last callback function that the NetIDMgr module
- manager calls before unloading the module. When this function is
- called, all of the plugins for the module have already been
- stopped. However, any localization libraries that were loaded as
- a result of init_module() calling kmm_set_locale_info() will still
- be loaded. These localization libraries will be unloaded
- immediately after this callback returns.
-
- Use this callback to perform any required cleanup tasks. However,
- it is advisable that each plugin perform its own cleanup tasks,
- since each plugin may be stopped independently of others.
-
- \return The return value of this function is ignored.
-
- \note This callback is not required.
-*/
-KHMEXP_EXP khm_int32 KHMAPI exit_module(kmm_module h_module);
-
-/*! \brief Type for exit_module() */
-typedef khm_int32 (KHMAPI *exit_module_t)(kmm_module);
-
-#if defined(_WIN64)
-#define EXP_EXIT_MODULE "exit_module"
-#elif defined(_WIN32)
-#define EXP_EXIT_MODULE "_exit_module@4"
-#else
-#error EXP_EXIT_MODULE not defined for platform
-#endif
-
-/*@}*/
-/*@}*/
-
-#endif
diff --git a/src/windows/identity/kmm/lang/kmm_msgs.mc b/src/windows/identity/kmm/lang/kmm_msgs.mc
deleted file mode 100644
index 898ffa2fc..000000000
--- a/src/windows/identity/kmm/lang/kmm_msgs.mc
+++ /dev/null
@@ -1,259 +0,0 @@
-; // ** kmm_msgs.mc
-
-; /* Since .mc files can contain strings from any language, we define
-; all our messages in one file in the /lang/ directory instead of
-; language specific subdirectories. */
-
-; /* The type is set to (wchar_t *) because that's what we will be
-; feeding kherr_report() function. */
-
-MessageIdTypedef=LPWSTR
-
-; /* Severity values as defined in the message definition file are
-; currently ignored. */
-
-SeverityNames=(
- Success=0x0
-)
-
-LanguageNames=(
- English=0x409:MSG_ENU
-)
-
-OutputBase=16
-
-; /* Actual messages start here */
-
-MessageId=1
-Severity=Success
-SymbolicName=MSG_INITIAL
-Language=English
-Initial placeholder message
-.
-
-MessageId=
-SymbolicName=MSG_LOAD_DEFAULT
-Language=English
-Load default modules
-.
-
-MessageId=
-SymbolicName=MSG_INIT_MODULE
-Language=English
-Initializing module [%1]
-.
-
-MessageId=
-SymbolicName=MSG_IM_GET_CONFIG
-Language=English
-Can't get configuration for modules
-.
-
-MessageId=
-SymbolicName=MSG_IM_NOT_PREINIT
-Language=English
-Module is not in PREINIT state. Current state=[%1!d!]
-.
-
-MessageId=
-SymbolicName=MSG_IM_NOT_REGISTERED
-Language=English
-Module is not registered
-.
-
-MessageId=
-SymbolicName=MSG_IM_DISABLED
-Language=English
-Module is disabled
-.
-
-MessageId=
-SymbolicName=MSG_IM_MAX_FAIL
-Language=English
-Module has failed too many times
-.
-
-MessageId=
-SymbolicName=MSG_IM_INVALID_MODULE
-Language=English
-The DLL containing the module was not of the correct format.
-.
-
-MessageId=
-SymbolicName=MSG_IM_INCOMPATIBLE
-Language=English
-The DLL containing the module was not compatible with this version of NetIDMgr.
-.
-
-Messageid=
-SymbolicName=MSG_IM_NOT_FOUND
-Language=English
-Module binary was not found. Checked path [%1]
-.
-
-MessageId=
-SymbolicName=MSG_IM_NO_ENTRY
-Language=English
-Entry point not found. Checked entry point [%1]
-.
-
-MessageId=
-SymbolicName=MSG_IM_INIT_FAIL
-Language=English
-Module initialization entry point returned failure code [%1!d!]
-.
-
-MessageId=
-SymbolicName=MSG_IM_NO_PLUGINS
-Language=English
-No plug-ins were registered by the module
-.
-
-MessageId=
-SymbolicName=MSG_IM_MOD_STATE
-Language=English
-Module [%1] is in state [%2!d!]
-.
-
-MessageId=
-SymbolicName=MSG_IMERR_TITLE
-Language=English
-Failed to load module %1!s!
-.
-
-MessageId=
-SymbolicName=MSG_IMERR_SUGGEST
-Language=English
-The following information may help resolve this issue:
-
-%2!s!
-.
-
-MessageId=
-SymbolicName=MSG_IP_TASK_DESC
-Language=English
-Initializing plug-in [%1]
-.
-
-MessageId=
-SymbolicName=MSG_IP_GET_CONFIG
-Language=English
-Can't get configuration for plug-ins
-.
-
-MessageId=
-SymbolicName=MSG_IP_NOT_REGISTERED
-Language=English
-The plug-in is not registered
-.
-
-MessageId=
-SymbolicName=MSG_IP_DISABLED
-Language=English
-The plug-in is disabled
-.
-
-MessageId=
-SymbolicName=MSG_IP_HOLD
-Language=English
-Placing plug-in [%1] on hold
-.
-
-MessageId=
-SymbolicName=MSG_IP_STATE
-Language=English
-Leaving plug-in [%1] in state [%2!d!]
-.
-
-MessageId=
-SymbolicName=MSG_IP_EXITING
-Language=English
-The plug-in [%1] is in error state [%2!d!]. Exiting plug-in.
-.
-
-MessageId=
-SymbolicName=MSG_RMI_NOT_FOUND
-Language=English
-Can't get file version information for path [%1!s!]
-.
-
-MessageId=
-SymbolicName=MSG_RMI_NO_TRANS
-Language=English
-Can't get version resource tranlations list for path [%1!s!]
-.
-
-MessageId=
-SymbolicName=MSG_RMI_NO_LOCAL
-Language=English
-The list of version translations were empty or did not contain a resource for the current user or system locale.
-.
-
-MessageId=
-SymbolicName=MSG_RMI_RES_MISSING
-Language=English
-Required resource %1!s! missing
-.
-
-MessageId=
-SymbolicName=MSG_RMI_MOD_MISMATCH
-Language=English
-The module name specified in the resource is [%1!s!] while the module name as registered is [%2!s!]
-.
-
-MessageId=
-SymbolicName=MSG_RMI_RES_TOO_LONG
-Language=English
-The resource %1!s! is malformed or too long
-.
-
-MessageId=
-SymbolicName=MSG_RMI_API_MISMATCH
-Language=English
-The module was compile for API version %1!d!. However the current API version is %2!d!.
-.
-
-MessageId=
-SymbolicName=MSG_PB_START
-Language=English
-Starting plug-in [%1!s!]
-.
-
-MessageId=
-SymbolicName=MSG_PB_INVALID_CODE_PTR
-Language=English
-The plug-in is no longer valid. This maybe because the module containing the plug-in was unloaded.
-.
-
-MessageId=
-SymbolicName=MSG_PB_INIT_RV
-Language=English
-Initialization of the plug-in returned code %1!d!.
-.
-
-MessageId=
-SymbolicName=MSG_PB_INIT_FAIL
-Language=English
-Initialization of the %1!s! plug-in failed. The plug-in will be unloaded and any functionality provided will not be available.
-.
-
-MessageId=
-SymbolicName=MSG_PB_INIT_FAIL_S
-Language=English
-Plug-in %1!s! failed to initialize
-.
-
-MessageId=
-SymbolicName=MSG_PB_INIT_FAIL_G
-Language=English
-Details for plug-in:
-Description: %2!s!
-Module: %3!s!
-Support: %4!s!
-.
-
-MessageId=
-SymbolicName=MSG_PB_INIT_DONE
-Language=English
-Plug-in running
-.