forked from mpamxl/ChromeX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchrome++.cpp
115 lines (96 loc) · 2.19 KB
/
chrome++.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include <windows.h>
#include <stdio.h>
#include <psapi.h>
HMODULE hInstance;
#define MAGIC_CODE 0x1603ABD9
#include "MinHook.h"
#include "version.h"
#include "hijack.h"
#include "utils.h"
#include "patch.h"
#include "TabBookmark.h"
#include "portable.h"
#include "PakPatch.h"
#include "appid.h"
#include "green.h"
typedef int (*Startup)();
Startup ExeMain = NULL;
void ChromePlus()
{
// 快捷方式
SetAppId();
// 便携化补丁
MakeGreen();
// 标签页,书签,地址栏增强
TabBookmark();
// 给pak文件打补丁
PakPatch();
}
void ChromePlusCommand(LPWSTR param)
{
if (!wcsstr(param, L"--Keeper"))
{
Portable(param);
}
else
{
ChromePlus();
}
}
int Loader()
{
// 硬补丁
MakePatch();
// 只关注主界面
LPWSTR param = GetCommandLineW();
// DebugLog(L"param %s", param);
if (!wcsstr(param, L"-type="))
{
ChromePlusCommand(param);
}
//返回到主程序
return ExeMain();
}
void InstallLoader()
{
//获取程序入口点
MODULEINFO mi;
GetModuleInformation(GetCurrentProcess(), GetModuleHandle(NULL), &mi, sizeof(MODULEINFO));
PBYTE entry = (PBYTE)mi.EntryPoint;
// 入口点跳转到Loader
MH_STATUS status = MH_CreateHook(entry, Loader, (LPVOID *)&ExeMain);
if (status == MH_OK)
{
MH_EnableHook(entry);
}
else
{
DebugLog(L"MH_CreateHook InstallLoader failed:%d", status);
}
}
#define EXTERNC extern "C"
//
EXTERNC __declspec(dllexport) void Keeper()
{
}
EXTERNC BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID pv)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls(hModule);
hInstance = hModule;
// 保持系统dll原有功能
LoadSysDll(hModule);
// 初始化HOOK库成功以后安装加载器
MH_STATUS status = MH_Initialize();
if (status == MH_OK)
{
InstallLoader();
}
else
{
DebugLog(L"MH_Initialize failed:%d", status);
}
}
return TRUE;
}