The specified module could not be found error.

c++ / delphi package - dll injection and api hooking
Post Reply
swifteg
Posts: 4
Joined: Wed Jul 15, 2015 2:03 pm

The specified module could not be found error.

Post by swifteg »

I have the following unmanaged c++ code

Code: Select all

#include "stdafx.h"
#include <conio.h>
#include "windows.h"
#include "madCHook.h"
#include <tlhelp32.h>

HANDLE GetProcessByName(PCWSTR name)
{
	DWORD pid = 0;

	HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
	PROCESSENTRY32 process;
	ZeroMemory(&process, sizeof(process));
	process.dwSize = sizeof(process);

	if (Process32First(snapshot, &process))
	{
		do
		{
			if (_wcsicmp(process.szExeFile, name) == 0)
			{
				pid = process.th32ProcessID;
				break;
			}
		} while (Process32Next(snapshot, &process));
	}

	CloseHandle(snapshot);

	if (pid != 0)
		return OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);

	return NULL;
}

extern "C"
{
	__declspec(dllexport) bool Inject(const char *p, const char* l)
	{
		return InjectLibraryW((DWORD)GetProcessByName((wchar_t *)p), (wchar_t *)l);
	}

	__declspec(dllexport) bool Remove(const char *p, const char* l)
	{
		return UninjectLibraryW((DWORD)GetProcessByName((wchar_t *)p), (wchar_t *)l);
	}
}
When I call these functions from my managed c# code, I get the "dll could not be loaded, The specified module could not be found error." exception, even though I've included .h and .lib files into my .dll project, moved the madCHook.dll file to system32 and launched the evaluation exe file. What could be the problem here? Does the library use a dependency I might be missing? Thanks.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: The specified module could not be found error.

Post by madshi »

madCHook.dll is only included in the evaluation version. It doesn't exist in the commercial edition. So I'm not sure if it's worth it trying to make it work with managed C#. For hooking related stuff you should really be using unmanaged code. The commercial madCodeHook version only comes with lib files for MSVC++ and DCUs for Delphi. Making all this work with C# will probably require some extra work on your side. Unfortunately I've zero knowledge about / experience with managed development. So I can't really help much in that area...
swifteg
Posts: 4
Joined: Wed Jul 15, 2015 2:03 pm

Re: The specified module could not be found error.

Post by swifteg »

Well, I am doing hooking related stuff with unmanaged c++, it's just that I'm interfacing with it using pinvoke. The problem is that I can't get these functions to work, as it seems to be missing some dependancy and dependancy walker refuses to work properly on my pc. Eh, I wanted to make sure if I'm including and using the evaluation version properly.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: The specified module could not be found error.

Post by madshi »

Yeah, well, we could try making it work together. But then, it would be work that would be mostly useless as the commercial version doesn't have a madCHook.dll. So I rather think there would be wiser ways to spend our time. What do you think?
swifteg
Posts: 4
Joined: Wed Jul 15, 2015 2:03 pm

Re: The specified module could not be found error.

Post by swifteg »

мамку твою ебал )))0
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: The specified module could not be found error.

Post by madshi »

Huh? I don't speak Russian... :-x
swifteg
Posts: 4
Joined: Wed Jul 15, 2015 2:03 pm

Re: The specified module could not be found error.

Post by swifteg »

Nothing, it's a shame a static library is for commercial use only - there's no way to try the library out since you don't seem to be helping evaluation version users.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: The specified module could not be found error.

Post by madshi »

Well, you can try it out with unmanaged code. For trying out writing some simple demo tests should suffice? E.g. you could take some of the madCodeHook demos, change them a bit to suit your needs. Shouldn't that be enough to test whether madCodeHook does what you need?

I would like to help as much as I can. But I have zero knowledge about managed development. So I don't really know how to help with that.

There's a very good reason why the commercial version doesn't come with a madCHook.dll: madCodeHook has been misused by malware developers in the past. If legit software using madCodeHook would ship with a madCHook.dll, malware writers could simply copy the madCHook.dll and call the exported APIs. Obviously that would be a very bad thing. So madCHook.dll is no longer available, to protect madCodeHook from being misused by malware writers in the future.
Post Reply