Skip to content

Commit

Permalink
Merge pull request #22 from roblabla/var-order
Browse files Browse the repository at this point in the history
Add var_order pragma to the compiler
  • Loading branch information
roblabla authored Oct 18, 2023
2 parents 50bea94 + 6421bfa commit 7150919
Show file tree
Hide file tree
Showing 7 changed files with 543 additions and 28 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,12 @@ and its history matches the checkin history from our team's Ghidra Server.
If you wish to help us in our Reverse Engineering effort, please contact
@roblabla on discord so we can give you an account on the Ghidra Server.

# Credits

We would like to extend our thanks to the following individuals for their
invaluable contributions:

- @EstexNT for porting the [`var_order` pragma](scripts/pragma_var_order.cpp) to
MSVC7.

[th06-re]: https://github.com/happyhavoc/th06-re
23 changes: 23 additions & 0 deletions scripts/create_devenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import subprocess
import sys
from typing import Optional
import os

SCRIPTS_DIR = Path(__file__).parent

def run_generic_extract(msi_file_path: Path, output_dir: Path) -> int:
return subprocess.check_call(["7z", "x", "-y", msi_file_path], cwd=output_dir)
Expand All @@ -19,6 +21,17 @@ def run_msiextract_win32(msi_file_path: Path, output_dir: Path) -> int:
return subprocess.check_call(["msiexec", "/a", msi_file_path, "/qb", f"TARGETDIR={output_dir}"], cwd=output_dir)


def run_windows_program(args, add_env=None, cwd=None):
env = dict(os.environ)
for k, v in add_env.items():
env[k] = v

if sys.platform == "win32":
subprocess.check_call(args, env=env, cwd=cwd)
else:
subprocess.check_call([os.getenv("WINE", "wine")] + args, env=env, cwd=cwd)


def translate_msiextract_name(raw_name: str) -> Optional[str]:
name = raw_name.split(":")[0]

Expand Down Expand Up @@ -200,6 +213,16 @@ def main(args: Namespace) -> int:
shutil.move(tmp_dir / "F_CENTRAL_msvcr100_x86", python_dst_dir / "msvcr100.dll")
shutil.rmtree(tmp_dir, ignore_errors=True)

print("Installing pragma_var_order")
tmp_dir.mkdir(parents=True, exist_ok=True)
run_windows_program([str(SCRIPTS_DIR / "th06run.bat"), "CL.EXE", str(SCRIPTS_DIR / "pragma_var_order.cpp"), "/ohackery.dll", "/link", "/DLL"], add_env={
'DEVENV_PREFIX': str(output_path)
}, cwd=str(tmp_dir))
VC7 = output_path / "PROGRAM FILES/MICROSOFT VISUAL STUDIO .NET/VC7"
shutil.move(VC7 / "BIN/C1XX.DLL", VC7 / "BIN/C1XXOrig.DLL")
shutil.move(tmp_dir / "hackery.dll", VC7 / "BIN/C1XX.DLL")
shutil.rmtree(tmp_dir, ignore_errors=True)

return 0


Expand Down
Loading

0 comments on commit 7150919

Please sign in to comment.