Exemplo n.º 1
0
void HookDefWindowProc()
{
	BOOST_LOG_TRIVIAL(info) << "Hooking USER32!DefWindowProcA (ANSI)";

	if (MH_CreateHookApiEx(L"user32", "DefWindowProcA", &DetourDefWindowProc, &OriginalDefWindowProc) != MH_OK)
	{
		BOOST_LOG_TRIVIAL(error) << "Couldn't hook USER32!DefWindowProcA (ANSI)";
		return;
	}

	BOOST_LOG_TRIVIAL(info) << "Hooking USER32!DefWindowProcW (Unicode)";

	if (MH_CreateHookApiEx(L"user32", "DefWindowProcW", &DetourDefWindowProc, &OriginalDefWindowProc) != MH_OK)
	{
		BOOST_LOG_TRIVIAL(error) << "Couldn't hook USER32!DefWindowProcW (Unicode)";
		return;
	}

	if (MH_EnableHook(MH_ALL_HOOKS) != MH_OK)
	{
		BOOST_LOG_TRIVIAL(error) << "Couldn't enable DefWindowProc hooks";
		return;
	}

	BOOST_LOG_TRIVIAL(info) << "DefWindowProc hooked";
}
Exemplo n.º 2
0
// main logic
int init()
{
	// initialize hook engine
	if (MH_Initialize() != MH_OK)
	{
		return -1;
	}

	// create kernel32!CreateFileW hook (unicode)
	if (MH_CreateHookApiEx(L"kernel32", "CreateFileW", &DetourCreateFileW, &OriginalCreateFileW) != MH_OK)
	{
		return -2;
	}

	// create kernel32!CreateFileA hook (ANSI)
	if (MH_CreateHookApiEx(L"kernel32", "CreateFileA", &DetourCreateFileA, &OriginalCreateFileA) != MH_OK)
	{
		return -3;
	}

	// enable all hooks
	if (MH_EnableHook(MH_ALL_HOOKS) != MH_OK)
	{
		return -5;
	}

	// block this thread infinitely to keep hooks active
	return WaitForSingleObject(INVALID_HANDLE_VALUE, INFINITE);
}
Exemplo n.º 3
0
void HookSSL()
{
	if (MH_Initialize() != MH_OK)
		printf("Init failed!\n");
	else
		printf("Init succeded!\n");
	if (MH_CreateHookApiEx(L"secur32.dll", "DecryptMessage", DetouredDecrypt, (LPVOID*)&orgDecrypt, true) != MH_OK)
        printf("Decrypthook failed!\n");
	else
		printf("Decrypthook succeded!\n");
	if (MH_CreateHookApiEx(L"secur32.dll", "EncryptMessage", DetouredEncrypt, (LPVOID*)&orgEncrypt, true) != MH_OK)
        printf("Encrypthook failed!\n");
	else
		printf("Encrypthook succeded!\n");
	MH_ApplyQueued();
}