mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2025-01-14 16:33:54 +08:00
.
This commit is contained in:
parent
40570e9baa
commit
23a9be562e
@ -1,61 +1,88 @@
|
||||
#include"MBLMED.h"
|
||||
#include "MBLMED.h"
|
||||
|
||||
// jichi 3/19/2014: Insert both hooks
|
||||
//void InsertLuneHook()
|
||||
// void InsertLuneHook()
|
||||
bool InsertMBLHook()
|
||||
{
|
||||
enum : DWORD { fun = 0xec8b55 }; // jichi 10/20/2014: mov ebp,esp, sub esp,*
|
||||
enum : DWORD
|
||||
{
|
||||
fun = 0xec8b55
|
||||
}; // jichi 10/20/2014: mov ebp,esp, sub esp,*
|
||||
bool ret = false;
|
||||
if (DWORD c = Util::FindCallOrJmpAbs((DWORD)::ExtTextOutA, processStopAddress - processStartAddress, processStartAddress, true))
|
||||
if (DWORD addr = Util::FindCallAndEntryRel(c, processStopAddress - processStartAddress, processStartAddress, fun)) {
|
||||
if (DWORD addr = Util::FindCallAndEntryRel(c, processStopAddress - processStartAddress, processStartAddress, fun))
|
||||
{
|
||||
HookParam hp;
|
||||
hp.address = addr;
|
||||
hp.offset=stackoffset(1);
|
||||
hp.offset = stackoffset(1);
|
||||
hp.type = USING_STRING;
|
||||
ConsoleOutput("INSERT MBL-Furigana");
|
||||
ret|=NewHook(hp, "MBL-Furigana");
|
||||
ret |= NewHook(hp, "MBL-Furigana");
|
||||
}
|
||||
if (DWORD c = Util::FindCallOrJmpAbs((DWORD)::GetGlyphOutlineA, processStopAddress - processStartAddress, processStartAddress, true))
|
||||
if (DWORD addr = Util::FindCallAndEntryRel(c, processStopAddress - processStartAddress, processStartAddress, fun)) {
|
||||
if (DWORD addr = Util::FindCallAndEntryRel(c, processStopAddress - processStartAddress, processStartAddress, fun))
|
||||
{
|
||||
HookParam hp;
|
||||
hp.address = addr;
|
||||
hp.offset=stackoffset(1);
|
||||
hp.offset = stackoffset(1);
|
||||
hp.split = regoffset(esp);
|
||||
hp.type = CODEC_ANSI_BE|USING_SPLIT;
|
||||
ConsoleOutput("INSERT MBL");
|
||||
ret|=NewHook(hp, "MBL");
|
||||
hp.type = CODEC_ANSI_BE | USING_SPLIT;
|
||||
ret |= NewHook(hp, "MBL");
|
||||
}
|
||||
if (!ret)
|
||||
ConsoleOutput("MBL: failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
bool h1()
|
||||
{
|
||||
char sig[] = "\x81\x90\x82\x4f\x00\x81\x90\x82\x50\x00\x81\x90\x82\x51\x00\x81\x90\x82\x52";
|
||||
auto asc_76BAAE = MemDbg::findBytes(sig, sizeof(sig), processStartAddress, processStopAddress);
|
||||
if (!asc_76BAAE)
|
||||
return false;
|
||||
BYTE bytes[] = {XX, XX4};
|
||||
*(int *)(bytes + 1) = asc_76BAAE; // mov edx, offset asc_76BAAE
|
||||
auto push = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStopAddress);
|
||||
if (!push)
|
||||
return false;
|
||||
auto addr = findfuncstart(push);
|
||||
if (!addr)
|
||||
return false;
|
||||
HookParam hp;
|
||||
hp.address = addr;
|
||||
hp.offset = regoffset(eax);
|
||||
hp.type = USING_STRING;
|
||||
return NewHook(hp, "MED");
|
||||
}
|
||||
}
|
||||
bool InsertMEDHook()
|
||||
{
|
||||
for (DWORD i = processStartAddress; i < processStopAddress - 4; i++)
|
||||
if (*(DWORD *)i == 0x8175) //cmp *, 8175
|
||||
if (*(DWORD *)i == 0x8175) // cmp *, 8175
|
||||
for (DWORD j = i, k = i + 0x100; j < k; j++)
|
||||
if (*(BYTE *)j == 0xe8) {
|
||||
if (*(BYTE *)j == 0xe8)
|
||||
{
|
||||
DWORD t = j + 5 + *(DWORD *)(j + 1);
|
||||
if (t > processStartAddress && t < processStopAddress) {
|
||||
if (t > processStartAddress && t < processStopAddress)
|
||||
{
|
||||
HookParam hp;
|
||||
hp.address = t;
|
||||
hp.offset=regoffset(eax);
|
||||
hp.offset = regoffset(eax);
|
||||
hp.type = CODEC_ANSI_BE;
|
||||
ConsoleOutput("INSERT MED");
|
||||
return NewHook(hp, "MED");
|
||||
//RegisterEngineType(ENGINE_MED);
|
||||
// RegisterEngineType(ENGINE_MED);
|
||||
}
|
||||
}
|
||||
|
||||
//ConsoleOutput("Unknown MED engine.");
|
||||
// ConsoleOutput("Unknown MED engine.");
|
||||
ConsoleOutput("MED: failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MBLMED::attach_function() {
|
||||
bool MBLMED::attach_function()
|
||||
{
|
||||
|
||||
bool b1=Util::CheckFile(L"*.mbl") &&InsertMBLHook();
|
||||
bool b2=Util::CheckFile(L"*.med") &&InsertMEDHook();
|
||||
return b1||b2;
|
||||
bool b1 = Util::CheckFile(L"*.mbl") && InsertMBLHook();
|
||||
bool b2 = Util::CheckFile(L"*.med") && (h1() || InsertMEDHook());
|
||||
return b1 || b2;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user