Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/winecrt0/crt_dllmain.c
12343 views
1
/*
2
* DllMainCRTStartup default entry point
3
*
4
* Copyright 2019 Jacek Caban for CodeWeavers
5
*
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.
10
*
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.
15
*
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19
*/
20
21
#ifdef __WINE_PE_BUILD
22
23
#include <stdarg.h>
24
#include <stdio.h>
25
#include <process.h>
26
#include "windef.h"
27
#include "winbase.h"
28
29
extern _PIFV __xi_a[];
30
extern _PIFV __xi_z[];
31
extern _PVFV __xc_a[];
32
extern _PVFV __xc_z[];
33
extern _PVFV __xt_a[];
34
extern _PVFV __xt_z[];
35
36
static void fallback_initterm( _PVFV *table,_PVFV *end )
37
{
38
for ( ; table < end; table++)
39
if (*table) (*table)();
40
}
41
42
static int fallback_initterm_e( _PIFV *table, _PIFV *end )
43
{
44
int res;
45
for (res = 0; !res && table < end; table++)
46
if (*table) res = (*table)();
47
return res;
48
}
49
50
BOOL WINAPI DllMainCRTStartup( HINSTANCE inst, DWORD reason, void *reserved )
51
{
52
BOOL ret;
53
54
if (reason == DLL_PROCESS_ATTACH)
55
{
56
if (fallback_initterm_e( __xi_a, __xi_z ) != 0) return FALSE;
57
fallback_initterm( __xc_a, __xc_z );
58
}
59
60
ret = DllMain( inst, reason, reserved );
61
62
if (reason == DLL_PROCESS_DETACH) fallback_initterm( __xt_a, __xt_z );
63
return ret;
64
}
65
66
#endif
67
68