Click here to Skip to main content
15,887,746 members
Articles / Programming Languages / C++

HookAPI source code

Rate me:
Please Sign up or sign in to vote.
3.09/5 (36 votes)
31 Jan 20052 min read 390.5K   9.6K   117  
A system wide api source code for windows api hook developpers
// APIInfo.h: interface for the CAPIInfo class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_APIINFO_H__48FBE38B_70DC_4906_A99D_4314ED371ECF__INCLUDED_)
#define AFX_APIINFO_H__48FBE38B_70DC_4906_A99D_4314ED371ECF__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

typedef void (WINAPI *APIFUNC)(void);

typedef struct tagAPIINFO
{
	char module_name[100];
	char api_name[50];
	char my_api_name[50];
	char my_friend_api_name[50];
	int param_count;
	int start_pos;
	APIFUNC old_api, my_api;
	int f_hooked;
	BYTE save_bytes[20];
#ifdef WIN95
	HANDLE hMutex, m_hMutex;
#else
	CRITICAL_SECTION cs;
	DWORD old_protection_flags;
#endif
	tagAPIINFO *pnext;
}APIINFO;

class CAPIInfo
{
public:
	CAPIInfo();
	virtual ~CAPIInfo();
	
	int m_count;
	APIINFO *m_pInfo;

	APIINFO *Add(char *module_name, char *api_name, char *my_api_name,
		int param_count, APIFUNC old_api=NULL, APIFUNC my_api =NULL,
		char *my_friend_api_name =NULL, int start_pos=0);
	int DeleteAll();
	
	APIINFO *FindByMyAPI(APIFUNC my_api);
	APIINFO *FindByOldAPI(APIFUNC old_api);
	APIINFO *FindByAPIName(char *api_name);
	APIINFO *FindByMyAPIName(char *my_api_name);

	int lock(APIINFO *pinfo);
	int unlock(APIINFO *pinfo);
};

#endif // !defined(AFX_APIINFO_H__48FBE38B_70DC_4906_A99D_4314ED371ECF__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
China China
An old C programmer in China.

Comments and Discussions