ie 5.5 hook -> exception, but not ie 6

c++ / delphi package - dll injection and api hooking
Post Reply
bigfreak
Posts: 4
Joined: Tue Apr 19, 2005 8:13 pm

ie 5.5 hook -> exception, but not ie 6

Post by bigfreak »

First, mad props to madshi. I purchased this lib back in version 1.3.0.8 ( Oct 2002 my dll was dated ). It's a great lib. The man really knows his stuff. :)

Anyway, this is my code:

Code: Select all

HOSTENT FAR * hook_gethostbyname ( const char FAR * name )
{
	if(nexthook_gethostbyname == NULL)
	{
		//this sucks
		return NULL;
	}
	return nexthook_gethostbyname( name );
}
The original function was much longer, but I've reduced it to this shell of a hook and I get the same results. As you can tell, I'm not doing anything. I'm not playing with error levels nor am I poking with stuff I shouldn't.

I've updated to the latest version (2.1.7.0) and I get the same exact thingL

Under Internet Explorer 6, the above hook works great. Even the "complicated version" of my hook is rock solid.

When the same code in IE 5.5, however, I get the "send" or "don't send" box that IE puts up when it has an exception. The exception is generated sometime after I call nexthook_gethostbyname.

Does anyone have any ideas?

ws2_32.dll version is 5.0.2195.6601
Modified: Thursday, June 19, 2003

When I update IE6, ws2_32.dll version stays the same.

Also, I just tried hooking the function this way:

Code: Select all

HookAPI(
				"ws2_32.dll",
				"gethostbyname",
				hook_gethostbyname,
				(PVOID*) &nexthook_gethostbyname);

Code: Select all

		HookCode(
			gethostbyname, 
			hook_gethostbyname, 
			(PVOID*) &nexthook_gethostbyname);
Both methods produce the same results (IE Exception only in 5.5 though).

Also, nexthook_gethostbyname returns successfully. I get a return value everything looks great. Then I return the results I got and... crash... :(

Any ideas?

-Robert
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Shouldn't you be using WINAPI?

If that doesn't help, how is "nexthook_gethostbyname" defined?
bigfreak
Posts: 4
Joined: Tue Apr 19, 2005 8:13 pm

Post by bigfreak »

madshi wrote:Shouldn't you be using WINAPI?
You NAILED it. I added WINAPI to my function def and it works.

Code: Select all

HOSTENT FAR * WINAPI hook_gethostbyname ( const char FAR * name )
{
  ...
}
Thanks for the help. :)
Post Reply