MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / InvokeClearCacheUtility

Method InvokeClearCacheUtility

cpp/iedriver/BrowserFactory.cpp:986–1086  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

984}
985
986void BrowserFactory::InvokeClearCacheUtility(bool use_low_integrity_level) {
987 LOG(TRACE) << "Entering BrowserFactory::InvokeClearCacheUtility";
988 HRESULT hr = S_OK;
989 std::vector<wchar_t> system_path_buffer(MAX_PATH);
990 std::vector<wchar_t> rundll_exe_path_buffer(MAX_PATH);
991 std::vector<wchar_t> inetcpl_path_buffer(MAX_PATH);
992 std::wstring args = L"";
993
994 UINT system_path_size = ::GetSystemDirectory(&system_path_buffer[0], MAX_PATH);
995
996 HANDLE process_token = NULL;
997 HANDLE mic_token = NULL;
998 PSID sid = NULL;
999
1000 bool can_create_process = true;
1001 if (!use_low_integrity_level ||
1002 this->CreateLowIntegrityLevelToken(&process_token, &mic_token, &sid)) {
1003 if (0 != system_path_size &&
1004 system_path_size <= static_cast<int>(system_path_buffer.size())) {
1005 if (::PathCombine(&rundll_exe_path_buffer[0],
1006 &system_path_buffer[0],
1007 RUNDLL_EXE_NAME) &&
1008 ::PathCombine(&inetcpl_path_buffer[0],
1009 &system_path_buffer[0],
1010 INTERNET_CONTROL_PANEL_APPLET_NAME)) {
1011 // PathCombine will return NULL if the buffer would be exceeded.
1012 ::PathQuoteSpaces(&rundll_exe_path_buffer[0]);
1013 ::PathQuoteSpaces(&inetcpl_path_buffer[0]);
1014 args = StringUtilities::Format(CLEAR_CACHE_COMMAND_LINE_ARGS,
1015 &inetcpl_path_buffer[0],
1016 CLEAR_CACHE_OPTIONS);
1017 } else {
1018 LOG(WARN) << "Cannot combine paths to utilities required to clear cache.";
1019 can_create_process = false;
1020 }
1021 } else {
1022 LOG(WARN) << "Paths system directory exceeds MAX_PATH.";
1023 can_create_process = false;
1024 }
1025
1026 if (can_create_process) {
1027 LOG(DEBUG) << "Launching inetcpl.cpl via rundll32.exe to clear cache";
1028 STARTUPINFO start_info;
1029 ::ZeroMemory(&start_info, sizeof(start_info));
1030 start_info.cb = sizeof(start_info);
1031
1032 PROCESS_INFORMATION process_info;
1033 BOOL is_process_created = FALSE;
1034 start_info.dwFlags = STARTF_USESHOWWINDOW;
1035 start_info.wShowWindow = SW_SHOWNORMAL;
1036
1037 std::vector<wchar_t> args_buffer(0);
1038 StringUtilities::ToBuffer(args, &args_buffer);
1039 // Create the process to run with low or medium rights
1040 if (use_low_integrity_level) {
1041 is_process_created = CreateProcessAsUser(mic_token,
1042 &rundll_exe_path_buffer[0],
1043 &args_buffer[0],

Callers 1

ClearCacheMethod · 0.95

Calls 3

LOGClass · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected