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

Silkys2 engine hook #1194

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions texthook/engine/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12268,6 +12268,52 @@ bool InsertSilkysHook()
return true;
}

bool Silkys2Filter(LPVOID data, DWORD *size, HookParam *, BYTE)
{
auto text = reinterpret_cast<LPWSTR>(data);
auto len = reinterpret_cast<size_t *>(size);

WideStringCharReplacer(text, len, L"\\i", 2, L'\'');

return true;
}

bool InsertSilkys2Hook()
{
//by Blu3train
/*
* Sample games:
* https://vndb.org/r89173
*/
const BYTE bytes[] = {
0x75, 0x10, // jne doukyuusei.exe+A5F7E
0x56, // push esi
0x57, // push edi
0xE8, XX4 // call doukyuusei.exe+A6120 << hook here
};
enum { addr_offset = sizeof(bytes) - 5 };

ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR);
ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range);
if (!addr) {
ConsoleOutput("vnreng:Silkys2: pattern not found");
return false;
}

HookParam hp = {};
hp.address = addr + addr_offset;
hp.offset = pusha_edi_off -4;
hp.index = 0;
hp.filter_fun = Silkys2Filter;
hp.type = USING_UNICODE | USING_STRING | NO_CONTEXT;
ConsoleOutput("vnreng: INSERT Silkys2");
NewHook(hp, "Silkys2");
return true;
}

bool InsertSilkysHooks()
{ return InsertSilkysHook() || InsertSilkys2Hook();}

/** jichi 6/1/2014 Eushully
* Insert to the last GetTextExtentPoint32A
*
Expand Down
2 changes: 1 addition & 1 deletion texthook/engine/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ bool InsertElfHook(); // elf: Silky.exe
bool InsertScenarioPlayerHook();// sol-fa-soft: *.iar && *.sec5
bool InsertSiglusHook(); // SiglusEngine: SiglusEngine.exe
bool InsertSideBHook(); // SideB: Copyright side-B
bool InsertSilkysHook(); // SilkysPlus
bool InsertSilkysHooks(); // SilkysPlus
bool InsertSyuntadaHook(); // Syuntada: dSoh.dat
bool InsertSystem43Hook(); // System43@AliceSoft: AliceStart.ini
bool InsertSystemAoiHook(); // SystemAoi: *.vfs
Expand Down
2 changes: 1 addition & 1 deletion texthook/engine/match32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ bool DetermineEngineByFile1()
// jichi 6/9/2015: Skip Silkys Sakura
if ( // Almost the same as Silkys except mes.arc is replaced by Script.arc
Util::CheckFile(L"data.arc") && Util::CheckFile(L"effect.arc") && Util::CheckFile(L"Script.arc")) {
InsertSilkysHook();
InsertSilkysHooks();
return true;
}
if (Util::CheckFile(L"data\\pack\\*.cpz")) {
Expand Down