[X 2014 Android Development] mikeoswego:
Install the CF.lumen app from the Play Store (or the xda thread) but do not open it yet.

Using ADB, enter shell (or use terminal) on the phone and then enter the following:

su
mkdir /data/recovery
rm -rf /cache/*
ln -s /data/recovery /cache/recovery

Now, open the CF.lumen app and have it install the driver using the recovery method. The phone will reboot into recovery but we have temporarily broken recovery with the previous steps. Use the volume down/power button combo until you can get into the boot-loader menu and then select normal powerup. When your phone boots up, ignore any message from CF.lumen. Use your root file explorer to copy the following files from /data/recovery to /sdcard/Download for access via USB (or whatever means of file transfer) to your development workstation:

# surfaceflinger, surfaceflinger_shell, surfaceflinger_cflumen, libcflumen.so

# Or from shell:

su
cp /data/recovery/surfaceflinger /sdcard/Download
cp /data/recovery/surfaceflinger_shell /sdcard/Download
cp /data/recovery/surfaceflinger_cflumen /sdcard/Download
cp /data/recovery/libcflumen.so /sdcard/Download

Clear /cache again using your root file explorer or 'rm -rf /cache/*' in shell to get rid of the symlink for /cache/recovery created earlier. A normal reboot will restore the file structure in /cache (Flashing with mofo also wipes the cache out.)

With the above files copied to your development workstation, these instructions presume the image for mofo is mounted to /system:

# Make backup of original surfaceflinger
# surfaceflinger_cflumen appears to be a backup as well but better
# safe then sorry and there is loads of room in the rom

sudo cp -a /system/bin/surfaceflinger /system/bin/surfaceflinger_original

# Copy files to image
sudo cp surfaceflinger /system/bin
sudo cp surfaceflinger_shell /system/bin
sudo cp surfaceflinger_cflumen /system/bin
sudo cp libcflumen.so /system/lib

# Set security contexts
sudo chcon u:object_r:system_file:s0 /system/bin/surfaceflinger
sudo chcon u:object_r:system_file:s0 /system/bin/surfaceflinger_shell
sudo chcon u:object_r:surfaceflinger_exec:s0 /system/bin/surfaceflinger_cflumen
sudo chcon u:object_r:system_file:s0 /system/lib/libcflumen.so

# Set ownership
sudo chown root:2000 /system/bin/surfaceflinger
sudo chown root:2000 /system/bin/surfaceflinger_shell
sudo chown root:2000 /system/bin/surfaceflinger_cflumen
sudo chown root:root /system/lib/libcflumen.so

# Set permissions
sudo chmod 755 /system/bin/surfaceflinger
sudo chmod 755 /system/bin/surfaceflinger_shell
sudo chmod 755 /system/bin/surfaceflinger_cflumen
sudo chmod 644 /system/lib/libcflumen.so

Optionally, to make CF.lumen a systemapp, with the CF.lumen /data/app/eu.chainfire.cflumen-1 directory copied from the phone to your dev box:

# Rename directory as copied from /data/app
mv eu.chainfire.cflumen-1 CF.lumen

# Copy directory, set perms, etc.
sudo cp -R CF.lumen /system/app
sudo chcon -R u:object_r:system_file:s0 /system/app/CF.lumen
sudo chown -R root:root /system/app/CF.lumen
sudo chmod 755 /system/app/CF.lumen
sudo chmod 755 /system/app/CF.lumen/lib
sudo chmod 755 /system/app/CF.lumen/lib/arm
sudo chmod 644 /system/app/CF.lumen/*.apk
sudo chmod 644 /system/app/CF.lumen/lib/arm/*.so