#!/usr/bin/env python3 """ Patch ADP initialization in libFoundation.so Makes TADPClient::initialize() return success immediately """ import sys import shutil def log(msg): print(f"[ADP-PATCH] {msg}") def patch_adp_init(): """Patch TADPClient::initialize to return success""" lib_path = "/usr/autodesk/maya2027/lib/libFoundation.so" log(f"Patching: {lib_path}") # Read library with open(lib_path, 'rb') as f: data = bytearray(f.read()) log(f" File size: {len(data):,} bytes") # Create backup backup_path = f"{lib_path}.adp_backup" shutil.copy2(lib_path, backup_path) log(f" Backup created: {backup_path}") # TADPClient::initialize is at offset 0x17ac30 # We need to patch it to return immediately (C3 = ret) # The function prologue is typically: 48 89 f5 48 83 ec ... # We'll replace with just: 48 89 f5 c3 (mov rbp, rsp; ret) offset = 0x17ac30 # Read current bytes original = data[offset:offset+16] log(f" Original bytes at 0x{offset:x}: {original.hex()}") # Patch to return success immediately # 48 89 f5 = mov rbp, rsp # c3 = ret patch_bytes = bytes([0x48, 0x89, 0xf5, 0xc3]) + bytes(12) # Pad with NOPs (0x90) data[offset:offset+16] = patch_bytes log(f" Patched bytes at 0x{offset:x}: {data[offset:offset+16].hex()}") log(f" ✓ TADPClient::initialize() will now return immediately") # Write patched library with open(lib_path, 'wb') as f: f.write(data) log(" ✓ Library patched successfully") if __name__ == "__main__": patch_adp_init()