bool org_pqrs_driver_NoEjectDelay::start(IOService* provider) { IOLOG_INFO("start\n"); bool res = super::start(provider); if (!res) { return res; } // ---------------------------------------- org_pqrs_NoEjectDelay::GlobalLock::initialize(); // ---------------------------------------- notifier_hookKeyboard_ = addMatchingNotification(gIOMatchedNotification, serviceMatching("IOHIKeyboard"), org_pqrs_driver_NoEjectDelay::IOHIKeyboard_gIOMatchedNotification_callback, this, NULL, 0); if (notifier_hookKeyboard_ == NULL) { IOLOG_ERROR("initialize_notification notifier_hookKeyboard_ == NULL\n"); return false; } notifier_unhookKeyboard_ = addMatchingNotification(gIOTerminatedNotification, serviceMatching("IOHIKeyboard"), org_pqrs_driver_NoEjectDelay::IOHIKeyboard_gIOTerminatedNotification_callback, this, NULL, 0); if (notifier_unhookKeyboard_ == NULL) { IOLOG_ERROR("initialize_notification notifier_unhookKeyboard_ == NULL\n"); return false; } notifier_hookEventService_ = addMatchingNotification(gIOMatchedNotification, serviceMatching("IOHIDEventService"), org_pqrs_driver_NoEjectDelay::IOHIKeyboard_gIOMatchedNotification_callback, this, NULL, 0); if (notifier_hookEventService_ == NULL) { IOLOG_ERROR("initialize_notification notifier_hookEventService_ == NULL\n"); return false; } notifier_unhookEventService_ = addMatchingNotification(gIOTerminatedNotification, serviceMatching("IOHIDEventService"), org_pqrs_driver_NoEjectDelay::IOHIKeyboard_gIOTerminatedNotification_callback, this, NULL, 0); if (notifier_unhookEventService_ == NULL) { IOLOG_ERROR("initialize_notification notifier_unhookEventService_ == NULL\n"); return false; } // ---------------------------------------- workLoop_ = IOWorkLoop::workLoop(); if (!workLoop_) return false; timerEventSource_ = IOTimerEventSource::timerEventSource(this, timer_callback); if (!timerEventSource_) return false; if (workLoop_->addEventSource(timerEventSource_) != kIOReturnSuccess) return false; timerEventSource_->setTimeoutMS(TIMER_INTERVAL_MS); // ---------------------------------------- return res; }
bool org_pqrs_driver_Seil::start(IOService* provider) { IOLOG_INFO("start\n"); bool res = super::start(provider); if (!res) { return res; } org_pqrs_Seil::GlobalLock::initialize(); notifier_hookKeyboard_ = addMatchingNotification(gIOMatchedNotification, serviceMatching("IOHIKeyboard"), org_pqrs_driver_Seil::IOHIKeyboard_gIOMatchedNotification_callback, this, nullptr, 0); if (notifier_hookKeyboard_ == nullptr) { IOLOG_ERROR("initialize_notification notifier_hookKeyboard_ == nullptr\n"); return false; } notifier_unhookKeyboard_ = addMatchingNotification(gIOTerminatedNotification, serviceMatching("IOHIKeyboard"), org_pqrs_driver_Seil::IOHIKeyboard_gIOTerminatedNotification_callback, this, nullptr, 0); if (notifier_unhookKeyboard_ == nullptr) { IOLOG_ERROR("initialize_notification notifier_unhookKeyboard_ == nullptr\n"); return false; } // Publish ourselves so clients can find us registerService(); return res; }
void com_prebeg_kext_KeyLog::activate() { IOLog("%s::%s\n", getName(), __FUNCTION__); notifyTerm = addMatchingNotification(gIOTerminatedNotification, serviceMatching("IOHIKeyboard"), (IOServiceMatchingNotificationHandler)&com_prebeg_kext_KeyLog::terminationHandler, this); return; }
// ====================================================================== bool org_pqrs_driver_Karabiner::initialize_notification(void) { notifier_hookKeyboard_ = addMatchingNotification(gIOMatchedNotification, serviceMatching("IOHIKeyboard"), org_pqrs_Karabiner::Core::IOHIKeyboard_gIOMatchedNotification_callback, this, NULL, 0); if (notifier_hookKeyboard_ == NULL) { IOLOG_ERROR("initialize_notification notifier_hookKeyboard_ == NULL\n"); return false; } notifier_unhookKeyboard_ = addMatchingNotification(gIOTerminatedNotification, serviceMatching("IOHIKeyboard"), org_pqrs_Karabiner::Core::IOHIKeyboard_gIOTerminatedNotification_callback, this, NULL, 0); if (notifier_unhookKeyboard_ == NULL) { IOLOG_ERROR("initialize_notification notifier_unhookKeyboard_ == NULL\n"); return false; } // ---------------------------------------- notifier_hookPointing_ = addMatchingNotification(gIOMatchedNotification, serviceMatching("IOHIPointing"), org_pqrs_Karabiner::Core::IOHIPointing_gIOMatchedNotification_callback, this, NULL, 0); if (notifier_hookPointing_ == NULL) { IOLOG_ERROR("initialize_notification notifier_hookPointing_ == NULL\n"); return false; } notifier_unhookPointing_ = addMatchingNotification(gIOTerminatedNotification, serviceMatching("IOHIPointing"), org_pqrs_Karabiner::Core::IOHIPointing_gIOTerminatedNotification_callback, this, NULL, 0); if (notifier_unhookPointing_ == NULL) { IOLOG_ERROR("initialize_notification notifier_unhookPointing_ == NULL\n"); return false; } return true; }
void Insomnia::startPM(IOService *provider) { static const int kMyNumberOfStates = 2; static IOPMPowerState myPowerStates[kMyNumberOfStates] = { {kIOPMPowerStateVersion1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {kIOPMPowerStateVersion1, kIOPMPowerOn, kIOPMPowerOn, kIOPMPowerOn, 0, 0, 0, 0, 0, 0, 0, 0} }; PMinit(); provider->joinPMtree(this); registerPowerDriver(this, myPowerStates, kMyNumberOfStates); if (OSDictionary *tmpDict = serviceMatching("IOPMPowerSource")) { addMatchingNotification(gIOFirstPublishNotification, tmpDict, &Insomnia::_power_source_published, this); tmpDict->release(); } }
bool com_prebeg_kext_KeyLog::start(IOService *provider) { IOLog("%s::%s\n", getName(), __FUNCTION__); bool result = super::start(provider); registerService(); notify = addMatchingNotification(gIOPublishNotification, serviceMatching("IOHIKeyboard"), (IOServiceMatchingNotificationHandler)&com_prebeg_kext_KeyLog::notificationHandler, this); activate(); if (!result) { stop(provider); return false; } return result; }
bool net_lundman_zfs_zvol::start (IOService *provider) { bool res = super::start(provider); IOLog("ZFS: Loading module ... \n"); sysctl_register_oid(&sysctl__zfs); sysctl_register_oid(&sysctl__zfs_kext_version); /* * Initialize /dev/zfs, this calls spa_init->dmu_init->arc_init-> etc */ zfs_ioctl_osx_init(); /* registerService() allows zconfigd to match against the service */ this->registerService(); ///sysctl_register_oid(&sysctl__debug_maczfs); //sysctl_register_oid(&sysctl__debug_maczfs_stalk); zfs_vfsops_init(); /* * When is the best time to start the system_taskq? It is strictly * speaking not used by SPL, but by ZFS. ZFS should really start it? */ system_taskq_init(); /* * hostid is left as 0 on OSX, and left to be set if developers wish to * use it. If it is 0, we will hash the hardware.uuid into a 32 bit * value and set the hostid. */ if (!zone_get_hostid(NULL)) { uint32_t myhostid = 0; IORegistryEntry *ioregroot = IORegistryEntry::getRegistryRoot(); if(ioregroot) { //IOLog("ioregroot is '%s'\n", ioregroot->getName(gIOServicePlane)); IORegistryEntry *macmodel = ioregroot->getChildEntry(gIOServicePlane); if(macmodel) { //IOLog("macmodel is '%s'\n", macmodel->getName(gIOServicePlane)); OSObject *ioplatformuuidobj; //ioplatformuuidobj = ioregroot->getProperty("IOPlatformUUID", gIOServicePlane, kIORegistryIterateRecursively); ioplatformuuidobj = macmodel->getProperty(kIOPlatformUUIDKey); if(ioplatformuuidobj) { OSString *ioplatformuuidstr = OSDynamicCast(OSString, ioplatformuuidobj); //IOLog("IOPlatformUUID is '%s'\n", ioplatformuuidstr->getCStringNoCopy()); myhostid = fnv_32a_str(ioplatformuuidstr->getCStringNoCopy(), FNV1_32A_INIT); sysctlbyname("kern.hostid", NULL, NULL, &myhostid, sizeof(myhostid)); printf("ZFS: hostid set to %08x from UUID '%s'\n", myhostid, ioplatformuuidstr->getCStringNoCopy()); } } } } disk_remove_notifier = addMatchingNotification(gIOTerminatedNotification, serviceMatching("IOMedia"), IOkit_disk_removed_callback, this, NULL, 0); return res; }
bool IOHIDLibUserClient::start(IOService *provider) { OSDictionary *matching = NULL; if (!super::start(provider)) return false; fNub = OSDynamicCast(IOHIDDevice, provider); if (!fNub) return false; fWL = getWorkLoop(); if (!fWL) return false; fWL->retain(); OSNumber *primaryUsage = (OSNumber*)fNub->copyProperty(kIOHIDPrimaryUsageKey); OSNumber *primaryUsagePage = (OSNumber*)fNub->copyProperty(kIOHIDPrimaryUsagePageKey); if ((OSDynamicCast(OSNumber, primaryUsagePage) && (primaryUsagePage->unsigned32BitValue() == kHIDPage_GenericDesktop)) && (OSDynamicCast(OSNumber, primaryUsage) && ((primaryUsage->unsigned32BitValue() == kHIDUsage_GD_Keyboard) || (primaryUsage->unsigned32BitValue() == kHIDUsage_GD_Keypad)))) { fNubIsKeyboard = true; } OSSafeReleaseNULL(primaryUsage); OSSafeReleaseNULL(primaryUsagePage); IOCommandGate * cmdGate = IOCommandGate::commandGate(this); if (!cmdGate) goto ABORT_START; fWL->addEventSource(cmdGate); fGate = cmdGate; fResourceES = IOInterruptEventSource::interruptEventSource (this, OSMemberFunctionCast(IOInterruptEventSource::Action, this, &IOHIDLibUserClient::resourceNotificationGated)); if ( !fResourceES ) goto ABORT_START; fWL->addEventSource(fResourceES); // Get notified everytime Root properties change matching = serviceMatching("IOResources"); fResourceNotification = addMatchingNotification( gIOPublishNotification, matching, OSMemberFunctionCast(IOServiceMatchingNotificationHandler, this, &IOHIDLibUserClient::resourceNotification), this); matching->release(); matching = NULL; if ( !fResourceNotification ) goto ABORT_START; return true; ABORT_START: if (fResourceES) { fWL->removeEventSource(fResourceES); fResourceES->release(); fResourceES = 0; } if (fGate) { fWL->removeEventSource(fGate); fGate->release(); fGate = 0; } fWL->release(); fWL = 0; return false; }