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

Function _tmain

cpp/iedriverserver/IEDriverServer.cpp:191–350  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189}
190
191int _tmain(int argc, _TCHAR* argv[]) {
192 CommandLineArguments args(argc, argv);
193 if (args.is_help_requested()) {
194 ShowUsage();
195 return 0;
196 }
197 vector<TCHAR> temp_file_name_buffer(MAX_PATH);
198 vector<TCHAR> temp_path_buffer(MAX_PATH);
199
200 // Gets the temp path env string (no guarantee it's a valid path).
201 unsigned long temp_path_length = ::GetTempPath(MAX_PATH,
202 &temp_path_buffer[0]);
203
204 std::wstring extraction_path(&temp_path_buffer[0]);
205
206 std::wstring extraction_path_arg = args.GetValue(EXTRACTPATH_COMMAND_LINE_ARG, L"");
207 if (extraction_path_arg.size() != 0) {
208 extraction_path = extraction_path_arg;
209 }
210
211 if (extraction_path.size() > 0 &&
212 extraction_path[extraction_path.size() - 1] != L'\\') {
213 extraction_path.append(L"\\");
214 }
215
216 std::wstring initial_file = extraction_path + TEMP_FILE_PREFIX + L".tmp";
217 std::wstring temp_file_name = initial_file;
218 WIN32_FIND_DATA find_file_data;
219 HANDLE file_handle = ::FindFirstFile(initial_file.c_str(), &find_file_data);
220 if (file_handle != INVALID_HANDLE_VALUE) {
221 ::FindClose(file_handle);
222 unsigned int error_code = ::GetTempFileName(extraction_path.c_str(),
223 TEMP_FILE_PREFIX,
224 0,
225 &temp_file_name_buffer[0]);
226
227 temp_file_name = &temp_file_name_buffer[0];
228 }
229
230 if (!ExtractResource(IDR_DRIVER_LIBRARY, temp_file_name)) {
231 std::wcout << L"Failed to extract the library to temp directory: "
232 << temp_file_name;
233 return ERR_DLL_EXTRACT_FAIL;
234 }
235
236 HMODULE module_handle = ::LoadLibrary(temp_file_name.c_str());
237 if (module_handle == NULL) {
238 std::wcout << L"Failed to load the library from temp directory: "
239 << temp_file_name;
240 return ERR_DLL_LOAD_FAIL;
241 }
242
243 STARTSERVERPROC start_server_ex_proc = reinterpret_cast<STARTSERVERPROC>(
244 ::GetProcAddress(module_handle, START_SERVER_EX_API_NAME));
245 STOPSERVERPROC stop_server_proc = reinterpret_cast<STOPSERVERPROC>(
246 ::GetProcAddress(module_handle, STOP_SERVER_API_NAME));
247 if (start_server_ex_proc == NULL || stop_server_proc == NULL) {
248 std::wcout << L"Could not find entry point in extracted library: "

Callers

nothing calls this directly

Calls 10

ShowUsageFunction · 0.85
ExtractResourceFunction · 0.85
GetExecutableVersionFunction · 0.85
is_help_requestedMethod · 0.80
endMethod · 0.80
is_version_requestedMethod · 0.80
GetValueMethod · 0.45
sizeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected