Handle SEE_MASK_CLASSKEY case for ShellExecute.
[wine.git] / dlls / msvcrt / main.c
blob77876cc063fc348f0a26daf5e8a355d97edbb8c7
1 /*
2 * msvcrt.dll initialisation functions
4 * Copyright 2000 Jon Griffiths
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "msvcrt.h"
22 #include "msvcrt/locale.h"
23 #include "msvcrt/stdio.h"
25 #include "wine/debug.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
29 /* Index to TLS */
30 DWORD MSVCRT_tls_index;
32 static inline BOOL msvcrt_init_tls(void);
33 static inline BOOL msvcrt_free_tls(void);
34 const char* msvcrt_get_reason(DWORD reason) WINE_UNUSED;
36 /*********************************************************************
37 * Init
39 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
41 MSVCRT_thread_data *tls;
43 TRACE("(%p, %s, %p) pid(%lx), tid(%lx), tls(%ld)\n",
44 hinstDLL, msvcrt_get_reason(fdwReason), lpvReserved,
45 GetCurrentProcessId(), GetCurrentThreadId(),
46 (long)MSVCRT_tls_index);
48 switch (fdwReason)
50 case DLL_PROCESS_ATTACH:
51 if (!msvcrt_init_tls())
52 return FALSE;
53 msvcrt_init_mt_locks();
54 msvcrt_init_io();
55 msvcrt_init_console();
56 msvcrt_init_args();
57 MSVCRT_setlocale(0, "C");
58 TRACE("finished process init\n");
59 break;
60 case DLL_THREAD_ATTACH:
61 break;
62 case DLL_PROCESS_DETACH:
63 msvcrt_free_mt_locks();
64 msvcrt_free_io();
65 msvcrt_free_console();
66 msvcrt_free_args();
67 if (!msvcrt_free_tls())
68 return FALSE;
69 TRACE("finished process free\n");
70 break;
71 case DLL_THREAD_DETACH:
72 /* Free TLS */
73 tls = TlsGetValue(MSVCRT_tls_index);
74 if (tls) HeapFree(GetProcessHeap(), 0, tls);
75 TRACE("finished thread free\n");
76 break;
78 return TRUE;
81 static inline BOOL msvcrt_init_tls(void)
83 MSVCRT_tls_index = TlsAlloc();
85 if (MSVCRT_tls_index == TLS_OUT_OF_INDEXES)
87 ERR("TlsAlloc() failed!\n");
88 return FALSE;
90 return TRUE;
93 static inline BOOL msvcrt_free_tls(void)
95 if (!TlsFree(MSVCRT_tls_index))
97 ERR("TlsFree() failed!\n");
98 return FALSE;
100 return TRUE;
103 const char* msvcrt_get_reason(DWORD reason)
105 switch (reason)
107 case DLL_PROCESS_ATTACH: return "DLL_PROCESS_ATTACH";
108 case DLL_PROCESS_DETACH: return "DLL_PROCESS_DETACH";
109 case DLL_THREAD_ATTACH: return "DLL_THREAD_ATTACH";
110 case DLL_THREAD_DETACH: return "DLL_THREAD_DETACH";
112 return "UNKNOWN";
116 /*********************************************************************
117 * $I10_OUTPUT (MSVCRT.@)
118 * Function not really understood but needed to make the DLL work
120 void MSVCRT_I10_OUTPUT(void)
122 /* FIXME: This is probably data, not a function */
125 /*********************************************************************
126 * __unDName (MSVCRT.@)
128 * Demangle a C++ identifier.
130 * PARAMS
131 * unknown [I] Not yet determined
132 * mangled [I] Mangled name of the function
133 * unknown2 [I] Not yet determined
134 * memget [I] Function to allocate memory with
135 * memfree [I] Function to free memory with
136 * flags [I] Flags determining demangled format
138 * RETURNS
139 * Success: A string pointing to the unmangled name, allocated with memget.
140 * Failure: NULL.
142 char* MSVCRT___unDName(int unknown, const char* mangled, int unknown2,
143 MSVCRT_malloc_func memget,
144 MSVCRT_free_func memfree,
145 unsigned int flags)
147 char* ret;
149 FIXME("(%d,%s,%d,%p,%p,%x) stub!\n", unknown, mangled, unknown2, memget, memfree, flags);
151 /* FIXME: The code in tools/winebuild/msmangle.c is pretty complete and
152 * could be used here.
155 /* Experimentation reveals the following flag meanings when set:
156 * 0x0001 - Dont show __ in calling convention
157 * 0x0002 - Dont show calling convention at all
158 * 0x0004 - Dont show function/method return value
159 * 0x0010 - Same as 0x1
160 * 0x0080 - Dont show access specifier (public/protected/private)
161 * 0x0200 - Dont show static specifier
162 * 0x0800 - Unknown, passed by type_info::name()
163 * 0x1000 - Only report the variable/class name
164 * 0x2000 - Unknown, passed by type_info::name()
166 /* Duplicate the mangled name; for comparisons it doesn't matter anyway */
167 ret = memget(strlen(mangled) + 1);
168 strcpy(ret, mangled);
169 return ret;
173 /*********************************************************************
174 * __unDNameEx (MSVCRT.@)
175 * Function not really understood but needed to make the DLL work
177 char* MSVCRT___unDNameEx(void)
179 return NULL;