Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/1 37 #252

Merged
merged 17 commits into from
May 18, 2024
98 changes: 65 additions & 33 deletions Plugin64/c_bitmap_font.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include "pch.h"
#include "pch.h"
#include "plugin_64.h"

namespace CBitmapFont {
extern "C" {
void cBitmapFontProc1();
void cBitmapFontProc1V137();
void cBitmapFontProc2();
void cBitmapFontProc2V137();
uintptr_t cBitmapFontProc1ReturnAddress;
uintptr_t cBitmapFontProc2ReturnAddress;
}
Expand All @@ -13,22 +15,6 @@ namespace CBitmapFont {
DllError e = {};

switch (options.version) {
case v1_36_0_0:
case v1_35_1_0:
// movzx eax, byte ptr [rdi+rax]
BytePattern::temp_instance().find_pattern("0F B6 04 07 49 8B 8C C7 20 01 00 00");
if (BytePattern::temp_instance().has_size(1, u8"�t�H���g�ǂݏo��")) {
uintptr_t address = BytePattern::temp_instance().get_first().address();

// jz xxxxxx
cBitmapFontProc1ReturnAddress = address + 0x0F;

Injector::MakeJMP(address, cBitmapFontProc1, true);
}
else {
e.cBitmapFont.unmatchdCBitmapFontProc1Injector = true;
}
break;
case v1_29_0_0:
case v1_29_1_0:
case v1_29_2_0:
Expand All @@ -50,6 +36,37 @@ namespace CBitmapFont {
case v1_33_3_0:
case v1_34_2_0:
break;
case v1_35_1_0:
case v1_36_0_0:
// movzx eax, byte ptr [rdi+rax]
BytePattern::temp_instance().find_pattern("0F B6 04 07 49 8B 8C C7 20 01 00 00");
if (BytePattern::temp_instance().has_size(1, u8"フォント読み出し")) {
uintptr_t address = BytePattern::temp_instance().get_first().address();

// jz xxxxxx
cBitmapFontProc1ReturnAddress = address + 0x0F;

Injector::MakeJMP(address, cBitmapFontProc1, true);
}
else {
e.cBitmapFont.unmatchdCBitmapFontProc1Injector = true;
}
break;
case v1_37_0_0:
// movzx eax, byte ptr [rdi+rax]
BytePattern::temp_instance().find_pattern("0F B6 04 07 49 8B 8C C6 20 01 00 00");
if (BytePattern::temp_instance().has_size(1, u8"フォント読み出し")) {
uintptr_t address = BytePattern::temp_instance().get_first().address();

// jz xxxxxx
cBitmapFontProc1ReturnAddress = address + 0x0F;

Injector::MakeJMP(address, cBitmapFontProc1V137, true);
}
else {
e.cBitmapFont.unmatchdCBitmapFontProc1Injector = true;
}
break;
default:
e.cBitmapFont.versionCBitmapFontProc1Injector = true;
}
Expand All @@ -61,22 +78,6 @@ namespace CBitmapFont {
DllError e = {};

switch (options.version) {
case v1_36_0_0:
case v1_35_1_0:
// mov r13d, edi
BytePattern::temp_instance().find_pattern("44 8B EF F3 41 0F 10 B4 24 48 08 00 00");
if (BytePattern::temp_instance().has_size(1, u8"�t�H���g�ǂݏo��")) {
uintptr_t address = BytePattern::temp_instance().get_first().address();

// jz xxxxxx
cBitmapFontProc2ReturnAddress = address + 0x19;

Injector::MakeJMP(address, cBitmapFontProc2, true);
}
else {
e.cBitmapFont.unmatchdCBitmapFontProc2Injector = true;
}
break;
case v1_29_0_0:
case v1_29_1_0:
case v1_29_2_0:
Expand All @@ -98,6 +99,37 @@ namespace CBitmapFont {
case v1_33_3_0:
case v1_34_2_0:
break;
case v1_35_1_0:
case v1_36_0_0:
// mov r13d, edi
BytePattern::temp_instance().find_pattern("44 8B EF F3 41 0F 10 B4 24 48 08 00 00");
if (BytePattern::temp_instance().has_size(1, u8"フォント読み出し")) {
uintptr_t address = BytePattern::temp_instance().get_first().address();

// jz xxxxxx
cBitmapFontProc2ReturnAddress = address + 0x19;

Injector::MakeJMP(address, cBitmapFontProc2, true);
}
else {
e.cBitmapFont.unmatchdCBitmapFontProc2Injector = true;
}
break;
case v1_37_0_0:
// movss xmm6, dword ptr [r14+848h]
BytePattern::temp_instance().find_pattern("F3 41 0F 10 B6 48 08 00 00 0F B6 04 02 4D 8B 3C C6");
if (BytePattern::temp_instance().has_size(1, u8"フォント読み出し")) {
uintptr_t address = BytePattern::temp_instance().get_first().address();

// jz xxxxxx
cBitmapFontProc2ReturnAddress = address + 0x14;

Injector::MakeJMP(address, cBitmapFontProc2V137, true);
}
else {
e.cBitmapFont.unmatchdCBitmapFontProc2Injector = true;
}
break;
default:
e.cBitmapFont.versionCBitmapFontProc2Injector = true;
}
Expand Down
105 changes: 104 additions & 1 deletion Plugin64/c_bitmap_font_asm.asm
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,58 @@ JMP_H:
ret;
cBitmapFontProc1 ENDP

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;----------------------------------------------;

cBitmapFontProc1V137 PROC
cmp byte ptr[rdi + rax], ESCAPE_SEQ_1;
jz JMP_A;
cmp byte ptr[rdi + rax], ESCAPE_SEQ_2;
jz JMP_B;
cmp byte ptr[rdi + rax], ESCAPE_SEQ_3;
jz JMP_C;
cmp byte ptr[rdi + rax], ESCAPE_SEQ_4;
jz JMP_D;

movzx eax, byte ptr [rdi + rax];
jmp JMP_H;

JMP_A:
movzx eax, word ptr[rdi + rax + 1];
jmp JMP_E;

JMP_B:
movzx eax, word ptr[rdi + rax + 1];
sub eax, SHIFT_2;
jmp JMP_E;

JMP_C:
movzx eax, word ptr[rdi + rax + 1];
add eax, SHIFT_3;
jmp JMP_E;

JMP_D:
movzx eax, word ptr[rdi + rax + 1];
add eax, SHIFT_4;

JMP_E:
movzx eax, ax;
cmp eax, NO_FONT;
ja JMP_G;
mov eax, NOT_DEF;

JMP_G:
add edi, 2;
xorps xmm6, xmm6

JMP_H:
mov rcx, qword ptr [r14 + rax * 8 + 120h];
test rcx, rcx

push cBitmapFontProc1ReturnAddress;
ret;
cBitmapFontProc1V137 ENDP

;----------------------------------------------;

cBitmapFontProc2 PROC
mov r13d, edi;
Expand Down Expand Up @@ -118,4 +169,56 @@ JMP_H:
ret;
cBitmapFontProc2 ENDP

;----------------------------------------------;

cBitmapFontProc2V137 PROC
movss xmm6, dword ptr [r14+848h]

cmp byte ptr[rdx+rax], ESCAPE_SEQ_1;
jz JMP_A;
cmp byte ptr[rdx+rax], ESCAPE_SEQ_2;
jz JMP_B;
cmp byte ptr[rdx+rax], ESCAPE_SEQ_3;
jz JMP_C;
cmp byte ptr[rdx+rax], ESCAPE_SEQ_4;
jz JMP_D;

movzx eax, byte ptr [rdx+rax];
jmp JMP_H;

JMP_A:
movzx eax, word ptr[rdx+rax + 1];
jmp JMP_E;

JMP_B:
movzx eax, word ptr[rdx+rax + 1];
sub eax, SHIFT_2;
jmp JMP_E;

JMP_C:
movzx eax, word ptr[rdx+rax + 1];
add eax, SHIFT_3;
jmp JMP_E;

JMP_D:
movzx eax, word ptr[rdx+rax + 1];
add eax, SHIFT_4;

JMP_E:
movzx eax, ax;
cmp eax, NO_FONT;
ja JMP_G;
mov eax, NOT_DEF;

JMP_G:
add edi, 2;

JMP_H:
mov r15, qword ptr [r14+rax*8];
test r15, r15

push cBitmapFontProc2ReturnAddress;
ret;
cBitmapFontProc2V137 ENDP

END
1 change: 1 addition & 0 deletions Plugin64/date.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace Date {
case v1_34_2_0:
case v1_35_1_0:
case v1_36_0_0:
case v1_37_0_0:
// d w mw w y
BytePattern::temp_instance().find_pattern("64 20 77 20 6D");
if (BytePattern::temp_instance().has_size(1, u8"右上の表記を変更")) {
Expand Down
8 changes: 4 additions & 4 deletions Plugin64/dll_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ BOOL APIENTRY DllMain(HMODULE hModule,
e |= Date::Init(options);

// IME
e |= Ime::Init(options);
//e |= Ime::Init(options);

// 入力
e |= Input::Init(options);
//e |= Input::Init(options);

// 文字列順序入れ替え
e |= Localization::Init(options);
//e |= Localization::Init(options);

// bitmapfont調整
// bitmapfont調整、スクロール量調整
e |= CBitmapFont::Init(options);

Validator::Validate(e, options);
Expand Down
57 changes: 57 additions & 0 deletions Plugin64/event_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ namespace EventDialog {
extern "C" {
void eventDialogProc1();
void eventDialogProc1V132();
void eventDialogProc1V137();
void eventDialogProc2();
void eventDialogProc2V137();
void eventDialogProc3();
void eventDialogProc3V130();
void eventDialogProc3V132();
void eventDialogProc3V137();
uintptr_t eventDialogProc1ReturnAddress;
uintptr_t eventDialogProc2ReturnAddress1;
uintptr_t eventDialogProc2ReturnAddress2;
Expand Down Expand Up @@ -68,6 +71,21 @@ namespace EventDialog {
e.eventDialog.unmatchdEventDialog1Injector = true;
}
break;
case v1_37_0_0:
// movzx eax, byte ptr [rdx+rax]
BytePattern::temp_instance().find_pattern("0F B6 04 10 4D 8B 9C C5 20 01 00 00");
if (BytePattern::temp_instance().has_size(1, u8"文字取得処理")) {
uintptr_t address = BytePattern::temp_instance().get_first().address();

// jz loc_xxxxx
eventDialogProc1ReturnAddress = address + 0x18;

Injector::MakeJMP(address, eventDialogProc1V137, true);
}
else {
e.eventDialog.unmatchdEventDialog1Injector = true;
}
break;
default:
e.eventDialog.versionEventDialog1Injector = true;
}
Expand Down Expand Up @@ -146,6 +164,30 @@ namespace EventDialog {
e.eventDialog.unmatchdEventDialog2Injector = true;
}
break;
case v1_37_0_0:
// mov rax, [rbp+1060h+arg_20]
BytePattern::temp_instance().find_pattern("48 8B 85 90 10 00 00 8B 00 03 C0");
if (BytePattern::temp_instance().has_size(1, u8"分岐処理修正戻り先アドレス2")) {
eventDialogProc2ReturnAddress2 = BytePattern::temp_instance().get_first().address();
}
else {
e.eventDialog.unmatchdEventDialog2Injector = true;
}

// cvtdq2ps xmm0, xmm0
BytePattern::temp_instance().find_pattern("0F 5B C0 F3 0F 59 C1 41 0F 2E C0 7A 53 75 51");
if (BytePattern::temp_instance().has_size(1, u8"分岐処理修正")) {
uintptr_t address = BytePattern::temp_instance().get_first().address();

// movd xmm0, [rsp+11158h+arg_8]
eventDialogProc2ReturnAddress1 = address + 0x0F;

Injector::MakeJMP(address, eventDialogProc2V137, true);
}
else {
e.eventDialog.unmatchdEventDialog2Injector = true;
}
break;
default:
e.eventDialog.versionEventDialog2Injector = true;
}
Expand Down Expand Up @@ -219,6 +261,21 @@ namespace EventDialog {
e.eventDialog.unmatchdEventDialog3Injector = true;
}
break;
case v1_37_0_0:
// inc edi
BytePattern::temp_instance().find_pattern("FF C7 44 8B 4B 10 41 3B F9 8B 8D 70 10 00 00");
if (BytePattern::temp_instance().has_size(1, u8"カウントアップ")) {
uintptr_t address = BytePattern::temp_instance().get_first().address();

// jl loc_14159AFD0
eventDialogProc3ReturnAddress = address + 0xF;

Injector::MakeJMP(address, eventDialogProc3V137, true);
}
else {
e.eventDialog.unmatchdEventDialog3Injector = true;
}
break;
default:
e.eventDialog.versionEventDialog3Injector = true;
}
Expand Down
Loading