xref: /reactos/dll/appcompat/apphelp/shimeng.h (revision da5f10af)
1 /*
2  * PROJECT:     ReactOS Application compatibility module
3  * LICENSE:     GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE:     Shim engine structures
5  * COPYRIGHT:   Copyright 2017 Mark Jansen (mark.jansen@reactos.org)
6  */
7 
8 #ifndef SHIMENG_H
9 #define SHIMENG_H
10 
11 /* This header is ReactOS specific */
12 
13 /* Structure that allows dynamic growing.
14    Be aware, the data may move! */
15 typedef struct _ARRAY
16 {
17     PVOID Data__;
18     DWORD Size__;
19     DWORD MaxSize__;
20     DWORD ItemSize__;
21 } ARRAY, *PARRAY;
22 
23 typedef struct _SHIMINFO *PSHIMINFO;
24 typedef struct _SHIMMODULE *PSHIMMODULE;
25 
26 /* Shims know this structure as HOOKAPI, with 2 reserved members (the last 2). */
27 typedef struct tagHOOKAPIEX
28 {
29     PCSTR LibraryName;
30     PCSTR FunctionName;
31     PVOID ReplacementFunction;
32     PVOID OriginalFunction;
33     PSHIMINFO pShimInfo;
34     PVOID Unused;
35 } HOOKAPIEX, *PHOOKAPIEX;
36 
37 C_ASSERT(sizeof(HOOKAPIEX) == sizeof(HOOKAPI));
38 C_ASSERT(offsetof(HOOKAPIEX, pShimInfo) == offsetof(HOOKAPI, Reserved));
39 
40 typedef struct _INEXCLUDE
41 {
42     UNICODE_STRING Module;
43     BOOL Include;
44 } INEXCLUDE, *PINEXCLUDE;
45 
46 typedef struct _SHIMINFO
47 {
48     PCWSTR ShimName;
49     PHOOKAPIEX pHookApi;
50     DWORD dwHookCount;
51     PSHIMMODULE pShimModule;
52     ARRAY InExclude;        /* INEXCLUDE */
53 } SHIMINFO, *PSHIMINFO;
54 
55 typedef struct _SHIMMODULE
56 {
57     UNICODE_STRING Name;
58     PVOID BaseAddress;
59 
60     PHOOKAPIEX (WINAPI* pGetHookAPIs)(LPCSTR szCommandLine, LPCWSTR wszShimName, PDWORD pdwHookCount);
61     BOOL (WINAPI* pNotifyShims)(DWORD fdwReason, PVOID ptr);
62 
63     ARRAY EnabledShims;     /* PSHIMINFO */
64 } SHIMMODULE, *PSHIMMODULE;
65 
66 typedef struct _HOOKMODULEINFO
67 {
68     UNICODE_STRING Name;
69     PVOID BaseAddress;
70 
71     ARRAY HookApis;         /* PHOOKAPIEX */
72 
73 } HOOKMODULEINFO, *PHOOKMODULEINFO;
74 
75 typedef struct _FLAGINFO
76 {
77     ULARGE_INTEGER AppCompatFlags;
78     ULARGE_INTEGER AppCompatFlagsUser;
79     ULONG ProcessParameters_Flags;
80 } FLAGINFO, *PFLAGINFO;
81 
82 
83 #if SDBAPI_DEBUG_ALLOC
84 
85 LPVOID SdbpAlloc(SIZE_T size, int line, const char* file);
86 LPVOID SdbpReAlloc(LPVOID mem, SIZE_T size, SIZE_T oldSize, int line, const char* file);
87 VOID SdbpFree(LPVOID mem, int line, const char* file);
88 
89 #define SeiAlloc(size) SdbpAlloc(size, __LINE__, __FILE__)
90 #define SeiReAlloc(mem, size, oldSize) SdbpReAlloc(mem, size, oldSize, __LINE__, __FILE__)
91 #define SeiFree(mem) SdbpFree(mem, __LINE__, __FILE__)
92 
93 #else
94 
95 LPVOID SdbpAlloc(SIZE_T size);
96 LPVOID SdbpReAlloc(LPVOID mem, SIZE_T size, SIZE_T oldSize);
97 VOID SdbpFree(LPVOID mem);
98 
99 #define SeiAlloc(size) SdbpAlloc(size)
100 #define SeiReAlloc(mem, size, oldSize) SdbpReAlloc(mem, size, oldSize)
101 #define SeiFree(mem) SdbpFree(mem)
102 
103 #endif
104 
105 #endif // SHIMENG_H
106