Click here to Skip to main content
15,897,891 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 393.2K   9.6K   117  
A system wide api source code for windows api hook developpers
// ------------------------------------- //
// �����Ҫʹ�ñ��ļ����벻Ҫɾ����˵��  //
// ------------------------------------- //
//             HOOKAPI ��������          //
//   Copyright 2002 ���ɳ�� Paladin     //
//       www.ProgramSalon.com            //
// ------------------------------------- //

#include "stdafx.h"
#include <stdio.h>

#include "mydll.h"
#include "util.h"
#include "filter.h"

HINSTANCE g_hInstance =NULL;
CFileFilter g_Filter;

HANDLE WINAPI myFindFirstFile(LPCSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData)
{
	HANDLE h =FindFirstFile(lpFileName, lpFindFileData);
	if(h)
	{
		if(g_Filter.FilterName(lpFindFileData->cFileName, FILTER_FIND) || strstr(lpFindFileData->cFileName, "myabc123"))
		{
			memset(lpFindFileData, 0, sizeof(*lpFindFileData));
			if(!FindNextFile(h, lpFindFileData))
			{
				FindClose(h);
				//SetLastError(-1);
				return h;
			}
		}
	}
	return h; 
}

BOOL WINAPI myFindNextFile(HANDLE h, LPWIN32_FIND_DATA lpFindFileData)
{
	BOOL f =FindNextFile(h, lpFindFileData);
	if(f)
	{
		if(g_Filter.FilterName(lpFindFileData->cFileName, FILTER_FIND) || strstr(lpFindFileData->cFileName, "myabc123"))
			return FindNextFile(h, lpFindFileData);
	}
	return f; 
}

MYAPIINFO myapi_info[] =
{
	{"KERNEL32.DLL", "FindFirstFile(LPCSTR, LPWIN32_FIND_DATA)", "myFindFirstFile"},
	{"KERNEL32.DLL", "FindNextFile(HANDLE, LPWIN32_FIND_DATAW)", "myFindNextFile"},
	
	{NULL,NULL,NULL}
};

MYAPIINFO *GetMyAPIInfo()
{
	return &myapi_info[0];
}

BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
	g_hInstance =(HINSTANCE)hModule;
    return TRUE;
}

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