| OLD | NEW |
| 1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
| 2 | 2 |
| 3 #include "PluginSettings.h" | 3 #include "PluginSettings.h" |
| 4 #include "PluginSystem.h" | 4 #include "PluginSystem.h" |
| 5 #include "PluginFilter.h" | 5 #include "PluginFilter.h" |
| 6 #include "PluginClientFactory.h" | 6 #include "PluginClientFactory.h" |
| 7 #include "PluginDictionary.h" | 7 #include "PluginDictionary.h" |
| 8 #include "PluginHttpRequest.h" | 8 #include "PluginHttpRequest.h" |
| 9 #include "PluginMutex.h" | 9 #include "PluginMutex.h" |
| 10 #include "PluginClass.h" | 10 #include "PluginClass.h" |
| 11 #include "PluginUtil.h" | 11 #include "PluginUtil.h" |
| 12 | 12 |
| 13 #include "AdblockPlusClient.h" | 13 #include "AdblockPlusClient.h" |
| 14 | 14 |
| 15 #include "../shared/AutoHandle.h" | 15 #include "../shared/AutoHandle.h" |
| 16 #include "../shared/Communication.h" | 16 #include "../shared/Communication.h" |
| 17 | 17 |
| 18 namespace | 18 namespace |
| 19 { | 19 { |
| 20 void SpawnAdblockPlusEngine() | 20 void SpawnAdblockPlusEngine() |
| 21 { | 21 { |
| 22 std::wstring engineExecutablePath = DllDir() + L"AdblockPlusEngine.exe"; | 22 std::wstring engineExecutablePath = DllDir() + L"AdblockPlusEngine.exe"; |
| 23 CString browserLanguage = CPluginSystem::GetInstance()->GetBrowserLanguage()
; |
| 23 STARTUPINFO startupInfo = {}; | 24 STARTUPINFO startupInfo = {}; |
| 24 PROCESS_INFORMATION processInformation = {}; | 25 PROCESS_INFORMATION processInformation = {}; |
| 25 | 26 |
| 26 HANDLE token; | 27 HANDLE token; |
| 27 OpenProcessToken(GetCurrentProcess(), TOKEN_DUPLICATE | TOKEN_ADJUST_DEFAULT
| TOKEN_QUERY | TOKEN_ASSIGN_PRIMARY, &token); | 28 OpenProcessToken(GetCurrentProcess(), TOKEN_DUPLICATE | TOKEN_ADJUST_DEFAULT
| TOKEN_QUERY | TOKEN_ASSIGN_PRIMARY, &token); |
| 28 HANDLE newToken; | 29 HANDLE newToken; |
| 29 DuplicateTokenEx(token, 0, 0, SecurityImpersonation, TokenPrimary, &newToken
); | 30 DuplicateTokenEx(token, 0, 0, SecurityImpersonation, TokenPrimary, &newToken
); |
| 30 | 31 |
| 31 if (!CreateProcessAsUser(newToken, 0, const_cast<wchar_t*>(engineExecutableP
ath.c_str()), 0, 0, 0, 0, 0, 0, | 32 if (!CreateProcessAsUserW(newToken, engineExecutablePath.c_str(), |
| 32 &startupInfo, &processInformation)) | 33 browserLanguage.GetBuffer(browserLanguage.GetLengt
h() + 1), |
| 34 0, 0, 0, 0, 0, 0, &startupInfo, &processInformatio
n)) |
| 33 { | 35 { |
| 34 DWORD error = GetLastError(); | 36 DWORD error = GetLastError(); |
| 35 throw std::runtime_error("Failed to start Adblock Plus Engine"); | 37 throw std::runtime_error("Failed to start Adblock Plus Engine"); |
| 36 } | 38 } |
| 37 | 39 |
| 38 CloseHandle(processInformation.hProcess); | 40 CloseHandle(processInformation.hProcess); |
| 39 CloseHandle(processInformation.hThread); | 41 CloseHandle(processInformation.hThread); |
| 40 } | 42 } |
| 41 | 43 |
| 42 std::auto_ptr<Communication::Pipe> OpenAdblockPlusEnginePipe() | 44 std::auto_ptr<Communication::Pipe> OpenAdblockPlusEnginePipe() |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 try | 364 try |
| 363 { | 365 { |
| 364 CallAdblockPlusEngineProcedure(request); | 366 CallAdblockPlusEngineProcedure(request); |
| 365 } | 367 } |
| 366 catch (const std::exception& e) | 368 catch (const std::exception& e) |
| 367 { | 369 { |
| 368 DEBUG_GENERAL(e.what()); | 370 DEBUG_GENERAL(e.what()); |
| 369 } | 371 } |
| 370 } | 372 } |
| 371 | 373 |
| OLD | NEW |