Skip to content

Commit

Permalink
input, ime
Browse files Browse the repository at this point in the history
  • Loading branch information
matanki-saito committed Jun 1, 2024
1 parent 1d9af95 commit 41532ab
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 6 deletions.
11 changes: 6 additions & 5 deletions Plugin64/ime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Ime {
void imeProc1V137();
void imeProc2();
void imeProc3();
void imeProc3V137();
uintptr_t imeProc1ReturnAddress1;
uintptr_t imeProc1ReturnAddress2;
uintptr_t imeProc1CallAddress;
Expand Down Expand Up @@ -338,7 +339,7 @@ namespace Ime {
// 直前の部分でjmpに使う14byteを確保することができなかった。
// そのためWM_KEYDOWNのコードをすべて移植した
// mov rcx, [rbp+0C0h+hRawInput]
BytePattern::temp_instance().find_pattern("48 8B 8D E8 ? ? ? ? 8B D6 E8 ? ? ? ? 33");
BytePattern::temp_instance().find_pattern("48 8B 8D F8 00 00 00 48 8B D6 E8 ? ? ? ? 33");
if (BytePattern::temp_instance().has_size(2, u8"SDL_windowsevents.cの修正")) {
uintptr_t address = BytePattern::temp_instance().get_first().address();

Expand All @@ -355,12 +356,12 @@ namespace Ime {
imeProc3CallAddress4 = Injector::GetBranchDestination(address + 0x50).as_int();

// call {sub_xxxxx} / SDL_SendKeyboardKey
imeProc3CallAddress5 = Injector::GetBranchDestination(address + 0x61).as_int();
imeProc3CallAddress5 = Injector::GetBranchDestination(address + 0x65).as_int();

// xor edi, edi
imeProc3ReturnAddress = address + 0x66;
imeProc3ReturnAddress = address + 0x6A;

Injector::MakeJMP(address, imeProc3, true);
Injector::MakeJMP(address, imeProc3V137, true);
}
else {
e.ime.unmatchdImeProc3Injector = true;
Expand All @@ -378,7 +379,7 @@ namespace Ime {

result |= imeProc1Injector(options);
result |= imeProc2Injector(options);
//result |= imeProc3Injector(options);
result |= imeProc3Injector(options);

return result;
}
Expand Down
48 changes: 48 additions & 0 deletions Plugin64/ime_asm.asm
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,52 @@ JMP_D:
ret;
imeProc3 ENDP

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

imeProc3V137 PROC
mov rcx,qword ptr [rbp + 0D0h + 28h];
mov rdx, rsi;
call imeProc3CallAddress1;
xor ecx, ecx;
mov edi, eax;
call imeProc3CallAddress2;
cmp byte ptr [rax + 0E2h], r14b;
jz JMP_A;
cmp byte ptr [rax + 0E6h], r14b;
jnz JMP_B;

JMP_A:
cmp edi, 3Dh;
jnz JMP_B;
lea rcx, aSdl_windows_no;
call imeProc3CallAddress3;
test rax, rax;
jz JMP_C;
cmp byte ptr [rax], 30h;
jnz JMP_E;

JMP_C:
mov rcx, qword ptr [rbx];
xor r9d, r9d;
xor r8d, r8d;
mov dl, 0Eh;
call imeProc3CallAddress4;
jmp JMP_E;

JMP_B:
test edi, edi;
jz JMP_D;

JMP_E:
cmp rsi,229; 本当にやりたかったのはここだけ
jz JMP_D;
mov edx, edi
movzx ecx, r14b;
call imeProc3CallAddress5;

JMP_D:
push imeProc3ReturnAddress;
ret;
imeProc3V137 ENDP

END
18 changes: 17 additions & 1 deletion Plugin64/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Input {
uintptr_t inputProc1CallAddress;

void inputProc2();
void inputProc2V137();
uintptr_t inputProc2ReturnAddress;
}

Expand Down Expand Up @@ -168,6 +169,21 @@ namespace Input {
e.input.unmatchdInputProc2Injector = true;
}
break;
case v1_37_0_0:
// xor ecx, ecx
BytePattern::temp_instance().find_pattern("33 C9 48 89 4C 24 20 48 C7 44 24 38 0F 00 00 00 48 89 4C 24 30");
if (BytePattern::temp_instance().has_size(3, u8"バックスペース処理の修正")) {
uintptr_t address = BytePattern::temp_instance().get(2).address();

// movzx r8d, word ptr [rdi+56h]
inputProc2ReturnAddress = address + 0x165;

Injector::MakeJMP(address, inputProc2V137, true);
}
else {
e.input.unmatchdInputProc2Injector = true;
}
break;
default:
e.input.versionInputProc2Injector = true;
}
Expand All @@ -179,7 +195,7 @@ namespace Input {
DllError result = {};

result |= inputProc1Injector(options);
//result |= inputProc2Injector(options);
result |= inputProc2Injector(options);

return result;
}
Expand Down
60 changes: 60 additions & 0 deletions Plugin64/input_asm.asm
Original file line number Diff line number Diff line change
Expand Up @@ -340,4 +340,64 @@ JMP_F:
push inputProc2ReturnAddress;
ret;
inputProc2 ENDP

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

inputProc2V137 PROC
mov inputProc2Tmp2,rsi; // カウンタとして使う
xor rsi,rsi;

xor ecx, ecx
mov [rsp+48h-28h], rcx
mov qword ptr [rsp+48h-10h], 0Fh
mov [rsp+48h-18h], rcx
cmp [rdi+80h], rcx


mov rcx, qword ptr [rdi + 40h];
cmp rcx, 10h;
lea rcx, [rdi + 30h];
jbe JMP_A;
mov rcx, [rcx];

JMP_A:
movsxd rax, dword ptr [rdi + 54h];
sub rax, 3;
js JMP_C;
mov al, byte ptr [rcx + rax];
cmp al, ESCAPE_SEQ_1;
jz JMP_B;
cmp al, ESCAPE_SEQ_2;
jz JMP_B;
cmp al, ESCAPE_SEQ_3;
jz JMP_B;
cmp al, ESCAPE_SEQ_4;
jnz JMP_C;

JMP_B:
mov rsi, 2;

JMP_C:
mov rax, qword ptr [rdi];
mov rcx, rdi;
cmp qword ptr [rdi+80h] ,0
jz JMP_D;
call qword ptr [rax+140h];
jmp JMP_E;

JMP_D:
call qword ptr [rax+138h];

JMP_E:
cmp rsi, 0;
jz JMP_F;
dec rsi;
jmp JMP_C;

JMP_F:
mov rsi,inputProc2Tmp2;

push inputProc2ReturnAddress;
ret;
inputProc2V137 ENDP
END

0 comments on commit 41532ab

Please sign in to comment.