![]() ![]() By tracing my way back through the binaries I’d loaded into Hopper, I found that the second parameter of IOServiceRequestProbe should be a bitwise-or between any of the kIOScaleRotates, bitwise-shifted up 16 bits, and kIOFBSetTransform. ![]() I’d already come across the compiled versions of a few successful rotation applications, so I decided to take Hopper out for a spin.Īfter some enormously helpful tutorials (see: here and here) I learned to use Hopper’s “pseudocode” functionality to cut through a dense jungle of assembly to some references to IOGraphicsTypes.h and IOGraphicsTypesPrivate.h, which contained some very important variables: kIOScaleRotate0, kIOScaleRotate90, kIOScaleRotate180, kIOScaleRotate270, and kIOFBSetTransform. ![]() It was at this point that I was first introduced to Hopper, a “reverse engineering tool that lets you disassemble, decompile and debug” existing binaries. I still didn’t know what I was passing IOServiceRequestProbe to actually rotate the display, only that copying other examples in a certain way resulted in a marginal degree of success. To cut a long, arduous adventure short, between Apple’s IOKit documentation and various pages in their open-source documentation, I was able to piece together enough information to reliably perform certain rotation operations consistently (albeit only by introducing many other bugs interfering with display configurations I’d already nailed down, particularly screen mirroring). Thus began my journey to discover what this function actually did, how it did so, and how I could manipulate it. Eventually, I stumbled across fb-rotate, which uses an IOKit function called IOServiceRequestProbe to rotate displays. I played around with this library for a bit, and after a little experimentation, I found ways to do simple things like flip a display’s screen upside down (though issues persisted like the mouse continuing to function right-side-up) with IOServiceRequestProbe. At wit’s end, I searched GitHub for many combinations of the keywords “rotate”, “iokit”, “quartz”, and “coregraphics”. I began with rather little to go on - while Quartz does have a way to check a display’s rotation, it cannot change it in IOKit’s case, there is no widely circulated public documentation (that I could find, at least) that details rotation functionality. ![]() My process for implementing the rotation feature into Display Manager was very much a microcosm of the whole project. Once I’d explored and tested my way to a sufficient understanding of these frameworks (and how the old Display Manager harnessed them), I began fleshing out the Display Manager Library, extending the built-in Quartz and CoreFoundation Python modules with PyObjC (which can reference Objective-C functions and variables directly from the files they “live in”). I began by reorganizing the features that “worked” into display_manager_lib.py, and educating myself about Apple’s Quartz Display Services (a branch of CoreGraphics) and IOKit frameworks, along with Objective-C (the language they’re written in). I started with Pierce Darragh’s “Display Manager” v0.10.0 ( Display Manager v0.10.0), and was tasked with updating several of its deprecated features, along with adding several of my own. This is my first project as a Junior System Administrator in the University of Utah Mac Group, and I’ve learned a great deal about Apple’s display-related frameworks in the course of completing it. Below, I’ll discuss how I found which of Apple’s frameworks to manipulate to manage Mac displays, how I used Hopper Disassembler to explore how others used those frameworks, and how I’ve utilized exploratory testing throughout the project. This blog post outlines my process in rebuilding and updating Display Manager’s codebase. Display Manager works in a 2-part package: a library that actually controls Mac displays ( display_manager_lib.py), and a script that allows access via the command line, and executes commands in a non-interfering way ( display_manager.py). It’s primarily intended for Mac sys admins and developers who need to control displays in specific, predictable ways. Display Manager is a tool that allows users to programmatically manage Mac display settings like resolution, refresh rate, rotation, brightness, screen mirroring, and HDMI underscan. ![]()
0 Comments
Leave a Reply. |