This interface is for raw mode hooking.
You usually should use ICodeHook's raw mode hooking feature instead of use this interface directly.
To get the interface, call ICodeHook.GetDirectCodeHook;
Delphi syntax:
IDirectCodeHook = interface(IErrorCodeHook) function Hook(ATarget, AHook: Pointer; APreviousMethod: Pointer): LongBool; stdcall; function Unhook(ATarget: Pointer; APreviousMethod: Pointer): LongBool; stdcall; function AllocatePreviousMethodMemory: Pointer; stdcall; procedure FreePreviousMethodMemory(APreviousMethod: Pointer); stdcall; end;C++ syntax:
class IDirectCodeHook: public ICodeHookError {
public:
virtual BOOL _stdcall Hook(Pointer Target, Pointer Hook, Pointer OldFunc) = 0;
virtual BOOL _stdcall Unhook(Pointer Target, Pointer AOldFunc) = 0;
virtual void * _stdcall AllocatePreviousMethodMemory() = 0;
virtual void FreePreviousMethodMemory(Pointer OldFunc) = 0;
};
Function:
Low level hook a method.
Delphi syntax:
C++ syntax:
Params
Hook
Low level hook a method.
Delphi syntax:
function Hook(ATarget, AHook: Pointer; APreviousMethod: Pointer): LongBool; stdcall;
C++ syntax:
virtual BOOL calltype Hook(Pointer Target, Pointer Hook, Pointer OldFunc) = 0;
Params
- ATarget
- Address of the target function.
- AHook
- Address of the hook function.
- APreviousMethod
- Pointer to a memory block to store the previous method information. You may use IDirectCodeHook.AllocatePreviousMethodMemory to allocate memory.
- Return TRUE on success, otherwise, return FALSE.
- Don't use this function, instead, use ICodeHook.Hook.
Function:
Low level unhook a method.
Delphi syntax:
C++ syntax:
Params
Unhook
Low level unhook a method.
Delphi syntax:
function Unhook(ATarget: Pointer; APreviousMethod: Pointer): LongBool; stdcall;
C++ syntax:
virtual BOOL calltype Unhook(Pointer Target, Pointer AOldFunc) = 0;
Params
- ATarget
- Address of the target function.
- APreviousMethod
- Address of the previous function.
- Return TRUE on success, otherwise, return FALSE.
- Don't use this function, instead, use ICodeHook.Unhook.
Function:
Allocate a block of memory to store previous method information.
Delphi syntax:
C++ syntax:
Params
AllocatePreviousMethodMemory
Allocate a block of memory to store previous method information.
Delphi syntax:
function AllocatePreviousMethodMemory: Pointer; stdcall;
C++ syntax:
virtual void * calltype AllocatePreviousMethodMemory() = 0;
Params
- This function has no parameters.
- Return the memory pointer.
- You can pass the return value to IDirectCodeHook.Hook and IDirectCodeHook.Unhook.
Function:
Free the memory block.
Delphi syntax:
C++ syntax:
Params
FreePreviousMethodMemory
Free the memory block.
Delphi syntax:
procedure FreePreviousMethodMemory(APreviousMethod: Pointer); stdcall;
C++ syntax:
virtual void FreePreviousMethodMemory(Pointer OldFunc) = 0;
Params
- APreviousMethod
- Pointer that returned by IDirectCodeHook.AllocatePreviousMethodMemory
- This function doesn't return value.