Files
mirror-processhacker/trunk/NProcessHacker/hook.h
T
wj32 5808bbcfc6 * added transparency hooking to NProcessHacker
* added some registry-related things to ProcessHacker.Native

git-svn-id: svn://svn.code.sf.net/p/processhacker/code@1379 21ef857c-d57f-4fe0-8362-d861dc6d29cd
2009-06-06 09:50:14 +00:00

75 lines
1.9 KiB
C

/*
* Process Hacker Library -
* hooks
*
* Copyright (C) 2009 wj32
*
* This file is part of Process Hacker.
*
* Process Hacker is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Process Hacker 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _HOOK_H
#define _HOOK_H
#include "nph.h"
/* Almost exactly the same as the hooking code in KProcessHacker. */
#define PH_DEFINE_HOOK_CALL(Name, Arguments, Hook) \
__declspec(naked) Name(Arguments) \
{ \
__asm lea eax, Hook \
__asm mov eax, [eax+PH_HOOK.Function] \
__asm add eax, 5 \
__asm push ebp \
__asm mov ebp, esp \
__asm jmp eax \
} \
#define PH_DEFINE_NT_HOOK_CALL(Name, Arguments, Hook) \
__declspec(naked) Name(Arguments) \
{ \
__asm lea eax, Hook \
__asm mov edx, [eax+PH_HOOK.Function] \
__asm add edx, 5 \
/* Store the system call number in eax. */ \
__asm mov eax, dword ptr [eax+PH_HOOK.Bytes+1] \
__asm jmp edx \
} \
typedef struct _PH_HOOK
{
PVOID Function;
PVOID Target;
BOOLEAN Hooked;
CHAR Bytes[5];
} PH_HOOK, *PPH_HOOK;
NPHAPI VOID PhInitializeHook(
PPH_HOOK Hook,
PVOID Function,
PVOID Target
);
NPHAPI NTSTATUS PhHook(
PPH_HOOK Hook
);
NPHAPI NTSTATUS PhUnhook(
PPH_HOOK Hook
);
#endif