1 Star 0 Fork 8

陈亚强/sox

forked from src-openEuler/sox 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
binpatch.py 1.10 KB
一键复制 编辑 原始数据 按行查看 历史
Grooooot 提交于 2019-12-17 16:13 . package init
import sys
OLD_PATH = b"/usr/lib/sox\x00"
NEW_PATH = b"/var/tmp/sox\x00"
OUT_PATH = "/var/tmp/sox\n"
OLD64_PATH = b"/usr/lib64/sox\x00"
NEW64_PATH = b"/var/tmp/l/sox\x00"
OUT64_PATH = "/var/tmp/l/sox\n"
assert len(OLD_PATH) == len(NEW_PATH)
assert len(OLD64_PATH) == len(NEW64_PATH)
argv = sys.argv
wout = sys.stdout.write
werr = sys.stderr.write
bye = sys.exit
def p(m, *args):
werr(m % args)
def usage():
p("Usage: %s <path to libsox>\n", argv[0])
def error(et):
def ef():
p("%s: %r cannot be binary patched [%s]\n", argv[0], argv[1], et)
return ef
def check(c, p):
if not c:
p()
bye(1)
check(len(argv) == 2, usage)
s = b""
o = ""
with open(argv[1], 'rb') as f:
s = f.read()
if s.count(OLD_PATH) == 1:
check(s.count(OLD64_PATH) == 0, error("OLD64_PATH"))
s = s.replace(OLD_PATH, NEW_PATH)
o = OUT_PATH
elif s.count(OLD64_PATH) == 1:
check(s.count(OLD_PATH) == 0, error("OLD_PATH"))
s = s.replace(OLD64_PATH, NEW64_PATH)
o = OUT64_PATH
else:
check(False, error("OLD_PATH/OLD64_PATH"))
with open(argv[1], 'wb') as f:
f.write(s)
wout(o)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yaqiangchen/sox.git
git@gitee.com:yaqiangchen/sox.git
yaqiangchen
sox
sox
master

搜索帮助