using System; using System.IO; using System.Reflection; using System.Runtime.InteropServices; class Program { static void Main(string[] args) { // Hardcoded working directory string workDir = "/data/resonite/Headless"; string resonitePath = Path.Combine(workDir, "Resonite.dll"); string winhttpPath = Path.Combine(workDir, "winhttp.dll"); Console.WriteLine($"Using hardcoded work directory: {workDir}"); // Verify work directory exists if (!Directory.Exists(workDir)) { Console.WriteLine($"Error: Work directory '{workDir}' does not exist."); return; } // Verify winhttp.dll exists if (!File.Exists(winhttpPath)) { Console.WriteLine($"Error: Cannot find winhttp.dll at {winhttpPath}"); return; } // Load the winhttp.dll IntPtr handle = LoadLibrary(winhttpPath); if (handle == IntPtr.Zero) { Console.WriteLine("Failed to load winhttp.dll"); return; } Console.WriteLine("winhttp.dll loaded successfully"); // Verify Resonite.dll exists if (!File.Exists(resonitePath)) { Console.WriteLine($"Error: Cannot find Resonite.dll at {resonitePath}"); return; } // Load and execute Resonite.dll Assembly resoniteAssembly = Assembly.LoadFrom(resonitePath); // Find the entry point and invoke it MethodInfo entryPoint = resoniteAssembly.EntryPoint; if (entryPoint == null) { Console.WriteLine("Error: Could not find entry point in Resonite.dll"); return; } Console.WriteLine("Executing Resonite.dll with provided arguments..."); entryPoint.Invoke(null, new object[] { args }); } #if WINDOWS [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)] private static extern IntPtr LoadLibrary(string lpFileName); #else [DllImport("libc.so.6", SetLastError = true)] private static extern IntPtr dlopen(string fileName, int flags); private static IntPtr LoadLibrary(string fileName) { const int RTLD_NOW = 2; return dlopen(fileName, RTLD_NOW); } #endif }