RudjiGames / MTuner

MTuner is a C/C++ memory profiler and memory leak finder for Windows, PlayStation 4 and 3, Android and other platforms
BSD 2-Clause "Simplified" License
2.63k stars 145 forks source link

One single unknown module, all others are fine #52

Closed gjaegy closed 4 years ago

gjaegy commented 4 years ago

Hi, we have a software that loads some internal windows DLL files, which don't have the .dll extension (.dlg). Just a naming convention.

I've noticed however those DLL don't appear in MTuner "Modules" list. Also, the calls that are supposed to be made from within that file are tagged as "Unknown" in the stack trace.

So, I assume there is some kind of filtering based on the file extensions (.exe, .dll, etc.). Is that correct ? How could I add our custom extensions ?

thanks !

gjaegy commented 4 years ago

Actually I've recompiled the project so that the output is a .DLL file, but the issue remains, so I assume the problem is something else.

Any idea what could prevent the DLL to be recognized by MTuner ? This DLL is loaded dynamically (using LoadLibraryEx()), entry point is fetched using a GetProcAddress() call. Shouldn't make any difference to me...

See below, the calls occuring in the missing DLL are indicated as "unknown":

image

milostosic commented 4 years ago

Do you mind attaching a capture so I can debug it on my side? The only thing that crosses my mind is if the library was loaded, unloaded and then loaded again but on a different address range - but would be nice to have a repro case.

gjaegy commented 4 years ago

Thanks for taking the time to respond. I've uploaded a capture on wetransfer, would rather not publish the link publically, how can I send it to you ? I've tried through twitter but I can't send you a message... Could you maybe send me your email adress through a twitter message (@gjaegy)?

milostosic commented 4 years ago

I've checked the capture and there are no calls to register a module (DLL). Few details are missing. how is the DLL loaded? How was the capture created? If LoadLibraryExA was hooked, the DLL information would have been saved but it's not so...

gjaegy commented 4 years ago

It's loaded through LoadLibraryEx(). So I would assume the hook doesn't work as expected. Should it work with VS2019 ? They've changed the CRT mechanism I think (universal CRT DLLs)... Or should I hook anything manually?

milostosic commented 4 years ago

Apparently hook doesn't work as expected in this case. I haven't tried with 2019. You could try calling rmemAddModuleC to register DLL path, base address and size manually as a workaround.

gjaegy commented 4 years ago

OK will try that. I assume the expected base address and size are what's returned by GetModuleInformation() on windows, is that correct?

milostosic commented 4 years ago

Yes, that's the info.

gjaegy commented 4 years ago

I haven't been able to try the workaround this afternoon. I'm out of the office next but will try once back in the office. I'll keep you informed. Thanks a lot for your help 👍

gjaegy commented 4 years ago

Hi, I had a chance to try your suggestion, and I confirm it works. Thanks a lot for your help !

Let me know once you've implemented a proper fix in the official branch (in the case you've planned to do so!).

milostosic commented 4 years ago

All fixes should already be there in the latest release. Thanks for helping out!