xref: /netbsd-src/crypto/external/bsd/heimdal/dist/lib/krb5/dll.c (revision d3273b5b76f5afaafe308cead5511dbb8df8c5e9)
1*d3273b5bSchristos /*	$NetBSD: dll.c,v 1.2 2017/01/28 21:31:49 christos Exp $	*/
2ca1c9b0cSelric 
3ca1c9b0cSelric /***********************************************************************
4ca1c9b0cSelric  * Copyright (c) 2009, Secure Endpoints Inc.
5ca1c9b0cSelric  * All rights reserved.
6ca1c9b0cSelric  *
7ca1c9b0cSelric  * Redistribution and use in source and binary forms, with or without
8ca1c9b0cSelric  * modification, are permitted provided that the following conditions
9ca1c9b0cSelric  * are met:
10ca1c9b0cSelric  *
11ca1c9b0cSelric  * - Redistributions of source code must retain the above copyright
12ca1c9b0cSelric  *   notice, this list of conditions and the following disclaimer.
13ca1c9b0cSelric  *
14ca1c9b0cSelric  * - Redistributions in binary form must reproduce the above copyright
15ca1c9b0cSelric  *   notice, this list of conditions and the following disclaimer in
16ca1c9b0cSelric  *   the documentation and/or other materials provided with the
17ca1c9b0cSelric  *   distribution.
18ca1c9b0cSelric  *
19ca1c9b0cSelric  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20ca1c9b0cSelric  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21ca1c9b0cSelric  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22ca1c9b0cSelric  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23ca1c9b0cSelric  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
24ca1c9b0cSelric  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25ca1c9b0cSelric  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26ca1c9b0cSelric  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27ca1c9b0cSelric  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28ca1c9b0cSelric  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29ca1c9b0cSelric  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
30ca1c9b0cSelric  * OF THE POSSIBILITY OF SUCH DAMAGE.
31ca1c9b0cSelric  *
32ca1c9b0cSelric  **********************************************************************/
33ca1c9b0cSelric 
34ca1c9b0cSelric #include<windows.h>
35ca1c9b0cSelric 
36b9d004c6Schristos extern void heim_w32_service_thread_detach(void *);
37b9d004c6Schristos 
38ca1c9b0cSelric HINSTANCE _krb5_hInstance = NULL;
39ca1c9b0cSelric 
40b9d004c6Schristos #if NTDDI_VERSION >= NTDDI_VISTA
41b9d004c6Schristos extern BOOL WINAPI
42b9d004c6Schristos _hc_w32crypto_DllMain(HINSTANCE hinstDLL,
43b9d004c6Schristos 		      DWORD fdwReason,
44b9d004c6Schristos 		      LPVOID lpvReserved);
45b9d004c6Schristos #endif
46b9d004c6Schristos 
DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)47ca1c9b0cSelric BOOL WINAPI DllMain(HINSTANCE hinstDLL,
48ca1c9b0cSelric 		    DWORD fdwReason,
49ca1c9b0cSelric 		    LPVOID lpvReserved)
50ca1c9b0cSelric {
51b9d004c6Schristos #if NTDDI_VERSION >= NTDDI_VISTA
52b9d004c6Schristos     BOOL ret;
53b9d004c6Schristos 
54b9d004c6Schristos     ret = _hc_w32crypto_DllMain(hinstDLL, fdwReason, lpvReserved);
55b9d004c6Schristos     if (!ret)
56b9d004c6Schristos 	return ret;
57b9d004c6Schristos #endif
58b9d004c6Schristos 
59ca1c9b0cSelric     switch (fdwReason) {
60ca1c9b0cSelric     case DLL_PROCESS_ATTACH:
61ca1c9b0cSelric 
62ca1c9b0cSelric 	_krb5_hInstance = hinstDLL;
63ca1c9b0cSelric 	return TRUE;
64ca1c9b0cSelric 
65ca1c9b0cSelric     case DLL_PROCESS_DETACH:
66ca1c9b0cSelric 	return FALSE;
67ca1c9b0cSelric 
68ca1c9b0cSelric     case DLL_THREAD_ATTACH:
69ca1c9b0cSelric 	return FALSE;
70ca1c9b0cSelric 
71ca1c9b0cSelric     case DLL_THREAD_DETACH:
72b9d004c6Schristos         heim_w32_service_thread_detach(NULL);
73ca1c9b0cSelric 	return FALSE;
74ca1c9b0cSelric     }
75ca1c9b0cSelric 
76ca1c9b0cSelric     return FALSE;
77ca1c9b0cSelric }
78ca1c9b0cSelric 
79