摘要:本文主要向大家介绍了C/C++知识点之mac ox驱动开发 c++版,通过具体的内容向大家展示,希望对大家学习C/C++知识点有所帮助。
本文主要向大家介绍了C/C++知识点之mac ox驱动开发 c++版,通过具体的内容向大家展示,希望对大家学习C/C++知识点有所帮助。
"
//IOKitTest.h
#include <IOKit/IOService.h>class com_osxkernel_driver_IOKitTest : public IOService { OSDeclareDefaultStructors(com_osxkernel_driver_IOKitTest)public: virtual bool init (OSDictionary* dictionary = NULL); virtual void free (void); virtual IOService* probe (IOService* provider, SInt32* score); virtual bool start (IOService* provider); virtual void stop (IOService* provider); };
//IOKitTest.cpp
#include ""IOKitTest.h""#include <IOKit/IOLib.h>//定义超类#define super IOService//表示提供构造与析构函数的声明 以及元数据OSDefineMetaClassAndStructors(com_osxkernel_driver_IOKitTest, IOService)//构造函数bool com_osxkernel_driver_IOKitTest::init (OSDictionary* dict) { bool res = super::init(dict); IOLog(""IOKitTest::init\n""); return res; }void com_osxkernel_driver_IOKitTest::free (void) { IOLog(""IOKitTest::free\n""); super::free(); }//检查硬件设备IOService* com_osxkernel_driver_IOKitTest::probe (IOService* provider, SInt32* score) { IOService *res = super::probe(provider, score); IOLog(""IOKitTest::probe\n""); return res; }bool com_osxkernel_driver_IOKitTest::start (IOService *provider) { bool res = super::start(provider); IOLog(""IOKitTest::start\n""); return res; }void com_osxkernel_driver_IOKitTest::stop (IOService *provider) { IOLog(""IOKitTest::stop\n""); super::stop(provider); }
注意点:
内核版本
编译器版本
安装:
liuhailong:~ liuhailong$ sudo chown -R root:wheel /Users/liuhailong/Library/Developer/Xcode/DerivedData/IOKitTest-grjzacxpxpyxiidhzzobgihdxfqm/Build/Products/Debug/IOKitTest.kext liuhailong:~ liuhailong$ sudo kextload /Users/liuhailong/Library/Developer/Xcode/DerivedData/IOKitTest-grjzacxpxpyxiidhzzobgihdxfqm/Build/Products/Debug/IOKitTest.kext liuhailong:~ liuhailong$ sudo kextunload /Users/liuhailong/Library/Developer/Xcode/DerivedData/IOKitTest-grjzacxpxpyxiidhzzobgihdxfqm/Build/Products/Debug/IOKitTest.kext liuhailong:~ liuhailong$
可以安装个IORegistryExplorer 工具查看:
本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标编程语言C/C+频道!
您输入的评论内容中包含违禁敏感词
我知道了
请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号