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=
# 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-
# style. If left empty, constant names will be checked with the set naming
@ -511,7 +511,7 @@ ignore-imports=yes
ignore-signatures=yes
# Minimum lines number of a similarity.
min-similarity-lines=4
min-similarity-lines=16
[SPELLING]

View File

@ -9,16 +9,21 @@
C2_MD5 = (
ORIGINAL_C2_MD5,
"e70acde41802ddec06c4263bb357ac30", # patched C2.EXE
"e70acde41802ddec06c4263bb357ac30", # patched C2.EXE
)
C2_SIZE = 549888
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("-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()
if not args.path.is_file():
@ -36,21 +41,23 @@ def main():
if md5 == ORIGINAL_C2_MD5:
backup = f"{args.path}.BAK"
print(f"Creating backup \"{backup}\"")
print(f'Creating backup "{backup}"')
shutil.copyfile(args.path, backup)
def nop_patch(start, count, expected=None):
replacement = [0x90] * count
if expected:
current = list(binary[start:start + count])
current = list(binary[start : start + count])
assert len(expected) == count
assert current in (expected, replacement)
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)
nop_patch(0x52f07, 5, [0xe8, 0x4f, 0xb3, 0xfe, 0xff]) # 0x00453b07
nop_patch(0x74832, 5, [0xe8, 0x24, 0x9a, 0xfc, 0xff]) # 0x00475432
print(
"Disable C4786 warning: '%Fs' : identifier was truncated to '%d' characters in the debug information"
)
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)
print("done")

View File

@ -23,6 +23,7 @@
import colorama
from pystache import Renderer
REGISTER_LIST = set(
[
"ax",
@ -200,7 +201,8 @@ def gen_svg(svg_file, name_svg, icon, svg_implemented_funcs, total_funcs, raw_ac
# 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(
allow_abbrev=False,
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,
total_effective_accuracy,
)
if __name__ == "__main__":
raise SystemExit(main())

View File

@ -8,61 +8,71 @@
from isledecomp.utils import print_diff
parser = argparse.ArgumentParser(
allow_abbrev=False, 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"
)
parser.add_argument(
"--no-color", "-n", action="store_true", help="Do not color the output"
)
args = parser.parse_args()
def main():
parser = argparse.ArgumentParser(
allow_abbrev=False,
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"
)
parser.add_argument(
"--no-color", "-n", action="store_true", help="Do not color the output"
)
if not os.path.isfile(args.original):
parser.error(f"Original binary file {args.original} does not exist")
args = parser.parse_args()
if not os.path.isfile(args.recompiled):
parser.error(f"Recompiled binary {args.recompiled} does not exist")
if not os.path.isfile(args.original):
parser.error(f"Original binary file {args.original} does not exist")
if not os.path.isfile(args.recompiled):
parser.error(f"Recompiled binary {args.recompiled} does not exist")
def get_file_in_script_dir(fn):
return os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), fn)
def get_exports(file):
call = [get_file_in_script_dir("DUMPBIN.EXE"), "/EXPORTS"]
if os.name != "nt":
call.insert(0, "wine")
file = (
subprocess.check_output(["winepath", "-w", file])
.decode("utf-8")
.strip()
)
call.append(file)
raw = subprocess.check_output(call).decode("utf-8").split("\r\n")
exports = []
start = False
for line in raw:
if not start:
if line == " ordinal hint name":
start = True
else:
if line:
exports.append(line[27 : line.rindex(" (")])
elif exports:
break
return exports
og_exp = get_exports(args.original)
re_exp = get_exports(args.recompiled)
udiff = difflib.unified_diff(og_exp, re_exp)
has_diff = print_diff(udiff, args.no_color)
return 1 if has_diff else 0
def get_file_in_script_dir(fn):
return os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), fn)
def get_exports(file):
call = [get_file_in_script_dir("DUMPBIN.EXE"), "/EXPORTS"]
if os.name != "nt":
call.insert(0, "wine")
file = subprocess.check_output(["winepath", "-w", file]).decode("utf-8").strip()
call.append(file)
raw = subprocess.check_output(call).decode("utf-8").split("\r\n")
exports = []
start = False
for line in raw:
if not start:
if line == " ordinal hint name":
start = True
else:
if line:
exports.append(line[27 : line.rindex(" (")])
elif exports:
break
return exports
og_exp = get_exports(args.original)
re_exp = get_exports(args.recompiled)
udiff = difflib.unified_diff(og_exp, re_exp)
has_diff = print_diff(udiff, args.no_color)
sys.exit(1 if has_diff else 0)
if __name__ == "__main__":
raise SystemExit(main())