OLD | NEW |
1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
2 #include "PluginSettings.h" | 2 #include "PluginSettings.h" |
3 #include "PluginSystem.h" | 3 #include "PluginSystem.h" |
4 #include "PluginFilter.h" | 4 #include "PluginFilter.h" |
5 #include "PluginClientFactory.h" | 5 #include "PluginClientFactory.h" |
6 #include "PluginMutex.h" | 6 #include "PluginMutex.h" |
7 #include "PluginClass.h" | 7 #include "PluginClass.h" |
8 | 8 |
9 #include "AdblockPlusClient.h" | 9 #include "AdblockPlusClient.h" |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 else | 37 else |
38 { | 38 { |
39 throw std::runtime_error("Out of memory"); | 39 throw std::runtime_error("Out of memory"); |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 BOOL createProcRes = 0; | 43 BOOL createProcRes = 0; |
44 // Running inside AppContainer? | 44 // Running inside AppContainer? |
45 if (acs != NULL && acs->TokenAppContainer != NULL) | 45 if (acs != NULL && acs->TokenAppContainer != NULL) |
46 { | 46 { |
47 // Launch with default security. Registry entry will eat the user prompt | 47 // We need to break out from AppContainer. Launch with default security -
registry entry will eat the user prompt |
48 // See http://msdn.microsoft.com/en-us/library/bb250462(v=vs.85).aspx#wpm_
elebp | 48 // See http://msdn.microsoft.com/en-us/library/bb250462(v=vs.85).aspx#wpm_
elebp |
49 LPWSTR stringSid; | |
50 ConvertSidToStringSidW(acs->TokenAppContainer, &stringSid); | |
51 params.Append(L" "); | |
52 params.Append(stringSid); | |
53 LocalFree(stringSid); | |
54 createProcRes = CreateProcessW(engineExecutablePath.c_str(), params.GetBuf
fer(params.GetLength() + 1), | 49 createProcRes = CreateProcessW(engineExecutablePath.c_str(), params.GetBuf
fer(params.GetLength() + 1), |
55 0, 0, false, 0, 0, 0, (STARTUPINFOW*)&startupInfo,
&processInformation); | 50 0, 0, false, 0, 0, 0, (STARTUPINFOW*)&startupInfo,
&processInformation); |
56 } | 51 } |
57 else | 52 else |
58 { | 53 { |
59 // Launch with the same security token (Low Integrity) explicitly | 54 // Launch with Low Integrity explicitly |
60 HANDLE newToken; | 55 HANDLE newToken; |
61 DuplicateTokenEx(token, 0, 0, SecurityImpersonation, TokenPrimary, &newTok
en); | 56 DuplicateTokenEx(token, 0, 0, SecurityImpersonation, TokenPrimary, &newTok
en); |
62 | 57 |
| 58 PSID integritySid = 0; |
| 59 ConvertStringSidToSid(L"S-1-16-4096", &integritySid); |
| 60 std::tr1::shared_ptr<SID> sharedIntegritySid(static_cast<SID*>(integritySi
d), FreeSid); // Just to simplify cleanup |
| 61 |
| 62 TOKEN_MANDATORY_LABEL tml = {}; |
| 63 tml.Label.Attributes = SE_GROUP_INTEGRITY; |
| 64 tml.Label.Sid = integritySid; |
| 65 |
| 66 // Set the process integrity level |
| 67 SetTokenInformation(newToken, TokenIntegrityLevel, &tml, sizeof(TOKEN_MAND
ATORY_LABEL) + GetLengthSid(integritySid)); |
| 68 |
| 69 STARTUPINFO startupInfo = {}; |
| 70 PROCESS_INFORMATION processInformation = {}; |
| 71 |
63 createProcRes = CreateProcessAsUserW(newToken, engineExecutablePath.c_str(
), params.GetBuffer(params.GetLength() + 1), | 72 createProcRes = CreateProcessAsUserW(newToken, engineExecutablePath.c_str(
), params.GetBuffer(params.GetLength() + 1), |
64 0, 0, false, 0, 0, 0, (STARTUPINFOW*)&startupInfo,
&processInformation); | 73 0, 0, false, 0, 0, 0, (STARTUPINFOW*)&startupInfo,
&processInformation); |
65 } | 74 } |
66 | 75 |
67 if (!createProcRes) | 76 if (!createProcRes) |
68 { | 77 { |
69 throw std::runtime_error("Failed to start Adblock Plus Engine"); | 78 throw std::runtime_error("Failed to start Adblock Plus Engine"); |
70 } | 79 } |
71 | 80 |
72 CloseHandle(processInformation.hProcess); | 81 CloseHandle(processInformation.hProcess); |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 bool CAdblockPlusClient::TogglePluginEnabled() | 506 bool CAdblockPlusClient::TogglePluginEnabled() |
498 { | 507 { |
499 DEBUG_GENERAL("TogglePluginEnabled"); | 508 DEBUG_GENERAL("TogglePluginEnabled"); |
500 Communication::InputBuffer response; | 509 Communication::InputBuffer response; |
501 if (!CallEngine(Communication::PROC_TOGGLE_PLUGIN_ENABLED, response)) | 510 if (!CallEngine(Communication::PROC_TOGGLE_PLUGIN_ENABLED, response)) |
502 return false; | 511 return false; |
503 bool currentEnabledState; | 512 bool currentEnabledState; |
504 response >> currentEnabledState; | 513 response >> currentEnabledState; |
505 return currentEnabledState; | 514 return currentEnabledState; |
506 } | 515 } |
OLD | NEW |