Skip to content

Commit 82bbbba

Browse files
committed
启用pch
1 parent ff709bc commit 82bbbba

36 files changed

+145
-135
lines changed

src/Snap.Hutao.Remastered.Native/DllInjectionUtils.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1+
#include "pch.h"
12
#include "DllInjectionUtils.h"
23
#include "ProcessUtils.h"
34
#include "PrivilegeUtils.h"
45
#include "HookUtils.h"
56
#include "MemoryUtils.h"
67
#include "StringUtils.h"
7-
#include "Error.h"
8-
#include <Windows.h>
9-
#include <vector>
10-
#include <string>
118
#include <tlhelp32.h>
129

1310
// Windows钩子注入方法1(使用WH_GETMESSAGE钩子)

src/Snap.Hutao.Remastered.Native/Error.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "pch.h"
12
#include "Error.h"
23
#include "WilCallbacksManager.h"
34
#include "FailureInfo.h"

src/Snap.Hutao.Remastered.Native/FirewallRuleManager.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
#pragma once
2-
1+
#include "pch.h"
32
#include "FirewallRuleManager.h"
43
#include <sddl.h>
5-
#include <vector>
64
#include <icftypes.h>
75
#include <netfw.h>
8-
#include <Windows.h>
9-
#include <string>
106

117
FirewallRuleManager::FirewallRuleManager()
128
: m_policy(nullptr)
@@ -87,21 +83,21 @@ HRESULT FirewallRuleManager::AddLoopbackExempt(const std::wstring& familyName, c
8783

8884
std::wstring ruleName = GetRuleName(familyName, sid);
8985

90-
// 检查规则是否已存在
86+
// 检查规则是否已存在
9187
INetFwRule* existingRule = nullptr;
9288
hr = m_rules->Item(BSTR(ruleName.c_str()), &existingRule);
9389

9490
if (SUCCEEDED(hr) && existingRule)
9591
{
96-
// 规则已存在,启用它
92+
// 规则已存在,启用它
9793
hr = existingRule->put_Enabled(VARIANT_TRUE);
9894
SafeRelease(existingRule);
9995
return hr;
10096
}
10197

10298
SafeRelease(existingRule);
10399

104-
// 创建新规则
100+
// 创建新规则
105101
return CreateFirewallRule(
106102
ruleName,
107103
L"loopback",
@@ -152,7 +148,7 @@ HRESULT FirewallRuleManager::CreateFirewallRule(const std::wstring& ruleName, co
152148
if (FAILED(hr))
153149
return hr;
154150

155-
// 设置规则属性
151+
// 设置规则属性
156152
hr = rule->put_Name(BSTR(ruleName.c_str()));
157153
if (FAILED(hr)) goto cleanup;
158154

@@ -186,7 +182,7 @@ HRESULT FirewallRuleManager::CreateFirewallRule(const std::wstring& ruleName, co
186182
}
187183
rule->put_Grouping(BSTR(groupName.c_str()));
188184

189-
// 将规则添加到集合中
185+
// 将规则添加到集合中
190186
hr = m_rules->Add(rule);
191187

192188
cleanup:
@@ -214,7 +210,7 @@ std::wstring FirewallRuleManager::GetCurrentUserSid()
214210
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken))
215211
return sidString;
216212

217-
// 获取所需缓冲区大小
213+
// 获取所需缓冲区大小
218214
DWORD tokenSize = 0;
219215
GetTokenInformation(hToken, TokenUser, nullptr, 0, &tokenSize);
220216

@@ -236,4 +232,4 @@ std::wstring FirewallRuleManager::GetCurrentUserSid()
236232

237233
CloseHandle(hToken);
238234
return sidString;
239-
}
235+
}

src/Snap.Hutao.Remastered.Native/FrameworkTheming.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1+
#include "pch.h"
12
#include "FrameworkTheming.h"
2-
#include "types.h"
3-
#include "Error.h"
4-
#include <Windows.h>
5-
#include <cstring>
63
#include <atomic>
74

85
// Global function pointers

src/Snap.Hutao.Remastered.Native/HookUtils.cpp

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
#pragma once
2-
1+
#include "pch.h"
32
#include "HookUtils.h"
43
#include "StringUtils.h"
5-
#include <Windows.h>
64

7-
// 使用Windows钩子注入DLL
5+
// 使用Windows钩子注入DLL
86
HRESULT InjectUsingHook(LPCWSTR dllPath, LPCWSTR functionName, DWORD threadId, int hookType)
97
{
108
if (!dllPath || !functionName) {
@@ -25,14 +23,14 @@ HRESULT InjectUsingHook(LPCWSTR dllPath, LPCWSTR functionName, DWORD threadId, i
2523
HOOKPROC hookProc = NULL;
2624

2725
if ((DWORD_PTR)ansiFunctionName <= 0xFFFF) {
28-
// 是序号
26+
// 是序号
2927
hookProc = (HOOKPROC)GetProcAddress(hHookDll, ansiFunctionName);
3028
}
3129
else {
32-
// 是字符串指针
30+
// 是字符串指针
3331
hookProc = (HOOKPROC)GetProcAddress(hHookDll, ansiFunctionName);
3432

35-
// 释放转换的字符串
33+
// 释放转换的字符串
3634
FreeConvertedString((LPVOID)ansiFunctionName);
3735
}
3836

@@ -41,12 +39,12 @@ HRESULT InjectUsingHook(LPCWSTR dllPath, LPCWSTR functionName, DWORD threadId, i
4139
return HRESULT_FROM_WIN32(ERROR_PROC_NOT_FOUND);
4240
}
4341

44-
// 设置Windows钩子
42+
// 设置Windows钩子
4543
HHOOK hHook = SetWindowsHookExW(
46-
hookType, // 钩子类型
47-
hookProc, // 钩子过程
48-
hHookDll, // 包含钩子过程的DLL
49-
threadId // 目标线程ID(0表示全局钩子)
44+
hookType, // 钩子类型
45+
hookProc, // 钩子过程
46+
hHookDll, // 包含钩子过程的DLL
47+
threadId // 目标线程ID(0表示全局钩子)
5048
);
5149

5250
if (!hHook) {
@@ -55,37 +53,37 @@ HRESULT InjectUsingHook(LPCWSTR dllPath, LPCWSTR functionName, DWORD threadId, i
5553
return HRESULT_FROM_WIN32(lastError);
5654
}
5755

58-
// 触发钩子 - 发送消息到目标线程的消息队列
56+
// 触发钩子 - 发送消息到目标线程的消息队列
5957
if (threadId != 0) {
60-
// 线程特定的钩子,发送线程消息
58+
// 线程特定的钩子,发送线程消息
6159
PostThreadMessageW(threadId, WM_NULL, 0, 0);
6260
}
6361
else {
64-
// 全局钩子,发送广播消息
62+
// 全局钩子,发送广播消息
6563
PostMessageW(HWND_BROADCAST, WM_NULL, 0, 0);
6664
}
6765

68-
// 等待一段时间确保DLL被加载
66+
// 等待一段时间确保DLL被加载
6967
Sleep(100);
7068

71-
// 卸载钩子(DLL已注入,不需要保持钩子)
69+
// 卸载钩子(DLL已注入,不需要保持钩子)
7270
UnhookWindowsHookEx(hHook);
7371

74-
// 释放当前进程中的DLL(不影响已注入到目标进程的DLL)
72+
// 释放当前进程中的DLL(不影响已注入到目标进程的DLL)
7573
FreeLibrary(hHookDll);
7674

7775
return S_OK;
7876
}
7977

80-
// 检查钩子是否可用
78+
// 检查钩子是否可用
8179
BOOL IsHookAvailable(int hookType)
8280
{
83-
// 临时钩子过程
81+
// 临时钩子过程
8482
HOOKPROC tempProc = [](int nCode, WPARAM wParam, LPARAM lParam) -> LRESULT {
8583
return CallNextHookEx(NULL, nCode, wParam, lParam);
8684
};
8785

88-
// 尝试设置一个临时钩子来检查是否可用
86+
// 尝试设置一个临时钩子来检查是否可用
8987
HHOOK hHook = SetWindowsHookExW(hookType, tempProc, NULL, 0);
9088

9189
if (hHook) {
@@ -96,7 +94,7 @@ BOOL IsHookAvailable(int hookType)
9694
return FALSE;
9795
}
9896

99-
// 获取钩子类型名称
97+
// 获取钩子类型名称
10098
LPCWSTR GetHookTypeName(int hookType)
10199
{
102100
switch (hookType) {
@@ -129,4 +127,4 @@ LPCWSTR GetHookTypeName(int hookType)
129127
default:
130128
return L"UNKNOWN";
131129
}
132-
}
130+
}

src/Snap.Hutao.Remastered.Native/HotKeyCallbackManager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "pch.h"
12
#include "HotKeyCallbackManager.h"
23
#include "HutaoNativeHotKeyBeforeSwitchCallback.h"
34

src/Snap.Hutao.Remastered.Native/HutaoNative.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "pch.h"
12
#include "HutaoNative.h"
23
#include "HutaoNativeRegistryNotification.h"
34
#include "IHutaoNativeLoopbackSupport.h"
@@ -16,12 +17,6 @@
1617
#include "HutaoNativeHotKeyAction.h"
1718
#include "HutaoNativeProcess.h"
1819
#include "HutaoNativeWindowNonRude.h"
19-
#include "types.h"
20-
#include "CustomImplements.h"
21-
#include "Error.h"
22-
#include <Windows.h>
23-
#include <hstring.h>
24-
#include <winternl.h>
2520

2621
HRESULT __stdcall HutaoNative::MakeLoopbackSupport(IHutaoNativeLoopbackSupport** ppv)
2722
{

src/Snap.Hutao.Remastered.Native/HutaoNativeDeviceCapabilities.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
#include "pch.h"
12
#include "HutaoNativeDeviceCapabilities.h"
2-
#include <Windows.h>
33

44
HRESULT __stdcall HutaoNativeDeviceCapabilities::GetPrimaryScreenVerticalRefreshRate(int* refreshRate) noexcept
55
{

src/Snap.Hutao.Remastered.Native/HutaoNativeExports.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
#include "pch.h"
12
#include "dllmain.h"
23
#include "HutaoNativeExports.h"
34
#include "WilCallbacksManager.h"
45
#include "HotKeyCallbackManager.h"
5-
#include "Types.h"
66
#include "HutaoNative.h"
77
#include "HutaoString.h"
88
#include "HutaoNativeRegistryNotification.h"
@@ -11,9 +11,6 @@
1111
#include "IHutaoNativeRegistryNotification.h"
1212
#include "IHutaoNative.h"
1313
#include "IHutaoString.h"
14-
#include "CustomImplements.h"
15-
#include "Error.h"
16-
#include <Windows.h>
1714

1815
DLL_EXPORT HRESULT __stdcall HutaoCreateInstance(
1916
IHutaoNative** ppInstance) {

src/Snap.Hutao.Remastered.Native/HutaoNativeFileSystem.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1+
#include "pch.h"
12
#include "HutaoNativeFileSystem.h"
23
#include "IHutaoString.h"
34
#include "HutaoString.h"
4-
#include "CustomImplements.h"
5-
#include "Error.h"
6-
#include <Windows.h>
75
#include <ShlObj.h>
86
#include <shellapi.h>
9-
#include <string>
10-
#include <vector>
117
#include <comdef.h>
128

139
HRESULT HutaoNativeFileSystem::PerformFileOperation(UINT operation, PCWSTR source, PCWSTR destination, long flags)

0 commit comments

Comments
 (0)