OSObject* FileNVRAM::cast(const OSSymbol* key, OSObject* obj) { const char* legacy[] = { "boot-args", "boot-script", }; OSString* str = OSDynamicCast(OSString, key); if (str) { for (int i = 0; i < sizeof(legacy)/sizeof(char*); i++) { if (str->isEqualTo(legacy[i])) { LOG(NOTICE, "Found legacy key %s\n", str->getCStringNoCopy()); // add null char, convert to OSString OSData* data = OSDynamicCast(OSData, obj); if (data) { data->appendByte(0x00, 1); return OSString::withCString((const char*)data->getBytesNoCopy()); } } } } return obj; }
bool FakeSMC::init(OSDictionary *properties) { if (!super::init(properties)) return false; IOLog("FakeSMC v%s Copyright %d netkas, slice, usr-sse2, kozlek, navi, THe KiNG, RehabMan. All rights reserved.\n", HWSENSORS_VERSION_STRING, HWSENSORS_LASTYEAR); if (IORegistryEntry *efi = IORegistryEntry::fromPath("/efi", gIODTPlane)) { if (OSData *vendor = OSDynamicCast(OSData, efi->getProperty("firmware-vendor"))) { // firmware-vendor is in EFI node OSData *buffer = OSData::withCapacity(128); const unsigned char* data = static_cast<const unsigned char*>(vendor->getBytesNoCopy()); for (unsigned int index = 0; index < vendor->getLength(); index += 2) { buffer->appendByte(data[index], 1); } OSString *name = OSString::withCString(static_cast<const char *>(buffer->getBytesNoCopy())); setProperty(kFakeSMCFirmwareVendor, name); //OSSafeRelease(vendor); //OSSafeRelease(name); OSSafeRelease(buffer); } OSSafeRelease(efi); } return true; }
void SMBPackedStrings::setDataProperty( IORegistryEntry * entry, const char * key, UInt8 index ) const { UInt8 length; const char * string = SMBPackedStrings::stringAtIndex(index, &length); if (length) { OSData * data = OSData::withCapacity(length + 1); if (data) { data->appendBytes(string, length); data->appendByte('\0', 1); entry->setProperty(key, data); data->release(); } } }
bool FakeSMC::init(OSDictionary *dictionary) { if (!super::init(dictionary)) return false; IOLog("HWSensors v%s Copyright %d netkas, slice, usr-sse2, kozlek, navi, THe KiNG, RehabMan. All rights reserved.\n", HWSENSORS_VERSION_STRING, HWSENSORS_LASTYEAR); //HWSensorsInfoLog("Opensource SMC device emulator. Copyright 2009 netkas. All rights reserved."); if (!(smcDevice = new FakeSMCDevice)) { HWSensorsInfoLog("failed to create SMC device"); return false; } if (!setOemProperties(this)) { // Another try after 200 ms spin IOSleep(200); setOemProperties(this); } if (!getProperty(kOEMInfoProduct) || !getProperty(kOEMInfoManufacturer)) { HWSensorsErrorLog("failed to obtain OEM vendor & product information from DMI"); // Try to obtain OEM info from Clover EFI if (IORegistryEntry* platformNode = fromPath("/efi/platform", gIODTPlane)) { if (OSData *data = OSDynamicCast(OSData, platformNode->getProperty("OEMVendor"))) { if (OSString *vendor = OSString::withCString((char*)data->getBytesNoCopy())) { if (OSString *manufacturer = getManufacturerNameFromOEMName(vendor)) { this->setProperty(kOEMInfoManufacturer, manufacturer); //OSSafeReleaseNULL(manufacturer); } //OSSafeReleaseNULL(vendor); } //OSSafeReleaseNULL(data); } if (OSData *data = OSDynamicCast(OSData, platformNode->getProperty("OEMBoard"))) { if (OSString *product = OSString::withCString((char*)data->getBytesNoCopy())) { this->setProperty(kOEMInfoProduct, product); //OSSafeReleaseNULL(product); } //OSSafeReleaseNULL(data); } } else { HWSensorsErrorLog("failed to get OEM info from Clover EFI, specific platform profiles will be unavailable"); } } if (IORegistryEntry *efi = IORegistryEntry::fromPath("/efi", gIODTPlane)) { if (OSData *vendor = OSDynamicCast(OSData, efi->getProperty("firmware-vendor"))) { // firmware-vendor is in EFI node OSData *buffer = OSData::withCapacity(128); const unsigned char* data = static_cast<const unsigned char*>(vendor->getBytesNoCopy()); for (unsigned int index = 0; index < vendor->getLength(); index += 2) { buffer->appendByte(data[index], 1); } OSString *name = OSString::withCString(static_cast<const char *>(buffer->getBytesNoCopy())); setProperty(kFakeSMCFirmwareVendor, name); //OSSafeRelease(vendor); //OSSafeRelease(name); OSSafeRelease(buffer); } OSSafeRelease(efi); } return true; }