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 typedef struct tagHOOKAPIEX *PHOOKAPIEX; 27 28 /* Shims know this structure as HOOKAPI, with 2 reserved members (the last 2). */ 29 typedef struct tagHOOKAPIEX 30 { 31 PCSTR LibraryName; 32 PCSTR FunctionName; 33 PVOID ReplacementFunction; 34 PVOID OriginalFunction; 35 PSHIMINFO pShimInfo; 36 PHOOKAPIEX ApiLink; 37 } HOOKAPIEX; 38 39 C_ASSERT(sizeof(HOOKAPIEX) == sizeof(HOOKAPI)); 40 C_ASSERT(offsetof(HOOKAPIEX, pShimInfo) == offsetof(HOOKAPI, Reserved)); 41 42 typedef struct _INEXCLUDE 43 { 44 UNICODE_STRING Module; 45 BOOL Include; 46 } INEXCLUDE, *PINEXCLUDE; 47 48 typedef struct _SHIMINFO 49 { 50 PCWSTR ShimName; 51 PHOOKAPIEX pHookApi; 52 DWORD dwHookCount; 53 PSHIMMODULE pShimModule; 54 ARRAY InExclude; /* INEXCLUDE */ 55 } SHIMINFO, *PSHIMINFO; 56 57 typedef struct _SHIMMODULE 58 { 59 UNICODE_STRING Name; 60 PVOID BaseAddress; 61 62 PHOOKAPIEX (WINAPI* pGetHookAPIs)(LPCSTR szCommandLine, LPCWSTR wszShimName, PDWORD pdwHookCount); 63 BOOL (WINAPI* pNotifyShims)(DWORD fdwReason, PVOID ptr); 64 65 ARRAY EnabledShims; /* PSHIMINFO */ 66 } SHIMMODULE, *PSHIMMODULE; 67 68 typedef struct _HOOKMODULEINFO 69 { 70 UNICODE_STRING Name; 71 PVOID BaseAddress; 72 73 ARRAY HookApis; /* PHOOKAPIEX */ 74 75 } HOOKMODULEINFO, *PHOOKMODULEINFO; 76 77 typedef struct _FLAGINFO 78 { 79 ULARGE_INTEGER AppCompatFlags; 80 ULARGE_INTEGER AppCompatFlagsUser; 81 ULONG ProcessParameters_Flags; 82 } FLAGINFO, *PFLAGINFO; 83 84 85 #if SDBAPI_DEBUG_ALLOC 86 87 LPVOID SdbpAlloc(SIZE_T size, int line, const char* file); 88 LPVOID SdbpReAlloc(LPVOID mem, SIZE_T size, SIZE_T oldSize, int line, const char* file); 89 VOID SdbpFree(LPVOID mem, int line, const char* file); 90 91 #define SeiAlloc(size) SdbpAlloc(size, __LINE__, __FILE__) 92 #define SeiReAlloc(mem, size, oldSize) SdbpReAlloc(mem, size, oldSize, __LINE__, __FILE__) 93 #define SeiFree(mem) SdbpFree(mem, __LINE__, __FILE__) 94 95 #else 96 97 LPVOID SdbpAlloc(SIZE_T size); 98 LPVOID SdbpReAlloc(LPVOID mem, SIZE_T size, SIZE_T oldSize); 99 VOID SdbpFree(LPVOID mem); 100 101 #define SeiAlloc(size) SdbpAlloc(size) 102 #define SeiReAlloc(mem, size, oldSize) SdbpReAlloc(mem, size, oldSize) 103 #define SeiFree(mem) SdbpFree(mem) 104 105 #endif 106 107 #endif // SHIMENG_H 108