myFun.h

   1: #include <stdio.h>

   2:  

   3: void __cyg_profile_func_enter(void *this_fn, void *call_site)

   4:         __attribute__((no_instrument_function));

   5: void __cyg_profile_func_enter(void *this_fn, void *call_site) {

   6:     printf("Hello I am entering\n");

   7: } /* __cyg_profile_func_enter */

   8: void __cyg_profile_func_exit(void *this_fn, void *call_site)

   9:         __attribute__((no_instrument_function));

  10: void __cyg_profile_func_exit(void *this_fn, void *call_site) {

  11:     printf("Hello, I am exitint\n");

  12: } /* __cyg_profile_func_enter */

  13:  

     main.c

   1: #include <stdio.h>

   2: #include "myfun.h"

   3: void myStartupFun (void) __attribute__ ((constructor));

   4: void myCleanupFun (void) __attribute__ ((destructor));

   5: int foo() {

   6:     return 2;

   7: }

   8: int bar() {

   9:    return 1;

  10: }

  11: int main(int argc, char** argv) {

  12:     int i ,j;

  13:     i = foo();

  14:     j = bar();

  15:     printf("foo=%d bar=%d\n", i, j);

  16:     return 0;

  17: }

 

when you compile this file, please put the myFun.h in the same directory with main.c, and MUST with flag “-finstrument-functions”

Hook to function的更多相关文章

  1. 黄聪:wordpress获取hook所有function

    list_hooked_functions('wp_footer'); function list_hooked_functions($tag=false) { global $wp_filter; ...

  2. [React] Use the React Effect Hook in Function Components

    Similar to the State Hook, the Effect Hook is “first-class” in React and handy for performing side e ...

  3. [MetaHook] GameUI hook

    Hook GameUI function. #include <metahook.h> #include <IGameUI.h> IGameUI *g_pGameUI = ; ...

  4. [MetaHook] BaseUI hook

    Hook IBaseUI function. #include <metahook.h> #include <IBaseUI.h> IBaseUI *g_pBaseUI = ; ...

  5. [MetaHook] Surface hook

    Hook ISurface function. #include <metahook.h> #include <vgui/ISurface.h> using namespace ...

  6. Linux LSM(Linux Security Modules) Hook Technology

    目录 . 引言 . Linux Security Module Framework Introduction . LSM Sourcecode Analysis . LSMs Hook Engine: ...

  7. HOOK钩子 - 钩子函数说明

    翻译参考自MaybeHelios的blog: http://blog.csdn.net/maybehelios/ 通过SetWindowsHookEx方法安装钩子,该函数指定处理拦截消息的钩子函数(回 ...

  8. 【Hook技术】实现从"任务管理器"中保护进程不被关闭 + 附带源码 + 进程保护知识扩展

    [Hook技术]实现从"任务管理器"中保护进程不被关闭 + 附带源码 + 进程保护知识扩展 公司有个监控程序涉及到进程的保护问题,需要避免用户通过任务管理器结束掉监控进程,这里使用 ...

  9. 使用fastcall 代替汇编hook thiscall

    利用fastcall中ecx edx传递的特性,解决了ecx需要内嵌汇编才能实现hook thiscall函数的问题. #include <stdio.h> #include <st ...

随机推荐

  1. MFC 最大化 的时候控件 按比例变大

    在dlg类头文件中声明CPoint Old; 在BEGIN_MESSAGE_MAP()和END_MESSAGE_MAP()声明一个映射:ON_WM_SIZE() 这样以后就可以在M_SIZE事件的时候 ...

  2. zookeeper 配置详解

    http://blog.csdn.net/shenlan211314/article/details/6185176  因博主原创,所以不能转载 下面是更为详细的配置说明: 前面两篇文章介绍了Zook ...

  3. 【转】Linux Shell脚本调试技术

    本文转载自:https://www.ibm.com/developerworks/cn/linux/l-cn-shell-debug/ Shell脚本调试技术 本文全面系统地介绍了shell脚本调试技 ...

  4. DP:Bridging Signals(POJ 1631)

    不能交叉的引脚 (这一题的难度在于读题)题目大意:有一堆引脚(signals),左边一排,右边一排,左边从上到下,对应着连接右边的引脚(所有的引脚都被接上),现在引脚之间的连线有交叉,我们要桥接这些交 ...

  5. Gym 100801A Alex Origami Squares (求正方形边长)

    题目:传送门.(需要下载PDF) 题意:给定一个长方形,在长方形内部画三个相同的正方形,问正方形的边长最大是多大. 题解:根据长宽比例可以算出三种情况,如果长比宽大三倍以上,那么正方形边长就是宽:如果 ...

  6. Servlet之Cookie操作

    Java对cookie的操作比较简单,主要介绍下建立cookie和读取cookie,以及如何设定cookie的生命周期和cookie的路径问题. 1,建立一个无生命周期的cookie,即随着浏览器的关 ...

  7. Android之数据库操作

    安卓数据库帮助类 /** * 数据库帮助类,用于管理数据库 * @author Administrator * */ public class PersonSQLiteOpenHelper exten ...

  8. undefined reference to 'typeinfo for android::Thread'

    原因:工程使用了系统库libstagefright.so,而该库是Android系统用no-rtti方式编译出来的,因此我们的工程也必须要用no-rtti方式编译. 解决方法:在Application ...

  9. oracle 10g 学习之oracle管理(3)

    怎样将预先写好的sql脚本执行? select * from employees;→107条记录 利用 Oracle 企业管理器连接数据库服务器 点击打开以下界面: 此时已经连接成功了 用 Oracl ...

  10. eclipse + Android Studio 集成 Genymotion 模拟器

    Genymotion 官网 -- android 模拟器https://www.genymotion.com 虚拟机下载安装目录C:\Users\xxx\AppData\Local\Genymobil ...