LEFT | RIGHT |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 #ifndef COMMUNICATION_H | 18 #ifndef COMMUNICATION_H |
19 #define COMMUNICATION_H | 19 #define COMMUNICATION_H |
20 | 20 |
21 #include <memory> | 21 #include <memory> |
22 #include <sstream> | 22 #include <sstream> |
23 #include <stdexcept> | 23 #include <stdexcept> |
24 #include <stdint.h> | 24 #include <stdint.h> |
25 #include <string> | 25 #include <string> |
26 #include <vector> | 26 #include <vector> |
27 #include <Windows.h> | 27 #include <Windows.h> |
28 #include "Utils.h" | 28 #include "Utils.h" |
29 | 29 |
30 namespace Communication | 30 namespace Communication |
31 { | 31 { |
32 extern const std::wstring pipeName; | 32 extern const std::wstring pipeName; |
33 extern std::wstring browserSID; | 33 extern std::wstring browserSID; |
34 | 34 |
35 enum ProcType : uint32_t { | 35 enum ProcType : uint32_t { |
36 PROC_MATCHES, | 36 PROC_MATCHES, |
37 PROC_GET_ELEMHIDE_SELECTORS, | 37 PROC_GET_ELEMHIDE_SELECTORS, |
38 PROC_AVAILABLE_SUBSCRIPTIONS, | 38 PROC_AVAILABLE_SUBSCRIPTIONS, |
39 PROC_LISTED_SUBSCRIPTIONS, | 39 PROC_LISTED_SUBSCRIPTIONS, |
40 PROC_SET_SUBSCRIPTION, | 40 PROC_SET_SUBSCRIPTION, |
41 PROC_ADD_SUBSCRIPTION, | 41 PROC_ADD_SUBSCRIPTION, |
42 PROC_REMOVE_SUBSCRIPTION, | 42 PROC_REMOVE_SUBSCRIPTION, |
43 PROC_UPDATE_ALL_SUBSCRIPTIONS, | 43 PROC_UPDATE_ALL_SUBSCRIPTIONS, |
44 PROC_GET_EXCEPTION_DOMAINS, | 44 PROC_GET_EXCEPTION_DOMAINS, |
45 PROC_IS_WHITELISTED_URL, | 45 PROC_GET_WHITELISTING_FITER, |
46 PROC_IS_ELEMHIDE_WHITELISTED_ON_URL, | 46 PROC_IS_ELEMHIDE_WHITELISTED_ON_URL, |
47 PROC_ADD_FILTER, | 47 PROC_ADD_FILTER, |
48 PROC_REMOVE_FILTER, | 48 PROC_REMOVE_FILTER, |
49 PROC_SET_PREF, | 49 PROC_SET_PREF, |
50 PROC_GET_PREF, | 50 PROC_GET_PREF, |
51 PROC_IS_FIRST_RUN_ACTION_NEEDED, | 51 PROC_IS_FIRST_RUN_ACTION_NEEDED, |
52 PROC_CHECK_FOR_UPDATES, | 52 PROC_CHECK_FOR_UPDATES, |
53 PROC_GET_DOCUMENTATION_LINK, | 53 PROC_GET_DOCUMENTATION_LINK, |
54 PROC_TOGGLE_PLUGIN_ENABLED, | 54 PROC_TOGGLE_PLUGIN_ENABLED, |
55 PROC_GET_HOST, | 55 PROC_GET_HOST, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 InputBuffer& ReadString(std::string& value) | 109 InputBuffer& ReadString(std::string& value) |
110 { | 110 { |
111 CheckType(TYPE_STRING); | 111 CheckType(TYPE_STRING); |
112 | 112 |
113 SizeType length; | 113 SizeType length; |
114 ReadBinary(length); | 114 ReadBinary(length); |
115 value.resize(length); | 115 value.resize(length); |
116 if (length > 0) | 116 if (length > 0) |
117 { | 117 { |
118 buffer.read(&value[0], length); | 118 buffer.read(&value[0], length); |
| 119 if (buffer.fail()) |
| 120 throw new std::runtime_error("Unexpected end of input buffer"); |
119 } | 121 } |
120 if (buffer.fail()) | |
121 throw new std::runtime_error("Unexpected end of input buffer"); | |
122 return *this; | 122 return *this; |
123 } | 123 } |
124 | 124 |
125 InputBuffer& ReadStrings(std::vector<std::string>& value) | 125 InputBuffer& ReadStrings(std::vector<std::string>& value) |
126 { | 126 { |
127 value.clear(); | 127 value.clear(); |
128 CheckType(ValueType::TYPE_STRINGS); | 128 CheckType(ValueType::TYPE_STRINGS); |
129 | 129 |
130 SizeType length; | 130 SizeType length; |
131 ReadBinary(length); | 131 ReadBinary(length); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 252 |
253 InputBuffer ReadMessage(); | 253 InputBuffer ReadMessage(); |
254 void WriteMessage(OutputBuffer& message); | 254 void WriteMessage(OutputBuffer& message); |
255 | 255 |
256 protected: | 256 protected: |
257 HANDLE pipe; | 257 HANDLE pipe; |
258 }; | 258 }; |
259 } | 259 } |
260 | 260 |
261 #endif | 261 #endif |
LEFT | RIGHT |