This commit is contained in:
恍兮惚兮 2024-11-28 11:55:41 +08:00
parent 0ea36dc0f3
commit 7b029f8a9c
30 changed files with 46 additions and 46 deletions

View File

@ -553,7 +553,7 @@ bool InsertBGIDynamicHook(LPVOID addr, DWORD frame, DWORD stack)
DWORD retaddr = s->stack[0]; // retaddr DWORD retaddr = s->stack[0]; // retaddr
*role = Engine::ScenarioRole; *role = Engine::ScenarioRole;
buffer->from_cs((LPCSTR)s->stack[textIndex_]); buffer->from((LPCSTR)s->stack[textIndex_]);
return; return;
} }
@ -619,7 +619,7 @@ bool InsertBGIDynamicHook(LPVOID addr, DWORD frame, DWORD stack)
break; break;
} }
buffer->from_cs((LPCSTR)s->stack[textIndex_]); buffer->from((LPCSTR)s->stack[textIndex_]);
} }
} }
@ -1590,7 +1590,7 @@ bool InsertBGI4Hook()
{ {
// [240726][1282405][HOOKSOFT] シークレットラブ(仮) // [240726][1282405][HOOKSOFT] シークレットラブ(仮)
// 这作case 1仅当快进时才有文本,其他的在XXXXX790上 // 这作case 1仅当快进时才有文本,其他的在XXXXX790上
buffer->from_cs((wchar_t *)stack->stack[2]); buffer->from((wchar_t *)stack->stack[2]);
} }
}; };
hp.type = CODEC_UTF16 | USING_STRING | NO_CONTEXT | EMBED_ABLE | EMBED_AFTER_OVERWRITE; hp.type = CODEC_UTF16 | USING_STRING | NO_CONTEXT | EMBED_ABLE | EMBED_AFTER_OVERWRITE;

View File

@ -158,7 +158,7 @@ namespace
//*(BYTE *)(retaddr + 3) == 0xe9 // old name //*(BYTE *)(retaddr + 3) == 0xe9 // old name
//? Engine::NameRole : // retaddr+3 is jmp //? Engine::NameRole : // retaddr+3 is jmp
// Engine::ScenarioRole; // Engine::ScenarioRole;
buffer->from_cs(trimmedText); buffer->from(trimmedText);
} }
// Alternatively, using the following pattern bytes also works: // Alternatively, using the following pattern bytes also works:

View File

@ -576,7 +576,7 @@ namespace
// 004B521B 33ED XOR EBP,EBP // 004B521B 33ED XOR EBP,EBP
*role = s->stack[5] == 0 ? Engine::NameRole : Engine::ScenarioRole; *role = s->stack[5] == 0 ? Engine::NameRole : Engine::ScenarioRole;
} }
buffer->from_cs(text); buffer->from(text);
} }
void hookAfterCaller(hook_stack *s, HookParam *hp, TextBuffer *buffer, uintptr_t *split) void hookAfterCaller(hook_stack *s, HookParam *hp, TextBuffer *buffer, uintptr_t *split)

View File

@ -19,7 +19,7 @@ namespace
// hp->type ^= EXTERN_HOOK; // hp->type ^= EXTERN_HOOK;
hp->text_fun = nullptr; hp->text_fun = nullptr;
*split = FIXED_SPLIT_VALUE; *split = FIXED_SPLIT_VALUE;
buffer->from_cs((char *)*(DWORD *)(stack->base + hp->offset)); buffer->from((char *)*(DWORD *)(stack->base + hp->offset));
} }
void embed_fun(hook_stack *s, TextBuffer buffer) void embed_fun(hook_stack *s, TextBuffer buffer)
{ {

View File

@ -234,7 +234,7 @@ namespace
auto text = arg->scenarioText; auto text = arg->scenarioText;
if (!Engine::isAddressReadable(text)) if (!Engine::isAddressReadable(text))
return; return;
buffer->from_cs(text); buffer->from(text);
return; return;
// data_ = q->dispatchTextASTD(text, role, sig); // data_ = q->dispatchTextASTD(text, role, sig);
// scenarioArg_ = arg; // scenarioArg_ = arg;
@ -245,7 +245,7 @@ namespace
{ {
*role = Engine::NameRole; *role = Engine::NameRole;
auto text = arg->nameText; auto text = arg->nameText;
buffer->from_cs(text); buffer->from(text);
return; return;
// ::memcpy(text, newData.constData(), qMin(oldData.size(), newData.size())); // ::memcpy(text, newData.constData(), qMin(oldData.size(), newData.size()));
// int left = oldData.size() - newData.size(); // int left = oldData.size() - newData.size();

View File

@ -181,7 +181,7 @@ namespace
if (!text) if (!text)
return; return;
*split = *(DWORD *)arg1; *split = *(DWORD *)arg1;
buffer->from_cs(text); buffer->from(text);
} }
struct HookArgument struct HookArgument
{ {
@ -214,7 +214,7 @@ namespace
return; return;
trimmedText = _escudeltrim(arg->text); trimmedText = _escudeltrim(arg->text);
*role = arg->role(); *role = arg->role();
buffer->from_cs(trimmedText); buffer->from(trimmedText);
} }
void embed_fun(hook_stack *s, TextBuffer buffer) void embed_fun(hook_stack *s, TextBuffer buffer)
{ {

View File

@ -175,7 +175,7 @@ static void SpecialHookExp(hook_stack *stack, HookParam *hp, TextBuffer *buffer,
lasttext = text; // mov edx,dword ptr ds:[eax] lasttext = text; // mov edx,dword ptr ds:[eax]
//*len = arg3 - 1; // the last char is the '\0', so -1, but this value is not reliable //*len = arg3 - 1; // the last char is the '\0', so -1, but this value is not reliable
buffer->from_cs((char*)text); buffer->from((char*)text);
// Registers are not used as split as all of them are floating at runtime // Registers are not used as split as all of them are floating at runtime
//*split = argof(4, esp_base); // arg4, always -8, this will merge all threads and result in repetition //*split = argof(4, esp_base); // arg4, always -8, this will merge all threads and result in repetition
*split = stack->stack[7]; // reduce repetition, but still have sub-text repeat *split = stack->stack[7]; // reduce repetition, but still have sub-text repeat

View File

@ -351,7 +351,7 @@ namespace
auto text = arg->getText(); auto text = arg->getText();
if (isBadText(text)) if (isBadText(text))
return; return;
buffer->from_cs(text); buffer->from(text);
} }
void hook2a(hook_stack *s, TextBuffer buffer) void hook2a(hook_stack *s, TextBuffer buffer)
{ {
@ -444,7 +444,7 @@ namespace
auto text = arg->getText(); auto text = arg->getText();
if (isBadText(text)) if (isBadText(text))
return; return;
buffer->from_cs(text); buffer->from(text);
} }
void hook2a(hook_stack *s, TextBuffer buffer) void hook2a(hook_stack *s, TextBuffer buffer)
{ {

View File

@ -26,7 +26,7 @@ namespace
return; return;
if (strlen((char *)Src) < Size - 4) if (strlen((char *)Src) < Size - 4)
return; return;
buffer->from_cs((char *)Src); buffer->from((char *)Src);
// ConsoleOutput(WideStringToString(StringToWideString((char*)Src,936).value()).c_str()); // ConsoleOutput(WideStringToString(StringToWideString((char*)Src,936).value()).c_str());
// std::string xx; // std::string xx;
// for(int i=0;i<*len;i++){ // for(int i=0;i<*len;i++){

View File

@ -166,7 +166,7 @@ inline DWORD MajiroNewFontSplit(const DWORD *arg) // arg is supposed to be a str
void SpecialHookMajiro(hook_stack *stack, HookParam *hp, TextBuffer *buffer, uintptr_t *split) void SpecialHookMajiro(hook_stack *stack, HookParam *hp, TextBuffer *buffer, uintptr_t *split)
{ {
DWORD arg3 = stack->stack[3]; // text DWORD arg3 = stack->stack[3]; // text
buffer->from_cs((LPCSTR)arg3); buffer->from((LPCSTR)arg3);
// IsBadReadPtr is not needed for old Majiro game. // IsBadReadPtr is not needed for old Majiro game.
// I am not sure if it is needed by new Majiro game. // I am not sure if it is needed by new Majiro game.
if (hp->user_value) { // new majiro if (hp->user_value) { // new majiro
@ -238,7 +238,7 @@ bool InsertMajiroHook3x() {
//私が好きなら「好き」って言って! //私が好きなら「好き」って言って!
hp.text_fun= [](hook_stack *stack, HookParam *hp, TextBuffer *buffer, uintptr_t *split){ hp.text_fun= [](hook_stack *stack, HookParam *hp, TextBuffer *buffer, uintptr_t *split){
auto str=(char*)stack->ecx; auto str=(char*)stack->ecx;
buffer->from_cs(str); buffer->from(str);
if((str[0]==0x81)&&(str[1]==0x79))*split=0; if((str[0]==0x81)&&(str[1]==0x79))*split=0;
else *split=1; else *split=1;

View File

@ -75,7 +75,7 @@ bool Moonstone::attach_function()
{ {
if (stack->edi != 0) if (stack->edi != 0)
return; return;
buffer->from_cs((char *)stack->edx); buffer->from((char *)stack->edx);
}; };
hp.filter_fun = [](TextBuffer *buffer, HookParam *) hp.filter_fun = [](TextBuffer *buffer, HookParam *)
{ {

View File

@ -287,7 +287,7 @@ bool InsertNeXASHookA()
else else
v9 = *(const unsigned __int8 **)(v1 + 268); v9 = *(const unsigned __int8 **)(v1 + 268);
buffer->from_cs((char *)v9); buffer->from((char *)v9);
}; };
if (NewHook(hp, "NeXAS_1")) if (NewHook(hp, "NeXAS_1"))
return true; return true;
@ -398,7 +398,7 @@ bool InsertNeXASHookW()
else else
v9 = *(const unsigned __int8 **)(v1 + off2); v9 = *(const unsigned __int8 **)(v1 + off2);
buffer->from_cs((char *)v9); buffer->from((char *)v9);
if (((nexassomeinfo *)hp->user_value)->split == 0) if (((nexassomeinfo *)hp->user_value)->split == 0)
((nexassomeinfo *)hp->user_value)->split = stack->stack[1]; ((nexassomeinfo *)hp->user_value)->split = stack->stack[1];
*split = std::abs((long long)((nexassomeinfo *)hp->user_value)->split - (long long)stack->stack[1]) < 0x10; *split = std::abs((long long)((nexassomeinfo *)hp->user_value)->split - (long long)stack->stack[1]) < 0x10;
@ -464,7 +464,7 @@ namespace
hp.text_fun = [](hook_stack *stack, HookParam *hp, TextBuffer *buffer, uintptr_t *split) hp.text_fun = [](hook_stack *stack, HookParam *hp, TextBuffer *buffer, uintptr_t *split)
{ {
auto a2 = (TextUnionA *)stack->stack[1]; // std::string* auto a2 = (TextUnionA *)stack->stack[1]; // std::string*
buffer->from_cs(a2->getText()); buffer->from(a2->getText());
}; };
hp.filter_fun = [](TextBuffer *buffer, HookParam *hp) hp.filter_fun = [](TextBuffer *buffer, HookParam *hp)
{ {

View File

@ -189,7 +189,7 @@ namespace Private {
else if (ins == 0x5f) // 0047D5A4 5F POP EDI else if (ins == 0x5f) // 0047D5A4 5F POP EDI
*role = Engine::NameRole; *role = Engine::NameRole;
buffer->from_cs(text); buffer->from(text);
} }
} // namespace Private } // namespace Private

View File

@ -5,7 +5,7 @@ namespace { // unnamed
void SpecialHookRetouch1(hook_stack *stack, HookParam *hp, TextBuffer *buffer, uintptr_t *split) void SpecialHookRetouch1(hook_stack *stack, HookParam *hp, TextBuffer *buffer, uintptr_t *split)
{ {
buffer->from_cs((char*)stack->stack[1]); buffer->from((char*)stack->stack[1]);
*split = *split =
stack->eax == 0 ? FIXED_SPLIT_VALUE * 2 : // name stack->eax == 0 ? FIXED_SPLIT_VALUE * 2 : // name
stack->ebx == 0 ? FIXED_SPLIT_VALUE * 1 : // scenario stack->ebx == 0 ? FIXED_SPLIT_VALUE * 1 : // scenario

View File

@ -336,7 +336,7 @@ namespace
// if (::strlen(text) < NameCapacity // if (::strlen(text) < NameCapacity
// && text[NameCapacity - 1] == 0 && text[NameCapacity]) // && text[NameCapacity - 1] == 0 && text[NameCapacity])
// *role = Engine::NameRole; // *role = Engine::NameRole;
b->from_cs(text); b->from(text);
} }
void dispatchText2(LPSTR text, bool paddingSpace, std::string newData) void dispatchText2(LPSTR text, bool paddingSpace, std::string newData)
{ {
@ -710,7 +710,7 @@ namespace
auto arg = (HookArgument *)argaddr; auto arg = (HookArgument *)argaddr;
if (Engine::isAddressReadable((argaddr + textOffset_)) == false) if (Engine::isAddressReadable((argaddr + textOffset_)) == false)
{ {
buffer->from_cs((LPSTR)s->stack[2]); buffer->from((LPSTR)s->stack[2]);
return; return;
} }
LPSTR textAddress = (LPSTR) * (DWORD *)(argaddr + textOffset_), LPSTR textAddress = (LPSTR) * (DWORD *)(argaddr + textOffset_),

View File

@ -1080,7 +1080,7 @@ namespace
else if (split >= 2 && split <= 0x14 && split != 3 && split != 0xb || split == 0x22) else if (split >= 2 && split <= 0x14 && split != 3 && split != 0xb || split == 0x22)
*role = Engine::ScenarioRole; *role = Engine::ScenarioRole;
} }
buffer->from_cs(arg->text); buffer->from(arg->text);
} }
void hookAfter(hook_stack *stack, HookParam *hp, TextBuffer *buffer, uintptr_t *split) void hookAfter(hook_stack *stack, HookParam *hp, TextBuffer *buffer, uintptr_t *split)
{ {

View File

@ -262,7 +262,7 @@ namespace
return; return;
*role = Engine::OtherRole; *role = Engine::OtherRole;
buffer->from_cs(text); buffer->from(text);
} }
void afterAgsSpriteCreateTextExW(hook_stack *s, TextBuffer buffer) void afterAgsSpriteCreateTextExW(hook_stack *s, TextBuffer buffer)
{ {
@ -298,7 +298,7 @@ namespace
*role = Engine::ScenarioRole; *role = Engine::ScenarioRole;
break; break;
} }
buffer->from_cs(text); buffer->from(text);
} }
void afterAgsSpriteCreateTextW(hook_stack *s, TextBuffer buffer) void afterAgsSpriteCreateTextW(hook_stack *s, TextBuffer buffer)
{ {
@ -341,7 +341,7 @@ namespace
*role = Engine::ScenarioRole; *role = Engine::ScenarioRole;
break; break;
} }
buffer->from_cs(text); buffer->from(text);
} }
} }
// jichi 7/26/2015: Backport logic in vnragent to vnrhook // jichi 7/26/2015: Backport logic in vnragent to vnrhook

View File

@ -207,7 +207,7 @@ namespace
{ {
sig = 0 sig = 0
}; // split not used }; // split not used
buffer->from_cs(text); buffer->from(text);
} }
void hookafter(hook_stack *s, TextBuffer buffer) void hookafter(hook_stack *s, TextBuffer buffer)
{ {

View File

@ -40,7 +40,7 @@ bool TeethingRing_attach_function()
case 16: case 16:
auto v4 = (char *)(*(int(__thiscall **)(void *, DWORD))(*(DWORD *)_this + 60))(_this, a2[1]); auto v4 = (char *)(*(int(__thiscall **)(void *, DWORD))(*(DWORD *)_this + 60))(_this, a2[1]);
buffer->from_cs(v4); buffer->from(v4);
} }
} }
} }
@ -96,7 +96,7 @@ bool TeethingRing_attach_function2()
v16 = (DWORD *)*v14; v16 = (DWORD *)*v14;
auto a2 = stack->ARG1; auto a2 = stack->ARG1;
*split = (DWORD)_this; *split = (DWORD)_this;
buffer->from_cs((char *)((DWORD)v16 + a2)); buffer->from((char *)((DWORD)v16 + a2));
}; };
hp.filter_fun = [](TextBuffer *buffer, HookParam *hp) hp.filter_fun = [](TextBuffer *buffer, HookParam *hp)
{ {

View File

@ -139,7 +139,7 @@ namespace
{ {
auto str = (wchar_t *)stack->ebx; auto str = (wchar_t *)stack->ebx;
*split = (wcschr(str, 0x3010) != nullptr) && (wcschr(str, 0x3011) != nullptr); *split = (wcschr(str, 0x3010) != nullptr) && (wcschr(str, 0x3011) != nullptr);
buffer->from_cs(str); buffer->from(str);
}; };
hp.offset = get_reg(regs::ebx); hp.offset = get_reg(regs::ebx);
return NewHook(hp, "tkbl"); return NewHook(hp, "tkbl");

View File

@ -26,7 +26,7 @@ bool VALKYRIA::attach_function()
auto str = buffer->strA(); auto str = buffer->strA();
if (str == "\\r" || str == "\\R") if (str == "\\r" || str == "\\R")
{ {
buffer->from_cs("\n"); buffer->from("\n");
} }
// switch ( v12 ) // switch ( v12 )
// { // {

View File

@ -131,7 +131,7 @@ static void SpecialGCHookVanillaware(hook_stack *stack, HookParam *hp, TextBuffe
if (lasttext != text && *text && !_vanillawaregarbage(text)) { if (lasttext != text && *text && !_vanillawaregarbage(text)) {
lasttext = text; lasttext = text;
*split = stack->ecx; *split = stack->ecx;
buffer->from_cs(text); buffer->from(text);
//*split = FIXED_SPLIT_VALUE; //*split = FIXED_SPLIT_VALUE;
} }
} }

View File

@ -187,7 +187,7 @@ namespace
// DOUT(retaddr); // DOUT(retaddr);
// auto sig = Engine::hashThreadSignature(role, reladdr); // auto sig = Engine::hashThreadSignature(role, reladdr);
buffer->from_cs(arg->getText()); buffer->from(arg->getText());
} }
void hookafter(hook_stack *s, TextBuffer buffer) void hookafter(hook_stack *s, TextBuffer buffer)
{ {

View File

@ -147,7 +147,7 @@ namespace
// Still extract the first text // Still extract the first text
// hp->type ^= EXTERN_HOOK; // hp->type ^= EXTERN_HOOK;
char *str = *(char **)(stack->base + hp->offset); char *str = *(char **)(stack->base + hp->offset);
buffer->from_cs(str); buffer->from(str);
*split = 0; // 8/3/2014 jichi: use return address as split *split = 0; // 8/3/2014 jichi: use return address as split
} }
else else
@ -1605,7 +1605,7 @@ namespace
if (!Engine::isAddressReadable(text) || !*text || ::strlen(text) <= 2) // do not translate single character if (!Engine::isAddressReadable(text) || !*text || ::strlen(text) <= 2) // do not translate single character
return; return;
*role = Engine::OtherRole; *role = Engine::OtherRole;
buffer->from_cs(text); buffer->from(text);
} }
} // namespace Private } // namespace Private

View File

@ -186,7 +186,7 @@ struct ItemText : public Item {
auto v471= (DWORD*)stack->eax; auto v471= (DWORD*)stack->eax;
auto v481 = *v471; auto v481 = *v471;
auto ptr=*(WCHAR**)(v481 + 28); auto ptr=*(WCHAR**)(v481 + 28);
buffer->from_cs(ptr); buffer->from(ptr);
}; };
return NewHook(hp, "godot35"); return NewHook(hp, "godot35");

View File

@ -769,7 +769,7 @@ namespace
if (!text || !*text) if (!text || !*text)
return; return;
*split = Engine::ChoiceRole; *split = Engine::ChoiceRole;
buffer->from_cs(text); buffer->from(text);
} }
void hookafter(hook_stack *s, TextBuffer buffer) void hookafter(hook_stack *s, TextBuffer buffer)
{ {
@ -969,7 +969,7 @@ namespace
if (!text || ::strlen(text) <= 2) if (!text || ::strlen(text) <= 2)
return; return;
*split = Engine::OtherRole; *split = Engine::OtherRole;
buffer->from_cs(text); buffer->from(text);
} }
void hookafter(hook_stack *s, TextBuffer buffer) void hookafter(hook_stack *s, TextBuffer buffer)
{ {

View File

@ -30,7 +30,7 @@ namespace
hp.text_fun = [](hook_stack *stack, HookParam *hp, TextBuffer *buffer, uintptr_t *split) hp.text_fun = [](hook_stack *stack, HookParam *hp, TextBuffer *buffer, uintptr_t *split)
{ {
if (stack->retaddr == (DWORD)-1){ if (stack->retaddr == (DWORD)-1){
buffer->from_cs((char *)stack->rax); buffer->from((char *)stack->rax);
} }
}; };
return NewHook(hp, "Kincaid"); return NewHook(hp, "Kincaid");

View File

@ -14,7 +14,7 @@ bool lua51::attach_function() {
hp.text_fun=[](hook_stack *stack, HookParam *hp, TextBuffer *buffer, uintptr_t *split){ hp.text_fun=[](hook_stack *stack, HookParam *hp, TextBuffer *buffer, uintptr_t *split){
auto text=(char*)stack->ARG2; auto text=(char*)stack->ARG2;
*split=all_ascii(text); *split=all_ascii(text);
buffer->from_cs(text); buffer->from(text);
}; };
return NewHook(hp,"lua51"); return NewHook(hp,"lua51");
} }

View File

@ -34,7 +34,7 @@ namespace
else else
hp->type &= ~EMBED_ABLE; hp->type &= ~EMBED_ABLE;
text = embedable + 1; text = embedable + 1;
buffer->from_cs(text); buffer->from(text);
} }
} }
std::wstring parseafter(std::wstring_view view) std::wstring parseafter(std::wstring_view view)

View File

@ -237,7 +237,7 @@ struct TextBuffer
BYTE *const buff; BYTE *const buff;
size_t size; size_t size;
template <typename CharT> template <typename CharT>
void from_cs(const CharT *c) void from(const CharT *c)
{ {
if (!c) if (!c)
return; return;
@ -250,8 +250,8 @@ struct TextBuffer
size = min(TEXT_BUFFER_SIZE, strSize(c)); size = min(TEXT_BUFFER_SIZE, strSize(c));
memcpy(buff, c.data(), size); memcpy(buff, c.data(), size);
} }
template <typename CharT> template <typename AddrT>
void from(const CharT ptr, size_t t) void from(const AddrT ptr, size_t t)
{ {
if (!ptr || !t) if (!ptr || !t)
return; return;