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


C++ IOServiceOpen函数代码示例

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


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

示例1: SMCOpen

kern_return_t SMCOpen(io_connect_t *conn, const char *serviceName)
{
    kern_return_t result;
    mach_port_t   masterPort;
    io_iterator_t iterator;
    io_object_t   device;

    IOMasterPort(MACH_PORT_NULL, &masterPort);

    CFMutableDictionaryRef matchingDictionary = IOServiceMatching(serviceName);
    result = IOServiceGetMatchingServices(masterPort, matchingDictionary, &iterator);
    if (result != kIOReturnSuccess)
    {
        //printf("Error: IOServiceGetMatchingServices() = %08x\n", result);
        return 1;
    }

    device = IOIteratorNext(iterator);
    IOObjectRelease((io_object_t)iterator);
    if (device == 0)
    {
        //printf("Error: no SMC found\n");
        return 1;
    }

    result = IOServiceOpen(device, mach_task_self(), 0, conn);
    IOObjectRelease(device);
    if (result != kIOReturnSuccess)
    {
        //printf("Error: IOServiceOpen() = %08x\n", result);
        return 1;
    }

    return kIOReturnSuccess;
}
开发者ID:ritzcarltn,项目名称:HWSensors,代码行数:35,代码来源:smc.c

示例2: IOAccelCreateAccelID

IOReturn IOAccelCreateAccelID(IOOptionBits options, IOAccelID * identifier)
{
    IOReturn err;

    if (!idConnect)
    {
        io_service_t
        service = IORegistryEntryFromPath(kIOMasterPortDefault, 
                                        kIOServicePlane ":/IOResources/IODisplayWrangler");
        if (service) 
        {
            err = IOServiceOpen(service, mach_task_self(), 0, &idConnect);
            IOObjectRelease(service);
        }
    }

    if (!idConnect)
        return (kIOReturnNotReady);

    uint64_t inData[] = { options, *identifier };
    uint64_t outData;
    uint32_t outLen = 1;
    err = IOConnectCallScalarMethod(idConnect, kAlloc,
                                 inData,   arrayCnt(inData),
                                &outData,  &outLen);
    *identifier = (IOAccelID) outData;

    return (err);
}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:29,代码来源:IOAccelSurfaceControl.c

示例3: connectSmartBatteryManager

io_connect_t    connectSmartBatteryManager(uint32_t options, IOReturn *outret)
{
    io_service_t            smartbattman_entry = MACH_PORT_NULL;
    io_connect_t            manager_connect = MACH_PORT_NULL;
    IOReturn                ret;

    smartbattman_entry = IOServiceGetMatchingService( MACH_PORT_NULL,
                            IOServiceNameMatching(kBatteryManagerName) );


    if (MACH_PORT_NULL == smartbattman_entry) {
        return MACH_PORT_NULL;
    }

    ret = IOServiceOpen( smartbattman_entry,            /* service */
                         mach_task_self(),              /* owning task */
                         options,                       /* type - kBatteryExclusiveAccessType or not*/
                         &manager_connect);             /* connect */


    if (outret) *outret = ret;

    if(kIOReturnSuccess != ret) {
        return MACH_PORT_NULL;
    }
    
    IOObjectRelease(smartbattman_entry);
    return manager_connect;
}
开发者ID:hashier,项目名称:caffeinate_fix,代码行数:29,代码来源:SmartBatteryUserClient.c

示例4: PCIDriver_setupDriver

int PCIDriver_setupDriver()
{
	kern_return_t   kern_result;
    io_iterator_t   iterator;
    bool            driverFound = false;
    io_service_t    local_driver_service;
    
	// get services
    kern_result = IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceMatching(kPcmMsrDriverClassName), &iterator);
	if (kern_result != KERN_SUCCESS) {
		fprintf(stderr, "[error] IOServiceGetMatchingServices returned 0x%08x\n", kern_result);
        return kern_result;
    }
	
	// find service
	while ((local_driver_service = IOIteratorNext(iterator)) != IO_OBJECT_NULL) {
        driverFound = true;
        break;
    }
	if (driverFound == false) {  
        fprintf(stderr, "[error] No matching drivers found \"%s\".\n", kPcmMsrDriverClassName);
        return KERN_FAILURE;
    }
	IOObjectRelease(iterator);

	// connect to service
    kern_result = IOServiceOpen(local_driver_service, mach_task_self(), 0, &PCIDriver_connect);
    if (kern_result != KERN_SUCCESS) {
        fprintf(stderr, "[error] IOServiceOpen returned 0x%08x\n", kern_result);
		return kern_result;
    }
	
	return KERN_SUCCESS;
}
开发者ID:Hope1993,项目名称:pbdPAPI,代码行数:34,代码来源:PCIDriverInterface.cpp

示例5: IOAccelCreateSurface

IOReturn IOAccelCreateSurface( io_service_t accelerator, UInt32 wID, eIOAccelSurfaceModeBits modebits,
                                IOAccelConnect *connect )
{
        IOReturn        kr;
        io_connect_t    window = MACH_PORT_NULL;

        *connect = NULL;

        /* Create a context */
        kr = IOServiceOpen( accelerator,
                    mach_task_self(),
                    kIOAccelSurfaceClientType,
                    &window );

        if( kr != kIOReturnSuccess)
        {
                return kr;
        }

        /* Set the window id */
        uint64_t data[] = { wID, modebits };
        kr = IOConnectCallScalarMethod(window, kIOAccelSurfaceSetIDMode,
                                   data, arrayCnt(data), NULL, NULL);
        if(kr != kIOReturnSuccess)
        {
                IOServiceClose(window);
                return kr;
        }

        *connect = (IOAccelConnect) (uintptr_t) window;

        return kIOReturnSuccess;
}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:33,代码来源:IOAccelSurfaceControl.c

示例6: hook_get_pointer_acceleration_multiplier

UIOHOOK_API long int hook_get_pointer_acceleration_multiplier() {
	#if defined USE_IOKIT || defined USE_COREFOUNDATION
	bool successful = false;
	double multiplier;
	#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), &multiplier);
				if (kren_ret == kIOReturnSuccess) {
					// Calculate the greatest common factor.

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

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

					value = denominator / gcf;
					successful = true;

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

	#ifdef USE_COREFOUNDATION
	if (!successful) {
		CFTypeRef pref_val = CFPreferencesCopyValue(CFSTR("com.apple.mouse.scaling"), kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
		if (pref_val != NULL && CFGetTypeID(pref_val) == CFNumberGetTypeID()) {
			if (CFNumberGetValue((CFNumberRef) pref_val, kCFNumberSInt32Type, &multiplier)) {
				value = (long) multiplier;

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

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

示例7: IOServiceMatching

 kern_return_t 
 CPUTemp::SMCOpen(void)
 {
     kern_return_t result;
     io_iterator_t iterator;
     io_object_t   device;
 
     CFMutableDictionaryRef matchingDictionary = IOServiceMatching("AppleSMC");
     result = IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDictionary, &iterator);
     if (result != kIOReturnSuccess)
     {
         printf("Error: IOServiceGetMatchingServices() = %08x\n", result);
         return 1;
     }
 
     device = IOIteratorNext(iterator);
     IOObjectRelease(iterator);
     if (device == 0)
     {
         printf("Error: no SMC found\n");
         return 1;
     }
 
     result = IOServiceOpen(device, mach_task_self(), 0, &conn);
     IOObjectRelease(device);
     if (result != kIOReturnSuccess)
     {
         printf("Error: IOServiceOpen() = %08x\n", result);
         return 1;
     }
 
     return kIOReturnSuccess;
 }
开发者ID:tempbottle,项目名称:cpusensor,代码行数:33,代码来源:cpu-temp.cpp

示例8: IN_GetIOHandle

/*
===============
IN_GetIOHandle
===============
*/
static io_connect_t IN_GetIOHandle( void )  // mac os x mouse accel hack
{
	io_connect_t  iohandle = MACH_PORT_NULL;
	kern_return_t status;
	io_service_t  iohidsystem = MACH_PORT_NULL;
	mach_port_t   masterport;

	status = IOMasterPort( MACH_PORT_NULL, &masterport );

	if ( status != KERN_SUCCESS )
	{
		return 0;
	}

	iohidsystem = IORegistryEntryFromPath( masterport, kIOServicePlane ":/IOResources/IOHIDSystem" );

	if ( !iohidsystem )
	{
		return 0;
	}

	status = IOServiceOpen( iohidsystem, mach_task_self(), kIOHIDParamConnectType, &iohandle );
	IOObjectRelease( iohidsystem );

	return iohandle;
}
开发者ID:SHOVELL,项目名称:Unvanquished,代码行数:31,代码来源:sdl_input.c

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

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

示例11: get_event_driver

io_connect_t get_event_driver(void){
	static  mach_port_t sEventDrvrRef = 0;
	mach_port_t masterPort, service, iter;
	kern_return_t    kr;
	
	if (!sEventDrvrRef)
	{
		// Get master device port
		kr = IOMasterPort( bootstrap_port, &masterPort );
		check( KERN_SUCCESS == kr);
		
		kr = IOServiceGetMatchingServices( masterPort, IOServiceMatching(
																		 kIOHIDSystemClass ), &iter );
		check( KERN_SUCCESS == kr);
		
		service = IOIteratorNext( iter );
		check( service );
		
		kr = IOServiceOpen( service, mach_task_self(),
							kIOHIDParamConnectType, &sEventDrvrRef );
		check( KERN_SUCCESS == kr );
		
		IOObjectRelease( service );
		IOObjectRelease( iter );
	}
	return sEventDrvrRef;
}
开发者ID:andreberg,项目名称:blacktree-alchemy,代码行数:27,代码来源:QSMediaKeys.c

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

示例13: NXOpenEventStatus

/* Open and Close */
NXEventHandle NXOpenEventStatus(void)
{
    NXEventHandle 		handle = MACH_PORT_NULL;
    register kern_return_t	kr;
    io_service_t		service = MACH_PORT_NULL;
    mach_port_t			masterPort;

    do {

	kr = IOMasterPort( MACH_PORT_NULL, &masterPort );
	if( kr != KERN_SUCCESS)
	    break;

        service = IORegistryEntryFromPath( masterPort,
                    kIOServicePlane ":/IOResources/IOHIDSystem" );
	if( !service)
	    break;

        kr = IOServiceOpen( service,
			mach_task_self(),
			kIOHIDParamConnectType,
			&handle);

        IOObjectRelease( service );

    } while( false );

    return( handle );
}
开发者ID:wzw19890321,项目名称:IOKitUser,代码行数:30,代码来源:IOEventStatusAPI.c

示例14: open_and_connect_user_client

io_connect_t open_and_connect_user_client(char* service_name, int type) {
    kern_return_t err;
    io_connect_t conn = MACH_PORT_NULL;
    
    CFMutableDictionaryRef matching = IOServiceMatching("IOGraphicsAccelerator2");
    if(!matching){
        printf("unable to create service matching dictionary\n");
        return conn;
    }
    
    io_iterator_t iterator;
    err = IOServiceGetMatchingServices(kIOMasterPortDefault, matching, &iterator);
    if (err != KERN_SUCCESS){
        printf("no matches\n");
        return conn;
    }
    
    io_service_t service = IOIteratorNext(iterator);
    
    if (service == IO_OBJECT_NULL){
        printf("unable to find service\n");
        return conn;
    }
    printf("got service: %x\n", service);
    
    
    err = IOServiceOpen(service, mach_task_self(), type, &conn);
    if (err != KERN_SUCCESS){
        printf("unable to get user client connection\n");
        return MACH_PORT_NULL;
    }
    //getchar();
    printf("got userclient connection: %x\n", conn);
    return conn;
}
开发者ID:LucaBongiorni,项目名称:Bug_POCs,代码行数:35,代码来源:main.cpp

示例15: printMsgBuffer

void printMsgBuffer(io_service_t service)
{
	kern_return_t ret;
	io_connect_t connect = 0;
#if __LP64__
	mach_vm_address_t address;
	mach_vm_size_t size;	
#else	
	vm_address_t address;
	vm_size_t size;
#endif	

	ret = IOServiceOpen(service, mach_task_self(), 0, &connect);
	if (ret != KERN_SUCCESS) {
		printf("error: IOServiceOpen returned 0x%08x\n", ret);
		goto failure;
	}

	ret = IOConnectMapMemory(connect, kVoodooHDAMemoryMessageBuffer, mach_task_self(), &address, &size,
			kIOMapAnywhere | kIOMapDefaultCache);
	if (ret != kIOReturnSuccess) {
		printf("error: IOConnectMapMemory returned 0x%08x\n", ret);
		goto failure;
	}

	printf("%s\n", (char *) address);

failure:
	if (connect) {
		ret = IOServiceClose(connect);
		if (ret != KERN_SUCCESS)
			printf("warning: IOServiceClose returned 0x%08x\n", ret);
	}
}
开发者ID:andyvand,项目名称:VoodooHDA_AnV,代码行数:34,代码来源:getdump.c


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