#define kIORegPlaneNameSuffixLen (sizeof(kIORegPlaneNameSuffix) - 1)
#define kIORegPlaneLocationSuffixLen (sizeof(kIORegPlaneLocationSuffix) - 1)
+#define KASLR_IOREG_DEBUG 0
+
static IORegistryEntry * gRegistryRoot;
static OSDictionary * gIORegistryPlanes;
int reserved[2];
public:
- virtual bool serialize(OSSerialize *s) const;
+ virtual bool serialize(OSSerialize *s) const APPLE_KEXT_OVERRIDE;
};
OSDefineMetaClassAndStructors(IORegistryPlane, OSObject)
bzero(reserved, sizeof(ExpansionData));
}
if( dict) {
- dict->retain();
+ if (OSCollection::kImmutable & dict->setOptions(0, 0)) {
+ dict = (OSDictionary *) dict->copyCollection();
+ if (!dict)
+ return (false);
+ } else
+ dict->retain();
if( fPropertyTable)
fPropertyTable->release();
fPropertyTable = dict;
fPropertyTable->retain();
#ifdef IOREGSPLITTABLES
fRegistryTable = old->fRegistryTable;
- old->fRegistryTable = OSDictionary::withDictionary( fRegistryTable );
+ old->fRegistryTable = (OSDictionary *) fRegistryTable->copyCollection();
#endif /* IOREGSPLITTABLES */
old->registryTable()->removeObject( plane->keys[ kParentSetIndex ] );
PUNLOCK;
}
+#if KASLR_IOREG_DEBUG
+extern "C" {
+
+bool ScanForAddrInObject(OSObject * theObject,
+ int indent);
+
+}; /* extern "C" */
+#endif
+
bool
IORegistryEntry::setProperty( const OSSymbol * aKey, OSObject * anObject)
{
ret = getPropertyTable()->setObject( aKey, anObject );
PUNLOCK;
-
+
+#if KASLR_IOREG_DEBUG
+ if ( anObject && strcmp(kIOKitDiagnosticsKey, aKey->getCStringNoCopy()) != 0 ) {
+ if (ScanForAddrInObject(anObject, 0)) {
+ IOLog("%s: IORegistryEntry name %s with key \"%s\" \n",
+ __FUNCTION__,
+ getName(0),
+ aKey->getCStringNoCopy() );
+ }
+ }
+#endif
+
return ret;
}
OSArray * stack;
IORegistryEntry * root;
const IORegistryEntry * entry;
- IORegistryEntry * parent;
+ const IORegistryEntry * parent;
const OSSymbol * alias;
int index;
int len, maxLength, compLen, aliasLen;
return( ok );
}
- entry = this;
- parent = entry->getParentEntry( plane );
- if( !parent)
- // Error if not attached in plane
- return( false);
-
stack = OSArray::withCapacity( getDepth( plane ));
- if( !stack)
- return( false);
+ if (!stack) return( false);
RLOCK;
+ parent = entry = this;
root = gRegistryRoot->getChildEntry( plane );
- while( parent && (entry != root)) {
+ while (parent && (parent != root))
+ {
// stop below root
- stack->setObject( (OSObject *) entry );
entry = parent;
parent = entry->getParentEntry( plane );
+ stack->setObject( (OSObject *) entry );
}
- index = stack->getCount();
- ok = true;
-
- if( 0 == index) {
-
- *nextComp++ = '/';
- *nextComp = 0;
- len++;
-
- } else while( ok && ((--index) >= 0)) {
-
- entry = (IORegistryEntry *) stack->getObject((unsigned int) index );
- assert( entry );
-
- if( (alias = entry->hasAlias( plane ))) {
- len = plane->nameKey->getLength() + 1;
- nextComp = path + len;
-
- compLen = alias->getLength();
- ok = (maxLength > (len + compLen));
- if( ok)
- strlcpy( nextComp, alias->getCStringNoCopy(), compLen + 1);
- } else {
- compLen = maxLength - len;
- ok = entry->getPathComponent( nextComp + 1, &compLen, plane );
-
- if( ok && compLen) {
- compLen++;
- *nextComp = '/';
+ ok = (0 != parent);
+ if (ok)
+ {
+ index = stack->getCount();
+ if( 0 == index) {
+
+ *nextComp++ = '/';
+ *nextComp = 0;
+ len++;
+
+ } else while( ok && ((--index) >= 0)) {
+
+ entry = (IORegistryEntry *) stack->getObject((unsigned int) index );
+ assert( entry );
+
+ if( (alias = entry->hasAlias( plane ))) {
+ len = plane->nameKey->getLength() + 1;
+ nextComp = path + len;
+
+ compLen = alias->getLength();
+ ok = (maxLength > (len + compLen));
+ if( ok)
+ strlcpy( nextComp, alias->getCStringNoCopy(), compLen + 1);
+ } else {
+ compLen = maxLength - len;
+ ok = entry->getPathComponent( nextComp + 1, &compLen, plane );
+
+ if( ok && compLen) {
+ compLen++;
+ *nextComp = '/';
+ }
}
- }
- if( ok) {
- len += compLen;
- nextComp += compLen;
+ if( ok) {
+ len += compLen;
+ nextComp += compLen;
+ }
}
+ *length = len;
}
- *length = len;
-
UNLOCK;
-
stack->release();
return( ok );
IORegistryEntry * parent;
retain();
- while( (parent = getParentEntry( plane )))
+ while( (parent = copyParentEntry( plane )))
+ {
detachFromParent( parent, plane );
+ parent->release();
+ }
release();
}