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. 【消息队列MQ】各类MQ比较

    目录(?)[-] RabbitMQ Redis ZeroMQ ActiveMQ JafkaKafka 目前业界有很多MQ产品,我们作如下对比: RabbitMQ 是使用Erlang编写的一个开源的消息 ...

  2. POJ 2386

    http://poj.org/problem?id=2386 这个题目与那个POJ 1562几乎是差不多的,只不过那个比这个输入要复杂一些 #include <stdio.h> #incl ...

  3. 项目总结(二)--- CocoaPods的简单介绍与使用

    先谈下,我们为什么要使用CocoaPods,它能为我们做什么吧. 所有开发过iOS应用的小伙伴们都知道,在整个项目中,第三方库的引用必不可少(特别感谢那些优秀第三方开源库的作者,给我们提供了多大的便捷 ...

  4. LINUX调优

    一.Linux系统调优及安全设置 系统安装安全最小化原则说明 ◆安装linux系统最小化,即选包最小化,yum安装软件最小化. ◆开机自启动程序服务最小化,即无用的服务不开启. ◆操作命令最小化原则, ...

  5. linux常见问题集锦

    本文转自 http://bbs.chinaunix.net/thread-3668921-1-1.html,在此感谢作者分享 一.填空题: 1. 在Linux系统中,以 文件 方式访问设备 . 2. ...

  6. Android之查看网络图片和网页HTML

    网络编程是Android应用中很重要的一部分,本文主要讲述了利用HttpURLConnection获取网络图片和HTML的方法. 获取网络图片 public class MainActivity ex ...

  7. hadoop的关键进程

    hadoop集群中主要进程有master:   NameNode, ResourceManager,slaves:   DataNode, NodeManager,  RunJar, MRAppMas ...

  8. Linux命令--文件管理

    1.ls ls -a 列出目录下是所有文件 ls -l 列出文件的详细信息   2.cd cd /root 进入更目录下的root文件夹 cd file 进入当前目录的file文件夹 cd .. 进入 ...

  9. 1.单件模式(Singleton Pattern)

    意图:为了保证一个类仅有一个实例,并提供一个访问它的全局访问点. 1.简单实现(多线程有可能产生多个实例) public class CommonSigleton { /// <summary& ...

  10. Web性能测试中的几个关键指标

    系统吞吐量 吞吐量指单位时间内系统处理的请求数量,体现系统的整体处理能力.对于网站,可以用"请求数/秒"或是"页面数/秒"来衡量,也可以用"访问人数/ ...