api hooking

I Worked on this code Earlier
==============================================
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// HookTestCpp.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include "ExtendedHook.h"

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
	typedef int (WINAPI * pMessageBox)(HWND myhandle, LPCWSTR text, LPCWSTR caption, UINT types); //function prototype
int WINAPI MessageBoxWHooker(HWND myhandle, LPCTSTR text, LPCTSTR caption, UINT types); //function hook
EHOOKSTRUCT myApi; //essential structure
 
pMessageBox myMessageBox = NULL; //optional, but i think it is useful
 
	if (InstallEHook("MessageBoxW", L"User32.dll", &myApi, &MessageBoxWHooker) == false){
                                          wcout<<"Error hooking"<<endl;
                                          return 1;
    }

	else{
	
			wcout<<"Hooking Sucessful"<<endl;
	}
	return 0;
}

=============================================

I did some debugging, for errors, but i got something like this as my error, why am i getting this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
1
1>Build started 20/10/2013 16:49:29.
1>InitializeBuildStatus:
1>  Touching "Debug\HookTestCpp.unsuccessfulbuild".
1>ClCompile:
1>  All outputs are up-to-date.
1>  HookTestCpp.cpp
1>HookTestCpp.obj : error LNK2019: unresolved external symbol "bool __cdecl InstallEHook(char const *,wchar_t const *,struct _EHOOKSTRUCT *,void *)" (?InstallEHook@@YA_NPBDPB_WPAU_EHOOKSTRUCT@@PAX@Z) referenced in function _wmain
1>HookTestCpp.obj : error LNK2019: unresolved external symbol "int __stdcall MessageBoxWHooker(struct HWND__ *,wchar_t const *,wchar_t const *,unsigned int)" (?MessageBoxWHooker@@YGHPAUHWND__@@PB_W1I@Z) referenced in function _wmain
1>C:\Users\SpaxxxPC\Desktop\hook\HookTestCpp\Debug\HookTestCpp.exe : fatal error LNK1120: 2 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:04.27
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
closed account (13bSLyTq)
Hi,

The hook here is failing here, because the InstallEHook() is not present in ExtendedHook.h, and the callback mechanism , MessageBoxWHooker is not defined nor exists.

Look man, these are basic errors anyone who knows basics will understand it, I think you are way too ahead of your self. Slow down.

Good Luck!
Topic archived. No new replies allowed.