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


C++ IOServiceClose函数代码示例

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


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

示例1: main

int
main(int argc, char **argv)
{
    kern_return_t   kr; 
    int             ret;
    io_iterator_t   iterator;
    io_service_t    serviceObject;
    CFDictionaryRef classToMatch;
    pthread_t       dataQueueThread;
    io_connect_t    connection;
    
    setbuf(stdout, NULL);
   
    if (!(classToMatch = IOServiceMatching(VNODE_WATCHER_IOKIT_CLASS)))
        PRINT_ERROR_AND_RETURN("failed to create matching dictionary", -1);
    
    kr = IOServiceGetMatchingServices(kIOMasterPortDefault, classToMatch,
                                      &iterator);
    if (kr != kIOReturnSuccess)
        PRINT_ERROR_AND_RETURN("failed to retrieve matching services", -1);
    
    serviceObject = IOIteratorNext(iterator);
    IOObjectRelease(iterator);
    if (!serviceObject)
        PRINT_ERROR_AND_RETURN("VnodeWatcher service not found", -1);
    
    kr = IOServiceOpen(serviceObject, mach_task_self(), 0, &connection);
    IOObjectRelease(serviceObject);
    if (kr != kIOReturnSuccess)
        PRINT_ERROR_AND_RETURN("failed to open VnodeWatcher service", kr);
   
    kr = IOConnectMethodScalarIScalarO(connection,
                                       kt_kVnodeWatcherUserClientOpen, 0, 0);
    if (kr != KERN_SUCCESS) {
        (void)IOServiceClose(connection);
        PRINT_ERROR_AND_RETURN("VnodeWatcher service is busy", kr);
    }
    
    ret = pthread_create(&dataQueueThread, (pthread_attr_t *)0,
                         (void *)vnodeNotificationHandler, (void *)connection);
    if (ret)
        perror("pthread_create");
    else
        pthread_join(dataQueueThread, (void **)&kr);
   
    (void)IOServiceClose(connection);
                  
    return 0;
}
开发者ID:Leask,项目名称:Mac-OS-X-Internals,代码行数:49,代码来源:vnodewatch.c

示例2: DisconnectFromSmc

static void DisconnectFromSmc(void)
{
    if (g_hSmcConnect)
    {
        IOConnectCallMethod(g_hSmcConnect, kSMCUserClientClose, NULL, 0, NULL, 0, NULL, NULL, NULL, NULL);
        IOServiceClose(g_hSmcConnect);
        g_hSmcConnect = IO_OBJECT_NULL;
    }

    if (g_hSmcService)
    {
        IOServiceClose(g_hSmcService);
        g_hSmcService = IO_OBJECT_NULL;
    }
}
开发者ID:sobomax,项目名称:virtualbox_64bit_edd,代码行数:15,代码来源:VBoxSmcUtil-darwin.cpp

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

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

示例5: suplibOsInit

int suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, bool fUnrestricted, SUPINITOP *penmWhat, PRTERRINFO pErrInfo)
{
    /*
     * Nothing to do if pre-inited.
     */
    if (fPreInited)
        return VINF_SUCCESS;

    /*
     * Do the job.
     */
    Assert(pThis->hDevice == (intptr_t)NIL_RTFILE);
    int rc = suplibDarwinOpenService(pThis);
    if (RT_SUCCESS(rc))
    {
        rc = suplibDarwinOpenDevice(pThis, fUnrestricted);
        if (RT_FAILURE(rc))
        {
            kern_return_t kr = IOServiceClose((io_connect_t)pThis->uConnection);
            if (kr != kIOReturnSuccess)
            {
                LogRel(("Warning: IOServiceClose(%RCv) returned %d\n", pThis->uConnection, kr));
                AssertFailed();
            }
            pThis->uConnection = 0;
        }
    }

    return rc;
}
开发者ID:sobomax,项目名称:virtualbox_64bit_edd,代码行数:30,代码来源:SUPLib-darwin.cpp

示例6: enkript_prologue

void enkript_prologue(void)
{
  if (IOConnectCallMethod == NULL) die("IOConnectCallMethod unavailable, require version >= 10.5");
  /* get iterator to browse drivers of the chosen class
   */
  io_iterator_t iterator;
  if (IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceMatching("com_enkript_driver_Service"), &iterator) != KERN_SUCCESS) die("IOServiceGetMatchingServices failed");
  /* browse drivers
   */
  for (io_service_t service = IOIteratorNext(iterator); service != IO_OBJECT_NULL; service = IOIteratorNext(iterator))
  {
    debug("com_enkript_driver_Service instance found!");
    /* open service
     */
    io_connect_t connect = IO_OBJECT_NULL;
    if (IOServiceOpen(service, mach_task_self(), 0, &connect) != KERN_SUCCESS) die("IOServiceOpen failed");
    /* call driver's open method
     */
    if (IOConnectCallMethod(connect, 0 /* open, TOFIX */, NULL, 0, NULL, 0, NULL, NULL, NULL, NULL) != KERN_SUCCESS) die("IOConnectCallMethod failed");
    /* call driver's hello method
     */
    uint64_t buf = getpid();
    if (IOConnectCallMethod(connect, 2 /* hello, TOFIX */, &buf, 1, NULL, 0, NULL, NULL, NULL, NULL) != KERN_SUCCESS) die("IOConnectCallMethod failed");
    /* call driver's close method
     */
    if (IOConnectCallMethod(connect, 1 /* close, TOFIX */, NULL, 0, NULL, 0, NULL, NULL, NULL, NULL) != KERN_SUCCESS) die("IOConnectCallMethod failed");
    /* close service
     */
    if (IOServiceClose(connect) != KERN_SUCCESS) die("IOServiceClose failed");
	}
  IOObjectRelease(iterator);
}
开发者ID:nicolascormier,项目名称:ncormier-academic-projects,代码行数:32,代码来源:main.c

示例7: os_inputclose

void os_inputclose(usbdevice* kb){
    if(kb->event){
        clearkeys(kb);
        IOServiceClose(kb->event);
        kb->event = 0;
    }
}
开发者ID:akosipc,项目名称:ckb,代码行数:7,代码来源:input_mac.c

示例8: PortsCleanup

/* Cleanup of the open ports */
void PortsCleanup()
{
	CFRunLoopRemoveSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(notifyPortRef), kCFRunLoopCommonModes);    /* Remove the notification port from the runloop */
	IODeregisterForSystemPower(&notifierObject);                                                                               /* Deregister from power notifications */
	IOServiceClose(root_power_port);                                                                                           /* Close the Root Power Domain IOService port */
	IONotificationPortDestroy(notifyPortRef);                                                                                  /* Destroy the notification port */
}
开发者ID:toshiya240,项目名称:DeepSleep,代码行数:8,代码来源:deepsleep.c

示例9: CFRunLoopRemoveSource

void CCocoaPowerSyscall::DeleteOSPowerCallBacks(void)
{
#if !defined(TARGET_DARWIN_IOS)
  CCocoaAutoPool autopool;
  // we no longer want sleep/wake notifications
  // remove the sleep notification port from the application runloop
  CFRunLoopRemoveSource( CFRunLoopGetCurrent(),
    IONotificationPortGetRunLoopSource(m_notify_port), kCFRunLoopDefaultMode );
  // deregister for system sleep notifications
  IODeregisterForSystemPower(&m_notifier_object);
  // IORegisterForSystemPower implicitly opens the Root Power Domain IOService
  // so we close it here
  IOServiceClose(m_root_port);
  // destroy the notification port allocated by IORegisterForSystemPower
  IONotificationPortDestroy(m_notify_port);
  
  // we no longer want power source change notifications
  if (m_HasBattery)
  {
    if (m_power_source)
    {
      CFRunLoopRemoveSource( CFRunLoopGetCurrent(), m_power_source, kCFRunLoopDefaultMode );
      CFRelease(m_power_source);
    }
  }
#endif
}
开发者ID:Alxandr,项目名称:spotyxbmc2,代码行数:27,代码来源:CocoaPowerSyscall.cpp

示例10: suplibOsTerm

int suplibOsTerm(PSUPLIBDATA pThis)
{
    /*
     * Close the connection to the IOService.
     * This will cause the SUPDRVSESSION to be closed (starting IOC 9.1).
     */
    if (pThis->uConnection)
    {
        kern_return_t kr = IOServiceClose((io_connect_t)pThis->uConnection);
        if (kr != kIOReturnSuccess)
        {
            LogRel(("Warning: IOServiceClose(%RCv) returned %d\n", pThis->uConnection, kr));
            AssertFailed();
        }
        pThis->uConnection = 0;
    }

    /*
     * Check if we're inited at all.
     */
    if (pThis->hDevice != (intptr_t)NIL_RTFILE)
    {
        if (close(pThis->hDevice))
            AssertFailed();
        pThis->hDevice = (intptr_t)NIL_RTFILE;
    }

    return VINF_SUCCESS;
}
开发者ID:sobomax,项目名称:virtualbox_64bit_edd,代码行数:29,代码来源:SUPLib-darwin.cpp

示例11: dtime

// On Dual-GPU Macbook Pros only:
// switch to intrinsic GPU if running on battery
// switch to discrete GPU if running on AC power
//
// Apple's Screensaver Engine will detect the GPU change and
// call stopAnimation, then initWithFrame and startAnimation.
void CScreensaver::CheckDualGPUStatus() {
    static double lastBatteryCheckTime = 0;
    double currentTime;
    bool nowOnBattery;
    
    if (!IsDualGPUMacbook) return;
    if (OKToRunOnBatteries) return;
    
    currentTime = dtime();
    if (currentTime < lastBatteryCheckTime + BATTERY_CHECK_INTERVAL) return;
    lastBatteryCheckTime = currentTime;
    
    nowOnBattery = Host_is_running_on_batteries();
    if (nowOnBattery == RunningOnBattery) return;
    
    RunningOnBattery = nowOnBattery;
    if (nowOnBattery) {
        if (GPUSelectConnect != IO_OBJECT_NULL) {
            IOServiceClose(GPUSelectConnect);
            GPUSelectConnect = IO_OBJECT_NULL;
        }
        // If an OpenGL screensaver app is running, we must shut it down
        // to release its claim on the discrete GPU to save battery power.
        DestroyDataManagementThread();
    } else {
        SetDiscreteGPU(true);
    }
}
开发者ID:DanAurea,项目名称:boinc,代码行数:34,代码来源:mac_saver_module.cpp

示例12: mac_sleep_stop

    void mac_sleep_stop()
    {
      if (root_port)
	{
	  // remove the sleep notification port from the application runloop
	  CFRunLoopRemoveSource(CFRunLoopGetCurrent(),
				IONotificationPortGetRunLoopSource(notifyPortRef),
				kCFRunLoopCommonModes);

	  // deregister for system sleep notifications
	  IODeregisterForSystemPower(&notifierObject);

	  // IORegisterForSystemPower implicitly opens the Root Power Domain IOService
	  // so we close it here
	  IOServiceClose(root_port);

	  // destroy the notification port allocated by IORegisterForSystemPower
	  IONotificationPortDestroy(notifyPortRef);

	  // reset object members
	  root_port = 0;
	  notifyPortRef = NULL;
	  notifierObject = 0;
	}
    }
开发者ID:akoshelnik,项目名称:openvpn3,代码行数:25,代码来源:macsleep.hpp

示例13: IN_DeactivateMouse

/*
===============
IN_DeactivateMouse
===============
*/
void IN_DeactivateMouse( void )
{
	if ( !SDL_WasInit( SDL_INIT_VIDEO ) )
	{
		return;
	}

	// Always show the cursor when the mouse is disabled,
	// but not when fullscreen
	if ( !Cvar_VariableIntegerValue( "r_fullscreen" ) )
	{
		SDL_ShowCursor( 1 );
	}

	if ( !mouseAvailable )
	{
		return;
	}

#ifdef MACOS_X_ACCELERATION_HACK

	if ( mouseActive ) // mac os x mouse accel hack
	{
		if ( originalMouseSpeed != -1.0 )
		{
			io_connect_t mouseDev = IN_GetIOHandle();

			if ( mouseDev != 0 )
			{
				Com_DPrintf( "restoring mouse acceleration to: %f\n", originalMouseSpeed );

				if ( IOHIDSetAccelerationWithKey( mouseDev, CFSTR( kIOHIDMouseAccelerationType ), originalMouseSpeed ) != kIOReturnSuccess )
				{
					Com_DPrintf( "Could not re-enable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n" );
				}

				IOServiceClose( mouseDev );
			}
			else
			{
				Com_DPrintf( "Could not re-enable mouse acceleration (failed at IO_GetIOHandle).\n" );
			}
		}
	}

#endif

	if ( mouseActive )
	{
		IN_GobbleMotionEvents();

		SDL_WM_GrabInput( SDL_GRAB_OFF );

		// Don't warp the mouse unless the cursor is within the window
		//if( SDL_GetAppState( ) & SDL_APPMOUSEFOCUS )
		//SDL_WarpMouse( cls.glconfig.vidWidth / 2, cls.glconfig.vidHeight / 2 );

		mouseActive = qfalse;
	}
}
开发者ID:SHOVELL,项目名称:Unvanquished,代码行数:65,代码来源:sdl_input.c

示例14: fake_IOServiceClose

kern_return_t
fake_IOServiceClose(
  io_connect_t  connect )
{
  printf("IOServiceClose(connect=%p)\n", connect);
  return IOServiceClose(connect);
}
开发者ID:ik2ploit,项目名称:OSX_vul,代码行数:7,代码来源:ig_video_media_jpegdecode.c

示例15: reset_baseband

void reset_baseband() {
    printf("Resetting baseband\n");
    io_connect_t connect = 0;
    CFMutableDictionaryRef match = IOServiceMatching("AppleBaseband");
    io_service_t service = IOServiceGetMatchingService(0, match);
    IOServiceOpen(service, mach_task_self(), 0, &connect);
    IOConnectCallScalarMethod(connect, 0, 0, 0, 0, 0);
    IOServiceClose(connect);
    sleep(1);
}
开发者ID:justvanbloom,项目名称:DLOADTool,代码行数:10,代码来源:main.cpp


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