سؤال

I'm trying to create a new Dictionary and inject it in the IORegistry. I've managed to inject simple strings or data values but thats it.

My approach is via a modified IOPCIFamily.kext, and it's not for a specific purpose but just for learning.

My code for 1 line values is something like this

if (product == id){ setProperty("test", "test") }

and another approach

if (product == id){ propTable->setObject("TEST", prop) prop->release(); }

propTable is the Parent Dictionary, so i must create a child Dictionary to which i can inject values with setObject parameter.

Does anyone have an idea on how to do this? I suspect it must be something like this:

propTable->newTable->setObject(etc)

but i didn't figure how to create the newTable for propTable to insert it in the existing one of what ever product == ids it finds.

Thank you very much, sorry if it's confusing. Not used to explain code related stuff in english.

هل كانت مفيدة؟

المحلول

If I understand your question correctly, you want the OSDictionary::withCapacity factory function.

For example:

OSDictionary* prop_dict = OSDictionary::withCapacity(1);
OSString* val = OSString::withCString("test");
if (!prop_dict || !val)
{
  // handle error...
}
prop_dict->setObject("test", val);
val->release(); val = NULL;

and then, to use it in you property table:

propTable->setObject("NewProperty", prop_dict);
prop_dict->release(); prop_dict = NULL;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top