summaryrefslogtreecommitdiffstats
path: root/src/windows/identity/include
diff options
context:
space:
mode:
authorJeffrey Altman <jaltman@secure-endpoints.com>2005-11-02 01:14:30 +0000
committerJeffrey Altman <jaltman@secure-endpoints.com>2005-11-02 01:14:30 +0000
commit5c27b523150384dd8655e739d68f01be2e4ff5d4 (patch)
tree649928f66dba979d1a84a9317b83a678e8321889 /src/windows/identity/include
parent5aa72f089113f917694a20144dca42049951c4da (diff)
Initial Commit Network Identity Manager for Windows
Initial commit of Network Identity Manager for KFW 3.0 Beta 1 ticket: new tags: pullup component: windows git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17476 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/windows/identity/include')
-rw-r--r--src/windows/identity/include/Makefile37
-rw-r--r--src/windows/identity/include/khdefs.h235
-rw-r--r--src/windows/identity/include/kherror.h177
-rw-r--r--src/windows/identity/include/khlist.h173
-rw-r--r--src/windows/identity/include/khmsgtypes.h700
-rw-r--r--src/windows/identity/include/khthread.h42
6 files changed, 1364 insertions, 0 deletions
diff --git a/src/windows/identity/include/Makefile b/src/windows/identity/include/Makefile
new file mode 100644
index 000000000..17182d57a
--- /dev/null
+++ b/src/windows/identity/include/Makefile
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2004 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.
+
+
+MODULE=include
+!include <../config/Makefile.w32>
+
+INCFILES= \
+ $(INCDIR)\khdefs.h \
+ $(INCDIR)\kherror.h \
+ $(INCDIR)\khlist.h \
+ $(INCDIR)\khmsgtypes.h
+
+all: $(INCFILES)
+
+clean::
+ $(RM) $(INCFILES)
diff --git a/src/windows/identity/include/khdefs.h b/src/windows/identity/include/khdefs.h
new file mode 100644
index 000000000..427926306
--- /dev/null
+++ b/src/windows/identity/include/khdefs.h
@@ -0,0 +1,235 @@
+/*
+ * Copyright (c) 2004 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_KHDEFS_H__
+#define __KHIMAIRA_KHDEFS_H__
+
+/*! \defgroup khdef Core definitions
+
+ Key type definitions used throughout NetIDMgr.
+ */
+/*@{*/
+#include<stddef.h>
+#include<limits.h>
+#include<wchar.h>
+
+/*!\typedef khm_octet
+ \brief A byte (8 bit unsigned)*/
+
+/*!\typedef khm_int16
+ \brief A signed 16 bit quantity */
+
+/*!\typedef khm_ui_2
+ \brief An unsigned 16 bit quantity */
+
+/*!\typedef khm_int32
+ \brief A signed 32 bit quantity */
+
+/*!\typedef khm_ui_4
+ \brief An unsigned 32 bit quantity */
+
+/*!\typedef khm_int64
+ \brief A signed 64 bit quantity */
+
+/*!\typedef khm_ui_8
+ \brief An unsigned 64 bit quantity */
+
+typedef unsigned __int8 khm_octet;
+
+typedef __int16 khm_int16;
+typedef unsigned __int16 khm_ui_2;
+
+typedef __int32 khm_int32;
+typedef unsigned __int32 khm_ui_4;
+
+typedef __int64 khm_int64;
+typedef unsigned __int64 khm_ui_8;
+
+#define VALID_INT_BITS INT_MAX
+#define VALID_UINT_BITS UINT_MAX
+
+#define KHM_UINT32_MAX 4294967295
+
+#define KHM_INT32_MAX 2147483647
+/* this strange form is necessary since - is a unary operator, not a sign
+ indicator */
+#define KHM_INT32_MIN (-KHM_INT32_MAX-1)
+
+#define KHM_UINT16_MAX 65535
+
+#define KHM_INT16_MAX 32767
+/* this strange form is necessary since - is a unary operator, not a sign
+ indicator */
+#define KHM_INT16_MIN (-KHM_INT16_MAX-1)
+
+/*! \brief Generic handle type.
+
+ Handles in NetIDMgr are generic pointers.
+*/
+typedef void * khm_handle;
+
+/*! \brief The invalid handle
+
+ Just used to indicate that this handle does not point to anything useful.
+ Usually returned by a function that returns a handle as a signal that the
+ operation failed.
+*/
+#define KHM_INVALID_HANDLE ((khm_handle) NULL)
+
+/*! \brief Boolean.
+*/
+typedef khm_int32 khm_boolean;
+
+/*! \brief A size
+ */
+typedef size_t khm_size;
+
+/*! \typedef ssize_t
+ \brief Signed size specifier
+
+ Just a signed version of size_t
+ */
+
+#ifdef _WIN64
+typedef __int64 ssize_t;
+#else
+typedef _W64 int ssize_t;
+#endif
+
+typedef ssize_t khm_ssize;
+
+#if defined(_WIN64)
+typedef unsigned __int64 khm_wparm;
+/*TODO: is this enough? */
+typedef unsigned __int64 khm_lparm;
+#elif defined(_WIN32)
+typedef unsigned __int32 khm_wparm;
+typedef unsigned __int64 khm_lparm;
+#else
+#error khm_wparm and khm_lparm need to be defined for this platform
+#endif
+
+/*!\def KHMAPI
+ \brief Calling convention for NetIDMgr exported functions
+
+ The caling convention for all NetIDMgr exported functions is \b
+ __stdcall , unless otherwise noted.
+ */
+
+/*!\def KHMEXP
+ \brief Export prefix for NetIDMgr exported functions
+
+ When compiling source that exports functions, those exported
+ function declarations will be done as follows:
+
+ \code
+ __declspec(dllexport) khm_int32 __stdcall function_name(arguments...);
+ \endcode
+
+ This eliminates the need for a separate exports definition file.
+ However, it doesn't preserve ordinals, but we aren't guaranteeing
+ that anyway.
+
+ On the other hand, if a particular function is going to be imported
+ from a DLL, it should declared as follows:
+
+ \code
+ __declspec(dllimport) khm_int32 __stdcall function_name(arguments...);
+ \endcode
+
+ This allows the compiler to properly instrument the import. If the
+ function is not declared this way, there will be a stub function
+ generated that will just jump to the proper import, generating
+ redundant instructions and wasting execution time.
+
+ This macro encapsulates the proper declaration specifier.
+ */
+
+#ifdef _WIN32
+#define KHMAPI __stdcall
+
+#define KHMEXP_EXP __declspec(dllexport)
+#define KHMEXP_IMP __declspec(dllimport)
+
+#define KHMEXP KHMEXP_EXP
+#endif
+
+/* Generic permission values */
+/*! \brief Generic read permission or request */
+#define KHM_PERM_READ 0x100
+
+/*! \brief Generic write permission or request */
+#define KHM_PERM_WRITE 0x200
+
+/* Generic flags */
+/*! \brief Generic create request
+
+ For most lookup functions, specifying this flag indicates that if
+ the requested object is not found it should be created.
+*/
+#define KHM_FLAG_CREATE 0x1000
+
+/*! \brief Wrap to DWORD boundary
+
+ Returns the smallest integer greater than or equal to the
+ parameter that is a multiple of 4.
+
+ \note Only use with positive integers. */
+#define UBOUND32(d) ((((d)-1)&~3) + 4)
+
+/*! \brief Offset a pointer by a number of bytes
+
+ Given a pointer, returns a void pointer that is a given number of
+ bytes offset from the pointer.
+ */
+#define BYTEOFFSET(p,off) ((void *)(((char *) (p)) + (off)))
+
+/*! \brief Check for powers of 2
+
+ Return TRUE if the operand is a positive power of 2 or 0*/
+#define IS_POW2(d) ((d)>=0 && !((d) & ((d) - 1)))
+
+/*! \brief Wrap to upper bound based on start and step size
+
+ Return the smallest element in the series <tt>s, s+t, s+2*t,
+ s+3*t, ...</tt> that is greater than or equal to \c v.
+*/
+#define UBOUNDSS(v,start,step) (((v)<=(start))?(start):(start)+((((v)-((start)+1))/(step))+1)*(step))
+
+/* \brief Length of an array
+*/
+#define ARRAYLENGTH(x) (sizeof(x)/sizeof(x[0]))
+
+/*! \brief Generic version type*/
+typedef struct tag_khm_version {
+ khm_ui_2 major; /*!< Major version number */
+ khm_ui_2 minor; /*!< Minor version number */
+ khm_ui_2 patch; /*!< Patch level */
+ khm_ui_2 aux; /*!< Auxilary level (usually carries a build number) */
+} khm_version;
+
+/*@}*/
+#endif
diff --git a/src/windows/identity/include/kherror.h b/src/windows/identity/include/kherror.h
new file mode 100644
index 000000000..d56fa7dc7
--- /dev/null
+++ b/src/windows/identity/include/kherror.h
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2004 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$ */
+
+/* Exported */
+#ifndef __KHIMAIRA_KHERROR_H
+#define __KHIMAIRA_KHERROR_H
+
+/*! \defgroup kherror NetIDMgr errors
+
+@{*/
+/*! \brief Base for error codes
+
+ NetIDMgr errors range from \a KHM_ERROR_BASE to KHM_ERROR_BASE +
+ KHM_ERROR_RANGE, with the exception of KHM_ERROR_SUCCESS and
+ KHM_ERROR_NONE.
+ */
+#define KHM_ERROR_BASE 0x40000000L
+
+/*! \brief Range for error codes
+
+ NetIDMgr errors range from \a KHM_ERROR_BASE to
+ KHM_ERROR_BASE + KHM_ERROR_RANGE.
+*/
+#define KHM_ERROR_RANGE 256L
+
+/*! \defgroup kherror_codes Error codes
+ @{*/
+
+/*! \brief No error */
+#define KHM_ERROR_NONE 0x00000000L
+
+/*! \brief Success. Same as \a KHM_ERROR_NONE */
+#define KHM_ERROR_SUCCESS KHM_ERROR_NONE
+
+/*! \brief The supplied name was invalid */
+#define KHM_ERROR_INVALID_NAME (KHM_ERROR_BASE + 1)
+
+/*! \brief Too much data
+
+ A supplied buffer was invalid, was of insufficient size, or a
+ buffer was of a larger size than expected
+ */
+#define KHM_ERROR_TOO_LONG (KHM_ERROR_BASE + 2)
+
+/*! \brief One or more parameters supplied to a function were invalid */
+#define KHM_ERROR_INVALID_PARM (KHM_ERROR_BASE + 3)
+
+/*! \brief A duplicate.
+
+ Usually means that something that should have been unique was
+ found to be not.
+ */
+#define KHM_ERROR_DUPLICATE (KHM_ERROR_BASE + 4)
+
+/*! \brief An object was not found
+
+ An object referenced in a parameter was not found.
+ */
+#define KHM_ERROR_NOT_FOUND (KHM_ERROR_BASE + 5)
+
+/*! \brief The relevant subsystem is not ready
+
+ Indicates that initialization has not been completed for a
+ subsystem.
+ */
+#define KHM_ERROR_NOT_READY (KHM_ERROR_BASE + 6)
+
+/*! \brief No more resources
+
+ A limited resource has been exhausted.
+ */
+#define KHM_ERROR_NO_RESOURCES (KHM_ERROR_BASE + 7)
+
+/*! \brief Type mismatch
+ */
+#define KHM_ERROR_TYPE_MISMATCH (KHM_ERROR_BASE + 8)
+
+/*! \brief Already exists
+
+ Usually indicates that an exclusive create operation failed due to
+ the existence of a similar object. Subtly different from
+ ::KHM_ERROR_DUPLICATE
+ */
+#define KHM_ERROR_EXISTS (KHM_ERROR_BASE + 9)
+
+/*! \brief Operation timed out
+ */
+#define KHM_ERROR_TIMEOUT (KHM_ERROR_BASE + 10)
+
+/*! \brief An EXIT message was received
+ */
+#define KHM_ERROR_EXIT (KHM_ERROR_BASE + 11)
+
+/*! \brief Unknown or unspecified error
+ */
+#define KHM_ERROR_UNKNOWN (KHM_ERROR_BASE + 12)
+
+/*! \brief General error
+ */
+#define KHM_ERROR_GENERAL KHM_ERROR_UNKNOWN
+
+/*! \brief An index was out of bounds
+ */
+#define KHM_ERROR_OUT_OF_BOUNDS (KHM_ERROR_BASE + 13)
+
+/*! \brief Object already deleted
+
+ One or more objects that were referenced were found to have been
+ already deleted.
+ */
+#define KHM_ERROR_DELETED (KHM_ERROR_BASE + 14)
+
+/*! \brief Invalid operation
+
+ The operation was not permitted to continue for some reason.
+ Usually because the necessary conditions for the operation haven't
+ been met yet or the operation can only be performed at certain
+ times during the execution of NetIDMgr.
+ */
+#define KHM_ERROR_INVALID_OPERATION (KHM_ERROR_BASE + 15)
+
+/*! \brief Signature check failed
+ */
+#define KHM_ERROR_INVALID_SIGNATURE (KHM_ERROR_BASE + 16)
+
+/*! \brief Not implemented yet
+
+ The operation that was attempted involved invoking functionality
+ that has not been implemented yet.
+ */
+#define KHM_ERROR_NOT_IMPLEMENTED (KHM_ERROR_BASE + 17)
+
+/*! \brief The objects were equivalent
+ */
+#define KHM_ERROR_EQUIVALENT (KHM_ERROR_BASE + 18)
+
+/*! \brief No provider exists to service the request
+*/
+#define KHM_ERROR_NO_PROVIDER (KHM_ERROR_BASE + 19)
+
+/*! \brief The operation succeeded, but with errors
+*/
+#define KHM_ERROR_PARTIAL (KHM_ERROR_BASE + 20)
+
+/*@}*/ /*kherror_codes*/
+
+/*! \brief Tests whether a return value indicates success */
+#define KHM_SUCCEEDED(rv) ((rv)==KHM_ERROR_NONE)
+
+/*! \brief Tests whether a return value indicates failure */
+#define KHM_FAILED(rv) ((rv)!=KHM_ERROR_NONE)
+
+/*@}*/
+#endif
diff --git a/src/windows/identity/include/khlist.h b/src/windows/identity/include/khlist.h
new file mode 100644
index 000000000..330cfc498
--- /dev/null
+++ b/src/windows/identity/include/khlist.h
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2004 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$ */
+
+/* Not exported */
+#ifndef _KHIMAIRA_KHLIST_H
+#define _KHIMAIRA_KHLIST_H
+
+/* Note that most of these are "unsafe" macros. Not for general use */
+
+/* LIFO lists */
+#define LDCL(type) \
+ type * next; \
+ type * prev
+
+#define LINIT(pe) \
+ do { \
+ (pe)->next = NULL; \
+ (pe)->prev = NULL; } while(0)
+
+#define LPUSH(pph,pe) \
+ do { \
+ (pe)->next = *pph; \
+ (pe)->prev = NULL; \
+ if(*(pph)) (*(pph))->prev = (pe); \
+ (*(pph)) = (pe); } while(0)
+
+#define LPOP(pph,ppe) \
+ do { \
+ *(ppe) = *(pph); \
+ if(*(pph)) *(pph) = (*(pph))->next; \
+ if(*(pph)) (*(pph))->prev = NULL; \
+ if(*(ppe)) (*(ppe))->next = NULL; \
+ } while(0)
+
+#define LDELETE(pph,pe) \
+ do { \
+ if((pe)->prev) (pe)->prev->next = (pe)->next; \
+ if((pe)->next) (pe)->next->prev = (pe)->prev; \
+ if(*(pph) == (pe)) *(pph) = (pe)->next; \
+ (pe)->next = (pe)->prev = NULL; \
+ } while(0)
+
+#define LEMPTY(pph) (*(pph) == NULL)
+
+#define LNEXT(pe) ((pe)?(pe)->next:NULL)
+
+#define LPREV(pe) ((pe)?(pe)->prev:NULL)
+
+/* Trees with LIFO child lists */
+#define TDCL(type) \
+ LDCL(type); \
+ type * children; \
+ type * parent
+
+#define TINIT(pe) \
+ do { \
+ (pe)->children = NULL; \
+ (pe)->parent = NULL; } while(0)
+
+#define TADDCHILD(pt,pe) \
+ do { \
+ LPUSH(&((pt)->children),(pe)); \
+ (pe)->parent = (pt); } while(0)
+
+#define TFIRSTCHILD(pt) ((pt)?(pt)->children:NULL)
+
+#define TPOPCHILD(pt, ppe) \
+ do { \
+ LPOP(&((pt)->children), ppe); \
+ if(*(ppe)) (*(ppe))->parent = NULL; \
+ } while(0)
+
+#define TDELCHILD(pt, pe) \
+ do { \
+ LDELETE(&((pt)->children), (pe)); \
+ (pe)->parent = NULL; } while(0)
+
+#define TPARENT(pe) ((pe)?(pe)->parent:NULL)
+
+/* FIFO lists */
+#define QDCL(type) \
+ type * head; \
+ type * tail
+
+#define QINIT(pq) \
+ do { \
+ (pq)->head = (pq)->tail = NULL; \
+ } while(0)
+
+#define QPUT(pq, pe) \
+ do { \
+ LPUSH(&(pq)->tail, (pe)); \
+ if(!(pq)->head) (pq)->head = (pe); \
+ } while(0)
+
+#define QGET(pq, ppe) \
+ do { \
+ *(ppe) = (pq)->head; \
+ if(*(ppe)) { \
+ (pq)->head = (*(ppe))->prev; \
+ if( (*(ppe))->prev ) (*(ppe))->prev->next = NULL; \
+ (*(ppe))->prev = NULL; \
+ if( (pq)->tail == *(ppe)) (pq)->tail = NULL; \
+ } \
+ } while(0)
+
+#define QDEL(pq, pe) \
+ do { \
+ if((pq)->head == (pe)) (pq)->head = LPREV(pe); \
+ LDELETE(&((pq)->tail), (pe)); \
+ } while(0)
+
+
+#define QGETT(pq,ppe) \
+ do { \
+ *(ppe) = (pq)->tail; \
+ if(*(ppe)) { \
+ (pq)->tail = (*(ppe))->next; \
+ if( (*(ppe))->next ) (*(ppe))->next->prev = NULL; \
+ (*(ppe))->next = NULL; \
+ if( (pq)->head == *(ppe)) (pq)->head = NULL; \
+ } \
+ } while(0)
+
+#define QTOP(pq) ((pq)->head)
+#define QBOTTOM(pq) ((pq)->tail)
+#define QNEXT(pe) ((pe)->prev)
+#define QPREV(pe) ((pe)->next)
+
+/* Trees with FIFO child lists */
+#define TQDCL(type) \
+ LDCL(type); \
+ QDCL(type); \
+ type * parent
+
+#define TQINIT(pe) \
+ do { \
+ QINIT(pe); \
+ (pe)->parent = NULL; } while(0)
+
+#define TQADDCHILD(pt,pe) \
+ do { \
+ QPUT((pt), (pe)); \
+ (pe)->parent = (pt); } while(0)
+
+#define TQFIRSTCHILD(pt) ((pt)?QTOP(pt):NULL)
+
+#define TQPARENT(pe) ((pe)?(pe)->parent:NULL)
+
+#endif
diff --git a/src/windows/identity/include/khmsgtypes.h b/src/windows/identity/include/khmsgtypes.h
new file mode 100644
index 000000000..8348bbf95
--- /dev/null
+++ b/src/windows/identity/include/khmsgtypes.h
@@ -0,0 +1,700 @@
+/*
+ * Copyright (c) 2004 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_KHMSGTYPES_H
+#define __KHIMAIRA_KHMSGTYPES_H
+
+/*! \addtogroup kmq
+@{*/
+/*! \defgroup kmq_msg Message Types
+@{*/
+
+/*! \name Global message types
+@{*/
+
+/*! \brief System messages.
+
+ All subscribers are subscribed to the system message class by default.
+
+ \see \ref kmq_msg_system
+*/
+#define KMSG_SYSTEM 0
+
+/*! \brief Ad-hoc messages.
+
+ These are messages that are sent through add hoc publishers and
+ subscribers.
+*/
+#define KMSG_ADHOC 1
+
+/*! \brief NetIDMgr Credentials Database messages
+
+ These messages notify subscribers of events related to the
+ credentials database, such as the registration, unregistration and
+ modification of identities, attributes, attribute types and
+ credential types. It also provides notifications of changes to
+ the root crednetial set.
+
+ \see \ref kmq_msg_kcdb
+*/
+#define KMSG_KCDB 2
+
+/*! \brief NetIDMgr Module Manager messages
+
+ \see \ref kmq_msg_kmm
+*/
+#define KMSG_KMM 3
+
+/*! \brief NetIDMgr Credential messages
+
+ Notifications of crednetial events. These are the most important
+ events that a credentials provider should respond to. The
+ notifications provide co-oridination between credential providers
+ for performing basic credentials management tasks such as
+ obtaining new credentials for an identity, deleting credentials
+ for an identity, obtaining or deleting credentials of a particular
+ type for an identity etc.
+
+ \see \ref cred_msgs
+ \see \ref kmq_msg_cred
+ */
+#define KMSG_CRED 4
+
+/*! \brief Action list messages
+
+ Notifications of changes in action state.
+
+ \see \ref kmq_msg_act
+ */
+#define KMSG_ACT 5
+
+/*! \brief Alert messages
+
+ Notifier is the component which displays alerts and error messages
+ when the NetIDMgr window is normally in operation and which
+ displays balloon prompts when the window is minimized to alert the
+ user to important messages such as credentials expiring etc.
+
+ \note This is an internal message class. Components that are not
+ the notifier should not be subscribing to alert messages.
+
+ \see \ref kmq_msg_alert
+ */
+#define KMSG_ALERT 6
+
+/*! \brief Identity messages
+
+ These are messages that are sent to the identity provider. These
+ are generally dispatched through a specific subscription object
+ and are not broadcast.
+
+ \see \ref kmq_msg_ident
+ */
+#define KMSG_IDENT 7
+
+/*! \brief Base message type ID for customized message types
+ */
+#define KMSGBASE_USER 16
+
+/*@}*/
+
+/*! \defgroup kmq_msg_system KMSG_SYSTEM subtypes
+@{*/
+/*! \brief Generic initialization message
+
+ This message is used by specific components to signal that the
+ recipient is to perform initialization tasks. As a convention,
+ the recipient should return KHM_ERROR_SUCCESS if it successfully
+ performed the initlization tasks or some other value if it failed
+ to do so. Failure to successfully initialize is usually taken to
+ mean that the recipient component is not able to perform its
+ function.
+
+ Usually this is the first message to be received by the recipient.
+
+ \see \ref pi_pt_cred_init
+ */
+#define KMSG_SYSTEM_INIT 1
+/*! \brief Generic uninitialization message
+
+ Used by specific components to signal that the recipient should
+ perform uninitilization tasks in preparation of termination. The
+ return value of this message is not used.
+
+ Usually this is the last message to be received by the recipient.
+
+ \see \ref pi_pt_cred_exit
+ */
+#define KMSG_SYSTEM_EXIT 2
+
+/*! \brief Message completion
+
+ This is an internal message
+ */
+#define KMSG_SYSTEM_COMPLETION 3
+/*@}*/
+
+/*! \defgroup kmq_msg_kcdb KMSG_KCDB subtypes
+@{*/
+#define KMSG_KCDB_IDENT 1
+#define KMSG_KCDB_CREDTYPE 2
+#define KMSG_KCDB_ATTRIB 3
+#define KMSG_KCDB_TYPE 4
+
+/*! \brief Generic credentials request
+
+ \see ::kcdb_cred_request for more information
+ */
+#define KMSG_KCDB_REQUEST 256
+/*@}*/
+
+/*! \defgroup kmq_msg_kmm KMSG_KMM subtypes
+@{*/
+#define KMSG_KMM_I_REG 1
+
+#define KMSG_KMM_I_DONE 2
+/*@}*/
+
+/*! \defgroup kmq_msg_act KMSG_ACT subtypes
+ @{*/
+
+/*! \brief One or more actions changed state
+
+ This message is sent in response to a call to
+ khui_enable_actions() or khui_enable_action() and indicates that
+ one or more actions have changed their state.
+ */
+#define KMSG_ACT_ENABLE 1
+
+/*! \brief One or more actions changed check state
+
+ Sent in response to khui_check_radio_action() or
+ khui_check_action() and indicates that one or more actions have
+ either been checked or unchecked.
+ */
+#define KMSG_ACT_CHECK 2
+
+/*! \brief Refresh action states
+
+ Sent after a batch of modifications were made to action states.
+ */
+#define KMSG_ACT_REFRESH 3
+
+#define KMSG_ACT_BEGIN_CMDLINE 128
+
+/*@}*/
+
+/*! \defgroup kmq_msg_cred KMSG_CRED subtypes
+ @{*/
+/*! \brief Root credential set changed
+
+ This message is issued when the root credential set successfully
+ collected credentials from another credential set.
+
+ \a uparam of the message is set to a bitmask indicating the change
+ that occured. It is a combination of ::KCDB_DELTA_ADD,
+ ::KCDB_DELTA_DEL and ::KCDB_DELTA_MODIFY.
+ */
+#define KMSG_CRED_ROOTDELTA 1
+
+/*! \brief Re-enumerate credentials
+
+ A notice to all credential providers to re-enumerate their
+ respective credentials.
+
+ \note May be sent to individual credential subscriptions.
+*/
+#define KMSG_CRED_REFRESH 2
+
+/*! \brief Change the password
+
+ This message notifies credentials providers that a password change
+ request has been received.
+
+ Message parameters:
+ - \b vparam : pointer to a ::khui_new_creds structure
+ */
+#define KMSG_CRED_PASSWORD 16
+
+/*! \brief Initiate the process of obtaining new credentials
+
+ The UI sends this message to start the process of obtaining new
+ credentials. See \ref cred_acq for more information about handling this
+ message.
+
+ Message parameters:
+ - \b vparam : pointer to a ::khui_new_creds structure
+
+ \see \ref cred_acq
+ */
+#define KMSG_CRED_NEW_CREDS 17
+
+/*! \brief Renew credentials
+
+ This is a notification sent to individual credentials providers
+ that a specified identity's credentials should be renewed.
+
+ Message parameters:
+ - \b vparam : Pointer to a khui_new_creds object
+ */
+#define KMSG_CRED_RENEW_CREDS 18
+
+/*! \brief Dialog setup
+
+ Once KMSG_CRED_NEW_CREDS has been responded to by all the
+ credential types, the UI creates the dialog windows using the data
+ supplied in the ::khui_new_creds_by_type structures and issues
+ this message. Each credentials provider is expected to respond by
+ finalizing dialog creation operations.
+
+ Message parameters:
+ - \b vparam : poitner to a ::khui_new_creds structure
+
+ \note May be sent to individual credential subscriptions.
+ */
+#define KMSG_CRED_DIALOG_SETUP 19
+
+/*! \brief Dialog pre-start
+
+ Sent after all the credentials providers have responded to
+ KMSG_CRED_DIALOG_SETUP and all the initialization has been
+ completed. Credentials providers are expected to respond to this
+ message by loading any default data into the dialog controls for
+ each credential type.
+
+ Message parameters:
+ - \b vparam : pointer to a ::khui_new_creds structure
+
+ \note May be sent to individual credential subscriptions.
+ */
+#define KMSG_CRED_DIALOG_PRESTART 20
+
+/*! \brief Dialog start
+
+ A notification that the dialog is now in progress.
+
+ Message parameters:
+ - \b vparam : pointer to a ::khui_new_creds structure
+
+ \note May be sent to individual credential subscriptions.
+ */
+#define KMSG_CRED_DIALOG_START 21
+
+/*! \brief The primary identity of the new credentials dialog has changed
+
+ This message is not sent out by the UI, but is reserved here for
+ use by individual credentials providers. The message may be sent
+ from the dialog procedure to the plugin.
+
+ Message parameters:
+ - \b vparam : pointer to a ::khui_new_creds structure
+
+ \note Be careful when sending this message. All messages that are
+ not sent by the system should not be sent via broadcast.
+ Instead, create a subscription using kmq_create_subscription()
+ for the individual plugin that you want to send the message
+ and use one of the per-subscription message functions to send
+ the actual message.
+ */
+#define KMSG_CRED_DIALOG_NEW_IDENTITY 22
+
+/*! \brief New credentials options have changed.
+
+ This message is not sent out by the UI, but is reserved here for
+ use by individual credentials providers. The message may be sent
+ from the dialog procedure to the plugin.
+
+ Message parameters:
+ - \b vparam : pointer to a ::khui_new_creds structure
+
+ \note Be careful when sending this message. All messages that are
+ not sent by the system should not be sent via broadcast.
+ Instead, create a subscription using kmq_create_subscription()
+ for the individual plugin that you want to send the message
+ and use one of the per-subscription message functions to send
+ the actual message.
+ */
+#define KMSG_CRED_DIALOG_NEW_OPTIONS 23
+
+/*! \brief Process dialog
+
+ Sent to all the credential providers to look at the contents of
+ the given ::khui_new_creds structure and do any required
+ processing.
+
+ If the \a result field in the structure is set to
+ KHUI_NC_RESULT_GET_CREDS, then new credentials should be obtained
+ using the given data.
+
+ Set the \a response field in the structure to indicate how the UI
+ should proceed from here.
+
+ Message parameters:
+ - \b vparam : pointer to a ::khui_new_creds structure
+
+ \note May be sent to individual credential subscriptions.
+ */
+#define KMSG_CRED_PROCESS 24
+
+/*! \brief End a credentials acquisition operation
+
+ A notification that the credentials acquisition operation has
+ ended.
+
+ Message parameters:
+ - \b vparam : pointer to a ::khui_new_creds structure
+
+ \note May be sent to individual credential subscriptions.
+ */
+#define KMSG_CRED_END 25
+
+/*! \brief Import credentials from the operating system
+
+ Notification to all credentials providers to import any available
+ credentials from the operating system.
+
+ Message parameters:
+ - This message does not have any parameters
+*/
+#define KMSG_CRED_IMPORT 26
+
+/*! \brief Destroy credentials
+
+ Notification that the specified credentials should be destroyed.
+ Once this message has completed processing a ::KMSG_CRED_REFRESH
+ message will be issued.
+
+ The credentials that should be destroyed are specified by a
+ ::khui_action_context structure. The context that should be used
+ is the selection context. Hence, the credentials that must be
+ destroyed are the ones lised in the credential set (\a credset).
+
+ Message parameters:
+
+ - \b upram : Unused. Zero.
+
+ - \b vparam : pointer to a ::khui_action_context structure which
+ describes which credentials need to be destroyed.
+
+ */
+#define KMSG_CRED_DESTROY_CREDS 32
+
+#if 0
+/*! \brief Parse an identity
+
+ \note May be sent to individual credential subscriptions.
+ */
+#define KMSG_CRED_IDENT_PARSE 65
+#endif
+
+/*! \brief A property page is being launced
+
+ Message parameters:
+ - \b vparam : pointer to a ::khui_property_sheet structure
+ */
+#define KMSG_CRED_PP_BEGIN 128
+
+/*! \brief A property page is about to be created
+
+ Message parameters:
+ - \b vparam : pointer to a ::khui_property_sheet structure
+
+ \note This message is merely a notification that the property
+ sheet is being created. Handlers should not modify the state
+ of the property sheet or pages at this time.
+ */
+#define KMSG_CRED_PP_PRECREATE 129
+
+/*! \brief A property page has finished processing
+
+ Message parameters:
+ - \b vparam : pointer to a ::khui_property_sheet structure
+ */
+#define KMSG_CRED_PP_END 130
+
+/*! \brief A property page has been destroyed
+
+ Message parameters:
+ - \b vparam : pointer to a ::khui_property_sheet structure
+ */
+#define KMSG_CRED_PP_DESTROY 131
+
+/*! \brief Check if a KMSG_CRED subtype is a credentials acquisition message
+
+ Dialog messages are those that deal with the new or initial
+ credentials acquisition dialog, from initial announcement to
+ dialog completion.
+
+ Currently, the dialog messages are:
+ - ::KMSG_CRED_INITIAL_CREDS
+ - ::KMSG_CRED_NEW_CREDS
+ - ::KMSG_CRED_RENEW_CREDS
+ - ::KMSG_CRED_DIALOG_SETUP
+ - ::KMSG_CRED_DIALOG_PRESTART
+ - ::KMSG_CRED_DIALOG_START
+ - ::KMSG_CRED_DIALOG_NEW_IDENTITY
+ - ::KMSG_CRED_DIALOG_NEW_OPTIONS
+ - ::KMSG_CRED_PROCESS
+ - ::KMSG_CRED_END
+
+ All dialog message numbers are allocated in a contigous block.
+
+ Note that while ::KMSG_CRED_PROCESS and ::KMSG_CRED_END are not
+ specific to dialogs, they are still included in this predicate
+ because they are also part of the dialog message sequence.
+ */
+#define IS_CRED_ACQ_MSG(msg) ((msg) >= 16 && (msg) <=31)
+
+/*@}*/ /* /KMSG_CRED subtypes */
+
+/*! \defgroup kmq_msg_alert KMSG_ALERT Subtypes
+ @{*/
+
+/*! \brief Show an alert
+
+ Message parameters:
+ - \b vparam : held pointer to a ::khui_alert object
+
+ \note The ::khui_alert object will be released when the processing
+ of this message completes.
+ */
+#define KMSG_ALERT_SHOW 1
+
+/*@}*/
+
+/*! \defgroup kmq_msg_ident KMSG_IDENT Subtypes
+ @{*/
+
+/*! \brief Initialize and start the identity provider
+
+
+ Sent by the KCDB to notify the identity provider that it is now
+ the current identity provider.
+
+ Note that unlike regular plugins, an identity provider can be
+ loaded and inert (not provide any services). Also, the user may
+ switch between multiple identity providers on the fly.
+ */
+#define KMSG_IDENT_INIT 1
+
+/*! \brief Stop the identity provider
+
+ Sent by the KCDB as notificaton that the identity provider is no
+ longer the current provider.
+ */
+#define KMSG_IDENT_EXIT 2
+
+/*! \brief Check if an identity name is valid
+
+ This message is sent to the identity provider to verify the syntax
+ of an identity name. Note that only the syntax of the name is to
+ be verfied and not the actual physical existence of said identity.
+
+ Message parameters:
+
+ - \b vparam : pointer to ::kcdb_ident_name_xfer object. The
+ name to be validated will be in the \a name_src member. The
+ buffer will be NULL terminated with a maximum limit of
+ KCDB_IDENT_MAXCCH_NAME characters including the terminating
+ NULL, consisting only of characters in KCDB_IDENT_VALID_CHARS
+ The \a result member should be set to one of the following
+ depending on the result of the validation:
+
+ - KHM_ERROR_SUCCESS : The name was valid
+ - KHM_ERROR_INVALID_NAME : The name was invalid
+ */
+#define KMSG_IDENT_VALIDATE_NAME 3
+
+/*! \brief Check if an identity is valid
+
+ Sent to the identity provider to verify the validity of the given
+ identity. The provider should verify that the identity exists and
+ is in a state where it can be actively used.
+
+ Depending on the result of the validation, the flags of the
+ identity should be updated.
+
+ Message parameters:
+ - \b vparam : Handle to an identity cast as a void pointer.
+ */
+#define KMSG_IDENT_VALIDATE_IDENTITY 4
+
+/*! \brief Canonicalize identity name
+
+ The identity provider will be given a name, which it should put in
+ canonical form, adjusting case and any character replacement or
+ doing any relevant expansions if applicable, and place it in the
+ supplied buffer.
+
+ Message parameters:
+
+ - \b vparam : Pointer to a ::kcdb_ident_name_xfer structure
+ which provides the identity name to canonicalize in the \a
+ name_src member, and the buffer to store the canonical name
+ in the \a name_dest member. The \a name_dest buffer is
+ guaranteed to be at least KCDB_IDENT_MAXCCH_NAME characters
+ in size.
+
+ If the name cannot be canonicalized for some reason, the
+ destination buffer should be set to a zero-length string and the
+ \a result member of the ::kcdb_ident_name_xfer structure should be
+ set to the error code. If the destination buffer is set to a
+ zero-length string and \a result is KHM_ERROR_SUCCESS, then the
+ original name provided in \a name_src is assumed to be already in
+ canonical form.
+ */
+#define KMSG_IDENT_CANON_NAME 5
+
+/*! \brief Compare names
+
+ Compare two identity names. The names that are given aren't
+ guaranteed to be in canonical form. The return value should be
+ akin to strcmp().
+
+ Message parameters:
+
+ - \b vparam : A pointer to a ::kcdb_ident_name_xfer structure.
+ The \a name_src member points at the first name, and the \a
+ name_alt member specifies the second name. The result of the
+ comparison should be place in \a result.
+ */
+#define KMSG_IDENT_COMPARE_NAME 6
+
+/*! \brief Set the default identity
+
+ Set or unset the default identity. To set the default identity,
+ the \a uparam parameter will be set to a non-zero value and a
+ handle to the identity will be specified in \a vparam. To unset
+ the default identity (i.e. not have a default identity), a zero
+ value will be specified in \a uparam and no identities will be
+ specified in \a vparam.
+
+ When setting a default identity, the identity provider will
+ receive this message prior to the ::KCDB_IDENT_FLAG_DEFAULT bit
+ being set or reset on any identity. It should return
+ KHM_ERROR_SUCCESS if the requested operation can be performed.
+ Returning any other value will abort the operation and will leave
+ the default identity unchanged.
+
+ When resetting the default identity, this message should be
+ treated only as a notification.
+
+ Message parameters:
+
+ - \a uparam : Is non-zero if an identity is being made default. If
+ this is zero, then identity should be the default.
+
+ - \a vparam : A handle to the identity to be made default if \a
+ uparam is non-zero. NULL otherwise.
+
+ Return value:
+
+ - KHM_ERROR_SUCCESS : The identity should be marked as default
+ - Any other value : The identity should not be marked as default
+
+ */
+#define KMSG_IDENT_SET_DEFAULT 7
+
+/*! \brief Set an identity as searchable
+
+ Set or reset the searchable bit on an identity. If the \a uparam
+ parameter is non-zero, then the searchable bit is being set.
+ Otherwise it is being reset. The identity provider should return
+ KHM_ERROR_SUCCESS in order to indicate that the identity should be
+ marked as searchable. Any other value will result in the
+ searchable bit being reset on the identity.
+
+ Message parameters:
+
+ - \a uparam : Is non-zero if the searchable bit is being set. Zero
+ otherwise.
+
+ - \a vparam : Handle to the identity
+
+ Return value:
+
+ - KHM_ERROR_SUCCESS: The identity should be marked as searchable
+ - Any other value : The identity should not be marked as default
+ */
+#define KMSG_IDENT_SET_SEARCHABLE 8
+
+/*! \brief Get information about an identity
+
+ */
+#define KMSG_IDENT_GET_INFO 9
+
+/*! \brief Enumerate known and accessible identities
+ */
+#define KMSG_IDENT_ENUM_KNOWN 10
+
+/*! \brief Update information about an identity
+ */
+#define KMSG_IDENT_UPDATE 11
+
+/*! \brief Retrieve the user interface callback function
+
+ When obtaining new credentials, the user interface needs to obtain
+ a callback function which will provide identity selection
+ controls.
+
+ Message parameters:
+
+ - \a uparam : Not used
+
+ - \a vparam : pointer to a ::khui_ident_new_creds_cb which will
+ receive the call back.
+ */
+#define KMSG_IDENT_GET_UI_CALLBACK 12
+
+/*! \brief Notification of the creation of an identity
+
+ This should be considered just a notification. The identit
+ provider does not have an opportunity to veto the creation of an
+ identity whose name has been found to be valid. However, when
+ handing this notification, the identity provider can:
+
+ - Change the flags of the identity and/or marking the identity as
+ invalid.
+
+ - Change the default identity.
+
+ Note that this notification is sent before the general :;KMSG_KCDB
+ notification of the identity creation is sent.
+
+ Message parameters:
+
+ - \a uparam : Not used.
+
+ - \p vparam : handle to the identity
+ */
+#define KMSG_IDENT_NOTIFY_CREATE 13
+
+/*@}*/ /* /KMSG_IDENT subtypes */
+
+/*@}*/ /* / message types */
+/*@}*/ /* / kmq */
+
+#endif
diff --git a/src/windows/identity/include/khthread.h b/src/windows/identity/include/khthread.h
new file mode 100644
index 000000000..b7354c468
--- /dev/null
+++ b/src/windows/identity/include/khthread.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2004 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$ */
+
+/* Not exported */
+#ifndef __KHIMAIRA_KTHREAD_H
+#define __KHIMAIRA_KTHREAD_H
+
+#ifdef _WIN32
+#define khm_mutex CRITICAL_SECTION
+
+#define khp_mutex_init(pcs) InitializeCriticalSection(pcs)
+#define khp_mutex_destroy(pcs) DeleteCriticalSection(pcs)
+#define khp_mutex_lock(pcs) EnterCriticalSection(pcs)
+#define khp_mutex_unlock(pcs) LeaveCriticalSection(pcs)
+#define khp_mutex_trylock(pcs) (!TryEnterCriticalSection(pcs))
+
+#endif
+
+#endif \ No newline at end of file