
import clr
import sys
import os
import System
from System import AppDomain

def inspect_dll(dll_path):
    print(f"Inspecting: {dll_path}")
    if not os.path.exists(dll_path):
        print("  File not found.")
        return

    try:
        ref = clr.AddReference(dll_path)
        print(f"  Loaded Assembly: {ref.FullName}")
        
        assembly = None
        for a in AppDomain.CurrentDomain.GetAssemblies():
             if a.FullName == ref.FullName:
                 assembly = a
                 break
        
        if not assembly:
            print("  Could not find assembly in AppDomain.")
            return

        print("  Types:")
        for t in assembly.GetTypes():
            if t.IsPublic:
                print(f"    - {t.FullName}")
                if "RApi" in t.Name or "AdmCallback" in t.Name or "RCallback" in t.Name:
                     print(f"      !!! Found Candidate: {t.Name} !!!")
                     for m in t.GetMethods():
                         if m.IsPublic and m.DeclaringType == t:
                             print(f"        Method: {m.Name}")

    except Exception as e:
        print(f"  Error loading DLL: {e}")

if __name__ == "__main__":
    # Rithmic DLL Directory
    dll_dir = r"C:\Program Files (x86)\Rithmic\Rithmic Trader Pro"
    sys.path.append(dll_dir)
    
    targets = ["RithmicPlugin.dll", "OmneChannel.dll", "OmneStreamEngine.dll", "OmneVerse.dll"]
    
    for t in targets:
        inspect_dll(os.path.join(dll_dir, t))
