驅動程式 - VxWorks - 23.09 - C/C++ - Module Hook



參考資訊:
https://zhuanlan.zhihu.com/p/597577575
https://studies.ac.upc.edu/doctorat/ENGRAP/VxWorks-device-drivers.htm
https://forums.windriver.com/t/vxworks-software-development-kit-sdk/43
https://mail.prz-rzeszow.pl/~ssamolej/vxworks/vxworks_kernel_programmers_guide_6.6.pdf
https://d13321s3lxgewa.cloudfront.net/downloads/wrsdk-vxworks7-docs/2309/README_qemu.html
https://learning.windriver.com/path/vxworks7-essentials-workbench-and-tools/vxworks-kernel-shell

main.c

#include <stdio.h>
#include <private/rtpLibP.h>

int create_hook(MODULE_ID moduleId)
{
    printf("%s: %s\n", __func__, moduleNameGet(moduleId));
    return OK;
}

int add_hook(void)
{
    moduleCreateHookAdd(create_hook);
    return OK;
}

編譯

$ wr-cc main.c -o main -dkm

執行

-> ld < main

-> add_hook

-> ld < main
    create_hook: main

-> unld "main"