File: binary_patch.pl

package info (click to toggle)
whitedune 0.30.10-2.2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 42,004 kB
  • sloc: cpp: 116,017; ansic: 79,688; java: 20,101; sh: 3,248; yacc: 2,902; makefile: 1,717; lex: 848; awk: 363; perl: 270; objc: 143; lisp: 112; python: 22
file content (24 lines) | stat: -rw-r--r-- 659 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# repair executables created by xcode
# this executables include a static path e.g.

# This file is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.

$filename=$ARGV[0]; 
$from=$ARGV[1];
$to=$ARGV[2];
undef $/;
if (length($to)>length($from)) {
    print STDERR "not enough space in binary, binary patch already applied ?\n";
    exit(0);
}
for ($i=0;i<length($from)-length($to);$i++) {
    $to=$to."\0"
}
open(EXE,"+<$filename") or die "can not open $filename: $!";
binmode(EXE);
$content=<EXE>;
$content=~s/$from/$to/;
seek(EXE, 0, 0);
print EXE $content or die "can not write content";
close(EXE);