MCPcopy Create free account
hub / github.com/GameTechDev/PresentMon / WinMain

Function WinMain

IntelPresentMon/AppCef/source/winmain.cpp:169–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167
168
169int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
170{
171#ifdef NDEBUG
172 constexpr bool is_debug = false;
173#else
174 constexpr bool is_debug = true;
175#endif
176 // parse the command line arguments and make them globally available
177 if (auto err = Options::Init(__argc, __argv, false)) {
178 return *err;
179 }
180 const auto& opt = Options::Get();
181 if (opt.filesWorking) {
182 infra::util::FolderResolver::SetDevMode();
183 }
184 if (opt.logFolder) {
185 infra::util::FolderResolver::SetLogPathOverride(str::ToWide(*opt.logFolder));
186 }
187
188 // create logging system and ensure cleanup before main ext
189 client::util::LogChannelManager zLogMan_;
190
191 // wait for debugger connection
192 if ((opt.cefType && *opt.cefType == "renderer" && opt.debugWaitRender) ||
193 (!opt.cefType && opt.debugWaitClient)) {
194 while (!IsDebuggerPresent()) {
195 std::this_thread::sleep_for(20ms);
196 }
197 DebugBreak();
198 }
199
200 // name this process / thread
201 log::IdentificationTable::AddThisProcess("cef-" + opt.cefType.AsOptional().value_or("mclient"));
202 log::IdentificationTable::AddThisThread("main");
203
204 // initialize the logging system
205 client::util::ConfigureLogging();
206
207 // set the app id so that windows get grouped
208 SetCurrentProcessExplicitAppUserModelID(L"Intel.PresentMon");
209
210 // disable DPI scaling
211 SetProcessDpiAwareness(PROCESS_DPI_UNAWARE);
212
213 try {
214 using namespace client;
215 // cef process constellation fork control
216 CefMainArgs main_args{ hInstance };
217 CefRefPtr<ccef::NanoCefProcessHandler> app = new ccef::NanoCefProcessHandler{};
218
219 if (const auto code = CefExecuteProcess(main_args, app.get(), nullptr); code >= 0) {
220 return (int)code;
221 }
222
223 // code from here on is only executed by the root process (browser window process)
224
225 pmlog_info(std::format("== UI client root process starting build#{} clean:{} CEF:{} ==",
226 BuildIdShortHash(), !BuildIdDirtyFlag(), CEF_VERSION));

Callers

nothing calls this directly

Calls 13

ToWideFunction · 0.85
BuildIdShortHashFunction · 0.85
BuildIdDirtyFlagFunction · 0.85
ToCefLogLevelFunction · 0.85
CreateBrowserWindowFunction · 0.85
CreateMessageWindowFunction · 0.85
ReportExceptionFunction · 0.85
ResolveLogPathMethod · 0.80
GetLogLevelMethod · 0.80
CheckVerboseModuleMethod · 0.80
ConfigureLoggingFunction · 0.50
AsOptionalMethod · 0.45

Tested by

no test coverage detected