0

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.

4

1 回答 1

0

如果我正确理解您的问题,您需要OSDictionary::withCapacity工厂函数。

例如:

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;

然后,在你的属性表中使用它:

propTable->setObject("NewProperty", prop_dict);
prop_dict->release(); prop_dict = NULL;
于 2012-04-28T13:31:33.453 回答