diff --git a/cpp/LunaHook/LunaHook/engine32/BGI.cpp b/cpp/LunaHook/LunaHook/engine32/BGI.cpp index 550df862..cf586691 100644 --- a/cpp/LunaHook/LunaHook/engine32/BGI.cpp +++ b/cpp/LunaHook/LunaHook/engine32/BGI.cpp @@ -553,7 +553,7 @@ bool InsertBGIDynamicHook(LPVOID addr, DWORD frame, DWORD stack) DWORD retaddr = s->stack[0]; // retaddr *role = Engine::ScenarioRole; - buffer->from_cs((LPCSTR)s->stack[textIndex_]); + buffer->from((LPCSTR)s->stack[textIndex_]); return; } @@ -619,7 +619,7 @@ bool InsertBGIDynamicHook(LPVOID addr, DWORD frame, DWORD stack) break; } - buffer->from_cs((LPCSTR)s->stack[textIndex_]); + buffer->from((LPCSTR)s->stack[textIndex_]); } } @@ -1590,7 +1590,7 @@ bool InsertBGI4Hook() { // [240726][1282405][HOOKSOFT] シークレットラブ(仮) // 这作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; diff --git a/cpp/LunaHook/LunaHook/engine32/Circus2.cpp b/cpp/LunaHook/LunaHook/engine32/Circus2.cpp index 87990451..e8ed8f39 100644 --- a/cpp/LunaHook/LunaHook/engine32/Circus2.cpp +++ b/cpp/LunaHook/LunaHook/engine32/Circus2.cpp @@ -158,7 +158,7 @@ namespace //*(BYTE *)(retaddr + 3) == 0xe9 // old name //? Engine::NameRole : // retaddr+3 is jmp // Engine::ScenarioRole; - buffer->from_cs(trimmedText); + buffer->from(trimmedText); } // Alternatively, using the following pattern bytes also works: diff --git a/cpp/LunaHook/LunaHook/engine32/Cotopha.cpp b/cpp/LunaHook/LunaHook/engine32/Cotopha.cpp index 56933d26..a3dcf66c 100644 --- a/cpp/LunaHook/LunaHook/engine32/Cotopha.cpp +++ b/cpp/LunaHook/LunaHook/engine32/Cotopha.cpp @@ -576,7 +576,7 @@ namespace // 004B521B 33ED XOR EBP,EBP *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) diff --git a/cpp/LunaHook/LunaHook/engine32/Debonosu.cpp b/cpp/LunaHook/LunaHook/engine32/Debonosu.cpp index d1c00352..894827d8 100644 --- a/cpp/LunaHook/LunaHook/engine32/Debonosu.cpp +++ b/cpp/LunaHook/LunaHook/engine32/Debonosu.cpp @@ -19,7 +19,7 @@ namespace // hp->type ^= EXTERN_HOOK; hp->text_fun = nullptr; *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) { diff --git a/cpp/LunaHook/LunaHook/engine32/Elf.cpp b/cpp/LunaHook/LunaHook/engine32/Elf.cpp index 1228c5f3..78103492 100644 --- a/cpp/LunaHook/LunaHook/engine32/Elf.cpp +++ b/cpp/LunaHook/LunaHook/engine32/Elf.cpp @@ -234,7 +234,7 @@ namespace auto text = arg->scenarioText; if (!Engine::isAddressReadable(text)) return; - buffer->from_cs(text); + buffer->from(text); return; // data_ = q->dispatchTextASTD(text, role, sig); // scenarioArg_ = arg; @@ -245,7 +245,7 @@ namespace { *role = Engine::NameRole; auto text = arg->nameText; - buffer->from_cs(text); + buffer->from(text); return; // ::memcpy(text, newData.constData(), qMin(oldData.size(), newData.size())); // int left = oldData.size() - newData.size(); diff --git a/cpp/LunaHook/LunaHook/engine32/Escude.cpp b/cpp/LunaHook/LunaHook/engine32/Escude.cpp index 2f5c4531..f9f460f7 100644 --- a/cpp/LunaHook/LunaHook/engine32/Escude.cpp +++ b/cpp/LunaHook/LunaHook/engine32/Escude.cpp @@ -181,7 +181,7 @@ namespace if (!text) return; *split = *(DWORD *)arg1; - buffer->from_cs(text); + buffer->from(text); } struct HookArgument { @@ -214,7 +214,7 @@ namespace return; trimmedText = _escudeltrim(arg->text); *role = arg->role(); - buffer->from_cs(trimmedText); + buffer->from(trimmedText); } void embed_fun(hook_stack *s, TextBuffer buffer) { diff --git a/cpp/LunaHook/LunaHook/engine32/Exp.cpp b/cpp/LunaHook/LunaHook/engine32/Exp.cpp index 980cee09..718b1e16 100644 --- a/cpp/LunaHook/LunaHook/engine32/Exp.cpp +++ b/cpp/LunaHook/LunaHook/engine32/Exp.cpp @@ -175,7 +175,7 @@ static void SpecialHookExp(hook_stack *stack, HookParam *hp, TextBuffer *buffer, 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 - buffer->from_cs((char*)text); + buffer->from((char*)text); // 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 = stack->stack[7]; // reduce repetition, but still have sub-text repeat diff --git a/cpp/LunaHook/LunaHook/engine32/GXP.cpp b/cpp/LunaHook/LunaHook/engine32/GXP.cpp index 0e88ec95..3c3c67f9 100644 --- a/cpp/LunaHook/LunaHook/engine32/GXP.cpp +++ b/cpp/LunaHook/LunaHook/engine32/GXP.cpp @@ -351,7 +351,7 @@ namespace auto text = arg->getText(); if (isBadText(text)) return; - buffer->from_cs(text); + buffer->from(text); } void hook2a(hook_stack *s, TextBuffer buffer) { @@ -444,7 +444,7 @@ namespace auto text = arg->getText(); if (isBadText(text)) return; - buffer->from_cs(text); + buffer->from(text); } void hook2a(hook_stack *s, TextBuffer buffer) { diff --git a/cpp/LunaHook/LunaHook/engine32/IGScript.cpp b/cpp/LunaHook/LunaHook/engine32/IGScript.cpp index 1f82564d..797b0b72 100644 --- a/cpp/LunaHook/LunaHook/engine32/IGScript.cpp +++ b/cpp/LunaHook/LunaHook/engine32/IGScript.cpp @@ -26,7 +26,7 @@ namespace return; if (strlen((char *)Src) < Size - 4) return; - buffer->from_cs((char *)Src); + buffer->from((char *)Src); // ConsoleOutput(WideStringToString(StringToWideString((char*)Src,936).value()).c_str()); // std::string xx; // for(int i=0;i<*len;i++){ diff --git a/cpp/LunaHook/LunaHook/engine32/Majiro.cpp b/cpp/LunaHook/LunaHook/engine32/Majiro.cpp index 964b4d52..3201ef5b 100644 --- a/cpp/LunaHook/LunaHook/engine32/Majiro.cpp +++ b/cpp/LunaHook/LunaHook/engine32/Majiro.cpp @@ -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) { DWORD arg3 = stack->stack[3]; // text - buffer->from_cs((LPCSTR)arg3); + buffer->from((LPCSTR)arg3); // IsBadReadPtr is not needed for old Majiro game. // I am not sure if it is needed by new Majiro game. 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){ auto str=(char*)stack->ecx; - buffer->from_cs(str); + buffer->from(str); if((str[0]==0x81)&&(str[1]==0x79))*split=0; else *split=1; diff --git a/cpp/LunaHook/LunaHook/engine32/Moonstone.cpp b/cpp/LunaHook/LunaHook/engine32/Moonstone.cpp index 9ef4151f..4c3a3a1a 100644 --- a/cpp/LunaHook/LunaHook/engine32/Moonstone.cpp +++ b/cpp/LunaHook/LunaHook/engine32/Moonstone.cpp @@ -75,7 +75,7 @@ bool Moonstone::attach_function() { if (stack->edi != 0) return; - buffer->from_cs((char *)stack->edx); + buffer->from((char *)stack->edx); }; hp.filter_fun = [](TextBuffer *buffer, HookParam *) { diff --git a/cpp/LunaHook/LunaHook/engine32/NeXAS.cpp b/cpp/LunaHook/LunaHook/engine32/NeXAS.cpp index e2c59286..2eea5512 100644 --- a/cpp/LunaHook/LunaHook/engine32/NeXAS.cpp +++ b/cpp/LunaHook/LunaHook/engine32/NeXAS.cpp @@ -287,7 +287,7 @@ bool InsertNeXASHookA() else v9 = *(const unsigned __int8 **)(v1 + 268); - buffer->from_cs((char *)v9); + buffer->from((char *)v9); }; if (NewHook(hp, "NeXAS_1")) return true; @@ -398,7 +398,7 @@ bool InsertNeXASHookW() else v9 = *(const unsigned __int8 **)(v1 + off2); - buffer->from_cs((char *)v9); + buffer->from((char *)v9); if (((nexassomeinfo *)hp->user_value)->split == 0) ((nexassomeinfo *)hp->user_value)->split = stack->stack[1]; *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) { auto a2 = (TextUnionA *)stack->stack[1]; // std::string* - buffer->from_cs(a2->getText()); + buffer->from(a2->getText()); }; hp.filter_fun = [](TextBuffer *buffer, HookParam *hp) { diff --git a/cpp/LunaHook/LunaHook/engine32/Nexton.cpp b/cpp/LunaHook/LunaHook/engine32/Nexton.cpp index f76ec2db..0eaf1e97 100644 --- a/cpp/LunaHook/LunaHook/engine32/Nexton.cpp +++ b/cpp/LunaHook/LunaHook/engine32/Nexton.cpp @@ -189,7 +189,7 @@ namespace Private { else if (ins == 0x5f) // 0047D5A4 5F POP EDI *role = Engine::NameRole; - buffer->from_cs(text); + buffer->from(text); } } // namespace Private diff --git a/cpp/LunaHook/LunaHook/engine32/Retouch.cpp b/cpp/LunaHook/LunaHook/engine32/Retouch.cpp index 23a9c8bd..e13ac474 100644 --- a/cpp/LunaHook/LunaHook/engine32/Retouch.cpp +++ b/cpp/LunaHook/LunaHook/engine32/Retouch.cpp @@ -5,7 +5,7 @@ namespace { // unnamed 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 = stack->eax == 0 ? FIXED_SPLIT_VALUE * 2 : // name stack->ebx == 0 ? FIXED_SPLIT_VALUE * 1 : // scenario diff --git a/cpp/LunaHook/LunaHook/engine32/ShinaRio.cpp b/cpp/LunaHook/LunaHook/engine32/ShinaRio.cpp index 86d60147..3187addb 100644 --- a/cpp/LunaHook/LunaHook/engine32/ShinaRio.cpp +++ b/cpp/LunaHook/LunaHook/engine32/ShinaRio.cpp @@ -336,7 +336,7 @@ namespace // if (::strlen(text) < NameCapacity // && text[NameCapacity - 1] == 0 && text[NameCapacity]) // *role = Engine::NameRole; - b->from_cs(text); + b->from(text); } void dispatchText2(LPSTR text, bool paddingSpace, std::string newData) { @@ -710,7 +710,7 @@ namespace auto arg = (HookArgument *)argaddr; if (Engine::isAddressReadable((argaddr + textOffset_)) == false) { - buffer->from_cs((LPSTR)s->stack[2]); + buffer->from((LPSTR)s->stack[2]); return; } LPSTR textAddress = (LPSTR) * (DWORD *)(argaddr + textOffset_), diff --git a/cpp/LunaHook/LunaHook/engine32/System4x.cpp b/cpp/LunaHook/LunaHook/engine32/System4x.cpp index d98be948..00af93bc 100644 --- a/cpp/LunaHook/LunaHook/engine32/System4x.cpp +++ b/cpp/LunaHook/LunaHook/engine32/System4x.cpp @@ -1080,7 +1080,7 @@ namespace else if (split >= 2 && split <= 0x14 && split != 3 && split != 0xb || split == 0x22) *role = Engine::ScenarioRole; } - buffer->from_cs(arg->text); + buffer->from(arg->text); } void hookAfter(hook_stack *stack, HookParam *hp, TextBuffer *buffer, uintptr_t *split) { diff --git a/cpp/LunaHook/LunaHook/engine32/SystemAoi.cpp b/cpp/LunaHook/LunaHook/engine32/SystemAoi.cpp index 7491a166..f6153aeb 100644 --- a/cpp/LunaHook/LunaHook/engine32/SystemAoi.cpp +++ b/cpp/LunaHook/LunaHook/engine32/SystemAoi.cpp @@ -262,7 +262,7 @@ namespace return; *role = Engine::OtherRole; - buffer->from_cs(text); + buffer->from(text); } void afterAgsSpriteCreateTextExW(hook_stack *s, TextBuffer buffer) { @@ -298,7 +298,7 @@ namespace *role = Engine::ScenarioRole; break; } - buffer->from_cs(text); + buffer->from(text); } void afterAgsSpriteCreateTextW(hook_stack *s, TextBuffer buffer) { @@ -341,7 +341,7 @@ namespace *role = Engine::ScenarioRole; break; } - buffer->from_cs(text); + buffer->from(text); } } // jichi 7/26/2015: Backport logic in vnragent to vnrhook diff --git a/cpp/LunaHook/LunaHook/engine32/Taskforce2.cpp b/cpp/LunaHook/LunaHook/engine32/Taskforce2.cpp index f6b8ebfb..5a2c176e 100644 --- a/cpp/LunaHook/LunaHook/engine32/Taskforce2.cpp +++ b/cpp/LunaHook/LunaHook/engine32/Taskforce2.cpp @@ -207,7 +207,7 @@ namespace { sig = 0 }; // split not used - buffer->from_cs(text); + buffer->from(text); } void hookafter(hook_stack *s, TextBuffer buffer) { diff --git a/cpp/LunaHook/LunaHook/engine32/TeethingRing.cpp b/cpp/LunaHook/LunaHook/engine32/TeethingRing.cpp index 1237c275..2f822840 100644 --- a/cpp/LunaHook/LunaHook/engine32/TeethingRing.cpp +++ b/cpp/LunaHook/LunaHook/engine32/TeethingRing.cpp @@ -40,7 +40,7 @@ bool TeethingRing_attach_function() case 16: 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; auto a2 = stack->ARG1; *split = (DWORD)_this; - buffer->from_cs((char *)((DWORD)v16 + a2)); + buffer->from((char *)((DWORD)v16 + a2)); }; hp.filter_fun = [](TextBuffer *buffer, HookParam *hp) { diff --git a/cpp/LunaHook/LunaHook/engine32/TinkerBell.cpp b/cpp/LunaHook/LunaHook/engine32/TinkerBell.cpp index c69df81f..351de5ad 100644 --- a/cpp/LunaHook/LunaHook/engine32/TinkerBell.cpp +++ b/cpp/LunaHook/LunaHook/engine32/TinkerBell.cpp @@ -139,7 +139,7 @@ namespace { auto str = (wchar_t *)stack->ebx; *split = (wcschr(str, 0x3010) != nullptr) && (wcschr(str, 0x3011) != nullptr); - buffer->from_cs(str); + buffer->from(str); }; hp.offset = get_reg(regs::ebx); return NewHook(hp, "tkbl"); diff --git a/cpp/LunaHook/LunaHook/engine32/VALKYRIA.cpp b/cpp/LunaHook/LunaHook/engine32/VALKYRIA.cpp index 2089e7b0..d51d2d8b 100644 --- a/cpp/LunaHook/LunaHook/engine32/VALKYRIA.cpp +++ b/cpp/LunaHook/LunaHook/engine32/VALKYRIA.cpp @@ -26,7 +26,7 @@ bool VALKYRIA::attach_function() auto str = buffer->strA(); if (str == "\\r" || str == "\\R") { - buffer->from_cs("\n"); + buffer->from("\n"); } // switch ( v12 ) // { diff --git a/cpp/LunaHook/LunaHook/engine32/VanillawareGC.cpp b/cpp/LunaHook/LunaHook/engine32/VanillawareGC.cpp index 923b68a6..112889af 100644 --- a/cpp/LunaHook/LunaHook/engine32/VanillawareGC.cpp +++ b/cpp/LunaHook/LunaHook/engine32/VanillawareGC.cpp @@ -131,7 +131,7 @@ static void SpecialGCHookVanillaware(hook_stack *stack, HookParam *hp, TextBuffe if (lasttext != text && *text && !_vanillawaregarbage(text)) { lasttext = text; *split = stack->ecx; - buffer->from_cs(text); + buffer->from(text); //*split = FIXED_SPLIT_VALUE; } } diff --git a/cpp/LunaHook/LunaHook/engine32/Waffle.cpp b/cpp/LunaHook/LunaHook/engine32/Waffle.cpp index 8a883eae..55bf4a15 100644 --- a/cpp/LunaHook/LunaHook/engine32/Waffle.cpp +++ b/cpp/LunaHook/LunaHook/engine32/Waffle.cpp @@ -187,7 +187,7 @@ namespace // DOUT(retaddr); // auto sig = Engine::hashThreadSignature(role, reladdr); - buffer->from_cs(arg->getText()); + buffer->from(arg->getText()); } void hookafter(hook_stack *s, TextBuffer buffer) { diff --git a/cpp/LunaHook/LunaHook/engine32/WillPlus.cpp b/cpp/LunaHook/LunaHook/engine32/WillPlus.cpp index 013408a3..bed4d3c0 100644 --- a/cpp/LunaHook/LunaHook/engine32/WillPlus.cpp +++ b/cpp/LunaHook/LunaHook/engine32/WillPlus.cpp @@ -147,7 +147,7 @@ namespace // Still extract the first text // hp->type ^= EXTERN_HOOK; 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 } else @@ -1605,7 +1605,7 @@ namespace if (!Engine::isAddressReadable(text) || !*text || ::strlen(text) <= 2) // do not translate single character return; *role = Engine::OtherRole; - buffer->from_cs(text); + buffer->from(text); } } // namespace Private diff --git a/cpp/LunaHook/LunaHook/engine32/godot.cpp b/cpp/LunaHook/LunaHook/engine32/godot.cpp index 38dd2e19..f6b7b171 100644 --- a/cpp/LunaHook/LunaHook/engine32/godot.cpp +++ b/cpp/LunaHook/LunaHook/engine32/godot.cpp @@ -186,7 +186,7 @@ struct ItemText : public Item { auto v471= (DWORD*)stack->eax; auto v481 = *v471; auto ptr=*(WCHAR**)(v481 + 28); - buffer->from_cs(ptr); + buffer->from(ptr); }; return NewHook(hp, "godot35"); diff --git a/cpp/LunaHook/LunaHook/engine32/lucifen.cpp b/cpp/LunaHook/LunaHook/engine32/lucifen.cpp index 08ba3473..a9dfc5d2 100644 --- a/cpp/LunaHook/LunaHook/engine32/lucifen.cpp +++ b/cpp/LunaHook/LunaHook/engine32/lucifen.cpp @@ -769,7 +769,7 @@ namespace if (!text || !*text) return; *split = Engine::ChoiceRole; - buffer->from_cs(text); + buffer->from(text); } void hookafter(hook_stack *s, TextBuffer buffer) { @@ -969,7 +969,7 @@ namespace if (!text || ::strlen(text) <= 2) return; *split = Engine::OtherRole; - buffer->from_cs(text); + buffer->from(text); } void hookafter(hook_stack *s, TextBuffer buffer) { diff --git a/cpp/LunaHook/LunaHook/engine64/Kincaid.cpp b/cpp/LunaHook/LunaHook/engine64/Kincaid.cpp index de22cdf0..c798a8f1 100644 --- a/cpp/LunaHook/LunaHook/engine64/Kincaid.cpp +++ b/cpp/LunaHook/LunaHook/engine64/Kincaid.cpp @@ -30,7 +30,7 @@ namespace hp.text_fun = [](hook_stack *stack, HookParam *hp, TextBuffer *buffer, uintptr_t *split) { if (stack->retaddr == (DWORD)-1){ - buffer->from_cs((char *)stack->rax); + buffer->from((char *)stack->rax); } }; return NewHook(hp, "Kincaid"); diff --git a/cpp/LunaHook/LunaHook/engines/lua/lua51.cpp b/cpp/LunaHook/LunaHook/engines/lua/lua51.cpp index 7e085342..ada1ebf0 100644 --- a/cpp/LunaHook/LunaHook/engines/lua/lua51.cpp +++ b/cpp/LunaHook/LunaHook/engines/lua/lua51.cpp @@ -14,7 +14,7 @@ bool lua51::attach_function() { hp.text_fun=[](hook_stack *stack, HookParam *hp, TextBuffer *buffer, uintptr_t *split){ auto text=(char*)stack->ARG2; *split=all_ascii(text); - buffer->from_cs(text); + buffer->from(text); }; return NewHook(hp,"lua51"); } \ No newline at end of file diff --git a/cpp/LunaHook/LunaHook/engines/v8/v8.cpp b/cpp/LunaHook/LunaHook/engines/v8/v8.cpp index 9b1d6f93..b82aa883 100644 --- a/cpp/LunaHook/LunaHook/engines/v8/v8.cpp +++ b/cpp/LunaHook/LunaHook/engines/v8/v8.cpp @@ -34,7 +34,7 @@ namespace else hp->type &= ~EMBED_ABLE; text = embedable + 1; - buffer->from_cs(text); + buffer->from(text); } } std::wstring parseafter(std::wstring_view view) diff --git a/cpp/LunaHook/include/types.h b/cpp/LunaHook/include/types.h index 53bf4cbe..7d10db55 100644 --- a/cpp/LunaHook/include/types.h +++ b/cpp/LunaHook/include/types.h @@ -237,7 +237,7 @@ struct TextBuffer BYTE *const buff; size_t size; template - void from_cs(const CharT *c) + void from(const CharT *c) { if (!c) return; @@ -250,8 +250,8 @@ struct TextBuffer size = min(TEXT_BUFFER_SIZE, strSize(c)); memcpy(buff, c.data(), size); } - template - void from(const CharT ptr, size_t t) + template + void from(const AddrT ptr, size_t t) { if (!ptr || !t) return;