Skip to content

AppCef: Check for non secure path #204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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