2017-07-01 20:06:30 +00:00
|
|
|
/*
|
2017-07-30 12:47:57 +00:00
|
|
|
* Copyright 2017 Mark Jansen (mark.jansen@reactos.org)
|
2017-07-01 20:06:30 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SHIMENG_H
|
|
|
|
#define SHIMENG_H
|
|
|
|
|
2017-07-30 12:47:57 +00:00
|
|
|
/* ReactOS specific */
|
|
|
|
|
|
|
|
/* Structure that allows dynamic growing.
|
|
|
|
Be aware, the data may move! */
|
2017-07-01 20:06:30 +00:00
|
|
|
typedef struct _ARRAY
|
|
|
|
{
|
2017-07-30 12:47:57 +00:00
|
|
|
PVOID Data__;
|
|
|
|
DWORD Size__;
|
|
|
|
DWORD MaxSize__;
|
|
|
|
DWORD ItemSize__;
|
2017-07-01 20:06:30 +00:00
|
|
|
} ARRAY, *PARRAY;
|
|
|
|
|
2017-07-30 12:47:57 +00:00
|
|
|
typedef struct _SHIMINFO *PSHIMINFO;
|
|
|
|
typedef struct _SHIMMODULE *PSHIMMODULE;
|
2017-07-01 20:06:30 +00:00
|
|
|
|
2017-07-30 12:47:57 +00:00
|
|
|
/* Shims know this structure as HOOKAPI, with 2 reserved members (the last 2). */
|
2017-07-01 20:06:30 +00:00
|
|
|
typedef struct tagHOOKAPIEX
|
|
|
|
{
|
|
|
|
PCSTR LibraryName;
|
|
|
|
PCSTR FunctionName;
|
|
|
|
PVOID ReplacementFunction;
|
|
|
|
PVOID OriginalFunction;
|
2017-07-30 12:47:57 +00:00
|
|
|
PSHIMINFO pShimInfo;
|
|
|
|
PVOID Unused;
|
2017-07-01 20:06:30 +00:00
|
|
|
} HOOKAPIEX, *PHOOKAPIEX;
|
|
|
|
|
|
|
|
C_ASSERT(sizeof(HOOKAPIEX) == sizeof(HOOKAPI));
|
2017-07-30 12:47:57 +00:00
|
|
|
C_ASSERT(offsetof(HOOKAPIEX, pShimInfo) == offsetof(HOOKAPI, Reserved));
|
2017-07-01 20:06:30 +00:00
|
|
|
|
|
|
|
|
2017-07-30 12:47:57 +00:00
|
|
|
typedef struct _SHIMINFO
|
2017-07-01 20:06:30 +00:00
|
|
|
{
|
|
|
|
PHOOKAPIEX pHookApi;
|
|
|
|
DWORD dwHookCount;
|
2017-07-30 12:47:57 +00:00
|
|
|
PSHIMMODULE pShimModule;
|
|
|
|
} SHIMINFO, *PSHIMINFO;
|
2017-07-01 20:06:30 +00:00
|
|
|
|
|
|
|
typedef struct _SHIMMODULE
|
|
|
|
{
|
|
|
|
UNICODE_STRING Name;
|
|
|
|
PVOID BaseAddress;
|
|
|
|
|
|
|
|
PHOOKAPIEX (WINAPI* pGetHookAPIs)(LPCSTR szCommandLine, LPCWSTR wszShimName, PDWORD pdwHookCount);
|
|
|
|
BOOL (WINAPI* pNotifyShims)(DWORD fdwReason, PVOID ptr);
|
|
|
|
|
2017-07-30 12:47:57 +00:00
|
|
|
ARRAY EnabledShims; /* PSHIMINFO */
|
2017-07-01 20:06:30 +00:00
|
|
|
} SHIMMODULE, *PSHIMMODULE;
|
|
|
|
|
|
|
|
typedef struct _HOOKMODULEINFO
|
|
|
|
{
|
|
|
|
UNICODE_STRING Name;
|
|
|
|
PVOID BaseAddress;
|
|
|
|
|
2017-07-30 12:47:57 +00:00
|
|
|
ARRAY HookApis; /* PHOOKAPIEX */
|
|
|
|
|
2017-07-01 20:06:30 +00:00
|
|
|
} HOOKMODULEINFO, *PHOOKMODULEINFO;
|
|
|
|
|
|
|
|
|
|
|
|
#if SDBAPI_DEBUG_ALLOC
|
|
|
|
|
|
|
|
LPVOID SdbpAlloc(SIZE_T size, int line, const char* file);
|
|
|
|
LPVOID SdbpReAlloc(LPVOID mem, SIZE_T size, SIZE_T oldSize, int line, const char* file);
|
|
|
|
VOID SdbpFree(LPVOID mem, int line, const char* file);
|
|
|
|
|
|
|
|
#define SeiAlloc(size) SdbpAlloc(size, __LINE__, __FILE__)
|
|
|
|
#define SeiReAlloc(mem, size, oldSize) SdbpReAlloc(mem, size, oldSize, __LINE__, __FILE__)
|
|
|
|
#define SeiFree(mem) SdbpFree(mem, __LINE__, __FILE__)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
LPVOID SdbpAlloc(SIZE_T size);
|
|
|
|
LPVOID SdbpReAlloc(LPVOID mem, SIZE_T size, SIZE_T oldSize);
|
|
|
|
VOID SdbpFree(LPVOID mem);
|
|
|
|
|
|
|
|
#define SeiAlloc(size) SdbpAlloc(size)
|
|
|
|
#define SeiReAlloc(mem, size, oldSize) SdbpReAlloc(mem, size, oldSize)
|
|
|
|
#define SeiFree(mem) SdbpFree(mem)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // SHIMENG_H
|