Panic! At The Kernel.
 
    The Panic:
 
Armed with the latest and greatest Mac OS X Kernel, I decided to change my “Kernel Panic” screen to the infamous windows “Blue Screen Of Death”.
 
I now have the first mac capable of blue-screening. Since I’m such a nice guy I thought I’d share my wonder kernel and the means to trigger a panic.
 
Briefly, I loaded my “Blue Screen” image into a 17,000 line c structure(Not by hand). And then altered the panic code [osfmk/console/panic_dialog.c] to color anything not covered by the 1024X768 image with the matching 0x000001AB blue.  Then I recompiled and installed my new kernel. Thats it! The instructions that follow cover the installation of my premade kernel.
 
    A moment to consider safety:
 
Before diving into the instructions, let us take a second to emphasize that safety is crucial. The process involves swapping out the OS X kernel, its core. Keep in mind that swapping a kernel is significant regardless of the precautions that are made. Be careful and assume that you will have to do step 2 “when” it doesn’t boot with the new kernel. (Step 2 involves reseting to the original kernel). Be cautious and you shouldn't have any problems.
 
Many would consider me unwise to give information on altering the OS X kernel. However, I looked at this whole process as a learning experience and thought others might benefit from it. My goal is to entertain and to spark interest in the Mac OS X kernel.
 
If your computer does combust, trigger a nuclear reaction, or in any way die it is on you.
 
    Lets do it!:
 
1. DO NOT ATTEMPT on any other system than a PPC mac with OS X 10.4.6 installed. This will not work on 10.4.7.
 
2. If at any point something goes wrong... Reboot your system and hold down apple-option-p-r until you hear a second boot chime. This will reset your systems pram. Write that key combo down on paper. I’m serious.
 
3. Download and run “Panic! At The Kernel” after reading the “Triggering a kernel panic” section below.
 
4. Download my custom blue screen kernel (mach_kernel.bsod) and move it to the root of your boot drive.
 
5. Open a Terminal.app window and type, “sudo nvram boot-file=`nvram boot-device | awk -F , '{print $1}' | awk '{print $2}'`,mach_kernel.bsod && sudo chown root /mach_kernel.bsod && sudo chgrp wheel /mach_kernel.bsod”, and then enter your admin password when prompted. (This step sets the proper file permissions for the kernel and tells the hardware to boot from the new kernel.)
 
6. Reboot. If No boot, do step two to reset to your old kernel.
 
7. You are done. Run “Panic! At The Kernel” to see your new panic screen.
 
    Triggering a kernel panic:
 
In order to see the blue screen kernel in action it is necessary to trigger a kernel panic. In the spirit of OS X, I made a nice cocoa application that simulates a kernel panic with the touch of a button. The panic is real, but no restart is necessary. Just use any expose function key to clear the screen after you finish enjoying the lovely panic screen.
 
 
    Thanks Amit Singh:
 
It was my first time looking at the OS X kernel since Amit Singh’s “Expert Challenge” in 2005. I was inspired after reading his recently published “Mac OS X Internals” book to re-enter the OS X kernel and play around. The book is fascinating.
 
FYI: Amit Singh is in no way responsible for anything on this page. However, some code was shamelessly stolen from his book. His book is pretty sweet.
 
   Feedback or Corrections:
 
I’d love to know what you think of this little bit on kernel hacking.
 
Feel free to send me an email david@davidhodge.net
 
~David Hodge
Thursday, July 20, 2006