MCH3: CheckHooks performance issue

c++ / delphi package - dll injection and api hooking
Post Reply
EaSy
Posts: 150
Joined: Tue Oct 23, 2012 12:33 pm

MCH3: CheckHooks performance issue

Post by EaSy »

Hi,
we are facing a huge performance hit caused by MCH. Our customer reports massive 350% slowdown when listing some of the data inside one of their private app. This app loads wldp.dll a few thousand times.
We traced the issue and it points into MCH CheckHooks. We are hooking about 100 windows APIs. We are using MCH v3.1.13.

I wrote a simple test app looking like this:

Code: Select all

	DWORD dwTickCount = GetTickCount();
	for (int i = 0; i < 10000; ++i)
	{
		HMODULE hMod = LoadLibraryW(L"wldp.dll");
		if (hMod)
			FreeLibrary(hMod);

		if (i % 100 == 0)
			printf("%u: %u\n", i, GetTickCount() - dwTickCount);
	}
When this test app is not injected by our DLL it runs for about 5 seconds, but hen this app is injected it runs for about 20 seconds. It is huge performance hit.

Is there a way to lower the amout the CheckHooks fcn is called (it is called on every load/unload) or the lower the time the CheckHooks fcn consume (it always enumerates all the hooks)?

Thx

PP

EDIT: changed MCH version to .13
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: MCH3: CheckHooks performance issue

Post by madshi »

Updating to 3.1.13 did not improve the situation?

When you say "This app loads wldp.dll a few thousand times" does that mean the dll is loaded *and* unloaded a few thousand times? Or is it just loaded once and the load counter increased to a couple thousand times?
EaSy
Posts: 150
Joined: Tue Oct 23, 2012 12:33 pm

Re: MCH3: CheckHooks performance issue

Post by EaSy »

Nope, 3.1.13 did not change a thing. It is still slow.

Yes, I mean LoadLibrary and FreeLibrary. The same way as the test sample does. The usecase is without MCH the app loads for about 1minute, but with MCH it loads for about 3 and half minutes.
EaSy
Posts: 150
Joined: Tue Oct 23, 2012 12:33 pm

Re: MCH3: CheckHooks performance issue

Post by EaSy »

Hi, any progress?

PP
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: MCH3: CheckHooks performance issue

Post by madshi »

I'm sorry for taking so long. I'm currently working on some stability issues reported by users, which are somewhat more important than performance issues. I should get to this performance problem some time this week, though.
EaSy
Posts: 150
Joined: Tue Oct 23, 2012 12:33 pm

Re: MCH3: CheckHooks performance issue

Post by EaSy »

Great,
thx.

PP
EaSy
Posts: 150
Joined: Tue Oct 23, 2012 12:33 pm

Re: MCH3: CheckHooks performance issue

Post by EaSy »

Hi, any progress?

PP
EaSy
Posts: 150
Joined: Tue Oct 23, 2012 12:33 pm

Re: MCH3: CheckHooks performance issue

Post by EaSy »

Hi, any progress?

PP
EaSy
Posts: 150
Joined: Tue Oct 23, 2012 12:33 pm

Re: MCH3: CheckHooks performance issue

Post by EaSy »

Hi, any progress? :confused:

PP
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: MCH3: CheckHooks performance issue

Post by madshi »

I'm sorry for taking so long. I'm hoping to get a look at this in the next 2 days.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: MCH3: CheckHooks performance issue

Post by madshi »

Here's a test build with some CheckHooks performance improvements. Hope the speed up is sufficient for you?

http://madshi.net/madCollectionBeta.exe (installer 2.8.0.7)

I've implemented the changes in both v3 and v4.
EaSy
Posts: 150
Joined: Tue Oct 23, 2012 12:33 pm

Re: MCH3: CheckHooks performance issue

Post by EaSy »

It works! Thx.

pp
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: MCH3: CheckHooks performance issue

Post by madshi »

Glad to hear that!
Post Reply