Chromium Embedded Framework (CEF)  127.1.0+ga1ec504+chromium-127.0.6533.57
cef_app_win.h File Reference
#include "include/base/cef_build.h"
#include <windows.h>

Typedefs

typedef int(APIENTRY * wWinMainPtr) (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
 
typedef int(* mainPtr) (int argc, char *argv[])
 

Functions

CEF_EXPORT int cef_run_winmain_with_preferred_stack_size (wWinMainPtr wWinMain, HINSTANCE hInstance, LPWSTR lpCmdLine, int nCmdShow)
 Run the main thread on 32-bit Windows using a fiber with the preferred 4MiB stack size. More...
 
CEF_EXPORT int cef_run_main_with_preferred_stack_size (mainPtr main, int argc, char *argv[])
 
CEF_EXPORT void cef_set_osmodal_loop (int osModalLoop)
 Set to true (1) before calling Windows APIs like TrackPopupMenu that enter a modal message loop. More...
 

Typedef Documentation

◆ mainPtr

typedef int(* mainPtr) (int argc, char *argv[])

◆ wWinMainPtr

typedef int(APIENTRY* wWinMainPtr) (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)

Function Documentation

◆ cef_run_main_with_preferred_stack_size()

CEF_EXPORT int cef_run_main_with_preferred_stack_size ( mainPtr  main,
int  argc,
char *  argv[] 
)

◆ cef_run_winmain_with_preferred_stack_size()

CEF_EXPORT int cef_run_winmain_with_preferred_stack_size ( wWinMainPtr  wWinMain,
HINSTANCE  hInstance,
LPWSTR  lpCmdLine,
int  nCmdShow 
)

Run the main thread on 32-bit Windows using a fiber with the preferred 4MiB stack size.

This function must be called at the top of the executable entry point function (main() or wWinMain()). It is used in combination with the initial stack size of 0.5MiB configured via the /STACK:0x80000 linker flag on executable targets. This saves significant memory on threads (like those in the Windows thread pool, and others) whose stack size can only be controlled via the linker flag.

CEF's main thread needs at least a 1.5 MiB stack size in order to avoid stack overflow crashes. However, if this is set in the PE file then other threads get this size as well, leading to address-space exhaustion in 32-bit CEF. This function uses fibers to switch the main thread to a 4 MiB stack (roughly the same effective size as the 64-bit build's 8 MiB stack) before running any other code.

Choose the function variant that matches the entry point function type used by the executable. Reusing the entry point minimizes confusion when examining call stacks in crash reports.

If this function is already running on the fiber it will return -1 immediately, meaning that execution should proceed with the remainder of the entry point function. Otherwise, this function will block until the entry point function has completed execution on the fiber and then return a result >= 0, meaning that the entry point function should return the result immediately without proceeding with execution.

◆ cef_set_osmodal_loop()

CEF_EXPORT void cef_set_osmodal_loop ( int  osModalLoop)

Set to true (1) before calling Windows APIs like TrackPopupMenu that enter a modal message loop.

Set to false (0) after exiting the modal message loop.