Skip to content

Commit

Permalink
AppCef: Check for non secure path
Browse files Browse the repository at this point in the history
  • Loading branch information
illusion0001 committed Mar 5, 2024
1 parent e3f2901 commit 2409a81
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion IntelPresentMon/AppCef/source/winmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ LRESULT CALLBACK MessageWindowWndProc(HWND window_handle, UINT message, WPARAM w
return DefWindowProc(window_handle, message, w_param, l_param);
}

#define PROGRAM_NAME "Intel PresentMon"

HWND CreateBrowserWindow(HINSTANCE instance_handle, int show_minimize_or_maximize)
{
WNDCLASSEX wcex = { 0 };
Expand All @@ -136,7 +138,7 @@ HWND CreateBrowserWindow(HINSTANCE instance_handle, int show_minimize_or_maximiz
RegisterClassEx(&wcex);

HWND hwnd = CreateWindow(
BrowserWindowClassName, "Intel PresentMon",
BrowserWindowClassName, PROGRAM_NAME,
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, 200, 20,
1360, 1020, nullptr, nullptr, instance_handle, nullptr
);
Expand Down Expand Up @@ -174,6 +176,20 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
{
using namespace client;
try {
#ifdef NDEBUG
std::wstring _path = std::filesystem::current_path();
if (_path.find(L"Program Files\\", 0) == -1LL) // -1 means no offset was found
{
wchar_t msg[512]{};
(void)_snwprintf_s(msg, _countof(msg),
L"Unable to start " PROGRAM_NAME " due to path not being in privileged location.\n"
"Path: \"%s\"\n"
"You must copy installation files to privileged location such as \"C:\\Program Files\".", _path.c_str());
MessageBoxW(nullptr, msg, L"" PROGRAM_NAME " Startup Error", MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
return -1;
}
#endif
#undef PROGRAM_NAME
opt::init();
util::BootServices();

Expand Down

0 comments on commit 2409a81

Please sign in to comment.