mireado

starting commit

english version
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 +#include "CustomFilter.h"
19 +
20 +void CustomFilter::Insert(WORD number)
21 +{
22 + set.insert(number);
23 +}
24 +
25 +void CustomFilter::Erase(WORD number)
26 +{
27 + set.erase(number);
28 +}
29 +
30 +bool CustomFilter::Find(WORD number) const
31 +{
32 + return set.find(number) != set.end();
33 +}
34 +
35 +void CustomFilter::Clear()
36 +{
37 + set.clear();
38 +}
39 +
40 +void CustomFilter::Traverse(CustomFilterCallBack callback, PVOID param)
41 +{
42 + for (auto ch = set.begin(); ch != set.end(); ++ch)
43 + callback(*ch, param);
44 +}
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 +
21 +typedef void (*CustomFilterCallBack) (WORD, PVOID);
22 +
23 +class CustomFilter
24 +{
25 +public:
26 + bool Find(WORD number) const;
27 + void Insert(WORD number);
28 + void Erase(WORD number);
29 + void Clear();
30 + void Traverse(CustomFilterCallBack callback, PVOID param);
31 +private:
32 + std::set<WORD> set;
33 +};
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 +#pragma once
18 +#include <windows.h>
19 +#include <string>
20 +#include <sstream>
21 +#include <ios>
22 +#include <memory>
23 +#include <stdexcept>
24 +#include <assert.h>
25 +#include <WindowsX.h>
26 +#include <algorithm>
27 +#include <Psapi.h>
28 +#include <vector>
29 +#include <map>
30 +#include <CommCtrl.h>
31 +#include <intrin.h>
32 +#include <WindowsX.h>
33 +#include <sstream>
34 +#include <regex>
35 +#include <set>
36 +#include "pugixml.hpp"
37 +#pragma warning(disable: 4146)
1 +// Generated by ResEdit 1.6.3
2 +// Copyright (C) 2006-2014
3 +// http://www.resedit.net
4 +
5 +#include <windows.h>
6 +#include <commctrl.h>
7 +#include <richedit.h>
8 +#include "resource.h"
9 +
10 +#define WC_LISTVIEW L"SysListView32"
11 +
12 +
13 +
14 +
15 +
16 +//
17 +// Dialog resources
18 +//
19 +LANGUAGE LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN
20 +IDD_DIALOG2 DIALOGEX 100, 100, 341, 210
21 +STYLE DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
22 +CAPTION "Process Explorer"
23 +FONT 8, "MS Shell Dlg", 400, 0, 1
24 +{
25 + DEFPUSHBUTTON "OK", IDOK, 281, 189, 53, 14, 0, WS_EX_LEFT
26 + PUSHBUTTON "Remove Profile", IDC_BUTTON6, 226, 189, 53, 14, 0, WS_EX_LEFT
27 + CONTROL "", IDC_LIST1, WC_LISTVIEW, WS_TABSTOP | WS_BORDER | LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT, 7, 20, 327, 164, WS_EX_LEFT
28 + LTEXT "Process", IDC_STATIC, 7, 7, 65, 13, SS_LEFT | SS_CENTERIMAGE, WS_EX_LEFT
29 + PUSHBUTTON "Attach", IDC_BUTTON2, 61, 189, 53, 14, 0, WS_EX_LEFT
30 + PUSHBUTTON "Detach", IDC_BUTTON3, 116, 189, 53, 14, 0, WS_EX_LEFT
31 + PUSHBUTTON "Add Profile", IDC_BUTTON5, 171, 189, 53, 14, 0, WS_EX_LEFT
32 + PUSHBUTTON "Refresh", IDC_BUTTON1, 7, 189, 53, 14, 0, WS_EX_LEFT
33 +}
34 +
35 +
36 +
37 +LANGUAGE LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN
38 +IDD_DIALOG4 DIALOGEX 150, 100, 123, 185
39 +STYLE DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
40 +CAPTION "Option"
41 +FONT 8, "MS Shell Dlg", 400, 0, 1
42 +{
43 + DEFPUSHBUTTON "OK", IDOK, 8, 164, 50, 14, 0, WS_EX_LEFT
44 + PUSHBUTTON "Cancel", IDCANCEL, 65, 164, 50, 14, 0, WS_EX_LEFT
45 + EDITTEXT IDC_EDIT1, 60, 7, 55, 14, ES_AUTOHSCROLL, WS_EX_LEFT
46 + LTEXT "Split time", IDC_STATIC, 7, 7, 47, 13, SS_LEFT | SS_CENTERIMAGE, WS_EX_LEFT
47 + EDITTEXT IDC_EDIT2, 60, 25, 55, 14, ES_AUTOHSCROLL, WS_EX_LEFT
48 + LTEXT "Process delay", IDC_STATIC, 7, 26, 47, 13, SS_LEFT | SS_CENTERIMAGE, WS_EX_LEFT
49 + EDITTEXT IDC_EDIT3, 60, 45, 55, 14, ES_AUTOHSCROLL, WS_EX_LEFT
50 + LTEXT "Inject delay", IDC_STATIC, 7, 45, 47, 13, SS_LEFT | SS_CENTERIMAGE, WS_EX_LEFT
51 + EDITTEXT IDC_EDIT4, 60, 65, 55, 14, ES_AUTOHSCROLL, WS_EX_LEFT
52 + LTEXT "Insert delay", IDC_STATIC, 7, 65, 47, 13, SS_LEFT | SS_CENTERIMAGE, WS_EX_LEFT
53 + AUTOCHECKBOX "Auto attach", IDC_CHECK1, 7, 87, 54, 10, 0, WS_EX_LEFT
54 + AUTOCHECKBOX "Auto insert", IDC_CHECK2, 62, 87, 50, 10, 0, WS_EX_LEFT
55 + AUTOCHECKBOX "Auto copy to clipboard", IDC_CHECK3, 7, 103, 88, 10, 0, WS_EX_LEFT
56 + AUTOCHECKBOX "Auto suppress repetition", IDC_CHECK4, 7, 119, 95, 10, 0, WS_EX_LEFT
57 + AUTOCHECKBOX "Reset character filter", IDC_CHECK6, 7, 149, 81, 8, 0, WS_EX_LEFT
58 + AUTOCHECKBOX "Enable global filter", IDC_CHECK5, 7, 134, 75, 10, 0, WS_EX_LEFT
59 +}
60 +
61 +
62 +
63 +//
64 +// Icon resources
65 +//
66 +LANGUAGE LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN
67 +IDI_ICON1 ICON "icon1.ico"
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 +#include "ITH.h"
19 +#include "ith/host/srv.h"
20 +#include "ith/common/const.h"
21 +#include "ith/common/types.h"
22 +#include "language.h"
23 +#include "utility.h"
24 +
25 +extern HookManager* man;
26 +extern HWND hwndProcessComboBox;
27 +
28 +bool Parse(const std::wstring& cmd, HookParam& hp)
29 +{
30 + using std::wregex;
31 + using std::regex_search;
32 + // /H[X]{A|B|W|S|Q}[N][data_offset[*drdo]][:sub_offset[*drso]]@addr[:[module[:{name|#ordinal}]]]
33 + wregex rx(L"^X?([ABWSQ])(N)?", wregex::icase);
34 + std::match_results<std::wstring::const_iterator> m;
35 + auto start = cmd.begin();
36 + auto end = cmd.end();
37 + bool result = regex_search(start, end, m, rx);
38 + if (!result)
39 + return result;
40 + start = m[0].second;
41 + if (m[2].matched)
42 + hp.type |= NO_CONTEXT;
43 +
44 + switch (m[1].first[0])
45 + {
46 + case L's':
47 + case L'S':
48 + hp.type |= USING_STRING;
49 + break;
50 + case L'e':
51 + case L'E':
52 + hp.type |= STRING_LAST_CHAR;
53 + case L'a':
54 + case L'A':
55 + hp.type |= BIG_ENDIAN;
56 + hp.length_offset = 1;
57 + break;
58 + case L'b':
59 + case L'B':
60 + hp.length_offset = 1;
61 + break;
62 + case L'h':
63 + case L'H':
64 + hp.type |= PRINT_DWORD;
65 + case L'q':
66 + case L'Q':
67 + hp.type |= USING_STRING | USING_UNICODE;
68 + break;
69 + case L'l':
70 + case L'L':
71 + hp.type |= STRING_LAST_CHAR;
72 + case L'w':
73 + case L'W':
74 + hp.type |= USING_UNICODE;
75 + hp.length_offset = 1;
76 + break;
77 + default:
78 + break;
79 + }
80 +
81 + // [data_offset[*drdo]]
82 + std::wstring data_offset(L"(-?[[:xdigit:]]+)"), drdo(L"(\\*-?[[:xdigit:]]+)?");
83 + rx = wregex(L"^"+ data_offset + drdo, wregex::icase);
84 + result = regex_search(start, end, m, rx);
85 + if (result)
86 + {
87 + start = m[0].second;
88 + hp.off = std::stoul(m[1].str(), NULL, 16);
89 + if (m[2].matched)
90 + {
91 + hp.type |= DATA_INDIRECT;
92 + hp.ind = std::stoul(m[2].str().substr(1), NULL, 16);
93 + }
94 + }
95 +
96 + // [:sub_offset[*drso]]
97 + std::wstring sub_offset(L"(-?[[:xdigit:]]+)"), drso(L"(\\*-?[[:xdigit:]]+)?");
98 + rx = wregex(L"^:" + sub_offset + drso, wregex::icase);
99 + result = regex_search(start, end, m, rx);
100 + if (result)
101 + {
102 + start = m[0].second;
103 + hp.type |= USING_SPLIT;
104 + hp.split = std::stoul(m[1].str(), NULL, 16);
105 + if (m[2].matched)
106 + {
107 + hp.type |= SPLIT_INDIRECT;
108 + hp.split_ind = std::stoul(m[2].str().substr(1), NULL, 16);
109 + }
110 + }
111 + // @addr
112 + rx = wregex(L"^@[[:xdigit:]]+", wregex::icase);
113 + result = regex_search(start, end, m, rx);
114 + if (!result)
115 + return false;
116 + start = m[0].second;
117 + hp.addr = std::stoul(m[0].str().substr(1), NULL, 16);
118 + if (hp.off & 0x80000000)
119 + hp.off -= 4;
120 + if (hp.split & 0x80000000)
121 + hp.split -= 4;
122 +
123 + // [:[module[:{name|#ordinal}]]]
124 + // ":" ->
125 + // "" -> MODULE_OFFSET && module == NULL && function == addr
126 + // ":GDI.dll" -> MODULE_OFFSET && module != NULL
127 + // ":GDI.dll:strlen" -> MODULE_OFFSET | FUNCTION_OFFSET && module != NULL && function != NULL
128 + // ":GDI.dll:#123" -> MODULE_OFFSET | FUNCTION_OFFSET && module != NULL && function != NULL
129 + std::wstring module(L"([[:graph:]]+)"), name(L"[[:graph:]]+"), ordinal(L"\\d+");
130 + rx = wregex(L"^:(" + module + L"(:" + name + L"|#" + ordinal + L")?)?$", wregex::icase);
131 + result = regex_search(start, end, m, rx);
132 + if (result) // :[module[:{name|#ordinal}]]
133 + {
134 + if (m[1].matched) // module
135 + {
136 + hp.type |= MODULE_OFFSET;
137 + std::wstring module = m[2];
138 + std::transform(module.begin(), module.end(), module.begin(), ::towlower);
139 + hp.module = Hash(module);
140 + if (m[3].matched) // :name|#ordinal
141 + {
142 + hp.type |= FUNCTION_OFFSET;
143 + hp.function = Hash(m[3].str().substr(1));
144 + }
145 + }
146 + }
147 + else
148 + {
149 + rx = wregex(L"^!([[:xdigit:]]+)(!([[:xdigit:]]+))?$", wregex::icase);
150 + result = regex_search(start, end, m, rx);
151 + if (result)
152 + {
153 + hp.type |= MODULE_OFFSET;
154 + hp.module = std::stoul(m[1].str(), NULL, 16);
155 + if (m[2].matched)
156 + {
157 + hp.type |= FUNCTION_OFFSET;
158 + hp.function = std::stoul(m[2].str().substr(1), NULL, 16);
159 + }
160 + }
161 + else
162 + {
163 + hp.type |= MODULE_OFFSET;
164 + hp.function = hp.addr;
165 + }
166 + }
167 + return true;
168 +}
169 +
170 +DWORD ProcessCommand(const std::wstring& cmd, DWORD pid)
171 +{
172 + using std::wregex;
173 + using std::regex_match;
174 + std::match_results<std::wstring::const_iterator> m;
175 +
176 + if (regex_match(cmd, m, wregex(L"/pn(.+)", wregex::icase)))
177 + {
178 + pid = IHF_GetPIDByName(m[1].str().c_str());
179 + if (pid == 0)
180 + return 0;
181 + IHF_InjectByPID(pid);
182 + }
183 + else if (regex_match(cmd, m, wregex(L"/p(\\d+)", wregex::icase)))
184 + {
185 + pid = std::stoul(m[1].str());
186 + IHF_InjectByPID(pid);
187 + }
188 + else if (regex_match(cmd, m, wregex (L"/h(.+)", wregex::icase)))
189 + {
190 + HookParam hp = {};
191 + if (Parse(m[1].str(), hp))
192 + IHF_InsertHook(pid, &hp);
193 + }
194 + else if (regex_match(cmd, m, wregex(L":l([[:xdigit:]]+)-([[:xdigit:]]+)", wregex::icase)))
195 + {
196 + DWORD from = std::stoul(m[1].str(), NULL, 16);
197 + DWORD to = std::stoul(m[2].str(), NULL, 16);
198 + IHF_AddLink(from, to);
199 + }
200 + else if (regex_match(cmd, m, wregex(L":u([[:xdigit:]]+)", wregex::icase)))
201 + {
202 + DWORD from = std::stoul(m[1].str(), NULL, 16);
203 + IHF_UnLink(from);
204 + }
205 + else if (regex_match(cmd, m, wregex(L":(?:h|help)", wregex::icase)))
206 + {
207 + ConsoleOutput(Usage);
208 + }
209 + else
210 + {
211 + ConsoleOutput(L"Unknown command. Type :h or :help for help.");
212 + }
213 + return 0;
214 +}
No preview for this file type
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 + */
1 +# winseh_unsafe.pri
2 +# 12/13/2013 jichi
3 +#
4 +# Need compile with /SAFESEH:NO
5 +# See: http://stackoverflow.com/questions/19722308/exception-handler-not-called-in-c
6 +#CONFIG += nosafeseh
7 +win32 {
8 +DEFINES += WITH_LIB_WINSEH
9 +
10 +DEPENDPATH += $$PWD
11 +
12 +HEADERS += $$PWD/winseh.h
13 +SOURCES += \
14 + $$PWD/winseh.cc \
15 + $$PWD/winseh_unsafe.cc
16 +}
17 +
18 +# EOF
1 +// winversion.cc
2 +// 9/5/2014 jichi
3 +
4 +#include "winversion/winversion.h"
5 +#include <windows.h>
6 +
7 +// http://stackoverflow.com/questions/940707/how-do-i-programatically-get-the-version-of-a-dll-or-exe-file
8 +bool WinVersion::queryFileVersion(const wchar_t *path, int ver[])
9 +{
10 + bool ok = false;
11 + // get the version info for the file requested
12 + if (DWORD dwSize = ::GetFileVersionInfoSizeW(path, nullptr)) {
13 + UINT len = 0;
14 + BYTE *buf = new BYTE[dwSize];
15 + VS_FIXEDFILEINFO *info = nullptr;
16 + ok = ::GetFileVersionInfoW(path, 0, dwSize, buf)
17 + && ::VerQueryValueW(buf, L"\\", (LPVOID*)&info, &len)
18 + && info;
19 + if (ok) {
20 + ver[0] = HIWORD(info->dwFileVersionMS),
21 + ver[1] = LOWORD(info->dwFileVersionMS),
22 + ver[2] = HIWORD(info->dwFileVersionLS),
23 + ver[3] = LOWORD(info->dwFileVersionLS);
24 + }
25 + delete[] buf;
26 + }
27 + return ok;
28 +}
29 +
30 +// EOF
1 +#pragma once
2 +
3 +// winversion.h
4 +// 9/5/2014 jichi
5 +
6 +#ifdef _MSC_VER
7 +# include <cstddef> // for wchar_t
8 +#endif // _MSC_VER
9 +
10 +namespace WinVersion {
11 +
12 +bool queryFileVersion(const wchar_t *path, int ver[4]);
13 +
14 +} // namespace WinVersion
15 +
16 +// EOF
1 +# winversion.pri
2 +# 9/5/2014 jichi
3 +win32 {
4 +DEFINES += WITH_LIB_WINVERSION
5 +
6 +LIBS += -lversion
7 +
8 +DEPENDPATH += $$PWD
9 +
10 +HEADERS += $$PWD/winversion.h
11 +SOURCES += $$PWD/winversion.cc
12 +}
13 +
14 +# EOF