ReactOS 0.4.15-dev-8100-g1887773
load_notifications.c
Go to the documentation of this file.
1#define WIN32_NO_STATUS
2#define _INC_WINDOWS
3#define COM_NO_WINDOWS_H
4
5#include <windows.h>
6
7
8#if defined(_MSC_VER)
9#define _CRTALLOC(x) __declspec(allocate(x))
10#elif defined(__GNUC__)
11#define _CRTALLOC(x) __attribute__ ((section (x) ))
12#else
13#error Your compiler is not supported.
14#endif
15
16
17static VOID (WINAPI* pTlsCallback)(IN HINSTANCE hDllHandle, IN DWORD dwReason, IN LPVOID lpvReserved);
18
23{
24 if (!pTlsCallback)
25 pTlsCallback = (VOID*)GetProcAddress(NULL, "notify_TlsCallback");
26 if (pTlsCallback)
27 {
28 pTlsCallback(hDllHandle, dwReason, lpvReserved);
29 return;
30 }
31 OutputDebugStringA("WARNING: load_notifications.dll loaded from a process without notify_TlsCallback\n");
32}
33
34/* Tls magic stolen from sdk/lib/crt/startup/tlssup.c */
35
36#if defined(_MSC_VER)
37#pragma section(".rdata$T",long,read)
38#pragma section(".tls",long,read,write)
39#pragma section(".tls$ZZZ",long,read,write)
40#endif
41
42_CRTALLOC(".tls") char _tls_start = 0;
43_CRTALLOC(".tls$ZZZ") char _tls_end = 0;
44
45PIMAGE_TLS_CALLBACK __xl_a[2] = { &TlsCallback, NULL };
46
48
49_CRTALLOC(".rdata$T") const IMAGE_TLS_DIRECTORY _tls_used = {
50 (ULONG_PTR) &_tls_start+1, (ULONG_PTR) &_tls_end,
51 (ULONG_PTR) &_tls_index, (ULONG_PTR) (__xl_a),
52 (ULONG) 0, (ULONG) 0
53};
54
55
56static BOOL (WINAPI* pDllMain)(IN HINSTANCE hDllHandle, IN DWORD dwReason, IN LPVOID lpvReserved);
57
58
60DllMain(IN HINSTANCE hDllHandle,
63{
64 if (!pDllMain)
65 pDllMain = (VOID*)GetProcAddress(NULL, "notify_DllMain");
66 if (pDllMain)
67 {
68 return pDllMain(hDllHandle, dwReason, lpvReserved);
69 }
70 OutputDebugStringA("WARNING: load_notifications.dll loaded from a process without notify_DllMain\n");
71 return TRUE;
72}
#define VOID
Definition: acefi.h:82
DWORD dwReason
Definition: misc.cpp:154
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define GetProcAddress(x, y)
Definition: compat.h:753
unsigned char
Definition: typeof.h:29
#define ULONG_PTR
Definition: config.h:101
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define _CRTALLOC(x)
void WINAPI SHIM_OBJ_NAME() OutputDebugStringA(LPCSTR lpOutputString)
Definition: ignoredbgout.c:18
VOID WINAPI TlsCallback(IN HANDLE hDllHandle, IN DWORD dwReason, IN LPVOID lpvReserved)
static IN DWORD IN LPVOID lpvReserved
BOOL WINAPI DllMain(IN HINSTANCE hDllHandle, IN DWORD dwReason, IN LPVOID lpvReserved)
ULONG _tls_index
#define BOOL
Definition: nt_native.h:43
VOID(NTAPI * PIMAGE_TLS_CALLBACK)(PVOID DllHandle, ULONG Reason, PVOID Reserved)
Definition: ntimage.h:531
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define WINAPI
Definition: msvc.h:6
#define const
Definition: zconf.h:233