/// <summary> /// Inject the managed assembly when the target process is an managed process /// </summary> public static void SampleManagedAssemblyInjection3(RemoteControl Control, Process Process) { //Wait the CLR initialize Control.WaitCLR(); //Get Current Assembly Path string CurrentAssembly = Assembly.GetExecutingAssembly().Location; //Unfortally if the target process is an managed assembly, you can't inject the assembly before the target startup. //When you call the CLRInvoke in a managed process the ResumeProcess will be automatically called. int Ret = Control.CLRInvoke(CurrentAssembly, "LOL, I'm a managed dll inside of the managed target process!"); //Show the managed assembly returned data Console.WriteLine("Returned: 0x" + Ret.ToString("X4")); }
/// <summary> /// Hooks an Unamanged Function Using The: <see cref="EntryPoint(string)"/> /// </summary> public static void SampleUnmanagedDllExportHook2(RemoteControl Control, Process Process) { //Lock the program in his entrypoint, Required to invoke methods or inject libraries Control.LockEntryPoint(); //Get Current Assembly Path string CurrentAssembly = Assembly.GetExecutingAssembly().Location; //Our EntryPoint will detect the "Hook" string as command to test the hook... int Ret = Control.CLRInvoke(CurrentAssembly, "GlobalHook"); //Show the managed assembly returned data Console.WriteLine("Returned: 0x" + Ret.ToString("X4")); //Allow the program startup continue Control.UnlockEntryPoint(); }
/// <summary> /// Inject the managed assembly when only have a single valid entrypoint /// </summary> public static void SampleManagedAssemblyInjection2(RemoteControl Control, Process Process) { //Lock the program in his entrypoint, Required to invoke methods or inject libraries Control.LockEntryPoint(); //Get Current Assembly Path string CurrentAssembly = Assembly.GetExecutingAssembly().Location; //If you have more than one method like that, you need specify it //If you only have one valid entrypoint to the injector, you don't need specifiy it int Ret = Control.CLRInvoke(CurrentAssembly, "LOL, I'm a managed dll inside of the target process!"); //Show the managed assembly returned data Console.WriteLine("Returned: 0x" + Ret.ToString("X4")); //Allow the program startup continue Control.UnlockEntryPoint(); }