timer = NULL;
43 | };
--------------------------------------------------------------------------------
/MisakaHookFinder/types.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "pch.h"
4 | #include "const.h"
5 |
6 | class WinMutex // Like CMutex but works with scoped_lock
7 | {
8 | public:
9 | WinMutex(std::wstring name = L"", LPSECURITY_ATTRIBUTES sa = nullptr) : m(CreateMutexW(sa, FALSE, name.empty() ? NULL : name.c_str())) {}
10 | void lock() { if (m) WaitForSingleObject(m, INFINITE); }
11 | void unlock() { if (m) ReleaseMutex(m); }
12 |
13 | private:
14 | AutoHandle<> m;
15 | };
16 |
17 | inline SECURITY_ATTRIBUTES allAccess = std::invoke([] // allows non-admin processes to access kernel objects made by admin processes
18 | {
19 | static SECURITY_DESCRIPTOR sd = {};
20 | InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
21 | SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
22 | return SECURITY_ATTRIBUTES{ sizeof(SECURITY_ATTRIBUTES), &sd, FALSE };
23 | });
24 |
25 | // jichi 3/7/2014: Add guessed comment
26 | struct HookParam
27 | {
28 | uint64_t address; // absolute or relative address
29 | int offset, // offset of the data in the memory
30 | index, // deref_offset1
31 | split, // offset of the split character
32 | split_index, // deref_offset2
33 | null_length;
34 |
35 | wchar_t module[MAX_MODULE_SIZE];
36 |
37 | char function[MAX_MODULE_SIZE];
38 | DWORD type; // flags
39 | UINT codepage; // text encoding
40 | short length_offset; // index of the string length
41 | uintptr_t padding; // padding before string
42 | DWORD user_value; // 7/20/2014: jichi additional parameters for PSP games
43 |
44 | void(*text_fun)(DWORD stack, HookParam* hp, BYTE obsoleteAlwaysZero, DWORD* data, DWORD* split, DWORD* len);
45 | bool(*filter_fun)(void* data, DWORD* len, HookParam* hp, BYTE obsoleteAlwaysZero); // jichi 10/24/2014: Add filter function. Return false to skip the text
46 | bool(*hook_fun)(DWORD stack, HookParam* hp); // jichi 10/24/2014: Add generic hook function, return false if stop execution.
47 | int(*length_fun)(uintptr_t stack, uintptr_t data); // data after padding added
48 |
49 | char name[HOOK_NAME_SIZE];
50 | };
51 |
52 | struct ThreadParam
53 | {
54 | bool operator==(ThreadParam other) const { return processId == other.processId && addr == other.addr && ctx == other.ctx && ctx2 == other.ctx2; }
55 | DWORD processId;
56 | uint64_t addr;
57 | uint64_t ctx; // The context of the hook: by default the first value on stack, usually the return address
58 | uint64_t ctx2; // The subcontext of the hook: 0 by default, generated in a method specific to the hook
59 | };
60 |
61 | struct SearchParam
62 | {
63 | BYTE pattern[PATTERN_SIZE] = { x64 ? 0xcc : 0x55, x64 ? 0xcc : 0x8b, x64 ? 0x48 : 0xec, 0x89 }; // pattern in memory to search for
64 | int length = x64 ? 4 : 3, // length of pattern (zero means this SearchParam is invalid and the default should be used)
65 | offset = x64 ? 2 : 0, // offset from start of pattern to add hook
66 | searchTime = 20000, // ms
67 | maxRecords = 100000,
68 | codepage = SHIFT_JIS;
69 | uintptr_t padding = 0, // same as hook param padding
70 | minAddress = 0, maxAddress = (uintptr_t)-1; // hook all functions between these addresses (used only if both modules empty)
71 | wchar_t boundaryModule[MAX_MODULE_SIZE] = {}; // hook all functions within this module (middle priority)
72 | wchar_t exportModule[MAX_MODULE_SIZE] = {}; // hook the exports of this module (highest priority)
73 | wchar_t text[PATTERN_SIZE] = {}; // text to search for
74 | void(*hookPostProcessor)(HookParam&) = nullptr;
75 | };
76 |
77 | struct InsertHookCmd // From host
78 | {
79 | InsertHookCmd(HookParam hp) : hp(hp) {}
80 | HostCommandType command = HOST_COMMAND_NEW_HOOK;
81 | HookParam hp;
82 | };
83 |
84 | struct RemoveHookCmd // From host
85 | {
86 | RemoveHookCmd(uint64_t address) : address(address) {}
87 | HostCommandType command = HOST_COMMAND_REMOVE_HOOK;
88 | uint64_t address;
89 | };
90 |
91 | struct FindHookCmd // From host
92 | {
93 | FindHookCmd(SearchParam sp) : sp(sp) {}
94 | HostCommandType command = HOST_COMMAND_FIND_HOOK;
95 | SearchParam sp;
96 | };
97 |
98 | struct ConsoleOutputNotif // From dll
99 | {
100 | ConsoleOutputNotif(std::string message = "") { strncpy_s(this->message, message.c_str(), MESSAGE_SIZE - 1); }
101 | HostNotificationType command = HOST_NOTIFICATION_TEXT;
102 | char message[MESSAGE_SIZE] = {};
103 | };
104 |
105 | struct HookFoundNotif // From dll
106 | {
107 | HookFoundNotif(HookParam hp, wchar_t* text) : hp(hp) { wcsncpy_s(this->text, text, MESSAGE_SIZE - 1); }
108 | HostNotificationType command = HOST_NOTIFICATION_FOUND_HOOK;
109 | HookParam hp;
110 | wchar_t text[MESSAGE_SIZE] = {}; // though type is wchar_t, may not be encoded in UTF-16 (it's just convenient to use wcs* functions)
111 | };
112 |
113 | struct HookRemovedNotif // From dll
114 | {
115 | HookRemovedNotif(uint64_t address) : address(address) {};
116 | HostNotificationType command = HOST_NOTIFICATION_RMVHOOK;
117 | uint64_t address;
118 | };
119 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | MisakaHookFinder 御坂Hook提取器
3 |
4 |
5 |
6 |
7 | Galgame/文字游戏文本钩子提取工具
8 |
9 |
10 |
11 |
12 |
13 | 本项目为[MisakaTranslator](https://github.com/hanmin0822/MisakaTranslator)的子项目之一,可以与MisakaTranslator一起使用以获得更好的使用体验!
14 |
15 |
16 | ## 软件功能及特点
17 |
18 | MisakaHookFinder采用Textractor作为Hook部分模块,最大程度对其精简,保证稳定的同时使搜寻Hook的过程更加便捷和简单,易于新手使用。
19 |
20 | MisakaHookFinder可以搜索到很多常规模式下搜索不到的文本钩子,得到的特殊码在目前知名的几款翻译软件(例如YUKI、MisakaTranslator等)中通用,
21 | 同时还支持剪贴板输出以便其他软件(如VNR等)调用翻译。
22 |
23 | ## 使用教程和说明
24 |
25 | 由于本项目不打算国际化,说明不放在Github上,请见[这里](https://blog.csdn.net/hanmin822/article/details/106362350)
26 |
27 | ## 帮助开发者
28 |
29 | 如果您对这个项目感兴趣,想提供任何帮助,欢迎联系作者。
30 |
31 | E-Mail/QQ:512240272@qq.com
32 |
33 | ## 本项目所使用到的其他开源项目
34 |
35 | * [lgztx96/texthost](https://github.com/lgztx96/texthost)
36 | * [Artikash/Textractor](https://github.com/Artikash/Textractor)
37 |
38 |
39 | ## 其他注意
40 |
41 | 软件开发过程中使用到部分网络素材,如果侵犯到您的权益,请第一时间联系作者删除,谢谢!
42 |
--------------------------------------------------------------------------------