Tag: 包装纸

如何在C中包装现有函数

我试图包装现有的function。 下面的代码是完美的工作。 #include int __real_main(); int __wrap_main() { printf(“Wrapped main\n”); return __real_main(); } int main() { printf(“main\n”); return 0; } 命令: gcc main.c -Wl,-wrap,main 输出: Wrapped main main 所以我用temp改变了主要function。 我的目标是包装temp()函数。 以下是代码 temp.c #include int temp(); int __real_temp(); int __wrap_temp() { printf(“Wrapped temp\n”); return __real_temp(); } int temp() { printf(“temp\n”); return 0; } int main() { […]