private static void Inject(Injector injector, CommandLineArguments args) { string assemblyPath, @namespace, className, methodName; byte[] assembly; if (args.GetStringArg("-a", out assemblyPath)) { try { assembly = File.ReadAllBytes(assemblyPath); } catch { System.Console.WriteLine("Could not read the file " + assemblyPath); return; } } else { System.Console.WriteLine("No assembly specified"); return; } args.GetStringArg("-n", out @namespace); if (!args.GetStringArg("-c", out className)) { System.Console.WriteLine("No class name specified"); return; } if (!args.GetStringArg("-m", out methodName)) { System.Console.WriteLine("No method name specified"); return; } using (injector) { IntPtr remoteAssembly = IntPtr.Zero; try { remoteAssembly = injector.Inject(assembly, @namespace, className, methodName); } catch (InjectorException ie) { System.Console.WriteLine("Failed to inject assembly: " + ie); } catch (Exception exc) { System.Console.WriteLine("Failed to inject assembly (unknown error): " + exc); } if (remoteAssembly == IntPtr.Zero) { return; } System.Console.WriteLine($"{Path.GetFileName(assemblyPath)}: " + (injector.Is64Bit ? $"0x{remoteAssembly.ToInt64():X16}" : $"0x{remoteAssembly.ToInt32():X8}")); } }