GenericCodeHook

c++ / delphi package - dll injection and api hooking
Post Reply
randy
Posts: 7
Joined: Sun Jun 08, 2008 1:07 am

GenericCodeHook

Post by randy »

Hi , i developed a unit named GenericCodeHook , it will do a generic code hook by replacing the code location to be patched by a jump to the new location .
i have 2 functions :
CreateGenericCHook and RemoveGenericCHook .

i use it like this :

Code: Select all


library GenCHook;

uses
  windows,
  GenericCodeHook;

procedure Main( Reason : Integer ) ;
begin

  case reason of

    DLL_PROCESS_DETACH:
    begin
        Detache;
{
Detache:
will call the RemoveGenericCHook function
}
    end;

    DLL_PROCESS_ATTACH: 
    begin
      Attach;
{
Attach:
will call the CreateGenericCHook function
}
    end;

  end;

end;

{ *******************
  *** Entry Point ***
  ******************* }

begin

DllProc := @Main;
DllProc(DLL_PROCESS_ATTACH) ;

end.


But the problem is how could i inject it into the whole system using MadCodeHook library ?


many thanks
iconic
Site Admin
Posts: 1065
Joined: Wed Jun 08, 2005 5:08 am

Post by iconic »

InjectLibrary(ALL_SESSIONS or SYSTEM_PROCESSES, 'dll.dll'); for madCodeHook 2.x

If you're using v3 it's a bit different, have a look here http://help.madshi.net/HowToUseMadCodeHook.htm

--Iconic
randy
Posts: 7
Joined: Sun Jun 08, 2008 1:07 am

Post by randy »

Thank you iconic , But when i use it with :
InjectLibrary(ALL_SESSIONS or SYSTEM_PROCESSES, 'dll.dll');

the System crashes .
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

randy wrote:Thank you iconic , But when i use it with :
InjectLibrary(ALL_SESSIONS or SYSTEM_PROCESSES, 'dll.dll');

the System crashes .
Then probably your GenericCodeHook is responsible for the crash? Try injecting an empty dll. Does that crash still occur?
Post Reply