public void SetNativeConfig(NativeModulesConfiguration nativeConfig)
 {
     ClrLibrariesPath = nativeConfig.ClrLibrariesPath;
     ClrRootPath      = nativeConfig.ClrRootPath;
     HostLibrary      = nativeConfig.HostLibrary;
     DetourLibrary    = nativeConfig.DetourLibrary;
 }
示例#2
0
        /// <summary>
        /// Retrieve the required paths for initializing the CoreCLR and executing .NET assemblies in an unmanaged process
        /// </summary>
        /// <param name="is64BitProcess">Flag for determining which native modules to load into the target process</param>
        /// <param name="nativeModulesConfig">Configuration class containing paths to the native modules used by CoreHook.</param>
        /// <returns>Returns whether all required paths and modules have been found.</returns>
        public static bool GetCoreLoadPaths(
            bool is64BitProcess,
            out NativeModulesConfiguration nativeModulesConfig)
        {
            nativeModulesConfig = null;

            string currentDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            if (!string.IsNullOrWhiteSpace(currentDir) && GetCoreClrRootPath(
                    is64BitProcess,
                    out string coreLibsPath,
                    out string coreRootPath))
            {
                // Module that initializes the .NET Core runtime and executes .NET assemblies
                var coreRunPath = Path.Combine(
                    currentDir,
                    is64BitProcess ? CoreHostModule64 : CoreHostModule32);
                if (!File.Exists(coreRunPath))
                {
                    HandleFileNotFound(coreRunPath);
                    return(false);
                }

                var corehookPath = Path.Combine(
                    currentDir,
                    is64BitProcess ? CoreHookingModule64 : CoreHookingModule32);
                if (!File.Exists(corehookPath))
                {
                    HandleFileNotFound(corehookPath);
                    return(false);
                }

                nativeModulesConfig = new NativeModulesConfiguration
                {
                    ClrLibrariesPath = coreLibsPath,
                    ClrRootPath      = coreRootPath,
                    HostLibrary      = coreRunPath,
                    DetourLibrary    = corehookPath
                };

                return(true);
            }
            return(false);
        }
 public RemoteInjectorConfiguration(NativeModulesConfiguration nativeConfig)
 {
     SetNativeConfig(nativeConfig);
 }