IOMobileFramebufferGetLayerDefaultSurface function failed on iOS 9

∥☆過路亽.° 提交于 2019-12-05 06:18:45

问题


I created a app to capture screenshot in background. It works well on iOS 7.x & 8.x, but failed to execute on iOS 9 beta. Here's my code:

CFMutableDictionaryRef sm = IOServiceMatching("AppleH1CLCD");
io_service_t ioService = IOServiceGetMatchingService(kIOMasterPortDefault, sm);
if (!ioService)
{
    sm = IOServiceMatching("AppleM2CLCD");
    ioService = IOServiceGetMatchingService(kIOMasterPortDefault, sm);
}

if (!ioService)
{
    sm = IOServiceMatching("AppleCLCD");
    ioService = IOServiceGetMatchingService(kIOMasterPortDefault, sm);
} 


IOMobileFramebufferConnection connection = 0;
IOSurfaceRef ptr = nil;

IOMobileFramebufferReturn openMobileFrameBufferResult = IOMobileFramebufferOpen(ioService, mach_task_self(), 0, &connection);

if (openMobileFrameBufferResult)
{
    return;
}

IOMobileFramebufferReturn getLayerDefaultSurfaceResult = IOMobileFramebufferGetLayerDefaultSurface(connection, 0,  (CoreSurfaceBufferRef*)&ptr);
if (getLayerDefaultSurfaceResult)
{
    return;   // Here, the getLayerDefaultSurfaceResult is -536870201, not 0!
}

.......

When debugging it step by step, I found that the function IOMobileFramebufferGetLayerDefaultSurface failed to execute with a returning value -536870201 and the value expected was 0.

Who can tell me why this happened and how to resolve it ? thhhhhhhhhhhhhhhx!!


回答1:


Another user asked a similar question. I did some digging into IOMobileFramebufferGetLayerDefaultSurface on iOS8 vs iOS9 (GM). And the results of what I found are summarized in this answer.

Given these results, I believe it is no longer possible, as of iOS9, to use IOMFB to capture the screen.



来源:https://stackoverflow.com/questions/32136308/iomobileframebuffergetlayerdefaultsurface-function-failed-on-ios-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!