Chromium 加载chrome.dll过程分析c++

server/2024/10/19 22:41:00/

chrome.exe加载同级版本号目录-》chrome.exe和chrome.dll同级目录。

一、优先从chrome.exe同级版本号目录下加载

例如:chrome.exe [版本号:129.0.6668.101] 从129.0.6668.101\chrome.dll下加载

          

发布版大多数都是以此种办法,主要是方便升级时候,防止不同版本号chrome.exe加载错误的chrome.dll。 

二、 chrome.exe和chrome.dll在同目录直接加载。

三、看下代码逻辑:

   F:\code\google\src\chrome\app\main_dll_loader_win.cc

// Returns the full path to |module_name|. Both dev builds (where |module_name|
// is in the current executable's directory) and proper installs (where
// |module_name| is in a versioned sub-directory of the current executable's
// directory) are supported. The identified file is not guaranteed to exist.
base::FilePath GetModulePath(std::wstring_view module_name) {base::FilePath exe_dir;const bool has_path = base::PathService::Get(base::DIR_EXE, &exe_dir);DCHECK(has_path);// Look for the module in a versioned sub-directory of the current// executable's directory and return the path if it can be read. This is the// expected location of modules for proper installs.const base::FilePath module_path =exe_dir.AppendASCII(chrome::kChromeVersion).Append(module_name);if (ModuleCanBeRead(module_path))return module_path;// Othwerwise, return the path to the module in the current executable's// directory. This is the expected location of modules for dev builds.return exe_dir.Append(module_name);
}

 1、 在base::FilePath GetModulePath(std::wstring_view module_name)函数中优先获取chrome.exe所在路径:F:\code\google\src\out\Debug

2、版本号目录F:\code\google\src\out\Debug\122.0.6224.0\chrome.dll

3、如果122.0.6224.0\chrome.dll目录下没有crome.dll直接返回F:\code\google\src\out\Debug

4、最终结果是加载F:\code\google\src\out\Debug\chrome.dll

// Prefetches and loads |module| after setting the CWD to |module|'s
// directory. Returns a handle to the loaded module on success, or nullptr on
// failure.
HMODULE LoadModuleWithDirectory(const base::FilePath& module,const base::CommandLine& cmd_line) {::SetCurrentDirectoryW(module.DirName().value().c_str());if (!cmd_line.HasSwitch(switches::kNoPreReadMainDll)) {base::PreReadFile(module, /*is_executable=*/true);}HMODULE handle = ::LoadLibraryExW(module.value().c_str(), nullptr,LOAD_WITH_ALTERED_SEARCH_PATH);return handle;
}// Prefetches and loads the appropriate DLL for the process type
// |process_type_|. Populates |module| with the path of the loaded DLL.
// Returns a handle to the loaded DLL, or nullptr on failure.
HMODULE Load(base::FilePath* module, const base::CommandLine& cmd_line) {*module = GetModulePath(installer::kChromeDll);if (module->empty()) {PLOG(ERROR) << "Cannot find module " << installer::kChromeDll;return nullptr;}HMODULE dll = LoadModuleWithDirectory(*module, cmd_line);if (!dll)PLOG(ERROR) << "Failed to load Chrome DLL from " << module->value();return dll;
}

总结:end


http://www.ppmy.cn/server/133169.html

相关文章

ubuntu 24.04 下载安装离线包,ubuntu 24.04 配置xrdp

ubuntu 24.04 配置xrdp 1. 安装gnome-tweaks sudo apt install gnome-tweaks 2. 配置 cat <<EOF > ~/.xsessionrc export GNOME_SHELL_SESSION_MODEubuntu export XDG_CURRENT_DESKTOPubuntu:GNOME export XDG_CONFIG_DIRS/etc/xdg/xdg-ubuntu:/etc/xdg EOF 3.…

玄机平台-应急响应-webshell查杀

首先xshell连接 然后进入/var/www/html目录中&#xff0c;将文件变成压缩包 cd /var/www/html tar -czvf web.tar.gz ./* 开启一个http.server服务&#xff0c;将文件下载到本地 python3 -m http.server 放在D盾中检测 基本可以确认木马文件就是这四个 /var/www/html/shell.p…

智慧社区Web解决方案:Spring Boot框架探索

1系统概述 1.1 研究背景 随着计算机技术的发展以及计算机网络的逐渐普及&#xff0c;互联网成为人们查找信息的重要场所&#xff0c;二十一世纪是信息的时代&#xff0c;所以信息的管理显得特别重要。因此&#xff0c;使用计算机来管理基于web的智慧社区设计与实现的相关信息成…

数据中台业务架构图

数据中台的业务架构是企业实现数据驱动决策和业务创新的关键支撑。它主要由数据源层、数据存储与处理层、数据服务层以及数据应用层组成。 数据源层涵盖了企业内部各个业务系统的数据&#xff0c;如 ERP、CRM 等&#xff0c;以及外部数据来源&#xff0c;如社交媒体、行业数据…

递归神经网络(RNN)简介

递归神经网络简介 在本文中,我们将介绍神经网络的一种新的变体,即递归神经网络,也称为 (RNN),当数据是连续的时,如时间序列数据和文本数据,它比简单的神经网络效果更好。 什么是递归神经网络 (RNN)? 循环神经网络 (RNN) 是一种神经网络,其中上一步的输出作为当前…

通信工程学习:什么是VPN虚拟私人网络

VPN&#xff1a;虚拟私人网络 VPN&#xff0c;即虚拟私人网络&#xff08;Virtual Private Network&#xff09;&#xff0c;是一种通过公共网络&#xff08;如互联网&#xff09;建立的加密连接&#xff0c;用于保护用户的网络连接和数据传输的安全与隐私。以下是关于VPN的详细…

Leetcode——数组:滑动窗口209.长度最小的子数组

题目 题解 当需要查找数组中某些连续的数字之和&#xff0c;适合使用滑动窗口 先将滑动窗口的长度设置为0&#xff0c;先将左侧固定&#xff0c;右边界向右移动&#xff0c;同时计算需要找的条件&#xff0c;直到找到可行解为止 当找到可行解后&#xff0c;对其进行优化&…

机器视觉入门基础相关概念一 ——单目相机模型

机器视觉入门基础相关概念 相机模型 引言介绍&#xff1a;如果只是希望获取图像上的一些信息&#xff08;例如特征提取、拟合等&#xff09;&#xff0c;那么我们不会对三维空间中相机的位置有所要求。但如果希望通过二维的图像去理解三维空间中摄像机的信息&#xff0c;或者是…