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


C++ IOServiceGetMatchingService函数代码示例

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


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

示例1: diskfile_device_size

off_t diskfile_device_size(const char *path) {
  // Get the path within /dev
  if (strncmp(path, DEV_PREFIX, strlen(DEV_PREFIX)) != 0)
    return 0;
  const char *bsdname = path + strlen(DEV_PREFIX);

  // Find the matching IOService
  CFMutableDictionaryRef matching = IOBSDNameMatching(kIOMasterPortDefault, 0,
    bsdname);
  // Consumes the matching dictionary
  io_service_t match = IOServiceGetMatchingService(kIOMasterPortDefault,
    matching);
  if (!match)
    return 0;

  // Get the size property
  CFNumberRef cfsize = IORegistryEntryCreateCFProperty(match,
    CFSTR(kIOMediaSizeKey), kCFAllocatorDefault, 0);
  IOObjectRelease(match);
  if (!cfsize)
    return 0;

  long long size;
  if (!CFNumberGetValue(cfsize, kCFNumberLongLongType, &size))
    return 0;

  return size;
}
开发者ID:dothan009,项目名称:diskfile,代码行数:28,代码来源:mac-size.c

示例2: getDataPort

io_connect_t getDataPort(void)
{
  kern_return_t     kr;
  io_service_t      serviceObject;

  if (dataPort) return dataPort;

  // Look up a registered IOService object whose class is AppleLMUController
  serviceObject = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("AppleLMUController"));

  if (!serviceObject)
  {
    printf("getLightSensors() error: failed to find ambient light sensor\n");
    return 0;
  }

  // Create a connection to the IOService object
  kr = IOServiceOpen(serviceObject, mach_task_self(), 0, &dataPort);
  IOObjectRelease(serviceObject);

  if (kr != KERN_SUCCESS)
  {
    printf("getLightSensors() error: failed to open IoService object\n");
    return 0;
  }

  return dataPort;
}
开发者ID:BaleroCMS,项目名称:macbook-brightness,代码行数:28,代码来源:displaybrightness.c

示例3: get_ff

static HRESULT get_ff(IOHIDDeviceRef device, FFDeviceObjectReference *ret)
{
    io_service_t service;
    CFMutableDictionaryRef matching;
    CFTypeRef type;

    matching = IOServiceMatching(kIOHIDDeviceKey);
    if(!matching) {
        WARN("IOServiceMatching failed, force feedback disabled\n");
        return DIERR_DEVICENOTREG;
    }

    type = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDLocationIDKey));
    if(!matching) {
        CFRelease(matching);
        WARN("IOHIDDeviceGetProperty failed, force feedback disabled\n");
        return DIERR_DEVICENOTREG;
    }

    CFDictionaryAddValue(matching, CFSTR(kIOHIDLocationIDKey), type);

    service = IOServiceGetMatchingService(kIOMasterPortDefault, matching);

    if(!ret)
        return FFIsForceFeedback(service) == FF_OK ? S_OK : S_FALSE;

    return osx_to_win32_hresult(FFCreateDevice(service, ret));
}
开发者ID:cournape,项目名称:wine,代码行数:28,代码来源:joystick_osx.c

示例4: AllocateHIDObjectFromIOHIDDeviceRef

//---------------------------------------------------------------------------------
//
// AllocateHIDObjectFromIOHIDDeviceRef( )
//
//	returns:
//		NULL, or acceptable io_object_t
//
//---------------------------------------------------------------------------------
io_service_t AllocateHIDObjectFromIOHIDDeviceRef(IOHIDDeviceRef inIOHIDDeviceRef) {
	io_service_t result = 0L;
	if ( inIOHIDDeviceRef ) {
		// Set up the matching criteria for the devices we're interested in.
		// We are interested in instances of class IOHIDDevice.
		// matchingDict is consumed below( in IOServiceGetMatchingService )
		// so we have no leak here.
		CFMutableDictionaryRef matchingDict = IOServiceMatching(kIOHIDDeviceKey);
		if ( matchingDict ) {
			// Add a key for locationID to our matching dictionary.  This works for matching to
			// IOHIDDevices, so we will only look for a device attached to that particular port
			// on the machine.
			CFTypeRef tCFTypeRef = IOHIDDeviceGetProperty( inIOHIDDeviceRef, CFSTR(kIOHIDLocationIDKey) );
			if ( tCFTypeRef ) {
				CFDictionaryAddValue(matchingDict, CFSTR(kIOHIDLocationIDKey), tCFTypeRef);
				// CFRelease( tCFTypeRef );	// don't release objects that we "Get".
				
				// IOServiceGetMatchingService assumes that we already know that there is only one device
				// that matches.  This way we don't have to do the whole iteration dance to look at each
				// device that matches.  This is a new API in 10.2
				result = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDict);
			}
			
			// Note: We're not leaking the matchingDict.
			// One reference is consumed by IOServiceGetMatchingServices
		}
	}
	
	return (result);
}   // AllocateHIDObjectFromIOHIDDeviceRef
开发者ID:Leonan8995,项目名称:Xenomia,代码行数:38,代码来源:ImmrHIDUtilAddOn.c

示例5: darwin_init

static int darwin_init(void)
{
	kern_return_t err;

	/* Note the actual security happens in the kernel module.
	 * This check is just candy to be able to get nicer output
	 */
	if (getuid() != 0) {
		/* Fun's reserved for root */
		errno = EPERM;
		return -1;
	}

	/* Get the DirectHW driver service */
	iokit_uc = IOServiceGetMatchingService(kIOMasterPortDefault,
					IOServiceMatching("DirectHWService"));

	if (!iokit_uc) {
		printf("DirectHW.kext not loaded.\n");
		errno = ENOSYS;
		return -1;
	}

	/* Create an instance */
	err = IOServiceOpen(iokit_uc, mach_task_self(), 0, &connect);

	/* Should not go further if error with service open */
	if (err != KERN_SUCCESS) {
		printf("Could not create DirectHW instance.\n");
		errno = ENOSYS;
		return -1;
	}

	return 0;
}
开发者ID:bpmilne,项目名称:rwmem,代码行数:35,代码来源:DirectHW.c

示例6: copy_device_imei

CFStringRef copy_device_imei() {
    CFMutableDictionaryRef matching;
    io_service_t service;
    CFDataRef imeiData;
    const void *imeiDataPtr;
    CFStringRef imeiString;
    
    matching = IOServiceNameMatching("baseband");
    service = IOServiceGetMatchingService(kIOMasterPortDefault, matching);
    
    if(!service) {
        return NULL;
    }
    
    imeiData = IORegistryEntryCreateCFProperty(service, CFSTR("device-imei"), kCFAllocatorDefault, 0);
    if(!imeiData) {
        printf("unable to find device-imei property\n");
        IOObjectRelease(service);
        return NULL;
    }
    
    imeiDataPtr = CFDataGetBytePtr(imeiData);
    imeiString = CFStringCreateWithCString(kCFAllocatorDefault, imeiDataPtr, kCFStringEncodingUTF8);
    
    CFRelease(imeiData);
    IOObjectRelease(service);
    
    return imeiString;
}
开发者ID:0bj3ct1veC,项目名称:iphone-dataprotection,代码行数:29,代码来源:registry.c

示例7: connect_to_keystore

static io_connect_t connect_to_keystore(void)
{
    io_registry_entry_t apple_key_bag_service;
    kern_return_t result;
    io_connect_t keystore = MACH_PORT_NULL;

    apple_key_bag_service = IOServiceGetMatchingService(kIOMasterPortDefault,
                                                        IOServiceMatching(kAppleKeyStoreServiceName));

    if (apple_key_bag_service == IO_OBJECT_NULL) {
        fprintf(stderr, "Failed to get service.\n");
        return keystore;
    }

    result = IOServiceOpen(apple_key_bag_service, mach_task_self(), 0, &keystore);
    if (KERN_SUCCESS != result)
        fprintf(stderr, "Failed to open keystore\n");

    if (keystore != MACH_PORT_NULL) {
        IOReturn kernResult = IOConnectCallMethod(keystore,
                                                  kAppleKeyStoreUserClientOpen, NULL, 0, NULL, 0, NULL, NULL,
                                                  NULL, NULL);
        if (kernResult) {
            fprintf(stderr, "Failed to open AppleKeyStore: %x\n", kernResult);
        }
    }
	return keystore;
}
开发者ID:unofficial-opensource-apple,项目名称:Security,代码行数:28,代码来源:si-33-keychain-backup.c

示例8: OSX_ProbeTargetDrive

uint16_t OSX_ProbeTargetDrive(const char* id3args_drive, char* mcdi_data) {
	uint16_t mcdi_data_len = 0;
	io_object_t	cdobject = MACH_PORT_NULL;
	
	if (strncmp(id3args_drive, "disk", 4) != 0) {
		OSX_ScanForCDDrive();
		exit(0);
	}
	cdobject = IOServiceGetMatchingService(kIOMasterPortDefault, IOBSDNameMatching (kIOMasterPortDefault, 0, id3args_drive) );

	if (cdobject == MACH_PORT_NULL) {
		fprintf(stdout, "No device found at %s; searching for possible drives...\n", id3args_drive);
		OSX_ScanForCDDrive();
		
	} else if (IOObjectConformsTo(cdobject, kIOCDMediaClass) == false) {
		fprintf (stdout, "No cd present in drive at %s\n", id3args_drive );
		IOObjectRelease(cdobject);
		cdobject = MACH_PORT_NULL;
		OSX_ScanForCDDrive();
	} else {
		//we now have a cd object
		OSX_ReadCDTOC(cdobject);
		if (cdTOC != NULL) {
			uint8_t cdType = DetermineCDType(cdTOC);
			if (cdType == CDOBJECT_AUDIOCD) {
				mcdi_data_len = FormMCDIdata(mcdi_data);
			}
		}
	}

	IOObjectRelease(cdobject);
	cdobject = MACH_PORT_NULL;
	return mcdi_data_len;
}
开发者ID:DanDrusch,项目名称:atomicparsley,代码行数:34,代码来源:CDtoc.cpp

示例9: getPstateTable

int getPstateTable(PSTATE_CTL_INFO* info){
	int count = 0;
	io_service_t	IOService  = IOServiceGetMatchingService(0, IOServiceMatching(SERVICE_NAME));
	if (! IOService )
		return 0;

	CFDictionaryRef CDictionary = (CFDictionaryRef) IORegistryEntryCreateCFProperty(IOService,					
				CFSTR("Characteristics"),kCFAllocatorDefault,0);

	CFArrayRef PSArray = CFArrayCreateCopy(kCFAllocatorDefault, 
								(CFArrayRef) CFDictionaryGetValue(CDictionary, CFSTR("PStates")));
	if (PSArray) {
		count = CFArrayGetCount(PSArray);
		for( int k = 0; k < count; k++ ){
			CFDictionaryRef PSDictionary = CFDictionaryCreateCopy(kCFAllocatorDefault,
																  (CFDictionaryRef) CFArrayGetValueAtIndex(PSArray, k));
			info->frequency = GetNumber(CFSTR("Frequency"), PSDictionary);
			info->voltage = GetNumber(CFSTR("Voltage"), PSDictionary);
			info->fid = GetNumber(CFSTR("FID"), PSDictionary);
			info->did = GetNumber(CFSTR("DID"), PSDictionary);
			info->vid = GetNumber(CFSTR("VID"), PSDictionary);
			info->pstate = k;
			info++;
			CFRelease(PSDictionary);
		}
		CFRelease(PSArray);
	}
	CFRelease(CDictionary);
	return count;
}
开发者ID:andyvand,项目名称:Intel-OS-X-LAN-Driver,代码行数:30,代码来源:KextIntf.c

示例10: main

int main(int argc, char** argv) {
    char* service_name = "AppleOscarGyro";
    int client_type = 0;

    io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching(service_name));
    if (service == MACH_PORT_NULL) {
        printf("can't find service\n");
        return 0;
    }

    IOServiceOpen(service, mach_task_self(), client_type, &conn);
    if (conn == MACH_PORT_NULL) {
        printf("can't connect to service\n");
        return 0;
    }

    OSSpinLockLock(&lock);

    pthread_t t;
    io_connect_t arg = conn;
    pthread_create(&t, NULL, (void*) go, (void*) &arg);

    usleep(100000);

    OSSpinLockUnlock(&lock);

    close_it(conn);

    pthread_join(t, NULL);

    return 0;
}
开发者ID:wzw19890321,项目名称:OSX_vul,代码行数:32,代码来源:appleoscargyro.c

示例11: main

int main(int argc, char** argv) {
  char* service_name = "IntelAccelerator";
  int client_type = 4;

  io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching(service_name));
  if (service == MACH_PORT_NULL) {
    printf("can't find service\n");
    return 0;
  }

  IOServiceOpen(service, mach_task_self(), client_type, &conn);
  if (conn == MACH_PORT_NULL) {
    printf("can't connect to service\n");
    return 0;
  }

  pthread_t t;
  io_connect_t arg = conn;
  pthread_create(&t, NULL, (void*) go, (void*) &arg);

  usleep(100000);

  start = 1;

  close_it(conn);

  pthread_join(t, NULL);

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

示例12: 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) {
    CFRelease(matching_dict);
    return;
  }

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

  CFMutableDictionaryRef properties;
  IORegistryEntryCreateCFProperties(
      service, &properties, kCFAllocatorDefault, kNilOptions);

  Row r;

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

  auto encrypted = getIOKitProperty(properties, kCoreStorageIsEncryptedKey_);
  r["encrypted"] = (encrypted.empty()) ? "0" : encrypted;
  r["type"] = (r.at("encrypted") == "1") ? kEncryptionType : std::string();

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

示例13: genACPITables

QueryData genACPITables(QueryContext& context) {
  QueryData results;

  auto matching = IOServiceMatching(kIOACPIClassName_);
  if (matching == nullptr) {
    // No ACPI platform expert service found.
    return {};
  }

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

  CFTypeRef table = IORegistryEntryCreateCFProperty(
      service, CFSTR(kIOACPIPropertyName_), kCFAllocatorDefault, 0);
  if (table == nullptr) {
    IOObjectRelease(service);
    return {};
  }

  CFDictionaryApplyFunction((CFDictionaryRef)table, genACPITable, &results);

  CFRelease(table);
  IOObjectRelease(service);
  return results;
}
开发者ID:JessicaWhite17,项目名称:osquery,代码行数:27,代码来源:acpi_tables.cpp

示例14: IOServiceGetMatchingService

std::string LLAppViewerMacOSX::generateSerialNumber()
{
	char serial_md5[MD5HEX_STR_SIZE];		// Flawfinder: ignore
	serial_md5[0] = 0;

	// JC: Sample code from http://developer.apple.com/technotes/tn/tn1103.html
	CFStringRef serialNumber = NULL;
	io_service_t    platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault,
																 IOServiceMatching("IOPlatformExpertDevice"));
	if (platformExpert) {
		serialNumber = (CFStringRef) IORegistryEntryCreateCFProperty(platformExpert,
																	 CFSTR(kIOPlatformSerialNumberKey),
																	 kCFAllocatorDefault, 0);		
		IOObjectRelease(platformExpert);
	}
	
	if (serialNumber)
	{
		char buffer[MAX_STRING];		// Flawfinder: ignore
		if (CFStringGetCString(serialNumber, buffer, MAX_STRING, kCFStringEncodingASCII))
		{
			LLMD5 md5( (unsigned char*)buffer );
			md5.hex_digest(serial_md5);
		}
		CFRelease(serialNumber);
	}

	return serial_md5;
}
开发者ID:Boy,项目名称:netbook,代码行数:29,代码来源:llappviewermacosx.cpp

示例15: copy_bluetooth_mac_address

CFStringRef copy_bluetooth_mac_address() {
    io_service_t service;
    CFDataRef macaddrData;
    CFStringRef macaddr;
    unsigned char macaddrBytes[6];
    
    service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceNameMatching("bluetooth"));
    if(!service) {
        printf("unable to find bluetooth service\n");
        return NULL;
    }
    
    macaddrData= IORegistryEntryCreateCFProperty(service, CFSTR("local-mac-address"), kCFAllocatorDefault, 0);
    if(macaddrData == NULL) {
        printf("bluetooth local-mac-address not found\n");
        IOObjectRelease(service);
        return NULL;
    }
    CFDataGetBytes(macaddrData, CFRangeMake(0,6), macaddrBytes);
    
    macaddr = CFStringCreateWithFormat(kCFAllocatorDefault,
                                        NULL,
                                        CFSTR("%02x:%02x:%02x:%02x:%02x:%02x"),
                                        macaddrBytes[0],
                                        macaddrBytes[1],
                                        macaddrBytes[2],
                                        macaddrBytes[3],
                                        macaddrBytes[4],
                                        macaddrBytes[5]);

    return macaddr;
}
开发者ID:0bj3ct1veC,项目名称:iphone-dataprotection,代码行数:32,代码来源:registry.c


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