winsock hooking

c++ / delphi package - dll injection and api hooking

hi

Postby legion » Fri Jun 11, 2004 3:23 pm

hi dear madshi
i am still now on this project
i have changed the code,now any error occur but when i send halo
the server or receiver's application doens't receive halo
but any others string are received successfully
did you why ?
what's happen ?

nildo i have also tried that but i obtain yje same result

here is my code

Code: Select all
library ws2hook;


uses
  windows,madcodehook,winsock,madstrings;

{$R *.res}
var
  sendNextHook: function(s: TSocket; var Buf; len, flags: Integer): Integer; stdcall;

function sendHookProc(s: TSocket; var Buf; len, flags: Integer): Integer; stdcall;
var
i1 : integer;
s1 : string;
begin
    result:=0;
    i1 := 0;
    while true do
    begin
     i1 := PosPchar('halo', @Buf, 4, len, true, i1);
     if i1 >= 0 then
      begin
      SetString(s1, pchar(@Buf), len);
      ReplaceStr(s1, 'hello', 'reallycool');
      Move(pchar(string(s1))^,(pchar(@buf))^,sizeof(@buf));
      len:=sizeof(buf);
      end
      else
      break;
    end;
 Result := sendNextHook(s, Buf, len, flags);
end;


begin
hookapi('ws2_32.dll','send', @sendHookProc, @sendNextHook);
hookapi('wsock32.dll','send', @sendHookProc, @sendNextHook);
end.
legion
 
Posts: 32
Joined: Sat May 15, 2004 7:48 pm

Postby madshi » Fri Jun 11, 2004 5:23 pm

Why don't you use the code I gave you? That one should work (if you use it right).
madshi
Site Admin
 
Posts: 9719
Joined: Sun Mar 21, 2004 5:25 pm

hi

Postby legion » Fri Jun 11, 2004 6:37 pm

hello

i tried your code but it don't work for me.
here is your code

Code: Select all
function SendCallback( s: Integer; Buf: Pointer; len, flags: Integer): Integer; stdcall;
var s1 : string;
begin
  SetString(s1, Buf, len);
  ReplaceStr(s1, 'hello', 'reallycool');
  result := sendNextHook(s, pointer(s1), length(s1), flags);
end;


did you know why ?
maybe it is mistake from me or what ?


thank in advance
legion
 
Posts: 32
Joined: Sat May 15, 2004 7:48 pm

Postby madshi » Fri Jun 11, 2004 6:58 pm

I already told you why. :?
madshi
Site Admin
 
Posts: 9719
Joined: Sun Mar 21, 2004 5:25 pm

Postby nildo » Sat Jun 12, 2004 11:18 pm

Pay atention on your declaration
nildo
 
Posts: 249
Joined: Mon Mar 22, 2004 11:32 am

Previous

Return to madCodeHook

Who is online

Users browsing this forum: Exabot [Bot] and 2 guests

cron