当前位置: 首页>>代码示例>>C++>>正文


C++ IORegistryEntryCreateCFProperties函数代码示例

本文整理汇总了C++中IORegistryEntryCreateCFProperties函数的典型用法代码示例。如果您正苦于以下问题:C++ IORegistryEntryCreateCFProperties函数的具体用法?C++ IORegistryEntryCreateCFProperties怎么用?C++ IORegistryEntryCreateCFProperties使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了IORegistryEntryCreateCFProperties函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: handle_drive

/*
 * Check whether an IORegistryEntry refers to a valid
 * I/O device, and if so, collect the information.
 */
static int
handle_drive(io_registry_entry_t drive, struct drivestats * dstat)
{
    io_registry_entry_t parent;
    CFMutableDictionaryRef     properties;
    CFStringRef         name;
    CFNumberRef         number;
    kern_return_t       status;

    /* get drive's parent */
    status = IORegistryEntryGetParentEntry(drive, kIOServicePlane, &parent);
    if (status != KERN_SUCCESS) {
	snmp_log(LOG_ERR, "diskio: device has no parent\n");
/*	fprintf(stderr, "device has no parent\n"); */
	return(1);
    }

    if (IOObjectConformsTo(parent, "IOBlockStorageDriver")) {

	/* get drive properties */
	status = IORegistryEntryCreateCFProperties(drive, &properties,
					    kCFAllocatorDefault, kNilOptions);
	if (status != KERN_SUCCESS) {
	    snmp_log(LOG_ERR, "diskio: device has no properties\n");
/*	    fprintf(stderr, "device has no properties\n"); */
	    return(1);
	}

	/* get BSD name and unitnumber from properties */
	name = (CFStringRef)CFDictionaryGetValue(properties,
					  CFSTR(kIOBSDNameKey));
	number = (CFNumberRef)CFDictionaryGetValue(properties,
					    CFSTR(kIOBSDUnitKey));

	/* Collect stats and if succesful store them with the name and unitnumber */
	if (name && number && !collect_drive_stats(parent, dstat->stats)) {

	    CFStringGetCString(name, dstat->name, MAXDRIVENAME, CFStringGetSystemEncoding());
	    CFNumberGetValue(number, kCFNumberSInt32Type, &dstat->bsd_unit_number);
	    num_drives++;
	}

	/* clean up, return success */
	CFRelease(properties);
	return(0);
    }

    /* failed, don't keep parent */
    IOObjectRelease(parent);
    return(1);
}
开发者ID:pexip,项目名称:os-net-snmp,代码行数:55,代码来源:diskio.c

示例2: myIORegistryEntryBSDNameMatchingCopyValue

CFDictionaryRef
myIORegistryEntryBSDNameMatchingCopyValue(const char * devname, Boolean parent)
{
    kern_return_t       	status;
    CFMutableDictionaryRef	properties = NULL;
    io_registry_entry_t 	service;

    service 
	= IOServiceGetMatchingService(kIOMasterPortDefault,
				      IOBSDNameMatching(kIOMasterPortDefault, 0, devname));
    if (service == MACH_PORT_NULL) {
	return (NULL);
    }
    if (parent) {
	io_registry_entry_t	parent_service;
	
	status = IORegistryEntryGetParentEntry(service, kIOServicePlane,
					       &parent_service);
	if (status == KERN_SUCCESS) {
	    status = IORegistryEntryCreateCFProperties(parent_service,
						       &properties,
						       kCFAllocatorDefault,
						       kNilOptions);
	    IOObjectRelease(parent_service);
	}
    }
    else {
	status = IORegistryEntryCreateCFProperties(service,
						   &properties,
						   kCFAllocatorDefault,
						   kNilOptions);
    }
    if (status != KERN_SUCCESS) {
	properties = NULL;
    }
    IOObjectRelease(service);
    return (properties);
}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:38,代码来源:ioregpath.c

示例3: IOMasterPort

int IdlePlatform::secondsIdle()
{
  mach_port_t masterPort;
  io_iterator_t iter;
  io_registry_entry_t curObj;

  IOMasterPort(MACH_PORT_NULL, &masterPort);
  IOServiceGetMatchingServices(masterPort, IOServiceMatching("IOHIDSystem"), &iter);
  if (iter == 0)
    return -1;

  curObj = IOIteratorNext(iter);
  if (curObj == 0)
    return -1;

  CFMutableDictionaryRef properties = 0;
  CFTypeRef obj;
  int result = -1;

  if (IORegistryEntryCreateCFProperties(curObj, &properties, kCFAllocatorDefault, 0) == KERN_SUCCESS && properties != NULL) {
    obj = CFDictionaryGetValue(properties, CFSTR("HIDIdleTime"));
    CFRetain(obj);
  } else
    obj = NULL;

  if (obj) {
    uint64_t tHandle;

    CFTypeID type = CFGetTypeID(obj);

    if (type == CFDataGetTypeID())
      CFDataGetBytes((CFDataRef) obj, CFRangeMake(0, sizeof(tHandle)), (UInt8*) &tHandle);
    else if (type == CFNumberGetTypeID())
      CFNumberGetValue((CFNumberRef)obj, kCFNumberSInt64Type, &tHandle);
    else
      return -1;

    CFRelease(obj);

    // essentially divides by 10^9
    tHandle >>= 30;
    result = tHandle;
  }

  /* Release our resources */
  IOObjectRelease(curObj);
  IOObjectRelease(iter);
  CFRelease((CFTypeRef)properties);
  return result;
}
开发者ID:ChALkeR,项目名称:vacuum-im,代码行数:50,代码来源:idle_mac.cpp

示例4: getProperties

// gets all properties from an entry into a QMap
static QMap<QString, QVariant> getProperties(const io_registry_entry_t &entry)
{
    CFMutableDictionaryRef propertyDict = 0;

    if (IORegistryEntryCreateCFProperties(entry, &propertyDict, kCFAllocatorDefault, kNilOptions) != KERN_SUCCESS) {
        return QMap<QString, QVariant>();
    }

    QMap<QString, QVariant> result = q_toVariantMap(propertyDict);

    CFRelease(propertyDict);

    return result;
}
开发者ID:shainer,项目名称:solid,代码行数:15,代码来源:iokitdevice.cpp

示例5: OSX_ReadCDTOC

void OSX_ReadCDTOC(io_object_t cdobject) {
	CFMutableDictionaryRef cd_props = 0;
	CFDataRef cdTOCdata = NULL;
	char* cdTOCrawdata = NULL;
	
	if (IORegistryEntryCreateCFProperties(cdobject, &cd_props, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess) return;
												
	cdTOCdata = (CFDataRef)CFDictionaryGetValue(cd_props, CFSTR (kIOCDMediaTOCKey));
	if (cdTOCdata != NULL) {
	   	Extract_cdTOCrawdata(cdTOCdata, cdTOCrawdata);
	}
	CFRelease(cd_props);
	cd_props = NULL;
	return;
}
开发者ID:DanDrusch,项目名称:atomicparsley,代码行数:15,代码来源:CDtoc.cpp

示例6: PRINT

IOReturn
SATSMARTClient::Probe ( CFDictionaryRef propertyTable,
                        io_service_t inService,
                        SInt32 *                order )
{

    CFMutableDictionaryRef dict    = NULL;
    IOReturn status  = kIOReturnBadArgument;

    PRINT ( ( "SATSMARTClient::Probe called\n" ) );

    // Sanity check
    if ( inService == 0 )
    {
        goto Exit;
    }

    status = IORegistryEntryCreateCFProperties ( inService, &dict, NULL, 0 );
    if ( status != kIOReturnSuccess )
    {
        goto Exit;
    }

    if ( !CFDictionaryContainsKey ( dict, CFSTR ( "IOCFPlugInTypes" ) ) )
    {
        goto Exit;
    }


    status = kIOReturnSuccess;


Exit:


    if ( dict != NULL )
    {

        CFRelease ( dict );
        dict = NULL;

    }


    PRINT ( ( "SATSMARTClient::Probe called %x\n",status ) );
    return status;

}
开发者ID:eitschpi,项目名称:OS-X-SAT-SMART-Driver,代码行数:48,代码来源:SATSMARTClient.cpp

示例7: genPCIDevice

void genPCIDevice(const io_service_t& device, QueryData& results) {
  Row r;

  // Get the device details
  CFMutableDictionaryRef details;
  IORegistryEntryCreateCFProperties(
      device, &details, kCFAllocatorDefault, kNilOptions);

  r["pci_slot"] = getIOKitProperty(details, "pcidebug");

  std::vector<std::string> properties;
  auto compatible = getIOKitProperty(details, "compatible");
  boost::trim(compatible);
  boost::split(properties, compatible, boost::is_any_of(" "));

  if (properties.size() < 2) {
    VLOG(1) << "Error parsing IOKit compatible properties";
    return;
  }

  size_t prop_index = 0;
  if (properties[1].find("pci") == 0 && properties[1].find("pciclass") != 0) {
    // There are two sets of PCI definitions.
    prop_index = 1;
  } else if (properties[0].find("pci") != 0) {
    VLOG(1) << "No vendor/model found";
    return;
  }

  std::vector<std::string> vendor;
  boost::split(vendor, properties[prop_index++], boost::is_any_of(","));
  r["vendor_id"] = vendor[0].substr(3);
  r["model_id"] = (vendor[1].size() == 3) ? "0" + vendor[1] : vendor[1];

  if (properties[prop_index].find("pciclass") == 0) {
    // There is a class definition.
    r["pci_class"] = properties[prop_index++].substr(9);
  }

  if (properties.size() > prop_index) {
    // There is a driver/ID.
    r["driver"] = properties[prop_index];
  }

  results.push_back(r);
  CFRelease(details);
}
开发者ID:JessicaWhite17,项目名称:osquery,代码行数:47,代码来源:pci_devices.cpp

示例8: record_device

/*
 * Determine whether an IORegistryEntry refers to a valid
 * I/O device, and if so, record it.
 */
static int
record_device(io_registry_entry_t drive)
{
    io_registry_entry_t parent;
    CFDictionaryRef properties;
    CFStringRef name;
    CFNumberRef number;
    kern_return_t status;

    /* get drive's parent */
    status = IORegistryEntryGetParentEntry(drive,
                                           kIOServicePlane, &parent);
    if (status != KERN_SUCCESS)
        errx(1, "device has no parent");
    if (IOObjectConformsTo(parent, "IOBlockStorageDriver")) {
        drivestat[num_devices].driver = parent;

        /* get drive properties */
        status = IORegistryEntryCreateCFProperties(drive,
                 (CFMutableDictionaryRef *)&properties,
                 kCFAllocatorDefault,
                 kNilOptions);
        if (status != KERN_SUCCESS)
            errx(1, "device has no properties");

        /* get name from properties */
        name = (CFStringRef)CFDictionaryGetValue(properties,
                CFSTR(kIOBSDNameKey));
        CFStringGetCString(name, drivestat[num_devices].name,
                           MAXDRIVENAME, CFStringGetSystemEncoding());

        /* get blocksize from properties */
        number = (CFNumberRef)CFDictionaryGetValue(properties,
                 CFSTR(kIOMediaPreferredBlockSizeKey));
        CFNumberGetValue(number, kCFNumberSInt64Type,
                         &drivestat[num_devices].blocksize);

        /* clean up, return success */
        CFRelease(properties);
        num_devices++;
        return(0);
    }

    /* failed, don't keep parent */
    IOObjectRelease(parent);
    return(1);
}
开发者ID:PaxGordon,项目名称:SEDarwin,代码行数:51,代码来源:iostat.c

示例9: genFDEStatusForBSDName

void genFDEStatusForBSDName(const std::string& bsd_name,
                            const std::string& uuid,
                            QueryData& results) {

  auto matching_dict =
      IOBSDNameMatching(kIOMasterPortDefault, kNilOptions, bsd_name.c_str());
  if (matching_dict == nullptr) {
    return;
  }

  auto service =
      IOServiceGetMatchingService(kIOMasterPortDefault, matching_dict);
  if (!service) {
    return;
  }

  CFMutableDictionaryRef properties;
  if (IORegistryEntryCreateCFProperties(
          service, &properties, kCFAllocatorDefault, kNilOptions) !=
      KERN_SUCCESS) {
    IOObjectRelease(service);
    return;
  }

  Row r;
  r["name"] = kDeviceNamePrefix + bsd_name;
  r["uuid"] = uuid;

  auto encrypted = getIOKitProperty(properties, kCoreStorageIsEncryptedKey_);
  if (encrypted.empty()) {
    r["encrypted"] = "0";
  } else {
    r["encrypted"] = encrypted;
    id_t uid;
    uuid_string_t uuid_string = {0};
    if (genUid(uid, uuid_string).ok()) {
      r["uid"] = BIGINT(uid);
      r["user_uuid"] = TEXT(uuid_string);
    }
  }
  r["type"] = (r.at("encrypted") == "1") ? kEncryptionType : std::string();

  results.push_back(r);
  CFRelease(properties);
  IOObjectRelease(service);
}
开发者ID:1514louluo,项目名称:osquery,代码行数:46,代码来源:disk_encryption.cpp

示例10: idleTime

long idleTime() {
    long idlesecs;
#ifdef LINUX
    bool _idleDetectionPossible;
    XScreenSaverInfo *_mit_info;

    int event_base, error_base;
    if(XScreenSaverQueryExtension(QX11Info::display(), &event_base, &error_base))
        _idleDetectionPossible = true;
    else
        _idleDetectionPossible = false;
    _mit_info = XScreenSaverAllocInfo();

    XScreenSaverQueryInfo(QX11Info::display(), QX11Info::appRootWindow(), _mit_info);

    idlesecs = (_mit_info->idle/1000);

#endif
#ifdef WINDOWS

    LASTINPUTINFO lif;
    lif.cbSize = sizeof(LASTINPUTINFO);
    GetLastInputInfo(&lif);
    DWORD tickCount = GetTickCount();
    idlesecs = (tickCount - lif.dwTime) / 1000;

#endif
#ifdef MAC
    idlesecs = -1;//int64_t
    io_iterator_t iter = 0;
    if (IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceMatching("IOHIDSystem"), &iter) == KERN_SUCCESS) {
        io_registry_entry_t entry = IOIteratorNext(iter);
        if (entry) {
            CFMutableDictionaryRef dict = NULL;
            if (IORegistryEntryCreateCFProperties(entry, &dict, kCFAllocatorDefault, 0) == KERN_SUCCESS) {
                CFNumberRef obj = (CFNumberRef)CFDictionaryGetValue(dict, CFSTR("HIDIdleTime"));
                if (obj) {
                    int64_t nanoseconds = 0;
                    if (CFNumberGetValue(obj, kCFNumberSInt64Type, &nanoseconds)) {
                        idlesecs = (nanoseconds >> 30); // Divide by 10^9 to convert from nanoseconds to seconds.
                    }
                }
                CFRelease(dict);
            }
开发者ID:crossleyjuan,项目名称:djon,代码行数:44,代码来源:util.cpp

示例11: genPCIDevice

void genPCIDevice(const io_service_t& device, QueryData& results) {
  Row r;

  // Get the device details
  CFMutableDictionaryRef details;
  IORegistryEntryCreateCFProperties(
      device, &details, kCFAllocatorDefault, kNilOptions);

  r["pci_slot"] = getIOKitProperty(details, "pcidebug");

  auto compatible = getIOKitProperty(details, "compatible");
  auto properties = IOKitPCIProperties(compatible);
  r["vendor_id"] = properties.vendor_id;
  r["model_id"] = properties.model_id;
  r["pci_class"] = properties.pci_class;
  r["driver"] = properties.driver;

  results.push_back(r);
  CFRelease(details);
}
开发者ID:theopolis,项目名称:osquery,代码行数:20,代码来源:pci_devices.cpp

示例12: myIORegistryEntryCopyValue

CFDictionaryRef
myIORegistryEntryCopyValue(const char * path)
{
    io_registry_entry_t 	service;
    kern_return_t       	status;
    CFMutableDictionaryRef	properties = NULL;

    service = IORegistryEntryFromPath(kIOMasterPortDefault, path);
    if (service == MACH_PORT_NULL) {
	return (NULL);
    }
    status = IORegistryEntryCreateCFProperties(service,
					       &properties,
					       kCFAllocatorDefault,
					       kNilOptions);
    if (status != KERN_SUCCESS) {
	properties = NULL;
    }
    IOObjectRelease(service);
    return (properties);
}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:21,代码来源:ioregpath.c

示例13: PrintSpeedForDisc

static IOReturn
PrintSpeedForDisc ( io_object_t opticalMedia )
{
	
	IOReturn				error 		= kIOReturnError;
	CFMutableDictionaryRef	properties 	= NULL;
	CFStringRef				bsdNode		= NULL;
	const char *			bsdName		= NULL;
	
	error = IORegistryEntryCreateCFProperties ( opticalMedia,
												&properties,
												kCFAllocatorDefault,
												kNilOptions );
	require ( ( error == kIOReturnSuccess ), ErrorExit );
	
	bsdNode = ( CFStringRef ) CFDictionaryGetValue ( properties, CFSTR ( kIOBSDNameKey ) );
	require ( ( bsdNode != NULL ), ReleaseProperties );
	
	bsdName = CFStringGetCStringPtr ( bsdNode, CFStringGetSystemEncoding ( ) );
	require ( ( bsdName != NULL ), ReleaseProperties );
	
	error = PrintSpeedForBSDNode ( bsdName );
	require ( ( error == kIOReturnSuccess ), ReleaseProperties );
	
	
ReleaseProperties:
	
	
	require_quiet ( ( properties != NULL ), ErrorExit );
	CFRelease ( properties );
	properties = NULL;
	
	
ErrorExit:
	
	
	return error;
	
}
开发者ID:unofficial-opensource-apple,项目名称:IOSCSIArchitectureModelFamily,代码行数:39,代码来源:OpticalMediaSpeed.c

示例14: genUSBDevice

void genUSBDevice(const io_service_t& device, QueryData& results) {
  Row r;

  // Get the device details
  CFMutableDictionaryRef details;
  IORegistryEntryCreateCFProperties(
      device, &details, kCFAllocatorDefault, kNilOptions);

  r["usb_address"] = getUSBProperty(details, "USB Address");
  r["usb_port"] = getUSBProperty(details, "PortNum");

  r["model"] = getUSBProperty(details, "USB Product Name");
  r["model_id"] = getUSBProperty(details, "idProduct");
  r["vendor"] = getUSBProperty(details, "USB Vendor Name");
  r["vendor_id"] = getUSBProperty(details, "idVendor");
  r["serial"] = getUSBProperty(details, "iSerialNumber");

  auto non_removable = getUSBProperty(details, "non-removable");
  r["removable"] = (non_removable == "yes") ? "0" : "1";

  results.push_back(r);
  CFRelease(details);
}
开发者ID:JessicaWhite17,项目名称:osquery,代码行数:23,代码来源:usb_devices.cpp

示例15: main

int main(int argc, char **argv)
{
    mach_port_t		   masterPort;
    io_registry_entry_t	   root;
    CFDictionaryRef        props;
    kern_return_t          status;

    // Obtain the I/O Kit communication handle.

    status = IOMasterPort(bootstrap_port, &masterPort);
    assert(status == KERN_SUCCESS);

    // Obtain the registry root entry.

    root = IORegistryGetRootEntry(masterPort);
    assert(root);

    status = IORegistryEntryCreateCFProperties(root,
			(CFTypeRef *) &props,
			kCFAllocatorDefault, kNilOptions );
    assert( KERN_SUCCESS == status );
    assert( CFDictionaryGetTypeID() == CFGetTypeID(props));

    props = (CFDictionaryRef)
		CFDictionaryGetValue( props, CFSTR(kIOKitDiagnosticsKey));
    assert( props );
    assert( CFDictionaryGetTypeID() == CFGetTypeID(props));

    printNumber(props, CFSTR("Instance allocation"));
    printNumber(props, CFSTR("Container allocation"));
    printNumber(props, CFSTR("IOMalloc allocation"));

    CFRelease(props);
    IOObjectRelease(root);

    exit(0);	
}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:37,代码来源:alloccount.c


注:本文中的IORegistryEntryCreateCFProperties函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。