internal static void InjectDllIntoTarget( Process target, string injectionLibrary, string injectionPipeName, params object[] remoteArguments ) { if (Examples.Common.ModulesPathHelper.GetCoreLoadPaths( target.Is64Bit(), out NativeModulesConfiguration nativeConfig) && Examples.Common.ModulesPathHelper.GetCoreLoadModulePath( out string coreLoadLibrary)) { RemoteInjector.Inject( target.Id, new RemoteInjectorConfiguration(nativeConfig) { InjectionPipeName = injectionPipeName, ClrBootstrapLibrary = coreLoadLibrary, PayloadLibrary = injectionLibrary, VerboseLog = false }, new PipePlatformBase(), remoteArguments); } }
/// <summary> /// Inject and load the CoreHook hooking module <paramref name="injectionLibrary"/> /// in the existing created process referenced by <paramref name="processId"/>. /// </summary> /// <param name="processId">The target process ID to inject and load plugin into.</param> /// <param name="injectionLibrary">The path of the plugin that is loaded into the target process.</param> /// <param name="injectionPipeName">The pipe name which receives messages during the plugin initialization stage.</param> private static void InjectDllIntoTarget( int processId, string injectionLibrary, string injectionPipeName = InjectionPipeName) { ValidateFilePath(injectionLibrary); if (Examples.Common.ModulesPathHelper.GetCoreLoadPaths( ProcessHelper.GetProcessById(processId).Is64Bit(), out NativeModulesConfiguration nativeConfig) && Examples.Common.ModulesPathHelper.GetCoreLoadModulePath( out string coreLoadLibrary)) { RemoteInjector.Inject( processId, new RemoteInjectorConfiguration(nativeConfig) { InjectionPipeName = injectionPipeName, ClrBootstrapLibrary = coreLoadLibrary, PayloadLibrary = injectionLibrary, VerboseLog = HostVerboseLog }, PipePlatform, CoreHookPipeName); } }
/// <summary> /// Inject and load the CoreHook hooking module <paramref name="injectionLibrary"/> /// in the existing created process referenced by <paramref name="processId"/>. /// </summary> /// <param name="processId">The target process ID to inject and load plugin into.</param> /// <param name="injectionLibrary">The path of the plugin that is loaded into the target process.</param> /// <param name="injectionPipeName">The pipe name which receives messages during the plugin initialization stage.</param> private static void InjectDllIntoTarget( int processId, string injectionLibrary, string injectionPipeName = InjectionPipeName) { if (Examples.Common.ModulesPathHelper.GetCoreLoadPaths( ProcessHelper.GetProcessById(processId).Is64Bit(), out NativeModulesConfiguration nativeConfig) && Examples.Common.ModulesPathHelper.GetCoreLoadModulePath( out string coreLoadLibrary)) { // Make sure the native dll modules can be accessed by the UWP application GrantAllAppPackagesAccessToFile(nativeConfig.HostLibrary); GrantAllAppPackagesAccessToFile(nativeConfig.DetourLibrary); RemoteInjector.Inject( processId, new RemoteInjectorConfiguration(nativeConfig) { InjectionPipeName = injectionPipeName, ClrBootstrapLibrary = coreLoadLibrary, PayloadLibrary = injectionLibrary, VerboseLog = HostVerboseLog }, PipePlatform, CoreHookPipeName); } }