Skip to content

Instantly share code, notes, and snippets.

@NilStack
Forked from anthonya1999/IOMobileFramebuffer.h
Created January 10, 2016 12:30
Show Gist options
  • Save NilStack/97dbc2bc05b8fa7c6095 to your computer and use it in GitHub Desktop.
Save NilStack/97dbc2bc05b8fa7c6095 to your computer and use it in GitHub Desktop.
A recent disassembly of IOMobileFramebuffer framework
/* You may have to include your IOSurface header to compile, because of the GetLayerDefaultSurface function. If you do not have it, you may just uncomment the typedef to an IOSurface below. */
#include <stdio.h>
#include <sys/mman.h>
#ifdef __cplusplus
extern "C" {
#endif
#define kIOMobileFramebufferError 0xE0000000
typedef kern_return_t IOMobileFramebufferReturn;
typedef struct __IOMobileFramebuffer *IOMobileFramebufferConnection;
/* typedef struct __IOSurface *IOSurfaceRef */
typedef struct {
uint32_t values[0xc0c / sizeof(uint32_t)];
} IOMobileFramebufferGammaTable;
typedef long s1516;
typedef struct {
union {
s1516 values[9];
} content;
} IOMobileFramebufferGamutMatrix;
typedef NS_ENUM(int, IOMobileFramebufferColorRemapMode) {
IOMobileFramebufferColorRemapModeError = -1,
IOMobileFramebufferColorRemapModeNormal = 0,
IOMobileFramebufferColorRemapModeInverted = 1,
IOMobileFramebufferColorRemapModeGrayscale = 2,
IOMobileFramebufferColorRemapModeGrayscaleIncreaseContrast = 3,
IOMobileFramebufferColorRemapModeInvertedGrayscale = 4
};
typedef NS_ENUM(uint32_t, IOMobileFramebufferBrightnessCorrection) {
IOMobileFramebufferBrightnessCorrectionReducedWhitepoint = 57344,
IOMobileFramebufferBrightnessCorrectionDefault = 65535
};
IOMobileFramebufferReturn IOMobileFramebufferOpen(mach_port_t service, mach_port_t owningTask, unsigned int type, IOMobileFramebufferConnection *connection);
IOMobileFramebufferReturn IOMobileFramebufferGetLayerDefaultSurface(IOMobileFramebufferConnection connection, int surface, IOSurfaceRef *buffer);
/* Use this instead of IOMobileFramebufferOpen, it is much more efficient and requires only this one function, rather getting the "AppleCLCD" and opening this service */
IOMobileFramebufferReturn IOMobileFramebufferGetMainDisplay(IOMobileFramebufferConnection *connection);
IOMobileFramebufferReturn IOMobileFramebufferSwapBegin(IOMobileFramebufferConnection connection, int *token);
IOMobileFramebufferReturn IOMobileFramebufferSwapEnd(IOMobileFramebufferConnection connection);
IOMobileFramebufferReturn IOMobileFramebufferSwapSetLayer(IOMobileFramebufferConnection connection, int layerid, IOSurfaceRef buffer);
IOMobileFramebufferReturn IOMobileFramebufferSwapWait(IOMobileFramebufferConnection connection, int token, int something);
IOMobileFramebufferReturn IOMobileFramebufferGetDisplayArea(IOMobileFramebufferConnection connection, CGFloat *displayArea);
IOMobileFramebufferReturn IOMobileFramebufferGetDisplaySize(IOMobileFramebufferConnection connection, CGSize *size);
IOMobileFramebufferReturn IOMobileFramebufferGetGammaTable(IOMobileFramebufferConnection connection, IOMobileFramebufferGammaTable *table);
IOMobileFramebufferReturn IOMobileFramebufferSetGammaTable(IOMobileFramebufferConnection connection, IOMobileFramebufferGammaTable *table);
IOMobileFramebufferReturn IOMobileFramebufferSetContrast(IOMobileFramebufferConnection connection, int level);
IOMobileFramebufferReturn IOMobileFramebufferGetColorRemapMode(IOMobileFramebufferConnection connection, IOMobileFramebufferColorRemapMode *mode);
IOMobileFramebufferReturn IOMobileFramebufferSetColorRemapMode(IOMobileFramebufferConnection connection, IOMobileFramebufferColorRemapMode mode);
IOMobileFramebufferReturn IOMobileFramebufferSetWhiteOnBlackMode(IOMobileFramebufferConnection connection, BOOL enabled);
IOMobileFramebufferReturn IOMobileFramebufferSetBrightnessCorrection(IOMobileFramebufferConnection connection, IOMobileFramebufferBrightnessCorrectionValue value);
/* If iOS version >= 8.3 & < 9.0, the name of the function is "IOMobileFramebufferGetGamutCSC". The function does not exist at all on versions < 8.3 */
IOMobileFramebufferReturn IOMobileFramebufferGetGamutMatrix(IOMobileFramebufferConnection connection, IOMobileFramebufferGamutMatrix *matrix);
/* If iOS version >= 8.3 & < 9.0, the name of the function is "IOMobileFramebufferSetGamutCSC". The function does not exist at all on versions < 8.3 */
IOMobileFramebufferReturn IOMobileFramebufferSetGamutMatrix(IOMobileFramebufferConnection conneciton, IOMobileFramebufferGamutMatrix *matrix);
#ifdef __cplusplus
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment