-#\r
-# Copyright (c) 2004 Massachusetts Institute of Technology\r
-# Copyright (c) 2006 Secure Endpoints Inc.\r
-#\r
-# Permission is hereby granted, free of charge, to any person\r
-# obtaining a copy of this software and associated documentation files\r
-# (the "Software"), to deal in the Software without restriction,\r
-# including without limitation the rights to use, copy, modify, merge,\r
-# publish, distribute, sublicense, and/or sell copies of the Software,\r
-# and to permit persons to whom the Software is furnished to do so,\r
-# subject to the following conditions:\r
-#\r
-# The above copyright notice and this permission notice shall be\r
-# included in all copies or substantial portions of the Software.\r
-#\r
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
-# SOFTWARE.\r
-\r
-!ifdef ETAGRUN\r
-all: finale doc\r
-!else\r
-all: finale\r
-!endif\r
-\r
-MODULE=all\r
-!include <config/Makefile.w32>\r
-\r
-!ifndef CLEANRUN\r
-!ifndef TESTRUN\r
-!ifndef ETAGRUN\r
-\r
-# Define KH_NO_WX if the build should not fail on warnings. The\r
-# default is to treat warnings as errors.\r
-\r
-#RMAKE=$(MAKECMD) /nologo all KH_NO_WX=1\r
-RMAKE=$(MAKECMD) /nologo all\r
-RMAKE_W2K=$(MAKECMD) /nologo all KHBUILD_W2K=1\r
-\r
-!else\r
-RMAKE=$(MAKECMD) /nologo etag\r
-RMAKE_W2K=echo Skipping W2K target for ETAGS run.\r
-!endif\r
-!else\r
-RMAKE=$(MAKECMD) /nologo test\r
-RMAKE_W2K=$(MAKECMD) /nologo test KHBUILD_W2K=1\r
-!endif\r
-!else\r
-RMAKE=$(MAKECMD) /nologo clean\r
-RMAKE_W2K=$(MAKECMD) /nologo clean KHBUILD_W2K=1\r
-!endif\r
-\r
-start:\r
-\r
-config: start\r
- $(ECHO) -- Entering $@:\r
- $(CD) $@\r
- $(RMAKE)\r
- $(CD) ..\r
- $(ECHO) -- Done with $@\r
-\r
-include: config\r
- $(ECHO) -- Entering $@:\r
- $(CD) $@\r
- $(RMAKE)\r
- $(CD) ..\r
- $(ECHO) -- Done with $@\r
-\r
-util: include\r
- $(ECHO) -- Entering $@:\r
- $(CD) $@\r
- $(RMAKE)\r
- $(CD) ..\r
- $(ECHO) -- Done with $@\r
-\r
-kherr: util\r
- $(ECHO) -- Entering $@:\r
- $(CD) $@\r
- $(RMAKE)\r
- $(CD) ..\r
- $(ECHO) -- Done with $@\r
-\r
-kconfig: kherr\r
- $(ECHO) -- Entering $@:\r
- $(CD) $@\r
- $(RMAKE)\r
- $(CD) ..\r
- $(ECHO) -- Done with $@\r
-\r
-kmq: kconfig\r
- $(ECHO) -- Entering $@:\r
- $(CD) $@\r
- $(RMAKE)\r
- $(CD) ..\r
- $(ECHO) -- Done with $@\r
-\r
-kcreddb: kmq\r
- $(ECHO) -- Entering $@:\r
- $(CD) $@\r
- $(RMAKE)\r
- $(CD) ..\r
- $(ECHO) -- Done with $@\r
-\r
-kmm: kcreddb\r
- $(ECHO) -- Entering $@:\r
- $(CD) $@\r
- $(RMAKE)\r
- $(CD) ..\r
- $(ECHO) -- Done with $@\r
-\r
-help: kmm\r
- $(ECHO) -- Entering $@:\r
- $(CD) $@\r
- $(RMAKE)\r
- $(CD) ..\r
- $(ECHO) -- Done with $@\r
-\r
-uilib: help\r
- $(ECHO) -- Entering $@:\r
- $(CD) $@\r
- $(RMAKE)\r
- $(RMAKE_W2K)\r
- $(CD) ..\r
- $(ECHO) -- Done with $@\r
-\r
-nidmgrdll: uilib\r
- $(ECHO) -- Entering $@\r
- $(CD) $@\r
- $(RMAKE)\r
- $(RMAKE_W2K)\r
- $(CD) ..\r
- $(ECHO) -- Done with $@\r
-\r
-ui: nidmgrdll\r
- $(ECHO) -- Entering $@:\r
- $(CD) $@\r
- $(RMAKE)\r
- $(RMAKE_W2K)\r
- $(CD) ..\r
- $(ECHO) -- Done with $@\r
-\r
-# Now build the plugins\r
-plugincommon: ui\r
- $(ECHO) -- Entering $@\r
- $(CD) plugins\common\r
- $(RMAKE)\r
- $(CD) ..\..\r
- $(ECHO) -- Done with $@\r
-\r
-krb5plugin: plugincommon\r
- $(ECHO) -- Entering $@\r
- $(CD) plugins\krb5\r
- $(RMAKE)\r
- $(CD) ..\..\r
- $(ECHO) -- Done with $@\r
-\r
-!ifndef NO_KRB4\r
-finale: krb4plugin\r
-\r
-krb4plugin: plugincommon\r
- $(ECHO) -- Entering $@\r
- $(CD) plugins\krb4\r
- $(RMAKE)\r
- $(CD) ..\..\r
- $(ECHO) -- Done with $@\r
-!endif\r
-\r
-!ifdef BUILD_AFS\r
-finale: afsplugin\r
-\r
-afsplugin: plugincommon\r
- $(ECHO) -- Entering $@\r
- $(CD) plugins\afs\r
- $(RMAKE)\r
- $(CD) ..\..\r
- $(ECHO) -- Done with $@\r
-!endif\r
-\r
-!ifdef NODOCBUILD\r
-doctarget=\r
-!else\r
-doctarget=doc\r
-!endif\r
-\r
-finale: krb5plugin $(doctarget)\r
- $(ECHO) -- Done.\r
-\r
-pdoc:\r
-\r
-doc: pdoc\r
- $(ECHO) -- Entering $@:\r
- $(CD) $@\r
- $(RMAKE)\r
- $(CD) ..\r
- $(ECHO) -- Done with $@\r
-\r
-clean::\r
- $(MAKECMD) /nologo CLEANRUN=1\r
-\r
-test::\r
- $(MAKECMD) /nologo TESTRUN=1\r
-\r
-etags::\r
- $(RM) $(TAGFILE)\r
- $(MAKECMD) /nologo ETAGRUN=1\r
+#
+# Copyright (c) 2004 Massachusetts Institute of Technology
+# Copyright (c) 2006 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.
+
+!ifdef ETAGRUN
+all: finale doc
+!else
+all: finale
+!endif
+
+MODULE=all
+!include <config/Makefile.w32>
+
+!ifndef CLEANRUN
+!ifndef TESTRUN
+!ifndef ETAGRUN
+
+# Define KH_NO_WX if the build should not fail on warnings. The
+# default is to treat warnings as errors.
+
+#RMAKE=$(MAKECMD) /nologo all KH_NO_WX=1
+RMAKE=$(MAKECMD) /nologo all
+RMAKE_W2K=$(MAKECMD) /nologo all KHBUILD_W2K=1
+
+!else
+RMAKE=$(MAKECMD) /nologo etag
+RMAKE_W2K=echo Skipping W2K target for ETAGS run.
+!endif
+!else
+RMAKE=$(MAKECMD) /nologo test
+RMAKE_W2K=$(MAKECMD) /nologo test KHBUILD_W2K=1
+!endif
+!else
+RMAKE=$(MAKECMD) /nologo clean
+RMAKE_W2K=$(MAKECMD) /nologo clean KHBUILD_W2K=1
+!endif
+
+!if "$(CPU)" != "i386"
+NO_KRB4=1
+!endif
+
+start:
+
+config: start
+ $(ECHO) -- Entering $@:
+ $(CD) $@
+ $(RMAKE)
+ $(CD) ..
+ $(ECHO) -- Done with $@
+
+include: config
+ $(ECHO) -- Entering $@:
+ $(CD) $@
+ $(RMAKE)
+ $(CD) ..
+ $(ECHO) -- Done with $@
+
+util: include
+ $(ECHO) -- Entering $@:
+ $(CD) $@
+ $(RMAKE)
+ $(CD) ..
+ $(ECHO) -- Done with $@
+
+kherr: util
+ $(ECHO) -- Entering $@:
+ $(CD) $@
+ $(RMAKE)
+ $(CD) ..
+ $(ECHO) -- Done with $@
+
+kconfig: kherr
+ $(ECHO) -- Entering $@:
+ $(CD) $@
+ $(RMAKE)
+ $(CD) ..
+ $(ECHO) -- Done with $@
+
+kmq: kconfig
+ $(ECHO) -- Entering $@:
+ $(CD) $@
+ $(RMAKE)
+ $(CD) ..
+ $(ECHO) -- Done with $@
+
+kcreddb: kmq
+ $(ECHO) -- Entering $@:
+ $(CD) $@
+ $(RMAKE)
+ $(CD) ..
+ $(ECHO) -- Done with $@
+
+kmm: kcreddb
+ $(ECHO) -- Entering $@:
+ $(CD) $@
+ $(RMAKE)
+ $(CD) ..
+ $(ECHO) -- Done with $@
+
+help: kmm
+ $(ECHO) -- Entering $@:
+ $(CD) $@
+ $(RMAKE)
+ $(CD) ..
+ $(ECHO) -- Done with $@
+
+uilib: help
+ $(ECHO) -- Entering $@:
+ $(CD) $@
+ $(RMAKE)
+ $(RMAKE_W2K)
+ $(CD) ..
+ $(ECHO) -- Done with $@
+
+nidmgrdll: uilib
+ $(ECHO) -- Entering $@
+ $(CD) $@
+ $(RMAKE)
+ $(RMAKE_W2K)
+ $(CD) ..
+ $(ECHO) -- Done with $@
+
+ui: nidmgrdll
+ $(ECHO) -- Entering $@:
+ $(CD) $@
+ $(RMAKE)
+ $(RMAKE_W2K)
+ $(CD) ..
+ $(ECHO) -- Done with $@
+
+# Now build the plugins
+plugincommon: ui
+ $(ECHO) -- Entering $@
+ $(CD) plugins\common
+ $(RMAKE)
+ $(CD) ..\..
+ $(ECHO) -- Done with $@
+
+krb5plugin: plugincommon
+ $(ECHO) -- Entering $@
+ $(CD) plugins\krb5
+ $(RMAKE)
+ $(CD) ..\..
+ $(ECHO) -- Done with $@
+
+!ifndef NO_KRB4
+finale: krb4plugin
+
+krb4plugin: plugincommon
+ $(ECHO) -- Entering $@
+ $(CD) plugins\krb4
+ $(RMAKE)
+ $(CD) ..\..
+ $(ECHO) -- Done with $@
+!endif
+
+!ifdef BUILD_AFS
+finale: afsplugin
+
+afsplugin: plugincommon
+ $(ECHO) -- Entering $@
+ $(CD) plugins\afs
+ $(RMAKE)
+ $(CD) ..\..
+ $(ECHO) -- Done with $@
+!endif
+
+!ifdef NODOCBUILD
+doctarget=
+!else
+doctarget=doc
+!endif
+
+finale: krb5plugin $(doctarget)
+ $(ECHO) -- Done.
+
+pdoc:
+
+doc: pdoc
+ $(ECHO) -- Entering $@:
+ $(CD) $@
+ $(RMAKE)
+ $(CD) ..
+ $(ECHO) -- Done with $@
+
+clean::
+ $(MAKECMD) /nologo CLEANRUN=1
+
+test::
+ $(MAKECMD) /nologo TESTRUN=1
+
+etags::
+ $(RM) $(TAGFILE)
+ $(MAKECMD) /nologo ETAGRUN=1
goto _skip_copy;
}
- kcdb_buf_set_value(&dest->buf, i, i, srcbuf, cbsrcbuf);
+ kcdb_buf_set_value(&dest->buf, i, (khm_ui_2) i, srcbuf, cbsrcbuf);
rv = KHM_ERROR_SUCCESS;
_skip_copy:
if (!(a->flags & KCDB_ATTR_FLAG_COMPUTED) &&
(a->flags & KCDB_ATTR_FLAG_TRANSIENT) &&
kcdb_cred_val_exist(dest, i)) {
- kcdb_buf_set_value(&dest->buf, i, i, NULL, 0);
+ kcdb_buf_set_value(&dest->buf, i, (khm_ui_2) i, NULL, 0);
rv = KHM_ERROR_SUCCESS;
}
if (buffer == 0) {
/* we are removing the value */
- kcdb_buf_alloc(&cred->buf, attr_id, attr_id, 0);
+ kcdb_buf_alloc(&cred->buf, attr_id, (khm_ui_2) attr_id, 0);
code = KHM_ERROR_SUCCESS;
goto _exit;
}
goto _exit;
}
- kcdb_buf_alloc(&cred->buf, attr_id, attr_id, cbdest);
+ kcdb_buf_alloc(&cred->buf, attr_id, (khm_ui_2) attr_id, cbdest);
if(!kcdb_cred_buf_exist(cred, attr_id)) {
code = KHM_ERROR_NO_RESOURCES;
goto _exit;
if(KHM_FAILED(code =
type->dup(buffer, cbbuf, kcdb_cred_buf_get(cred,attr_id), &cbdest)))
{
- kcdb_buf_alloc(&cred->buf, attr_id, attr_id, 0);
+ kcdb_buf_alloc(&cred->buf, attr_id, (khm_ui_2) attr_id, 0);
goto _exit;
}
return rv;
}
+/* These are protected with cs_credset */
+static void * _creds_comp_rock = NULL;
+static kcdb_cred_comp_func _creds_comp_func = NULL;
-/* wrapper for qsort and also parameter gobbling FSM. Access to this
- function is serialized via cs_credset. */
+/* Need cs_credset when calling this function. */
int __cdecl
kcdb_creds_comp_wrapper(const void * a, const void * b)
{
- static void * rock = NULL;
- static kcdb_cred_comp_func comp = NULL;
-
- if(!b) {
- rock = (void *) a;
- return 0;
- }
-
- if(!a) {
- comp = (kcdb_cred_comp_func) b;
- return 0;
- }
-
- return comp((khm_handle) ((kcdb_credset_credref *)a)->cred,
- (khm_handle) ((kcdb_credset_credref *)b)->cred,
- rock);
+ return (*_creds_comp_func)((khm_handle) ((kcdb_credset_credref *)a)->cred,
+ (khm_handle) ((kcdb_credset_credref *)b)->cred,
+ _creds_comp_rock);
}
KHMEXP khm_int32 KHMAPI
EnterCriticalSection(&cs_credset);
- kcdb_creds_comp_wrapper(rock, NULL);
- kcdb_creds_comp_wrapper(NULL, (void *) comp);
+ _creds_comp_rock = rock;
+ _creds_comp_func = comp;
qsort(cs->clist, cs->nclist,
sizeof(kcdb_credset_credref), kcdb_creds_comp_wrapper);
if (buffer == NULL) {
/* we are removing a value */
- slot = kcdb_buf_slot_by_id(&id->buf, attr_id);
+ slot = kcdb_buf_slot_by_id(&id->buf, (khm_ui_2) attr_id);
if (slot != KCDB_BUF_INVALID_SLOT &&
kcdb_buf_exist(&id->buf, slot))
- kcdb_buf_alloc(&id->buf, slot, attr_id, 0);
+ kcdb_buf_alloc(&id->buf, slot, (khm_ui_2) attr_id, 0);
code = KHM_ERROR_SUCCESS;
goto _exit;
}
goto _exit;
}
- kcdb_buf_alloc(&id->buf, KCDB_BUF_APPEND, attr_id, cbdest);
- slot = kcdb_buf_slot_by_id(&id->buf, attr_id);
+ kcdb_buf_alloc(&id->buf, KCDB_BUF_APPEND, (khm_ui_2) attr_id, cbdest);
+ slot = kcdb_buf_slot_by_id(&id->buf, (khm_ui_2) attr_id);
if(slot == KCDB_BUF_INVALID_SLOT || !kcdb_buf_exist(&id->buf, slot)) {
code = KHM_ERROR_NO_RESOURCES;
goto _exit;
if(KHM_FAILED(code =
type->dup(buffer, cbbuf, kcdb_buf_get(&id->buf, slot), &cbdest)))
{
- kcdb_buf_alloc(&id->buf, slot, attr_id, 0);
+ kcdb_buf_alloc(&id->buf, slot, (khm_ui_2) attr_id, 0);
goto _exit;
}
id = (kcdb_identity *) vid;
if(!(id->flags & KCDB_IDENT_FLAG_ATTRIBS) ||
- (slot = kcdb_buf_slot_by_id(&id->buf, attr_id)) == KCDB_BUF_INVALID_SLOT ||
+ (slot = kcdb_buf_slot_by_id(&id->buf, (khm_ui_2) attr_id)) == KCDB_BUF_INVALID_SLOT ||
!kcdb_buf_val_exist(&id->buf, slot))
{
code = KHM_ERROR_NOT_FOUND;
id = (kcdb_identity *) vid;
if(!(id->flags & KCDB_IDENT_FLAG_ATTRIBS) ||
- (slot = kcdb_buf_slot_by_id(&id->buf, attr_id)) == KCDB_BUF_INVALID_SLOT ||
+ (slot = kcdb_buf_slot_by_id(&id->buf, (khm_ui_2) attr_id)) == KCDB_BUF_INVALID_SLOT ||
!kcdb_buf_val_exist(&id->buf, slot))
{
code = KHM_ERROR_NOT_FOUND;
\note Not all functions that take a count of bytes support the \a
KCDB_CBSIZE_AUTO value.
*/
-#define KCDB_CBSIZE_AUTO (-1)
+#define KCDB_CBSIZE_AUTO ((khm_size) -1)
/*!
\defgroup kcdb_ident Identities
if(parm_type(e->p1) == KEPT_STRINGT) {
assert((void *) parm_data(e->p1));
PFREE((void*) parm_data(e->p1));
- ZeroMemory(&e->p1, sizeof(e->p1));
}
+ ZeroMemory(&e->p1, sizeof(e->p1));
+
if(parm_type(e->p2) == KEPT_STRINGT) {
assert((void *) parm_data(e->p2));
PFREE((void*) parm_data(e->p2));
- ZeroMemory(&e->p2, sizeof(e->p2));
}
+ ZeroMemory(&e->p2, sizeof(e->p2));
+
if(parm_type(e->p3) == KEPT_STRINGT) {
assert((void *) parm_data(e->p3));
PFREE((void*) parm_data(e->p3));
- ZeroMemory(&e->p3, sizeof(e->p3));
}
+ ZeroMemory(&e->p3, sizeof(e->p3));
+
if(parm_type(e->p4) == KEPT_STRINGT) {
assert((void *) parm_data(e->p4));
PFREE((void*) parm_data(e->p4));
- ZeroMemory(&e->p4, sizeof(e->p4));
}
+ ZeroMemory(&e->p4, sizeof(e->p4));
}
static void
EnterCriticalSection(&cs_error);
assert(IS_KHERR_EVENT(e));
+#ifdef DEBUG
+ assert(LNEXT(e) == NULL);
+ assert(LPREV(e) == NULL);
+#endif
#ifdef DEBUG_CONTEXT
- kherr_debug_printf(L"Freeing event 0x%x\n", e);
if (!(e->flags & KHERR_RF_STR_RESOLVED))
resolve_event_strings(e);
- if (e->short_desc)
- kherr_debug_printf(L" Desc(S):[%s]\n", e->short_desc);
- if (e->long_desc)
- kherr_debug_printf(L" Desc(L):[%s]\n", e->long_desc);
+
+ if (e->short_desc && e->long_desc) {
+ kherr_debug_printf(L"E:%s (%s)\n", e->short_desc, e->long_desc);
+ } else if (e->short_desc) {
+ kherr_debug_printf(L"E:%s\n", e->short_desc);
+ } else if (e->long_desc) {
+ kherr_debug_printf(L"E:%s\n", e->long_desc);
+ } else {
+ kherr_debug_printf(L"E:[No description for event 0x%p]\n", e);
+ }
+
if (e->suggestion)
kherr_debug_printf(L" Suggest:[%s]\n", e->suggestion);
if (e->facility)
assert(IS_KHERR_CTX(c));
assert(IS_KHERR_EVENT(e));
+#ifdef DEBUG
+ assert(LPREV(e) == NULL && LNEXT(e) == NULL);
+#endif
EnterCriticalSection(&cs_error);
te = QBOTTOM(c);
}
static void
-arg_from_param(DWORD_PTR ** parm, kherr_param p)
+va_arg_from_param(va_list * parm, kherr_param p)
{
- int t;
-
- if (p.type != KEPT_NONE) {
- t = parm_type(p);
- if (t == KEPT_INT32 ||
- t == KEPT_UINT32 ||
- t == KEPT_STRINGC ||
- t == KEPT_STRINGT ||
- t == KEPT_PTR) {
-
- *(*parm)++ = (DWORD_PTR) parm_data(p);
-
- } else if (t == KEPT_INT64 ||
- t == KEPT_UINT64) {
- *(*parm)++ = (DWORD_PTR) parm_data(p) & 0xffffffff;
- *(*parm)++ = (DWORD_PTR) (parm_data(p) >> 32) & 0xffffffff;
- } else
- *(*parm)++ = 0;
+ int t = parm_type(p);
+
+ khm_int32 * pi;
+ wchar_t ** ps;
+ void ** pptr;
+ khm_int64 * pli;
+
+ if (t != KEPT_NONE) {
+ switch (t) {
+ case KEPT_INT32:
+ case KEPT_UINT32:
+ pi = (khm_int32 *)(*parm);
+ va_arg(*parm, khm_int32);
+ *pi = (khm_int32) parm_data(p);
+ break;
+
+ case KEPT_STRINGC:
+ case KEPT_STRINGT:
+ ps = (wchar_t **) (*parm);
+ va_arg(*parm, wchar_t *);
+ *ps = (wchar_t *) parm_data(p);
+ break;
+
+ case KEPT_PTR:
+ pptr = (void **) (*parm);
+ va_arg(*parm, void *);
+ *pptr = (void *) parm_data(p);
+ break;
+
+ case KEPT_INT64:
+ case KEPT_UINT64:
+ pli = (khm_int64 *) (*parm);
+ va_arg(*parm, khm_int64);
+ *pli = (khm_int64) parm_data(p);
+ break;
+
+#ifdef DEBUG
+ default:
+ assert(FALSE);
+#endif
+ }
}
}
-/* The 'buf' parameter MUST point to a DWORD_PTR[8] array */
static void
-args_from_event(DWORD_PTR * buf, kherr_event * e)
+va_args_from_event(va_list args, kherr_event * e, khm_size cb)
{
- arg_from_param(&buf, e->p1);
- arg_from_param(&buf, e->p2);
- arg_from_param(&buf, e->p3);
- arg_from_param(&buf, e->p4);
-}
+ ZeroMemory(args, cb);
-#ifdef _WIN64
-# error resolve_string_resource() does not work on 64 bit architectures
-#endif
+ va_arg_from_param(&args, e->p1);
+ va_arg_from_param(&args, e->p2);
+ va_arg_from_param(&args, e->p3);
+ va_arg_from_param(&args, e->p4);
+}
static void
resolve_string_resource(kherr_event * e,
const wchar_t ** str,
+ va_list vl,
khm_int32 if_flag,
khm_int32 or_flag)
{
*str = NULL;
else {
wchar_t * s;
- DWORD_PTR args[8];
-
- args_from_event(args, e);
- chars = FormatMessage(FORMAT_MESSAGE_FROM_STRING |
- FORMAT_MESSAGE_ARGUMENT_ARRAY,
- tfmt,
- 0,
- 0,
- tbuf,
- ARRAYLENGTH(tbuf),
- (va_list *) args);
+ chars = FormatMessage(FORMAT_MESSAGE_FROM_STRING, tfmt,
+ 0, 0, tbuf, ARRAYLENGTH(tbuf), &vl);
if (chars == 0) {
*str = NULL;
}
}
-#ifdef _WIN64
-# error resolve_msg_resource() does not work on 64 bit architectures
-#endif
-
static void
resolve_msg_resource(kherr_event * e,
const wchar_t ** str,
+ va_list vl,
khm_int32 if_flag,
khm_int32 or_flag)
{
wchar_t tbuf[KHERR_MAXCCH_STRING];
size_t chars = 0;
size_t bytes = 0;
- DWORD_PTR args[8];
if(e->flags & if_flag) {
if(e->h_module != NULL) {
- args_from_event(args, e);
- chars = FormatMessage(FORMAT_MESSAGE_FROM_HMODULE |
- FORMAT_MESSAGE_ARGUMENT_ARRAY,
+ chars = FormatMessage(FORMAT_MESSAGE_FROM_HMODULE,
(LPCVOID) e->h_module,
(DWORD)(DWORD_PTR) *str,
0,
tbuf,
ARRAYLENGTH(tbuf),
- (va_list *) args);
+ &vl);
}
if(e->h_module == NULL || chars == 0) {
}
}
-#ifdef _WIN64
-# error resolve_string() does not work on 64 bit architectures
-#endif
-
static void
resolve_string(kherr_event * e,
const wchar_t ** str,
+ va_list vl,
khm_int32 mask,
khm_int32 free_if,
khm_int32 or_flag)
wchar_t tbuf[KHERR_MAXCCH_STRING];
size_t chars;
size_t bytes;
- DWORD_PTR args[8];
if (((e->flags & mask) == 0 ||
- (e->flags & mask) == free_if) &&
+ (e->flags & mask) == free_if) &&
*str != NULL) {
- args_from_event(args, e);
- chars = FormatMessage(FORMAT_MESSAGE_FROM_STRING |
- FORMAT_MESSAGE_ARGUMENT_ARRAY,
+ chars = FormatMessage(FORMAT_MESSAGE_FROM_STRING,
(LPCVOID) *str,
0,
0,
tbuf,
ARRAYLENGTH(tbuf),
- (va_list *) args);
+ &vl);
if ((e->flags & mask) == free_if) {
PFREE((void *) *str);
void
resolve_event_strings(kherr_event * e)
{
- resolve_string(e, &e->short_desc,
+ DWORD_PTR args[8];
+ va_list vl = (va_list) args;
+
+ va_args_from_event(vl, e, sizeof(args));
+
+ resolve_string(e, &e->short_desc, vl,
KHERR_RFMASK_SHORT_DESC,
KHERR_RF_FREE_SHORT_DESC,
KHERR_RF_FREE_SHORT_DESC);
- resolve_string(e, &e->long_desc,
+ resolve_string(e, &e->long_desc, vl,
KHERR_RFMASK_LONG_DESC,
KHERR_RF_FREE_LONG_DESC,
KHERR_RF_FREE_LONG_DESC);
- resolve_string(e, &e->suggestion,
+ resolve_string(e, &e->suggestion, vl,
KHERR_RFMASK_SUGGEST,
KHERR_RF_FREE_SUGGEST,
KHERR_RF_FREE_SUGGEST);
- resolve_string_resource(e, &e->short_desc,
+ resolve_string_resource(e, &e->short_desc, vl,
KHERR_RF_RES_SHORT_DESC,
KHERR_RF_FREE_SHORT_DESC);
- resolve_string_resource(e, &e->long_desc,
- KHERR_RF_RES_LONG_DESC,
+ resolve_string_resource(e, &e->long_desc, vl,
+ KHERR_RF_RES_LONG_DESC,
KHERR_RF_FREE_LONG_DESC);
- resolve_string_resource(e, &e->suggestion,
- KHERR_RF_RES_SUGGEST,
+ resolve_string_resource(e, &e->suggestion, vl,
+ KHERR_RF_RES_SUGGEST,
KHERR_RF_FREE_SUGGEST);
- resolve_msg_resource(e, &e->short_desc,
- KHERR_RF_MSG_SHORT_DESC,
+ resolve_msg_resource(e, &e->short_desc, vl,
+ KHERR_RF_MSG_SHORT_DESC,
KHERR_RF_FREE_SHORT_DESC);
- resolve_msg_resource(e, &e->long_desc,
- KHERR_RF_MSG_LONG_DESC,
+ resolve_msg_resource(e, &e->long_desc, vl,
+ KHERR_RF_MSG_LONG_DESC,
KHERR_RF_FREE_LONG_DESC);
- resolve_msg_resource(e, &e->suggestion,
- KHERR_RF_MSG_SUGGEST,
+ resolve_msg_resource(e, &e->suggestion, vl,
+ KHERR_RF_MSG_SUGGEST,
KHERR_RF_FREE_SUGGEST);
/* get rid of dangling reference now that we have done everything
then only the first part of the string that fits within the limit
is duplicated.
- The resulign ::kherr_param must be passed in to kherr_report().
+ The resulting ::kherr_param must be passed in to kherr_report().
The event logging framework will free the duplicated string once
the data is no longer required.
*/
EnterCriticalSection(&cs_kmm);
m->h_resource = h;
- m->lcid_resource = l->language;
+ m->lcid_resource = (WORD) l->language;
LeaveCriticalSection(&cs_kmm);
return TRUE;
EnterCriticalSection(&cs_kmm);
m->h_resource = m->h_module;
- m->lcid_resource = l->language;
+ m->lcid_resource = (WORD) l->language;
LeaveCriticalSection(&cs_kmm);
return TRUE;
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);
if(!VerQueryValue(m->version_info,
L"\\VarFileInfo\\Translation",
(LPVOID*) &languages,
- &cb)) {
+ &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) (cb / sizeof(*languages));
+ n_languages = (int) (c / sizeof(*languages));
/* Try searching for the user's default language first */
lang = GetUserDefaultLangID();
languages[i].codepage);
if (!VerQueryValue(m->version_info,
- resname, (LPVOID *) &r, &cb)) {
+ resname, (LPVOID *) &r, &c)) {
rv = KHM_ERROR_INVALID_PARAM;
_report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING,
_cstr(TEXT(NIMV_MODULE)));
goto _cleanup;
}
- if (cb > KMM_MAXCB_NAME ||
+ 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,
languages[i].codepage);
if (!VerQueryValue(m->version_info,
- resname, (LPVOID *) &r, &cb)) {
+ resname, (LPVOID *) &r, &c)) {
rv = KHM_ERROR_INVALID_PARAM;
_report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING,
_cstr(TEXT(NIMV_APIVER)));
goto _cleanup;
}
- if (cb > KMM_MAXCB_NAME ||
+ 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,
languages[i].codepage);
if (!VerQueryValue(m->version_info,
- resname, (LPVOID *) &r, &cb)) {
+ resname, (LPVOID *) &r, &c)) {
rv = KHM_ERROR_INVALID_PARAM;
_report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING,
_cstr(L"FileDescription"));
goto _cleanup;
}
- if (cb > KMM_MAXCB_DESC ||
+ 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,
languages[i].codepage);
if (!VerQueryValue(m->version_info,
- resname, (LPVOID *) &r, &cb)) {
+ resname, (LPVOID *) &r, &c)) {
rv = KHM_ERROR_INVALID_PARAM;
_report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING,
_cstr(TEXT(NIMV_SUPPORT)));
goto _cleanup;
}
- if (cb > KMM_MAXCB_SUPPORT ||
+ 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,
languages[i].codepage);
if (!VerQueryValue(m->version_info,
- resname, (LPVOID *) &r, &cb)) {
+ resname, (LPVOID *) &r, &c)) {
rv = KHM_ERROR_INVALID_PARAM;
_report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING,
_cstr(L"LegalCopyright"));
goto _cleanup;
}
- if (cb > KMM_MAXCB_SUPPORT ||
+ 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,
if (!VerQueryValue(m->version_info,
L"\\",
- (LPVOID *) &vff,
- &cb) ||
- cb != sizeof(*vff)) {
+ (LPVOID *) &vff, &c) ||
+ c != sizeof(*vff)) {
rv = KHM_ERROR_INVALID_PARAM;
_report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING,
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
- * Copyright (c) 2006 Secure Endpoints Inc.
+ * 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
kmq_unsubscribe(KMSG_SYSTEM, kmmint_reg_cb);
ExitThread(0);
- /* not reached */
- return 0;
}
/*! \internal
p->tid_thread = GetCurrentThreadId();
- if (IsBadCodePtr(p->p.msg_proc)) {
- _report_mr0(KHERR_WARNING, MSG_PB_INVALID_CODE_PTR);
- rv = KHM_ERROR_INVALID_PARAM;
- } else {
- rv = (*p->p.msg_proc)(KMSG_SYSTEM, KMSG_SYSTEM_INIT,
- 0, (void *) &(p->p));
- _report_mr1(KHERR_INFO, MSG_PB_INIT_RV, _int32(rv));
- }
+ 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)) {
TlsSetValue(tls_kmm, (LPVOID) 0);
ExitThread(rv);
-
- /* not reached */
- return rv;
}
/*! \internal
}
}
- if(khc_read_string(csp_mod, L"ImagePath", NULL, &sz) ==
+ 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, L"ImagePath", m->path, &sz);
+ khc_read_string(csp_mod, KMM_VALNAME_IMAGEPATH, m->path, &sz);
} else {
_report_mr0(KHERR_ERROR, MSG_IM_NOT_REGISTERED);
#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);
s,
s->type,
(s->rcpt_type == KMQ_RCPTTYPE_CB)?"CALLBACK":"HWND",
- (s->rcpt_type == KMQ_RCPTTYPE_CB) ? (void *) s->recipient.cb: (void *) s->recipient.hwnd,
+ (s->rcpt_type == KMQ_RCPTTYPE_CB)? s->recipient.cb: (void *) s->recipient.hwnd,
s->queue);
s = LNEXT(s);
the message queue. */
m->refcount++;
m->nSent++;
- if (IsBadCodePtr(s->recipient.cb)) {
- rv = KHM_ERROR_INVALID_OPERATION;
- } else {
- rv = s->recipient.cb(m->type, m->subtype,
- m->uparam, m->vparam);
- }
+ rv = s->recipient.cb(m->type, m->subtype,
+ m->uparam, m->vparam);
m->refcount--;
if(KHM_SUCCEEDED(rv))
m->nCompleted++;
LeaveCriticalSection(&cs_compl);
ExitThread(0);
-
- /* not reached */
- return 0;
}
int kmqint_call_completion_handler(kmq_msg_completion_handler h,
imp_rv = LoadFuncs(SECUR32_DLL, lsa_fi, &hSecur32, 0, 1, 1, 1);
CKRV(SECUR32_DLL);
+#ifndef _WIN64
imp_rv = LoadFuncs(KRB524_DLL, k524_fi, &hKrb524, 0, 1, 1, 1);
CKRV(KRB524_DLL);
+#endif
imp_rv = LoadFuncs(PROFILE_DLL, profile_fi, &hProfile, 0, 1, 0, 0);
CKRV(PROFILE_DLL);
FARPROC em,
FARPROC etn)
{
- (FARPROC)Lcom_err=ce;
- (FARPROC)Lerror_message=em;
- (FARPROC)Lerror_table_name=etn;
+ Lcom_err = (int (*)(LPSTR,long,LPSTR,...)) ce;
+ Lerror_message = (LPSTR (*)(long)) em;
+ Lerror_table_name = (LPSTR (*)(long)) etn;
}
///////////////////////////////////////////////////////////////////////////////
+#ifdef _WIN64
+#define CCAPI_DLL "krbcc64.dll"
+#define KRBCC32_DLL "krbcc64.dll"
+#else
#define CCAPI_DLL "krbcc32.dll"
#define KRBCC32_DLL "krbcc32.dll"
+#endif
#define SERVICE_DLL "advapi32.dll"
#define SECUR32_DLL "secur32.dll"
-#define PROFILE_DLL "xpprof32.dll"
//////////////////////////////////////////////////////////////////////////////
CHAR krbrealm_path[MAX_PATH];
CHAR ticketName[MAX_PATH];
char * pticketName;
- unsigned int krb_path_sz = sizeof(krb_path);
- unsigned int krbrealm_path_sz = sizeof(krbrealm_path);
+ size_t krb_path_sz = sizeof(krb_path);
+ size_t krbrealm_path_sz = sizeof(krbrealm_path);
khm_size cbsize;
d = PMALLOC(sizeof(*d));
StringCchCopyA(confname, szConfname, krbConFile);
} else if (hKrb4) {
- unsigned int size = szConfname;
+ size_t size = szConfname;
memset(confname, '\0', szConfname);
if (!pkrb_get_krbconf2(confname, &size)) {
GetWindowsDirectoryA(confname,szConfname);
{
if (i < sizeof(buf)) {
if (c == '\n') {
- buf[i] = '\0';
- return i;
+ buf[i] = '\0';
+ return i;
} else {
- buf[i] = c;
+ buf[i] = (char)c;
}
} else {
if (c == '\n') {
#include<strsafe.h>
+#pragma warning(disable: 4204 4221)
+
typedef struct tag_k5_realm_kdc {
wchar_t name[K5_MAXCCH_HOST];
khm_boolean admin; /* admin server? */
(LPARAM) d->realms[i].realm);
}
- SendMessage(hw, CB_SELECTSTRING, -1,
+ SendMessage(hw, CB_SELECTSTRING, (WPARAM) -1,
(LPARAM) d->def_realm);
SetDlgItemText(hwnd, IDC_CFG_DEFREALM, d->def_realm);
SendDlgItemMessage(hwnd, IDC_CFG_DEFREALM, CB_LIMITTEXT,
SendMessage(hw, CB_SETCURSEL, 0, d->lsa_import);
t = importopts;
SendMessage(hw, CB_GETLBTEXT, d->lsa_import,(LPARAM) t);
- SendMessage(hw, CB_SELECTSTRING, -1, (LPARAM) t);
+ SendMessage(hw, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) t);
}
break;
d->public_ip = 0;
cb = sizeof(d->ccache);
- rv = khc_read_string(csp_ident, L"DefaultCCName", d->ccache, &cb);
- if (KHM_FAILED(rv) || cb <= sizeof(wchar_t)) {
- cb = sizeof(d->ccache);
- if (KHM_FAILED(kcdb_identity_get_attr(d->ident, attr_id_krb5_ccname,
- NULL, d->ccache, &cb)))
- ZeroMemory(d->ccache, sizeof(d->ccache));
- }
+ rv = khm_krb5_get_identity_default_ccache(d->ident, d->ccache, &cb);
+
+#ifdef DEBUG
+ assert(KHM_SUCCEEDED(rv));
+#endif
khui_tracker_initialize(&d->tc_life);
d->tc_life.current = d->life;
khm_size cb;
khm_int32 rv;
khm_boolean b;
+ khm_boolean applied = FALSE;
DWORD dwaddress = 0;
if (!k5_id_is_mod(hw, d))
rv = kcdb_identity_get_config(d->ident, KHM_FLAG_CREATE, &csp_idroot);
if (KHM_SUCCEEDED(rv)) {
khc_open_space(csp_idroot, CSNAME_KRB5CRED,
- KHM_FLAG_CREATE,
+ KHM_FLAG_CREATE | KCONF_FLAG_WRITEIFMOD,
&csp_ident);
}
if (d->life != d->tc_life.current) {
d->life = d->tc_life.current;
khc_write_int32(csp_ident, L"DefaultLifetime", (khm_int32) d->life);
+ applied = TRUE;
}
if (d->renew_life != d->tc_renew.current) {
d->renew_life = d->tc_renew.current;
khc_write_int32(csp_ident, L"DefaultRenewLifetime", (khm_int32) d->renew_life);
+ applied = TRUE;
}
b = (IsDlgButtonChecked(hw, IDC_CFG_RENEW) == BST_CHECKED);
if (b != d->renewable) {
d->renewable = b;
khc_write_int32(csp_ident, L"Renewable", (khm_int32) b);
+ applied = TRUE;
}
b = (IsDlgButtonChecked(hw, IDC_CFG_FORWARD) == BST_CHECKED);
if (b != d->forwardable) {
d->forwardable = b;
khc_write_int32(csp_ident, L"Forwardable", (khm_int32) b);
+ applied = TRUE;
}
b = (IsDlgButtonChecked(hw, IDC_CFG_ADDRESSLESS) == BST_CHECKED);
if (b != d->addressless) {
d->addressless = b;
khc_write_int32(csp_ident, L"Addressless", (khm_int32) b);
+ applied = TRUE;
}
SendDlgItemMessage(hw, IDC_CFG_PUBLICIP, IPM_GETADDRESS,
if (dwaddress != d->public_ip) {
d->public_ip = dwaddress;
khc_write_int32(csp_ident, L"PublicIP", (khm_int32) dwaddress);
+ applied = TRUE;
}
GetDlgItemText(hw, IDC_CFG_CCACHE, ccache, ARRAYLENGTH(ccache));
if (SUCCEEDED(StringCbLength(ccache, sizeof(ccache), &cb)) &&
- _wcsicmp(ccache, d->ccache)) {
- khc_write_string(csp_ident, L"DefaultCCName", ccache);
- StringCbCopy(d->ccache, sizeof(d->ccache), ccache);
+ cb > sizeof(wchar_t)) {
+
+ if (wcscmp(ccache, d->ccache)) {
+ khc_write_string(csp_ident, L"DefaultCCName", ccache);
+ StringCbCopy(d->ccache, sizeof(d->ccache), ccache);
+ applied = TRUE;
+ }
+
} else {
khc_remove_value(csp_ident, L"DefaultCCName", KCONF_FLAG_USER);
+ d->ccache[0] = L'\0';
+ applied = TRUE;
}
if (csp_ident)
khc_close_space(csp_ident);
khui_cfg_set_flags_inst(&d->cfg,
- KHUI_CNFLAG_APPLIED,
+ (applied ? KHUI_CNFLAG_APPLIED : 0),
KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED);
}
code = pkrb5_cc_resolve(ctx, ccache, &cc);
} else {
khm_handle identity = NULL;
- khm_handle csp_ident = NULL;
- khm_handle csp_k5 = NULL;
wchar_t idname[KCDB_IDENT_MAXCCH_NAME];
- wchar_t wccname[MAX_PATH];
char ccname[MAX_PATH];
char * pccname = principal_name;
khm_size cb;
idname[0] = L'\0';
AnsiStrToUnicode(idname, sizeof(idname), principal_name);
- cb = sizeof(wccname);
+ cb = sizeof(ccname);
if (KHM_SUCCEEDED(kcdb_identity_create(idname, 0, &identity)) &&
+ KHM_SUCCEEDED(khm_krb5_get_identity_default_ccacheA(identity, ccname, &cb))) {
- KHM_SUCCEEDED(kcdb_identity_get_config(identity, 0, &csp_ident)) &&
-
- KHM_SUCCEEDED(khc_open_space(csp_ident, CSNAME_KRB5CRED, 0,
- &csp_k5)) &&
-
- KHM_SUCCEEDED(khc_read_string(csp_k5, L"DefaultCCName",
- wccname, &cb)) &&
-
- cb > sizeof(wchar_t)) {
-
- _reportf(L"Using DefaultCCName [%s] from identity", wccname);
-
- UnicodeStrToAnsi(ccname, sizeof(ccname), wccname);
pccname = ccname;
+
}
- if (csp_k5)
- khc_close_space(csp_k5);
- if (csp_ident)
- khc_close_space(csp_ident);
if (identity)
kcdb_identity_release(identity);
krb5_cc_cursor cursor=0;
krb5_principal princ = 0;
khm_handle ident = NULL;
- wchar_t wname[KCDB_IDENT_MAXCCH_NAME];
- char cname[KCDB_IDENT_MAXCCH_NAME];
+ wchar_t idname[KCDB_IDENT_MAXCCH_NAME];
+ char ccname[MAX_PATH];
char *cache_name = NULL;
char *princ_name = NULL;
BOOL rc = FALSE;
if (code = pkrb5_unparse_name(kcontext, princ, &princ_name))
goto cleanup;
- AnsiStrToUnicode(wname, sizeof(wname), princ_name);
+ AnsiStrToUnicode(idname, sizeof(idname), princ_name);
- kherr_reportf(L"Unparsed name [%s]", wname);
+ kherr_reportf(L"Unparsed name [%s]", idname);
/* see if we have to match a specific principal */
if (match_princ != NULL) {
PFREE(wdefrealm);
}
- if (KHM_SUCCEEDED(kcdb_identity_create(wname,
+ if (KHM_SUCCEEDED(kcdb_identity_create(idname,
KCDB_IDENT_FLAG_CREATE,
&ident))) {
- khm_handle idconfig = NULL;
- khm_handle k5config = NULL;
khm_size cb;
- wname[0] = L'\0';
-
- kcdb_identity_get_config(ident, KHM_FLAG_CREATE, &idconfig);
- if (idconfig == NULL)
- goto _done_checking_config;
+ cb = sizeof(ccname);
- khc_open_space(idconfig, CSNAME_KRB5CRED, KHM_FLAG_CREATE, &k5config);
- if (k5config == NULL)
- goto _done_checking_config;
+ khm_krb5_get_identity_default_ccacheA(ident, ccname, &cb);
- cb = sizeof(wname);
- khc_read_string(k5config,
- L"DefaultCCName",
- wname, &cb);
-
- _done_checking_config:
-
- if (idconfig)
- khc_close_space(idconfig);
- if (k5config)
- khc_close_space(k5config);
-
- if (wname[0]) {
- UnicodeStrToAnsi(cname, sizeof(cname), wname);
- } else {
- StringCbPrintfA(cname, sizeof(cname), "API:%s", princ_name);
- }
-
- cache_name = cname;
+ cache_name = ccname;
} else {
/* the identity could not be created. we just use the
name of the principal as the ccache name. */
- StringCbPrintfA(cname, sizeof(cname), "API:%s", princ_name);
- cache_name = cname;
+#ifdef DEBUG
+ assert(FALSE);
+#endif
+ kherr_reportf(L"Failed to create identity");
+ StringCbPrintfA(ccname, sizeof(ccname), "API:%s", princ_name);
+ cache_name = ccname;
}
kherr_reportf(L"Resolving target cache [%S]\n", cache_name);
StringCchCopyA(confname, szConfname, krbConFile);
}
else if (hKrb4) {
- unsigned int size = szConfname;
+ size_t size = szConfname;
memset(confname, '\0', szConfname);
if (!pkrb_get_krbconf2(confname, &size))
{ // Error has happened
buf[i] = '\0';
return i;
} else {
- buf[i] = c;
+ buf[i] = (char) c;
}
} else {
if (c == '\n') {
wchar_t * d;
if (!khm_get_krb4_con_file(krb_conf,sizeof(krb_conf)) &&
-#if _MSC_VER >= 1400
+#if _MSC_VER >= 1400 && __STDC_WANT_SECURE_LIB__
!fopen_s(&file, krb_conf, "rt")
#else
(file = fopen(krb_conf, "rt"))
return code;
}
+khm_int32
+khm_krb5_get_identity_default_ccache(khm_handle ident, wchar_t * buf, khm_size * pcb) {
+ khm_handle csp_id = NULL;
+ khm_int32 rv = KHM_ERROR_SUCCESS;
+
+ rv = khm_krb5_get_identity_config(ident, 0, &csp_id);
+
+ if (KHM_SUCCEEDED(rv))
+ rv = khc_read_string(csp_id, L"DefaultCCName", buf, pcb);
+
+ if (KHM_FAILED(rv) && rv != KHM_ERROR_TOO_LONG) {
+ /* we need to figure out the default ccache from the principal
+ name */
+ wchar_t idname[KCDB_IDENT_MAXCCH_NAME];
+ wchar_t ccname[MAX_PATH];
+ khm_size cb;
+
+ cb = sizeof(idname);
+ kcdb_identity_get_name(ident, idname, &cb);
+ StringCbCopy(ccname, sizeof(ccname), idname);
+ khm_krb5_canon_cc_name(ccname, sizeof(ccname));
+ StringCbLength(ccname, sizeof(ccname), &cb);
+
+ _reportf(L"Setting CCache [%s] for identity [%s]", ccname, idname);
+
+ if (buf && *pcb >= cb) {
+ StringCbCopy(buf, *pcb, ccname);
+ *pcb = cb;
+ rv = KHM_ERROR_SUCCESS;
+ } else {
+ *pcb = cb;
+ rv = KHM_ERROR_TOO_LONG;
+ }
+ } else if (KHM_SUCCEEDED(rv)) {
+ wchar_t idname[KCDB_IDENT_MAXCCH_NAME];
+ khm_size cb;
+
+ cb = sizeof(idname);
+ kcdb_identity_get_name(ident, idname, &cb);
+
+ _reportf(L"Found CCache [%s] for identity [%s]", buf, idname);
+ }
+
+ if (csp_id != NULL)
+ khc_close_space(csp_id);
+
+ return rv;
+}
+
+khm_int32
+khm_krb5_get_identity_default_ccacheA(khm_handle ident, char * buf, khm_size * pcb) {
+ wchar_t wccname[MAX_PATH];
+ khm_size cbcc;
+ khm_int32 rv;
+
+ cbcc = sizeof(wccname);
+ rv = khm_krb5_get_identity_default_ccache(ident, wccname, &cbcc);
+
+ if (KHM_SUCCEEDED(rv)) {
+ cbcc = sizeof(char) * cbcc / sizeof(wchar_t);
+ if (buf == NULL || *pcb < cbcc) {
+ *pcb = cbcc;
+ rv = KHM_ERROR_TOO_LONG;
+ } else {
+ UnicodeStrToAnsi(buf, *pcb, wccname);
+ *pcb = cbcc;
+ rv = KHM_ERROR_SUCCESS;
+ }
+ }
+
+ return rv;
+}
+
khm_int32
khm_krb5_get_identity_params(khm_handle ident, k5_params * p) {
khm_int32
khm_krb5_get_identity_params(khm_handle ident, k5_params * p);
+khm_int32
+khm_krb5_get_identity_default_ccache(khm_handle ident, wchar_t * buf, khm_size * pcb);
+
+khm_int32
+khm_krb5_get_identity_default_ccacheA(khm_handle ident, char * buf, khm_size * pcb);
+
/* Utility */
wchar_t *
return;
if (c != s && ((khm_size)(c - s)) < cch) {
-#if _MSC_VER >= 1400
+#if _MSC_VER >= 1400 && __STDC_WANT_SECURE_LIB__
wmemmove_s(s, cch, c, cch - ((khm_size)(c - s)));
#else
memmove(s, c, (cch - ((khm_size)(c - s))) * sizeof(wchar_t));
_exit:
ExitThread(rv);
-
- /* not reached */
- return rv;
}
khm_int32
/*
- * Copyright (c) 2006 Secure Endpoints Inc.
+ * 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
_reportf(L" g_fjob.state = %d", g_fjob.state);
_reportf(L" g_fjob.prompt_set= %d", g_fjob.prompt_set);
_reportf(L" g_fjob.valid_principal = %d", (int) g_fjob.valid_principal);
+ _reportf(L" g_fjob.ccache = [%s]", g_fjob.ccache);
#endif
/* If we don't know if we have a valid principal, we
}
void
-k5_write_dlg_params(k5_dlg_data * d, khm_handle identity)
+k5_write_dlg_params(k5_dlg_data * d, khm_handle identity, char * ccache)
{
k5_params p;
khm_krb5_set_identity_params(identity, &p);
+ /* if we used a FILE: ccache, we should add it to FileCCList.
+ Otherwise the tickets are not going to get listed. */
+ do {
+ wchar_t thisccache[MAX_PATH];
+ wchar_t * ccpath;
+ khm_size cb_cc;
+ wchar_t * mlist = NULL;
+ khm_size cb_mlist;
+ khm_int32 rv;
+ khm_size t;
+
+ if (ccache != NULL &&
+ strncmp(ccache, "FILE:", 5) != 0)
+ break;
+
+ if (ccache == NULL) {
+ cb_cc = sizeof(thisccache);
+ rv = khm_krb5_get_identity_default_ccache(identity, thisccache, &cb_cc);
+#ifdef DEBUG
+ assert(KHM_SUCCEEDED(rv));
+#endif
+ } else {
+ thisccache[0] = L'\0';
+ AnsiStrToUnicode(thisccache, sizeof(thisccache), ccache);
+ }
+
+ if (wcsncmp(thisccache, L"FILE:", 5))
+ break;
+
+ /* the FileCCList is a list of paths. We have to strip out
+ the FILE: prefix. */
+ ccpath = thisccache + 5;
+
+ _reportf(L"Checking if ccache [%s] is in FileCCList", ccpath);
+
+ StringCbLength(ccpath, sizeof(thisccache) - sizeof(wchar_t) * 5, &cb_cc);
+ cb_cc += sizeof(wchar_t);
+
+ rv = khc_read_multi_string(csp_params, L"FileCCList", NULL, &cb_mlist);
+ if (rv == KHM_ERROR_TOO_LONG && cb_mlist > sizeof(wchar_t) * 2) {
+ cb_mlist += cb_cc;
+ mlist = PMALLOC(cb_mlist);
+
+ t = cb_mlist;
+ rv = khc_read_multi_string(csp_params, L"FileCCList", mlist, &t);
+#ifdef DEBUG
+ assert(KHM_SUCCEEDED(rv));
+#endif
+ if (KHM_FAILED(rv))
+ goto failed_filecclist;
+
+ if (multi_string_find(mlist, ccpath, 0) == NULL) {
+ t = cb_mlist;
+ multi_string_append(mlist, &t, ccpath);
+
+ khc_write_multi_string(csp_params, L"FileCCList", mlist);
+ _reportf(L"Added CCache to list");
+ } else {
+ _reportf(L"The CCache is already in the list");
+ }
+ } else {
+ cb_mlist = cb_cc + sizeof(wchar_t);
+ mlist = PMALLOC(cb_mlist);
+
+ multi_string_init(mlist, cb_mlist);
+ t = cb_mlist;
+ multi_string_append(mlist, &t, ccpath);
+
+ khc_write_multi_string(csp_params, L"FileCCList", mlist);
+
+ _reportf(L"FileCCList was empty. Added CCache");
+ }
+
+ failed_filecclist:
+
+ if (mlist)
+ PFREE(mlist);
+
+ } while(FALSE);
+
/* as in k5_read_dlg_params, once we write the data in, the local
data is no longer dirty */
d->dirty = FALSE;
g_fjob.identity = ident;
g_fjob.prompt_set = 0;
g_fjob.valid_principal = FALSE;
+ g_fjob.ccache = NULL;
g_fjob.retry_if_valid_principal = FALSE;
/* the value for
StringCbCopy(pdlginfo->out.ccache, sizeof(pdlginfo->out.ccache),
pdlginfo->in.ccache);
} else {
+ wchar_t ccache[MAX_PATH];
+
g_fjob.ccache = NULL;
+ size = sizeof(ccache);
- StringCbCopy(pdlginfo->out.ccache, sizeof(pdlginfo->out.ccache),
- idname);
+ khm_krb5_get_identity_default_ccache(ident, ccache, &size);
- khm_krb5_canon_cc_name(pdlginfo->out.ccache,
- sizeof(pdlginfo->out.ccache));
+ StringCbCopy(pdlginfo->out.ccache, sizeof(pdlginfo->out.ccache),
+ ccache);
}
t = khm_get_realm_from_princ(idname);
}
- /* we can't possibly have succeeded without a
- password */
if(g_fjob.code == KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN &&
is_k5_identpro) {
kcdb_identity_set_flags(ident,
msg[0] = L'\0';
switch(g_fjob.code) {
+ case 0:
+ /* we succeeded. This can actually happen if
+ there was an external program that prompted
+ for credentials. */
+ break;
+
case KRB5KDC_ERR_NAME_EXP:
/* principal expired */
LoadString(hResModule, IDS_K5ERR_NAME_EXPIRED,
k5_free_kinit_job();
- if (is_k5_identpro)
- kcdb_identity_set_flags(ident,
- KCDB_IDENT_FLAG_UNKNOWN,
- KCDB_IDENT_FLAG_UNKNOWN);
-
+ if (is_k5_identpro) {
+ if (g_fjob.code == 0)
+ kcdb_identity_set_flags(ident,
+ KCDB_IDENT_FLAG_VALID,
+ KCDB_IDENT_FLAG_VALID);
+ else
+ kcdb_identity_set_flags(ident,
+ KCDB_IDENT_FLAG_UNKNOWN,
+ KCDB_IDENT_FLAG_UNKNOWN);
+ }
} else if(g_fjob.state == FIBER_STATE_KINIT) {
/* this is what we want. Leave the fiber there. */
/* We get back here once the fiber finishes
processing */
- }
#ifdef DEBUG
- else {
+ } else {
assert(FALSE);
- }
#endif
+ }
} else {
/* we weren't in a KINIT state */
if (nc->result == KHUI_NC_RESULT_CANCEL) {
/* g_fjob.code should have the result of the
last kinit attempt. We should leave it
as-is */
- }
#ifdef DEBUG
- else {
+ } else {
/* unknown result */
assert(FALSE);
- }
#endif
+ }
}
/* special case: if there was no password entered, and
assert(nc->n_identities > 0);
assert(nc->identities[0]);
- k5_write_dlg_params(d, nc->identities[0]);
+ k5_write_dlg_params(d, nc->identities[0], g_fjob.ccache);
/* We should also quickly refresh the credentials
so that the identity flags and ccache
obtaining the ticket. */
if (nc->subtype == KMSG_CRED_NEW_CREDS) {
- k5_write_dlg_params(d, nc->identities[0]);
+ k5_write_dlg_params(d, nc->identities[0], NULL);
/* and then update the LRU too */
k5_update_LRU(nc->identities[0]);
_end_thread:
ExitThread(0);
- return 0; /* unreachable */
}
void
} else if (wParam == MAKEWPARAM(IDC_CFG_ITALICS, BN_CLICKED)) {
- d->lf_work.lfItalic =
+ d->lf_work.lfItalic = (BYTE)
(IsDlgButtonChecked(hwnd, IDC_CFG_ITALICS) == BST_CHECKED);
refresh_view(hwnd, d);
/* we need populate the notification action combo box control and
set the current selection to match the default action. */
- if (n_khm_notifier_actions != SendDlgItemMessage(hwnd, IDC_CFG_NOTACTION,
- CB_GETCOUNT, 0, 0)) {
+ if (n_khm_notifier_actions != (khm_size) SendDlgItemMessage(hwnd, IDC_CFG_NOTACTION,
+ CB_GETCOUNT, 0, 0)) {
for (i=0; i < n_khm_notifier_actions; i++) {
int idx;
for (t = info->plugin.reg.dependencies; t && *t;
t = multi_string_next(t)) {
SendDlgItemMessage(hwnd, IDC_CFG_DEPS,
- LB_INSERTSTRING, -1, (LPARAM) t);
+ LB_INSERTSTRING, (WPARAM) -1, (LPARAM) t);
}
if (info->plugin.reg.module)
goto _next_cfg;
}
- khui_menu_insert_action(omenu, -1, action, 0);
+ khui_menu_insert_action(omenu, (khm_size) -1, action, 0);
refresh_menu = TRUE;
}
khm_int32 attr_to_action[KCDB_ATTR_MAX_ID + 1];
-khm_int32 bHideWatermarks = 0;
-
/* forward declarations */
static void
cw_select_row_creds(khui_credwnd_tbl * tbl, int row, int selected);
if (name == NULL) {
LOGFONT lf = {
- -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72), 0, /* width/height */
- 0,0, /* escapement */
+ 0,0,
+ 0,0,
FW_THIN,
FALSE,
FALSE,
FF_SWISS,
L"MS Shell Dlg"};
+ lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72);
+
*pfont = lf;
} else if (!wcscmp(name, L"FontHeader")) {
LOGFONT lf = {
- -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72), 0, /* width/height */
- 0,0, /* escapement */
+ 0,0,
+ 0,0,
FW_THIN,
FALSE,
FALSE,
FF_SWISS,
L"MS Shell Dlg"};
+ lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72);
+
*pfont = lf;
} else if (!wcscmp(name, L"FontHeaderBold")) {
LOGFONT lf = {
- -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72), 0, /* width/height */
- 0,0, /* escapement */
+ 0,0,
+ 0,0,
FW_BOLD,
FALSE,
FALSE,
FF_SWISS,
L"MS Shell Dlg"};
+ lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72);
+
*pfont = lf;
} else if (!wcscmp(name, L"FontNormal")) {
LOGFONT lf = {
- -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72), 0, /* width/height */
- 0,0, /* escapement */
+ 0,0,
+ 0,0,
FW_THIN,
FALSE,
FALSE,
FF_SWISS,
L"MS Shell Dlg"};
+ lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72);
+
*pfont = lf;
} else if (!wcscmp(name, L"FontBold")) {
LOGFONT lf = {
- -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72), 0, /* width/height */
- 0,0, /* escapement */
+ 0,0,
+ 0,0,
FW_BOLD,
FALSE,
FALSE,
FF_SWISS,
L"MS Shell Dlg"};
+ lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72);
+
*pfont = lf;
} else {
&hc_cw)))
return;
- khc_read_int32(hc_cw, L"HideWatermarks", &bHideWatermarks);
-
if(KHM_FAILED(khc_open_space(hc_cw, L"Views", KHM_PERM_READ, &hc_vs)))
goto _exit;
khm_handle hc_themes = NULL;
khm_handle hc_theme = NULL;
- COLORREF bg_s;
- COLORREF bg_normal;
- COLORREF bg_gray;
- COLORREF bg_hdr;
- COLORREF bg_hdr_cred;
- COLORREF bg_hdr_warn;
- COLORREF bg_hdr_crit;
- COLORREF bg_hdr_exp;
-
- COLORREF bg_hdr_s;
- COLORREF bg_hdr_cred_s;
- COLORREF bg_hdr_warn_s;
- COLORREF bg_hdr_crit_s;
- COLORREF bg_hdr_exp_s;
+ COLORREF bg_s = 0;
+ COLORREF bg_normal = 0;
+ COLORREF bg_gray = 0;
+ COLORREF bg_hdr = 0;
+ COLORREF bg_hdr_cred = 0;
+ COLORREF bg_hdr_warn = 0;
+ COLORREF bg_hdr_crit = 0;
+ COLORREF bg_hdr_exp = 0;
+
+ COLORREF bg_hdr_s = 0;
+ COLORREF bg_hdr_cred_s = 0;
+ COLORREF bg_hdr_warn_s = 0;
+ COLORREF bg_hdr_crit_s = 0;
+ COLORREF bg_hdr_exp_s = 0;
cbsize = sizeof(buf);
if (KHM_SUCCEEDED(khc_read_string(hc_cw, L"DefaultTheme", buf, &cbsize)) &&
} else {
#ifdef DEBUG
assert(FALSE);
-#endif
+#endif
}
if (hc_theme)
o->start = n_rows;
o->length = 1;
- o->idx_start = -1;
- o->idx_end = -1;
+ o->idx_start = (khm_size) -1;
+ o->idx_end = (khm_size) -1;
if (grouping[0] == tbl->n_cols - 1)
o->flags |= KHUI_CW_O_NOOUTLINE;
o->flags &= ~KHUI_CW_O_EXPAND;
o->start = n_rows;
o->length = 1;
- o->idx_start = -1;
- o->idx_end = -1;
+ o->idx_start = (khm_size) -1;
+ o->idx_end = (khm_size) -1;
cw_set_tbl_row_header(tbl, n_rows, grouping[0], o);
rlogo.right = r_wnd->right;
rlogo.top = r_wnd->bottom - tbl->kbm_logo_shade.cy;
rlogo.bottom = r_wnd->bottom;
- if (bHideWatermarks) {rie = FALSE;}
- else {rie = IntersectRect(&ri, r_erase, &rlogo);}
+ rie = IntersectRect(&ri, r_erase, &rlogo);
} else {
ZeroMemory(&rlogo, sizeof(rlogo));
ZeroMemory(&ri, sizeof(ri));
cw_wm_paint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
khui_credwnd_tbl * tbl;
- HDC hdc;
+ HDC hdc = NULL;
PAINTSTRUCT ps;
RECT r,rh;
HFONT hf_old = NULL;
khm_get_file_log_path(sizeof(temppath), temppath);
logfile = NULL;
-#if _MSC_VER >= 1400
+#if _MSC_VER >= 1400 && __STDC_WANT_SECURE_LIB__
_wfopen_s(&logfile, temppath, L"w");
#else
logfile = _wfopen(temppath, L"w");
n = 1;
} else if(!_wcsnicmp(start, L"b", c - start)) {
- format_push(s,d, HTW_DEFAULT, FV_BOLD, HTW_DEFAULT);
+ format_push(s,d, HTW_DEFAULT, FV_BOLD, (COLORREF) HTW_DEFAULT);
} else if(!_wcsnicmp(start, L"/b", c - start)) {
format_pop(s);
} else if(!_wcsnicmp(start, L"u", c - start)) {
- format_push(s,d, HTW_DEFAULT, FV_UNDERLINE, HTW_DEFAULT);
+ format_push(s,d, HTW_DEFAULT, FV_UNDERLINE, (COLORREF) HTW_DEFAULT);
} else if(!_wcsnicmp(start, L"/u", c - start)) {
format_pop(s);
} else if(!_wcsnicmp(start, L"i", c - start)) {
- format_push(s,d, HTW_DEFAULT, FV_ITALIC, HTW_DEFAULT);
+ format_push(s,d, HTW_DEFAULT, FV_ITALIC, (COLORREF) HTW_DEFAULT);
} else if(!_wcsnicmp(start, L"/i", c - start)) {
format_pop(s);
} else if(!_wcsnicmp(start, L"large", c - start)) {
- format_push(s,d,-MulDiv(HTW_LARGE_SIZE, d->l_pixel_y, 72), HTW_DEFAULT, HTW_DEFAULT);
+ format_push(s,d,-MulDiv(HTW_LARGE_SIZE, d->l_pixel_y, 72), HTW_DEFAULT, (COLORREF) HTW_DEFAULT);
} else if(!_wcsnicmp(start, L"/large", c - start)) {
format_pop(s);
} else if(!_wcsnicmp(start, L"huge", c - start)) {
- format_push(s,d,-MulDiv(HTW_HUGE_SIZE, d->l_pixel_y, 72), HTW_DEFAULT, HTW_DEFAULT);
+ format_push(s,d,-MulDiv(HTW_HUGE_SIZE, d->l_pixel_y, 72), HTW_DEFAULT, (COLORREF) HTW_DEFAULT);
} else if(!_wcsnicmp(start, L"/huge", c - start)) {
format_pop(s);
} else if(!_wcsnicmp(start, L"center", c - start)) {
lf.lfEscapement = 0;
lf.lfOrientation = 0;
lf.lfWeight = (d->styles[style].variation & FV_BOLD)? FW_BOLD: FW_NORMAL;
- lf.lfItalic = !!(d->styles[style].variation & FV_ITALIC);
- lf.lfUnderline = !!(d->styles[style].variation & FV_UNDERLINE);
- lf.lfStrikeOut = !!(d->styles[style].variation & FV_STRIKEOUT);
+ lf.lfItalic = (BYTE) !!(d->styles[style].variation & FV_ITALIC);
+ lf.lfUnderline = (BYTE) !!(d->styles[style].variation & FV_UNDERLINE);
+ lf.lfStrikeOut = (BYTE) !!(d->styles[style].variation & FV_STRIKEOUT);
lf.lfCharSet = DEFAULT_CHARSET;
lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
else
d->flags &= ~KHUI_HTWND_VSCROLL;
- l = GetWindowLongPtr(hwnd, GWL_STYLE);
+ l = (LONG) GetWindowLongPtr(hwnd, GWL_STYLE);
l &= ~(WS_HSCROLL | WS_VSCROLL);
l |= ((d->flags & KHUI_HTWND_HSCROLL) ? WS_HSCROLL : 0) |
HRESULT hr_coinitialize = S_OK;
+#if defined(DEBUG) && (defined(KH_BUILD_PRIVATE) || defined(KH_BUILD_SPECIAL))
+
+KHMEXP void KHMAPI khcint_dump_handles(FILE * f);
+KHMEXP void KHMAPI perf_dump(FILE * f);
+KHMEXP void KHMAPI kmqint_dump(FILE * f);
+
+#endif
+
void khm_init_gui(void) {
hr_coinitialize = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
{
FILE * f = NULL;
- KHMEXP void KHMAPI khcint_dump_handles(FILE * f);
- KHMEXP void KHMAPI perf_dump(FILE * f);
- KHMEXP void KHMAPI kmqint_dump(FILE * f);
-
-#if _MSC_VER >= 1400
+#if _MSC_VER >= 1400 && __STDC_WANT_SECURE_LIB__
if (fopen_s(&f, "memleak.txt", "w") != 0)
goto done_with_dump;
#else
mii.fMask = MIIM_STATE | MIIM_ID | MIIM_FTYPE;
if (!GetMenuItemInfo(hm, idx, TRUE, &mii) ||
((flags & KHUI_ACTIONREF_SEP) && !(mii.fType & MFT_SEPARATOR)) ||
- (!(flags & KHUI_ACTIONREF_SEP) && mii.wID != act->cmd)) {
+ (!(flags & KHUI_ACTIONREF_SEP) && mii.wID != (WORD) act->cmd)) {
add_action_to_menu(hm, ((flags & KHUI_ACTIONREF_SEP)? NULL : act),
idx, flags);
return 0;
#endif
/* make the call */
- if (!IsBadCodePtr(pcbdata->cb))
- pcbdata->rv = (*pcbdata->cb)(khm_hwnd_main, pcbdata->rock);
- else {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- pcbdata->rv = KHM_ERROR_INVALID_PARAM;
- }
+ pcbdata->rv = (*pcbdata->cb)(khm_hwnd_main, pcbdata->rock);
}
case KHUI_ACTION_VIEW_REFRESH:
khm_cred_refresh();
InvalidateRect(khm_hwnd_main_cred, NULL, FALSE);
- khui_action_trigger(KHUI_ACTION_LAYOUT_RELOAD, NULL); /* Hack causes refresh button to work in Basic view. */
return 0;
case KHUI_ACTION_PASSWD_ID:
/* layout control */
case KHUI_ACTION_LAYOUT_MINI:
+
if (khm_main_wnd_mode == KHM_MAIN_WND_MINI) {
khm_set_main_window_mode(KHM_MAIN_WND_NORMAL);
} else {
return kmq_wm_end(m, rv);
}
- return 0;
case WM_KHUI_ASSIGN_COMMANDLINE_V1:
{
wc.cbWndExtra = 0;
wc.hInstance = khm_hInstance;
wc.hIcon = LoadIcon(khm_hInstance, MAKEINTRESOURCE(IDI_MAIN_APP));
- wc.hCursor = LoadCursor((HINSTANCE) NULL, MAKEINTRESOURCE(IDC_ARROW));
+ wc.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW);
wc.hIconSm = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_MAIN_APP), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
wc.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE);
wc.lpszMenuName = NULL;
wc.cbWndExtra = 0;
wc.hInstance = khm_hInstance;
wc.hIcon = LoadIcon(khm_hInstance, MAKEINTRESOURCE(IDI_MAIN_APP));
- wc.hCursor = LoadCursor((HINSTANCE) NULL, MAKEINTRESOURCE(IDC_ARROW));
+ wc.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW);
wc.hIconSm = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_MAIN_APP), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
wc.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE);
wc.lpszMenuName = NULL;
void khm_unregister_newcredwnd_class(void)
{
- UnregisterClass((LPWSTR) khui_newcredwnd_cls, khm_hInstance);
+ UnregisterClass(MAKEINTATOM(khui_newcredwnd_cls), khm_hInstance);
}
HWND khm_create_newcredwnd(HWND parent, khui_new_creds * c)
POINT pt;
int menu_id;
khui_menu_def * mdef;
- khui_action_ref * act;
+ khui_action_ref * act = NULL;
khm_size i, n;
khm_int32 def_cmd;
if (in_printclient) {
hdc = (HDC) wParam;
+ ZeroMemory(&ps, sizeof(ps));
} else {
hdc = BeginPaint(hwnd, &ps);
}
khui_alert * a;
#ifndef ALERT_STATIC_BACKGROUND
-#define MIX_C(v1, v2, p) (((int)v1) * p + (((int) v2) * (256 - p)))
+#define MIX_C(v1, v2, p) ((COLOR16)(((int)v1) * p + (((int) v2) * (256 - p))))
#define ALPHA 50
if (in_printclient || ps.fErase) {
TRIVERTEX v[2];
v[1].Blue = MIX_C(GetBValue(clr), GetBValue(clr2), ALPHA);
} else {
clr = GetSysColor(COLOR_BTNHIGHLIGHT);
- v[0].Red = ((int)GetRValue(clr)) << 8;
- v[0].Green = ((int)GetGValue(clr)) << 8;
- v[0].Blue = ((int)GetBValue(clr)) << 8;
+ v[0].Red = (COLOR16) ((int)GetRValue(clr)) << 8;
+ v[0].Green = (COLOR16) ((int)GetGValue(clr)) << 8;
+ v[0].Blue = (COLOR16) ((int)GetBValue(clr)) << 8;
clr = GetSysColor(COLOR_BTNFACE);
- v[1].Red = ((int)GetRValue(clr)) << 8;
- v[1].Green = ((int)GetGValue(clr)) << 8;
- v[1].Blue = ((int)GetBValue(clr)) << 8;
+ v[1].Red = (COLOR16) ((int)GetRValue(clr)) << 8;
+ v[1].Green = (COLOR16) ((int)GetGValue(clr)) << 8;
+ v[1].Blue = (COLOR16) ((int)GetBValue(clr)) << 8;
}
gr.UpperLeft = 0;
wcx.cbWndExtra = DLGWINDOWEXTRA + sizeof(LONG_PTR);
wcx.hInstance = khm_hInstance;
wcx.hIcon = LoadIcon(khm_hInstance, MAKEINTRESOURCE(IDI_MAIN_APP));
- wcx.hCursor = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
+ wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
wcx.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wcx.lpszMenuName = NULL;
wcx.lpszClassName = KHUI_ALERTER_CLASS;
wcx.cbWndExtra = sizeof(LONG_PTR);
wcx.hInstance = khm_hInstance;
wcx.hIcon = NULL;
- wcx.hCursor = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
+ wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
wcx.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wcx.lpszMenuName = NULL;
wcx.lpszClassName = KHUI_ALERTBIN_CLASS;
for (i=0; i<n; i++) {
if (src->items[i].flags & KHUI_ACTIONREF_PACTION) {
- khui_menu_insert_paction(d, -1, src->items[i].p_action, src->items[i].flags);
+ khui_menu_insert_paction(d, (khm_size) -1, src->items[i].p_action, src->items[i].flags);
} else {
- khui_menu_insert_action(d, -1, src->items[i].action, 0);
+ khui_menu_insert_action(d, (khm_size) -1, src->items[i].action, 0);
}
}
accels = PMALLOC(sizeof(ACCEL) * khui_n_accel_global);
for(i=0;i<khui_n_accel_global;i++) {
- accels[i].cmd = khui_accel_global[i].cmd;
- accels[i].fVirt = khui_accel_global[i].mod;
- accels[i].key = khui_accel_global[i].key;
+ accels[i].cmd = (WORD) khui_accel_global[i].cmd;
+ accels[i].fVirt = (BYTE) khui_accel_global[i].mod;
+ accels[i].key = (WORD) khui_accel_global[i].key;
}
ha = CreateAcceleratorTable(accels, khui_n_accel_global);
} else {
wchar_t mbuf[2];
- mbuf[0] = def->key;
+ mbuf[0] = (wchar_t) def->key;
mbuf[1] = L'\0';
if(FAILED(StringCbCat(buf, bufsiz, mbuf)))
#include<khuidefs.h>
#include<utils.h>
#include<assert.h>
-
#include<strsafe.h>
#define CW_ALLOC_INCR 8
return;
if (c != s && ((khm_size)(c - s)) < cch) {
-#if _MSC_VER >= 1400
+#if _MSC_VER >= 1400 && __STDC_WANT_SECURE_LIB__
wmemmove_s(s, cch, c, cch - ((khm_size)(c - s)));
#else
memmove(s, c, (cch - ((khm_size)(c - s)))* sizeof(wchar_t));
} khui_menu_def;
#ifdef NOEXPORT
-#define CONSTMENU(c,s,i) {c,s,-1,-1,i}
+#define CONSTMENU(c,s,i) {c,s,(khm_size)-1,(khm_size)-1,i}
#endif
/*! \brief Unspecified menu