This commit is contained in:
Anonymous Maarten 2023-12-08 02:34:41 +01:00
parent 162ae219e6
commit 786bd4b6fa
4 changed files with 88 additions and 65 deletions

View File

@ -165,7 +165,7 @@ class-naming-style=PascalCase
#class-rgx= #class-rgx=
# Naming style matching correct constant names. # Naming style matching correct constant names.
const-naming-style=snake_case const-naming-style=UPPER_CASE
# Regular expression matching correct constant names. Overrides const-naming- # Regular expression matching correct constant names. Overrides const-naming-
# style. If left empty, constant names will be checked with the set naming # style. If left empty, constant names will be checked with the set naming
@ -511,7 +511,7 @@ ignore-imports=yes
ignore-signatures=yes ignore-signatures=yes
# Minimum lines number of a similarity. # Minimum lines number of a similarity.
min-similarity-lines=4 min-similarity-lines=16
[SPELLING] [SPELLING]

View File

@ -16,9 +16,14 @@
def main(): def main():
parser = argparse.ArgumentParser(allow_abbrev=False, description="Patch C2.EXE of Micrisoft Visual Studio 4.2.0 to disable C4786 warning") parser = argparse.ArgumentParser(
allow_abbrev=False,
description="Path C2.EXE of Micrisoft Visual Studio 4.2.0 to disable C4786 warning",
)
parser.add_argument("path", type=pathlib.Path, help="Path of C2.EXE") parser.add_argument("path", type=pathlib.Path, help="Path of C2.EXE")
parser.add_argument("-f", dest="force", default=False, action="store_true", help="force") parser.add_argument(
"-f", dest="force", default=False, action="store_true", help="force"
)
args = parser.parse_args() args = parser.parse_args()
if not args.path.is_file(): if not args.path.is_file():
@ -36,21 +41,23 @@ def main():
if md5 == ORIGINAL_C2_MD5: if md5 == ORIGINAL_C2_MD5:
backup = f"{args.path}.BAK" backup = f"{args.path}.BAK"
print(f"Creating backup \"{backup}\"") print(f'Creating backup "{backup}"')
shutil.copyfile(args.path, backup) shutil.copyfile(args.path, backup)
def nop_patch(start, count, expected=None): def nop_patch(start, count, expected=None):
replacement = [0x90] * count replacement = [0x90] * count
if expected: if expected:
current = list(binary[start:start + count]) current = list(binary[start : start + count])
assert len(expected) == count assert len(expected) == count
assert current in (expected, replacement) assert current in (expected, replacement)
print(f"Nopping {count} bytes at 0x{start:08x}") print(f"Nopping {count} bytes at 0x{start:08x}")
binary[start:start + count] = replacement binary[start : start + count] = replacement
# Disable C4786 warning ('%Fs' : identifier was truncated to '%d' characters in the debug information) print(
nop_patch(0x52f07, 5, [0xe8, 0x4f, 0xb3, 0xfe, 0xff]) # 0x00453b07 "Disable C4786 warning: '%Fs' : identifier was truncated to '%d' characters in the debug information"
nop_patch(0x74832, 5, [0xe8, 0x24, 0x9a, 0xfc, 0xff]) # 0x00475432 )
nop_patch(0x52F07, 5, [0xE8, 0x4F, 0xB3, 0xFE, 0xFF]) # 0x00453b07
nop_patch(0x74832, 5, [0xE8, 0x24, 0x9A, 0xFC, 0xFF]) # 0x00475432
args.path.open("wb").write(binary) args.path.open("wb").write(binary)
print("done") print("done")

View File

@ -23,6 +23,7 @@
import colorama import colorama
from pystache import Renderer from pystache import Renderer
REGISTER_LIST = set( REGISTER_LIST = set(
[ [
"ax", "ax",
@ -200,7 +201,8 @@ def gen_svg(svg_file, name_svg, icon, svg_implemented_funcs, total_funcs, raw_ac
# Do the actual work # Do the actual work
if __name__ == "__main__": def main():
# pylint: disable=too-many-locals, too-many-nested-blocks, too-many-branches, too-many-statements
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
allow_abbrev=False, allow_abbrev=False,
description="Recompilation Compare: compare an original EXE with a recompiled EXE + PDB.", description="Recompilation Compare: compare an original EXE with a recompiled EXE + PDB.",
@ -483,3 +485,7 @@ def gen_svg(svg_file, name_svg, icon, svg_implemented_funcs, total_funcs, raw_ac
function_count, function_count,
total_effective_accuracy, total_effective_accuracy,
) )
if __name__ == "__main__":
raise SystemExit(main())

View File

@ -8,36 +8,43 @@
from isledecomp.utils import print_diff from isledecomp.utils import print_diff
parser = argparse.ArgumentParser(
allow_abbrev=False, description="Verify Exports: Compare the exports of two DLLs." def main():
) parser = argparse.ArgumentParser(
parser.add_argument("original", metavar="original-binary", help="The original binary") allow_abbrev=False,
parser.add_argument( description="Verify Exports: Compare the exports of two DLLs.",
)
parser.add_argument(
"original", metavar="original-binary", help="The original binary"
)
parser.add_argument(
"recompiled", metavar="recompiled-binary", help="The recompiled binary" "recompiled", metavar="recompiled-binary", help="The recompiled binary"
) )
parser.add_argument( parser.add_argument(
"--no-color", "-n", action="store_true", help="Do not color the output" "--no-color", "-n", action="store_true", help="Do not color the output"
) )
args = parser.parse_args() args = parser.parse_args()
if not os.path.isfile(args.original): if not os.path.isfile(args.original):
parser.error(f"Original binary file {args.original} does not exist") parser.error(f"Original binary file {args.original} does not exist")
if not os.path.isfile(args.recompiled): if not os.path.isfile(args.recompiled):
parser.error(f"Recompiled binary {args.recompiled} does not exist") parser.error(f"Recompiled binary {args.recompiled} does not exist")
def get_file_in_script_dir(fn):
def get_file_in_script_dir(fn):
return os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), fn) return os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), fn)
def get_exports(file):
def get_exports(file):
call = [get_file_in_script_dir("DUMPBIN.EXE"), "/EXPORTS"] call = [get_file_in_script_dir("DUMPBIN.EXE"), "/EXPORTS"]
if os.name != "nt": if os.name != "nt":
call.insert(0, "wine") call.insert(0, "wine")
file = subprocess.check_output(["winepath", "-w", file]).decode("utf-8").strip() file = (
subprocess.check_output(["winepath", "-w", file])
.decode("utf-8")
.strip()
)
call.append(file) call.append(file)
@ -58,11 +65,14 @@ def get_exports(file):
return exports return exports
og_exp = get_exports(args.original)
re_exp = get_exports(args.recompiled)
og_exp = get_exports(args.original) udiff = difflib.unified_diff(og_exp, re_exp)
re_exp = get_exports(args.recompiled) has_diff = print_diff(udiff, args.no_color)
udiff = difflib.unified_diff(og_exp, re_exp) return 1 if has_diff else 0
has_diff = print_diff(udiff, args.no_color)
sys.exit(1 if has_diff else 0)
if __name__ == "__main__":
raise SystemExit(main())