upgpkg: discord-electron 0.0.59-2: update krisp patcher

* Fix segfault after patching Krisp binary
This commit is contained in:
Manuel 2024-07-14 23:57:09 +02:00
parent a19f7a248f
commit 10a0cea6bf
Signed by: Manuel
GPG key ID: 4085037435E1F07A
3 changed files with 8 additions and 6 deletions

View file

@ -1,7 +1,7 @@
pkgbase = discord-electron
pkgdesc = Discord using system provided electron (v31) for increased security and performance
pkgver = 0.0.59
pkgrel = 1
pkgrel = 2
url = https://discord.com
install = discord-electron.install
arch = x86_64
@ -23,6 +23,6 @@ pkgbase = discord-electron
source = krisp-patcher.py
sha512sums = 43a911d03d62f9d73e8058771b59d148500fc48a0cf51be90899f4927979034d73326086084d342b4885ebe74560b4b99598d8514be9a51f00a9dd2010c74132
sha512sums = 4497ff3df7e2c1e72eea09d6f36a80cabeabfd43bb03b0966795d45e10a02ea6b4c10407661092d057435e0d69d75e958a3dbb1dc5971a215ce09547ec56f666
sha512sums = 3c1021592fa856f3561072c76b5ee0b5a34a53bc230336e6d36827efb4866c9d801ef7abb24650d3a7210c61dd57f35e2812ae89226fc157cc8d9ffce032155f
sha512sums = ac1212b09c3c1e7af3f93294d799765a0547f20a8373bea0ecb1a3e2bcb165488eb1412141c4e577d53ae87122646b12b9339b0a3f8e6817c3865fbb3f642938
pkgname = discord-electron

View file

@ -1,7 +1,7 @@
pkgname=discord-electron
_pkgname=discord
pkgver=0.0.59
pkgrel=1
pkgrel=2
_electronver=31
_electronname="electron${_electronver}"
pkgdesc="Discord using system provided electron (v${_electronver}) for increased security and performance"
@ -26,7 +26,7 @@ source=("https://dl.discordapp.net/apps/linux/${pkgver}/${_pkgname}-${pkgver}.ta
'krisp-patcher.py') # original: https://github.com/sersorrel/sys/blob/main/hm/discord/krisp-patcher.py
sha512sums=('43a911d03d62f9d73e8058771b59d148500fc48a0cf51be90899f4927979034d73326086084d342b4885ebe74560b4b99598d8514be9a51f00a9dd2010c74132'
'4497ff3df7e2c1e72eea09d6f36a80cabeabfd43bb03b0966795d45e10a02ea6b4c10407661092d057435e0d69d75e958a3dbb1dc5971a215ce09547ec56f666'
'3c1021592fa856f3561072c76b5ee0b5a34a53bc230336e6d36827efb4866c9d801ef7abb24650d3a7210c61dd57f35e2812ae89226fc157cc8d9ffce032155f')
'ac1212b09c3c1e7af3f93294d799765a0547f20a8373bea0ecb1a3e2bcb165488eb1412141c4e577d53ae87122646b12b9339b0a3f8e6817c3865fbb3f642938')
prepare() {
# prepare launcher script

View file

@ -41,9 +41,10 @@ found_issigned_by_discord_test = False
found_issigned_by_discord_je = False
found_already_patched = False
je_location = None
je_size = 0
# We are looking for a call to IsSignedByDiscord, followed by a test, followed by a je.
# Then we patch the je into a two byte nop.
# Then we replace the je with nops.
md = Cs(CS_ARCH_X86, CS_MODE_64)
md.detail = True
@ -61,6 +62,7 @@ for i in md.disasm(krisp_initialize, krisp_initialize_address):
if found_issigned_by_discord_test:
found_issigned_by_discord_je = True
je_location = i.address
je_size = len(i.bytes)
break
if i.id == X86_INS_NOP:
@ -74,7 +76,7 @@ if je_location:
shutil.copyfile(executable, executable + ".orig")
f = open(executable, 'rb+')
f.seek(je_location - address_to_file)
f.write(b'\x66\x90') # Two byte NOP
f.write(b'\x90' * je_size) # je can be larger than 2 bytes given a large enough displacement :(
f.close()
else:
if found_already_patched: