I'm trying to run cefclient as a DLL from a Windows Desktop application.
The CEF version is 86.0.20+gf2039ae+chromium-86.0.4240.111, built for VS 2019 / Win32 platform / no sandbox.
The original cefclient executable project builds and runs fine. But when run as a DLL, an exception is thrown from libcef:
- Code: Select all
> libcef.dll!logging::LogMessage::~LogMessage() Line 867 C++
libcef.dll!logging::LogMessage::~LogMessage() Line 537 C++
libcef.dll!logging::CheckError::~CheckError() Line 105 C++
libcef.dll!`anonymous namespace'::RegisterLocalizedFontPref(user_prefs::PrefRegistrySyncable * registry=0x076154e8, const char * path=0x178f516c, int default_message_id=143) Line 281 C++
libcef.dll!PrefsTabHelper::RegisterProfilePrefs(user_prefs::PrefRegistrySyncable * registry=0x076154e8, const std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>> & locale={...}) Line 421 C++
libcef.dll!renderer_prefs::RegisterProfilePrefs(user_prefs::PrefRegistrySyncable * registry=0x076154e8, const std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>> & locale={...}) Line 321 C++
libcef.dll!browser_prefs::CreatePrefService(Profile * profile=0x07611630, const base::FilePath & cache_path={...}, bool persist_user_preferences) Line 240 C++
libcef.dll!AlloyBrowserContext::Initialize() Line 123 C++
libcef.dll!AlloyMainDelegate::CreateNewBrowserContext(const CefStructBase<CefRequestContextSettingsTraits> & settings={...}) Line 449 C++
libcef.dll!CefRequestContextImpl::Initialize() Line 652 C++
libcef.dll!CefRequestContextImpl::CreateGlobalRequestContext(const CefStructBase<CefRequestContextSettingsTraits> & settings={...}) Line 215 C++
libcef.dll!AlloyBrowserMainParts::PreMainMessageLoopRun() Line 196 C++
libcef.dll!content::BrowserMainLoop::PreMainMessageLoopRun() Line 983 C++
libcef.dll!base::OnceCallback<int ()>::Run() Line 99 C++
libcef.dll!content::StartupTaskRunner::RunAllTasksNow() Line 41 C++
libcef.dll!content::BrowserMainLoop::CreateStartupTasks() Line 897 C++
libcef.dll!content::BrowserMainRunnerImpl::Initialize(const content::MainFunctionParams & parameters={...}) Line 130 C++
libcef.dll!CefMainRunner::RunMainProcess(const content::MainFunctionParams & main_function_params={...}) Line 449 C++
libcef.dll!AlloyMainDelegate::RunProcess(const std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>> & process_type={...}, const content::MainFunctionParams & main_function_params={...}) Line 407 C++
libcef.dll!content::RunBrowserProcessMain(const content::MainFunctionParams & main_function_params={...}, content::ContentMainDelegate * delegate=0x00cdbf48) Line 523 C++
libcef.dll!content::ContentMainRunnerImpl::RunServiceManager(content::MainFunctionParams & main_params={...}, bool start_service_manager_only) Line 998 C++
libcef.dll!content::ContentMainRunnerImpl::Run(bool start_service_manager_only) Line 885 C++
libcef.dll!content::ContentServiceManagerMainDelegate::RunEmbedderProcess() Line 60 C++
libcef.dll!service_manager::MainRun(service_manager::MainParams & params={...}) Line 460 C++
libcef.dll!CefMainRunner::ContentMainRun(bool * initialized=0x00d016e0, base::OnceCallback<void ()> context_initialized={...}) Line 419 C++
libcef.dll!CefMainRunner::Initialize(CefStructBase<CefSettingsTraits> * settings=0x00d016e8, scoped_refptr<CefApp> application={...}, const CefMainArgs & args={...}, void * windows_sandbox_info=0x00000000, bool * initialized=0x00d016e0, base::OnceCallback<void ()> context_initialized={...}) Line 241 C++
libcef.dll!CefContext::Initialize(const CefMainArgs & args={...}, const CefStructBase<CefSettingsTraits> & settings={...}, scoped_refptr<CefApp> application={...}, void * windows_sandbox_info=0x00000000) Line 356 C++
libcef.dll!CefInitialize(const CefMainArgs & args={...}, const CefStructBase<CefSettingsTraits> & settings={...}, scoped_refptr<CefApp> application={...}, void * windows_sandbox_info=0x00000000) Line 214 C++
libcef.dll!cef_initialize(const _cef_main_args_t * args=0x008dfad8, const _cef_settings_t * settings=0x008df9a8, _cef_app_t * application=0x00cdda50, void * windows_sandbox_info=0x00000000) Line 111 C++
cefclient.dll!CefInitialize(const CefMainArgs & args={...}, const CefStructBase<CefSettingsTraits> & settings={...}, scoped_refptr<CefApp> application={...}, void * windows_sandbox_info=0x00000000) Line 105 C++
cefclient.dll!client::MainContextImpl::Initialize(const CefMainArgs & args={...}, const CefStructBase<CefSettingsTraits> & settings={...}, scoped_refptr<CefApp> application={...}, void * windows_sandbox_info=0x00000000) Line 225 C++
cefclient.dll!client::`anonymous namespace'::RunMain() Line 99 C++
cefclient.dll!interface() Line 129 C++
test_app.exe!wWinMain(HINSTANCE__ * hInstance=0x009a0000, HINSTANCE__ * hPrevInstance=0x00000000, wchar_t * lpCmdLine=0x00c937c8, int nCmdShow=10) Line 134 C++
test_app.exe!invoke_main() Line 123 C++
test_app.exe!__scrt_common_main_seh() Line 288 C++
test_app.exe!__scrt_common_main() Line 331 C++
test_app.exe!wWinMainCRTStartup() Line 17 C++
kernel32.dll!7640fa29() Unknown
kernel32.dll![Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll] Unknown
ntdll.dll!777575f4() Unknown
ntdll.dll!777575c4() Unknown
The changes I've made to cefclient are minimal: set the project as a DLL, added a .def file, and modified cefclient_win.cc as follows:
- Code: Select all
36c36
< int RunMain(HINSTANCE hInstance, int nCmdShow) {
---
> int RunMain() {
40c40
< CefMainArgs main_args(hInstance);
---
> CefMainArgs main_args(GetModuleHandle(NULL));
127,134c127,128
< // Program entry point function.
< int APIENTRY wWinMain(HINSTANCE hInstance,
< HINSTANCE hPrevInstance,
< LPTSTR lpCmdLine,
< int nCmdShow) {
< UNREFERENCED_PARAMETER(hPrevInstance);
< UNREFERENCED_PARAMETER(lpCmdLine);
< return client::RunMain(hInstance, nCmdShow);
---
> extern void interface() {
> client::RunMain();
So in the main app I'm calling interface().
Note that I really have to use this DLL architecture: I'm working on upgrading a code that essentially does that but uses an old version of CEF (3.1750.1738).
Thank you in advance,