Skip to content

Instantly share code, notes, and snippets.

@9ary
Forked from vijfhoek/fix_telegram.md
Last active January 2, 2018 20:47
Show Gist options
  • Save 9ary/bb2091bc5761a71e3b7c85d4e4a1ad99 to your computer and use it in GitHub Desktop.
Save 9ary/bb2091bc5761a71e3b7c85d4e4a1ad99 to your computer and use it in GitHub Desktop.
How to fix the really really round telegram avatars and << >> -- stuff

Note: I won't update this gist anymore, please see my dotfiles repo for future updates.

Here is a bash/GDB script to fix it (tested on GNU/Linux only):

#!/bin/bash

gdb /usr/bin/telegram-desktop << EOF
tbreak _ZN3App9initMediaEv
commands
    set {char}_ZN3App9msgRadiusEv=0xB8
    set {int}(_ZN3App9msgRadiusEv+1)=3
    set {char}(_ZN3App9msgRadiusEv+5)=0xC3

    set {char}_ZN13TextUtilities21ReplaceStringWithCharERK13QLatin1String5QCharR16TextWithEntitiesb = 0xC3

    set {char}(_ZNK5Image10pixCircledEii+0) = 0x41
    set {char}(_ZNK5Image10pixCircledEii+1) = 0xB8
    set {int}(_ZNK5Image10pixCircledEii+2) = 0x0F
    set {char}(_ZNK5Image10pixCircledEii+6) = 0xB9
    set {int}(_ZNK5Image10pixCircledEii+7) = 0x01
    set {char}(_ZNK5Image10pixCircledEii+11) = 0xE9
    set {int}(_ZNK5Image10pixCircledEii+12) = (_ZNK5Image10pixRoundedEii16ImageRoundRadiusN4base5flagsI16ImageRoundCornerEE) - (_ZNK5Image10pixCircledEii + 16)
end
run
detach
quit
EOF

Just run it instead of the usual Telegram binary and you're set.

This replaces the start of App::msgRadius with

mov $0x3, %eax
retq

In C++, that is return 3;

The first instruction in replaceStringWithEntities gets replacemed by a retq, bypassing it.
pixCircled's beginning is replaced with loading extra arguments (0x0F for all corners rounded and 0x01 for big corner radius) and a jump to pixRounded.

@MrMetric
Copy link

MrMetric commented Nov 7, 2016

I'd like to note that this is forked (uncredited) from something I made: telegramdesktop/tdesktop#2235 (comment)

@9ary
Copy link
Author

9ary commented Nov 7, 2016

Thanks for letting me know, I wasn't aware of this at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment