Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/winecrt0/delay_load.c
12343 views
1
/*
2
* Support for delayed imports
3
*
4
* Copyright 2005 Alexandre Julliard
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
#include <stdarg.h>
22
#include "windef.h"
23
#include "winbase.h"
24
#include "delayloadhandler.h"
25
26
WINBASEAPI void *WINAPI DelayLoadFailureHook( LPCSTR name, LPCSTR function );
27
WINBASEAPI void *WINAPI ResolveDelayLoadedAPI( void* base, const IMAGE_DELAYLOAD_DESCRIPTOR* desc,
28
PDELAYLOAD_FAILURE_DLL_CALLBACK dllhook,
29
PDELAYLOAD_FAILURE_SYSTEM_ROUTINE syshook,
30
IMAGE_THUNK_DATA* addr, ULONG flags );
31
32
static inline void *image_base(void)
33
{
34
#ifdef __WINE_PE_BUILD
35
extern IMAGE_DOS_HEADER __ImageBase;
36
return (void *)&__ImageBase;
37
#else
38
extern IMAGE_NT_HEADERS __wine_spec_nt_header;
39
return (void *)((__wine_spec_nt_header.OptionalHeader.ImageBase + 0xffff) & ~0xffff);
40
#endif
41
}
42
43
FARPROC WINAPI __delayLoadHelper2( const IMAGE_DELAYLOAD_DESCRIPTOR *descr, IMAGE_THUNK_DATA *addr )
44
{
45
return ResolveDelayLoadedAPI( image_base(), descr, NULL, DelayLoadFailureHook, addr, 0 );
46
}
47
48