@@ -22,31 +22,31 @@ struct Screen
22
22
int32_t nWidescreenHudOffset;
23
23
} Screen;
24
24
25
- injector::hook_back<void *(__cdecl*)(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9)> hb_5F27E2 ;
26
- void * __cdecl sub_5F27E2 (int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9)
25
+ injector::hook_back<void *(__cdecl*)(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9)> hb_5F34C0 ;
26
+ void * __cdecl sub_5F34C0 (int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9)
27
27
{
28
28
if ((a8 == 642 && a9 == 450 ) || (a8 == 640 && a9 == 448 ) || (a8 == 641 && a9 == 58 ))
29
- return hb_5F27E2 .fun (a1, a2, a3, a4, a5, a6, a7, a8, a9);
29
+ return hb_5F34C0 .fun (a1, a2, a3, a4, a5, a6, a7, a8, a9);
30
30
31
31
a5 = static_cast <int32_t >(static_cast <float >(a5) / Screen.fHudScale );
32
32
a8 = static_cast <int32_t >(static_cast <float >(a8) / Screen.fHudScale );
33
33
a5 += static_cast <int32_t >(Screen.fHudOffsetReal / (Screen.fWidth / 640 .0f ));
34
34
35
- return hb_5F27E2 .fun (a1, a2, a3, a4, a5, a6, a7, a8, a9);
35
+ return hb_5F34C0 .fun (a1, a2, a3, a4, a5, a6, a7, a8, a9);
36
36
}
37
37
38
- injector::hook_back<void *(__cdecl*)(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9)> hb_5F28E2 ;
39
- void * __cdecl sub_5F28E2 (int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9)
38
+ injector::hook_back<void *(__cdecl*)(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9)> hb_5F35C0 ;
39
+ void * __cdecl sub_5F35C0 (int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9)
40
40
{
41
41
a5 = static_cast <int32_t >(static_cast <float >(a5) / Screen.fHudScale );
42
42
a6 = static_cast <int32_t >(static_cast <float >(a6) / Screen.fHudScale );
43
43
a5 += static_cast <int32_t >(Screen.fHudOffsetReal / (Screen.fWidth / 640 .0f ));
44
44
45
- return hb_5F28E2 .fun (a1, a2, a3, a4, a5, a6, a7, a8, a9);
45
+ return hb_5F35C0 .fun (a1, a2, a3, a4, a5, a6, a7, a8, a9);
46
46
}
47
47
48
- injector::hook_back<void *(__cdecl*)(int a1, int a2, int a3, int a4, int a5, int a6, float a7, void * a8, float a9, int a10)> hb_608BF9 ;
49
- void * __cdecl sub_608BF9 (int a1, int a2, int a3, int a4, int a5, int a6, float a7, void * a8, float a9, int a10)
48
+ injector::hook_back<void *(__cdecl*)(int a1, int a2, int a3, int a4, int a5, int a6, float a7, void * a8, float a9, int a10)> hb_60AC93 ;
49
+ void * __cdecl sub_60AC93 (int a1, int a2, int a3, int a4, int a5, int a6, float a7, void * a8, float a9, int a10)
50
50
{
51
51
if (Screen.nWidescreenHudOffset )
52
52
{
@@ -62,10 +62,10 @@ void* __cdecl sub_608BF9(int a1, int a2, int a3, int a4, int a5, int a6, float a
62
62
}
63
63
}
64
64
65
- return hb_608BF9 .fun (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
65
+ return hb_60AC93 .fun (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
66
66
}
67
67
68
- void InitSettings ()
68
+ void InitCDSettings ()
69
69
{
70
70
static std::vector<std::string> list;
71
71
GetResolutionsList (list);
@@ -117,15 +117,67 @@ void InitSettings()
117
117
}; injector::MakeInline<MatrixOptionsHook>(pattern.get_first (0 ), pattern.get_first (18 )); // 0x406B9F, 0x406BB1
118
118
}
119
119
120
+ void InitDVDSettings ()
121
+ {
122
+ static std::vector<std::string> list;
123
+ GetResolutionsList (list);
124
+
125
+ static auto dword_4270D8 = *hook::get_pattern<uint32_t *>(" 8B 0D ? ? ? ? 8D 54 24 0C 51" , 2 );
126
+ auto pattern = hook::pattern (" 8B 45 04 85 C0 74" );
127
+ struct ResListHook
128
+ {
129
+ void operator ()(injector::reg_pack& regs)
130
+ {
131
+ char iniPath[MAX_PATH];
132
+ GetModuleFileNameA (NULL , iniPath, MAX_PATH);
133
+ *strrchr (iniPath, ' \\ ' ) = ' \0 ' ;
134
+ strcat_s (iniPath, " \\ MatrixConfig.ini" );
135
+ CIniReader iniReader (iniPath);
136
+ int32_t iniResX = 0 , iniResY = 0 ;
137
+ std::tie (iniResX, iniResY) = GetDesktopRes ();
138
+ char defVal[20 ];
139
+ sprintf_s (defVal, " %dx%d" , iniResX, iniResY);
140
+ auto iniRes = iniReader.ReadString (" RENDERING" , " RESOLUTION" , defVal);
141
+ // sscanf_s(iniRes, "%dx%d", &iniResX, &iniResY);
142
+ int32_t i = 0 , mode = 0 ;
143
+ for (auto &res : list)
144
+ {
145
+ SendMessageA (*((HWND*)(regs.esi + 0x1460 )), 0x143u , 0 , (LPARAM)(res.c_str ()));
146
+
147
+ if (res == iniRes)
148
+ mode = i;
149
+
150
+ ++i;
151
+ }
152
+ SendMessageA (*((HWND*)(regs.esi + 0x1460 )), 0x14Eu , mode, 0 );
153
+ *dword_4270D8 = mode;
154
+ }
155
+ }; injector::MakeInline<ResListHook>(pattern.get_first (0 ), pattern.get_first (125 )); // 0x406055, 0x4060D2
156
+
157
+ pattern = hook::pattern (" 68 ? ? ? ? 50 68 ? ? ? ? 68 ? ? ? ? FF D6 8D 4C 24 0C 51" );
158
+ struct MatrixOptionsHook
159
+ {
160
+ void operator ()(injector::reg_pack& regs)
161
+ {
162
+ char iniPath[MAX_PATH];
163
+ GetModuleFileNameA (NULL , iniPath, MAX_PATH);
164
+ *strrchr (iniPath, ' \\ ' ) = ' \0 ' ;
165
+ strcat_s (iniPath, " \\ MatrixConfig.ini" );
166
+ CIniReader iniReader (iniPath);
167
+ iniReader.WriteString (" RENDERING" , " RESOLUTION" , (char *)list[*dword_4270D8].c_str ());
168
+ }
169
+ }; injector::MakeInline<MatrixOptionsHook>(pattern.get_first (0 ), pattern.get_first (18 )); // 0x406C0F, 0x406C21
170
+ }
171
+
120
172
void Init ()
121
173
{
122
174
CIniReader iniReader (" " );
123
175
bool bFixHud = iniReader.ReadInteger (" MAIN" , " FixHud" , 1 ) != 0 ;
124
176
Screen.fWidescreenHudOffset = iniReader.ReadFloat (" MAIN" , " WidescreenHudOffset" , 100 .0f );
125
177
126
178
auto pattern = hook::pattern (" 68 ? ? ? ? 6A 00 68 ? ? ? ? 68 ? ? ? ? FF 15 ? ? ? ? 89 85 EC FA FF FF 8B 8D" );
127
- static auto dword_93B7B0 = *hook::get_pattern<int32_t *>(" A1 ? ? ? ? 89 45 E0 8B 0D ? ? ? ? 89 4D E4 33 D2 " , 1 );
128
- static auto dword_93B7B4 = *hook::get_pattern<int32_t *>(" A1 ? ? ? ? 89 45 E0 8B 0D ? ? ? ? 89 4D E4 33 D2 " , 10 );
179
+ static auto dword_947F60 = *hook::get_pattern<int32_t *>(" 8B ? ? ? ? 00 89 55 E0 A1 ? ? ? ? 89 45 E4 33 C9 " , 2 );
180
+ static auto dword_947F64 = *hook::get_pattern<int32_t *>(" 8B ? ? ? ? 00 89 55 E0 A1 ? ? ? ? 89 45 E4 33 C9 " , 10 );
129
181
struct ResHook
130
182
{
131
183
void operator ()(injector::reg_pack& regs)
@@ -141,8 +193,8 @@ void Init()
141
193
auto iniRes = iniReader.ReadString (" RENDERING" , " RESOLUTION" , defVal);
142
194
sscanf_s (iniRes.c_str (), " %dx%d" , &Screen.nWidth , &Screen.nHeight );
143
195
144
- *dword_93B7B0 = Screen.nWidth ;
145
- *dword_93B7B4 = Screen.nHeight ;
196
+ *dword_947F60 = Screen.nWidth ;
197
+ *dword_947F64 = Screen.nHeight ;
146
198
147
199
Screen.fWidth = static_cast <float >(Screen.nWidth );
148
200
Screen.fHeight = static_cast <float >(Screen.nHeight );
@@ -164,20 +216,20 @@ void Init()
164
216
Screen.nWidescreenHudOffset = static_cast <int32_t >(Screen.fWidescreenHudOffset );
165
217
}
166
218
}
167
- }; injector::MakeInline<ResHook>(pattern.get_first (0 ), pattern.get_first (186 )); // 0x7AD916, 0x7AD9D0
219
+ }; injector::MakeInline<ResHook>(pattern.get_first (0 ), pattern.get_first (237 )); // 0x7B8AF0, 0x7B8BDD
168
220
169
221
// Aspect Ratio
170
222
pattern = hook::pattern (" D9 05 ? ? ? ? D8 35 ? ? ? ? D9 1D ? ? ? ? 5D C3" );
171
- static auto flt_972448 = *pattern.get_first <float *>(8 );
172
- static auto flt_97244C = *pattern.get_first <float *>(14 );
223
+ static auto flt_97EDA8 = *pattern.get_first <float *>(8 );
224
+ static auto flt_97EDAC = *pattern.get_first <float *>(14 );
173
225
struct ARHook
174
226
{
175
227
void operator ()(injector::reg_pack& regs)
176
228
{
177
- *flt_972448 = 1 .0f ;
178
- *flt_97244C = 1 .0f ;
229
+ *flt_97EDA8 = 1 .0f ;
230
+ *flt_97EDAC = 1 .0f ;
179
231
}
180
- }; injector::MakeInline<ARHook>(pattern.get_first (0 ), pattern.get_first (18 )); // 0x6E6024, 0x6E6024 +18
232
+ }; injector::MakeInline<ARHook>(pattern.get_first (0 ), pattern.get_first (18 )); // 0x6EAE96, 0x6EAE96 +18
181
233
182
234
// FMVs
183
235
pattern = hook::pattern (" C7 45 10 00 00 00 00 C7 45 18 80 02 00 00 8B 45 E4" );
@@ -188,26 +240,27 @@ void Init()
188
240
*(int32_t *)(regs.ebp + 0x10 ) = 0 + static_cast <int32_t >(Screen.fFMVOffset );
189
241
*(int32_t *)(regs.ebp + 0x18 ) = 640 - static_cast <int32_t >(Screen.fFMVOffset + Screen.fFMVOffset );
190
242
}
191
- }; injector::MakeInline<FMVHook>(pattern.get_first (0 ), pattern.get_first (14 )); // 0x7B3369
243
+ }; injector::MakeInline<FMVHook>(pattern.get_first (0 ), pattern.get_first (14 )); // 0x7BE620
192
244
193
245
if (bFixHud)
194
246
{
195
- pattern = hook::pattern (" 6A 02 FF 15 ? ? ? ? 83 C4 04 C7 05" ); // 0x40766C
196
- hb_5F27E2 .fun = injector::MakeJMP (*pattern.get_first <void *>(157 ), sub_5F27E2 , true ).get (); // hud
197
- pattern = hook::pattern (" E8 ? ? ? ? 83 C4 1C 83 3D ? ? ? ? 00 75 ? 8B 55 FC" ); // 0x403882
198
- hb_5F28E2 .fun = injector::MakeJMP (injector::GetBranchDestination (pattern.get_first (0 )), sub_5F28E2 , true ).get (); // text
199
- pattern = hook::pattern (" E8 ? ? ? ? 83 C4 28 8B 15 ? ? ? ? DB 42 1C" ); // 0x407013
200
- hb_608BF9 .fun = injector::MakeJMP (injector::GetBranchDestination (pattern.get_first (0 )), sub_608BF9 , true ).get ();
247
+ pattern = hook::pattern (" 6A 02 FF 15 ? ? ? ? 83 C4 04 C7 05" ); // 0x4076CB
248
+ hb_5F34C0 .fun = injector::MakeJMP (*pattern.get_first <void *>(157 ), sub_5F34C0 , true ).get (); // hud
249
+ pattern = hook::pattern (" E8 ? ? ? ? 83 C4 1C 83 3D ? ? ? ? 00 75 ? 8B 55 FC" ); // 0x403887
250
+ hb_5F35C0 .fun = injector::MakeJMP (injector::GetBranchDestination (pattern.get_first (0 )), sub_5F35C0 , true ).get (); // text
251
+ pattern = hook::pattern (" E8 ? ? ? ? 83 C4 28 8B 15 ? ? ? ? DB 42 1C" ); // 0x407068
252
+ hb_60AC93 .fun = injector::MakeJMP (injector::GetBranchDestination (pattern.get_first (0 )), sub_60AC93 , true ).get ();
201
253
}
202
254
}
203
255
204
256
CEXP void InitializeASI ()
205
257
{
206
258
std::call_once (CallbackHandler::flag, []()
207
- {
208
- CallbackHandler::RegisterCallback (Init, hook::pattern (" 55 8B EC 83 EC 34 56 6A 00 6A FF" ));
209
- CallbackHandler::RegisterCallback (InitSettings, hook::pattern (" 8B 45 04 85 C0 74 6B 8B 15" ));
210
- });
259
+ {
260
+ CallbackHandler::RegisterCallback (Init, hook::pattern (" 55 8B EC 83 EC 34 56 6A 00 6A FF" ));
261
+ CallbackHandler::RegisterCallback (InitCDSettings, hook::pattern (" 8B 45 04 85 C0 74 6B 8B 15" ));
262
+ CallbackHandler::RegisterCallback (InitDVDSettings, hook::pattern (" 8B 45 04 85 C0 74 6A A1 F8" ));
263
+ });
211
264
}
212
265
213
266
BOOL APIENTRY DllMain (HMODULE hModule, DWORD reason, LPVOID lpReserved)
0 commit comments