Brief Tutorial on Reverse Engineering Mac OS X 121
rjw57 writes "There is an article on OSNews I wrote about how the guy behind Desktop Manager goes about reverse engineering APIs from Mac OS X with a brand new example not revealed anywhere else. From the article: 'I am often asked in email how I uncovered the API calls I use in Desktop Manager which are, unfortunately, undocumented. This article aims to give a little insight into the techniques I use to reverse engineer Mac OS X in order to provide extra functionality to users and extra information to third-party developers. In this article all the utilities I use are a standard part of Mac OS X's developer tools which are freely available.'"
Versus Expose? (Score:3, Insightful)
However, Apple have already come up with a perfect way of handling large groups of windows on one screen; it's called expose. I used to use virtual desktops on Linux, which was adequate, but when I got a Mac I settled in nicely with Expose; OS X has a near perfect user interface designed by actual HID experts. The only reason I can think of for using virtual desktops is if you're some kind of Linux zealot.
(Don't mod me down just because you're an anti-Mac zealot mod
Re:Versus Expose? (Score:5, Interesting)
I'm surprised Apple hasn't made it a built-in feature. They have fast user switching, but that's not the same thing.
Re:Versus Expose? (Score:1)
I agree; Desktop Manager is a great piece of software - free, reliable, and amazingly small.
Re:Versus Expose? (Score:2, Informative)
As a user of Linux and Mac, I use both Virt Desktops and Expose (used to use VD on the Mac before 10.3). Not trying to be a flamer here but there is no way one person can be productive with 4x (or even 2x) what Expose handles.
Expose is good for less than 15 windows on a standard desktop. Those with t
It depends on how you work (Score:5, Insightful)
For me, this means using Hide (Command-H), Swich app (Alt-Tab), Focus on window (active) or next window (a custom key binding like Alt-Tab), and Expose.
But that doesn't mean there isn't a place for virtual desktops.
One thing that expose relies on is that the conceptual groupings of "All app windows" and "All of this apps windows" are all you need. The problem is if you have a large number of similar looking windows from different applications it can be difficult to manage even with Expose.
Virtual desktops can give you custom Expose groups - which can narrow the search for a particular window. This can be useful if you are working on several complex tasks that use multiple windows from multiple apps (each task can get its own desktop), and also have a bunch of side apps - like your calendar, email, instant messenger etc.
So Expose solves the window management problem to an extent, but it can be combined with virtual desktops when things become even more complex.
Re:It depends on how you work (Score:1)
As you said, when you use Exposee, Hide, etc. Then you are way more powerful.
Especially F10 Esposee to show all windows of the current app, are the Virtual Desktop Killer for me. (at least at home)
Re:It depends on how you work (Score:4, Interesting)
Re:It depends on how you work (Score:1)
When I switch apps I usually either do it via CMD+TAB (no hiding) or I click on the dock wile pressing OPTION that way the current app gets hidden. Keeps the screen clean.
Re:Versus Expose? (Score:5, Insightful)
I personally don't use multiple desktops, even in Linux, but would never, ever consider taking away that functionality (if I had the power to do so), knowing how useful it is to so many other people. For that reason, I think it'd be a great idea for Apple to add this feature to OSX.
Re:Versus Expose? (Score:1)
An example of this is at work, I need to have serveral different applications open, each having multiple windows. It works well when I separate them by virtual desktops and then use Expose when I need to find a certain window of that application when I'm on that desktop.
However, at home, I am not running as many applications so Expose is sufficient enough to sort through the ope
Re:Versus Expose? (Score:5, Insightful)
Mail, in OS X, is even a third window gui(?), it isn't quite Aqua, and has noticable differences unlike any other application on OS X. Why? Who knows.
Apple has done great, but they have clearly ignored their own UI rules for the sake of eye candy at times.
Re:Versus Expose? (Score:3, Insightful)
HIG stands for Human Interface Guidelines. If they were "rules" they would be stupid, because there are no absolute rules to design, and pretending there are leads to bad designs. Without such guidelines, you'd end up with even worse designs. Look at Open Source GUIs (if you must).
Really, the HIG should be titled "Interface Design for People That Can't be Trusted to Design Decent Interfaces withou
Re:Versus Expose? (Score:3, Insightful)
Worse than Metal Finder? It's hard to imagine how they could have done a worse job without risking people storming One Infinite Loop and burning Jobs in effigy.
Re:Versus Expose? (Score:2)
Re:Versus Expose? (Score:1)
Re:Versus Expose? (Score:2)
Re:Versus Expose? (Score:1)
Re:Versus Expose? (Score:5, Informative)
iTunes, for example, and the whole brushed metal is basicly an excuse for making cool-looking apps. I like brushed metal, but apple has changed the HIG to morph around what they think looks best. There really should only be 1 window gui, aqua.
Brushed metal was originally applied to windows that simulated real world devices. iTunes=stereo. DVD Player=TV+DVD player. Later on it was applied to most of the interface and I for one am very glad. It provides better contrast with window contents. Finder windows have a default white background as do many text style documents like PDFs, Word files, etc. Most editors and terminal windows are best with white text on a black background for maximum contrast with minimal eyestrain. This means about half my windows are primarily white and half are primarily black. Now what color is halfway between white and black, does not grab the eye, and does not clash with any other color? Gee that would be only one...gray. Add a little texture and you get the brushed metal look. Apple designers probably realized why people like the brushed metal, but most people just like it because it looks good. It looks good because it is pretty much the best color you can use from a UI design perspective.
Re:Versus Expose? (Score:1)
Guys, it's worse than that: the "Pro" line of Apple Apps, eg Final Cut Pro, Shake, and Soundtrack, etc. have another gui theme (dark grey, and quite appealing, frankly). And GarageBand has an absolutely monstrous ui, totally unique.
And yes, this is important. If this keeps up, it could get to be like Windows around here in no time.
Re:Versus Expose? (Score:3, Interesting)
GNUMail? (Score:2)
Apple Mail isn't open-source, and Mail 2 uses more custom widgetry a
Re:Versus Expose? (Score:5, Insightful)
Expose is for switching between windows.
Virtual desktops are for logically grouping/partitioning windows (more typically, whole applications). Virtual desktops are, basically, a poor man's multi monitor setup.
The two solve different problems.
Re:Versus Expose? (Score:1)
> Virtual desktops are for logically grouping/partitioning windows (more typically, whole applications).
> Virtual desktops are, basically, a poor man's multi monitor setup.
> The two solve different problems.
But when you click on an application's icon in the Dock, it brings all the application's windows to the front. That's pretty much all the 'logical grouping' I need, and if I really need to see just that app, I can command-option-click the icon
Re:Versus Expose? (Score:1)
Lets say I'm developing three different projects at once. It would be really nice to show the editor, terminal, preview, etc. for each one quickly. In other words, I want three virtual desktops each with several open windows from a various applications.
Virtual desktops have their place.
Re:Versus Expose? (Score:3, Interesting)
I've been trying to take this line of thinking to it's logical conclusion, but I can't figure it out...
I always ignore the multiple desktop features and disable the pager in X11 window managers, does that make me a Mac zealot or a Windows zealot?
Conversely, I know people who religiously use multiple desktops in Windows who won't touch Linux with a 10 ft pole. Are they still a Linux zealot?
I'm so confused.
Re:Versus Expose? (Score:4, Insightful)
Wrong. Expose is nearly perfect for managing large groups of windows only in the case where you don't have multiple windows from an application being used in separate user tasks.
For example, suppose you are working on some graphics for your web site. You have a browser window opened on your site for reference, and other browser windows on other sites. You have Photoshop opened with various images being edited, so you have a bunch of Photoshop windows. You've got a mail application opened reading an email thread discussing the web site design.
Expose is perfect for managing your windows in that situation. All those windows belong to the same logical task ("update web graphics").
Expose even stays almost perfect if we throw in another logical task, if it doesn't use any of the same apps. For example, if you have a couple terminal windows opened to servers you are remotely admining, things are still fine.
However, when you get to multiple logical user tasks, with some apps being used for more than one of those, Expose becomes inadequate.
Consider this situation: you are working on three separate things. For thing A, you are using two terminal windows (say to ssh to two separate servers you admin), one spreadsheet window, and two browser windows.
For thing B, you are using one terminal window, two spreadsheet windows, and one word processor window.
For thing C, you are using one spreadsheet window, two word processor windows, and two browser windows.
Expose doesn't handle this very well at all. When used an all windows, it doesn't work well. Its "all windows" mode has windows from all three of your logical tasks, scattered all around, and it can be hard to tell which window is which (especially for terminals and spreadsheets).
What you need here is a way to hide or minimize a group of windows based on the user task they are associated with. Apple provides no mechanism for that. They provide a way to hide all the windows of a given app, but in my examples above, each app has windows associated with more than one user task.
What would be perfect would be Expose with multiple desktops. In my example above, you'd then do task A on one desktop, task B on another desktop, and task C on a third. On each desktop, you'd use Expose to manage the several windows that are on that desktop.
Basically, Expose, minimizing, and hiding only provide three levels of organization: by individual window, by application, or everything. What's missing is a way to manage all the widows of whatever the user is working on at the moment.
Re:Versus Expose? (Score:2)
Well, typically the window title is listed when you mouse over the scaled version. You can set Terminal.app to set the window title to the currently running command including arguments.
What would be perfect would be Expose with multiple desktops. In my example above, you'd then do task A on one desktop, task B on another desktop, and task C on a third. On each desktop, you'd use Expose to manage the several windows that are on that desktop.
Nothing stopping y
Re: "Nothing stopping you" (Score:1)
Re:Versus Expose? (Score:4, Interesting)
There's no such thing as a perfect user interface. Apple should give users as much flexibility as possible since everyone has different usage styles. There's an interesting article from a frustrated Mac user here [ex-parrot.com] (read the section titled "Switcher Stories").
Re:Versus Expose? (Score:3, Insightful)
Expose is probably all one really needs, yes. However,,virtual desktops are nice for development. I find it very convenient to have several documentation and reference windows open on one desktop, the test environment on another, and the actual code view on a third.
This means that it's much easier for me to quickly switch between, say, documentation and code view, while providing a cleaner workspace for each area. Is it necessity? No. It is, however, my taste. The OSX interface is very nice, and ver
Re:Versus Expose? (Score:3, Interesting)
Apple is composed of some very smart people, but Exposé is not at all the "perfect" way to handle large numbers of Windows. Having a second monitor - which MacOS supports very well - is usually better for users with no space or cost constraints.
Re:Versus Expose? (Score:2)
Re:Versus Expose? (Score:2)
So, if someone decides to have a "real discussion" with you, it will only show his side.
Brilliant.
Huh? (Score:5, Funny)
Sounds like something Microsoft would pull.
Oh, wait, this is Slashdot. I forgot.
Well, then Apple's just trying to protect its intellectual property. No harm.
Re:Huh? (Score:5, Interesting)
p
Re:Huh? (Score:1, Informative)
I doubt they will ever get around to documenting functions related to to switching "workspaces"/desktops unless Apple themselves chooses to ship a desktop switcher. Another example is putting items into the Menu Bar.
Re:Huh? (Score:5, Interesting)
Apple has two methods for putting items in the menu bar: The "right" way to do things, and the way that looks good to users.
The wrong way to do things -- and the way Apple uses for their menulets -- reserved involves injecting code into SystemUIServer's running space. If one menulet crashes, all menulets crash under this model. It is not surprising they want to discourage this mechanism for end-developer use.
Personally, I expect that sooner or later Apple will port the features of the "wrong" way to the right way, then upgrade thier menulets to use the documented API instead of the undocumented one. However, I expect there are much higher priorities.
Re:Huh? (Score:2, Informative)
Then again, these MAC things weird me out. I need to get a new Apple when MAC announces them.
Comment removed (Score:5, Informative)
You parrot nonsense without understanding... (Score:4, Informative)
Um, no Apple has no applications that use the virtual desktop APIs to compete unfairly with third party apps. In fact Apple has no competing application in this area at all, and two of the three applications that DO exist are open source.
Re:Huh? (Score:5, Insightful)
Remember there is a difference between hidden APIs and undocumented APIs. Are all the APIs in Linux documented?
Re:Huh? (Score:1, Funny)
I thought the big stink with Microsoft was that many OS services had 2 APIs, one they gave to third party developers, and one they used internally. One of them was tuned to run slower than the other... I just can't seem to remember right now which was which.
:^P
truss for MacOS X? (Score:4, Interesting)
OS X uses ktrace/kdump (Score:1, Informative)
(first window) ktrace -f less.ktrace less foo.txt
(second window) kdump -l -f less.ktrace
Only thing is that you have to run the first one first - if you run kdump first, then start ktracing the comand, ktrace will respect kdump's read lock on the file, and you won't see anything. Which means that there's that little time at the start, during which you're not seeing "live" syscalls, but catching up to the backlog...
Re:OS X uses ktrace/kdump (Score:2)
Re:truss for MacOS X? (Score:2)
Re:truss for MacOS X? (Score:2)
I'm happy without virtual desktops... (Score:3, Interesting)
Re:I'm happy without virtual desktops... (Score:1)
Re:I'm happy without virtual desktops... (Score:2)
Re:I'm happy without virtual desktops... (Score:2)
it used to be that my 2 monitor setup confused my coworkers, but you should see the bug-eyes i get when i switch from desktop to desktop - each looking different from the last. i've had peo
Re:I'm happy without virtual desktops... (Score:2)
Comment removed (Score:5, Informative)
Re:In a word, Don't. (Score:2)
Why? Because the people who actually understand systems, who are capable of reverse-engineering the O/S to get at the functionality they want, who write software that does new and amazing things... those people are my competition.
And while I believe competition is good for innovation, I also understand that a LACK of competiti
Re:In a word, Don't. (Score:2)
Why would anyone pay for a newsreader when Google Groups exists? I can't even imagine someone trying to set up a local NNTP server for anything.
Maybe not evil, but at least rude... (Score:3, Interesting)
Um, because Google could arbitrarily change Google Groups at any moment and remove features that you depend on?
Oh, wait, Doctor Evil, that already happened.
(yes, it's their code, their hardware, they have a right to do it, the point is they can and do, and that's one good reason to do Usenet yourself instead of depending on the kindness of strangers)
Comment removed (Score:4, Insightful)
Re:In a word, Don't. (Score:2)
Everything's relative. If you don't think it's small, maybe you're just not all that big. There's a lot of room to play in the OS X sandbox at first, but anyone worth his salt is constantly growing -- and will
Wow. Got ego? (Score:1)
The mac development community is small. We tend to notice who the major players are. You sir, are not one of those players.
Please take your, "l337er than thou" attitude back to your high school computer lab. You'll impress your peers with that kind of talk, but to pull it off here you'd better start naming programs that shock and delight.
"maybe your'e just not all that big" indeed. What trash. Sure, lots of cool programs are out that use undocumented APIs. But a
Re:Wow. Got ego? (Score:2)
> We tend to notice who the major players
> are. You sir, are not one of those players.
That's true. I'm a Windows guy. But the statement holds: if you're pushing the envelope, the documented API doesn't always reach where you need to go. I would expect it's the same for Macs; it used to be.
Apple and Microsoft have different ideas here. (Score:3, Insightful)
So what you're doing it coming from a Windows perspective and trying to make intelligent and topical assertions about the mac development platform.
This is a mistake. Disabuse yourself of such notions. They will get you nowhere. Apple has a very different policy towards its developers. They give as much power as they can do their developers, and the tools are so good that often applications do not need to go outside the standard APIs.
You might not believe me, because of the perspective you br
Re:Apple and Microsoft have different ideas here. (Score:2)
> from a Windows perspective and
> trying to make intelligent and
> topical assertions about the mac
> development platform.
Is this not a platform-independent question? Every O/S has undocumented APIs. They're undocumented for a reason, often because there are strange subtleties to their operation that are hard to understand. But they *exist* because someone needed to do something that they *couldn't* do under the documented API. Is the Mac somehow different? Why
Re:Apple and Microsoft have different ideas here. (Score:2)
No, because of how the companies handle it. MS will actively move to block you from using these APIs. I worked in a shop where I saw it done. They changed it on us by reversing the order of all parameters. That's adding insult to injury.
Also untrue.
Or are not done yet. Or didn't make it into
Re:Apple and Microsoft have different ideas here. (Score:2)
> the order of all parameters. That's
> adding insult to injury.
IIRC, I had this problem with VB routines: VB passed and handled parameters in the opposite order, so if a VB routine was rewritten in C++ (or vice-versa, if you were crazy) the parameter order would reverse. I also seem to recall Microsoft eventually bowed down to the de facto standard and changed VB to handle parameters in the same order as most other languages.
So I wouldn't attribute this to any
Re: (Score:2)
Re: (Score:2)
Re:In a word, Don't. (Score:2)
> supported API, help is available.
Why, yes, that WOULD be the difference between "supported" and "unsupported". Why didn't *I* think of that? It's so... obvious.
> I see some truly brilliant work on a
> daily basis, from developers who are
> sticking to published API
I'm not saying you can't be truly brilliant *unless* you use undocumented APIs; brilliance can be achieved with any tools you have. I'm just saying that *sometimes* the documented and suppo
If you're ready to go out and start innovating... (Score:2)
Get a second monitor. :D (Score:4, Insightful)
I seem to be the only OS X user that neither uses no likes Expose much. Part of it's the fact that a few apps I use bind to F11-13, though my BIG gripe is that F14-F16 ARE NOT MAPPING OPTIONS. Why can't I put the shortcuts for Expose onto the three keys that I NEVER use for ANYTHING?
That aside, I've noticed that virts are something the "I used to use freenix but the desktop sucks so I switched" crowd complains about, as well as sloppy focus and the fact that portables have one button trackpads (something of an annoyance if you're using X11 applications). As a whole, the freenix imports seem to be so used to doing things Their Way that the mere notion of a UNIX not having $feature makes them positively apoplectic.
Re:Get a second monitor. :D (Score:3, Interesting)
Re:Get a second monitor. :D (Score:3, Informative)
Re:Get a second monitor. :D (Score:1)
A couple more APIs Apple needs to add... (Score:4, Interesting)
What I want to know is why Apple hasn't put a general purpose input or hotkey manager in Preferences that would let you map any key combo to any hotkey-using application.
Plus, every second keyboard these days has half a dozen extra "Multimedia" or "Internet" buttons. Why can't I map those to actions?
Re:A couple more APIs Apple needs to add... (Score:2)
I have a Sun Ray USB board I'd LOVE to use with OS X - while it recognizes all of the keys that it should properly, there's the slight matter of the extra rows off to the left, the blank key, and other bits - there are keys on that board that the OS doesn't SEE that, if it was all HEY BUTTONS WHADDAYAWANNADOWITH
Re:A couple more APIs Apple needs to add... (Score:2)
Well, the problem is that the extra keys on a USB keyboard aren't keys,they're system control endpoints. But, yes, there are standards for all of them and they all have descriptors that describe them. It should still be able to put up a list of system control buttons and let me assign events to them.
And what I'
Undocumented? (Score:2)
But please, let's not complain about apple not documenting function calls.. apple is very clear about which APIs are official and supported.
Re:Which way today apple? (Score:5, Informative)
It's an undocumented, unsupported API; that's what the article is about. What broken APIs were you thinking of? Carbon took over most of the OS 9 ones (apart from some clearly documented exceptions).
If you had read the article you might actually have had something useful to say.
Re:Which way today apple? (Score:5, Insightful)
That's one of the many reasons why some APIs are left undocumented: because they are expected to be unstable.
Can't really blame Apple on this one. They didn't publish the API, and changed it in Tiger to a more flexible three-part solution. Eventually they may decide the design's a good one and publish the API.
Until then, use it at your own risk.
Re:Which way today apple? (Score:5, Insightful)
The APIs that DesktopManager uses were probably left undocumented precisely because Apple knew they were going to be subject to change.
Apple is good, and we are going to talk to talk about it.
Re:Which way today apple? (Score:1, Troll)
Unless the company is Microsoft - then it becomes evil.
The slight problem with this slightly simplistic argument is that the APIs are not undocumented. They are documented, otherwise the Apple developers would not be able to use them (and, after all, the article is about disassembling an Apple application to find out how they worked).
The APIs are just not documented publically - Sec
Re:Which way today apple? (Score:3)
Re:Which way today apple? (Score:2)
Like many things, it depends on the intention for keeping it secret. Sometimes it's because things aren't stable enough to document. Sometimes it's because your documentation team is understaffed and can't get to it yet. Sometimes it's an illegal abuse of monopoly to give your companion products an unfair advantage.
Appleista here! (Score:5, Insightful)
No doubt an Appleista will be along in due course to make clear the path to enlightenment.
You called?
The answer to your difficulty is obvious: follow the money. What strategic advantage does Apple gain by not publicly documenting these APIs? A corner on the windows management market? I'm sure is worth a whole lot because you can see how much Apple charges for it at the Apple Store. Oh, wait, you can't, cause there is no such separate competing product that Apple profits by leveraging their OS.
vs. Windows, where, let's see, they made a substantial amount of their $50 Billion on by selling Office--which required that they kill their competition in Office applications.
"But what of IE?", I hear you plaintively cry. "Doesn't Microsoft give that away for free?" Certainly. But their clear strategy was to use the product to own the web, and IE was the platform to do it.
When Apple sells a virtual desktop management tool, besides the OS, and doesn't document the APIs, you'd have an argument. For example, I imagine QT has access to things that WMP doesn't, but proving that is an exercise for the reader. As it is, you're just trolling. Speaking of simplistic arguments.
Re:Appleista here! (Score:2)
Re:Appleista here! (Score:2)
Apple started to publish information about Core Image/Video "before" Motion shipped.
Comment removed (Score:5, Informative)
Re:Which way today apple? (Score:3, Insightful)
Re:Which way today apple? (Score:1)
Re:Which way today apple? (Score:2)
Trolling - nope. But it seems that not only is anything slightly critical of Apple seen as a troll in these here parts, but even a pointing out of the double standards that apply when judging Apple is seen as a troll.
This is slashdot - a feverent member of the open/free software world. If anybody suggested that any other vendor* should be able to keep APIs private a
Re:Which way today apple? (Score:2)
* The exception is, of course, google - they also get a free pass when indulging in questionable behaviour. It seems that there is a lot of "the enemy of my enemy is my friend" going on, with MS being the enemy. I'm old enough to remember when MS was in google's position, and IBM was the leviathan, crushing all before it. And I'm astute enough to realise the there will
Re:Which way today apple? (Score:2)
Re:Which way today apple? (Score:2)
Re:Which way today apple? (Score:3, Insightful)
they're just some that some committee or workgroup decided that they shouldn't be used.. all closed os's have those.. hell, I'm frustrated at the moment at symbian because of precisely this(well, nokia to be more specific but anyways..). it bugs the hell out of me that there's a bunch of things in there that aren't open.. but that are in and usabl
Re:Which way today apple? (Score:3, Interesting)
In Mac OS X, for example, the CGS SPIs provide functionality used by the Carbon, Cocoa, and Java environments. (You didn't really think Carbon and Cocoa somehow each implemented their own window systems, did you?) The SPIs are private because, simply, the functionality they provide is pretty raw, low level stuff. U
Re: (Score:3, Insightful)
Re:Which way today apple? (Score:2, Insightful)
You're confused, oh trollish one. (Score:5, Funny)
Re:You're confused, oh trollish one. (Score:1)
Re:How long before ... (Score:5, Informative)
Re:How long before ... (Score:2, Informative)
Reverse Engineering for interoperability is explicitly permitted.