Skip to content

Instantly share code, notes, and snippets.

@gpadd
Forked from 9ary/fix_telegram.md
Last active January 12, 2017 23:50
Show Gist options
  • Save gpadd/80258e6723711db3ebc1545061bfa7f3 to your computer and use it in GitHub Desktop.
Save gpadd/80258e6723711db3ebc1545061bfa7f3 to your computer and use it in GitHub Desktop.
How to fix the really really round telegram bubbles and avatars and << >> -- stuff

EDIT: Doesn't work for newer version of telegram. (yet)

Credits goes to serveral people:

MrMetric - telegramdesktop/tdesktop#2235 (comment)

Afogal - https://gist.github.com/afogal/5ec200f46856b1b776a9a91601c00b87

SijmenSchoon - https://gist.github.com/SijmenSchoon/a24b453f001549bb14562de5078ae1bc

Streetwalrus - https://gist.github.com/Streetwalrus/bb2091bc5761a71e3b7c85d4e4a1ad99

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

#/bin/bash

cp Telegram Telegram_backup

gdb --write ./Telegram << EOF

tbreak _ZN3App9initMediaEv
set {char}_ZN3App9msgRadiusEv=0xB8
set {int}(_ZN3App9msgRadiusEv+1)=3
set {char}(_ZN3App9msgRadiusEv+5)=0xC3

set {char}_Z25replaceStringWithEntitiesRK13QLatin1String5QCharR7QStringP5QListI12EntityInTextEb = 0xC3

set {char [5]}_ZNK5Image10pixCircledEii = { 0x89, 0xD1, 0x89, 0xF2, 0xBE }
set {int}(_ZNK5Image10pixCircledEii+5) = 0x02
set {char}(_ZNK5Image10pixCircledEii+9) = 0xE9
set {int}(_ZNK5Image10pixCircledEii+10) = (_ZNK5Image10pixRoundedE16ImageRoundRadiusii) - (_ZNK5Image10pixCircledEii + 14)
EOF

This replaces the start of App::msgRadius with

mov $0x3, %eax
retq

In C++, that is return 3;

Explanation: 0xB8 means mov a number to %eax, 3 is the border radius, and 0xC3 is retq. The first instruction in replaceStringWithEntities gets replacemed by a retq, bypassing it.

@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)

@gpadd
Copy link
Author

gpadd commented Dec 15, 2016

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

There, credited.
I know SijmenSchoon and Streetwalrus, seems they didn't know this either.

@MrMetric
Copy link

Thanks. (all must love me for my work! :^D)

I didn't know gdb can write modifications. That's pretty neat.

@MrMetric
Copy link

EDIT: Doesn't work for newer version of telegram. (yet)

Have a look at my fork

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