C/C++ HOOK API£¨ÔÀíÉîÈëÆÊÎöÖ®
9Ô¶¼¿ì½áÊøÁË£¬Ö®Ç°Ò»Ö±Ã¦µ½Ð´×Ô¼ºµÄ¶«Î÷¼ÓÉÏÉÏ°à¡£»ù±¾Ã»ÓÐʱ¼äÑо¿Ï»ã±àºÍC C++·½ÃæµÄ¸ÐÐËȤµÄ¶«Î÷¡£ÔÙÔõô˵Â9Ô»¹ÊǵÃдһƪÈö£¬ÒÔºóÿÔÂÖÁÉÙһƪ°É¡£¸ø×Ô¼º¶¨ÁË£¬Ï£Íû´ó¼Ò¼à¶½¡£ºÙºÙ£¡
ÕâƪÎÄÕ¾ÍÀ´Ì¸Ì¸Æ½³£ºÜ³£¼ûµÄHOOK¼¼Êõ£¬ÕâÀïÄØ¡£Ð´µÃ±È½Ï¼òµ¥£¬·½·¨ºÜ¶à¡£Ö»½²ÔÀí£¡Ï£Íû´óÄñÃDZðÍÂÎÒ¿ÚË®¹þ - -¡£ºÃ£¡ÇÐÈëÕýÌâ¡£
Ê×ÏÈÊǸÅÄî°É¡£Ê²Ã´Êǹ³×Ó£¨HOOK£©£¿
¹³×Ó(Hook)£¬ÊÇWindowsÏûÏ¢´¦Àí»úÖƵÄÒ»¸öƽ̨,Ó¦ÓóÌÐò¿ÉÒÔÔÚÉÏÃæÉèÖÃ×Ó³ÌÒÔ¼àÊÓÖ¸¶¨´°¿ÚµÄijÖÖÏûÏ¢£¬¶øÇÒËù¼àÊӵĴ°¿Ú¿ÉÒÔÊÇÆäËû½ø³ÌËù´´½¨µÄ¡£µ±ÏûÏ¢µ½´ïºó£¬ÔÚÄ¿±ê´°¿Ú´¦Àíº¯Êý֮ǰ´¦ÀíËü¡£¹³×Ó»úÖÆÔÊÐíÓ¦ÓóÌÐò½Ø»ñ´¦ÀíwindowÏûÏ¢»òÌض¨Ê¼þ¡£
¹³×Óʵ¼ÊÉÏÊÇÒ»¸ö´¦ÀíÏûÏ¢µÄ³ÌÐò¶Î£¬Í¨¹ýϵͳµ÷Ó㬰ÑËü¹ÒÈëϵͳ¡£Ã¿µ±Ìض¨µÄÏûÏ¢·¢³ö£¬ÔÚûÓе½´ïÄ¿µÄ´°¿ÚÇ°£¬¹³×Ó³ÌÐò¾ÍÏȲ¶»ñ¸ÃÏûÏ¢£¬Ò༴¹³×Óº¯ÊýÏȵõ½¿ØÖÆȨ¡£Õâʱ¹³×Óº¯Êý¼´¿ÉÒÔ¼Ó¹¤´¦Àí£¨¸Ä±ä£©¸ÃÏûÏ¢£¬Ò²¿ÉÒÔ²»×÷´¦Àí¶ø¼ÌÐø´«µÝ¸ÃÏûÏ¢£¬»¹¿ÉÒÔÇ¿ÖƽáÊøÏûÏ¢µÄ´«µÝ¡£
ÕâÉÏÃæÖ»ÊÇÒ»¸ö¸ÅÄ¶ÔËüÓÐËùÁ˽â¶øÒÑ¡£ÉÏÃæÖ÷ÒªÓ¦ÓÃÔÚWindowsÏûÏ¢´¦Àí»úÖÆÀïÃæµÄÒ»¸ö½âÊÍ¡£ÕâÀïÎÒÖ»Êǵ¥´¿µÄ̸̸À¹½ØÎÒÃdz£ÓõÄLoadLibraryA¼ÓÔØÕâ¸öº¯Êý¡£ÈÃÎÒÃǵijÌÐò»òÕßÄ¿±ê³ÌÐòÔÚµ÷ÓÃÕâ¸öº¯Êý¼ÓÔØÁ´½Ó¿âµÄʱºò£¬ÏÈÖ´ÐÐÎÒÃÇ×Ô¼ºÐ´µÄº¯Êý£¬È»ºóÔÚ½øÐÐÕý³£¼ÓÔØ¡£Í¨Ë×µÄ˵¾ÍÊÇa----->b. ÎÒÃÇÔÚÖмä¼ÓÉÏÒ»¸öc¡£ a-------->c----->bÈÃËûÏÈÖ´ÐÐcÈ»ºóÔÙÖ´ÐÐb¡£ÕâÀïµÄc¾ÍÊÇÎÒÃÇ×Ô¼ºµÄº¯ÊýÁË¡£
ºÇºÇ£¬¸ÅÄî˵µÃ²î²»¶àÁË£¬¿ªÊ¼Ðж¯Ð´´úÂëÈö£º
#include <iostream>
#include <Windows.h>
using namespace std;
#pragma warning( disable: 4309 )
#pragma warning( disable: 4311 )
typedef HMODULE ( WINAPI *HOOKAPI )( IN LPCSTR );
#define MYHOOKMETHOD ( __fun ) HMODULE WINAPI __fun
#define DECLARE_REGISTER ( __0bj, __lawfunc, __newfunc ) Inline_Hook< HOOKAPI, 1 > __Obj( __lawfunc, __newfunc )
struct __InlineHOOK_Base
{
DWORD _argsBytes;
void* _lawFunc;
void* _newFunc;
char _lawByteCode[16];
char _newByteCode[16];
bool unhook ( void )
{
&nbs
Ïà¹ØÎĵµ£º
ÔÚʹÓÃCÓïÑÔ±àд´óÐ͹¤³ÌʱҪÓõ½ÃæÏò¶ÔÏóÓïÑÔÖеÄһЩÌØÐÔ£¨ÄÚºËÖÐijЩ²¿·Ö¾ÍÓ¦ÓÃÁËÕâЩÌØÐÔ£©¡£CÓïÑÔÊÇ»ùÓÚÎļþµÄÀ࣬static¹Ø¼ü×ÖÉùÃ÷˽ÓÐÊý¾Ý³ÉÔ±£¬¹«ÓÐÊý¾Ý³ÉÔ±±ØÐ붨Ò嵽ͷÎļþ£¬»òÓÉÆäËüÎļþʹÓÃextern¹Ø¼ü×ÖÉùÃ÷À´Ê¹Óᣵ«ºóÕßÒýÓùØϵ²»ÇåÎú¡£Í·Îļþ¾Í³ÉÁ˹«ÓÐÊý¾Ý³ÉÔ±ÉùÃ÷µÄµØ·½¡£
Í·ÎļþÖÐÓ¦¸Ã°üº¬ÒÔϼ°·½ÃæÄÚ ......
·ûºÅ
C- Òâ˼ÊÇ°´×¡ Ctrol ¼ü
M- ÒâÖ¸ Meta ¼ü (¼üÅÌÉÏÈôÎÞMeta ¼ü£¬Ôò¿ÉÒÔALT ESC ¼üÀ´È¡¶ø´úÖ®)
DEL ÒâÖ¸Í˸ñ¼ü (²»ÊÇ É¾³ý(Delete) key)
RET ÒâÖ¸»Ø³µ¼ü
SPC ÒâÖ¸¿Õ¸ñ¼ü
ESC ÒâÖ¸Escape¼ü
TAB ÒâÖ¸Tab¼ü
Ïñ "C-M-" (or "M-C") ......
ÓüÇʱ¾Ð´C³ÌÐò£¬²¢±àÒë¡£ ¸Õ×°ºÃµÄϵͳ
ÖÐÒѾÓÐGCCÁË£¬µ«ÊÇÕâ¸öGCCʲôÎļþ¶¼²»ÄܱàÒ룬ÒòΪûÓÐһЩ±ØÐëµÄÍ·Îļþ£¬ËùÒÔÒª°²×°build-essentialÕâ¸öÈí¼þ
°ü£¬°²×°ÁËÕâ¸ö°ü»á×Ô¶¯°²×°ÉÏg++,libc6-dev,linux
-libc-dev,libstdc++6-4.1-devµÈһЩ±ØÐëµÄÈí¼þºÍÍ·ÎļþµÄ¿â¡£
¿ÉÒÔÔÚÐÂÁ¢µÃÀïÃæË ......
¸´ÔÓµÄC\C++ÉùÃ÷£¬³£³öÏÖÔÚѧУµÄ¿¼¾í£¬ÃæÊÔÌâ»òÊÇÅ£ÈËÀÏÍâµÄ´úÂëÖС£
ÎÒÃÇÔÚʵ¼ÊµÄ¹¤×÷ÖУ¬Ó¦¸Ã¾¡¿ÉÄÜÉÙʹÓø´ÔÓµÄÉùÃ÷¡£¸´ÔÓµÄÉùÃ÷£¬»áÈÃÔĶÁÄú´úÂëµÄÈ˺ÜÊÇÓôÃÆ¡£
ËäÈ»²»Ê¹ÓÃÕâÖÖ¸´ÔÓµÄÉùÃ÷£¬µ«»¹ÊÇÓ¦¸Ã°Ñ½«ÈçºÎ½âÎöÕâÖÖ¸´ÔÓµÄÉùÃ÷µÄ·½·¨¼ÇÔÚÐÄÖС£
ËùÒÔ£¬ÎÒ°ÑÕâÖÖ·½·¨¼Ç¼ÏÂÀ´£¬ÒÔ±¸²»Ê±Ö®Ðè¡£
ÈëÃÅÌâ
1) Ò»¸öÕûÐ ......