This commit is contained in:
+33
-34
@@ -5,44 +5,43 @@
|
||||
}
|
||||
"""
|
||||
|
||||
priority = 0
|
||||
|
||||
# imports
|
||||
__author__ = "Kentai Radiquum <radiquum@gmail.com>"
|
||||
__version__ = "1.0.0"
|
||||
import textwrap
|
||||
from tqdm import tqdm
|
||||
from typing import Dict, Any
|
||||
from typing import Any, Dict
|
||||
|
||||
from utils.config import PatchConfig
|
||||
from utils.smali_parser import (
|
||||
find_smali_method_end,
|
||||
find_smali_method_start,
|
||||
get_smali_lines,
|
||||
replace_smali_method_body,
|
||||
)
|
||||
from pydantic import Field
|
||||
|
||||
from utils.config import PatchTemplate
|
||||
from utils.smali_parser import (find_smali_method_end, find_smali_method_start,
|
||||
get_smali_lines, replace_smali_method_body)
|
||||
|
||||
|
||||
#Config
|
||||
class Config(PatchConfig): ...
|
||||
class Patch(PatchTemplate):
|
||||
priority: int = Field(frozen=True, exclude=True, default=0)
|
||||
|
||||
def apply(self, base: Dict[str, Any]) -> bool:
|
||||
path = "./decompiled/smali_classes2/com/swiftsoft/anixartd/Prefs.smali"
|
||||
replacement = [
|
||||
f"\t{line}\n"
|
||||
for line in textwrap.dedent(
|
||||
"""\
|
||||
.locals 0
|
||||
const/4 p0, 0x1
|
||||
return p0
|
||||
"""
|
||||
).splitlines()
|
||||
]
|
||||
|
||||
# Patch
|
||||
def apply(config: Config, base: Dict[str, Any]) -> bool:
|
||||
replacement = [f'\t{line}\n' for line in textwrap.dedent("""\
|
||||
.locals 0
|
||||
const/4 p0, 0x1
|
||||
return p0
|
||||
""").splitlines()]
|
||||
lines = get_smali_lines(path)
|
||||
for index, line in enumerate(lines):
|
||||
if line.find("IS_SPONSOR") >= 0:
|
||||
method_start = find_smali_method_start(lines, index)
|
||||
method_end = find_smali_method_end(lines, index)
|
||||
new_content = replace_smali_method_body(
|
||||
lines, method_start, method_end, replacement
|
||||
)
|
||||
|
||||
path = "./decompiled/smali_classes2/com/swiftsoft/anixartd/Prefs.smali"
|
||||
lines = get_smali_lines(path)
|
||||
for index, line in enumerate(lines):
|
||||
if line.find("IS_SPONSOR") >= 0:
|
||||
method_start = find_smali_method_start(lines, index)
|
||||
method_end = find_smali_method_end(lines, index)
|
||||
new_content = replace_smali_method_body(
|
||||
lines, method_start, method_end, replacement
|
||||
)
|
||||
|
||||
with open(path, "w", encoding="utf-8") as file:
|
||||
file.writelines(new_content)
|
||||
return True
|
||||
with open(path, "w", encoding="utf-8") as file:
|
||||
file.writelines(new_content)
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user