generated from oci/template
Begin Monkeyloader Work
This commit is contained in:
parent
1fec55efc0
commit
d79288f11d
8 changed files with 187 additions and 46 deletions
76
defaults/loader/Loader.cs
Normal file
76
defaults/loader/Loader.cs
Normal file
|
@ -0,0 +1,76 @@
|
|||
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
|
||||
}
|
11
defaults/loader/Loader.csproj
Normal file
11
defaults/loader/Loader.csproj
Normal file
|
@ -0,0 +1,11 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
Loading…
Add table
Add a link
Reference in a new issue