views:

17

answers:

1

I need to make a kext which does a very simple function. Whenever a key combination is pressed the kext should kill a process which happens to be "WindowServer"

It has to be a kext due to the nature of the problem. It has to be independent from system's UI so if it hangs up, I can press this combination and restart it.

Can someone provide a starting point? Like how to make a key handler?

A: 

I'm not convinced it needs to be a kext. An application that asked you to authenticate for admin powers and then used them (like sudo) to run a command-line tool that killed the WindowServer should do the job just as well. As a bonus, the authentication check prior to running the tool would double as a confirmation dialog.

Peter Hosey
Mac OS X is not a great system when it comes to GUI hanging up. On linux you can use a hotkey combo to restart X11. On Mac OS X there is no such key combo, so I wanted to make it. Your idea has a fatal flaw - when UI hangs up, you can't rely on Cocoa methods of getting things done. Instead you have to fallback to low level things. Anyway, I figured out how to make this kext using a hack which hooks up the HID kext and intercepts keyboard events.
Nick Brooks