FORUMS
Remove All Ads from XDA

[APP][4.0+] Logo Me

715 posts
Thanks Meter: 1,726
 
By Ezekeel, Retired Recognized Developer on 8th June 2012, 01:21 AM
Post Reply Email Thread
7th September 2016, 04:38 PM |#111  
osm0sis's Avatar
Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 29,909
 
Donate to Me
More
Quote:
Originally Posted by osm0sis

Alright. Vanity got the best of me; I caved and bought this abandonware to find out how it ticks so I could make my bootloader pretty.

Logo Me dumps sbl (part of the bootloader), and only uses known bootloaders because the offset changed with each successive bootloader.

I've just figured it all out and I'm not sure why @Ezekeel didn't come up with a more elegant solution, since just like with the awesome imgdata work by @bitdomo, sbl images are all in a particular order, and, searching for them we can learn their offsets, and knowing their sizes we can actually change them quite easily.

Here's what I've got so far:
/dev/block/mmcblk0p2
/dev/block/platform/omap/omap_hsmmc.0/by-name/sbl

dd if=/dev/block/platform/omap/omap_hsmmc.0/by-name/sbl of=/sdcard/sbl.img
dd if=/sdcard/sbl.img of=/dev/block/platform/omap/omap_hsmmc.0/by-name/sbl

JPEG header magic:
FF D8 FF E0 00 10 4A 46 49 46
ÿØÿà..JFIF

Different offsets with each bootloader since bootloader=gpt+xloader+sbl:

grep -obUaP "\x00\x10\x4A\x46\x49\x46" sbl.img # unfortunately doesn't work on Android grep
-4 to get to beginning of JPEG magic

KK15 (my favorite due to the better color calibration)
logo=840376; #11
lock=927932; #16

LC03 (last before the 2 second wait was added)
logo=840988; #11
lock=928544; #16

MD04
logo=841456; #11
lock=929012; #16

logo specifications:
#11 image in sbl
720 x 595 pixels max
12126 bytes max

lock specifications:
#16 image in sbl
720 x 100 pixels max
2215 bytes max

00 padding to full byte length (if necessary)
FF to 4 trailing bytes


I used Photoshop to reduce the size of the latest Google logo and lock icon down to the dimensions of the GN versions, then TinyJPG.com to shrink them to (less than) the appropriate file size maximums. The FF trailing 4 bytes is something Logo Me does that it's unclear why, since there is usually other data there, but it works either way.

Also, important to note that flashing a bootloader.img will of course reset the changes, and that since bootloader.img files reset the GPT (partition table) any changes made by something like @Lanchon's brilliant RePIT will get reset as well. Logo Me especially doesn't cooperate with that, since it looks for a bootloader checksum which is of course affected by the changed GPT.

Anyway I'll probably turn this into a script soon enough, and provided the supplied jpg files are small enough it should be able to patch the sbl partition on-the-fly, and that should be friendly for repartitioned devices as well.

@bamtan2, @MWisBest, @Ziyan, @aosp, @bsmitty83 - I'll mention you since this thread is lost to the GN community way out here in the boonies of Paid Software.

Quote:
Originally Posted by bamtan2

Sweet work!

Maybe now you get to create an official GN forum thread

Haha maybe? It's been a while since I had something that didn't fall better under my Odds and Ends.

As it is now, those osmod sbl dumps can be flashed from sdcard using dd to get the new Google/lock images into the corresponding bootloader (so flash that first if you want to switch), including the MD04 bootloader Logo Me doesn't support, and it works on repartitioned devices, so my goal is pretty much done.

So, for example, if you are on bootloader KK15, the root command for flashing my KK15 sbl dump osmod would be:
Code:
dd if=/sdcard/kk15-sbl-osmod.img of=/dev/block/platform/omap/omap_hsmmc.0/by-name/sbl;
But I'll post my script once it's done and then people can do whatever they want with their current bootloader without having to mess with dd directly. I'll probably take down the pre-modded dumps at that point.

I'll mention a few more.
@massoudsh @musical_chairs @zzpianoman @Fenix46 @rahimali @nikodr @rajputrajat @benkxda

Edit: Script now posted below!
The Following 4 Users Say Thank You to osm0sis For This Useful Post: [ View ]
 
 
8th September 2016, 11:19 PM |#112  
siealex's Avatar
Senior Member
Flag Kharkov
Thanks Meter: 502
 
More
The google logo is too small, is it possible to make it 50% larger?
8th September 2016, 11:37 PM |#113  
osm0sis's Avatar
Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 29,909
 
Donate to Me
More
Quote:
Originally Posted by siealex

The google logo is too small, is it possible to make it 50% larger?

It's literally the same size as the old one. You can do whatever you want with a hex editor or once I'm done my script though.
10th September 2016, 06:43 PM |#114  
massoudsh's Avatar
Senior Member
Flag Tehran
Thanks Meter: 55
 
More
Quote:
Originally Posted by osm0sis

Haha maybe? It's been a while since I had something that didn't fall better under my Odds and Ends.

As it is now, those osmod sbl dumps can be flashed from sdcard using dd to get the new Google/lock images into the corresponding bootloader (so flash that first if you want to switch), including the MD04 bootloader Logo Me doesn't support, and it works on repartitioned devices, so my goal is pretty much done.

So, for example, if you are on bootloader KK15, the root command for flashing my KK15 sbl dump osmod would be:

Code:
dd if=/sdcard/kk15-sbl-osmod.img of=/dev/block/platform/omap/omap_hsmmc.0/by-name/sbl;
I'll mention a few more.
@massoudsh @musical_chairs @zzpianoman @Fenix46 @rahimali @nikodr @rajputrajat @benkxda

I can't install this app in my country because Google does not allow me to buy it, I'm very sorry
11th September 2016, 05:05 AM |#115  
osm0sis's Avatar
Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 29,909
 
Donate to Me
More
Quote:
Originally Posted by massoudsh

I can't install this app in my country because Google does not allow me to buy it, I'm very sorry

Huh @massoudsh?

The whole point of my post is to make this abandoned closed source app useless. Just follow my instructions and use dd from a root prompt to flash the sbl osmod for your bootloader to get the updated logos. No app required and completely free, as a mod like this should be.

He did a great job figuring the basic method out in the first place, but don't give @Ezekeel any more money for something he hasn't even updated to support the final md04 bootloader. To be honest, I got a refund as soon as I reverse engineered it. Of course, if he wants to come back and update it I'll back off and carry my work on in my Odds and Ends thread.
The Following User Says Thank You to osm0sis For This Useful Post: [ View ]
22nd September 2016, 10:49 PM |#116  
osm0sis's Avatar
Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 29,909
 
Donate to Me
More
Here we are!

/su/bin/logohack.sh:
Code:
#!/system/bin/sh
# GN Bootloader Image Replacement Hack Script
# osm0sis @ xda-developers
#
# Original version-locked method by Ezekeel @ xda-developers

# ensure we use a known busybox since dd, ob, strings, and truncate need to work as expected
bb=busybox;
bbver=$($bb 2>/dev/null | grep 'BusyBox v' | cut -d ' ' -f 2);
bbrev=$(echo $bbver | cut -c 2-7 | tr -d '.');
bbvar=$(echo $bbver | cut -d - -f 2);
if [ ! "$($bb 2>/dev/null)" -o "$bbrev" -lt 1251 ]; then
  echo "Busybox 1.25.1-osm0sis (or newer) installation required!";
  return 1;
elif [ "$bbrev" -lt 1260 -a "$bbvar" != "osm0sis" ]; then
  echo "Busybox 1.25.1-osm0sis (or newer) installation required!";
  return 1;
fi;

# sbl bootloader partition contains the images
block=/dev/block/platform/omap/omap_hsmmc.0/by-name/sbl;
if [ ! -e "$block" ]; then
  echo "Partition not found!";
  return 1;
fi;

# loop through commandline arguments
case $1 in
  --help|"")
    echo "usage: logohack.sh [--logo [logo.jpg]] [--lock [lock.jpg]]";
    return 1;
  ;;
  --logo|--lock)
    echo -e "\nGN Bootloader Image Replacement Hack Script";
    echo "by osm0sis @ xda-developers";
  ;;
esac;
until [ ! "$1" ]; do
  # image order has logo at #11, and lock at #16, stored as JPEG
  case $1 in
    --logo) num=11; len=12126;;
    --lock) num=16; len=2215;;
    *) echo "Invalid \"$1\" option!"; return 1;;
  esac;
  type=$(echo $1 | $bb cut -c 3-);

  # search for JFIF magic and -6 to get to beginning of the image
  echo -e "\nSearching for \"$type\" offset ...";
  count=1;
  for i in $($bb strings -t d $block | $bb grep 'JFIF$' | $bb tr -d ' ' | $bb cut -d J -f 1); do
    test "$count" == "$num" && offset=$((i - 6));
    count=$((count + 1));
  done;
  if [ "$offset" ]; then
    echo "Found offset: $offset";
  else
    echo "Offset not found!";
    return 1;
  fi;

  case $2 in
    --logo|--lock|"")
      # if no filename is specified, dump the requested current image
      echo -e "\nDumping $type to \"/sdcard/$type.jpg\" ...";
      $bb dd ibs=1 obs=1 count=$len skip=$offset if=$block of=/sdcard/$type.jpg;

      # trim off trailing zeros from dump
      echo -e "\nTrimming \"/sdcard/$type.jpg\" ...";
      trim=$($bb od -A d -t x8 /sdcard/$type.jpg | $bb tail -n 4 | $bb head -n 2 | $bb grep -v '*');
      if [ "$(echo $trim | $bb awk '{ print $2 $3 }')" == "00000000000000000000000000000000" ]; then
        $bb truncate -s "$(echo $trim | $bb awk '{ print $1 }')" /sdcard/$type.jpg;
      elif [ "$(echo $trim | $bb awk '{ print $5 $6 }')" == "00000000000000000000000000000000" ]; then
        $bb truncate -s "$(echo $trim | $bb awk '{ print $4 }')" /sdcard/$type.jpg;
      fi;
      shift;
    ;;
    *)
      # if there is a file specified (and it meets the requirements), write it to sbl
      if [ ! -f "$2" ]; then
        echo "File \"$2\" not found!";
      else
        # ensure file will fit in the target image section
        if [ "$($bb wc -c < "$2")" -gt "$len" ]; then
          echo "File \"$2\" is too large; >$len bytes!";
        else
          # get short name of bootloader for backup name
          blname=$(getprop ro.boot.bootloader | tr '[A-Z]' '[a-z]' | cut -c 6-);

          # backup current sbl before making changes
          backup=/sdcard/sbl-$blname-$(date +%Y-%m-%d_%H%M%S).img;
          echo -e "\nBacking up \"$block\" to \"$backup\" ...";
          $bb dd if=$block of=$backup;

          # zero the section prior to writing new image
          echo -e "\nZeroing \"$type\" image area of sbl partition ...";
          $bb dd ibs=1 obs=1 count=$len seek=$offset conv=notrunc if=/dev/zero of=$block;

          # write the image to sbl
          echo -e "\nWriting \"$2\" to sbl partition ...";
          $bb dd ibs=1 obs=1 count=$len seek=$offset conv=notrunc if=$2 of=$block;

          # write FF to the 4 trailing bytes
          echo -ne "\xFF\xFF\xFF\xFF" | dd obs=1 count=4 seek=$((offset + len)) of=$block;
        fi;
      fi;
      shift 2;
    ;;
  esac;
done;
echo -e "\nDone!";
return 0;
There were some crazy complications with the strings command, and I discovered that none currently worked as advertisted; the toybox version has all the offsets wrong by 1 byte, and busybox outputs all the offsets in octal despite stating they're in decimal in the help. This is present in busybox pretty much forever as far as I can tell, and is present in Stericson (1.24.2-Stericson uClibc), and TWRP/Omni (1.22.1-jb bionic), so basically everywhere.

Long story short I fixed the busybox bug and so the script can only be used with my latest patched BusyBox (1.25.0-osm0sis or later). It's available in my Odds and Ends thread.

Attached is the script, and the images I prepped (with an editor to resize and TinyJPG.com to optimize) to update the bootloader to the current Google look.

Rename the script to logohack.sh and place it in /su/bin/ or /system/bin/ with root:root ownership and 755 executable permissions. The arguments can be supplied in any combination; without a filename they dump, and with they write. You can just type "logohack.sh" to get started though.

Edit: Just bumped the required busybox version to 1.25.1-osm0sis since I've applied some patches from the master branch (added after my prodding ) that give proper strings -t radix support to get the decimal offsets, and the script has been updated accordingly. I've also lifted the restriction of using my variant for busybox 1.26.0 and above since it should have the required changes when it gets released as well.

I'm going to unsubscribe from this thread. If anyone needs help with my script, @ mention me or post in my Odds and Ends thread.


Click image for larger version

Name:	logo.jpg
Views:	94
Size:	9.1 KB
ID:	3883401Name:  lock.jpg
Views: 834
Size:  1.6 KB
Attached Files
File Type: txt logohack.sh.txt - [Click for QR Code] (3.9 KB, 94 views)
The Following 3 Users Say Thank You to osm0sis For This Useful Post: [ View ]
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes