MCH3: CheckHooks performance issue

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

MCH3: CheckHooks performance issue

Postby EaSy » Tue Sep 13, 2016 11:49 am

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
EaSy
 
Posts: 146
Joined: Tue Oct 23, 2012 12:33 pm

Re: MCH3: CheckHooks performance issue

Postby madshi » Wed Sep 14, 2016 12:58 pm

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?
madshi
Site Admin
 
Posts: 9230
Joined: Sun Mar 21, 2004 5:25 pm

Re: MCH3: CheckHooks performance issue

Postby EaSy » Thu Sep 15, 2016 5:39 am

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: 146
Joined: Tue Oct 23, 2012 12:33 pm

Re: MCH3: CheckHooks performance issue

Postby EaSy » Wed Sep 21, 2016 5:00 am

Hi, any progress?

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

Re: MCH3: CheckHooks performance issue

Postby madshi » Mon Sep 26, 2016 10:36 am

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.
madshi
Site Admin
 
Posts: 9230
Joined: Sun Mar 21, 2004 5:25 pm

Re: MCH3: CheckHooks performance issue

Postby EaSy » Tue Sep 27, 2016 12:38 pm

Great,
thx.

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

Re: MCH3: CheckHooks performance issue

Postby EaSy » Mon Oct 03, 2016 5:25 am

Hi, any progress?

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

Re: MCH3: CheckHooks performance issue

Postby EaSy » Thu Oct 13, 2016 3:11 pm

Hi, any progress?

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

Re: MCH3: CheckHooks performance issue

Postby EaSy » Wed Oct 19, 2016 6:48 am

Hi, any progress? :confused:

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

Re: MCH3: CheckHooks performance issue

Postby madshi » Wed Oct 19, 2016 2:31 pm

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: 9230
Joined: Sun Mar 21, 2004 5:25 pm

Re: MCH3: CheckHooks performance issue

Postby madshi » Thu Oct 27, 2016 5:51 pm

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.
madshi
Site Admin
 
Posts: 9230
Joined: Sun Mar 21, 2004 5:25 pm

Re: MCH3: CheckHooks performance issue

Postby EaSy » Thu Nov 03, 2016 3:37 pm

It works! Thx.

pp
EaSy
 
Posts: 146
Joined: Tue Oct 23, 2012 12:33 pm

Re: MCH3: CheckHooks performance issue

Postby madshi » Thu Nov 03, 2016 3:40 pm

Glad to hear that!
madshi
Site Admin
 
Posts: 9230
Joined: Sun Mar 21, 2004 5:25 pm


Return to madCodeHook

Who is online

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

cron