Showing
63 changed files
with
0 additions
and
4376 deletions
gui/PointerTable.h
deleted
100644 → 0
1 | -/* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com) | ||
2 | - * This file is part of the Interactive Text Hooker. | ||
3 | - | ||
4 | - * Interactive Text Hooker is free software: you can redistribute it and/or | ||
5 | - * modify it under the terms of the GNU General Public License as published | ||
6 | - * by the Free Software Foundation, either version 3 of the License, or | ||
7 | - * (at your option) any later version. | ||
8 | - | ||
9 | - * This program is distributed in the hope that it will be useful, | ||
10 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | - * GNU General Public License for more details. | ||
13 | - | ||
14 | - * You should have received a copy of the GNU General Public License | ||
15 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | - */ | ||
17 | - | ||
18 | -#pragma once | ||
19 | - | ||
20 | -template <class T, unsigned int default_size> | ||
21 | -class PointerTable | ||
22 | -{ | ||
23 | -public: | ||
24 | - PointerTable() | ||
25 | - { | ||
26 | - assert((default_size & (default_size - 1)) == 0); | ||
27 | - size = default_size; | ||
28 | - table = new T*[size]; | ||
29 | - used = 0; | ||
30 | - next = 0; | ||
31 | - memset(table, 0, size * sizeof(T*)); | ||
32 | - } | ||
33 | - ~PointerTable() | ||
34 | - { | ||
35 | - delete table; | ||
36 | - } | ||
37 | - T* Set(unsigned int number, T* ptr) | ||
38 | - { | ||
39 | - if (number >= size - 2) | ||
40 | - { | ||
41 | - unsigned int new_size = size; | ||
42 | - while (number >= new_size - 2) new_size <<= 1; | ||
43 | - Resize(new_size); | ||
44 | - } | ||
45 | - T* original = table[number + 1]; | ||
46 | - table[number + 1] = ptr; | ||
47 | - if (ptr == 0) //Clear pointer. | ||
48 | - { | ||
49 | - if (number < next) next = number; | ||
50 | - if (number == used - 1) //Last used position is cleared. | ||
51 | - { | ||
52 | - table[0] = (T*)1; | ||
53 | - for (used--; table[used] == 0; used--); | ||
54 | - } | ||
55 | - } | ||
56 | - else //Set pointer. | ||
57 | - { | ||
58 | - __assume(number < size - 2); //Otherwise a resize operation is invoked. | ||
59 | - if (number == next) | ||
60 | - { | ||
61 | - next++; //Next position is occupied. | ||
62 | - for (next++; table[next]; next++); //There is always a zero in the end. | ||
63 | - next--; //next is zero based but the table start at one(zero is used as sentry). | ||
64 | - } | ||
65 | - if (number >= used) used = number + 1; | ||
66 | - } | ||
67 | - return original; | ||
68 | - } | ||
69 | - T* Get(unsigned int number) | ||
70 | - { | ||
71 | - number++; | ||
72 | - if (number <= used) return table[number]; | ||
73 | - else return 0; | ||
74 | - } | ||
75 | - T* operator [](unsigned int number) | ||
76 | - { | ||
77 | - number++; | ||
78 | - if (number <= used) return table[number]; | ||
79 | - else return 0; | ||
80 | - } | ||
81 | - void Append(T* ptr) | ||
82 | - { | ||
83 | - Set(next,ptr); | ||
84 | - } | ||
85 | - void Resize(unsigned int new_size) | ||
86 | - { | ||
87 | - assert(new_size > size); | ||
88 | - assert((new_size & (new_size - 1)) == 0); | ||
89 | - assert(new_size < 0x10000); | ||
90 | - | ||
91 | - T** temp = new T*[new_size]; | ||
92 | - memcpy(temp, table, size * sizeof(T*)); | ||
93 | - memset(temp + size, 0, (new_size - size) * sizeof(T*)); | ||
94 | - delete table; | ||
95 | - size = new_size; | ||
96 | - table = temp; | ||
97 | - } | ||
98 | - void DeleteAll() //Release all pointers on demand. | ||
99 | - { | ||
100 | - T* p; | ||
101 | - next = 0; | ||
102 | - while (used) | ||
103 | - { | ||
104 | - p = table[used]; | ||
105 | - if (p) delete p; | ||
106 | - table[used] = 0; | ||
107 | - used--; | ||
108 | - } | ||
109 | - } | ||
110 | - void Reset() //Reset without release pointers. | ||
111 | - { | ||
112 | - memset(table, 0, sizeof(T*) * (used + 1)); | ||
113 | - next = 0; | ||
114 | - used = 0; | ||
115 | - | ||
116 | - } | ||
117 | - unsigned int size,next,used; | ||
118 | - T** table; | ||
119 | -}; |
gui/Profile.cpp
deleted
100644 → 0
1 | -/* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com) | ||
2 | - * This file is part of the Interactive Text Hooker. | ||
3 | - | ||
4 | - * Interactive Text Hooker is free software: you can redistribute it and/or | ||
5 | - * modify it under the terms of the GNU General Public License as published | ||
6 | - * by the Free Software Foundation, either version 3 of the License, or | ||
7 | - * (at your option) any later version. | ||
8 | - | ||
9 | - * This program is distributed in the hope that it will be useful, | ||
10 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | - * GNU General Public License for more details. | ||
13 | - | ||
14 | - * You should have received a copy of the GNU General Public License | ||
15 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | - */ | ||
17 | - | ||
18 | - | ||
19 | -#include "ITH.h" | ||
20 | -#include "ith/host/srv.h" | ||
21 | -#include "ith/host/hookman.h" | ||
22 | -#include "ith/common/types.h" | ||
23 | -#include "ith/common/const.h" | ||
24 | -#include "Profile.h" | ||
25 | -#include "utility.h" | ||
26 | - | ||
27 | -Profile::Profile(const std::wstring& title) : | ||
28 | -select_index(-1), | ||
29 | -title(title) | ||
30 | -{} | ||
31 | - | ||
32 | -std::vector<thread_ptr>::const_iterator Profile::FindThreadProfile(const ThreadParameter& tp) const | ||
33 | -{ | ||
34 | - auto thread_profile = std::find_if(threads.begin(), threads.end(), | ||
35 | - [&tp](const thread_ptr& thread_profile) -> bool | ||
36 | - { | ||
37 | - if (thread_profile->HookAddress() != tp.hook) | ||
38 | - return false; | ||
39 | - DWORD t1 = thread_profile->Return(); | ||
40 | - DWORD t2 = tp.retn; | ||
41 | - if (thread_profile->Flags() & THREAD_MASK_RETN) | ||
42 | - { | ||
43 | - t1 &= 0xFFFF; | ||
44 | - t2 &= 0xFFFF; | ||
45 | - } | ||
46 | - if (t1 != t2) | ||
47 | - return false; | ||
48 | - t1 = thread_profile->Split(); | ||
49 | - t2 = tp.spl; | ||
50 | - if (thread_profile->Flags() & THREAD_MASK_SPLIT) | ||
51 | - { | ||
52 | - t1 &= 0xFFFF; | ||
53 | - t2 &= 0xFFFF; | ||
54 | - } | ||
55 | - return t1 == t2; | ||
56 | - }); | ||
57 | - return thread_profile; | ||
58 | -} | ||
59 | - | ||
60 | -const std::vector<hook_ptr>& Profile::Hooks() const | ||
61 | -{ | ||
62 | - return hooks; | ||
63 | -} | ||
64 | - | ||
65 | -const std::vector<thread_ptr>& Profile::Threads() const | ||
66 | -{ | ||
67 | - return threads; | ||
68 | -} | ||
69 | - | ||
70 | -const std::vector<link_ptr>& Profile::Links() const | ||
71 | -{ | ||
72 | - return links; | ||
73 | -} | ||
74 | - | ||
75 | -bool Profile::XmlReadProfile(pugi::xml_node profile) | ||
76 | -{ | ||
77 | - auto hooks_node = profile.child(L"Hooks"); | ||
78 | - auto threads_node = profile.child(L"Threads"); | ||
79 | - auto links_node = profile.child(L"Links"); | ||
80 | - if (hooks_node && !XmlReadProfileHook(hooks_node)) | ||
81 | - return false; | ||
82 | - if (threads_node && !XmlReadProfileThread(threads_node)) | ||
83 | - return false; | ||
84 | - if (links_node && !XmlReadProfileLink(links_node)) | ||
85 | - return false; | ||
86 | - auto select_node = profile.child(L"Select"); | ||
87 | - if (select_node) | ||
88 | - { | ||
89 | - auto thread_index = select_node.attribute(L"ThreadIndex"); | ||
90 | - if (!thread_index) | ||
91 | - return false; | ||
92 | - DWORD tmp_select = std::stoul(thread_index.value(), NULL, 16); | ||
93 | - select_index = tmp_select & 0xFFFF; | ||
94 | - } | ||
95 | - return true; | ||
96 | -} | ||
97 | - | ||
98 | -bool Profile::XmlReadProfileHook(pugi::xml_node hooks_node) | ||
99 | -{ | ||
100 | - for (auto hook = hooks_node.begin(); hook != hooks_node.end(); ++hook) | ||
101 | - { | ||
102 | - std::wstring name = hook->name(); | ||
103 | - if (name.empty() || name.compare(L"Hook") != 0) | ||
104 | - return false; | ||
105 | - auto type = hook->attribute(L"Type"); | ||
106 | - if (!type || type.empty()) | ||
107 | - return false; | ||
108 | - auto code = hook->attribute(L"Code"); | ||
109 | - if (!code) | ||
110 | - return false; | ||
111 | - std::wstring code_value = code.value(); | ||
112 | - HookParam hp = {}; | ||
113 | - switch (type.value()[0]) | ||
114 | - { | ||
115 | - case L'H': | ||
116 | - if (code_value[0] != L'/') | ||
117 | - return false; | ||
118 | - if (code_value[1] != L'H' && code_value[1] != L'h') | ||
119 | - return false; | ||
120 | - if (Parse(code_value.substr(2), hp)) | ||
121 | - { | ||
122 | - auto name = hook->attribute(L"Name"); | ||
123 | - if (!name || name.empty()) | ||
124 | - AddHook(hp, L""); | ||
125 | - else | ||
126 | - AddHook(hp, name.value()); | ||
127 | - } | ||
128 | - break; | ||
129 | - default: | ||
130 | - return false; | ||
131 | - } | ||
132 | - } | ||
133 | - return true; | ||
134 | -} | ||
135 | - | ||
136 | -bool Profile::XmlReadProfileThread(pugi::xml_node threads_node) | ||
137 | -{ | ||
138 | - std::wstring hook_name_buffer; | ||
139 | - for (auto thread = threads_node.begin(); thread != threads_node.end(); ++thread) | ||
140 | - { | ||
141 | - std::wstring name = thread->name(); | ||
142 | - if (name.empty() || name.compare(L"Thread") != 0) | ||
143 | - return false; | ||
144 | - auto hook_name = thread->attribute(L"HookName"); | ||
145 | - if (!hook_name) | ||
146 | - return false; | ||
147 | - auto context = thread->attribute(L"Context"); | ||
148 | - if (!context) | ||
149 | - return false; | ||
150 | - auto sub_context = thread->attribute(L"SubContext"); | ||
151 | - if (!sub_context) | ||
152 | - return false; | ||
153 | - auto mask = thread->attribute(L"Mask"); | ||
154 | - if (!mask) | ||
155 | - return false; | ||
156 | - DWORD mask_tmp = std::stoul(mask.value(), NULL, 16); | ||
157 | - auto comment = thread->attribute(L"Comment"); | ||
158 | - auto retn = std::stoul(context.value(), NULL, 16); | ||
159 | - WORD hm_index = 0; | ||
160 | - auto hook_addr = 0; | ||
161 | - auto split = std::stoul(sub_context.value(), NULL, 16); | ||
162 | - WORD flags = mask_tmp & 0xFFFF; | ||
163 | - auto tp = new ThreadProfile(hook_name.value(), retn, split, hook_addr, hm_index, flags, | ||
164 | - comment.value()); | ||
165 | - AddThread(thread_ptr(tp)); | ||
166 | - } | ||
167 | - return true; | ||
168 | -} | ||
169 | - | ||
170 | -bool Profile::XmlReadProfileLink(pugi::xml_node links_node) | ||
171 | -{ | ||
172 | - for (auto link = links_node.begin(); link != links_node.end(); ++link) | ||
173 | - { | ||
174 | - std::wstring name = link->name(); | ||
175 | - if (name.empty() || name.compare(L"Link") != 0) | ||
176 | - return false; | ||
177 | - auto from = link->attribute(L"From"); | ||
178 | - if (!from) | ||
179 | - return false; | ||
180 | - DWORD link_from = std::stoul(from.value(), NULL, 16); | ||
181 | - auto to = link->attribute(L"To"); | ||
182 | - if (!to) | ||
183 | - return false; | ||
184 | - DWORD link_to = std::stoul(to.value(), NULL, 16); | ||
185 | - auto lp = new LinkProfile(link_from & 0xFFFF, link_to & 0xFFFF); | ||
186 | - AddLink(link_ptr(lp)); | ||
187 | - } | ||
188 | - return true; | ||
189 | -} | ||
190 | - | ||
191 | -bool Profile::XmlWriteProfile(pugi::xml_node profile_node) | ||
192 | -{ | ||
193 | - if (!hooks.empty()) | ||
194 | - { | ||
195 | - auto node = profile_node.append_child(L"Hooks"); | ||
196 | - XmlWriteProfileHook(node); | ||
197 | - } | ||
198 | - if (!threads.empty()) | ||
199 | - { | ||
200 | - auto node = profile_node.append_child(L"Threads"); | ||
201 | - XmlWriteProfileThread(node); | ||
202 | - } | ||
203 | - if (!links.empty()) | ||
204 | - { | ||
205 | - auto node = profile_node.append_child(L"Links"); | ||
206 | - XmlWriteProfileLink(node); | ||
207 | - } | ||
208 | - if (select_index != 0xFFFF) | ||
209 | - { | ||
210 | - auto node = profile_node.append_child(L"Select"); | ||
211 | - node.append_attribute(L"ThreadIndex") = select_index; | ||
212 | - } | ||
213 | - return true; | ||
214 | -} | ||
215 | - | ||
216 | -bool Profile::XmlWriteProfileHook(pugi::xml_node hooks_node) | ||
217 | -{ | ||
218 | - for (auto hook = hooks.begin(); hook != hooks.end(); ++hook) | ||
219 | - { | ||
220 | - auto hook_node = hooks_node.append_child(L"Hook"); | ||
221 | - hook_node.append_attribute(L"Type") = L"H"; | ||
222 | - hook_node.append_attribute(L"Code") = GetCode((*hook)->HP()).c_str(); | ||
223 | - if (!(*hook)->Name().empty()) | ||
224 | - hook_node.append_attribute(L"Name") = (*hook)->Name().c_str(); | ||
225 | - } | ||
226 | - return true; | ||
227 | -} | ||
228 | - | ||
229 | -bool Profile::XmlWriteProfileThread(pugi::xml_node threads_node) | ||
230 | -{ | ||
231 | - for (auto thread = threads.begin(); thread != threads.end(); ++thread) | ||
232 | - { | ||
233 | - const std::wstring& name = (*thread)->HookName(); | ||
234 | - if (name.empty()) | ||
235 | - return false; | ||
236 | - auto node = threads_node.append_child(L"Thread"); | ||
237 | - node.append_attribute(L"HookName") = name.c_str(); | ||
238 | - node.append_attribute(L"Mask") = ToHexString((*thread)->Flags() & 3).c_str(); | ||
239 | - node.append_attribute(L"SubContext") = ToHexString((*thread)->Split()).c_str(); | ||
240 | - node.append_attribute(L"Context") = ToHexString((*thread)->Return()).c_str(); | ||
241 | - if (!(*thread)->Comment().empty()) | ||
242 | - node.append_attribute(L"Comment") = (*thread)->Comment().c_str(); | ||
243 | - } | ||
244 | - return true; | ||
245 | -} | ||
246 | - | ||
247 | -bool Profile::XmlWriteProfileLink(pugi::xml_node links_node) | ||
248 | -{ | ||
249 | - for (auto link = links.begin(); link != links.end(); ++link) | ||
250 | - { | ||
251 | - auto node = links_node.append_child(L"Link"); | ||
252 | - node.append_attribute(L"From") = ToHexString((*link)->FromIndex()).c_str(); | ||
253 | - node.append_attribute(L"To") = ToHexString((*link)->ToIndex()).c_str(); | ||
254 | - } | ||
255 | - return true; | ||
256 | -} | ||
257 | - | ||
258 | -void Profile::Clear() | ||
259 | -{ | ||
260 | - title = L""; | ||
261 | - select_index = -1; | ||
262 | - hooks.clear(); | ||
263 | - threads.clear(); | ||
264 | - links.clear(); | ||
265 | -} | ||
266 | - | ||
267 | -int Profile::AddHook(const HookParam& hp, const std::wstring& name) | ||
268 | -{ | ||
269 | - //if (hook_count == 4) return; | ||
270 | - auto it = std::find_if(hooks.begin(), hooks.end(), [&hp](hook_ptr& hook) | ||
271 | - { | ||
272 | - return hook->HP().addr == hp.addr && | ||
273 | - hook->HP().module == hp.module && | ||
274 | - hook->HP().function == hp.function; | ||
275 | - }); | ||
276 | - if (it != hooks.end()) | ||
277 | - return it - hooks.begin(); | ||
278 | - hooks.emplace_back(new HookProfile(hp, name)); | ||
279 | - return hooks.size() - 1; | ||
280 | -} | ||
281 | - | ||
282 | -// add the thread profile and return its index | ||
283 | -int Profile::AddThread(thread_ptr tp) | ||
284 | -{ | ||
285 | - auto it = std::find_if(threads.begin(), threads.end(), [&tp](thread_ptr& thread) | ||
286 | - { | ||
287 | - return thread->HookName().compare(tp->HookName()) == 0 && | ||
288 | - thread->Return() == tp->Return() && | ||
289 | - thread->Split() == tp->Split(); | ||
290 | - }); | ||
291 | - if (it != threads.end()) | ||
292 | - return it - threads.begin(); | ||
293 | - threads.push_back(std::move(tp)); | ||
294 | - return threads.size() - 1; | ||
295 | -} | ||
296 | - | ||
297 | -int Profile::AddLink(link_ptr lp) | ||
298 | -{ | ||
299 | - auto it = std::find_if(links.begin(), links.end(), [&lp] (link_ptr& link) | ||
300 | - { | ||
301 | - return link->FromIndex() == lp->FromIndex() && | ||
302 | - link->ToIndex() == lp->ToIndex(); | ||
303 | - }); | ||
304 | - if (it != links.end()) | ||
305 | - return it - links.begin(); | ||
306 | - links.push_back(std::move(lp)); | ||
307 | - return links.size() - 1; | ||
308 | -} | ||
309 | - | ||
310 | -void Profile::RemoveHook(DWORD index) | ||
311 | -{ | ||
312 | - if (index >= 0 && index < hooks.size()) | ||
313 | - hooks.erase(hooks.begin() + index); | ||
314 | -} | ||
315 | - | ||
316 | -void Profile::RemoveThread(DWORD index) | ||
317 | -{ | ||
318 | - if (index >= 0 && index < threads.size()) | ||
319 | - { | ||
320 | - links.erase(std::remove_if(links.begin(), links.end(), [index](link_ptr& link) | ||
321 | - { | ||
322 | - return link->FromIndex() == index + 1 || link->ToIndex() == index + 1; | ||
323 | - }), links.end()); | ||
324 | - if (select_index == index) | ||
325 | - select_index = -1; | ||
326 | - threads.erase(threads.begin() + index); | ||
327 | - if (index < select_index) | ||
328 | - select_index--; | ||
329 | - } | ||
330 | -} | ||
331 | - | ||
332 | -void Profile::RemoveLink(DWORD index) | ||
333 | -{ | ||
334 | - if (index >= 0 && index < links.size()) | ||
335 | - links.erase(links.begin() + index); | ||
336 | -} | ||
337 | - | ||
338 | -const std::wstring& Profile::Title() const | ||
339 | -{ | ||
340 | - return title; | ||
341 | -} |
gui/Profile.h
deleted
100644 → 0
1 | -/* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com) | ||
2 | - * This file is part of the Interactive Text Hooker. | ||
3 | - | ||
4 | - * Interactive Text Hooker is free software: you can redistribute it and/or | ||
5 | - * modify it under the terms of the GNU General Public License as published | ||
6 | - * by the Free Software Foundation, either version 3 of the License, or | ||
7 | - * (at your option) any later version. | ||
8 | - | ||
9 | - * This program is distributed in the hope that it will be useful, | ||
10 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | - * GNU General Public License for more details. | ||
13 | - | ||
14 | - * You should have received a copy of the GNU General Public License | ||
15 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | - */ | ||
17 | - | ||
18 | -#pragma once | ||
19 | -#include "ITH.h" | ||
20 | -#include "ith/common/types.h" // HookParam | ||
21 | - | ||
22 | -struct ThreadParameter; | ||
23 | - | ||
24 | -#define THREAD_MASK_RETN 1 | ||
25 | -#define THREAD_MASK_SPLIT 2 | ||
26 | - | ||
27 | -class HookProfile | ||
28 | -{ | ||
29 | - HookParam hp; | ||
30 | - std::wstring name; | ||
31 | -public: | ||
32 | - HookProfile(const HookParam& hp, const std::wstring& name): | ||
33 | - hp(hp), | ||
34 | - name(name) | ||
35 | - {} | ||
36 | - const HookParam& HP() const { return hp; }; | ||
37 | - const std::wstring& Name() const { return name; }; | ||
38 | -}; | ||
39 | - | ||
40 | -class ThreadProfile | ||
41 | -{ | ||
42 | - std::wstring hook_name; | ||
43 | - DWORD retn; | ||
44 | - DWORD split; | ||
45 | - DWORD hook_addr; | ||
46 | - WORD hm_index, flags; | ||
47 | - std::wstring comment; | ||
48 | -public: | ||
49 | - ThreadProfile(const std::wstring& hook_name, | ||
50 | - DWORD retn, | ||
51 | - DWORD split, | ||
52 | - DWORD hook_addr, | ||
53 | - WORD hm_index, | ||
54 | - WORD flags, | ||
55 | - const std::wstring& comment) : | ||
56 | - hook_name(hook_name), | ||
57 | - retn(retn), | ||
58 | - split(split), | ||
59 | - hook_addr(hook_addr), | ||
60 | - hm_index(hm_index), | ||
61 | - flags(flags), | ||
62 | - comment(comment) | ||
63 | - { | ||
64 | - } | ||
65 | - const std::wstring& HookName() const { return hook_name; } | ||
66 | - const std::wstring& Comment() const { return comment; } | ||
67 | - DWORD Return() const { return retn; } | ||
68 | - DWORD Split() const { return split; } | ||
69 | - DWORD& HookAddress() { return hook_addr; } | ||
70 | - WORD& HookManagerIndex() { return hm_index; } | ||
71 | - WORD Flags() const { return flags; } | ||
72 | -}; | ||
73 | - | ||
74 | -class LinkProfile | ||
75 | -{ | ||
76 | - WORD from_index, to_index; | ||
77 | -public: | ||
78 | - LinkProfile(WORD from_index, WORD to_index): | ||
79 | - from_index(from_index), | ||
80 | - to_index(to_index) | ||
81 | - {} | ||
82 | - WORD FromIndex() const { return from_index; } | ||
83 | - WORD ToIndex() const { return to_index; } | ||
84 | -}; | ||
85 | - | ||
86 | -typedef std::unique_ptr<HookProfile> hook_ptr; | ||
87 | -typedef std::unique_ptr<ThreadProfile> thread_ptr; | ||
88 | -typedef std::unique_ptr<LinkProfile> link_ptr; | ||
89 | - | ||
90 | -class Profile | ||
91 | -{ | ||
92 | -public: | ||
93 | - Profile(const std::wstring& title); | ||
94 | - bool XmlReadProfile(pugi::xml_node profile_node); | ||
95 | - bool XmlWriteProfile(pugi::xml_node profile_node); | ||
96 | - int AddHook(const HookParam& hp, const std::wstring& name); | ||
97 | - int AddThread(thread_ptr tp); | ||
98 | - int AddLink(link_ptr lp); | ||
99 | - void Clear(); | ||
100 | - const std::vector<hook_ptr>& Hooks() const; | ||
101 | - const std::vector<thread_ptr>& Threads() const; | ||
102 | - const std::vector<link_ptr>& Links() const; | ||
103 | - const std::wstring& Title() const; | ||
104 | - std::vector<thread_ptr>::const_iterator FindThreadProfile(const ThreadParameter& tp) const; | ||
105 | - WORD& SelectedIndex() { return select_index; } | ||
106 | - | ||
107 | -private: | ||
108 | - void RemoveLink(DWORD index); | ||
109 | - void RemoveHook(DWORD index); | ||
110 | - void RemoveThread(DWORD index); | ||
111 | - | ||
112 | - bool XmlReadProfileHook(pugi::xml_node hooks_node); | ||
113 | - bool XmlReadProfileThread(pugi::xml_node threads_node); | ||
114 | - bool XmlReadProfileLink(pugi::xml_node links_node); | ||
115 | - bool XmlWriteProfileHook(pugi::xml_node hooks_node); | ||
116 | - bool XmlWriteProfileThread(pugi::xml_node threads_node); | ||
117 | - bool XmlWriteProfileLink(pugi::xml_node links_node); | ||
118 | - | ||
119 | - std::wstring title; | ||
120 | - std::vector<hook_ptr> hooks; | ||
121 | - std::vector<thread_ptr> threads; | ||
122 | - std::vector<link_ptr> links; | ||
123 | - | ||
124 | - WORD select_index; | ||
125 | -}; |
gui/pugiconfig.hpp
deleted
100644 → 0
1 | -/** | ||
2 | - * pugixml parser - version 1.5 | ||
3 | - * -------------------------------------------------------- | ||
4 | - * Copyright (C) 2006-2014, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) | ||
5 | - * Report bugs and download new versions at http://pugixml.org/ | ||
6 | - * | ||
7 | - * This library is distributed under the MIT License. See notice at the end | ||
8 | - * of this file. | ||
9 | - * | ||
10 | - * This work is based on the pugxml parser, which is: | ||
11 | - * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) | ||
12 | - */ | ||
13 | - | ||
14 | -#ifndef HEADER_PUGICONFIG_HPP | ||
15 | -#define HEADER_PUGICONFIG_HPP | ||
16 | - | ||
17 | -// Uncomment this to enable wchar_t mode | ||
18 | -#define PUGIXML_WCHAR_MODE | ||
19 | - | ||
20 | -// Uncomment this to disable XPath | ||
21 | -// #define PUGIXML_NO_XPATH | ||
22 | - | ||
23 | -// Uncomment this to disable STL | ||
24 | -// #define PUGIXML_NO_STL | ||
25 | - | ||
26 | -// Uncomment this to disable exceptions | ||
27 | -// #define PUGIXML_NO_EXCEPTIONS | ||
28 | - | ||
29 | -// Set this to control attributes for public classes/functions, i.e.: | ||
30 | -// #define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL | ||
31 | -// #define PUGIXML_CLASS __declspec(dllimport) // to import all classes from DLL | ||
32 | -// #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall | ||
33 | -// In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead | ||
34 | - | ||
35 | -// Tune these constants to adjust memory-related behavior | ||
36 | -// #define PUGIXML_MEMORY_PAGE_SIZE 32768 | ||
37 | -// #define PUGIXML_MEMORY_OUTPUT_STACK 10240 | ||
38 | -// #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096 | ||
39 | - | ||
40 | -// Uncomment this to switch to header-only version | ||
41 | -// #define PUGIXML_HEADER_ONLY | ||
42 | -// #include "pugixml.cpp" | ||
43 | - | ||
44 | -// Uncomment this to enable long long support | ||
45 | -// #define PUGIXML_HAS_LONG_LONG | ||
46 | - | ||
47 | -#endif | ||
48 | - | ||
49 | -/** | ||
50 | - * Copyright (c) 2006-2014 Arseny Kapoulkine | ||
51 | - * | ||
52 | - * Permission is hereby granted, free of charge, to any person | ||
53 | - * obtaining a copy of this software and associated documentation | ||
54 | - * files (the "Software"), to deal in the Software without | ||
55 | - * restriction, including without limitation the rights to use, | ||
56 | - * copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
57 | - * copies of the Software, and to permit persons to whom the | ||
58 | - * Software is furnished to do so, subject to the following | ||
59 | - * conditions: | ||
60 | - * | ||
61 | - * The above copyright notice and this permission notice shall be | ||
62 | - * included in all copies or substantial portions of the Software. | ||
63 | - * | ||
64 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
65 | - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
66 | - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
67 | - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
68 | - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
69 | - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
70 | - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
71 | - * OTHER DEALINGS IN THE SOFTWARE. | ||
72 | - */ |
gui/pugixml.cpp
deleted
100644 → 0
This diff could not be displayed because it is too large.
gui/pugixml.hpp
deleted
100644 → 0
This diff is collapsed. Click to expand it.
vnr/ith/common/common.pri
deleted
100644 → 0
1 | -# ith/common/common.pri | ||
2 | -# 8/9/2011 jichi | ||
3 | -# Overwrite ITH headers | ||
4 | - | ||
5 | -#DEFINES += ITH_HAS_CRT # whether ITH is linked with msvcrt | ||
6 | -#DEFINES += ITH_HAS_CXX # whether ITH has access to native C++ syntax | ||
7 | - | ||
8 | -DEPENDPATH += $$PWD | ||
9 | - | ||
10 | -HEADERS += \ | ||
11 | - $$PWD/const.h \ | ||
12 | - $$PWD/defs.h \ | ||
13 | - $$PWD/except.h \ | ||
14 | - $$PWD/growl.h \ | ||
15 | - $$PWD/memory.h \ | ||
16 | - $$PWD/string.h \ | ||
17 | - $$PWD/types.h | ||
18 | - | ||
19 | -DEFINES += _CRT_NON_CONFORMING_SWPRINTFS | ||
20 | - | ||
21 | -# jichi 9/14/2013: Whether using SEH exception handle. | ||
22 | -# msvcrt on Windows XP is missin EH | ||
23 | -#DEFINES += ITH_HAS_SEH | ||
24 | - | ||
25 | -# jichi 9/22/2013: Whether let ITH manage heap | ||
26 | -#DEFINES += ITH_HAS_HEAP | ||
27 | - | ||
28 | -# EOF |
vnr/ith/common/const.h
deleted
100644 → 0
1 | -#pragma once | ||
2 | - | ||
3 | -// ith/common/const.h | ||
4 | -// 8/23/2013 jichi | ||
5 | -// Branch: ITH/common.h, rev 128 | ||
6 | - | ||
7 | -// jichi 9/9/2013: Another importnat function is lstrcatA, which is already handled by | ||
8 | -// Debonosu hooks. Wait until it is really needed by certain games. | ||
9 | -// The order of the functions is used in several place. | ||
10 | -// I need to recompile all of the dlls to modify the order. | ||
11 | -enum HookFunType { | ||
12 | - HF_Null = -1 | ||
13 | - , HF_GetTextExtentPoint32A | ||
14 | - , HF_GetGlyphOutlineA | ||
15 | - , HF_ExtTextOutA | ||
16 | - , HF_TextOutA | ||
17 | - , HF_GetCharABCWidthsA | ||
18 | - , HF_DrawTextA | ||
19 | - , HF_DrawTextExA | ||
20 | - //, HF_lstrlenA | ||
21 | - , HF_GetTextExtentPoint32W | ||
22 | - , HF_GetGlyphOutlineW | ||
23 | - , HF_ExtTextOutW | ||
24 | - , HF_TextOutW | ||
25 | - , HF_GetCharABCWidthsW | ||
26 | - , HF_DrawTextW | ||
27 | - , HF_DrawTextExW | ||
28 | - //, HF_lstrlenW | ||
29 | - , HookFunCount // 14 | ||
30 | -}; | ||
31 | - | ||
32 | -// jichi 10/14/2014 | ||
33 | -#define HOOK_GDI_FUNCTION_LIST \ | ||
34 | - GetTextExtentPoint32A \ | ||
35 | - , GetGlyphOutlineA \ | ||
36 | - , ExtTextOutA \ | ||
37 | - , TextOutA \ | ||
38 | - , GetCharABCWidthsA \ | ||
39 | - , GetTextExtentPoint32W \ | ||
40 | - , GetGlyphOutlineW \ | ||
41 | - , ExtTextOutW \ | ||
42 | - , TextOutW \ | ||
43 | - , GetCharABCWidthsW \ | ||
44 | - , DrawTextA \ | ||
45 | - , DrawTextExA \ | ||
46 | - , DrawTextW \ | ||
47 | - , DrawTextExW | ||
48 | - | ||
49 | -enum { HOOK_FUN_COUNT = HookFunCount }; | ||
50 | -// jichi 1/16/2015: Though called max hook, it means max number of text threads | ||
51 | -enum { MAX_HOOK = 32 }; // must be larger than HookFunCount | ||
52 | -//enum { HOOK_SECTION_SIZE = 0x2000 }; // default ITH value | ||
53 | -// jichi 1/16/2015: Change to a very large number to prevent crash | ||
54 | -//enum { MAX_HOOK = 0x100 }; // must be larger than HookFunCount | ||
55 | -enum { HOOK_SECTION_SIZE = MAX_HOOK * 0x100 }; // default ITH value is 0x2000 for 32 hook (0x100 per hook) | ||
56 | - | ||
57 | -// jichi 375/2014: Add offset of pusha/pushad | ||
58 | -// http://faydoc.tripod.com/cpu/pushad.htm | ||
59 | -// http://agth.wikia.com/wiki/Cheat_Engine_AGTH_Tutorial | ||
60 | -// | ||
61 | -// Warning: The offset in ITH has -4 offset comparing to pusha and AGTH | ||
62 | -enum pusha_off { | ||
63 | - pusha_eax_off = -0x4 | ||
64 | - , pusha_ecx_off = -0x8 | ||
65 | - , pusha_edx_off = -0xc | ||
66 | - , pusha_ebx_off = -0x10 | ||
67 | - , pusha_esp_off = -0x14 | ||
68 | - , pusha_ebp_off = -0x18 | ||
69 | - , pusha_esi_off = -0x1c | ||
70 | - , pusha_edi_off = -0x20 | ||
71 | - , pusha_off = -0x24 // pushad offset | ||
72 | -}; | ||
73 | - | ||
74 | -enum IhfCommandType { | ||
75 | - IHF_COMMAND = -1 // null type | ||
76 | - , IHF_COMMAND_NEW_HOOK = 0 | ||
77 | - , IHF_COMMAND_REMOVE_HOOK = 1 | ||
78 | - , IHF_COMMAND_MODIFY_HOOK = 2 | ||
79 | - , IHF_COMMAND_DETACH = 3 | ||
80 | -}; | ||
81 | - | ||
82 | -enum IhfNotificationType { | ||
83 | - IHF_NOTIFICATION = -1 // null type | ||
84 | - , IHF_NOTIFICATION_TEXT = 0 | ||
85 | - , IHF_NOTIFICATION_NEWHOOK = 1 | ||
86 | -}; | ||
87 | - | ||
88 | -// jichi 9/8/2013: The meaning are guessed | ||
89 | -// Values must be within DWORD | ||
90 | -// Unused values are as follows: | ||
91 | -// - 0x100 | ||
92 | -enum HookParamType : unsigned long { | ||
93 | - USING_STRING = 0x1 // type(data) is char* or wchar_t* and has length | ||
94 | - , USING_UTF8 = USING_STRING // jichi 10/21/2014: temporarily handled the same way as USING_STRING | ||
95 | - , USING_UNICODE = 0x2 // type(data) is wchar_t or wchar_t* | ||
96 | - , BIG_ENDIAN = 0x4 // type(data) is char | ||
97 | - , DATA_INDIRECT = 0x8 | ||
98 | - , USING_SPLIT = 0x10 // aware of split time? | ||
99 | - , SPLIT_INDIRECT = 0x20 | ||
100 | - , MODULE_OFFSET = 0x40 // do hash module, and the address is relative to module | ||
101 | - , FUNCTION_OFFSET = 0x80 // do hash function, and the address is relative to funccion | ||
102 | - , PRINT_DWORD = 0x100 // jichi 12/7/2014: Removed | ||
103 | - , STRING_LAST_CHAR = 0x200 | ||
104 | - , NO_CONTEXT = 0x400 | ||
105 | - //, EXTERN_HOOK = 0x800 // jichi 10/24/2014: Removed | ||
106 | - //, HOOK_AUXILIARY = 0x2000 // jichi 12/13/2013: None of known hooks are auxiliary | ||
107 | - , HOOK_ENGINE = 0x4000 | ||
108 | - , HOOK_ADDITIONAL = 0x8000 | ||
109 | - | ||
110 | - // jichi 10/24/2014: Only trigger the dynamic function, do not return any data | ||
111 | - , HOOK_EMPTY = 0x800 | ||
112 | - // jichi 6/1/2014: fix the split value to 0x10001 | ||
113 | - , FIXING_SPLIT = 0x1000 | ||
114 | - , RELATIVE_SPLIT = 0x2000 // relative split return address | ||
115 | -}; | ||
116 | - | ||
117 | -// 6/1/2014: Fixed split value for hok parameter | ||
118 | -// Fuse all threads, and prevent floating | ||
119 | -enum { FIXED_SPLIT_VALUE = 0x10001 }; | ||
120 | - | ||
121 | -// jichi 12/18/2013: | ||
122 | -// These dlls are used to guess the range for non-NO_CONTEXT hooks. | ||
123 | -// | ||
124 | -// Disabling uxtheme.dll would crash certain system: http://tieba.baidu.com/p/2764436254 | ||
125 | -#define IHF_FILTER_DLL_LIST \ | ||
126 | - /* ITH original filters */ \ | ||
127 | - L"gdiplus.dll" /* Graphics functions like TextOutA */ \ | ||
128 | - , L"lpk.dll" /* Language package scripts and fonts */ \ | ||
129 | - , L"msctf.dll" /* Text service */ \ | ||
130 | - , L"psapi.dll" /* Processes */ \ | ||
131 | - , L"usp10.dll" /* UNICODE rendering */ \ | ||
132 | - , L"user32.dll" /* Non-graphics functions like lstrlenA */ \ | ||
133 | - , L"uxtheme.dll" /* Theme */ \ | ||
134 | - \ | ||
135 | - /* Windows DLLs */ \ | ||
136 | - , L"advapi32.dll" /* Advanced services */ \ | ||
137 | - , L"apphelp.dll" /* Appliation help */ \ | ||
138 | - , L"audioses.dll" /* Audios */ \ | ||
139 | - , L"avrt.dll" /* Audio video runtime */ \ | ||
140 | - , L"cfgmgr32.dll" /* Configuration manager */ \ | ||
141 | - , L"clbcatq.dll" /* COM query service */ \ | ||
142 | - , L"comctl32.dll" /* Common control library */ \ | ||
143 | - , L"comdlg32.dll" /* Common dialogs */ \ | ||
144 | - , L"crypt32.dll" /* Security cryption */ \ | ||
145 | - , L"cryptbase.dll"/* Security cryption */ \ | ||
146 | - , L"cryptsp.dll" /* Security cryption */ \ | ||
147 | - , L"d3d8thk.dll" /* Direct3D 8 */ \ | ||
148 | - , L"d3d9.dll" /* Direct3D 9 */ \ | ||
149 | - , L"dbghelp.dll" /* Debug help */ \ | ||
150 | - , L"dciman32.dll" /* Display cotrol */ \ | ||
151 | - , L"devobj.dll" /* Device object */ \ | ||
152 | - , L"ddraw.dll" /* Direct draw */ \ | ||
153 | - , L"dinput.dll" /* Diret input */ \ | ||
154 | - , L"dsound.dll" /* Direct sound */ \ | ||
155 | - , L"DShowRdpFilter.dll" /* Direct show */ \ | ||
156 | - , L"dwmapi.dll" /* Windows manager */ \ | ||
157 | - , L"gdi32.dll" /* GDI32 */ \ | ||
158 | - , L"hid.dll" /* HID user library */ \ | ||
159 | - , L"iertutil.dll" /* IE runtime */ \ | ||
160 | - , L"imagehlp.dll" /* Image help */ \ | ||
161 | - , L"imm32.dll" /* Input method */ \ | ||
162 | - , L"ksuser.dll" /* Kernel service */ \ | ||
163 | - , L"ole32.dll" /* COM OLE */ \ | ||
164 | - , L"oleacc.dll" /* OLE access */ \ | ||
165 | - , L"oleaut32.dll" /* COM OLE */ \ | ||
166 | - , L"kernel.dll" /* Kernel functions */ \ | ||
167 | - , L"kernelbase.dll" /* Kernel functions */ \ | ||
168 | - , L"midimap.dll" /* MIDI */ \ | ||
169 | - , L"mmdevapi.dll" /* Audio device */ \ | ||
170 | - , L"mpr.dll" /* Winnet */ \ | ||
171 | - , L"msacm32.dll" /* MS ACM */ \ | ||
172 | - , L"msacm32.drv" /* MS ACM */ \ | ||
173 | - , L"msasn1.dll" /* Encoding/decoding */ \ | ||
174 | - , L"msimg32.dll" /* Image */ \ | ||
175 | - , L"msvfw32.dll" /* Media play */ \ | ||
176 | - , L"netapi32.dll" /* Network service */ \ | ||
177 | - , L"normaliz.dll" /* Normalize */ \ | ||
178 | - , L"nsi.dll" /* NSI */ \ | ||
179 | - , L"ntdll.dll" /* NT functions */ \ | ||
180 | - , L"ntmarta.dll" /* NT MARTA */ \ | ||
181 | - , L"nvd3dum.dll" /* Direct 3D */ \ | ||
182 | - , L"powerprof.dll"/* Power profile */ \ | ||
183 | - , L"profapi.dll" /* Profile API */ \ | ||
184 | - , L"propsys.dll" /* System properties */ \ | ||
185 | - , L"quartz.dll" /* OpenGL */ \ | ||
186 | - , L"rpcrt4.dll" /* RPC runtime */ \ | ||
187 | - , L"rpcrtremote.dll" /* RPC runtime */ \ | ||
188 | - , L"rsabase.dll" /* RSA cryption */ \ | ||
189 | - , L"rsaenh.dll" /* RSA cryption */ \ | ||
190 | - , L"schannel.dll" /* Security channel */ \ | ||
191 | - , L"sechost.dll" /* Service host */ \ | ||
192 | - , L"setupapi.dll" /* Setup service */ \ | ||
193 | - , L"shell32.dll" /* Windows shell */ \ | ||
194 | - , L"shlwapi.dll" /* Light-weighted shell */ \ | ||
195 | - , L"slc.dll" /* SLC */ \ | ||
196 | - , L"srvcli.dll" /* Service client */ \ | ||
197 | - , L"version.dll" /* Windows version */ \ | ||
198 | - , L"wdmaud.drv" /* Wave output */ \ | ||
199 | - , L"wldap32.dll" /* Wireless */ \ | ||
200 | - , L"wininet.dll" /* Internet access */ \ | ||
201 | - , L"winmm.dll" /* Windows sound */ \ | ||
202 | - , L"winsta.dll" /* Connection system */ \ | ||
203 | - , L"wtsapi32.dll" /* Windows terminal server */ \ | ||
204 | - , L"wintrust.dll" /* Windows trust */ \ | ||
205 | - , L"wsock32.dll" /* Windows sock */ \ | ||
206 | - , L"ws2_32.dll" /* Terminal server */ \ | ||
207 | - , L"wkscli.dll" /* ACIS */ \ | ||
208 | - \ | ||
209 | - /* MSVCRT */ \ | ||
210 | - , L"msvcrt.dll" /* VC rutime */ \ | ||
211 | - , L"msvcr80.dll" /* VC rutime 8 */ \ | ||
212 | - , L"msvcp80.dll" /* VC rutime 8 */ \ | ||
213 | - , L"msvcr90.dll" /* VC rutime 9 */ \ | ||
214 | - , L"msvcp90.dll" /* VC rutime 9 */ \ | ||
215 | - , L"msvcr100.dll" /* VC rutime 10 */ \ | ||
216 | - , L"msvcp100.dll" /* VC rutime 10 */ \ | ||
217 | - , L"msvcr110.dll" /* VC rutime 11 */ \ | ||
218 | - , L"msvcp110.dll" /* VC rutime 11 */ \ | ||
219 | - \ | ||
220 | - /* VNR */ \ | ||
221 | - , L"vnrhook.dll" \ | ||
222 | - , L"vnrhookxp.dll" \ | ||
223 | - \ | ||
224 | - /* Sogou IME */ \ | ||
225 | - , L"sogoupy.ime" \ | ||
226 | - , L"PicFace.dll" \ | ||
227 | - , L"AddressSearch.dll" \ | ||
228 | - \ | ||
229 | - /* QQ IME */ \ | ||
230 | - , L"QQPINYIN.IME" \ | ||
231 | - \ | ||
232 | - /* AlphaROM */ \ | ||
233 | - , L"kDays.dll" \ | ||
234 | - \ | ||
235 | - /* 360Safe */ \ | ||
236 | - , L"safemon.dll" \ | ||
237 | - \ | ||
238 | - /* Locale changers */ \ | ||
239 | - , L"AlLayer.dll" /* AppLocale */ \ | ||
240 | - , L"LocaleEmulator.dll" /* Locale Emulator */ \ | ||
241 | - , L"LSH.dll" /* LocaleSwitch */ \ | ||
242 | - , L"ntleah.dll" /* NTLEA */ | ||
243 | - | ||
244 | - // Google Japanese IME | ||
245 | - //, L"GoogleIMEJaTIP32.dll" | ||
246 | - | ||
247 | -enum { | ||
248 | - //IHF_FILTER_COUNT = 7 | ||
249 | - IHF_FILTER_COUNT = 7 + 72 + 9 + 4 + 3 + 1 + 1 + 1 + 4 // count of total dlls to filter | ||
250 | - , IHF_FILTER_CAPACITY = IHF_FILTER_COUNT + 1 // one more than the dll count | ||
251 | -}; | ||
252 | - | ||
253 | -// EOF |
vnr/ith/common/defs.h
deleted
100644 → 0
1 | -#pragma once | ||
2 | - | ||
3 | -// ith/common/defs.h | ||
4 | -// 8/23/2013 jichi | ||
5 | - | ||
6 | -// DLL files | ||
7 | - | ||
8 | -//#define ITH_SERVER_DLL L"vnrsrv.dll" | ||
9 | -//#define ITH_CLIENT_DLL L"vnrcli.dll" | ||
10 | -//#define ITH_CLIENT_XP_DLL L"vnrclixp.dll" | ||
11 | -////#define ITH_CLIENT_UX_DLL L"vnrcliux.dll" | ||
12 | -//#define ITH_ENGINE_DLL L"vnreng.dll" | ||
13 | -//#define ITH_ENGINE_XP_DLL L"vnrengxp.dll" | ||
14 | -//#define ITH_ENGINE_UX_DLL L"vnrengux.dll" | ||
15 | - | ||
16 | -#define ITH_DLL L"vnrhook.dll" | ||
17 | -#define ITH_DLL_XP L"vnrhookxp.dll" | ||
18 | - | ||
19 | -// Pipes | ||
20 | - | ||
21 | -#define ITH_TEXT_PIPE L"\\??\\pipe\\VNR_TEXT" | ||
22 | -#define ITH_COMMAND_PIPE L"\\??\\pipe\\VNR_COMMAND" | ||
23 | - | ||
24 | -// Sections | ||
25 | - | ||
26 | -#define ITH_SECTION_ L"VNR_SECTION_" // _%d | ||
27 | - | ||
28 | -// Mutex | ||
29 | - | ||
30 | -#define ITH_PROCESS_MUTEX_ L"VNR_PROCESS_" // ITH_%d | ||
31 | -#define ITH_HOOKMAN_MUTEX_ L"VNR_HOOKMAN_" // ITH_HOOKMAN_%d | ||
32 | -#define ITH_DETACH_MUTEX_ L"VNR_DETACH_" // ITH_DETACH_%d | ||
33 | - | ||
34 | -#define ITH_GRANTPIPE_MUTEX L"VNR_GRANT_PIPE" // ITH_GRANT_PIPE | ||
35 | - | ||
36 | -//#define ITH_ENGINE_MUTEX L"VNR_ENGINE" // ITH_ENGINE | ||
37 | -#define ITH_CLIENT_MUTEX L"VNR_CLIENT" // ITH_DLL_RUNNING | ||
38 | -#define ITH_SERVER_MUTEX L"VNR_SERVER" // ITH_RUNNING | ||
39 | -#define ITH_SERVER_HOOK_MUTEX L"VNR_SERVER_HOOK" // original | ||
40 | - | ||
41 | -// Events | ||
42 | - | ||
43 | -#define ITH_REMOVEHOOK_EVENT L"VNR_REMOVE_HOOK" // ITH_REMOVE_HOOK | ||
44 | -#define ITH_MODIFYHOOK_EVENT L"VNR_MODIFY_HOOK" // ITH_MODIFY_HOOK | ||
45 | -#define ITH_PIPEEXISTS_EVENT L"VNR_PIPE_EXISTS" // ITH_PIPE_EXIST | ||
46 | - | ||
47 | -// EOF |
vnr/ith/common/except.h
deleted
100644 → 0
1 | -#pragma once | ||
2 | - | ||
3 | -// ith/common/except.h | ||
4 | -// 9/17/2013 jichi | ||
5 | - | ||
6 | -#define ITH_RAISE (*(int*)0 = 0) // raise C000005, for debugging only | ||
7 | - | ||
8 | -#ifdef ITH_HAS_SEH | ||
9 | - | ||
10 | -# define ITH_TRY __try | ||
11 | -# define ITH_EXCEPT __except(EXCEPTION_EXECUTE_HANDLER) | ||
12 | -# define ITH_WITH_SEH(...) \ | ||
13 | - ITH_TRY { __VA_ARGS__; } ITH_EXCEPT {} | ||
14 | - | ||
15 | -#else // for old msvcrt.dll on Windows XP that does not have exception handler | ||
16 | - | ||
17 | -// Currently, only with_seh is implemented. Try and catch are not. | ||
18 | -# define ITH_TRY if (true) | ||
19 | -# define ITH_EXCEPT else | ||
20 | -# include "winseh/winseh.h" | ||
21 | -# define ITH_WITH_SEH(...) seh_with(__VA_ARGS__) | ||
22 | - | ||
23 | -#endif // ITH_HAS_SEH | ||
24 | - | ||
25 | -// EOF |
vnr/ith/common/growl.h
deleted
100644 → 0
1 | -#pragma once | ||
2 | - | ||
3 | -// ith/common/growl.h | ||
4 | -// 9/17/2013 jichi | ||
5 | - | ||
6 | -//#ifdef ITH_HAS_GROWL | ||
7 | - | ||
8 | -#include <windows.h> | ||
9 | -#include "ith/common/string.h" | ||
10 | - | ||
11 | -#define ITH_MSG_A(_msg) MessageBoxA(nullptr, _msg, "VNR Message", MB_OK) | ||
12 | -#define ITH_MSG(_msg) MessageBoxW(nullptr, _msg, L"VNR Message", MB_OK) | ||
13 | -#define ITH_WARN(_msg) MessageBoxW(nullptr, _msg, L"VNR Warning", MB_OK) | ||
14 | -#define ITH_ERROR(_msg) MessageBoxW(nullptr, _msg, L"VNR Error", MB_OK) | ||
15 | - | ||
16 | -inline void ITH_GROWL_DWORD(DWORD value) | ||
17 | -{ | ||
18 | - WCHAR buf[100]; | ||
19 | - swprintf(buf, L"DWORD: %x", value); | ||
20 | - ITH_MSG(buf); | ||
21 | -} | ||
22 | - | ||
23 | -inline void ITH_GROWL_DWORD2(DWORD v, DWORD v2) | ||
24 | -{ | ||
25 | - WCHAR buf[100]; | ||
26 | - swprintf(buf, L"DWORD2: %x,%x", v, v2); | ||
27 | - ITH_MSG(buf); | ||
28 | -} | ||
29 | - | ||
30 | -inline void ITH_GROWL_DWORD3(DWORD v, DWORD v2, DWORD v3) | ||
31 | -{ | ||
32 | - WCHAR buf[100]; | ||
33 | - swprintf(buf, L"DWORD3: %x,%x,%x", v, v2, v3); | ||
34 | - ITH_MSG(buf); | ||
35 | -} | ||
36 | - | ||
37 | -inline void ITH_GROWL_DWORD4(DWORD v, DWORD v2, DWORD v3, DWORD v4) | ||
38 | -{ | ||
39 | - WCHAR buf[100]; | ||
40 | - swprintf(buf, L"DWORD4: %x,%x,%x,%x", v, v2, v3, v4); | ||
41 | - ITH_MSG(buf); | ||
42 | -} | ||
43 | - | ||
44 | -inline void ITH_GROWL_DWORD5(DWORD v, DWORD v2, DWORD v3, DWORD v4, DWORD v5) | ||
45 | -{ | ||
46 | - WCHAR buf[100]; | ||
47 | - swprintf(buf, L"DWORD5: %x,%x,%x,%x,%x", v, v2, v3, v4, v5); | ||
48 | - ITH_MSG(buf); | ||
49 | -} | ||
50 | - | ||
51 | -inline void ITH_GROWL_DWORD6(DWORD v, DWORD v2, DWORD v3, DWORD v4, DWORD v5, DWORD v6) | ||
52 | -{ | ||
53 | - WCHAR buf[100]; | ||
54 | - swprintf(buf, L"DWORD6: %x,%x,%x,%x,%x,%x", v, v2, v3, v4, v5, v6); | ||
55 | - ITH_MSG(buf); | ||
56 | -} | ||
57 | - | ||
58 | -inline void ITH_GROWL_DWORD7(DWORD v, DWORD v2, DWORD v3, DWORD v4, DWORD v5, DWORD v6, DWORD v7) | ||
59 | -{ | ||
60 | - WCHAR buf[100]; | ||
61 | - swprintf(buf, L"DWORD7: %x,%x,%x,%x,%x,%x,%x", v, v2, v3, v4, v5, v6, v7); | ||
62 | - ITH_MSG(buf); | ||
63 | -} | ||
64 | - | ||
65 | -inline void ITH_GROWL_DWORD8(DWORD v, DWORD v2, DWORD v3, DWORD v4, DWORD v5, DWORD v6, DWORD v7, DWORD v8) | ||
66 | -{ | ||
67 | - WCHAR buf[100]; | ||
68 | - swprintf(buf, L"DWORD8: %x,%x,%x,%x,%x,%x,%x,%x", v, v2, v3, v4, v5, v6, v7, v8); | ||
69 | - ITH_MSG(buf); | ||
70 | -} | ||
71 | - | ||
72 | -inline void ITH_GROWL_DWORD9(DWORD v, DWORD v2, DWORD v3, DWORD v4, DWORD v5, DWORD v6, DWORD v7, DWORD v8, DWORD v9) | ||
73 | -{ | ||
74 | - WCHAR buf[100]; | ||
75 | - swprintf(buf, L"DWORD9: %x,%x,%x,%x,%x,%x,%x,%x,%x", v, v2, v3, v4, v5, v6, v7, v8, v9); | ||
76 | - ITH_MSG(buf); | ||
77 | -} | ||
78 | - | ||
79 | -inline void ITH_GROWL(DWORD v) { ITH_GROWL_DWORD(v); } | ||
80 | -inline void ITH_GROWL(LPCWSTR v) { ITH_MSG(v); } | ||
81 | -inline void ITH_GROWL(LPCSTR v) { ITH_MSG_A(v); } | ||
82 | - | ||
83 | -//#endif // ITH_HAS_GROWL | ||
84 | - | ||
85 | -// EOF |
vnr/ith/common/memory.h
deleted
100644 → 0
1 | -#pragma once | ||
2 | - | ||
3 | -// ith/common/memory.h | ||
4 | -// 8/23/2013 jichi | ||
5 | -// Branch: ITH/mem.h, revision 66 | ||
6 | - | ||
7 | -#ifndef ITH_HAS_HEAP | ||
8 | -# define ITH_MEMSET_HEAP(...) ::memset(__VA_ARGS__) | ||
9 | -#else | ||
10 | -# define ITH_MEMSET_HEAP(...) (void)0 | ||
11 | - | ||
12 | -// Defined in kernel32.lilb | ||
13 | -extern "C" { | ||
14 | -// PVOID RtlAllocateHeap( _In_ PVOID HeapHandle, _In_opt_ ULONG Flags, _In_ SIZE_T Size); | ||
15 | -__declspec(dllimport) void * __stdcall RtlAllocateHeap(void *HeapHandle, unsigned long Flags, unsigned long Size); | ||
16 | - | ||
17 | -// BOOLEAN RtlFreeHeap( _In_ PVOID HeapHandle, _In_opt_ ULONG Flags, _In_ PVOID HeapBase); | ||
18 | -__declspec(dllimport) int __stdcall RtlFreeHeap(void *HeapHandle, unsigned long Flags, void *HeapBase); | ||
19 | -} // extern "C" | ||
20 | - | ||
21 | -//NTSYSAPI | ||
22 | -//BOOL | ||
23 | -//NTAPI | ||
24 | -//RtlFreeHeap( | ||
25 | -// _In_ HANDLE hHeap, | ||
26 | -// _In_ DWORD dwFlags, | ||
27 | -// _In_ LPVOID lpMem | ||
28 | -//); | ||
29 | - | ||
30 | -extern void *hHeap; // defined in ith/sys.cc | ||
31 | - | ||
32 | -inline void * __cdecl operator new(size_t lSize) | ||
33 | -{ | ||
34 | - // http://msdn.microsoft.com/en-us/library/windows/desktop/aa366597%28v=vs.85%29.aspx | ||
35 | - // HEAP_ZERO_MEMORY flag is critical. All new objects are assumed with zero initialized. | ||
36 | - enum { HEAP_ZERO_MEMORY = 0x00000008 }; | ||
37 | - return RtlAllocateHeap(::hHeap, HEAP_ZERO_MEMORY, lSize); | ||
38 | -} | ||
39 | - | ||
40 | -inline void __cdecl operator delete(void *pBlock) | ||
41 | -{ RtlFreeHeap(::hHeap, 0, pBlock); } | ||
42 | - | ||
43 | -inline void __cdecl operator delete[](void *pBlock) | ||
44 | -{ RtlFreeHeap(::hHeap, 0, pBlock); } | ||
45 | - | ||
46 | -#endif // ITH_HAS_HEAP |
vnr/ith/common/string.h
deleted
100644 → 0
1 | -#pragma once | ||
2 | - | ||
3 | -// ith/common/string.h | ||
4 | -// 8/9/2013 jichi | ||
5 | -// Branch: ITH/string.h, rev 66 | ||
6 | - | ||
7 | -#ifdef ITH_HAS_CRT // ITH is linked with msvcrt dlls | ||
8 | -# include <cstdio> | ||
9 | -# include <cstring> | ||
10 | - | ||
11 | -#else | ||
12 | -# define _INC_SWPRINTF_INL_ | ||
13 | -# define CRT_IMPORT __declspec(dllimport) | ||
14 | - | ||
15 | -#include <windows.h> // for wchar_t | ||
16 | -extern "C" { | ||
17 | -CRT_IMPORT int swprintf(wchar_t *src, const wchar_t *fmt, ...); | ||
18 | -CRT_IMPORT int sprintf(char *src, const char *fmt, ...); | ||
19 | -CRT_IMPORT int swscanf(const wchar_t *src, const wchar_t *fmt, ...); | ||
20 | -CRT_IMPORT int sscanf(const char *src, const char *fmt, ...); | ||
21 | -CRT_IMPORT int wprintf(const wchar_t *fmt, ...); | ||
22 | -CRT_IMPORT int printf(const char *fmt, ...); | ||
23 | -CRT_IMPORT int _wputs(const wchar_t *src); | ||
24 | -CRT_IMPORT int puts(const char *src); | ||
25 | -CRT_IMPORT int _stricmp(const char *x, const char *y); | ||
26 | -CRT_IMPORT int _wcsicmp(const wchar_t *x, const wchar_t *y); | ||
27 | -//CRT_IMPORT size_t strlen(const char *); | ||
28 | -//CRT_IMPORT size_t wcslen(const wchar_t *); | ||
29 | -//CRT_IMPORT char *strcpy(char *,const char *); | ||
30 | -//CRT_IMPORT wchar_t *wcscpy(wchar_t *,const wchar_t *); | ||
31 | -CRT_IMPORT void *memmove(void *dst, const void *src, size_t sz); | ||
32 | -CRT_IMPORT const char *strchr(const char *src, int val); | ||
33 | -CRT_IMPORT int strncmp(const char *x, const char *y, size_t sz); | ||
34 | -} // extern "C" | ||
35 | - | ||
36 | -#endif // ITH_HAS_CRT |
vnr/ith/common/types.h
deleted
100644 → 0
1 | -#pragma once | ||
2 | - | ||
3 | -// ith/common/types.h | ||
4 | -// 8/23/2013 jichi | ||
5 | -// Branch: ITH/common.h, rev 128 | ||
6 | - | ||
7 | -#include <windows.h> // needed for windef types | ||
8 | - | ||
9 | - /** jichi 3/7/2014: Add guessed comment | ||
10 | - * | ||
11 | - * DWORD addr absolute or relative address | ||
12 | - * DWORD split esp offset of the split character | ||
13 | - * | ||
14 | - * http://faydoc.tripod.com/cpu/pushad.htm | ||
15 | - * http://agth.wikia.com/wiki/Cheat_Engine_AGTH_Tutorial | ||
16 | - * The order is the same as pushd | ||
17 | - * EAX, ECX, EDX, EBX, ESP (original value), EBP, ESI, and EDI (if the current operand-size attribute is 32) and AX, CX, DX, BX, SP | ||
18 | - * Negative values of 'data_offset' and 'sub_offset' refer to registers:-4 for EAX, -8 for ECX, -C for EDX, -10 for EBX, -14 for ESP, -18 for EBP, -1C for ESI, -20 for EDI | ||
19 | - */ | ||
20 | -struct HookParam { | ||
21 | - // jichi 8/24/2013: For special hooks. Original name: DataFun | ||
22 | - typedef void (*text_fun_t)(DWORD esp, HookParam *hp, BYTE index, DWORD *data, DWORD *split, DWORD *len); | ||
23 | - | ||
24 | - // jichi 10/24/2014: Add filter function. Return the if skip the text | ||
25 | - typedef bool (*filter_fun_t)(LPVOID str, DWORD *len, HookParam *hp, BYTE index); | ||
26 | - | ||
27 | - // jichi 10/24/2014: Add generic hook function, return false if stop execution. | ||
28 | - typedef bool (*hook_fun_t)(DWORD esp, HookParam *hp); | ||
29 | - | ||
30 | - DWORD addr; // absolute or relative address | ||
31 | - DWORD off, // offset of the data in the memory | ||
32 | - ind, // ? | ||
33 | - split, // esp offset of the split character = pusha offset - 4 | ||
34 | - split_ind; // ? | ||
35 | - DWORD module, // hash of the module | ||
36 | - function; | ||
37 | - text_fun_t text_fun; | ||
38 | - filter_fun_t filter_fun; | ||
39 | - hook_fun_t hook_fun; | ||
40 | - DWORD type; // flags | ||
41 | - WORD length_offset; // index of the string length | ||
42 | - BYTE hook_len, // ? | ||
43 | - recover_len; // ? | ||
44 | - | ||
45 | - // 2/2/2015: jichi number of times - 1 to run the hook | ||
46 | - BYTE extra_text_count; | ||
47 | - BYTE _unused; // jichi 2/2/2015: add a BYTE type to make to total sizeof(HookParam) even. | ||
48 | - | ||
49 | - // 7/20/2014: jichi additional parameters for PSP games | ||
50 | - DWORD user_flags, | ||
51 | - user_value; | ||
52 | -}; | ||
53 | - | ||
54 | -// jichi 6/1/2014: Structure of the esp for extern functions | ||
55 | -struct HookStack | ||
56 | -{ | ||
57 | - // pushad | ||
58 | - DWORD edi, // -0x24 | ||
59 | - esi, // -0x20 | ||
60 | - ebp, // -0x1c | ||
61 | - esp, // -0x18 | ||
62 | - ebx, // -0x14 | ||
63 | - edx, // -0x10 | ||
64 | - ecx, // -0xc | ||
65 | - eax; // -0x8 | ||
66 | - // pushfd | ||
67 | - DWORD eflags; // -0x4 | ||
68 | - DWORD retaddr; // 0 | ||
69 | - DWORD args[1]; // 0x4 | ||
70 | -}; | ||
71 | - | ||
72 | -struct SendParam { | ||
73 | - DWORD type; | ||
74 | - HookParam hp; | ||
75 | -}; | ||
76 | - | ||
77 | -struct Hook { // size: 0x80 | ||
78 | - HookParam hp; | ||
79 | - LPWSTR hook_name; | ||
80 | - int name_length; | ||
81 | - BYTE recover[0x68 - sizeof(HookParam)]; | ||
82 | - BYTE original[0x10]; | ||
83 | - | ||
84 | - DWORD Address() const { return hp.addr; } | ||
85 | - DWORD Type() const { return hp.type; } | ||
86 | - WORD Length() const { return hp.hook_len; } | ||
87 | - LPWSTR Name() const { return hook_name; } | ||
88 | - int NameLength() const { return name_length; } | ||
89 | -}; | ||
90 | - | ||
91 | -// EOF |
vnr/ith/dllconfig.h
deleted
100644 → 0
vnr/ith/dllconfig.pri
deleted
100644 → 0
1 | -# dllconfig.pri | ||
2 | -# 8/9/2013 jichi | ||
3 | -# For linking ITH injectable dlls. | ||
4 | -# The dll is self-containd and Windows-independent. | ||
5 | - | ||
6 | -CONFIG += dll noqt #noeh nosafeseh | ||
7 | -CONFIG -= embed_manifest_dll # dynamically load dlls | ||
8 | -win32 { | ||
9 | - CONFIG(eh): DEFINES += ITH_HAS_SEH # Do have exception handler in msvcrt.dll on Windows Vista and later | ||
10 | - CONFIG(noeh): DEFINES -= ITH_HAS_SEH # Do not have exception handler in msvcrt.dll on Windows XP and before | ||
11 | -} | ||
12 | -include(../../../config.pri) | ||
13 | -#win32 { | ||
14 | -# CONFIG(noeh): include($$LIBDIR/winseh/winseh_safe.pri) | ||
15 | -#} | ||
16 | - | ||
17 | -# jichi 11/24/2013: Disable manual heap | ||
18 | -DEFINES -= ITH_HAS_HEAP | ||
19 | - | ||
20 | -# jichi 11/13/2011: disable swprinf warning | ||
21 | -DEFINES += _CRT_NON_CONFORMING_SWPRINTFS | ||
22 | - | ||
23 | -## Libraries | ||
24 | - | ||
25 | -#LIBS += -lkernel32 -luser32 -lgdi32 | ||
26 | -LIBS += -L$$WDK7_HOME/lib/wxp/i386 -lntdll | ||
27 | -LIBS += $$WDK7_HOME/lib/crt/i386/msvcrt.lib # Override msvcrt10 | ||
28 | -#LIBS += -L$$WDK7_HOME/lib/crt/i386 -lmsvcrt | ||
29 | -#QMAKE_LFLAGS += $$WDK7_HOME/lib/crt/i386/msvcrt.lib # This will leave runtime flags in the dll | ||
30 | - | ||
31 | -#LIBS += -L$$WDK8_HOME/lib/winv6.3/um/x86 -lntdll | ||
32 | - | ||
33 | -HEADERS += $$PWD/dllconfig.h | ||
34 | - | ||
35 | -# EOF |
vnr/ith/hook/CMakeLists.txt
deleted
100644 → 0
1 | -# hook.pro | ||
2 | -# CONFIG += eh eha | ||
3 | -# include(../dllconfig.pri) | ||
4 | - | ||
5 | -# hookxp.pro | ||
6 | -# CONFIG += noeh | ||
7 | -# include(../dllconfig.pri) | ||
8 | - | ||
9 | -# dllconfig.pri | ||
10 | -# include(../../../config.pri) | ||
11 | -# win32 { | ||
12 | -# CONFIG(eh): DEFINES += ITH_HAS_SEH | ||
13 | -# CONFIG(noeh): DEFINES -= ITH_HAS_SEH | ||
14 | -# } | ||
15 | - | ||
16 | -# config.pri | ||
17 | -# CONFIG(eha) { | ||
18 | -# message(CONFIG eha) | ||
19 | -# QMAKE_CXXFLAGS_STL_ON -= /EHsc | ||
20 | -# QMAKE_CXXFLAGS_EXCEPTIONS_ON -= /EHsc | ||
21 | -# QMAKE_CXXFLAGS_STL_ON += /EHa | ||
22 | -# QMAKE_CXXFLAGS_EXCEPTIONS_ON += /EHa | ||
23 | -# } | ||
24 | -# | ||
25 | -# CONFIG(noeh) { # No Exception handler | ||
26 | -# QMAKE_CXXFLAGS += /GR- | ||
27 | -# QMAKE_CXXFLAGS_RTTI_ON -= /GR | ||
28 | -# QMAKE_CXXFLAGS_STL_ON -= /EHsc | ||
29 | -# QMAKE_CXXFLAGS_EXCEPTIONS_ON -= /EHsc | ||
30 | -# } | ||
31 | - | ||
32 | -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) | ||
33 | - | ||
34 | -set(vnrhook_src | ||
35 | - cli.h | ||
36 | - config.h | ||
37 | - hook.h | ||
38 | - main.cc | ||
39 | - engine/engine.cc | ||
40 | - engine/engine.h | ||
41 | - engine/hookdefs.h | ||
42 | - engine/match.cc | ||
43 | - engine/match.h | ||
44 | - engine/pchooks.cc | ||
45 | - engine/pchooks.h | ||
46 | - engine/util.cc | ||
47 | - engine/util.h | ||
48 | - hijack/texthook.cc | ||
49 | - rpc/pipe.cc | ||
50 | - tree/avl.h | ||
51 | - ${PROJECT_SOURCE_DIR}/ccutil/ccmacro.h | ||
52 | - ${PROJECT_SOURCE_DIR}/cpputil/cpplocale.h | ||
53 | - ${PROJECT_SOURCE_DIR}/cpputil/cppmarshal.h | ||
54 | - ${PROJECT_SOURCE_DIR}/cpputil/cppmath.h | ||
55 | - ${PROJECT_SOURCE_DIR}/cpputil/cpppath.h | ||
56 | - ${PROJECT_SOURCE_DIR}/cpputil/cppstring.h | ||
57 | - ${PROJECT_SOURCE_DIR}/cpputil/cpptype.h | ||
58 | - ${PROJECT_SOURCE_DIR}/cpputil/cppunicode.h | ||
59 | - ${PROJECT_SOURCE_DIR}/disasm/disasm.cc | ||
60 | - ${PROJECT_SOURCE_DIR}/memdbg/memdbg.h | ||
61 | - ${PROJECT_SOURCE_DIR}/memdbg/memsearch.cc | ||
62 | - ${PROJECT_SOURCE_DIR}/memdbg/memsearch.h | ||
63 | - ${PROJECT_SOURCE_DIR}/ntinspect/ntinspect.cc | ||
64 | - ${PROJECT_SOURCE_DIR}/ntinspect/ntinspect.h | ||
65 | - ${PROJECT_SOURCE_DIR}/winversion/winversion.cc | ||
66 | - ${PROJECT_SOURCE_DIR}/winversion/winversion.h | ||
67 | - ${common_src} | ||
68 | - ${import_src} | ||
69 | -) | ||
70 | - | ||
71 | -source_group("common" FILES ${common_src}) | ||
72 | -source_group("import" FILES ${import_src}) | ||
73 | - | ||
74 | -add_library(vnrhook SHARED ${vnrhook_src}) | ||
75 | - | ||
76 | -set(vnrhookxp_src ${vnrhook_src} | ||
77 | - ${PROJECT_SOURCE_DIR}/winseh/winseh.cc | ||
78 | - ${PROJECT_SOURCE_DIR}/winseh/winseh_safe.cc | ||
79 | - ${PROJECT_SOURCE_DIR}/winseh/winseh.h | ||
80 | - ${PROJECT_SOURCE_DIR}/winseh/safeseh.asm | ||
81 | -) | ||
82 | - | ||
83 | -enable_language(ASM_MASM) | ||
84 | - | ||
85 | -set_source_files_properties( | ||
86 | - ${PROJECT_SOURCE_DIR}/winseh/safeseh.asm | ||
87 | - PROPERTIES | ||
88 | - # CMAKE_ASM_MASM_FLAGS /safeseh # CMake bug 14711: http://www.cmake.org/Bug/view.php?id=14711 | ||
89 | - COMPILE_FLAGS /safeseh | ||
90 | -) | ||
91 | - | ||
92 | -add_library(vnrhookxp SHARED ${vnrhookxp_src}) | ||
93 | - | ||
94 | -set_target_properties(vnrhook vnrhookxp PROPERTIES | ||
95 | - LINK_FLAGS "/SUBSYSTEM:WINDOWS /MANIFEST:NO" | ||
96 | -) | ||
97 | - | ||
98 | -target_compile_options(vnrhook PRIVATE | ||
99 | - /EHa | ||
100 | - $<$<CONFIG:Release>:> | ||
101 | - $<$<CONFIG:Debug>:> | ||
102 | -) | ||
103 | - | ||
104 | -target_compile_options(vnrhookxp PRIVATE | ||
105 | - /GR- | ||
106 | -# /EHs-c- # disable exception handling # CMake bug 15243: http://www.cmake.org/Bug/view.php?id=15243 | ||
107 | - $<$<CONFIG:Release>:> | ||
108 | - $<$<CONFIG:Debug>:> | ||
109 | -) | ||
110 | - | ||
111 | -if(TARGET vnrhookxp) | ||
112 | - STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) | ||
113 | -endif(TARGET vnrhookxp) | ||
114 | - | ||
115 | -set(vnrhook_libs | ||
116 | - vnrsys | ||
117 | - ${WDK_HOME}/lib/wxp/i386/ntdll.lib | ||
118 | - Version.lib | ||
119 | -) | ||
120 | - | ||
121 | -target_link_libraries(vnrhook ${vnrhook_libs}) | ||
122 | -target_link_libraries(vnrhookxp ${vnrhook_libs}) | ||
123 | - | ||
124 | -target_compile_definitions(vnrhook | ||
125 | - PRIVATE | ||
126 | - -DITH_HAS_SEH | ||
127 | -) | ||
128 | -target_compile_definitions(vnrhookxp | ||
129 | - PRIVATE | ||
130 | -) | ||
131 | - | ||
132 | -install(TARGETS vnrhook vnrhookxp RUNTIME | ||
133 | - DESTINATION . | ||
134 | - CONFIGURATIONS Release | ||
135 | -) |
vnr/ith/hook/cli.h
deleted
100644 → 0
1 | -#pragma once | ||
2 | - | ||
3 | -// cli.h | ||
4 | -// 8/24/2013 jichi | ||
5 | -// Branch: IHF_DLL/IHF_CLIENT.h, rev 133 | ||
6 | -// | ||
7 | -// 8/24/2013 TODO: | ||
8 | -// - Clean up this file | ||
9 | -// - Reduce global variables. Use namespaces or singleton classes instead. | ||
10 | - | ||
11 | -//#include <windows.h> | ||
12 | -//#define IHF | ||
13 | -#include "config.h" | ||
14 | -#include "hook.h" | ||
15 | - | ||
16 | -// jichi 12/25/2013: Header in each message sent to vnrsrv | ||
17 | -// There are totally three elements | ||
18 | -// - 0x0 dwAddr hook address | ||
19 | -// - 0x4 dwRetn return address | ||
20 | -// - 0x8 dwSplit split value | ||
21 | -#define HEADER_SIZE 0xc | ||
22 | - | ||
23 | -extern int current_hook; | ||
24 | -extern WCHAR dll_mutex[]; | ||
25 | -//extern WCHAR dll_name[]; | ||
26 | -extern DWORD trigger; | ||
27 | -//extern DWORD current_process_id; | ||
28 | - | ||
29 | -// jichi 6/3/2014: Get memory range of the current module | ||
30 | -extern DWORD processStartAddress, | ||
31 | - processStopAddress; | ||
32 | - | ||
33 | -template <class T, class D, class fComp, class fCopy, class fLength> | ||
34 | -class AVLTree; | ||
35 | -struct FunctionInfo { | ||
36 | - DWORD addr; | ||
37 | - DWORD module; | ||
38 | - DWORD size; | ||
39 | - LPWSTR name; | ||
40 | -}; | ||
41 | -struct SCMP; | ||
42 | -struct SCPY; | ||
43 | -struct SLEN; | ||
44 | -extern AVLTree<char, FunctionInfo, SCMP, SCPY, SLEN> *tree; | ||
45 | - | ||
46 | -void InitFilterTable(); | ||
47 | - | ||
48 | -// jichi 9/25/2013: This class will be used by NtMapViewOfSectionfor | ||
49 | -// interprocedure communication, where constructor/destructor will NOT work. | ||
50 | -class TextHook : public Hook | ||
51 | -{ | ||
52 | - int UnsafeInsertHookCode(); | ||
53 | - DWORD UnsafeSend(DWORD dwDataBase, DWORD dwRetn); | ||
54 | -public: | ||
55 | - int InsertHook(); | ||
56 | - int InsertHookCode(); | ||
57 | - int InitHook(const HookParam &hp, LPCWSTR name = 0, WORD set_flag = 0); | ||
58 | - int InitHook(LPVOID addr, DWORD data, DWORD data_ind, | ||
59 | - DWORD split_off, DWORD split_ind, WORD type, DWORD len_off = 0); | ||
60 | - DWORD Send(DWORD dwDataBase, DWORD dwRetn); | ||
61 | - int RecoverHook(); | ||
62 | - int RemoveHook(); | ||
63 | - int ClearHook(); | ||
64 | - int ModifyHook(const HookParam&); | ||
65 | - int SetHookName(LPCWSTR name); | ||
66 | - int GetLength(DWORD base, DWORD in); // jichi 12/25/2013: Return 0 if failed | ||
67 | - void CoolDown(); // jichi 9/28/2013: flush instruction cache on wine | ||
68 | -}; | ||
69 | - | ||
70 | -extern TextHook *hookman, | ||
71 | - *current_available; | ||
72 | - | ||
73 | -//void InitDefaultHook(); | ||
74 | - | ||
75 | -struct FilterRange { DWORD lower, upper; }; | ||
76 | -extern FilterRange *filter; | ||
77 | - | ||
78 | -extern bool running, | ||
79 | - live; | ||
80 | - | ||
81 | -extern HANDLE hPipe, | ||
82 | - hmMutex; | ||
83 | - | ||
84 | -DWORD WINAPI WaitForPipe(LPVOID lpThreadParameter); | ||
85 | -DWORD WINAPI CommandPipe(LPVOID lpThreadParameter); | ||
86 | - | ||
87 | -//void RequestRefreshProfile(); | ||
88 | - | ||
89 | -//typedef DWORD (*InsertHookFun)(DWORD); | ||
90 | -//typedef DWORD (*IdentifyEngineFun)(); | ||
91 | -//typedef DWORD (*InsertDynamicHookFun)(LPVOID addr, DWORD frame, DWORD stack); | ||
92 | -//extern IdentifyEngineFun IdentifyEngine; | ||
93 | -//extern InsertDynamicHookFun InsertDynamicHook; | ||
94 | - | ||
95 | -// jichi 9/28/2013: Protect pipeline in wine | ||
96 | -void CliLockPipe(); | ||
97 | -void CliUnlockPipe(); | ||
98 | - | ||
99 | -// EOF |
vnr/ith/hook/config.h
deleted
100644 → 0
vnr/ith/hook/engine/engine.cc
deleted
100644 → 0
This diff could not be displayed because it is too large.
vnr/ith/hook/engine/engine.h
deleted
100644 → 0
1 | -#pragma once | ||
2 | - | ||
3 | -// engine/engine.h | ||
4 | -// 8/23/2013 jichi | ||
5 | -// See: http://ja.wikipedia.org/wiki/プロジェクト:美少女ゲーム系/ゲームエンジン | ||
6 | - | ||
7 | -#include "config.h" | ||
8 | - | ||
9 | -struct HookParam; // defined in ith types.h | ||
10 | - | ||
11 | -namespace Engine { | ||
12 | - | ||
13 | -// Global variables | ||
14 | -extern wchar_t process_name_[MAX_PATH], // cached | ||
15 | - process_path_[MAX_PATH]; // cached | ||
16 | -extern DWORD module_base_, | ||
17 | - module_limit_; | ||
18 | - | ||
19 | -//extern LPVOID trigger_addr; | ||
20 | -typedef bool (* trigger_fun_t)(LPVOID addr, DWORD frame, DWORD stack); | ||
21 | -extern trigger_fun_t trigger_fun_; | ||
22 | - | ||
23 | -bool InsertMonoHooks(); // Mono | ||
24 | - | ||
25 | -// Wii engines | ||
26 | - | ||
27 | -bool InsertGCHooks(); // Dolphin | ||
28 | -bool InsertVanillawareGCHook(); | ||
29 | - | ||
30 | -// PS2 engines | ||
31 | - | ||
32 | -bool InsertPCSX2Hooks(); // PCSX2 | ||
33 | -bool InsertMarvelousPS2Hook(); // http://marvelous.jp | ||
34 | -bool InsertMarvelous2PS2Hook(); // http://marvelous.jp | ||
35 | -bool InsertTypeMoonPS2Hook(); // http://typemoon.com | ||
36 | -//bool InsertNamcoPS2Hook(); | ||
37 | - | ||
38 | -// PSP engines | ||
39 | - | ||
40 | -void SpecialPSPHook(DWORD esp_base, HookParam *hp, DWORD *data, DWORD *split, DWORD *len); // General PSP extern hook | ||
41 | - | ||
42 | -bool InsertPPSSPPHooks(); // PPSSPPWindows | ||
43 | - | ||
44 | -bool InsertPPSSPPHLEHooks(); | ||
45 | -bool InsertOtomatePPSSPPHook(); // PSP otomate.jp, 0.9.9.0 only | ||
46 | - | ||
47 | -bool Insert5pbPSPHook(); // PSP 5pb.jp | ||
48 | -bool InsertAlchemistPSPHook(); // PSP Alchemist-net.co.jp, 0.9.8 only | ||
49 | -bool InsertAlchemist2PSPHook(); // PSP Alchemist-net.co.jp | ||
50 | -bool InsertBandaiNamePSPHook(); // PSP Bandai.co.jp | ||
51 | -bool InsertBandaiPSPHook(); // PSP Bandai.co.jp | ||
52 | -bool InsertBroccoliPSPHook(); // PSP Broccoli.co.jp | ||
53 | -bool InsertFelistellaPSPHook(); // PSP felistella.co.jp | ||
54 | - | ||
55 | -bool InsertCyberfrontPSPHook(); // PSP CYBERFRONT (closed) | ||
56 | -bool InsertImageepochPSPHook(); // PSP Imageepoch.co.jp | ||
57 | -bool InsertImageepoch2PSPHook();// PSP Imageepoch.co.jp | ||
58 | -bool InsertKadokawaNamePSPHook(); // PSP Kadokawa.co.jp | ||
59 | -bool InsertKonamiPSPHook(); // PSP Konami.jp | ||
60 | -bool InsertTecmoPSPHook(); // PSP Koeitecmo.co.jp | ||
61 | -//bool InsertTypeMoonPSPHook(); // PSP Typemoon.com | ||
62 | - | ||
63 | -bool InsertOtomatePSPHook(); // PSP Otomate.jp, 0.9.8 only | ||
64 | -//bool InsertOtomate2PSPHook(); // PSP otomate.jp >= 0.9.9.1 | ||
65 | - | ||
66 | -bool InsertIntensePSPHook(); // PSP Intense.jp | ||
67 | -bool InsertKidPSPHook(); // PSP Kid-game.co.jp | ||
68 | -bool InsertNippon1PSPHook(); // PSP Nippon1.jp | ||
69 | -bool InsertNippon2PSPHook(); // PSP Nippon1.jp | ||
70 | -bool InsertYetiPSPHook(); // PSP Yetigame.jp | ||
71 | -bool InsertYeti2PSPHook(); // PSP Yetigame.jp | ||
72 | - | ||
73 | -// PC engines | ||
74 | - | ||
75 | -bool Insert2RMHook(); // 2RM - Adventure Engine | ||
76 | -bool Insert5pbHook(); // 5pb.jp, PSP/PS3 games ported to PC | ||
77 | -bool InsertAB2TryHook(); // Yane@AkabeiSoft2Try: YaneSDK.dll. | ||
78 | -bool InsertAbelHook(); // Abel | ||
79 | -bool InsertAdobeAirHook(); // Adobe AIR | ||
80 | -bool InsertAdobeFlash10Hook(); // Adobe Flash Player 10 | ||
81 | -bool InsertAliceHook(); // System40@AliceSoft; do not work for latest alice games | ||
82 | -bool InsertAmuseCraftHook(); // AMUSE CRAFT: *.pac | ||
83 | -bool InsertAnex86Hook(); // Anex86: anex86.exe | ||
84 | -bool InsertAOSHook(); // AOS: *.aos | ||
85 | -bool InsertApricoTHook(); // Apricot: arc.a* | ||
86 | -bool InsertArtemisHook(); // Artemis Engine: *.pfs | ||
87 | -bool InsertAtelierHook(); // Atelier Kaguya: message.dat | ||
88 | -bool InsertBGIHook(); // BGI: BGI.* | ||
89 | -bool InsertC4Hook(); // C4: C4.EXE or XEX.EXE | ||
90 | -bool InsertCaramelBoxHook(); // Caramel: *.bin | ||
91 | -bool InsertCandyHook(); // SystemC@CandySoft: *.fpk | ||
92 | -bool InsertCatSystemHook(); // CatSystem2: *.int | ||
93 | -bool InsertCMVSHook(); // CMVS: data/pack/*.cpz; do not support the latest cmvs32.exe and cmvs64.exe | ||
94 | -bool InsertCotophaHook(); // Cotopha: *.noa | ||
95 | -bool InsertDebonosuHook(); // Debonosu: bmp.bak and dsetup.dll | ||
96 | -bool InsertEaglsHook(); // E.A.G.L.S: EAGLES.dll | ||
97 | -bool InsertEMEHook(); // EmonEngine: emecfg.ecf | ||
98 | -bool InsertEushullyHook(); // Eushully: AGERC.DLL | ||
99 | -bool InsertExpHook(); // EXP: http://www.exp-inc.jp | ||
100 | -bool InsertFocasLensHook(); // FocasLens: Dat/*.arc, http://www.fo-lens.net | ||
101 | -bool InsertGesen18Hook(); // Gsen18: *.szs | ||
102 | -bool InsertGXPHook(); // GXP: *.gxp | ||
103 | -bool InsertHorkEyeHook(); // HorkEye: resource string | ||
104 | -bool InsertKAGParserHook(); // plugin/KAGParser.dll | ||
105 | -bool InsertKAGParserExHook(); // plugin/KAGParserEx.dll | ||
106 | -bool InsertKiriKiriHook(); // KiriKiri: *.xp3, resource string | ||
107 | -bool InsertKiriKiriZHook(); // KiriKiri: *.xp3, resource string | ||
108 | -bool InsertLeafHook(); // Leaf: *.pak | ||
109 | -bool InsertLiveHook(); // Live: live.dll | ||
110 | -bool InsertLunaSoftHook(); // LunaSoft: Pac/*.pac | ||
111 | -bool InsertMalieHook(); // Malie@light: malie.ini | ||
112 | -bool InsertMajiroHook(); // Majiro: *.arc | ||
113 | -bool InsertMarineHeartHook(); // Marine Heart: SAISYS.exe | ||
114 | -bool InsertMBLHook(); // MBL: *.mbl | ||
115 | -bool InsertMEDHook(); // MED: *.med | ||
116 | -bool InsertMinkHook(); // Mink: *.at2 | ||
117 | -//bool InsertMonoHook(); // Mono (Unity3D): */Mono/mono.dll | ||
118 | -bool InsertNeXASHook(); // NeXAS: Thumbnail.pac | ||
119 | -bool InsertNextonHook(); // NEXTON: aInfo.db | ||
120 | -bool InsertNexton1Hook(); | ||
121 | -bool InsertNitroPlusHook(); // NitroPlus: *.npa | ||
122 | -bool InsertPensilHook(); // Pensil: PSetup.exe | ||
123 | -bool InsertQLIEHook(); // QLiE: GameData/*.pack | ||
124 | -//bool InsertRai7Hook(); // Rai7puk: rai7.exe | ||
125 | -bool InsertRejetHook(); // Rejet: Module/{gd.dat,pf.dat,sd.dat} | ||
126 | -bool InsertRUGPHook(); // rUGP: rUGP.exe | ||
127 | -bool InsertRetouchHook(); // Retouch: resident.dll | ||
128 | -bool InsertRREHook(); // RunrunEngine: rrecfg.rcf | ||
129 | -bool InsertShinaHook(); // ShinaRio: Rio.ini | ||
130 | -bool InsertShinyDaysHook(); // ShinyDays | ||
131 | -bool InsertElfHook(); // elf: Silky.exe | ||
132 | -bool InsertScenarioPlayerHook();// sol-fa-soft: *.iar && *.sec5 | ||
133 | -bool InsertSiglusHook(); // SiglusEngine: SiglusEngine.exe | ||
134 | -bool InsertSideBHook(); // SideB: Copyright side-B | ||
135 | -bool InsertSyuntadaHook(); // Syuntada: dSoh.dat | ||
136 | -bool InsertSystem43Hook(); // System43@AliceSoft: AliceStart.ini | ||
137 | -bool InsertSystemAoiHook(); // SystemAoi: *.vfs | ||
138 | -bool InsertTanukiHook(); // Tanuki: *.tak | ||
139 | -bool InsertTaskforce2Hook(); // Taskforce2.exe | ||
140 | -bool InsertTencoHook(); // Tenco: Check.mdx | ||
141 | -bool InsertTriangleHook(); // Triangle: Execle.exe | ||
142 | -bool InsertYukaSystem2Hook(); // YukaSystem2: *.ykc | ||
143 | -bool InsertYurisHook(); // YU-RIS: *.ypf | ||
144 | -bool InsertWillPlusHook(); // WillPlus: Rio.arc | ||
145 | -bool InsertWolfHook(); // Wolf: Data.wolf | ||
146 | - | ||
147 | -void InsertBrunsHook(); // Bruns: bruns.exe | ||
148 | -void InsertIronGameSystemHook();// IroneGameSystem: igs_sample.exe | ||
149 | -void InsertLucifenHook(); // Lucifen@Navel: *.lpk | ||
150 | -void InsertRyokuchaHook(); // Ryokucha: _checksum.exe | ||
151 | -void InsertRealliveHook(); // RealLive: RealLive*.exe | ||
152 | -void InsertStuffScriptHook(); // Stuff: *.mpk | ||
153 | -void InsertTinkerBellHook(); // TinkerBell: arc00.dat | ||
154 | -void InsertWaffleHook(); // WAFFLE: cg.pak | ||
155 | - | ||
156 | -// CIRCUS: avdata/ | ||
157 | -bool InsertCircusHook1(); | ||
158 | -bool InsertCircusHook2(); | ||
159 | - | ||
160 | -} // namespace Engine | ||
161 | - | ||
162 | -// EOF |
vnr/ith/hook/engine/hookdefs.h
deleted
100644 → 0
vnr/ith/hook/engine/match.cc
deleted
100644 → 0
This diff is collapsed. Click to expand it.
vnr/ith/hook/engine/match.h
deleted
100644 → 0
1 | -#pragma once | ||
2 | - | ||
3 | -// engine/match.h | ||
4 | -// 8/23/2013 jichi | ||
5 | -// TODO: Clean up the interface to match game engines. | ||
6 | -// Split the engine match logic out of hooks. | ||
7 | -// Modify the game hook to allow replace functions for arbitary purpose | ||
8 | -// instead of just extracting text. | ||
9 | - | ||
10 | -#include "config.h" | ||
11 | - | ||
12 | -namespace Engine { | ||
13 | - | ||
14 | -void match(LPVOID lpThreadParameter); | ||
15 | - | ||
16 | -// jichi 10/21/2014: Return whether found the engine | ||
17 | -bool IdentifyEngine(); | ||
18 | - | ||
19 | -// jichi 10/21/2014: Return 0 if failed | ||
20 | -DWORD InsertDynamicHook(LPVOID addr, DWORD frame, DWORD stack); | ||
21 | - | ||
22 | -} // namespace Engine | ||
23 | - | ||
24 | -// EOF |
vnr/ith/hook/engine/pchooks.cc
deleted
100644 → 0
1 | -// pchooks.cc | ||
2 | -// 8/1/2014 jichi | ||
3 | - | ||
4 | -#include "engine/pchooks.h" | ||
5 | -#include "hook.h" | ||
6 | - | ||
7 | -#define DEBUG "vnrcli" | ||
8 | -#define DPRINT(cstr) ConsoleOutput(DEBUG ":" __FUNCTION__ ":" cstr) // defined in vnrcli | ||
9 | - | ||
10 | -// 8/1/2014 jichi: Split is not used. | ||
11 | -// Although split is specified, USING_SPLIT is not assigned. | ||
12 | - | ||
13 | -// Use LPASTE to convert to wchar_t | ||
14 | -// http://bytes.com/topic/c/answers/135834-defining-wide-character-strings-macros | ||
15 | -#define LPASTE(s) L##s | ||
16 | -#define L(s) LPASTE(s) | ||
17 | -#define NEW_HOOK(_fun, _data, _data_ind, _split_off, _split_ind, _type, _len_off) \ | ||
18 | - { \ | ||
19 | - HookParam hp = {}; \ | ||
20 | - hp.addr = (DWORD)_fun; \ | ||
21 | - hp.off = _data; \ | ||
22 | - hp.ind = _data_ind; \ | ||
23 | - hp.split = _split_off; \ | ||
24 | - hp.split_ind = _split_ind; \ | ||
25 | - hp.type = _type; \ | ||
26 | - hp.length_offset = _len_off; \ | ||
27 | - NewHook(hp, L(#_fun)); \ | ||
28 | - } | ||
29 | - | ||
30 | -// jichi 7/17/2014: Renamed from InitDefaultHook | ||
31 | -void PcHooks::hookGDIFunctions() | ||
32 | -{ | ||
33 | - DPRINT("enter"); | ||
34 | - // int TextHook::InitHook(LPVOID addr, DWORD data, DWORD data_ind, DWORD split_off, DWORD split_ind, WORD type, DWORD len_off) | ||
35 | - // | ||
36 | - // jichi 9/8/2013: Guessed meaning | ||
37 | - // - data(off): 4 * the n-th (base 1) parameter representing the data of the string | ||
38 | - // - len_off: | ||
39 | - // - the n-th (base 1) parameter representing the length of the string | ||
40 | - // - or 1 if is char | ||
41 | - // - or 0 if detect on run time | ||
42 | - // - type: USING_STRING if len_off != 1 else BIG_ENDIAN or USING_UNICODE | ||
43 | - // | ||
44 | - // Examples: | ||
45 | - // int WINAPI lstrlenA(LPCSTR lpString) | ||
46 | - // - data: 4 * 1 = 4, as lpString is the first | ||
47 | - // - len_off: 0, as no parameter representing string length | ||
48 | - // - type: BIG_ENDIAN, since len_off == 1 | ||
49 | - // BOOL GetTextExtentPoint32(HDC hdc, LPCTSTR lpString, int c, LPSIZE lpSize); | ||
50 | - // - data: 4 * 2 = 0x8, as lpString is the second | ||
51 | - // - len_off: 3, as nCount is the 3rd parameter | ||
52 | - // - type: USING_STRING, since len_off != 1 | ||
53 | - // | ||
54 | - // Note: All functions does not have NO_CONTEXT attribute and will be filtered. | ||
55 | - | ||
56 | - enum stack { | ||
57 | - s_retaddr = 0 | ||
58 | - , s_arg1 = 4 * 1 // 0x4 | ||
59 | - , s_arg2 = 4 * 2 // 0x8 | ||
60 | - , s_arg3 = 4 * 3 // 0xc | ||
61 | - , s_arg4 = 4 * 4 // 0x10 | ||
62 | - , s_arg5 = 4 * 5 // 0x14 | ||
63 | - , s_arg6 = 4 * 6 // 0x18 | ||
64 | - }; | ||
65 | - | ||
66 | -//#define _(Name, ...) \ | ||
67 | -// hookman[HF_##Name].InitHook(Name, __VA_ARGS__); \ | ||
68 | -// hookman[HF_##Name].SetHookName(names[HF_##Name]); | ||
69 | - | ||
70 | - // Always use s_arg1 = hDC as split_off | ||
71 | - // 7/26/2014 jichi: Why there is no USING_SPLIT type? | ||
72 | - | ||
73 | - // gdi32.dll | ||
74 | - NEW_HOOK(GetTextExtentPoint32A, s_arg2, 0,s_arg1,0, USING_STRING, 3) // BOOL GetTextExtentPoint32(HDC hdc, LPCTSTR lpString, int c, LPSIZE lpSize); | ||
75 | - NEW_HOOK(GetGlyphOutlineA, s_arg2, 0,s_arg1,0, BIG_ENDIAN, 1) // DWORD GetGlyphOutline(HDC hdc, UINT uChar, UINT uFormat, LPGLYPHMETRICS lpgm, DWORD cbBuffer, LPVOID lpvBuffer, const MAT2 *lpmat2); | ||
76 | - NEW_HOOK(ExtTextOutA, s_arg6, 0,s_arg1,0, USING_STRING, 7) // BOOL ExtTextOut(HDC hdc, int X, int Y, UINT fuOptions, const RECT *lprc, LPCTSTR lpString, UINT cbCount, const INT *lpDx); | ||
77 | - NEW_HOOK(TextOutA, s_arg4, 0,s_arg1,0, USING_STRING, 5) // BOOL TextOut(HDC hdc, int nXStart, int nYStart, LPCTSTR lpString, int cchString); | ||
78 | - NEW_HOOK(GetCharABCWidthsA, s_arg2, 0,s_arg1,0, BIG_ENDIAN, 1) // BOOL GetCharABCWidths(HDC hdc, UINT uFirstChar, UINT uLastChar, LPABC lpabc); | ||
79 | - NEW_HOOK(GetTextExtentPoint32W, s_arg2, 0,s_arg1,0, USING_UNICODE|USING_STRING, 3) | ||
80 | - NEW_HOOK(GetGlyphOutlineW, s_arg2, 0,s_arg1,0, USING_UNICODE, 1) | ||
81 | - NEW_HOOK(ExtTextOutW, s_arg6, 0,s_arg1,0, USING_UNICODE|USING_STRING, 7) | ||
82 | - NEW_HOOK(TextOutW, s_arg4, 0,s_arg1,0, USING_UNICODE|USING_STRING, 5) | ||
83 | - NEW_HOOK(GetCharABCWidthsW, s_arg2, 0,s_arg1,0, USING_UNICODE, 1) | ||
84 | - | ||
85 | - // user32.dll | ||
86 | - NEW_HOOK(DrawTextA, s_arg2, 0,s_arg1,0, USING_STRING, 3) // int DrawText(HDC hDC, LPCTSTR lpchText, int nCount, LPRECT lpRect, UINT uFormat); | ||
87 | - NEW_HOOK(DrawTextExA, s_arg2, 0,s_arg1,0, USING_STRING, 3) // int DrawTextEx(HDC hdc, LPTSTR lpchText,int cchText, LPRECT lprc, UINT dwDTFormat, LPDRAWTEXTPARAMS lpDTParams); | ||
88 | - NEW_HOOK(DrawTextW, s_arg2, 0,s_arg1,0, USING_UNICODE|USING_STRING, 3) | ||
89 | - NEW_HOOK(DrawTextExW, s_arg2, 0,s_arg1,0, USING_UNICODE|USING_STRING, 3) | ||
90 | -//#undef _ | ||
91 | - DPRINT("leave"); | ||
92 | -} | ||
93 | - | ||
94 | -// jichi 10/2/2013 | ||
95 | -// Note: All functions does not have NO_CONTEXT attribute and will be filtered. | ||
96 | -void PcHooks::hookLstrFunctions() | ||
97 | -{ | ||
98 | - DPRINT("enter"); | ||
99 | - // int TextHook::InitHook(LPVOID addr, DWORD data, DWORD data_ind, DWORD split_off, DWORD split_ind, WORD type, DWORD len_off) | ||
100 | - | ||
101 | - enum stack { | ||
102 | - s_retaddr = 0 | ||
103 | - , s_arg1 = 4 * 1 // 0x4 | ||
104 | - //, s_arg2 = 4 * 2 // 0x8 | ||
105 | - //, s_arg3 = 4 * 3 // 0xc | ||
106 | - //, s_arg4 = 4 * 4 // 0x10 | ||
107 | - //, s_arg5 = 4 * 5 // 0x14 | ||
108 | - //, s_arg6 = 4 * 6 // 0x18 | ||
109 | - }; | ||
110 | - | ||
111 | - // http://msdn.microsoft.com/en-us/library/78zh94ax.aspx | ||
112 | - // int WINAPI lstrlen(LPCTSTR lpString); | ||
113 | - // Lstr functions usually extracts rubbish, and might crash certain games like 「Magical Marriage Lunatics!!」 | ||
114 | - // Needed by Gift | ||
115 | - // Use arg1 address for both split and data | ||
116 | - NEW_HOOK(lstrlenA, s_arg1, 0,s_arg1,0, USING_STRING, 0) // 9/8/2013 jichi: int WINAPI lstrlen(LPCTSTR lpString); | ||
117 | - NEW_HOOK(lstrlenW, s_arg1, 0,s_arg1,0, USING_UNICODE|USING_STRING, 0) // 9/8/2013 jichi: add lstrlen | ||
118 | - | ||
119 | - // size_t strlen(const char *str); | ||
120 | - // size_t strlen_l(const char *str, _locale_t locale); | ||
121 | - // size_t wcslen(const wchar_t *str); | ||
122 | - // size_t wcslen_l(const wchar_t *str, _locale_t locale); | ||
123 | - // size_t _mbslen(const unsigned char *str); | ||
124 | - // size_t _mbslen_l(const unsigned char *str, _locale_t locale); | ||
125 | - // size_t _mbstrlen(const char *str); | ||
126 | - // size_t _mbstrlen_l(const char *str, _locale_t locale); | ||
127 | - | ||
128 | - // http://msdn.microsoft.com/en-us/library/ex0hs2ad.aspx | ||
129 | - // Needed by 娘姉妹 | ||
130 | - // | ||
131 | - // <tchar.h> | ||
132 | - // char *_strinc(const char *current, _locale_t locale); | ||
133 | - // wchar_t *_wcsinc(const wchar_t *current, _locale_t locale); | ||
134 | - // <mbstring.h> | ||
135 | - // unsigned char *_mbsinc(const unsigned char *current); | ||
136 | - // unsigned char *_mbsinc_l(const unsigned char *current, _locale_t locale); | ||
137 | - //_(L"_strinc", _strinc, 4, 0,4,0, USING_STRING, 0) // 12/13/2013 jichi | ||
138 | - //_(L"_wcsinc", _wcsinc, 4, 0,4,0, USING_UNICODE|USING_STRING, 0) | ||
139 | - DPRINT("leave"); | ||
140 | -} | ||
141 | - | ||
142 | -void PcHooks::hookWcharFunctions() | ||
143 | -{ | ||
144 | - DPRINT("enter"); | ||
145 | - // 12/1/2013 jichi: | ||
146 | - // AlterEgo | ||
147 | - // http://tieba.baidu.com/p/2736475133 | ||
148 | - // http://www.hongfire.com/forum/showthread.php/36807-AGTH-text-extraction-tool-for-games-translation/page355 | ||
149 | - // | ||
150 | - // MultiByteToWideChar | ||
151 | - // http://blgames.proboards.com/thread/265 | ||
152 | - // | ||
153 | - // WideCharToMultiByte | ||
154 | - // http://www.hongfire.com/forum/showthread.php/36807-AGTH-text-extraction-tool-for-games-translation/page156 | ||
155 | - // | ||
156 | - // int MultiByteToWideChar( | ||
157 | - // _In_ UINT CodePage, | ||
158 | - // _In_ DWORD dwFlags, | ||
159 | - // _In_ LPCSTR lpMultiByteStr, // hook here | ||
160 | - // _In_ int cbMultiByte, | ||
161 | - // _Out_opt_ LPWSTR lpWideCharStr, | ||
162 | - // _In_ int cchWideChar | ||
163 | - // ); | ||
164 | - // int WideCharToMultiByte( | ||
165 | - // _In_ UINT CodePage, | ||
166 | - // _In_ DWORD dwFlags, | ||
167 | - // _In_ LPCWSTR lpWideCharStr, | ||
168 | - // _In_ int cchWideChar, | ||
169 | - // _Out_opt_ LPSTR lpMultiByteStr, | ||
170 | - // _In_ int cbMultiByte, | ||
171 | - // _In_opt_ LPCSTR lpDefaultChar, | ||
172 | - // _Out_opt_ LPBOOL lpUsedDefaultChar | ||
173 | - // ); | ||
174 | - | ||
175 | - enum stack { | ||
176 | - s_retaddr = 0 | ||
177 | - //, s_arg1 = 4 * 1 // 0x4 | ||
178 | - //, s_arg2 = 4 * 2 // 0x8 | ||
179 | - , s_arg3 = 4 * 3 // 0xc | ||
180 | - //, s_arg4 = 4 * 4 // 0x10 | ||
181 | - //, s_arg5 = 4 * 5 // 0x14 | ||
182 | - //, s_arg6 = 4 * 6 // 0x18 | ||
183 | - }; | ||
184 | - | ||
185 | - // 3/17/2014 jichi: Temporarily disabled | ||
186 | - // http://sakuradite.com/topic/159 | ||
187 | - NEW_HOOK(MultiByteToWideChar, s_arg3, 0,4,0, USING_STRING, 4) | ||
188 | - NEW_HOOK(WideCharToMultiByte, s_arg3, 0,4,0, USING_UNICODE|USING_STRING, 4) | ||
189 | - DPRINT("leave"); | ||
190 | -} | ||
191 | - | ||
192 | -// EOF |
vnr/ith/hook/engine/pchooks.h
deleted
100644 → 0
vnr/ith/hook/engine/util.cc
deleted
100644 → 0
1 | -// util/util.cc | ||
2 | -// 8/23/2013 jichi | ||
3 | -// Branch: ITH_Engine/engine.cpp, revision 133 | ||
4 | -// See: http://ja.wikipedia.org/wiki/プロジェクト:美少女ゲーム系/ゲームエンジン | ||
5 | - | ||
6 | -#include "engine/util.h" | ||
7 | -#include "ith/sys/sys.h" | ||
8 | - | ||
9 | -namespace { // unnamed | ||
10 | - | ||
11 | -// jichi 4/19/2014: Return the integer that can mask the signature | ||
12 | -DWORD SigMask(DWORD sig) | ||
13 | -{ | ||
14 | - __asm | ||
15 | - { | ||
16 | - xor ecx,ecx | ||
17 | - mov eax,sig | ||
18 | -_mask: | ||
19 | - shr eax,8 | ||
20 | - inc ecx | ||
21 | - test eax,eax | ||
22 | - jnz _mask | ||
23 | - sub ecx,4 | ||
24 | - neg ecx | ||
25 | - or eax,-1 | ||
26 | - shl ecx,3 | ||
27 | - shr eax,cl | ||
28 | - } | ||
29 | -} | ||
30 | - | ||
31 | -} // namespace unnamed | ||
32 | - | ||
33 | -// jichi 8/24/2013: binary search? | ||
34 | -DWORD Util::GetCodeRange(DWORD hModule,DWORD *low, DWORD *high) | ||
35 | -{ | ||
36 | - IMAGE_DOS_HEADER *DosHdr; | ||
37 | - IMAGE_NT_HEADERS *NtHdr; | ||
38 | - DWORD dwReadAddr; | ||
39 | - IMAGE_SECTION_HEADER *shdr; | ||
40 | - DosHdr = (IMAGE_DOS_HEADER *)hModule; | ||
41 | - if (IMAGE_DOS_SIGNATURE == DosHdr->e_magic) { | ||
42 | - dwReadAddr = hModule + DosHdr->e_lfanew; | ||
43 | - NtHdr = (IMAGE_NT_HEADERS *)dwReadAddr; | ||
44 | - if (IMAGE_NT_SIGNATURE == NtHdr->Signature) { | ||
45 | - shdr = (PIMAGE_SECTION_HEADER)((DWORD)(&NtHdr->OptionalHeader) + NtHdr->FileHeader.SizeOfOptionalHeader); | ||
46 | - while ((shdr->Characteristics & IMAGE_SCN_CNT_CODE) == 0) | ||
47 | - shdr++; | ||
48 | - *low = hModule + shdr->VirtualAddress; | ||
49 | - *high = *low + (shdr->Misc.VirtualSize & 0xfffff000) + 0x1000; | ||
50 | - } | ||
51 | - } | ||
52 | - return 0; | ||
53 | -} | ||
54 | - | ||
55 | -DWORD Util::FindCallAndEntryBoth(DWORD fun, DWORD size, DWORD pt, DWORD sig) | ||
56 | -{ | ||
57 | - //WCHAR str[0x40]; | ||
58 | - enum { reverse_length = 0x800 }; | ||
59 | - DWORD t, l; | ||
60 | - DWORD mask = SigMask(sig); | ||
61 | - bool flag2; | ||
62 | - for (DWORD i = 0x1000; i < size-4; i++) { | ||
63 | - bool flag1 = false; | ||
64 | - if (*(BYTE *)(pt + i) == 0xe8) { | ||
65 | - flag1 = flag2 = true; | ||
66 | - t = *(DWORD *)(pt + i + 1); | ||
67 | - } else if (*(WORD *)(pt + i) == 0x15ff) { | ||
68 | - flag1 = true; | ||
69 | - flag2 = false; | ||
70 | - t = *(DWORD *)(pt + i + 2); | ||
71 | - } | ||
72 | - if (flag1) { | ||
73 | - if (flag2) { | ||
74 | - flag1 = (pt + i + 5 + t == fun); | ||
75 | - l = 5; | ||
76 | - } else if (t >= pt && t <= pt + size - 4) { | ||
77 | - flag1 = fun == *(DWORD *)t; | ||
78 | - l = 6; | ||
79 | - } else | ||
80 | - flag1 = false; | ||
81 | - if (flag1) | ||
82 | - //swprintf(str,L"CALL addr: 0x%.8X",pt + i); | ||
83 | - //OutputConsole(str); | ||
84 | - for (DWORD j = i; j > i - reverse_length; j--) | ||
85 | - if ((*(WORD *)(pt + j)) == (sig & mask)) //Fun entry 1. | ||
86 | - //swprintf(str,L"Entry: 0x%.8X",pt + j); | ||
87 | - //OutputConsole(str); | ||
88 | - return pt + j; | ||
89 | - else | ||
90 | - i += l; | ||
91 | - } | ||
92 | - } | ||
93 | - //OutputConsole(L"Find call and entry failed."); | ||
94 | - return 0; | ||
95 | -} | ||
96 | - | ||
97 | -DWORD Util::FindCallOrJmpRel(DWORD fun, DWORD size, DWORD pt, bool jmp) | ||
98 | -{ | ||
99 | - BYTE sig = (jmp) ? 0xe9 : 0xe8; | ||
100 | - for (DWORD i = 0x1000; i < size - 4; i++) | ||
101 | - if (sig == *(BYTE *)(pt + i)) { | ||
102 | - DWORD t = *(DWORD *)(pt + i + 1); | ||
103 | - if(fun == pt + i + 5 + t) | ||
104 | - //OutputDWORD(pt + i); | ||
105 | - return pt + i; | ||
106 | - else | ||
107 | - i += 5; | ||
108 | - } | ||
109 | - return 0; | ||
110 | -} | ||
111 | - | ||
112 | -DWORD Util::FindCallOrJmpAbs(DWORD fun, DWORD size, DWORD pt, bool jmp) | ||
113 | -{ | ||
114 | - WORD sig = jmp ? 0x25ff : 0x15ff; | ||
115 | - for (DWORD i = 0x1000; i < size - 4; i++) | ||
116 | - if (sig == *(WORD *)(pt + i)) { | ||
117 | - DWORD t = *(DWORD *)(pt + i + 2); | ||
118 | - if (t > pt && t < pt + size) { | ||
119 | - if (fun == *(DWORD *)t) | ||
120 | - return pt + i; | ||
121 | - else | ||
122 | - i += 5; | ||
123 | - } | ||
124 | - } | ||
125 | - return 0; | ||
126 | -} | ||
127 | - | ||
128 | -DWORD Util::FindCallBoth(DWORD fun, DWORD size, DWORD pt) | ||
129 | -{ | ||
130 | - for (DWORD i = 0x1000; i < size - 4; i++) { | ||
131 | - if (*(BYTE *)(pt + i) == 0xe8) { | ||
132 | - DWORD t = *(DWORD *)(pt + i + 1) + pt + i + 5; | ||
133 | - if (t == fun) | ||
134 | - return i; | ||
135 | - } | ||
136 | - if (*(WORD *)(pt + i) == 0x15ff) { | ||
137 | - DWORD t = *(DWORD *)(pt + i + 2); | ||
138 | - if (t >= pt && t <= pt + size - 4) { | ||
139 | - if (*(DWORD *)t == fun) | ||
140 | - return i; | ||
141 | - else | ||
142 | - i += 6; | ||
143 | - } | ||
144 | - } | ||
145 | - } | ||
146 | - return 0; | ||
147 | -} | ||
148 | - | ||
149 | -DWORD Util::FindCallAndEntryAbs(DWORD fun, DWORD size, DWORD pt, DWORD sig) | ||
150 | -{ | ||
151 | - //WCHAR str[0x40]; | ||
152 | - enum { reverse_length = 0x800 }; | ||
153 | - DWORD mask = SigMask(sig); | ||
154 | - for (DWORD i = 0x1000; i < size - 4; i++) | ||
155 | - if (*(WORD *)(pt + i) == 0x15ff) { | ||
156 | - DWORD t = *(DWORD *)(pt + i + 2); | ||
157 | - if (t >= pt && t <= pt + size - 4) { | ||
158 | - if (*(DWORD *)t == fun) | ||
159 | - //swprintf(str,L"CALL addr: 0x%.8X",pt + i); | ||
160 | - //OutputConsole(str); | ||
161 | - for (DWORD j = i ; j > i - reverse_length; j--) | ||
162 | - if ((*(DWORD *)(pt + j) & mask) == sig) // Fun entry 1. | ||
163 | - //swprintf(str,L"Entry: 0x%.8X",pt + j); | ||
164 | - //OutputConsole(str); | ||
165 | - return pt + j; | ||
166 | - | ||
167 | - } else | ||
168 | - i += 6; | ||
169 | - } | ||
170 | - //OutputConsole(L"Find call and entry failed."); | ||
171 | - return 0; | ||
172 | -} | ||
173 | - | ||
174 | -DWORD Util::FindCallAndEntryRel(DWORD fun, DWORD size, DWORD pt, DWORD sig) | ||
175 | -{ | ||
176 | - //WCHAR str[0x40]; | ||
177 | - enum { reverse_length = 0x800 }; | ||
178 | - if (DWORD i = FindCallOrJmpRel(fun, size, pt, false)) { | ||
179 | - DWORD mask = SigMask(sig); | ||
180 | - for (DWORD j = i; j > i - reverse_length; j--) | ||
181 | - if (((*(DWORD *)j) & mask) == sig) //Fun entry 1. | ||
182 | - //swprintf(str,L"Entry: 0x%.8X",j); | ||
183 | - //OutputConsole(str); | ||
184 | - return j; | ||
185 | - //OutputConsole(L"Find call and entry failed."); | ||
186 | - } | ||
187 | - return 0; | ||
188 | -} | ||
189 | -DWORD Util::FindEntryAligned(DWORD start, DWORD back_range) | ||
190 | -{ | ||
191 | - start &= ~0xf; | ||
192 | - for (DWORD i = start, j = start - back_range; i > j; i-=0x10) { | ||
193 | - DWORD k = *(DWORD *)(i-4); | ||
194 | - if (k == 0xcccccccc | ||
195 | - || k == 0x90909090 | ||
196 | - || k == 0xccccccc3 | ||
197 | - || k == 0x909090c3 | ||
198 | - ) | ||
199 | - return i; | ||
200 | - DWORD t = k & 0xff0000ff; | ||
201 | - if (t == 0xcc0000c2 || t == 0x900000c2) | ||
202 | - return i; | ||
203 | - k >>= 8; | ||
204 | - if (k == 0xccccc3 || k == 0x9090c3) | ||
205 | - return i; | ||
206 | - t = k & 0xff; | ||
207 | - if (t == 0xc2) | ||
208 | - return i; | ||
209 | - k >>= 8; | ||
210 | - if (k == 0xccc3 || k == 0x90c3) | ||
211 | - return i; | ||
212 | - k >>= 8; | ||
213 | - if (k == 0xc3) | ||
214 | - return i; | ||
215 | - } | ||
216 | - return 0; | ||
217 | -} | ||
218 | - | ||
219 | -DWORD Util::FindImportEntry(DWORD hModule, DWORD fun) | ||
220 | -{ | ||
221 | - IMAGE_DOS_HEADER *DosHdr; | ||
222 | - IMAGE_NT_HEADERS *NtHdr; | ||
223 | - DWORD IAT, end, pt, addr; | ||
224 | - DosHdr = (IMAGE_DOS_HEADER *)hModule; | ||
225 | - if (IMAGE_DOS_SIGNATURE == DosHdr->e_magic) { | ||
226 | - NtHdr = (IMAGE_NT_HEADERS *)(hModule + DosHdr->e_lfanew); | ||
227 | - if (IMAGE_NT_SIGNATURE == NtHdr->Signature) { | ||
228 | - IAT = NtHdr->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress; | ||
229 | - end = NtHdr->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].Size; | ||
230 | - IAT += hModule; | ||
231 | - end += IAT; | ||
232 | - for (pt = IAT; pt < end; pt += 4) { | ||
233 | - addr = *(DWORD *)pt; | ||
234 | - if (addr == fun) | ||
235 | - return pt; | ||
236 | - } | ||
237 | - } | ||
238 | - } | ||
239 | - return 0; | ||
240 | -} | ||
241 | - | ||
242 | -// Search string in rsrc section. This section usually contains version and copyright info. | ||
243 | -bool Util::SearchResourceString(LPCWSTR str) | ||
244 | -{ | ||
245 | - DWORD hModule = Util::GetModuleBase(); | ||
246 | - IMAGE_DOS_HEADER *DosHdr; | ||
247 | - IMAGE_NT_HEADERS *NtHdr; | ||
248 | - DosHdr = (IMAGE_DOS_HEADER *)hModule; | ||
249 | - DWORD rsrc, size; | ||
250 | - //__asm int 3 | ||
251 | - if (IMAGE_DOS_SIGNATURE == DosHdr->e_magic) { | ||
252 | - NtHdr = (IMAGE_NT_HEADERS *)(hModule + DosHdr->e_lfanew); | ||
253 | - if (IMAGE_NT_SIGNATURE == NtHdr->Signature) { | ||
254 | - rsrc = NtHdr->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress; | ||
255 | - if (rsrc) { | ||
256 | - rsrc += hModule; | ||
257 | - if (IthGetMemoryRange((LPVOID)rsrc, &rsrc ,&size) && | ||
258 | - SearchPattern(rsrc, size - 4, str, wcslen(str) << 1)) | ||
259 | - return true; | ||
260 | - } | ||
261 | - } | ||
262 | - } | ||
263 | - return false; | ||
264 | -} | ||
265 | - | ||
266 | -// jichi 4/15/2014: Copied from GetModuleBase in ITH CLI, for debugging purpose | ||
267 | -DWORD Util::FindModuleBase(DWORD hash) | ||
268 | -{ | ||
269 | - __asm | ||
270 | - { | ||
271 | - mov eax,fs:[0x30] | ||
272 | - mov eax,[eax+0xc] | ||
273 | - mov esi,[eax+0x14] | ||
274 | - mov edi,_wcslwr | ||
275 | -listfind: | ||
276 | - mov edx,[esi+0x28] | ||
277 | - test edx,edx | ||
278 | - jz notfound | ||
279 | - push edx | ||
280 | - call edi | ||
281 | - pop edx | ||
282 | - xor eax,eax | ||
283 | -calc: | ||
284 | - movzx ecx, word ptr [edx] | ||
285 | - test cl,cl | ||
286 | - jz fin | ||
287 | - ror eax,7 | ||
288 | - add eax,ecx | ||
289 | - add edx,2 | ||
290 | - jmp calc | ||
291 | -fin: | ||
292 | - cmp eax,[hash] | ||
293 | - je found | ||
294 | - mov esi,[esi] | ||
295 | - jmp listfind | ||
296 | -notfound: | ||
297 | - xor eax,eax | ||
298 | - jmp termin | ||
299 | -found: | ||
300 | - mov eax,[esi+0x10] | ||
301 | -termin: | ||
302 | - } | ||
303 | -} | ||
304 | - | ||
305 | -// EOF |
vnr/ith/hook/engine/util.h
deleted
100644 → 0
1 | -#pragma once | ||
2 | - | ||
3 | -// util/util.h | ||
4 | -// 8/23/2013 jichi | ||
5 | - | ||
6 | -#include "config.h" | ||
7 | - | ||
8 | -namespace Util { | ||
9 | - | ||
10 | -DWORD GetCodeRange(DWORD hModule,DWORD *low, DWORD *high); | ||
11 | -DWORD FindCallAndEntryBoth(DWORD fun, DWORD size, DWORD pt, DWORD sig); | ||
12 | -DWORD FindCallOrJmpRel(DWORD fun, DWORD size, DWORD pt, bool jmp); | ||
13 | -DWORD FindCallOrJmpAbs(DWORD fun, DWORD size, DWORD pt, bool jmp); | ||
14 | -DWORD FindCallBoth(DWORD fun, DWORD size, DWORD pt); | ||
15 | -DWORD FindCallAndEntryAbs(DWORD fun, DWORD size, DWORD pt, DWORD sig); | ||
16 | -DWORD FindCallAndEntryRel(DWORD fun, DWORD size, DWORD pt, DWORD sig); | ||
17 | -DWORD FindEntryAligned(DWORD start, DWORD back_range); | ||
18 | -DWORD FindImportEntry(DWORD hModule, DWORD fun); | ||
19 | - | ||
20 | -// jichi 4/15/2014: Copied from ITH CLI, for debugging purpose | ||
21 | -DWORD FindModuleBase(DWORD hash); | ||
22 | - | ||
23 | -bool SearchResourceString(LPCWSTR str); | ||
24 | - | ||
25 | -/** | ||
26 | - * @param name process name without path deliminator | ||
27 | - */ | ||
28 | -inline void GetProcessName(wchar_t *name) | ||
29 | -{ | ||
30 | - //assert(name); | ||
31 | - PLDR_DATA_TABLE_ENTRY it; | ||
32 | - __asm | ||
33 | - { | ||
34 | - mov eax,fs:[0x30] | ||
35 | - mov eax,[eax+0xc] | ||
36 | - mov eax,[eax+0xc] | ||
37 | - mov it,eax | ||
38 | - } | ||
39 | - ::wcscpy(name, it->BaseDllName.Buffer); | ||
40 | -} | ||
41 | - | ||
42 | -/** | ||
43 | - * @param path with process name and directy name | ||
44 | - */ | ||
45 | -inline void GetProcessPath(wchar_t *path) | ||
46 | -{ | ||
47 | - //assert(path); | ||
48 | - PLDR_DATA_TABLE_ENTRY it; | ||
49 | - __asm | ||
50 | - { | ||
51 | - mov eax,fs:[0x30] | ||
52 | - mov eax,[eax+0xc] | ||
53 | - mov eax,[eax+0xc] | ||
54 | - mov it,eax | ||
55 | - } | ||
56 | - ::wcscpy(path, it->FullDllName.Buffer); | ||
57 | -} | ||
58 | - | ||
59 | -/** | ||
60 | - * @return HANDLE module handle | ||
61 | - */ | ||
62 | -inline DWORD GetModuleBase() | ||
63 | -{ | ||
64 | - __asm | ||
65 | - { | ||
66 | - mov eax,fs:[0x18] | ||
67 | - mov eax,[eax+0x30] | ||
68 | - mov eax,[eax+0xc] | ||
69 | - mov eax,[eax+0xc] | ||
70 | - mov eax,[eax+0x18] | ||
71 | - } | ||
72 | -} | ||
73 | - | ||
74 | -} // namespace Util | ||
75 | - | ||
76 | -// EOF |
vnr/ith/hook/hijack/texthook.cc
deleted
100644 → 0
This diff is collapsed. Click to expand it.
vnr/ith/hook/hook.h
deleted
100644 → 0
1 | -#pragma once | ||
2 | - | ||
3 | -// hook.h | ||
4 | -// 8/23/2013 jichi | ||
5 | -// Branch: ITH/IHF_DLL.h, rev 66 | ||
6 | - | ||
7 | -#include "ith/common/const.h" | ||
8 | -#include "ith/common/types.h" | ||
9 | - | ||
10 | -//#ifdef IHF | ||
11 | -//# define IHFAPI __declspec(dllexport) __stdcall | ||
12 | -//#else | ||
13 | -//# define IHFAPI __declspec(dllimport) __stdcall | ||
14 | -//#endif // IHF | ||
15 | -#define IHFAPI // 9/19/2014 jichi: dummy | ||
16 | - | ||
17 | -//extern "C" { | ||
18 | -//DWORD IHFAPI OutputConsole(LPCWSTR text); | ||
19 | -void IHFAPI ConsoleOutput(LPCSTR text); // jichi 12/25/2013: Used to return length of sent text | ||
20 | -//DWORD IHFAPI OutputDWORD(DWORD d); | ||
21 | -//DWORD IHFAPI OutputRegister(DWORD *base); | ||
22 | -DWORD IHFAPI NotifyHookInsert(DWORD addr); | ||
23 | -DWORD IHFAPI NewHook(const HookParam &hp, LPCWSTR name, DWORD flag = HOOK_ENGINE); | ||
24 | -DWORD IHFAPI RemoveHook(DWORD addr); | ||
25 | -DWORD IHFAPI SwitchTrigger(DWORD on); | ||
26 | -DWORD IHFAPI GetFunctionAddr(const char *name, DWORD *addr, DWORD *base, DWORD *size, LPWSTR *base_name); | ||
27 | -//DWORD IHFAPI RegisterEngineModule(DWORD idEngine, DWORD dnHook); | ||
28 | -//} // extern "C" | ||
29 | - | ||
30 | -// 10/21/2014 jichi: TODO: Get rid of this global variable | ||
31 | -// Defined in pipe.cc | ||
32 | -extern bool engine_registered; | ||
33 | - | ||
34 | - | ||
35 | -// 10/14/2014 jichi: disable GDI hooks | ||
36 | -void DisableGDIHooks(); | ||
37 | - | ||
38 | -// EOF |
vnr/ith/hook/hook.pro
deleted
100644 → 0
1 | -# hook.pro | ||
2 | -# 8/9/2013 jichi | ||
3 | -# Build vnrhook.dll for Windows 7+ | ||
4 | - | ||
5 | -CONFIG += eh eha # exception handler to catch all exceptions | ||
6 | -#CONFIG += noeh # msvcrt on Windows XP does not has exception handler | ||
7 | -include(../dllconfig.pri) | ||
8 | -include(../sys/sys.pri) | ||
9 | -include($$LIBDIR/disasm/disasm.pri) | ||
10 | -include($$LIBDIR/memdbg/memdbg.pri) | ||
11 | -include($$LIBDIR/ntinspect/ntinspect.pri) | ||
12 | -#include($$LIBDIR/winseh/winseh_safe.pri) | ||
13 | -include($$LIBDIR/winversion/winversion.pri) | ||
14 | - | ||
15 | -# 9/27/2013: disable ITH this game engine, only for debugging purpose | ||
16 | -#DEFINES += ITH_DISABLE_ENGINE | ||
17 | - | ||
18 | -# jichi 9/22/2013: When ITH is on wine, mutex is needed to protect NtWriteFile | ||
19 | -#DEFINES += ITH_WINE | ||
20 | -#DEFINES += ITH_SYNC_PIPE | ||
21 | - | ||
22 | -## Libraries | ||
23 | - | ||
24 | -LIBS += -lkernel32 -luser32 -lgdi32 | ||
25 | - | ||
26 | -## Sources | ||
27 | - | ||
28 | -TEMPLATE = lib | ||
29 | -TARGET = vnrhook | ||
30 | - | ||
31 | -#CONFIG += staticlib | ||
32 | - | ||
33 | -HEADERS += \ | ||
34 | - config.h \ | ||
35 | - cli.h \ | ||
36 | - hook.h \ | ||
37 | - engine/engine.h \ | ||
38 | - engine/hookdefs.h \ | ||
39 | - engine/match.h \ | ||
40 | - engine/pchooks.h \ | ||
41 | - engine/util.h \ | ||
42 | - tree/avl.h | ||
43 | - | ||
44 | -SOURCES += \ | ||
45 | - main.cc \ | ||
46 | - rpc/pipe.cc \ | ||
47 | - hijack/texthook.cc \ | ||
48 | - engine/engine.cc \ | ||
49 | - engine/match.cc \ | ||
50 | - engine/pchooks.cc \ | ||
51 | - engine/util.cc | ||
52 | - | ||
53 | -#RC_FILE += vnrhook.rc | ||
54 | -#OTHER_FILES += vnrhook.rc | ||
55 | - | ||
56 | -# EOF |
vnr/ith/hook/main.cc
deleted
100644 → 0
This diff is collapsed. Click to expand it.
vnr/ith/hook/rpc/pipe.cc
deleted
100644 → 0
1 | -// pipe.cc | ||
2 | -// 8/24/2013 jichi | ||
3 | -// Branch: ITH_DLL/pipe.cpp, rev 66 | ||
4 | -// 8/24/2013 TODO: Clean up this file | ||
5 | - | ||
6 | -#ifdef _MSC_VER | ||
7 | -# pragma warning (disable:4100) // C4100: unreference formal parameter | ||
8 | -#endif // _MSC_VER | ||
9 | - | ||
10 | -#include "cli.h" | ||
11 | -#include "engine/match.h" | ||
12 | -#include "ith/common/defs.h" | ||
13 | -//#include "ith/common/growl.h" | ||
14 | -#include "ith/sys/sys.h" | ||
15 | -#include "ccutil/ccmacro.h" | ||
16 | - | ||
17 | -//#include <ITH\AVL.h> | ||
18 | -//#include <ITH\ntdll.h> | ||
19 | -WCHAR mutex[] = ITH_GRANTPIPE_MUTEX; | ||
20 | -WCHAR exist[] = ITH_PIPEEXISTS_EVENT; | ||
21 | -WCHAR detach_mutex[0x20]; | ||
22 | -//WCHAR write_event[0x20]; | ||
23 | -//WCHAR engine_event[0x20]; | ||
24 | - | ||
25 | -//WCHAR recv_pipe[] = L"\\??\\pipe\\ITH_PIPE"; | ||
26 | -//WCHAR command[] = L"\\??\\pipe\\ITH_COMMAND"; | ||
27 | -wchar_t recv_pipe[] = ITH_TEXT_PIPE; | ||
28 | -wchar_t command[] = ITH_COMMAND_PIPE; | ||
29 | - | ||
30 | -LARGE_INTEGER wait_time = {-100*10000, -1}; | ||
31 | -LARGE_INTEGER sleep_time = {-20*10000, -1}; | ||
32 | - | ||
33 | -DWORD engine_type; | ||
34 | -DWORD module_base; | ||
35 | - | ||
36 | -//DWORD engine_base; | ||
37 | -bool engine_registered; // 10/19/2014 jichi: disable engine dll | ||
38 | - | ||
39 | -HANDLE hPipe, | ||
40 | - hCommand, | ||
41 | - hDetach; //,hLose; | ||
42 | -//InsertHookFun InsertHook; | ||
43 | -//IdentifyEngineFun IdentifyEngine; | ||
44 | -//InsertDynamicHookFun InsertDynamicHook; | ||
45 | - | ||
46 | -bool hook_inserted = false; | ||
47 | - | ||
48 | -// jichi 9/28/2013: protect pipe on wine | ||
49 | -// Put the definition in this file so that it might be inlined | ||
50 | -void CliUnlockPipe() | ||
51 | -{ | ||
52 | - if (IthIsWine()) | ||
53 | - IthReleaseMutex(::hmMutex); | ||
54 | -} | ||
55 | - | ||
56 | -void CliLockPipe() | ||
57 | -{ | ||
58 | - if (IthIsWine()) { | ||
59 | - const LONGLONG timeout = -50000000; // in nanoseconds = 5 seconds | ||
60 | - NtWaitForSingleObject(hmMutex, 0, (PLARGE_INTEGER)&timeout); | ||
61 | - } | ||
62 | -} | ||
63 | - | ||
64 | -HANDLE IthOpenPipe(LPWSTR name, ACCESS_MASK direction) | ||
65 | -{ | ||
66 | - UNICODE_STRING us; | ||
67 | - RtlInitUnicodeString(&us,name); | ||
68 | - SECURITY_DESCRIPTOR sd = {1}; | ||
69 | - OBJECT_ATTRIBUTES oa = {sizeof(oa), 0, &us, OBJ_CASE_INSENSITIVE, &sd, 0}; | ||
70 | - HANDLE hFile; | ||
71 | - IO_STATUS_BLOCK isb; | ||
72 | - if (NT_SUCCESS(NtCreateFile(&hFile, direction, &oa, &isb, 0, 0, FILE_SHARE_READ, FILE_OPEN, 0, 0, 0))) | ||
73 | - return hFile; | ||
74 | - else | ||
75 | - return INVALID_HANDLE_VALUE; | ||
76 | -} | ||
77 | - | ||
78 | -DWORD WINAPI WaitForPipe(LPVOID lpThreadParameter) // Dynamically detect ITH main module status. | ||
79 | -{ | ||
80 | - CC_UNUSED(lpThreadParameter); | ||
81 | - int i; | ||
82 | - TextHook *man; | ||
83 | - struct { | ||
84 | - DWORD pid; | ||
85 | - TextHook *man; | ||
86 | - DWORD module; | ||
87 | - //DWORD engine; | ||
88 | - } u; | ||
89 | - HANDLE hMutex, | ||
90 | - hPipeExist; | ||
91 | - //swprintf(engine_event,L"ITH_ENGINE_%d",current_process_id); | ||
92 | - swprintf(detach_mutex, ITH_DETACH_MUTEX_ L"%d", current_process_id); | ||
93 | - //swprintf(lose_event,L"ITH_LOSEPIPE_%d",current_process_id); | ||
94 | - //hEngine=IthCreateEvent(engine_event); | ||
95 | - //NtWaitForSingleObject(hEngine,0,0); | ||
96 | - //NtClose(hEngine); | ||
97 | - while (!engine_registered) | ||
98 | - NtDelayExecution(0, &wait_time); | ||
99 | - //LoadEngine(L"ITH_Engine.dll"); | ||
100 | - u.module = module_base; | ||
101 | - u.pid = current_process_id; | ||
102 | - u.man = hookman; | ||
103 | - //u.engine = engine_base; // jichi 10/19/2014: disable the second dll | ||
104 | - hPipeExist = IthOpenEvent(exist); | ||
105 | - IO_STATUS_BLOCK ios; | ||
106 | - //hLose=IthCreateEvent(lose_event,0,0); | ||
107 | - if (hPipeExist != INVALID_HANDLE_VALUE) | ||
108 | - while (running) { | ||
109 | - hPipe = INVALID_HANDLE_VALUE; | ||
110 | - hCommand = INVALID_HANDLE_VALUE; | ||
111 | - while (NtWaitForSingleObject(hPipeExist,0,&wait_time) == WAIT_TIMEOUT) | ||
112 | - if (!running) | ||
113 | - goto _release; | ||
114 | - hMutex = IthCreateMutex(mutex,0); | ||
115 | - NtWaitForSingleObject(hMutex,0,0); | ||
116 | - while (hPipe == INVALID_HANDLE_VALUE|| | ||
117 | - hCommand == INVALID_HANDLE_VALUE) { | ||
118 | - NtDelayExecution(0, &sleep_time); | ||
119 | - if (hPipe == INVALID_HANDLE_VALUE) | ||
120 | - hPipe = IthOpenPipe(recv_pipe, GENERIC_WRITE); | ||
121 | - if (hCommand == INVALID_HANDLE_VALUE) | ||
122 | - hCommand = IthOpenPipe(command, GENERIC_READ); | ||
123 | - } | ||
124 | - //NtClearEvent(hLose); | ||
125 | - CliLockPipe(); | ||
126 | - NtWriteFile(hPipe, 0, 0, 0, &ios, &u, sizeof(u), 0, 0); | ||
127 | - CliUnlockPipe(); | ||
128 | - live = true; | ||
129 | - for (man = hookman, i = 0; i < current_hook; man++) | ||
130 | - if (man->RecoverHook()) // jichi 9/27/2013: This is the place where built-in hooks like TextOutA are inserted | ||
131 | - i++; | ||
132 | - //ConsoleOutput(dll_name); | ||
133 | - ConsoleOutput("vnrcli:WaitForPipe: pipe connected"); | ||
134 | - //OutputDWORD(tree->Count()); | ||
135 | - NtReleaseMutant(hMutex,0); | ||
136 | - NtClose(hMutex); | ||
137 | - if (!hook_inserted && engine_registered) { | ||
138 | - hook_inserted = true; | ||
139 | - Engine::IdentifyEngine(); | ||
140 | - } | ||
141 | - hDetach = IthCreateMutex(detach_mutex,1); | ||
142 | - while (running && NtWaitForSingleObject(hPipeExist, 0, &sleep_time) == WAIT_OBJECT_0) | ||
143 | - NtDelayExecution(0, &sleep_time); | ||
144 | - live = false; | ||
145 | - for (man = hookman, i = 0; i < current_hook; man++) | ||
146 | - if (man->RemoveHook()) | ||
147 | - i++; | ||
148 | - if (!running) { | ||
149 | - IthCoolDown(); // jichi 9/28/2013: Use cooldown instead of lock pipe to prevent from hanging on exit | ||
150 | - //CliLockPipe(); | ||
151 | - NtWriteFile(hPipe, 0, 0, 0, &ios, man, 4, 0, 0); | ||
152 | - //CliUnlockPipe(); | ||
153 | - IthReleaseMutex(hDetach); | ||
154 | - } | ||
155 | - NtClose(hDetach); | ||
156 | - NtClose(hPipe); | ||
157 | - } | ||
158 | -_release: | ||
159 | - //NtClose(hLose); | ||
160 | - NtClose(hPipeExist); | ||
161 | - return 0; | ||
162 | -} | ||
163 | -DWORD WINAPI CommandPipe(LPVOID lpThreadParameter) | ||
164 | -{ | ||
165 | - CC_UNUSED(lpThreadParameter); | ||
166 | - DWORD command; | ||
167 | - BYTE buff[0x400] = {}; | ||
168 | - HANDLE hPipeExist; | ||
169 | - hPipeExist = IthOpenEvent(exist); | ||
170 | - IO_STATUS_BLOCK ios={}; | ||
171 | - if (hPipeExist!=INVALID_HANDLE_VALUE) | ||
172 | - while (running) { | ||
173 | - while (!live) { | ||
174 | - if (!running) | ||
175 | - goto _detach; | ||
176 | - NtDelayExecution(0, &sleep_time); | ||
177 | - } | ||
178 | - // jichi 9/27/2013: Why 0x200 not 0x400? wchar_t? | ||
179 | - switch (NtReadFile(hCommand, 0, 0, 0, &ios, buff, 0x200, 0, 0)) { | ||
180 | - case STATUS_PIPE_BROKEN: | ||
181 | - case STATUS_PIPE_DISCONNECTED: | ||
182 | - NtClearEvent(hPipeExist); | ||
183 | - continue; | ||
184 | - case STATUS_PENDING: | ||
185 | - NtWaitForSingleObject(hCommand, 0, 0); | ||
186 | - switch (ios.Status) { | ||
187 | - case STATUS_PIPE_BROKEN: | ||
188 | - case STATUS_PIPE_DISCONNECTED: | ||
189 | - NtClearEvent(hPipeExist); | ||
190 | - continue; | ||
191 | - case 0: break; | ||
192 | - default: | ||
193 | - if (NtWaitForSingleObject(hDetach, 0, &wait_time) == WAIT_OBJECT_0) | ||
194 | - goto _detach; | ||
195 | - } | ||
196 | - } | ||
197 | - if (ios.uInformation && live) { | ||
198 | - command = *(DWORD *)buff; | ||
199 | - switch(command) { | ||
200 | - case IHF_COMMAND_NEW_HOOK: | ||
201 | - //IthBreak(); | ||
202 | - buff[ios.uInformation] = 0; | ||
203 | - buff[ios.uInformation + 1] = 0; | ||
204 | - NewHook(*(HookParam *)(buff + 4), (LPWSTR)(buff + 4 + sizeof(HookParam)), 0); | ||
205 | - break; | ||
206 | - case IHF_COMMAND_REMOVE_HOOK: | ||
207 | - { | ||
208 | - DWORD rm_addr = *(DWORD *)(buff+4); | ||
209 | - HANDLE hRemoved = IthOpenEvent(ITH_REMOVEHOOK_EVENT); | ||
210 | - | ||
211 | - TextHook *in = hookman; | ||
212 | - for (int i = 0; i < current_hook; in++) { | ||
213 | - if (in->Address()) i++; | ||
214 | - if (in->Address() == rm_addr) break; | ||
215 | - } | ||
216 | - if (in->Address()) | ||
217 | - in->ClearHook(); | ||
218 | - IthSetEvent(hRemoved); | ||
219 | - NtClose(hRemoved); | ||
220 | - } break; | ||
221 | - case IHF_COMMAND_MODIFY_HOOK: | ||
222 | - { | ||
223 | - DWORD rm_addr = *(DWORD *)(buff + 4); | ||
224 | - HANDLE hModify = IthOpenEvent(ITH_MODIFYHOOK_EVENT); | ||
225 | - TextHook *in = hookman; | ||
226 | - for (int i = 0; i < current_hook; in++) { | ||
227 | - if (in->Address()) | ||
228 | - i++; | ||
229 | - if (in->Address() == rm_addr) | ||
230 | - break; | ||
231 | - } | ||
232 | - if (in->Address()) | ||
233 | - in->ModifyHook(*(HookParam *)(buff + 4)); | ||
234 | - IthSetEvent(hModify); | ||
235 | - NtClose(hModify); | ||
236 | - } break; | ||
237 | - case IHF_COMMAND_DETACH: | ||
238 | - running = false; | ||
239 | - live = false; | ||
240 | - goto _detach; | ||
241 | - default: ; | ||
242 | - } | ||
243 | - } | ||
244 | - } | ||
245 | -_detach: | ||
246 | - NtClose(hPipeExist); | ||
247 | - NtClose(hCommand); | ||
248 | - return 0; | ||
249 | -} | ||
250 | -//extern "C" { | ||
251 | -void IHFAPI ConsoleOutput(LPCSTR text) | ||
252 | -{ // jichi 12/25/2013: Rewrite the implementation | ||
253 | - if (!live || !text) | ||
254 | - return; | ||
255 | - enum { buf_size = 0x50 }; | ||
256 | - BYTE buf[buf_size]; // buffer is needed to append the message header | ||
257 | - size_t text_size = strlen(text) + 1; | ||
258 | - size_t data_size = text_size + 8; | ||
259 | - | ||
260 | - BYTE *data = (data_size <= buf_size) ? buf : new BYTE[data_size]; | ||
261 | - *(DWORD *)data = IHF_NOTIFICATION; //cmd | ||
262 | - *(DWORD *)(data + 4) = IHF_NOTIFICATION_TEXT; //console | ||
263 | - memcpy(data + 8, text, text_size); | ||
264 | - | ||
265 | - IO_STATUS_BLOCK ios; | ||
266 | - NtWriteFile(hPipe, 0, 0, 0, &ios, data, data_size, 0, 0); | ||
267 | - if (data != buf) | ||
268 | - delete[] data; | ||
269 | -} | ||
270 | - //if (str) { | ||
271 | - // int t, len, sum; | ||
272 | - // BYTE buffer[0x80]; | ||
273 | - // BYTE *buff; | ||
274 | - // len = wcslen(str) << 1; | ||
275 | - // t = swprintf((LPWSTR)(buffer + 8),L"%d: ",current_process_id) << 1; | ||
276 | - // sum = len + t + 8; | ||
277 | - // if (sum > 0x80) { | ||
278 | - // buff = new BYTE[sum]; | ||
279 | - // memset(buff, 0, sum); // jichi 9/25/2013: zero memory | ||
280 | - // memcpy(buff + 8, buffer + 8, t); | ||
281 | - // } | ||
282 | - // else | ||
283 | - // buff = buffer; | ||
284 | - // *(DWORD *)buff = IHF_NOTIFICATION; //cmd | ||
285 | - // *(DWORD *)(buff + 4) = IHF_NOTIFICATION_TEXT; //console | ||
286 | - // memcpy(buff + t + 8, str, len); | ||
287 | - // IO_STATUS_BLOCK ios; | ||
288 | - // NtWriteFile(hPipe,0,0,0,&ios,buff,sum,0,0); | ||
289 | - // if (buff != buffer) | ||
290 | - // delete[] buff; | ||
291 | - // return len; | ||
292 | - //} | ||
293 | - | ||
294 | -//DWORD IHFAPI OutputDWORD(DWORD d) | ||
295 | -//{ | ||
296 | -// WCHAR str[0x10]; | ||
297 | -// swprintf(str,L"%.8X",d); | ||
298 | -// ConsoleOutput(str); | ||
299 | -// return 0; | ||
300 | -//} | ||
301 | -//DWORD IHFAPI OutputRegister(DWORD *base) | ||
302 | -//{ | ||
303 | -// WCHAR str[0x40]; | ||
304 | -// swprintf(str,L"EAX:%.8X",base[0]); | ||
305 | -// ConsoleOutput(str); | ||
306 | -// swprintf(str,L"ECX:%.8X",base[-1]); | ||
307 | -// ConsoleOutput(str); | ||
308 | -// swprintf(str,L"EDX:%.8X",base[-2]); | ||
309 | -// ConsoleOutput(str); | ||
310 | -// swprintf(str,L"EBX:%.8X",base[-3]); | ||
311 | -// ConsoleOutput(str); | ||
312 | -// swprintf(str,L"ESP:%.8X",base[-4]); | ||
313 | -// ConsoleOutput(str); | ||
314 | -// swprintf(str,L"EBP:%.8X",base[-5]); | ||
315 | -// ConsoleOutput(str); | ||
316 | -// swprintf(str,L"ESI:%.8X",base[-6]); | ||
317 | -// ConsoleOutput(str); | ||
318 | -// swprintf(str,L"EDI:%.8X",base[-7]); | ||
319 | -// ConsoleOutput(str); | ||
320 | -// return 0; | ||
321 | -//} | ||
322 | -//DWORD IHFAPI RegisterEngineModule(DWORD idEngine, DWORD dnHook) | ||
323 | -//{ | ||
324 | -// ::IdentifyEngine = (IdentifyEngineFun)idEngine; | ||
325 | -// ::InsertDynamicHook = (InsertDynamicHookFun)dnHook; | ||
326 | -// ::engine_registered = true; | ||
327 | -// return 0; | ||
328 | -//} | ||
329 | -DWORD IHFAPI NotifyHookInsert(DWORD addr) | ||
330 | -{ | ||
331 | - if (live) { | ||
332 | - BYTE buffer[0x10]; | ||
333 | - *(DWORD *)buffer = IHF_NOTIFICATION; | ||
334 | - *(DWORD *)(buffer + 4) = IHF_NOTIFICATION_NEWHOOK; | ||
335 | - *(DWORD *)(buffer + 8) = addr; | ||
336 | - *(DWORD *)(buffer + 0xc) = 0; | ||
337 | - IO_STATUS_BLOCK ios; | ||
338 | - CliLockPipe(); | ||
339 | - NtWriteFile(hPipe,0,0,0,&ios,buffer,0x10,0,0); | ||
340 | - CliUnlockPipe(); | ||
341 | - } | ||
342 | - return 0; | ||
343 | -} | ||
344 | -//} // extern "C" | ||
345 | - | ||
346 | -// EOF |
vnr/ith/hook/tree/avl.h
deleted
100644 → 0
This diff is collapsed. Click to expand it.
vnr/ith/hookxp/hookxp.pro
deleted
100644 → 0
1 | -# hookxp.pro | ||
2 | -# 8/9/2013 jichi | ||
3 | -# Build vnrhookxp.dll for Windows XP | ||
4 | - | ||
5 | -CONFIG += noeh # msvcrt on Windows XP does not has exception handler | ||
6 | -include(../dllconfig.pri) | ||
7 | -include(../sys/sys.pri) | ||
8 | -include($$LIBDIR/disasm/disasm.pri) | ||
9 | -include($$LIBDIR/memdbg/memdbg.pri) | ||
10 | -include($$LIBDIR/ntinspect/ntinspect.pri) | ||
11 | -include($$LIBDIR/winseh/winseh_safe.pri) | ||
12 | -include($$LIBDIR/winversion/winversion.pri) | ||
13 | - | ||
14 | -VPATH += ../hook | ||
15 | -INCLUDEPATH += ../hook | ||
16 | - | ||
17 | -# 9/27/2013: disable ITH this game engine, only for debugging purpose | ||
18 | -#DEFINES += ITH_DISABLE_ENGINE | ||
19 | - | ||
20 | - | ||
21 | -# jichi 9/22/2013: When ITH is on wine, mutex is needed to protect NtWriteFile | ||
22 | -#DEFINES += ITH_WINE | ||
23 | -#DEFINES += ITH_SYNC_PIPE | ||
24 | - | ||
25 | -## Libraries | ||
26 | - | ||
27 | -LIBS += -lkernel32 -luser32 -lgdi32 | ||
28 | - | ||
29 | -## Sources | ||
30 | - | ||
31 | -TEMPLATE = lib | ||
32 | -TARGET = vnrhookxp | ||
33 | - | ||
34 | -#CONFIG += staticlib | ||
35 | - | ||
36 | -HEADERS += \ | ||
37 | - config.h \ | ||
38 | - cli.h \ | ||
39 | - hook.h \ | ||
40 | - engine/engine.h \ | ||
41 | - engine/hookdefs.h \ | ||
42 | - engine/match.h \ | ||
43 | - engine/pchooks.h \ | ||
44 | - engine/util.h \ | ||
45 | - tree/avl.h | ||
46 | - | ||
47 | -SOURCES += \ | ||
48 | - main.cc \ | ||
49 | - rpc/pipe.cc \ | ||
50 | - hijack/texthook.cc \ | ||
51 | - engine/engine.cc \ | ||
52 | - engine/match.cc \ | ||
53 | - engine/pchooks.cc \ | ||
54 | - engine/util.cc | ||
55 | - | ||
56 | -#RC_FILE += vnrhook.rc | ||
57 | -#OTHER_FILES += vnrhook.rc | ||
58 | - | ||
59 | -# EOF |
vnr/ith/host/CMakeLists.txt
deleted
100644 → 0
1 | -# host.pro | ||
2 | -# #CONFIG += eha # 3/1/2014: catchlng all exceptions will break pytexthook on Windows XP | ||
3 | -# CONFIG += noeh # Needed by pytexthook ONLY on windows xp orz | ||
4 | -# include(../dllconfig.pri) | ||
5 | -# include(../sys/sys.pri) | ||
6 | -# include($$LIBDIR/winmaker/winmaker.pri) | ||
7 | -# include($$LIBDIR/winmutex/winmutex.pri) | ||
8 | - | ||
9 | -# config.pri | ||
10 | -# CONFIG(noeh) { # No Exception handler | ||
11 | -# message(CONFIG noeh) | ||
12 | -# QMAKE_CXXFLAGS += /GR- | ||
13 | -# QMAKE_CXXFLAGS_RTTI_ON -= /GR | ||
14 | -# QMAKE_CXXFLAGS_STL_ON -= /EHsc | ||
15 | -# QMAKE_CXXFLAGS_EXCEPTIONS_ON -= /EHsc | ||
16 | -# CONFIG(dll) { | ||
17 | -# QMAKE_LFLAGS += /ENTRY:"DllMain" | ||
18 | -# } | ||
19 | -# } | ||
20 | - | ||
21 | -set(vnrhost_src | ||
22 | - avl_p.h | ||
23 | - config.h | ||
24 | - hookman.h | ||
25 | - settings.h | ||
26 | - srv.h | ||
27 | - srv_p.h | ||
28 | - textthread.h | ||
29 | - textthread_p.h | ||
30 | - SettingManager.h | ||
31 | - hookman.cc | ||
32 | - main.cc | ||
33 | - pipe.cc | ||
34 | - textthread.cc | ||
35 | - ${PROJECT_SOURCE_DIR}/winmaker/winmaker.h | ||
36 | - ${PROJECT_SOURCE_DIR}/winmaker/winmaker.cc | ||
37 | - ${PROJECT_SOURCE_DIR}/winmutex/winmutex.h | ||
38 | - ${common_src} | ||
39 | -) | ||
40 | - | ||
41 | -source_group("common" FILES ${common_src}) | ||
42 | - | ||
43 | -add_library(vnrhost SHARED ${vnrhost_src}) | ||
44 | - | ||
45 | -set_target_properties(vnrhost PROPERTIES LINK_FLAGS /SUBSYSTEM:WINDOWS) | ||
46 | - | ||
47 | -target_compile_options(vnrhost PRIVATE | ||
48 | - /GR- | ||
49 | - $<$<CONFIG:Release>:> | ||
50 | - $<$<CONFIG:Debug>:> | ||
51 | -) | ||
52 | - | ||
53 | -STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) | ||
54 | - | ||
55 | -target_link_libraries(vnrhost | ||
56 | - vnrsys | ||
57 | - ${WDK_HOME}/lib/wxp/i386/ntdll.lib | ||
58 | -) | ||
59 | - | ||
60 | -target_compile_definitions(vnrhost PRIVATE | ||
61 | -) | ||
62 | - | ||
63 | -install(TARGETS vnrhost RUNTIME | ||
64 | - DESTINATION . | ||
65 | - CONFIGURATIONS Release | ||
66 | -) |
vnr/ith/host/SettingManager.h
deleted
100644 → 0
1 | -/* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com) | ||
2 | - * This file is part of the Interactive Text Hooker. | ||
3 | - | ||
4 | - * Interactive Text Hooker is free software: you can redistribute it and/or | ||
5 | - * modify it under the terms of the GNU General Public License as published | ||
6 | - * by the Free Software Foundation, either version 3 of the License, or | ||
7 | - * (at your option) any later version. | ||
8 | - | ||
9 | - * This program is distributed in the hope that it will be useful, | ||
10 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | - * GNU General Public License for more details. | ||
13 | - | ||
14 | - * You should have received a copy of the GNU General Public License | ||
15 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | - */ | ||
17 | - | ||
18 | -#pragma once | ||
19 | -#include "config.h" | ||
20 | -#include <intrin.h> | ||
21 | -#define SETTING_SPLIT_TIME 0 | ||
22 | -#define SETTING_CYCLIC_REMOVE 1 | ||
23 | -#define SETTING_REPEAT_COUNT 2 | ||
24 | -#define SETTING_CLIPFLAG 3 | ||
25 | -#define SETTING_MAX_INDEX 4 | ||
26 | -class IHFSERVICE SettingManager | ||
27 | -{ | ||
28 | -public: | ||
29 | - SettingManager() {memset(setting_int,0,sizeof(setting_int));} | ||
30 | - ~SettingManager(){} | ||
31 | - unsigned int SetValue(unsigned int index, unsigned int value) | ||
32 | - { | ||
33 | - if (index < SETTING_MAX_INDEX) | ||
34 | - return (unsigned int)_InterlockedExchange((long*)setting_int+index,(long)value); | ||
35 | - else return 0; | ||
36 | - } | ||
37 | - unsigned int GetValue(unsigned int index) | ||
38 | - { | ||
39 | - if (index < SETTING_MAX_INDEX) | ||
40 | - return setting_int[index]; | ||
41 | - else return 0; | ||
42 | - } | ||
43 | -private: | ||
44 | - unsigned int setting_int[SETTING_MAX_INDEX]; | ||
45 | - | ||
46 | -}; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
vnr/ith/host/avl_p.h
deleted
100644 → 0
This diff is collapsed. Click to expand it.
vnr/ith/host/config.h
deleted
100644 → 0
1 | -#pragma once | ||
2 | - | ||
3 | -// config.h | ||
4 | -// 8/23/2013 jichi | ||
5 | -// The first header file that are included by all source files. | ||
6 | - | ||
7 | -#define IHF // for dll import | ||
8 | -#include "ith/dllconfig.h" | ||
9 | -#define IHFAPI __stdcall | ||
10 | -#ifdef IHF | ||
11 | -# define IHFSERVICE __declspec(dllexport) | ||
12 | -#else | ||
13 | -# define IHFSERVICE __declspec(dllimport) | ||
14 | -#endif | ||
15 | - | ||
16 | -// EOF |
vnr/ith/host/hookman.cc
deleted
100644 → 0
This diff is collapsed. Click to expand it.
vnr/ith/host/hookman.h
deleted
100644 → 0
1 | -#pragma once | ||
2 | - | ||
3 | -// hookman.h | ||
4 | -// 8/23/2013 jichi | ||
5 | -// Branch: ITH/HookManager.h, rev 133 | ||
6 | - | ||
7 | -#include "ith/host/avl_p.h" | ||
8 | -#include "ith/host/textthread.h" | ||
9 | -#include "winmutex/winmutex.h" | ||
10 | - | ||
11 | -enum { MAX_REGISTER = 0xf }; | ||
12 | -enum { MAX_PREV_REPEAT_LENGTH = 0x20 }; | ||
13 | - | ||
14 | -struct ProcessRecord { | ||
15 | - DWORD pid_register; | ||
16 | - DWORD hookman_register; | ||
17 | - DWORD module_register; | ||
18 | - //DWORD engine_register; // jichi 10/19/2014: removed | ||
19 | - HANDLE process_handle; | ||
20 | - HANDLE hookman_mutex; | ||
21 | - HANDLE hookman_section; | ||
22 | - LPVOID hookman_map; | ||
23 | -}; | ||
24 | - | ||
25 | -class ThreadTable : public MyVector<TextThread *, 0x40> | ||
26 | -{ | ||
27 | -public: | ||
28 | - virtual void SetThread(DWORD number, TextThread *ptr); | ||
29 | - virtual TextThread *FindThread(DWORD number); | ||
30 | -}; | ||
31 | - | ||
32 | -struct TCmp { char operator()(const ThreadParameter *t1,const ThreadParameter *t2); }; | ||
33 | -struct TCpy { void operator()(ThreadParameter *t1,const ThreadParameter *t2); }; | ||
34 | -struct TLen { int operator()(const ThreadParameter *t); }; | ||
35 | - | ||
36 | -typedef DWORD (*ProcessEventCallback)(DWORD pid); | ||
37 | - | ||
38 | -class IHFSERVICE HookManager : public AVLTree<ThreadParameter, DWORD, TCmp, TCpy, TLen> | ||
39 | -{ | ||
40 | -public: | ||
41 | - HookManager(); | ||
42 | - ~HookManager(); | ||
43 | - // jichi 12/26/2013: remove virtual modifiers | ||
44 | - TextThread *FindSingle(DWORD pid, DWORD hook, DWORD retn, DWORD split); | ||
45 | - TextThread *FindSingle(DWORD number); | ||
46 | - ProcessRecord *GetProcessRecord(DWORD pid); | ||
47 | - DWORD GetProcessIDByPath(LPCWSTR str); | ||
48 | - void RemoveSingleThread(DWORD number); | ||
49 | - void LockHookman(); | ||
50 | - void UnlockHookman(); | ||
51 | - void ResetRepeatStatus(); | ||
52 | - void ClearCurrent(); | ||
53 | - void AddLink(WORD from, WORD to); | ||
54 | - void UnLink(WORD from); | ||
55 | - void UnLinkAll(WORD from); | ||
56 | - void SelectCurrent(DWORD num); | ||
57 | - void DetachProcess(DWORD pid); | ||
58 | - void SetCurrent(TextThread *it); | ||
59 | - void AddConsoleOutput(LPCWSTR text); | ||
60 | - | ||
61 | - // jichi 10/27/2013: Add const; add space. | ||
62 | - void DispatchText(DWORD pid, const BYTE *text, DWORD hook, DWORD retn, DWORD split, int len, bool space); | ||
63 | - | ||
64 | - void ClearText(DWORD pid, DWORD hook, DWORD retn, DWORD split); | ||
65 | - void RemoveProcessContext(DWORD pid); | ||
66 | - void RemoveSingleHook(DWORD pid, DWORD addr); | ||
67 | - void RegisterThread(TextThread*, DWORD); | ||
68 | - void RegisterPipe(HANDLE text, HANDLE cmd, HANDLE thread); | ||
69 | - void RegisterProcess(DWORD pid, DWORD hookman, DWORD module); | ||
70 | - void UnRegisterProcess(DWORD pid); | ||
71 | - //void SetName(DWORD); | ||
72 | - | ||
73 | - DWORD GetCurrentPID(); | ||
74 | - HANDLE GetCmdHandleByPID(DWORD pid); | ||
75 | - | ||
76 | - ConsoleCallback RegisterConsoleCallback(ConsoleCallback cf) | ||
77 | - { return (ConsoleCallback)_InterlockedExchange((long*)&console,(long)cf); } | ||
78 | - | ||
79 | - ConsoleWCallback RegisterConsoleWCallback(ConsoleWCallback cf) | ||
80 | - { return (ConsoleWCallback)_InterlockedExchange((long*)&wconsole,(long)cf); } | ||
81 | - | ||
82 | - ThreadEventCallback RegisterThreadCreateCallback(ThreadEventCallback cf) | ||
83 | - { return (ThreadEventCallback)_InterlockedExchange((long*)&create,(long)cf); } | ||
84 | - | ||
85 | - ThreadEventCallback RegisterThreadRemoveCallback(ThreadEventCallback cf) | ||
86 | - { return (ThreadEventCallback)_InterlockedExchange((long*)&remove,(long)cf); } | ||
87 | - | ||
88 | - ThreadEventCallback RegisterThreadResetCallback(ThreadEventCallback cf) | ||
89 | - { return (ThreadEventCallback)_InterlockedExchange((long*)&reset,(long)cf); } | ||
90 | - | ||
91 | - ThreadEventCallback RegisterAddRemoveLinkCallback(ThreadEventCallback cf) | ||
92 | - { return (ThreadEventCallback)_InterlockedExchange((long*)&addRemoveLink, (long)cf); } | ||
93 | - | ||
94 | - ProcessEventCallback RegisterProcessAttachCallback(ProcessEventCallback cf) | ||
95 | - { return (ProcessEventCallback)_InterlockedExchange((long*)&attach,(long)cf); } | ||
96 | - | ||
97 | - ProcessEventCallback RegisterProcessDetachCallback(ProcessEventCallback cf) | ||
98 | - { return (ProcessEventCallback)_InterlockedExchange((long*)&detach,(long)cf); } | ||
99 | - | ||
100 | - ProcessEventCallback RegisterProcessNewHookCallback(ProcessEventCallback cf) | ||
101 | - { return (ProcessEventCallback)_InterlockedExchange((long*)&hook,(long)cf); } | ||
102 | - | ||
103 | - ProcessEventCallback ProcessNewHook() { return hook; } | ||
104 | - TextThread *GetCurrentThread() { return current; } | ||
105 | - ProcessRecord *Records() { return record; } | ||
106 | - ThreadTable *Table() { return thread_table; } | ||
107 | - | ||
108 | - //DWORD& SplitTime() { return split_time; } | ||
109 | - //DWORD& RepeatCount() { return repeat_count; } | ||
110 | - //DWORD& CyclicRemove() { return cyclic_remove; } | ||
111 | - //DWORD& GlobalFilter() { return global_filter; } | ||
112 | - void ConsoleOutput(LPCSTR text) { if (console) console(text); } // not thread safe | ||
113 | - void ConsoleOutputW(LPCWSTR text) { if (wconsole) wconsole(text); } // not thread safe | ||
114 | - | ||
115 | -private: | ||
116 | - typedef win_mutex<CRITICAL_SECTION> mutex_type; | ||
117 | - mutex_type hmcs; | ||
118 | - | ||
119 | - TextThread *current; | ||
120 | - ConsoleCallback console; // jichi 12/25/2013: add console output callback | ||
121 | - ConsoleWCallback wconsole; | ||
122 | - ThreadEventCallback create, | ||
123 | - remove, | ||
124 | - reset, | ||
125 | - addRemoveLink; | ||
126 | - ProcessEventCallback attach, | ||
127 | - detach, | ||
128 | - hook; | ||
129 | - DWORD current_pid; | ||
130 | - ThreadTable *thread_table; | ||
131 | - HANDLE destroy_event; | ||
132 | - ProcessRecord record[MAX_REGISTER + 1]; | ||
133 | - HANDLE text_pipes[MAX_REGISTER + 1], | ||
134 | - cmd_pipes[MAX_REGISTER + 1], | ||
135 | - recv_threads[MAX_REGISTER + 1]; | ||
136 | - WORD register_count, | ||
137 | - new_thread_number; | ||
138 | - | ||
139 | - // jichi 1/16/2014: Stop adding new threads when full | ||
140 | - bool IsFull() const; // { return new_thread_number >= MAX_HOOK; } | ||
141 | - bool IsEmpty() const { return !new_thread_number; } | ||
142 | -}; | ||
143 | - | ||
144 | -// EOF |
vnr/ith/host/host.pri
deleted
100644 → 0
vnr/ith/host/host.pro
deleted
100644 → 0
1 | -# host.pro | ||
2 | -# 8/9/2013 jichi | ||
3 | -# Build vnrhost | ||
4 | - | ||
5 | -#CONFIG += eha # 3/1/2014: catchlng all exceptions will break pytexthook on Windows XP | ||
6 | -CONFIG += noeh # Needed by pytexthook ONLY on windows xp orz | ||
7 | -include(../dllconfig.pri) | ||
8 | -include(../sys/sys.pri) | ||
9 | -include($$LIBDIR/winmaker/winmaker.pri) | ||
10 | -include($$LIBDIR/winmutex/winmutex.pri) | ||
11 | - | ||
12 | -# 9/22/2013: When ITH is on wine, certain NT functions are replaced | ||
13 | -#DEFINES += ITH_WINE | ||
14 | - | ||
15 | -# 9/27/2013: Only for debugging purpose | ||
16 | -#DEFINES += ITH_DISABLE_REPEAT # disable repetition elimination | ||
17 | -#DEFINES += ITH_DISABLE_FILTER # disable space filter in pipe | ||
18 | - | ||
19 | -## Libraries | ||
20 | - | ||
21 | -LIBS += -lkernel32 -luser32 #-lcomctl32 | ||
22 | - | ||
23 | -## Sources | ||
24 | - | ||
25 | -TEMPLATE = lib | ||
26 | -#TARGET = IHF # compatible with ITHv3 | ||
27 | -TARGET = vnrhost | ||
28 | - | ||
29 | -#CONFIG += staticlib | ||
30 | - | ||
31 | -HEADERS += \ | ||
32 | - avl_p.h \ | ||
33 | - config.h \ | ||
34 | - hookman.h \ | ||
35 | - settings.h \ | ||
36 | - srv.h \ | ||
37 | - srv_p.h \ | ||
38 | - textthread.h \ | ||
39 | - textthread_p.h | ||
40 | - #util.h | ||
41 | - | ||
42 | -SOURCES += \ | ||
43 | - hookman.cc \ | ||
44 | - main.cc \ | ||
45 | - pipe.cc \ | ||
46 | - textthread.cc | ||
47 | - #util.cc | ||
48 | - | ||
49 | -#RC_FILE += engine.rc | ||
50 | -#OTHER_FILES += engine.rc | ||
51 | - | ||
52 | -OTHER_FILES += host.pri | ||
53 | - | ||
54 | -# EOF |
vnr/ith/host/main.cc
deleted
100644 → 0
This diff is collapsed. Click to expand it.
vnr/ith/host/pipe.cc
deleted
100644 → 0
1 | -// pipe.cc | ||
2 | -// 8/24/2013 jichi | ||
3 | -// Branch IHF/pipe.cpp, rev 93 | ||
4 | -// 8/24/2013 TODO: Clean up this file | ||
5 | - | ||
6 | -#include "srv_p.h" | ||
7 | -#include "hookman.h" | ||
8 | -#include "ith/common/defs.h" | ||
9 | -#include "ith/common/const.h" | ||
10 | -//#include "ith/common/growl.h" | ||
11 | -#include "ith/sys/sys.h" | ||
12 | -//#include "CommandQueue.h" | ||
13 | - | ||
14 | -//DWORD WINAPI UpdateWindows(LPVOID lpThreadParameter); | ||
15 | - | ||
16 | -namespace { // unnamed | ||
17 | -enum NamedPipeCommand { | ||
18 | - NAMED_PIPE_DISCONNECT = 1 | ||
19 | - , NAMED_PIPE_CONNECT = 2 | ||
20 | -}; | ||
21 | - | ||
22 | -bool newline = false; | ||
23 | -bool detach = false; | ||
24 | - | ||
25 | -// jichi 10/27/2013 | ||
26 | -// Check if text has leading space | ||
27 | -enum { _filter_limit = 0x20 }; // The same as the orignal ITH filter. So, I don't have to check \u3000 | ||
28 | -//enum { _filter_limit = 0x19 }; | ||
29 | -inline bool has_leading_space(const BYTE *text, int len) | ||
30 | -{ | ||
31 | - return len == 1 ? *text <= _filter_limit : // 1 byte | ||
32 | - *reinterpret_cast<const WORD *>(text) <= _filter_limit; // 2 bytes | ||
33 | -} | ||
34 | - | ||
35 | -// jichi 9/28/2013: Skip leading garbage | ||
36 | -// Note: | ||
37 | -// - Modifying limit will break manual translation. The orignal one is 0x20 | ||
38 | -// - Eliminating 0x20 will break English-translated games | ||
39 | -const BYTE *Filter(const BYTE *str, int len) | ||
40 | -{ | ||
41 | -#ifdef ITH_DISABLE_FILTER // jichi 9/28/2013: only for debugging purpose | ||
42 | - return str; | ||
43 | -#endif // ITH_DISABLE_FILTER | ||
44 | -// if (len && *str == 0x10) // jichi 9/28/2013: garbage on wine, data link escape, or ^P | ||
45 | -// return nullptr; | ||
46 | - //enum { limit = 0x19 }; | ||
47 | - while (true) | ||
48 | - if (len >= 2) { | ||
49 | - if (*(const WORD *)str <= _filter_limit) { // jichi 10/27/2013: two bytes | ||
50 | - str += 2; | ||
51 | - len -= 2; | ||
52 | - } else | ||
53 | - break; | ||
54 | - } else if (*str <= _filter_limit) { // jichi 10/27/2013: 1 byte | ||
55 | - str++; | ||
56 | - len--; | ||
57 | - } else | ||
58 | - break; | ||
59 | - return str; | ||
60 | -} | ||
61 | -} // unnamed namespace | ||
62 | - | ||
63 | -//WCHAR recv_pipe[] = L"\\??\\pipe\\ITH_PIPE"; | ||
64 | -//WCHAR command_pipe[] = L"\\??\\pipe\\ITH_COMMAND"; | ||
65 | -wchar_t recv_pipe[] = ITH_TEXT_PIPE; | ||
66 | -wchar_t command_pipe[] = ITH_COMMAND_PIPE; | ||
67 | - | ||
68 | -CRITICAL_SECTION detach_cs; // jichi 9/27/2013: also used in main | ||
69 | -//HANDLE hDetachEvent; | ||
70 | -extern HANDLE hPipeExist; | ||
71 | - | ||
72 | -void CreateNewPipe() | ||
73 | -{ | ||
74 | - static DWORD acl[7] = { | ||
75 | - 0x1C0002, | ||
76 | - 1, | ||
77 | - 0x140000, | ||
78 | - GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, | ||
79 | - 0x101, | ||
80 | - 0x1000000, | ||
81 | - 0}; | ||
82 | - static SECURITY_DESCRIPTOR sd = {1, 0, 4, 0, 0, 0, (PACL)acl}; | ||
83 | - | ||
84 | - HANDLE hTextPipe, hCmdPipe, hThread; | ||
85 | - IO_STATUS_BLOCK ios; | ||
86 | - UNICODE_STRING us; | ||
87 | - | ||
88 | - OBJECT_ATTRIBUTES oa = {sizeof(oa), 0, &us, OBJ_CASE_INSENSITIVE, &sd, 0}; | ||
89 | - LARGE_INTEGER time = {-500000, -1}; | ||
90 | - | ||
91 | - RtlInitUnicodeString(&us, recv_pipe); | ||
92 | - if (!NT_SUCCESS(NtCreateNamedPipeFile( | ||
93 | - &hTextPipe, | ||
94 | - GENERIC_READ | SYNCHRONIZE, | ||
95 | - &oa, | ||
96 | - &ios, | ||
97 | - FILE_SHARE_WRITE, | ||
98 | - FILE_OPEN_IF, | ||
99 | - FILE_SYNCHRONOUS_IO_NONALERT, | ||
100 | - 1, 1, 0, -1, | ||
101 | - 0x1000, | ||
102 | - 0x1000, | ||
103 | - &time))) { | ||
104 | - //ConsoleOutput(ErrorCreatePipe); | ||
105 | - ConsoleOutput("vnrhost:CreateNewPipe: failed to create recv pipe"); | ||
106 | - return; | ||
107 | - } | ||
108 | - | ||
109 | - RtlInitUnicodeString(&us, command_pipe); | ||
110 | - if (!NT_SUCCESS(NtCreateNamedPipeFile( | ||
111 | - &hCmdPipe, | ||
112 | - GENERIC_WRITE | SYNCHRONIZE, | ||
113 | - &oa, | ||
114 | - &ios, | ||
115 | - FILE_SHARE_READ, | ||
116 | - FILE_OPEN_IF, | ||
117 | - FILE_SYNCHRONOUS_IO_NONALERT, | ||
118 | - 1, 1, 0, -1, | ||
119 | - 0x1000, | ||
120 | - 0x1000, | ||
121 | - &time))) { | ||
122 | - //ConsoleOutput(ErrorCreatePipe); | ||
123 | - ConsoleOutput("vnrhost:CreateNewPipe: failed to create cmd pipe"); | ||
124 | - return; | ||
125 | - } | ||
126 | - | ||
127 | - hThread = IthCreateThread(RecvThread, (DWORD)hTextPipe); | ||
128 | - man->RegisterPipe(hTextPipe, hCmdPipe, hThread); | ||
129 | -} | ||
130 | - | ||
131 | -void DetachFromProcess(DWORD pid) | ||
132 | -{ | ||
133 | - HANDLE hMutex = INVALID_HANDLE_VALUE, | ||
134 | - hEvent = INVALID_HANDLE_VALUE; | ||
135 | - //try { | ||
136 | - IO_STATUS_BLOCK ios; | ||
137 | - ProcessRecord *pr = man->GetProcessRecord(pid); | ||
138 | - if (!pr) | ||
139 | - return; | ||
140 | - //IthBreak(); | ||
141 | - hEvent = IthCreateEvent(nullptr); | ||
142 | - if (STATUS_PENDING == NtFsControlFile( | ||
143 | - man->GetCmdHandleByPID(pid), | ||
144 | - hEvent, | ||
145 | - 0,0, | ||
146 | - &ios, | ||
147 | - CTL_CODE(FILE_DEVICE_NAMED_PIPE, NAMED_PIPE_DISCONNECT, 0, 0), | ||
148 | - 0,0,0,0)) | ||
149 | - NtWaitForSingleObject(hEvent, 0, 0); | ||
150 | - NtClose(hEvent); | ||
151 | - //hEvent = INVALID_HANDLE_VALUE; | ||
152 | - | ||
153 | - WCHAR mutex[0x20]; | ||
154 | - swprintf(mutex, ITH_DETACH_MUTEX_ L"%d", pid); | ||
155 | - hMutex = IthOpenMutex(mutex); | ||
156 | - if (hMutex != INVALID_HANDLE_VALUE) { | ||
157 | - NtWaitForSingleObject(hMutex, 0, 0); | ||
158 | - NtReleaseMutant(hMutex, 0); | ||
159 | - NtClose(hMutex); | ||
160 | - //hMutex = INVALID_HANDLE_VALUE; | ||
161 | - } | ||
162 | - | ||
163 | - //} catch (...) { | ||
164 | - // if (hEvent != INVALID_HANDLE_VALUE) | ||
165 | - // NtClose(hEvent); | ||
166 | - // else if (hMutex != INVALID_HANDLE_VALUE) { | ||
167 | - // NtWaitForSingleObject(hMutex, 0, 0); | ||
168 | - // NtReleaseMutant(hMutex, 0); | ||
169 | - // NtClose(hMutex); | ||
170 | - // } | ||
171 | - //} | ||
172 | - | ||
173 | - //NtSetEvent(hDetachEvent, 0); | ||
174 | - if (::running) | ||
175 | - NtSetEvent(hPipeExist, 0); | ||
176 | -} | ||
177 | - | ||
178 | -// jichi 9/27/2013: I don't need this | ||
179 | -//void OutputDWORD(DWORD d) | ||
180 | -//{ | ||
181 | -// WCHAR str[0x20]; | ||
182 | -// swprintf(str, L"%.8X", d); | ||
183 | -// ConsoleOutput(str); | ||
184 | -//} | ||
185 | - | ||
186 | -DWORD WINAPI RecvThread(LPVOID lpThreadParameter) | ||
187 | -{ | ||
188 | - HANDLE hTextPipe = (HANDLE)lpThreadParameter; | ||
189 | - | ||
190 | - IO_STATUS_BLOCK ios; | ||
191 | - NtFsControlFile(hTextPipe, | ||
192 | - 0, 0, 0, | ||
193 | - &ios, | ||
194 | - CTL_CODE(FILE_DEVICE_NAMED_PIPE, NAMED_PIPE_CONNECT, 0, 0), | ||
195 | - 0, 0, 0, 0); | ||
196 | - if (!::running) { | ||
197 | - NtClose(hTextPipe); | ||
198 | - return 0; | ||
199 | - } | ||
200 | - | ||
201 | - BYTE *buff; | ||
202 | - | ||
203 | - enum { PipeBufferSize = 0x1000 }; | ||
204 | - buff = new BYTE[PipeBufferSize]; | ||
205 | - ITH_MEMSET_HEAP(buff, 0, PipeBufferSize); // jichi 8/27/2013: zero memory, or it will crash wine on start up | ||
206 | - | ||
207 | - // 10/19/2014 jichi: there are totally three words received | ||
208 | - // See: hook/rpc/pipe.cc | ||
209 | - // struct { | ||
210 | - // DWORD pid; | ||
211 | - // TextHook *man; | ||
212 | - // DWORD module; | ||
213 | - // //DWORD engine; | ||
214 | - // } u; | ||
215 | - enum { module_struct_size = 12 }; | ||
216 | - NtReadFile(hTextPipe, 0, 0, 0, &ios, buff, module_struct_size, 0, 0); | ||
217 | - | ||
218 | - DWORD pid = *(DWORD *)buff, | ||
219 | - hookman = *(DWORD *)(buff + 0x4), | ||
220 | - module = *(DWORD *)(buff + 0x8); | ||
221 | - //engine = *(DWORD *)(buff + 0xc); | ||
222 | - man->RegisterProcess(pid, hookman, module); | ||
223 | - | ||
224 | - // jichi 9/27/2013: why recursion? | ||
225 | - CreateNewPipe(); | ||
226 | - | ||
227 | - //NtClose(IthCreateThread(UpdateWindows,0)); | ||
228 | - while (::running) { | ||
229 | - if (!NT_SUCCESS(NtReadFile(hTextPipe, | ||
230 | - 0, 0, 0, | ||
231 | - &ios, | ||
232 | - buff, | ||
233 | - 0xf80, | ||
234 | - 0, 0))) | ||
235 | - break; | ||
236 | - | ||
237 | - enum { data_offset = 0xc }; // jichi 10/27/2013: Seem to be the data offset in the pipe | ||
238 | - | ||
239 | - DWORD RecvLen = ios.uInformation; | ||
240 | - if (RecvLen < data_offset) | ||
241 | - break; | ||
242 | - DWORD hook = *(DWORD *)buff; | ||
243 | - | ||
244 | - union { DWORD retn; DWORD cmd_type; }; | ||
245 | - union { DWORD split; DWORD new_engine_type; }; | ||
246 | - | ||
247 | - retn = *(DWORD *)(buff + 4); | ||
248 | - split = *(DWORD *)(buff + 8); | ||
249 | - | ||
250 | - buff[RecvLen] = 0; | ||
251 | - buff[RecvLen + 1] = 0; | ||
252 | - | ||
253 | - if (hook == IHF_NOTIFICATION) { | ||
254 | - switch (cmd_type) { | ||
255 | - case IHF_NOTIFICATION_NEWHOOK: | ||
256 | - { | ||
257 | - static long lock; | ||
258 | - while (InterlockedExchange(&lock, 1) == 1); | ||
259 | - ProcessEventCallback new_hook = man->ProcessNewHook(); | ||
260 | - if (new_hook) | ||
261 | - new_hook(pid); | ||
262 | - lock = 0; | ||
263 | - } break; | ||
264 | - case IHF_NOTIFICATION_TEXT: | ||
265 | - ConsoleOutput((LPCSTR)(buff + 8)); | ||
266 | - break; | ||
267 | - } | ||
268 | - } else { | ||
269 | - // jichi 9/28/2013: Debug raw data | ||
270 | - //ITH_DEBUG_DWORD9(RecvLen - 0xc, | ||
271 | - // buff[0xc], buff[0xd], buff[0xe], buff[0xf], | ||
272 | - // buff[0x10], buff[0x11], buff[0x12], buff[0x13]); | ||
273 | - | ||
274 | - const BYTE *data = buff + data_offset; // th | ||
275 | - int len = RecvLen - data_offset; | ||
276 | - bool space = ::has_leading_space(data, len); | ||
277 | - if (space) { | ||
278 | - const BYTE *it = ::Filter(data, len); | ||
279 | - len -= it - data; | ||
280 | - data = it; | ||
281 | - } | ||
282 | - if (len >> 31) // jichi 10/27/2013: len is too large, which seldom happens | ||
283 | - len = 0; | ||
284 | - //man->DispatchText(pid, len ? data : nullptr, hook, retn, split, len, space); | ||
285 | - man->DispatchText(pid, data, hook, retn, split, len, space); | ||
286 | - } | ||
287 | - } | ||
288 | - | ||
289 | - EnterCriticalSection(&detach_cs); | ||
290 | - | ||
291 | - HANDLE hDisconnect = IthCreateEvent(nullptr); | ||
292 | - | ||
293 | - if (STATUS_PENDING == NtFsControlFile( | ||
294 | - hTextPipe, | ||
295 | - hDisconnect, | ||
296 | - 0, 0, | ||
297 | - &ios, | ||
298 | - CTL_CODE(FILE_DEVICE_NAMED_PIPE, NAMED_PIPE_DISCONNECT, 0, 0), | ||
299 | - 0, 0, 0, 0)) | ||
300 | - NtWaitForSingleObject(hDisconnect, 0, 0); | ||
301 | - | ||
302 | - NtClose(hDisconnect); | ||
303 | - DetachFromProcess(pid); | ||
304 | - man->UnRegisterProcess(pid); | ||
305 | - | ||
306 | - //NtClearEvent(hDetachEvent); | ||
307 | - | ||
308 | - LeaveCriticalSection(&detach_cs); | ||
309 | - delete[] buff; | ||
310 | - | ||
311 | - if (::running) | ||
312 | - ConsoleOutput("vnrhost:DetachFromProcess: detached"); | ||
313 | - | ||
314 | - //if (::running) { | ||
315 | - // swprintf((LPWSTR)buff, FormatDetach, pid); | ||
316 | - // ConsoleOutput((LPWSTR)buff); | ||
317 | - // NtClose(IthCreateThread(UpdateWindows, 0)); | ||
318 | - //} | ||
319 | - return 0; | ||
320 | -} | ||
321 | - | ||
322 | -// EOF |
vnr/ith/host/settings.h
deleted
100644 → 0
vnr/ith/host/srv.h
deleted
100644 → 0
1 | -#pragma once | ||
2 | - | ||
3 | -// srv.h | ||
4 | -// 8/23/2013 jichi | ||
5 | -// Branch: ITH/IHF.h, rev 105 | ||
6 | - | ||
7 | -#include "config.h" | ||
8 | -//#include "ith/host/settings.h" | ||
9 | -#include "ith/host/hookman.h" | ||
10 | -#include "ith/host/SettingManager.h" | ||
11 | - | ||
12 | -struct Settings; | ||
13 | -struct HookParam; | ||
14 | - | ||
15 | -// jichi 8/24/2013: Why extern "C"? Any specific reason to use C instead of C++ naming? | ||
16 | -extern "C" { | ||
17 | -IHFSERVICE DWORD IHFAPI IHF_Init(); | ||
18 | -IHFSERVICE DWORD IHFAPI IHF_Start(); | ||
19 | -IHFSERVICE DWORD IHFAPI IHF_Cleanup(); | ||
20 | -IHFSERVICE DWORD IHFAPI IHF_GetPIDByName(LPCWSTR pwcTarget); | ||
21 | -IHFSERVICE DWORD IHFAPI IHF_InjectByPID(DWORD pid); | ||
22 | -IHFSERVICE DWORD IHFAPI IHF_ActiveDetachProcess(DWORD pid); | ||
23 | -IHFSERVICE DWORD IHFAPI IHF_GetHookManager(HookManager **hookman); | ||
24 | -IHFSERVICE DWORD IHFAPI IHF_GetSettingManager(SettingManager** set_man); | ||
25 | -IHFSERVICE DWORD IHFAPI IHF_GetSettings(Settings **settings); | ||
26 | -IHFSERVICE DWORD IHFAPI IHF_InsertHook(DWORD pid, HookParam *hp, LPCWSTR name = 0); | ||
27 | -IHFSERVICE DWORD IHFAPI IHF_ModifyHook(DWORD pid, HookParam *hp); | ||
28 | -IHFSERVICE DWORD IHFAPI IHF_RemoveHook(DWORD pid, DWORD addr); | ||
29 | -IHFSERVICE DWORD IHFAPI IHF_IsAdmin(); | ||
30 | -//IHFSERVICE DWORD IHFAPI IHF_GetFilters(PVOID *mb_filter, PVOID *uni_filter); | ||
31 | -IHFSERVICE DWORD IHFAPI IHF_AddLink(DWORD from, DWORD to); | ||
32 | -IHFSERVICE DWORD IHFAPI IHF_UnLink(DWORD from); | ||
33 | -IHFSERVICE DWORD IHFAPI IHF_UnLinkAll(DWORD from); | ||
34 | -} // extern "C" | ||
35 | - | ||
36 | -// EOF |
vnr/ith/host/srv_p.h
deleted
100644 → 0
1 | -#pragma once | ||
2 | -// srv_p.h | ||
3 | -// 8/24/2013 jichi | ||
4 | -// Branch IHF/main.h, rev 111 | ||
5 | -#include "config.h" | ||
6 | - | ||
7 | -#define GLOBAL extern | ||
8 | -#define SHIFT_JIS 0x3A4 | ||
9 | -class HookManager; | ||
10 | -//class CommandQueue; | ||
11 | -class SettingManager; | ||
12 | -class TextHook; | ||
13 | -//class BitMap; | ||
14 | -//class CustomFilterMultiByte; | ||
15 | -//class CustomFilterUnicode; | ||
16 | -//#define TextHook Hook | ||
17 | -GLOBAL BOOL running; | ||
18 | -//GLOBAL BitMap *pid_map; | ||
19 | -//GLOBAL CustomFilterMultiByte *mb_filter; | ||
20 | -//GLOBAL CustomFilterUnicode *uni_filter; | ||
21 | -GLOBAL HookManager *man; | ||
22 | -//GLOBAL CommandQueue *cmdq; | ||
23 | -GLOBAL SettingManager *setman; | ||
24 | -GLOBAL WCHAR recv_pipe[]; | ||
25 | -GLOBAL WCHAR command[]; | ||
26 | -GLOBAL HANDLE hPipeExist; | ||
27 | -GLOBAL DWORD split_time, | ||
28 | - cyclic_remove, | ||
29 | - clipboard_flag, | ||
30 | - global_filter; | ||
31 | -GLOBAL CRITICAL_SECTION detach_cs; | ||
32 | - | ||
33 | -DWORD WINAPI RecvThread(LPVOID lpThreadParameter); | ||
34 | -DWORD WINAPI CmdThread(LPVOID lpThreadParameter); | ||
35 | - | ||
36 | -void ConsoleOutput(LPCSTR text); | ||
37 | -void ConsoleOutputW(LPCWSTR text); | ||
38 | -DWORD GetCurrentPID(); | ||
39 | -//DWORD GetProcessIDByPath(LPWSTR str); | ||
40 | -HANDLE GetCmdHandleByPID(DWORD pid); | ||
41 | -//DWORD Inject(HANDLE hProc); | ||
42 | -//DWORD InjectByPID(DWORD pid); | ||
43 | -//DWORD PIDByName(LPWSTR target); | ||
44 | -//DWORD Hash(LPCWSTR module, int length=-1); | ||
45 | - | ||
46 | -// EOF |
vnr/ith/host/textthread.cc
deleted
100644 → 0
This diff is collapsed. Click to expand it.
vnr/ith/host/textthread.h
deleted
100644 → 0
1 | -#pragma once | ||
2 | - | ||
3 | -// textthread.h | ||
4 | -// 8/23/2013 jichi | ||
5 | -// Branch: ITH/TextThread.h, rev 120 | ||
6 | - | ||
7 | -#include "ith/host/textthread_p.h" | ||
8 | -#include <intrin.h> // require _InterlockedExchange | ||
9 | - | ||
10 | -struct RepeatCountNode { | ||
11 | - short repeat; | ||
12 | - short count; | ||
13 | - RepeatCountNode *next; | ||
14 | - | ||
15 | - //RepeatCountNode() : repeat(0), count(0), next(nullptr) {} | ||
16 | -}; | ||
17 | - | ||
18 | -struct ThreadParameter { | ||
19 | - DWORD pid; // jichi: 5/11/2014: The process ID | ||
20 | - DWORD hook; | ||
21 | - DWORD retn; // jichi 5/11/2014: The return address of the hook | ||
22 | - DWORD spl; // jichi 5/11/2014: the processed split value of the hook parameter | ||
23 | -}; | ||
24 | - | ||
25 | -#define CURRENT_SELECT 0x1000 | ||
26 | -#define REPEAT_NUMBER_DECIDED 0x2000 | ||
27 | -#define BUFF_NEWLINE 0x4000 | ||
28 | -#define CYCLIC_REPEAT 0x8000 | ||
29 | -#define COUNT_PER_FOWARD 0x200 | ||
30 | -#define REPEAT_DETECT 0x10000 | ||
31 | -#define REPEAT_SUPPRESS 0x20000 | ||
32 | -#define REPEAT_NEWLINE 0x40000 | ||
33 | - | ||
34 | -class TextThread; | ||
35 | -typedef void (* ConsoleCallback)(LPCSTR text); | ||
36 | -typedef void (* ConsoleWCallback)(LPCWSTR text); | ||
37 | -typedef DWORD (* ThreadOutputFilterCallback)(TextThread *, BYTE *, DWORD, DWORD, PVOID, bool space); // jichi 10/27/2013: Add space | ||
38 | -typedef DWORD (* ThreadEventCallback)(TextThread *); | ||
39 | - | ||
40 | -//extern DWORD split_time,repeat_count,global_filter,cyclic_remove; | ||
41 | - | ||
42 | -class TextThread : public MyVector<BYTE, 0x200> | ||
43 | -{ | ||
44 | -public: | ||
45 | - TextThread(DWORD pid, DWORD hook, DWORD retn, DWORD spl, WORD num); | ||
46 | - ~TextThread(); | ||
47 | - //virtual void CopyLastSentence(LPWSTR str); | ||
48 | - //virtual void SetComment(LPWSTR); | ||
49 | - //virtual void ExportTextToFile(LPWSTR filename); | ||
50 | - | ||
51 | - virtual bool CheckCycle(TextThread *start); | ||
52 | - virtual DWORD GetThreadString(LPWSTR str, DWORD max); | ||
53 | - virtual DWORD GetEntryString(LPWSTR str, DWORD max = 0x200); | ||
54 | - | ||
55 | - void Reset(); | ||
56 | - void AddText(const BYTE *con,int len, bool new_line, bool space); // jichi 10/27/2013: add const; remove console; add space | ||
57 | - void RemoveSingleRepeatAuto(const BYTE *con, int &len); // jichi 10/27/2013: add const | ||
58 | - void RemoveSingleRepeatForce(BYTE *con, int &len); | ||
59 | - void RemoveCyclicRepeat(BYTE *&con, int &len); | ||
60 | - void ResetRepeatStatus(); | ||
61 | - void AddLineBreak(); | ||
62 | - //void ResetEditText(); | ||
63 | - void ComboSelectCurrent(); | ||
64 | - void UnLinkAll(); | ||
65 | - void CopyLastToClipboard(); | ||
66 | - | ||
67 | - //void AdjustPrevRepeat(DWORD len); | ||
68 | - //void PrevRepeatLength(DWORD &len); | ||
69 | - | ||
70 | - //bool AddToCombo(); | ||
71 | - bool RemoveFromCombo(); | ||
72 | - | ||
73 | - void SetNewLineFlag(); | ||
74 | - void SetNewLineTimer(); | ||
75 | - | ||
76 | - BYTE *GetStore(DWORD *len) { if (len) *len = used; return storage; } | ||
77 | - DWORD LastSentenceLen() { return used - last_sentence; } | ||
78 | - DWORD PID() const { return tp.pid; } | ||
79 | - DWORD Addr() const {return tp.hook; } | ||
80 | - DWORD &Status() { return status; } | ||
81 | - WORD Number() const { return thread_number; } | ||
82 | - WORD &Last() { return last; } | ||
83 | - WORD &LinkNumber() { return link_number; } | ||
84 | - UINT_PTR &Timer() { return timer; } | ||
85 | - ThreadParameter *GetThreadParameter() { return &tp; } | ||
86 | - TextThread *&Link() { return link; } | ||
87 | - //LPCWSTR GetComment() { return comment; } | ||
88 | - | ||
89 | - ThreadOutputFilterCallback RegisterOutputCallBack(ThreadOutputFilterCallback cb, PVOID data) | ||
90 | - { | ||
91 | - app_data = data; | ||
92 | - return (ThreadOutputFilterCallback)_InterlockedExchange((long*)&output,(long)cb); | ||
93 | - } | ||
94 | - | ||
95 | - ThreadOutputFilterCallback RegisterFilterCallBack(ThreadOutputFilterCallback cb, PVOID data) | ||
96 | - { | ||
97 | - app_data = data; | ||
98 | - return (ThreadOutputFilterCallback)_InterlockedExchange((long*)&filter,(long)cb); | ||
99 | - } | ||
100 | - | ||
101 | - void SetRepeatFlag() { status |= CYCLIC_REPEAT; } | ||
102 | - void ClearNewLineFlag() { status &= ~BUFF_NEWLINE; } | ||
103 | - void ClearRepeatFlag() { status &= ~CYCLIC_REPEAT; } | ||
104 | - | ||
105 | -protected: | ||
106 | - void AddTextDirect(const BYTE *con, int len, bool space); // jichi 10/27/2013: add const; add space; change to protected | ||
107 | - | ||
108 | -private: | ||
109 | - ThreadParameter tp; | ||
110 | - | ||
111 | - WORD thread_number, | ||
112 | - link_number; | ||
113 | - WORD last, | ||
114 | - align_space; | ||
115 | - WORD repeat_single; | ||
116 | - WORD repeat_single_current; | ||
117 | - WORD repeat_single_count; | ||
118 | - WORD repeat_detect_count; | ||
119 | - RepeatCountNode *head; | ||
120 | - | ||
121 | - TextThread *link; | ||
122 | - ThreadOutputFilterCallback filter; // jichi 10/27/2013: Remove filter | ||
123 | - ThreadOutputFilterCallback output; | ||
124 | - PVOID app_data; | ||
125 | - //LPWSTR comment, | ||
126 | - LPWSTR thread_string; | ||
127 | - UINT_PTR timer; | ||
128 | - DWORD status,repeat_detect_limit; | ||
129 | - DWORD last_sentence, | ||
130 | - prev_sentence, | ||
131 | - sentence_length, | ||
132 | - repeat_index, | ||
133 | - last_time; | ||
134 | -}; | ||
135 | - | ||
136 | -// EOF |
vnr/ith/host/textthread_p.h
deleted
100644 → 0
1 | -#pragma once | ||
2 | -// textthread_p.h | ||
3 | -// 8/14/2013 jichi | ||
4 | -// Branch: ITH/main_template.h, rev 66 | ||
5 | - | ||
6 | -#include "config.h" | ||
7 | - | ||
8 | -template <typename T> | ||
9 | -void Release(const T &p) { delete p; } | ||
10 | - | ||
11 | -// Prevent memory release. | ||
12 | -// Used when T is basic types and will be automatically released (on stack). | ||
13 | -#define MK_BASIC_TYPE(T) \ | ||
14 | - template<> \ | ||
15 | - void Release<T>(const T &p) {} | ||
16 | - | ||
17 | -template<class T> | ||
18 | -struct BinaryEqual { | ||
19 | - bool operator ()(const T &a, const T &b, DWORD) { return a == b; } | ||
20 | -}; | ||
21 | - | ||
22 | -template<class T, int default_size, class fComp=BinaryEqual<T> > | ||
23 | -class MyVector | ||
24 | -{ | ||
25 | -public: | ||
26 | - MyVector() : size(default_size), used(0) | ||
27 | - { | ||
28 | - InitializeCriticalSection(&cs_store); | ||
29 | - storage = new T[size]; | ||
30 | - // jichi 9/21/2013: zero memory | ||
31 | - // This would cause trouble if T is not an atomic type | ||
32 | - ITH_MEMSET_HEAP(storage, 0, sizeof(T) * size); | ||
33 | - } | ||
34 | - | ||
35 | - virtual ~MyVector() | ||
36 | - { | ||
37 | - if (storage) | ||
38 | - delete[] storage; | ||
39 | - DeleteCriticalSection(&cs_store); | ||
40 | - storage = 0; | ||
41 | - } | ||
42 | - | ||
43 | - void Reset() | ||
44 | - { | ||
45 | - EnterCriticalSection(&cs_store); | ||
46 | - for (int i = 0; i < used; i++) { | ||
47 | - Release<T>(storage[i]); | ||
48 | - storage[i] = T(); | ||
49 | - } | ||
50 | - used = 0; | ||
51 | - LeaveCriticalSection(&cs_store); | ||
52 | - } | ||
53 | - void Remove(int index) | ||
54 | - { | ||
55 | - if (index>=used) | ||
56 | - return; | ||
57 | - Release<T>(storage[index]); | ||
58 | - for (int i = index; i < used; i++) | ||
59 | - storage[i] = storage[i+1]; | ||
60 | - used--; | ||
61 | - } | ||
62 | - void ClearMemory(int offset, int clear_size) | ||
63 | - { | ||
64 | - if (clear_size < 0) | ||
65 | - return; | ||
66 | - EnterCriticalSection(&cs_store); | ||
67 | - if (offset+clear_size <= size) | ||
68 | - memset(storage+offset, 0, clear_size * sizeof(T)); // jichi 11/30/2013: This is the original code of ITH | ||
69 | - LeaveCriticalSection(&cs_store); | ||
70 | - //else __asm int 3 | ||
71 | - } | ||
72 | - int AddToStore(T *con,int amount) | ||
73 | - { | ||
74 | - if (amount <= 0 || con == 0) | ||
75 | - return 0; | ||
76 | - int status = 0; | ||
77 | - EnterCriticalSection(&cs_store); | ||
78 | - if (amount + used + 2 >= size) { | ||
79 | - while (amount + used + 2 >= size) | ||
80 | - size<<=1; | ||
81 | - T *temp; | ||
82 | - if (size * sizeof(T) < 0x1000000) { | ||
83 | - temp = new T[size]; | ||
84 | - if (size > used) | ||
85 | - ITH_MEMSET_HEAP(temp, 0, (size - used) * sizeof(T)); // jichi 9/25/2013: zero memory | ||
86 | - memcpy(temp, storage, used * sizeof(T)); | ||
87 | - } else { | ||
88 | - size = default_size; | ||
89 | - temp = new T[size]; | ||
90 | - ITH_MEMSET_HEAP(temp, 0, sizeof(T) * size); // jichi 9/25/2013: zero memory | ||
91 | - used = 0; | ||
92 | - status = 1; | ||
93 | - } | ||
94 | - delete[] storage; | ||
95 | - storage = temp; | ||
96 | - } | ||
97 | - memcpy(storage+used, con, amount * sizeof(T)); | ||
98 | - used += amount; | ||
99 | - LeaveCriticalSection(&cs_store); | ||
100 | - return status; | ||
101 | - } | ||
102 | - int Find(const T &item, int start = 0, DWORD control = 0) | ||
103 | - { | ||
104 | - int c = -1; | ||
105 | - for (int i=start; i < used; i++) | ||
106 | - if (fCmp(storage[i],item,control)) { | ||
107 | - c=i; | ||
108 | - break; | ||
109 | - } | ||
110 | - //if (storage[i]==item) {c=i;break;} | ||
111 | - return c; | ||
112 | - } | ||
113 | - int Used() const { return used; } | ||
114 | - T *Storage() const { return storage; } | ||
115 | - void LockVector() { EnterCriticalSection(&cs_store); } | ||
116 | - void UnlockVector() { LeaveCriticalSection(&cs_store); } | ||
117 | -protected: | ||
118 | - CRITICAL_SECTION cs_store; | ||
119 | - int size, | ||
120 | - used; | ||
121 | - T *storage; | ||
122 | - fComp fCmp; | ||
123 | -}; | ||
124 | - | ||
125 | -// EOF | ||
126 | - | ||
127 | -/* | ||
128 | -#ifndef ITH_STACK | ||
129 | -#define ITH_STACK | ||
130 | -template<class T, int default_size> | ||
131 | -class MyStack | ||
132 | -{ | ||
133 | -public: | ||
134 | - MyStack(): index(0) {} | ||
135 | - void push_back(const T& e) | ||
136 | - { | ||
137 | - if (index<default_size) | ||
138 | - s[index++]=e; | ||
139 | - } | ||
140 | - void pop_back() | ||
141 | - { | ||
142 | - index--; | ||
143 | - } | ||
144 | - T& back() | ||
145 | - { | ||
146 | - return s[index-1]; | ||
147 | - } | ||
148 | - T& operator[](int i) {return s[i];} | ||
149 | - int size() {return index;} | ||
150 | -private: | ||
151 | - int index; | ||
152 | - T s[default_size]; | ||
153 | -}; | ||
154 | -#endif | ||
155 | -*/ |
vnr/ith/import/mono/funcinfo.h
deleted
100644 → 0
1 | -#pragma once | ||
2 | - | ||
3 | -// mono/funcinfo.h | ||
4 | -// 12/26/2014 | ||
5 | -// https://github.com/mono/mono/blob/master/mono/metadata/object.h | ||
6 | -// http://api.xamarin.com/index.aspx?link=xhtml%3Adeploy%2Fmono-api-string.html | ||
7 | - | ||
8 | -//#include "ith/import/mono/types.h" | ||
9 | - | ||
10 | -// MonoString* mono_string_new (MonoDomain *domain, | ||
11 | -// const char *text); | ||
12 | -// MonoString* mono_string_new_len (MonoDomain *domain, | ||
13 | -// const char *text, | ||
14 | -// guint length); | ||
15 | -// MonoString* mono_string_new_size (MonoDomain *domain, | ||
16 | -// gint32 len); | ||
17 | -// MonoString* mono_string_new_utf16 (MonoDomain *domain, | ||
18 | -// const guint16 *text, | ||
19 | -// gint32 len); | ||
20 | -// MonoString* mono_string_from_utf16 (gunichar2 *data); | ||
21 | -// mono_unichar2* mono_string_to_utf16 (MonoString *s); | ||
22 | -// char* mono_string_to_utf8 (MonoString *s); | ||
23 | -// gboolean mono_string_equal (MonoString *s1, | ||
24 | -// MonoString *s2); | ||
25 | -// guint mono_string_hash (MonoString *s); | ||
26 | -// MonoString* mono_string_intern (MonoString *str); | ||
27 | -// MonoString* mono_string_is_interned (MonoString *o); | ||
28 | -// MonoString* mono_string_new_wrapper (const char *text); | ||
29 | -// gunichar2* mono_string_chars (MonoString *s); | ||
30 | -// int mono_string_length (MonoString *s); | ||
31 | -// gunichar2* mono_unicode_from_external (const gchar *in, gsize *bytes); | ||
32 | -// gchar* mono_unicode_to_external (const gunichar2 *uni); | ||
33 | -// gchar* mono_utf8_from_external (const gchar *in); | ||
34 | - | ||
35 | -struct MonoFunction { | ||
36 | - const wchar_t *hookName; | ||
37 | - const char *functionName; | ||
38 | - size_t textIndex; // argument index, starting from 0 | ||
39 | - size_t lengthIndex; // argument index, start from 0 | ||
40 | - unsigned long hookType; // HookParam type | ||
41 | - void *text_fun; // HookParam::text_fun_t | ||
42 | -}; | ||
43 | - | ||
44 | -#define MONO_FUNCTIONS_INITIALIZER \ | ||
45 | - { L"mono_string_to_utf8", "mono_string_to_utf8", 0, 0, USING_UNICODE, SpecialHookMonoString } \ | ||
46 | - , { L"mono_string_to_utf16", "mono_string_to_utf16", 0, 0, USING_UNICODE, SpecialHookMonoString } \ | ||
47 | - , { L"mono_utf8_from_external", "mono_utf8_from_external", 1, 0, USING_STRING|USING_UTF8, nullptr } \ | ||
48 | - , { L"mono_string_from_utf16", "mono_string_from_utf16", 1, 0, USING_UNICODE, nullptr } \ | ||
49 | - , { L"mono_unicode_from_external", "mono_unicode_from_external", 1, 2, USING_UNICODE, nullptr } \ | ||
50 | - , { L"mono_unicode_to_external", "mono_unicode_to_external", 1, 0, USING_UNICODE, nullptr } | ||
51 | - | ||
52 | -// EOF |
vnr/ith/import/mono/mono.pri
deleted
100644 → 0
vnr/ith/import/mono/types.h
deleted
100644 → 0
1 | -#pragma once | ||
2 | - | ||
3 | -// mono/types.h | ||
4 | -// 12/26/2014 | ||
5 | -// https://github.com/mono/mono/blob/master/mono/metadata/object.h | ||
6 | -// http://api.xamarin.com/index.aspx?link=xhtml%3Adeploy%2Fmono-api-string.html | ||
7 | - | ||
8 | -#include <cstdint> | ||
9 | - | ||
10 | -// mono/io-layer/uglify.h | ||
11 | -typedef int8_t gint8; | ||
12 | -typedef int32_t gint32; | ||
13 | -typedef wchar_t gunichar2; // either char or wchar_t, depending on how mono is compiled | ||
14 | - | ||
15 | -typedef gint8 mono_byte; | ||
16 | -typedef gunichar2 mono_unichar2; | ||
17 | - | ||
18 | -// mono/metadata/object.h | ||
19 | - | ||
20 | -typedef mono_byte MonoBoolean; | ||
21 | - | ||
22 | -struct MonoArray; | ||
23 | -struct MonoDelegate; | ||
24 | -struct MonoException; | ||
25 | -struct MonoString; | ||
26 | -struct MonoThreadsSync; | ||
27 | -struct MonoThread; | ||
28 | -struct MonoVTable; | ||
29 | - | ||
30 | -struct MonoObject { | ||
31 | - MonoVTable *vtable; | ||
32 | - MonoThreadsSync *synchronisation; | ||
33 | -}; | ||
34 | - | ||
35 | -struct MonoString { | ||
36 | - MonoObject object; | ||
37 | - gint32 length; | ||
38 | - gunichar2 chars[0]; | ||
39 | -}; | ||
40 | - | ||
41 | -// EOF |
vnr/ith/import/ppsspp/funcinfo.h
deleted
100644 → 0
1 | -#pragma once | ||
2 | -//#include "ith/common/const.h" | ||
3 | - | ||
4 | -// ppsspp/funcinfo.h | ||
5 | -// 12/26/2014 | ||
6 | -// See: https://github.com/hrydgard/ppsspp | ||
7 | - | ||
8 | -// Core/HLE (High Level Emulator) | ||
9 | -// - sceCcc | ||
10 | -// #void sceCccSetTable(u32 jis2ucs, u32 ucs2jis) | ||
11 | -// int sceCccUTF8toUTF16(u32 dstAddr, u32 dstSize, u32 srcAddr) | ||
12 | -// int sceCccUTF8toSJIS(u32 dstAddr, u32 dstSize, u32 srcAddr) | ||
13 | -// int sceCccUTF16toUTF8(u32 dstAddr, u32 dstSize, u32 srcAddr) | ||
14 | -// int sceCccUTF16toSJIS(u32 dstAddr, u32 dstSize, u32 srcAddr) | ||
15 | -// int sceCccSJIStoUTF8(u32 dstAddr, u32 dstSize, u32 srcAddr) | ||
16 | -// int sceCccSJIStoUTF16(u32 dstAddr, u32 dstSize, u32 srcAddr) | ||
17 | -// int sceCccStrlenUTF8(u32 strAddr) | ||
18 | -// int sceCccStrlenUTF16(u32 strAddr) | ||
19 | -// int sceCccStrlenSJIS(u32 strAddr) | ||
20 | -// u32 sceCccEncodeUTF8(u32 dstAddrAddr, u32 ucs) | ||
21 | -// void sceCccEncodeUTF16(u32 dstAddrAddr, u32 ucs) | ||
22 | -// u32 sceCccEncodeSJIS(u32 dstAddrAddr, u32 jis) | ||
23 | -// u32 sceCccDecodeUTF8(u32 dstAddrAddr) | ||
24 | -// u32 sceCccDecodeUTF16(u32 dstAddrAddr) | ||
25 | -// u32 sceCccDecodeSJIS(u32 dstAddrAddr) | ||
26 | -// int sceCccIsValidUTF8(u32 c) | ||
27 | -// int sceCccIsValidUTF16(u32 c) | ||
28 | -// int sceCccIsValidSJIS(u32 c) | ||
29 | -// int sceCccIsValidUCS2(u32 c) | ||
30 | -// int sceCccIsValidUCS4(u32 c) | ||
31 | -// int sceCccIsValidJIS(u32 c) | ||
32 | -// int sceCccIsValidUnicode(u32 c) | ||
33 | -// #u32 sceCccSetErrorCharUTF8(u32 c) | ||
34 | -// #u32 sceCccSetErrorCharUTF16(u32 c) | ||
35 | -// #u32 sceCccSetErrorCharSJIS(u32 c) | ||
36 | -// u32 sceCccUCStoJIS(u32 c, u32 alt) | ||
37 | -// u32 sceCccJIStoUCS(u32 c, u32 alt) | ||
38 | -// - sceFont: search charCode | ||
39 | -// int sceFontGetCharInfo(u32 fontHandle, u32 charCode, u32 charInfoPtr) | ||
40 | -// int sceFontGetShadowInfo(u32 fontHandle, u32 charCode, u32 charInfoPtr) | ||
41 | -// int sceFontGetCharImageRect(u32 fontHandle, u32 charCode, u32 charRectPtr) | ||
42 | -// int sceFontGetShadowImageRect(u32 fontHandle, u32 charCode, u32 charRectPtr) | ||
43 | -// int sceFontGetCharGlyphImage(u32 fontHandle, u32 charCode, u32 glyphImagePtr) | ||
44 | -// int sceFontGetCharGlyphImage_Clip(u32 fontHandle, u32 charCode, u32 glyphImagePtr, int clipXPos, int clipYPos, int clipWidth, int clipHeight) | ||
45 | -// #int sceFontSetAltCharacterCode(u32 fontLibHandle, u32 charCode) | ||
46 | -// int sceFontGetShadowGlyphImage(u32 fontHandle, u32 charCode, u32 glyphImagePtr) | ||
47 | -// int sceFontGetShadowGlyphImage_Clip(u32 fontHandle, u32 charCode, u32 glyphImagePtr, int clipXPos, int clipYPos, int clipWidth, int clipHeight) | ||
48 | -// - sceKernelInterrupt | ||
49 | -// u32 sysclib_strcat(u32 dst, u32 src) | ||
50 | -// int sysclib_strcmp(u32 dst, u32 src) | ||
51 | -// u32 sysclib_strcpy(u32 dst, u32 src) | ||
52 | -// u32 sysclib_strlen(u32 src) | ||
53 | -// | ||
54 | -// Sample debug string: | ||
55 | -// 006EFD8E PUSH PPSSPPWi.00832188 ASCII "sceCccEncodeSJIS(%08x, U+%04x)" | ||
56 | -// Corresponding source code in sceCcc: | ||
57 | -// ERROR_LOG(HLE, "sceCccEncodeSJIS(%08x, U+%04x): invalid pointer", dstAddrAddr, jis); | ||
58 | - | ||
59 | -struct PPSSPPFunction | ||
60 | -{ | ||
61 | - const wchar_t *hookName; // hook name | ||
62 | - size_t argIndex; // argument index | ||
63 | - unsigned long hookType; // hook parameter type | ||
64 | - unsigned long hookSplit; // hook parameter split, positive: stack, negative: registers | ||
65 | - const char *pattern; // debug string used within the function | ||
66 | -}; | ||
67 | - | ||
68 | -// jichi 7/14/2014: UTF-8 is treated as STRING | ||
69 | -// http://867258173.diandian.com/post/2014-06-26/40062099618 | ||
70 | -// sceFontGetCharGlyphImage_Clip | ||
71 | -// Sample game: [KID] Monochrome: sceFontGetCharInfo, sceFontGetCharGlyphImage_Clip | ||
72 | -// | ||
73 | -// Example: { L"sceFontGetCharInfo", 2, USING_UNICODE, 4, "sceFontGetCharInfo(" } | ||
74 | -// Text is at arg2, using arg1 as split | ||
75 | -#define PPSSPP_FUNCTIONS_INITIALIZER \ | ||
76 | - { L"sceCccStrlenSJIS", 1, USING_STRING, 0, "sceCccStrlenSJIS(" } \ | ||
77 | - , { L"sceCccStrlenUTF8", 1, USING_UTF8, 0, "sceCccStrlenUTF8(" } \ | ||
78 | - , { L"sceCccStrlenUTF16", 1, USING_UNICODE, 0, "sceCccStrlenUTF16(" } \ | ||
79 | -\ | ||
80 | - , { L"sceCccSJIStoUTF8", 3, USING_UTF8, 0, "sceCccSJIStoUTF8(" } \ | ||
81 | - , { L"sceCccSJIStoUTF16", 3, USING_STRING, 0, "sceCccSJIStoUTF16(" } \ | ||
82 | - , { L"sceCccUTF8toSJIS", 3, USING_UTF8, 0, "sceCccUTF8toSJIS(" } \ | ||
83 | - , { L"sceCccUTF8toUTF16", 3, USING_UTF8, 0, "sceCccUTF8toUTF16(" } \ | ||
84 | - , { L"sceCccUTF16toSJIS", 3, USING_UNICODE, 0, "sceCccUTF16toSJIS(" } \ | ||
85 | - , { L"sceCccUTF16toUTF8", 3, USING_UNICODE, 0, "sceCccUTF16toUTF8(" } \ | ||
86 | -\ | ||
87 | - , { L"sceFontGetCharInfo", 2, USING_UNICODE, 4, "sceFontGetCharInfo(" } \ | ||
88 | - , { L"sceFontGetShadowInfo", 2, USING_UNICODE, 4, "sceFontGetShadowInfo("} \ | ||
89 | - , { L"sceFontGetCharImageRect", 2, USING_UNICODE, 4, "sceFontGetCharImageRect(" } \ | ||
90 | - , { L"sceFontGetShadowImageRect", 2, USING_UNICODE, 4, "sceFontGetShadowImageRect(" } \ | ||
91 | - , { L"sceFontGetCharGlyphImage", 2, USING_UNICODE, 4, "sceFontGetCharGlyphImage(" } \ | ||
92 | - , { L"sceFontGetCharGlyphImage_Clip", 2, USING_UNICODE, 4, "sceFontGetCharGlyphImage_Clip(" } \ | ||
93 | - , { L"sceFontGetShadowGlyphImage", 2, USING_UNICODE, 4, "sceFontGetShadowGlyphImage(" } \ | ||
94 | - , { L"sceFontGetShadowGlyphImage_Clip", 2, USING_UNICODE, 4, "sceFontGetShadowGlyphImage_Clip(" } \ | ||
95 | -\ | ||
96 | - , { L"sysclib_strcat", 2, USING_STRING, 0, "Untested sysclib_strcat(" } \ | ||
97 | - , { L"sysclib_strcpy", 2, USING_STRING, 0, "Untested sysclib_strcpy(" } \ | ||
98 | - , { L"sysclib_strlen", 1, USING_STRING, 0, "Untested sysclib_strlen(" } | ||
99 | - | ||
100 | - // Disabled as I am not sure how to deal with the source string | ||
101 | - //, { L"sceCccEncodeSJIS", 2, USING_STRING, 0, "sceCccEncodeSJIS(" } | ||
102 | - //, { L"sceCccEncodeUTF8", 2, USING_UTF8, 0, "sceCccEncodeUTF8(" } | ||
103 | - //, { L"sceCccEncodeUTF16", 2, USING_UNICODE, 0, "sceCccEncodeUTF16(" } | ||
104 | - //, { L"sysclib_strcmp", 2, USING_STRING, 0, "Untested sysclib_strcmp(" } | ||
105 | - | ||
106 | -// EOF |
vnr/ith/import/ppsspp/ppsspp.pri
deleted
100644 → 0
vnr/ith/ith.pro
deleted
100644 → 0
1 | -# ith.pro | ||
2 | -# 10/13/2011 jichi | ||
3 | - | ||
4 | -TEMPLATE = subdirs | ||
5 | - | ||
6 | -# The order is important! | ||
7 | -SUBDIRS += \ | ||
8 | - sys \ | ||
9 | - hook hookxp \ | ||
10 | - host | ||
11 | - | ||
12 | -OTHER_FILES += dllconfig.pri | ||
13 | - | ||
14 | -include(common/common.pri) # not used | ||
15 | -include(import/mono/mono.pri) # not used | ||
16 | -include(import/ppsspp/ppsspp.pri) # not used | ||
17 | - | ||
18 | -# EOF |
vnr/ith/sys/CMakeLists.txt
deleted
100644 → 0
1 | -# sys.pro | ||
2 | -# CONFIG += noqt noeh staticlib | ||
3 | - | ||
4 | -# CONFIG(noeh) { | ||
5 | -# message(CONFIG noeh) | ||
6 | -# QMAKE_CXXFLAGS += /GR- | ||
7 | -# QMAKE_CXXFLAGS_RTTI_ON -= /GR | ||
8 | -# QMAKE_CXXFLAGS_STL_ON -= /EHsc | ||
9 | -# QMAKE_CXXFLAGS_EXCEPTIONS_ON -= /EHsc | ||
10 | -# CONFIG(dll) { | ||
11 | -# QMAKE_LFLAGS += /ENTRY:"DllMain" | ||
12 | -# } | ||
13 | -# } | ||
14 | - | ||
15 | -set(vnrsys_src | ||
16 | - sys.h | ||
17 | - sys.cc | ||
18 | -) | ||
19 | - | ||
20 | -add_library(vnrsys STATIC ${vnrsys_src}) | ||
21 | - | ||
22 | -target_compile_options(vnrsys PRIVATE | ||
23 | - # http://msdn.microsoft.com/library/we6hfdy0.aspx | ||
24 | - /GR- # disable RTTI | ||
25 | - # http://msdn.microsoft.com/library/1deeycx5.aspx | ||
26 | - # /EHs-c- # disable exception handling # CMake bug 15243: http://www.cmake.org/Bug/view.php?id=15243 | ||
27 | - $<$<CONFIG:Release>:> | ||
28 | - $<$<CONFIG:Debug>:> | ||
29 | -) | ||
30 | - | ||
31 | -STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) | ||
32 | - | ||
33 | -target_link_libraries(vnrsys comctl32.lib) | ||
34 | - | ||
35 | -target_compile_definitions(vnrsys | ||
36 | - PRIVATE | ||
37 | -) |
vnr/ith/sys/sys.cc
deleted
100644 → 0
This diff is collapsed. Click to expand it.
vnr/ith/sys/sys.h
deleted
100644 → 0
1 | -#pragma once | ||
2 | - | ||
3 | -// ith/sys.h | ||
4 | -// 8/23/2013 jichi | ||
5 | -// Branch: ITH/IHF_SYS.h, rev 111 | ||
6 | - | ||
7 | -#ifdef _MSC_VER | ||
8 | -# pragma warning(disable:4800) // C4800: forcing value to bool | ||
9 | -#endif // _MSC_VER | ||
10 | - | ||
11 | -#include "ntdll/ntdll.h" | ||
12 | - | ||
13 | -// jichi 8/24/2013: Why extern "C"? Any specific reason to use C instead of C++ naming? | ||
14 | -extern "C" { | ||
15 | -//int disasm(BYTE *opcode0); // jichi 8/15/2013: move disasm to separate file | ||
16 | -extern WORD *NlsAnsiCodePage; | ||
17 | -int FillRange(LPCWSTR name,DWORD *lower, DWORD *upper); | ||
18 | -int MB_WC(char *mb, wchar_t *wc); | ||
19 | -//int MB_WC_count(char *mb, int mb_length); | ||
20 | -int WC_MB(wchar_t *wc, char *mb); | ||
21 | - | ||
22 | -// jichi 10/1/2013: Return 0 if failed. So, it is ambiguous if the search pattern starts at 0 | ||
23 | -DWORD SearchPattern(DWORD base, DWORD base_length, LPCVOID search, DWORD search_length); // KMP | ||
24 | - | ||
25 | -// jichi 2/5/2014: The same as SearchPattern except it uses 0xff to match everything | ||
26 | -// According to @Andys, 0xff seldom appear in the source code: http://sakuradite.com/topic/124 | ||
27 | -enum : BYTE { SP_ANY = 0xff }; | ||
28 | -#define SP_ANY_2 SP_ANY,SP_ANY | ||
29 | -#define SP_ANY_3 SP_ANY,SP_ANY,SP_ANY | ||
30 | -#define SP_ANY_4 SP_ANY,SP_ANY,SP_ANY,SP_ANY | ||
31 | -DWORD SearchPatternEx(DWORD base, DWORD base_length, LPCVOID search, DWORD search_length, BYTE wildcard=SP_ANY); | ||
32 | - | ||
33 | -BOOL IthInitSystemService(); | ||
34 | -void IthCloseSystemService(); | ||
35 | -DWORD IthGetMemoryRange(LPCVOID mem, DWORD *base, DWORD *size); | ||
36 | -BOOL IthCheckFile(LPCWSTR file); | ||
37 | -BOOL IthFindFile(LPCWSTR file); | ||
38 | -BOOL IthGetFileInfo(LPCWSTR file, LPVOID info, DWORD size = 0x1000); | ||
39 | -BOOL IthCheckFileFullPath(LPCWSTR file); | ||
40 | -HANDLE IthCreateFile(LPCWSTR name, DWORD option, DWORD share, DWORD disposition); | ||
41 | -HANDLE IthCreateFileInDirectory(LPCWSTR name, HANDLE dir, DWORD option, DWORD share, DWORD disposition); | ||
42 | -HANDLE IthCreateDirectory(LPCWSTR name); | ||
43 | -HANDLE IthCreateFileFullPath(LPCWSTR fullpath, DWORD option, DWORD share, DWORD disposition); | ||
44 | -HANDLE IthPromptCreateFile(DWORD option, DWORD share, DWORD disposition); | ||
45 | -HANDLE IthCreateSection(LPCWSTR name, DWORD size, DWORD right); | ||
46 | -HANDLE IthCreateEvent(LPCWSTR name, DWORD auto_reset=0, DWORD init_state=0); | ||
47 | -HANDLE IthOpenEvent(LPCWSTR name); | ||
48 | -void IthSetEvent(HANDLE hEvent); | ||
49 | -void IthResetEvent(HANDLE hEvent); | ||
50 | -HANDLE IthCreateMutex(LPCWSTR name, BOOL InitialOwner, DWORD *exist=0); | ||
51 | -HANDLE IthOpenMutex(LPCWSTR name); | ||
52 | -BOOL IthReleaseMutex(HANDLE hMutex); | ||
53 | -//DWORD IthWaitForSingleObject(HANDLE hObject, DWORD dwTime); | ||
54 | -HANDLE IthCreateThread(LPCVOID start_addr, DWORD param, HANDLE hProc=(HANDLE)-1); | ||
55 | -DWORD GetExportAddress(DWORD hModule,DWORD hash); | ||
56 | -void IthSleep(int time); // jichi 9/28/2013: in ms | ||
57 | -void IthSystemTimeToLocalTime(LARGE_INTEGER *ptime); | ||
58 | -void FreeThreadStart(HANDLE hProc); | ||
59 | -void CheckThreadStart(); | ||
60 | -} // extern "C" | ||
61 | - | ||
62 | -#ifdef ITH_HAS_HEAP | ||
63 | -extern HANDLE hHeap; // used in ith/common/memory.h | ||
64 | -#endif // ITH_HAS_HEAP | ||
65 | - | ||
66 | -extern DWORD current_process_id; | ||
67 | -extern DWORD debug; | ||
68 | -extern BYTE LeadByteTable[]; | ||
69 | -extern LPVOID page; | ||
70 | -extern BYTE launch_time[]; | ||
71 | - | ||
72 | -inline DWORD GetHash(LPSTR str) | ||
73 | -{ | ||
74 | - DWORD hash = 0; | ||
75 | - //for (; *str; str++) | ||
76 | - while (*str) | ||
77 | - hash = ((hash>>7) | (hash<<25)) + *str++; | ||
78 | - return hash; | ||
79 | -} | ||
80 | - | ||
81 | -inline DWORD GetHash(LPCWSTR str) | ||
82 | -{ | ||
83 | - DWORD hash = 0; | ||
84 | - //for (; *str; str++) | ||
85 | - while (*str) | ||
86 | - hash = ((hash>>7) | (hash<<25)) + *str++; | ||
87 | - return hash; | ||
88 | -} | ||
89 | - | ||
90 | -inline void IthBreak() | ||
91 | -{ if (debug) __debugbreak(); } | ||
92 | - | ||
93 | -inline LPCWSTR GetMainModulePath() | ||
94 | -{ | ||
95 | - __asm | ||
96 | - { | ||
97 | - mov eax, fs:[0x30] | ||
98 | - mov eax, [eax + 0xC] | ||
99 | - mov eax, [eax + 0xC] | ||
100 | - mov eax, [eax + 0x28] | ||
101 | - } | ||
102 | -} | ||
103 | - | ||
104 | -// jichi 9/28/2013: Add this to lock NtWriteFile in wine | ||
105 | -class IthMutexLocker | ||
106 | -{ | ||
107 | - HANDLE m; | ||
108 | -public: | ||
109 | - explicit IthMutexLocker(HANDLE mutex) : m(mutex) | ||
110 | - { NtWaitForSingleObject(m, 0, 0); } | ||
111 | - | ||
112 | - ~IthMutexLocker() { if (m != INVALID_HANDLE_VALUE) IthReleaseMutex(m); } | ||
113 | - | ||
114 | - bool locked() const { return m != INVALID_HANDLE_VALUE; } | ||
115 | - | ||
116 | - void unlock() { if (m != INVALID_HANDLE_VALUE) { IthReleaseMutex(m); m = INVALID_HANDLE_VALUE; } } | ||
117 | -}; | ||
118 | - | ||
119 | -void IthCoolDown(); | ||
120 | - | ||
121 | -BOOL IthIsWine(); | ||
122 | -BOOL IthIsWindowsXp(); | ||
123 | -//BOOL IthIsWindows8OrGreater(); // not public | ||
124 | - | ||
125 | -/** Get current dll path. | ||
126 | - * @param buf | ||
127 | - * @param len | ||
128 | - * @return length of the path excluding \0 | ||
129 | - */ | ||
130 | -size_t IthGetCurrentModulePath(wchar_t *buf, size_t len); | ||
131 | - | ||
132 | -// EOF |
vnr/ith/sys/sys.pri
deleted
100644 → 0
vnr/ith/sys/sys.pro
deleted
100644 → 0
1 | -# sys.pro | ||
2 | -# 8/21/2013 jichi | ||
3 | -# Build vnrsys.lib | ||
4 | - | ||
5 | -CONFIG += noqt noeh staticlib | ||
6 | - | ||
7 | -include(../../../../config.pri) | ||
8 | -include($$LIBDIR/ntdll/ntdll.pri) | ||
9 | - | ||
10 | -#include($$LIBDIR/winddk/winddk.pri) | ||
11 | -#LIBS += -L$$WDK/lib/wxp/i386 | ||
12 | - | ||
13 | -# jichi 9/22/2013: When ITH is on wine, certain NT functions are replaced | ||
14 | -#DEFINES += ITH_WINE | ||
15 | - | ||
16 | -# jichi 9/14/2013: Windows XP's msvnrt does not have except handler | ||
17 | -DEFINES -= ITH_HAS_SEH | ||
18 | - | ||
19 | -# jichi 11/24/2013: Disable manual heap | ||
20 | -DEFINES -= ITH_HAS_HEAP | ||
21 | - | ||
22 | -## Libraries | ||
23 | - | ||
24 | -#INCLUDEPATH += $$ITH_HOME/include | ||
25 | -#INCLUDEPATH += $$WDK7_HOME/inc/ddk | ||
26 | - | ||
27 | -#LIBS += -lgdi32 -luser32 -lkernel32 | ||
28 | -#LIBS += -L$$WDK7_HOME/lib/wxp/i386 -lntdll | ||
29 | -#LIBS += $$WDK7_HOME/lib/crt/i386/msvcrt.lib # Override msvcrt10 | ||
30 | - | ||
31 | -#DEFINES += ITH_HAS_CXX | ||
32 | - | ||
33 | -#LIBS += -lith_sys -lntdll | ||
34 | -#LIBS += -lith_tls -lntdll | ||
35 | -#LIBS += -lntoskrnl | ||
36 | - | ||
37 | -DEFINES += _CRT_NON_CONFORMING_SWPRINTFS | ||
38 | - | ||
39 | -## Sources | ||
40 | - | ||
41 | -TEMPLATE = lib | ||
42 | -TARGET = vnrsys | ||
43 | - | ||
44 | -HEADERS += sys.h | ||
45 | -SOURCES += sys.cc | ||
46 | - | ||
47 | -OTHER_FILES += sys.pri | ||
48 | - | ||
49 | -# EOF |
vnr/ith/xp.txt
deleted
100644 → 0
-
Please register or login to post a comment