-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsrc.cpp
139 lines (125 loc) · 4.88 KB
/
src.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#include <windows.h>
#include <commctrl.h>
#include <winuser.h>
#include "aviutl/filter.h"
#include <iostream>
#include <string>
FILTER_DLL filter = {
FILTER_FLAG_ALWAYS_ACTIVE,
NULL,NULL,
const_cast<char*>("updown"),
NULL, NULL, NULL,
NULL, NULL,
NULL, NULL, NULL,
NULL,
func_init, func_exit, NULL,
NULL,
NULL,NULL,
NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,
NULL, NULL, NULL,
};
EXTERN_C FILTER_DLL __declspec(dllexport)* __stdcall GetFilterTable(void) {
return &filter;
}
static int exedit_base;
static WNDPROC exedit_SettingDialog_WndProc;
static char path[MAX_PATH + 1];
static UINT scale[6] = {1,1,1,1,1,1};
static const char section_default[] = "Default";
static const char section_shift[] = "Shift";
FILTER* get_exeditfp(FILTER* fp) {
SYS_INFO si;
fp->exfunc->get_sys_info(NULL, &si);
for (int i = 0; i < si.filter_n; i++) {
FILTER* tfp = (FILTER*)fp->exfunc->get_filterp(i);
if (tfp->information != NULL) {
if (!strcmp(tfp->information, "拡張編集(exedit) version 0.92 by KENくん")) return tfp;
}
}
return NULL;
}
BOOL exedit_Replace_Address(int exedit_address, const void* function) {
DWORD oldProtect;
byte* address = (byte*)(exedit_address + exedit_base);
if (!VirtualProtect(address, 4, PAGE_EXECUTE_READWRITE, &oldProtect)) {
return false;
}
*(uint32_t*)address = (uint32_t)(function);
return VirtualProtect(address, 4, oldProtect, &oldProtect);
}
void change_delta(int* data, LPNMUPDOWN& lpnmud) {
int mul = data[3];
int n = (GetKeyState(VK_SHIFT) & 0x8000) ? 3 : 0;
if (data[9] > 1) { //アニメーション効果の場合
mul /= data[9];
}
switch (mul) {
default:
// 整数の場合
lpnmud->iDelta *= scale[n];
break;
case 10:
// 0.0の場合
lpnmud->iDelta *= scale[n + 1];
break;
case 100:
// 0.00の場合
lpnmud->iDelta *= scale[n + 2];
break;
}
}
LRESULT CALLBACK exedit_SettingDialog_WndProc_wrap(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
if (message == WM_NOTIFY) {
//0x2cde0,WM_HSCROLL(0x114),SB_THUMBPOSITION(0x04)
int tracknum = *(int*)(exedit_base + 0x14d4b0);
if (tracknum == 0) return exedit_SettingDialog_WndProc(hwnd, message, wparam, lparam);
LPNMUPDOWN lpnmud = (LPNMUPDOWN)lparam;
if (lpnmud->hdr.code == UDN_DELTAPOS) {
int* hwnd1 = (int*)(exedit_base + 0x14d4e4);
int* hwnd2 = (int*)(exedit_base + 0x14df0c);
int* data1 = (int*)(exedit_base + 0x14d4c8);
int* data2 = (int*)(exedit_base + 0x14def0);
for (int i = 0; i < tracknum; i++) {
if ((HWND) * (hwnd1 + i * 10) == lpnmud->hdr.hwndFrom) {
change_delta(data1 + i * 10, lpnmud);
break;
}
else if ((HWND) * (hwnd2 + i * 10) == lpnmud->hdr.hwndFrom) {
change_delta(data2 + i * 10, lpnmud);
break;
}
}
}
}
return exedit_SettingDialog_WndProc(hwnd, message, wparam, lparam);
}
BOOL func_init(FILTER* fp) {
FILTER* exeditfp = get_exeditfp(fp);
if (exeditfp == NULL) {
MessageBoxA(fp->hwnd, "拡張編集0.92が見つかりませんでした", fp->name, MB_OK);
return TRUE;
}
exedit_base = (int)exeditfp->dll_hinst;
GetModuleFileNameA(fp->dll_hinst, path, MAX_PATH);
lstrcpyA(&path[lstrlenA(path) - 4], ".ini");
scale[0] = GetPrivateProfileIntA(section_default, "scale_0", 1, path);
scale[1] = GetPrivateProfileIntA(section_default, "scale_0.0", 1, path);
scale[2] = GetPrivateProfileIntA(section_default, "scale_0.00", 1, path);
scale[3] = GetPrivateProfileIntA(section_shift, "scale_0", 1, path);
scale[4] = GetPrivateProfileIntA(section_shift, "scale_0.0", 1, path);
scale[5] = GetPrivateProfileIntA(section_shift, "scale_0.00", 1, path);
exedit_SettingDialog_WndProc = *(WNDPROC*)(exedit_base + 0x2e804);
exedit_Replace_Address(0x2e804, exedit_SettingDialog_WndProc_wrap);
return TRUE;
}
// iniに設定を保存
BOOL func_exit(FILTER* fp) {
WritePrivateProfileStringA(section_default, "scale_0", std::to_string(scale[0]).c_str(), path);
WritePrivateProfileStringA(section_default, "scale_0.0", std::to_string(scale[1]).c_str(), path);
WritePrivateProfileStringA(section_default, "scale_0.00", std::to_string(scale[2]).c_str(), path);
WritePrivateProfileStringA(section_shift, "scale_0", std::to_string(scale[3]).c_str(), path);
WritePrivateProfileStringA(section_shift, "scale_0.0", std::to_string(scale[4]).c_str(), path);
WritePrivateProfileStringA(section_shift, "scale_0.00", std::to_string(scale[5]).c_str(), path);
return 0;
}