首页
社区
课程
招聘
[求助]求一个TK_HookImportFunction函数使用的完整例子
发表于: 2016-3-16 11:51 5943

[求助]求一个TK_HookImportFunction函数使用的完整例子

2016-3-16 11:51
5943
libTKHooklib.so 只是一个so库,大大也没在论坛里写具体怎么使用,哪位大大有测试代码的例子,求一份参考。

[峰会]看雪.第八届安全开发者峰会10月23日上海龙之梦大酒店举办!

收藏
免费 1
支持
分享
最新回复 (6)
雪    币: 18
活跃值: (1039)
能力值: ( LV7,RANK:110 )
在线值:
发帖
回帖
粉丝
2
2016-3-16 12:59
0
雪    币: 118
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
....
2016-3-16 13:16
0
雪    币: 118
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
[QUOTE=猪会被杀掉;1420328]ELF-ARM-HOOK-Library

[/QUOTE]

这位大大 给的链接 我看了 里面也只是.h和so库文件,没有具体的 如何调用他们使用的例子啊
2016-3-16 13:22
0
雪    币: 18
活跃值: (1039)
能力值: ( LV7,RANK:110 )
在线值:
发帖
回帖
粉丝
5
人家不是给了注释掉的使用范例吗!!!!!!!!!!!!!!!!!!!!!!!!!!!

Skip to content
Personal Open source Business Explore
Sign upSign inPricingBlogSupport
 Watch 25  Star 72  Fork 73 ThomasKing2014/ELF-ARM-HOOK-Library
 Code  Issues 1  Pull requests 0  Pulse  Graphs
Branch: master Find file Copy pathELF-ARM-HOOK-Library/utils/TKHooklib.h
17b5907  on Nov 9, 2015
 Thomas King Fix some bugs
1 contributor
RawBlameHistory     74 lines (60 sloc)  1.77 KB
#ifndef _TKHOOKLIB_H
#define _TKHOOKLIB_H

#define SOINFO_NAME_LEN 128

#define HOOK_SUCCESS 0
#define HOOK_FAILED -1

typedef struct _HookStruct{
	char SOName[SOINFO_NAME_LEN];
	char FunctionName[SOINFO_NAME_LEN];
	void *NewFunc;
	void *OldFunc;
	void *occPlace;
}HookStruct;

#ifdef __cplusplus
extern "C" {
#endif

void TK_UnHookExportFunction(HookStruct *pHookStruct);

void TK_UnHookImportFunction(HookStruct *pHookStruct);

/*
**  Return: HOOK_SUCCESS or HOOK_FAILED
**	Example: 	Hook libfoo.so Import Function: puts
**	HookStruct HookPara;
**  strncpy(HookPara.SOName, "libfoo.so", strlen("libfoo.so"));
**	strncpy(HookPara.FunctionName, "puts", strlen("puts"));
**	HookPara.NewFunc = myputs;
**	TK_HookImportFunction(&HookPara);
*/
int TK_HookImportFunction(HookStruct *pHookStruct);

/*
[FONT="Arial Black"][SIZE="7"][B][B][COLOR="Red"]**  Return: HOOK_SUCCESS or HOOK_FAILED
**	Example: 	Hook libc.so Export Function: puts
**	HookStruct HookPara;
**  strncpy(HookPara.SOName, "libc.so", strlen("libc.so"));
**	strncpy(HookPara.FunctionName, "puts", strlen("puts"));
**	HookPara.NewFunc = myputs;
**	TK_HookExportFunction(&HookPara);[/COLOR][/B][/B][/SIZE][/FONT]
*/
int TK_HookExportFunction(HookStruct *pHookStruct);

/*
**  Return: HOOK_SUCCESS or HOOK_FAILED
**	Example: 	Inline Hook libc.so Function: puts
**	void* OldFunc = NULL;
**	TK_InlineHookFunction(puts, myputs, &OldFunc);
**	----------------------------------------------
** 	For the new implementation of HOOK Bridge, I suggest you add some lock to enhance the stability.
**		
**		
		int myputs(const char *string){
			// Do sth before calling ori-function
			pthread_mutex_lock(&hook_mutex);
			puts(string);
			pthread_mutex_unlock(&hook_mutex);
			
			// Do sth after calling ori-function
		}
**	
*/
int TK_InlineHookFunction(void *TargetFunc, void *NewFunc, void** OldFunc);

#ifdef __cplusplus
};
#endif

#endif
Status API Training Shop Blog About
© 2016 GitHub, Inc. Terms Privacy Security Contact Help
2016-3-16 13:25
0
雪    币: 118
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
看到了  谢谢大大
2016-3-16 13:45
0
雪    币: 303
活跃值: (179)
能力值: ( LV4,RANK:40 )
在线值:
发帖
回帖
粉丝
7
找king,如何HOOK Register
2016-3-17 21:00
0
游客
登录 | 注册 方可回帖
返回
//