ddcb09c08f4edea6e76c24b459cd62bc2992428a
[reactos.git] / reactos / dll / appcompat / apphelp / shimeng.h
1 /*
2 * Copyright 2017 Mark Jansen (mark.jansen@reactos.org)
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19 #ifndef SHIMENG_H
20 #define SHIMENG_H
21
22 /* ReactOS specific */
23
24 /* Structure that allows dynamic growing.
25 Be aware, the data may move! */
26 typedef struct _ARRAY
27 {
28 PVOID Data__;
29 DWORD Size__;
30 DWORD MaxSize__;
31 DWORD ItemSize__;
32 } ARRAY, *PARRAY;
33
34 typedef struct _SHIMINFO *PSHIMINFO;
35 typedef struct _SHIMMODULE *PSHIMMODULE;
36
37 /* Shims know this structure as HOOKAPI, with 2 reserved members (the last 2). */
38 typedef struct tagHOOKAPIEX
39 {
40 PCSTR LibraryName;
41 PCSTR FunctionName;
42 PVOID ReplacementFunction;
43 PVOID OriginalFunction;
44 PSHIMINFO pShimInfo;
45 PVOID Unused;
46 } HOOKAPIEX, *PHOOKAPIEX;
47
48 C_ASSERT(sizeof(HOOKAPIEX) == sizeof(HOOKAPI));
49 C_ASSERT(offsetof(HOOKAPIEX, pShimInfo) == offsetof(HOOKAPI, Reserved));
50
51
52 typedef struct _SHIMINFO
53 {
54 PHOOKAPIEX pHookApi;
55 DWORD dwHookCount;
56 PSHIMMODULE pShimModule;
57 } SHIMINFO, *PSHIMINFO;
58
59 typedef struct _SHIMMODULE
60 {
61 UNICODE_STRING Name;
62 PVOID BaseAddress;
63
64 PHOOKAPIEX (WINAPI* pGetHookAPIs)(LPCSTR szCommandLine, LPCWSTR wszShimName, PDWORD pdwHookCount);
65 BOOL (WINAPI* pNotifyShims)(DWORD fdwReason, PVOID ptr);
66
67 ARRAY EnabledShims; /* PSHIMINFO */
68 } SHIMMODULE, *PSHIMMODULE;
69
70 typedef struct _HOOKMODULEINFO
71 {
72 UNICODE_STRING Name;
73 PVOID BaseAddress;
74
75 ARRAY HookApis; /* PHOOKAPIEX */
76
77 } HOOKMODULEINFO, *PHOOKMODULEINFO;
78
79
80 #if SDBAPI_DEBUG_ALLOC
81
82 LPVOID SdbpAlloc(SIZE_T size, int line, const char* file);
83 LPVOID SdbpReAlloc(LPVOID mem, SIZE_T size, SIZE_T oldSize, int line, const char* file);
84 VOID SdbpFree(LPVOID mem, int line, const char* file);
85
86 #define SeiAlloc(size) SdbpAlloc(size, __LINE__, __FILE__)
87 #define SeiReAlloc(mem, size, oldSize) SdbpReAlloc(mem, size, oldSize, __LINE__, __FILE__)
88 #define SeiFree(mem) SdbpFree(mem, __LINE__, __FILE__)
89
90 #else
91
92 LPVOID SdbpAlloc(SIZE_T size);
93 LPVOID SdbpReAlloc(LPVOID mem, SIZE_T size, SIZE_T oldSize);
94 VOID SdbpFree(LPVOID mem);
95
96 #define SeiAlloc(size) SdbpAlloc(size)
97 #define SeiReAlloc(mem, size, oldSize) SdbpReAlloc(mem, size, oldSize)
98 #define SeiFree(mem) SdbpFree(mem)
99
100 #endif
101
102 #endif // SHIMENG_H