mirror of
https://github.com/HIllya51/LunaHook.git
synced 2024-12-24 20:24:13 +08:00
refactor
This commit is contained in:
parent
5e6bc37051
commit
eb123790e6
@ -1,6 +1,6 @@
|
||||
include_directories(. util engines)
|
||||
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
|
||||
set(enginessrc TYPEMOON ENTERGRAM AGES7 mono Godot Renpy 5pb lucasystem LightVN V8 pchooks Artemis KiriKiri YOX PPSSPP CMVS Suika2 )
|
||||
set(enginessrc yuzusuyu TYPEMOON ENTERGRAM AGES7 mono Godot Renpy 5pb lucasystem LightVN V8 pchooks Artemis KiriKiri YOX PPSSPP CMVS Suika2 )
|
||||
set(enginepath "engine64")
|
||||
set(collector "enginecollection64.cpp")
|
||||
else()
|
||||
|
@ -7,14 +7,14 @@
|
||||
#include"winevent.hpp"
|
||||
#include"defs.h"
|
||||
#include"stringfilters.h"
|
||||
#include"util.h"
|
||||
DynamicShiftJISCodec *dynamiccodec=new DynamicShiftJISCodec(932);
|
||||
|
||||
|
||||
void cast_back(const HookParam& hp,void*data ,size_t *len,const std::wstring& trans,bool normal){
|
||||
|
||||
if((hp.type&EMBED_CODEC_UTF16)||(hp.type&CODEC_UTF16)){//renpy
|
||||
wcscpy((wchar_t*)data,trans.c_str());
|
||||
*len=trans.size()*2;
|
||||
write_string_overwrite(data,len,trans);
|
||||
}
|
||||
else{
|
||||
std::string astr;
|
||||
@ -24,8 +24,7 @@ void cast_back(const HookParam& hp,void*data ,size_t *len,const std::wstring& tr
|
||||
else{
|
||||
astr=WideStringToString(trans,hp.codepage?hp.codepage:((hp.type&CODEC_UTF8)?CP_UTF8:embedsharedmem->codepage));
|
||||
}
|
||||
strcpy((char*)data,astr.c_str());
|
||||
*len=astr.size();
|
||||
write_string_overwrite(data,len,astr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include"5pb.h"
|
||||
#include"mages/mages.hpp"
|
||||
#include"mages/mages.h"
|
||||
/** jichi 12/2/2014 5pb
|
||||
*
|
||||
* Sample game: [140924] CROSS<EFBFBD>CHANNEL 〜FINAL COMPLETE<EFBFBD> * See: http://sakuradite.com/topic/528
|
||||
@ -530,7 +530,7 @@ bool StuffScript_attach_function() {
|
||||
bool _5pb::attach_function() {
|
||||
bool b1 = Insert5pbHook();
|
||||
bool b2 = Insert5pbHookex();
|
||||
bool b3=mages::MAGES();
|
||||
bool b3=hookmages::MAGES();
|
||||
bool sf=StuffScript_attach_function();
|
||||
return b1 || b2 || b3||sf;
|
||||
}
|
||||
@ -687,9 +687,7 @@ namespace{
|
||||
auto xx=std::wstring(text,*len/2);
|
||||
xx = std::regex_replace(xx, std::wregex(L"\\[(.*?),\\d\\]"), L"$1");
|
||||
xx = std::regex_replace(xx, std::wregex(L"\\\\x%l(.*?);(.*?);(.*?);#;"), L"$1");
|
||||
*len=xx.size()*2;
|
||||
wcscpy(text,xx.c_str());
|
||||
return true;
|
||||
return write_string_overwrite(data,size,xx);
|
||||
};
|
||||
hp.newlineseperator=L"\\n";
|
||||
return NewHook(hp, "5bp");
|
||||
|
@ -37,8 +37,7 @@ bool InsertAnim2Hook() {
|
||||
static const std::regex rx("@\\[(.*?):(.*?)\\]", std::regex_constants::icase);
|
||||
std::string result = std::string((char*)data,*len);
|
||||
result = std::regex_replace(result, rx, "$1");
|
||||
*len = (result.size());
|
||||
strcpy((char*)data, result.c_str());return true;
|
||||
return write_string_overwrite(data,len,result);
|
||||
};
|
||||
myhp.newlineseperator=L"@n";
|
||||
myhp.type = USING_STRING | NO_CONTEXT|EMBED_ABLE|EMBED_AFTER_OVERWRITE|EMBED_BEFORE_SIMPLE|EMBED_DYNA_SJIS;
|
||||
|
@ -537,9 +537,7 @@ namespace Private {
|
||||
|
||||
DWORD retaddr = s->stack[0]; // retaddr
|
||||
* role = Engine::ScenarioRole;
|
||||
strcpy((char*)data,(LPCSTR)s->stack[textIndex_]);
|
||||
*len=strlen((LPCSTR)s->stack[textIndex_]);
|
||||
return true;
|
||||
return write_string_overwrite(data,len,(LPCSTR)s->stack[textIndex_]);
|
||||
}
|
||||
|
||||
static std::string data_; // persistent storage, which makes this function not thread-safe
|
||||
@ -594,10 +592,7 @@ namespace Private {
|
||||
break;
|
||||
} break;
|
||||
}
|
||||
strcpy((char*)data,(LPCSTR)s->stack[textIndex_]);
|
||||
*len=strlen((LPCSTR)s->stack[textIndex_]);
|
||||
|
||||
return true;
|
||||
return write_string_overwrite(data,len,(LPCSTR)s->stack[textIndex_]);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1200,8 +1195,8 @@ bool InsertBGI2Hook()
|
||||
static const std::regex rx("<r.+?>(.+?)</r>", std::regex_constants::icase);
|
||||
std::string result = std::string((char*)data,*len);
|
||||
result = std::regex_replace(result, rx, "$1");
|
||||
*len = (result.size());
|
||||
strcpy((char*)data, result.c_str());return true;
|
||||
|
||||
return write_string_overwrite(data,len,result);
|
||||
} ;
|
||||
|
||||
hp.split = get_stack(8); // pseudo arg8
|
||||
|
@ -1187,10 +1187,8 @@ bool attach(const uint8_t pattern[],int patternSize,DWORD startAddress,DWORD sto
|
||||
|
||||
std::regex reg1("\\{(.*?)/(.*?)\\}");
|
||||
std::string result1 = std::regex_replace(str, reg1, "$1");
|
||||
*len = result1.size();
|
||||
strcpy(text, result1.c_str());
|
||||
return true;
|
||||
|
||||
|
||||
return write_string_overwrite(text,len,result1);
|
||||
};
|
||||
|
||||
return NewHook(hp, "EmbedCMVS");
|
||||
|
@ -574,9 +574,8 @@ static bool containsNamePunct_(const char *text)
|
||||
}
|
||||
|
||||
std::string oldData(trimmedText, trimmedSize);
|
||||
strcpy((char*)data,oldData.c_str());
|
||||
*len=oldData.size();
|
||||
return true;
|
||||
|
||||
return write_string_overwrite(data,len,oldData);
|
||||
}
|
||||
void hookafter(hook_stack*s,void* data, size_t len){
|
||||
|
||||
@ -773,8 +772,7 @@ bool attach(ULONG startAddress, ULONG stopAddress)
|
||||
|
||||
static std::regex rx(R"(\[(.+?)/.+\])");
|
||||
auto _=std::regex_replace(std::string((char*)data,*len), rx, "$1");
|
||||
strcpy((char*)data,_.c_str());*len=_.size();return true;
|
||||
|
||||
return write_string_overwrite(data,len,_);
|
||||
};
|
||||
|
||||
static ULONG p;
|
||||
|
@ -126,10 +126,8 @@ namespace Private {
|
||||
trimmedText = ltrim(text);
|
||||
if (trimmedText != text)
|
||||
newData.insert(0,std::string(text, trimmedText - text));
|
||||
auto ss=new char[newData.size()+1];
|
||||
strcpy(ss,newData.c_str());
|
||||
s->stack[2] =(ULONG)ss; // reset arg2
|
||||
|
||||
write_string_new(&s->stack[2],0,newData);
|
||||
}
|
||||
bool hookBefore(hook_stack*s,void* data, size_t* len,uintptr_t*role)
|
||||
{
|
||||
@ -149,10 +147,7 @@ namespace Private {
|
||||
//? Engine::NameRole : // retaddr+3 is jmp
|
||||
//Engine::ScenarioRole;
|
||||
|
||||
std::string oldData = trimmedText;
|
||||
strcpy((char*)data,oldData.c_str());
|
||||
*len=oldData.size();
|
||||
return true;
|
||||
return write_string_overwrite(data,len,trimmedText);
|
||||
}
|
||||
|
||||
// Alternatively, using the following pattern bytes also works:
|
||||
|
@ -10,9 +10,8 @@ bool CodeXFilter(LPVOID data, size_t *size, HookParam *)
|
||||
//|晒[さら]
|
||||
std::string result = std::string((char*)data,*len);
|
||||
result = std::regex_replace(result, std::regex("\\|(.+?)\\[(.+?)\\]"), "$1");
|
||||
*len = (result.size());
|
||||
strcpy((char*)data, result.c_str());return true;
|
||||
return true;
|
||||
|
||||
return write_string_overwrite(data,len,result);
|
||||
}
|
||||
|
||||
bool InsertCodeXHook()
|
||||
|
@ -568,9 +568,7 @@ namespace Private {
|
||||
// 004B521B 33ED XOR EBP,EBP
|
||||
*role = s->stack[5] == 0 ? Engine::NameRole : Engine::ScenarioRole;
|
||||
}
|
||||
wcscpy((LPWSTR)data,text);
|
||||
*len=wcslen(text)*2;
|
||||
return true;
|
||||
return write_string_overwrite(data,len,text);
|
||||
}
|
||||
|
||||
bool hookAfterCaller(hook_stack*s,void* data, size_t* len,uintptr_t*role)
|
||||
|
@ -56,16 +56,7 @@ bool InsertDebonosuScenarioHook()
|
||||
hp.hook_font=F_MultiByteToWideChar|F_GetTextExtentPoint32A;
|
||||
hp.type = USING_STRING|NO_CONTEXT|USING_SPLIT|FIXING_SPLIT|EMBED_ABLE|EMBED_BEFORE_SIMPLE|EMBED_DYNA_SJIS; // there is only one thread
|
||||
hp.filter_fun=[](void* data, size_t* len, HookParam* hp){
|
||||
auto text = reinterpret_cast<LPSTR>(data);
|
||||
std::string str = text;
|
||||
str = str.substr(0, *len);
|
||||
|
||||
std::regex reg1("\\{(.*?)/(.*?)\\}");
|
||||
std::string result1 = std::regex_replace(str, reg1, "$1");
|
||||
*len = result1.size();
|
||||
strcpy(text, result1.c_str());
|
||||
return true;
|
||||
|
||||
return write_string_overwrite(data,len,std::regex_replace(std::string((char*)data,*len), std::regex("\\{(.*?)/(.*?)\\}"), "$1"));
|
||||
};
|
||||
ConsoleOutput("INSERT Debonosu");
|
||||
|
||||
|
@ -212,7 +212,7 @@ namespace Private {
|
||||
auto text = arg->scenarioText;
|
||||
if (!Engine::isAddressReadable(text))
|
||||
return 0;
|
||||
strcpy((LPSTR)data,text);*len=strlen(text);return 1;
|
||||
return write_string_overwrite(data,len,text);
|
||||
// data_ = q->dispatchTextASTD(text, role, sig);
|
||||
// scenarioArg_ = arg;
|
||||
// scenarioText_ = arg->scenarioText;
|
||||
@ -220,8 +220,7 @@ namespace Private {
|
||||
} else if (arg->nameFlag == 0) {
|
||||
* role = Engine::NameRole;
|
||||
auto text = arg->nameText;
|
||||
|
||||
strcpy((LPSTR)data,text);*len=strlen(text);return 1;
|
||||
return write_string_overwrite(data,len,text);
|
||||
// ::memcpy(text, newData.constData(), qMin(oldData.size(), newData.size()));
|
||||
//int left = oldData.size() - newData.size();
|
||||
//if (left > 0)
|
||||
|
@ -215,9 +215,7 @@ bool hook_before(hook_stack*s,void* data, size_t* len,uintptr_t*role){
|
||||
return false;
|
||||
trimmedText = _escudeltrim(arg->text);
|
||||
* role = arg->role();
|
||||
strcpy((char*)data,trimmedText);
|
||||
*len=strlen(trimmedText);
|
||||
return true;
|
||||
return write_string_overwrite(data,len,trimmedText);
|
||||
}
|
||||
void hook_after(hook_stack*s,void* data, size_t len){
|
||||
static std::string data_;
|
||||
|
@ -476,10 +476,7 @@ bool attach(ULONG startAddress, ULONG stopAddress)
|
||||
hp.hook_font=F_DrawTextA|F_GetGlyphOutlineA;
|
||||
hp.filter_fun=[](void* data, size_t* len, HookParam* hp){
|
||||
|
||||
static std::regex rx("\\[.+\\|(.+?)\\]");
|
||||
auto x= std::regex_replace(std::string((LPSTR)data,*len), rx, "$1");
|
||||
strcpy((LPSTR)data,x.c_str());
|
||||
*len=x.size();return true;
|
||||
return write_string_overwrite(data,len,std::regex_replace(std::string((LPSTR)data,*len), std::regex("\\[.+\\|(.+?)\\]"), "$1"));
|
||||
};
|
||||
|
||||
return NewHook(hp,"EmbedFVP");
|
||||
|
@ -339,22 +339,7 @@ namespace Private {
|
||||
auto text = arg->getText();
|
||||
if (isBadText(text))
|
||||
return 0;
|
||||
std::wstring oldText = std::wstring(text);//,
|
||||
wcscpy((LPWSTR)data1,oldText.c_str());*len=oldText.size()*2;
|
||||
return 1;
|
||||
// newText = EngineController::instance()->dispatchTextWSTD(oldText, role, reladdr);
|
||||
// if (newText == oldText)
|
||||
// return true;
|
||||
// text_ = newText;
|
||||
|
||||
// arg_ = arg;
|
||||
// argValue_ = *arg;
|
||||
|
||||
// arg->setText(text_);
|
||||
|
||||
// //if (arg->size)
|
||||
// // hashes_.insert(Engine::hashWCharArray(arg->text, arg->size));
|
||||
// return true;
|
||||
return write_string_overwrite(data1,len,text);
|
||||
}
|
||||
void hook2a(hook_stack*s,void* data1, size_t len)
|
||||
{
|
||||
@ -447,9 +432,9 @@ namespace Private {
|
||||
auto text = arg->getText();
|
||||
if (isBadText(text))
|
||||
return 0;
|
||||
std::wstring oldText = std::wstring(text);//,
|
||||
wcscpy((LPWSTR)data1,oldText.c_str());*len=oldText.size()*2;
|
||||
return 1;}
|
||||
return write_string_overwrite(data1,len,text);
|
||||
|
||||
}
|
||||
void hook2a(hook_stack*s,void* data1, size_t len)
|
||||
{
|
||||
auto text_=new wchar_t[len/2+1];
|
||||
|
@ -211,9 +211,7 @@ namespace{
|
||||
str=stop+2;
|
||||
} // = u'<27>.encode('sjis')
|
||||
auto old=std::string(str,len);
|
||||
strcpy((char*)data,old.c_str());*len1=old.size();
|
||||
return true;
|
||||
|
||||
return write_string_overwrite(data,len1,old);
|
||||
}
|
||||
template<int offset=1>
|
||||
void hookafter(hook_stack*s,void* data, size_t len1){
|
||||
|
@ -26,12 +26,8 @@ bool Jellyfish_attach_function() {
|
||||
if(*size==2)return false;
|
||||
StringCharReplacer(reinterpret_cast<char*>(data), size, "\\n", 2, '\n');
|
||||
StringCharReplacer(reinterpret_cast<char*>(data), size, "\\N", 2, '\n');
|
||||
auto str=std::string(reinterpret_cast<char*>(data),*size);
|
||||
str = std::regex_replace(str, std::regex("\\\\[0-7a-zA-Z]"), "");
|
||||
|
||||
*size = str.size() ;
|
||||
strcpy(reinterpret_cast<char*>(data), str.c_str());
|
||||
return true;
|
||||
|
||||
return write_string_overwrite(data,size,std::regex_replace(std::string(reinterpret_cast<char*>(data),*size), std::regex("\\\\[0-7a-zA-Z]"), ""));
|
||||
};
|
||||
|
||||
return NewHook(hp, "Jellyfish");
|
||||
|
@ -1222,9 +1222,8 @@ namespace{
|
||||
}
|
||||
}
|
||||
}
|
||||
wcscpy((wchar_t*)data,innner.c_str());
|
||||
*len=innner.size()*2;
|
||||
return true;
|
||||
|
||||
return write_string_overwrite(data,len,innner);
|
||||
}
|
||||
|
||||
bool attachkr2(ULONG startAddress, ULONG stopAddress)
|
||||
@ -1300,9 +1299,8 @@ namespace Private {
|
||||
strReplace(utf8save, "#00ff0000;", "\\#FF0000");
|
||||
strReplace(utf8save, "%p-1;%f\xef\xbc\xad\xef\xbc\xb3 \xe3\x82\xb4\xe3\x82\xb7\xe3\x83\x83\xe3\x82\xaf;", ""); //"%p-1;%fMS ゴシック;"
|
||||
strReplace(utf8save, "%p;%fuser;", "");
|
||||
strcpy((char*)data,utf8save.c_str());
|
||||
*len=utf8save.size();
|
||||
return true;
|
||||
|
||||
return write_string_overwrite(data,len,utf8save);
|
||||
|
||||
}
|
||||
void after(hook_stack*s,void* data, size_t len){
|
||||
@ -1316,9 +1314,8 @@ namespace Private {
|
||||
strReplace(res, "\\#FFFFFF", "#;");
|
||||
strReplace(res, "\\#FF0000", "#00ff0000;");
|
||||
res=WideStringToString(ConvertToFullWidth((StringToWideString(res))));
|
||||
auto cs = new char[res.size() + 1];
|
||||
strcpy(cs, res.c_str());
|
||||
s->ecx = (DWORD)cs;
|
||||
|
||||
write_string_new(&s->ecx,0,res);
|
||||
|
||||
}
|
||||
bool attach(ULONG startAddress, ULONG stopAddress)
|
||||
@ -1464,7 +1461,7 @@ namespace{
|
||||
t=std::regex_replace(t,std::wregex(L"\\[ruby text=\"(.*?)\"\\]"),L"");
|
||||
t=std::regex_replace(t,std::wregex(L"\\[ch text=\"(.*?)\"\\]"),L"$1");
|
||||
if(std::any_of(t.begin(),t.end(),[](wchar_t c){return (c<=127)&&((c!=L'[')||c!=L']');}))return false;
|
||||
wcscpy((wchar_t*) data,t.c_str());*size=t.size()*2;return true;
|
||||
return write_string_overwrite(data,size,t);
|
||||
};
|
||||
hp.hook_after=[](hook_stack*s,void* data, size_t len){
|
||||
auto t=std::wstring((wchar_t*)s->stack[off/4]);
|
||||
|
@ -261,27 +261,8 @@ namespace Private {
|
||||
// They should be escaped here.
|
||||
// Escaping not implemented since I am lazy.
|
||||
}
|
||||
strcpy((char*)data,oldData.c_str());*len1=oldData.size();
|
||||
write_string_overwrite(data,len1,oldData);
|
||||
return true;
|
||||
std::string newData = oldData+"xx";
|
||||
if (newData.empty() || newData == oldData)
|
||||
return false;
|
||||
|
||||
if (containsZeros)
|
||||
strReplace(newData, zero_str, zero_bytes);
|
||||
//newData.replace(zero_str, zero_bytes);
|
||||
|
||||
int prefixSize = trimmedText - text,
|
||||
suffixSize = size - prefixSize - trimmedSize;
|
||||
if (prefixSize)
|
||||
newData.insert(0,std::string(text, prefixSize));
|
||||
if (suffixSize)
|
||||
newData.append(trimmedText + trimmedSize, suffixSize);
|
||||
|
||||
data_ = newData;
|
||||
s->eax = data_.size() + 1;
|
||||
return true;
|
||||
|
||||
}
|
||||
void hookafter(hook_stack*s,void* data, size_t len1){
|
||||
|
||||
|
@ -395,19 +395,12 @@ bool hook2(hook_stack*s,void* data1, size_t* len,uintptr_t*role)
|
||||
strReplace(save,"\\k","");
|
||||
static std::regex rx("<R(.+?)\\|.+>");
|
||||
save= std::regex_replace(save, rx, "$1");
|
||||
strcpy((char*)data1,save.c_str());*len=save.size();
|
||||
// if (!data_.empty()) {
|
||||
// s->ecx = (ULONG)data_.c_str();
|
||||
// }ConsoleOutput("3");
|
||||
write_string_overwrite(data1,len,save);
|
||||
return save.size();
|
||||
}
|
||||
void hook2a(hook_stack*s,void* data1, size_t len)
|
||||
{
|
||||
|
||||
std::string newdata = std::string((char*)data1,len);
|
||||
auto xx=new char[newdata.size()+1];
|
||||
strcpy(xx,newdata.c_str());
|
||||
s->ecx=(ULONG)xx;
|
||||
write_string_new(&s->ecx,0,std::string((char*)data1,len));
|
||||
}
|
||||
}
|
||||
bool InsertLeafHook()
|
||||
|
@ -27,8 +27,8 @@ void SpecialHookLightvnA(hook_stack*, HookParam*, uintptr_t* data, uintptr_t* sp
|
||||
_=std::string(match[2]);
|
||||
*split=2;
|
||||
}
|
||||
auto _s=new char[_.size()+1];strcpy(_s,_.c_str());
|
||||
*data=(uintptr_t)_s;*len=_.size();
|
||||
|
||||
write_string_new(data,len,_);
|
||||
}
|
||||
|
||||
void SpecialHookLightvnW(hook_stack*, HookParam*, uintptr_t* data, uintptr_t* split, size_t* len)
|
||||
@ -48,8 +48,7 @@ void SpecialHookLightvnW(hook_stack*, HookParam*, uintptr_t* data, uintptr_t* sp
|
||||
_=std::wstring(match[2]);
|
||||
*split=2;
|
||||
}
|
||||
auto _s=new wchar_t[_.size()+1];wcscpy(_s,_.c_str());
|
||||
*data=(uintptr_t)_s;*len=_.size()*2;
|
||||
write_string_new(data,len,_);
|
||||
}
|
||||
bool InsertLightvnHook()
|
||||
{
|
||||
|
@ -192,7 +192,8 @@ namespace Private {
|
||||
* role = Engine::OtherRole;
|
||||
if (*(DWORD *)retaddr == 0x5010458b)
|
||||
*role = Engine::ScenarioRole;
|
||||
strcpy((char*)data1,oldData.c_str());*len=oldData.size();
|
||||
|
||||
write_string_overwrite(data1,len,oldData);
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
@ -1192,8 +1192,7 @@ namespace Private {
|
||||
data.append(oldData);
|
||||
else {
|
||||
std::wstring oldText = std::wstring(oldTextAddress, trimmedSize);
|
||||
wcscpy((LPWSTR)data1,oldText.c_str());
|
||||
*len=oldText.size()*2;
|
||||
write_string_overwrite(data1,len,oldText);
|
||||
update=true;
|
||||
}
|
||||
}
|
||||
@ -1628,10 +1627,7 @@ namespace{
|
||||
static std::wstring _ws;
|
||||
if(_ws==str)return;
|
||||
_ws=str;
|
||||
auto _s=new wchar_t[str.size()+1];
|
||||
wcscpy(_s,str.c_str());
|
||||
*data=(DWORD)_s;
|
||||
*len=str.size()*2;
|
||||
write_string_new(data,len,str);
|
||||
*split=0;
|
||||
}
|
||||
bool malie_light(){
|
||||
|
@ -415,8 +415,9 @@ std::unordered_map<uintptr_t,int>addr_role;
|
||||
*role=addr_role[retaddr];
|
||||
if (*role == Engine::NameRole)
|
||||
strReplace(oldData,"\x81\x40", ""); // remove spaces in the middle of names
|
||||
strcpy((char*)data1,oldData.c_str());
|
||||
*len=oldData.size();return true;
|
||||
|
||||
write_string_overwrite(data1,len,oldData);
|
||||
return true;
|
||||
|
||||
}
|
||||
void hookafter(hook_stack*s,void* data1, size_t len){
|
||||
@ -666,9 +667,8 @@ bool attach(ULONG startAddress, ULONG stopAddress)
|
||||
hp.hook_font=F_GetGlyphOutlineA;
|
||||
hp.filter_fun=[](void* data, size_t* len, HookParam* hp){
|
||||
|
||||
static std::regex rx("\\{.*?\\}");
|
||||
auto _=std::regex_replace(std::string((char*)data,*len), rx, "");
|
||||
strcpy((char*)data,_.c_str());*len=_.size();return true;
|
||||
write_string_overwrite(data,len,std::regex_replace(std::string((char*)data,*len), std::regex("\\{.*?\\}"), ""));
|
||||
return true;
|
||||
|
||||
};
|
||||
count|=NewHook(hp,"EmbedMinori");
|
||||
|
@ -189,8 +189,8 @@ namespace Private {
|
||||
*role = Engine::ScenarioRole;
|
||||
else if (ins == 0x5f) // 0047D5A4 5F POP EDI
|
||||
*role = Engine::NameRole;
|
||||
strcpy((char*)data,text);
|
||||
*len1=strlen(text);
|
||||
|
||||
write_string_overwrite(data,len1,text);
|
||||
return true;
|
||||
}
|
||||
} // namespace Private
|
||||
|
@ -123,8 +123,7 @@ bool before(hook_stack*s,void* data, size_t* len,uintptr_t*role){
|
||||
if (*(WORD *)(retaddr - 8) == 0x088b) // 8b08 mov ecx,dword ptr ds:[eax]
|
||||
*role = s->stack[3] ? Engine::ScenarioRole : Engine::NameRole;
|
||||
std::string oldData(trimmedText, trimmedSize);
|
||||
strcpy((char*)data,oldData.c_str());
|
||||
*len=oldData.size();
|
||||
write_string_overwrite(data,len,oldData);
|
||||
return true;
|
||||
}
|
||||
void after(hook_stack*s,void* data, size_t len){
|
||||
@ -177,8 +176,7 @@ static bool InsertNewPal1Hook()
|
||||
hp.filter_fun=[](void* data, size_t* len, HookParam* hp){
|
||||
auto s=std::string((char*)data,*len);
|
||||
s=rubyRemove(s);
|
||||
strcpy((LPSTR)data,s.c_str());*len=s.size();
|
||||
|
||||
write_string_overwrite(data,len,s);
|
||||
return true;
|
||||
};
|
||||
hp.hook_font=F_CreateFontIndirectA|F_CreateFontA;
|
||||
@ -238,7 +236,7 @@ const BYTE bytes[] = {
|
||||
hp.filter_fun=[](void* data, size_t* len, HookParam* hp){
|
||||
auto s=std::string((char*)data,*len);
|
||||
s=rubyRemove(s);
|
||||
strcpy((LPSTR)data,s.c_str());*len=s.size();
|
||||
write_string_overwrite(data,len,s);
|
||||
return true;
|
||||
};
|
||||
return NewHook(hp, "Pal");
|
||||
|
@ -24,11 +24,7 @@ bool InsertPensilHook()
|
||||
namespace{
|
||||
bool pensilfilter(void* data, size_t* len, HookParam* hp){
|
||||
//「馬鹿な、\{軌道護符|サテラ}が封じられるとは! ハーリーの仕業か。連中の魔法科学はそこまで進んだのか!?」
|
||||
auto str=std::string(reinterpret_cast<char*>(data),*len);
|
||||
str = std::regex_replace(str, std::regex("\\\\\\{(.*?)\\|(.*?)\\}"), "$1");
|
||||
|
||||
*len = (str.size()) ;
|
||||
strcpy(reinterpret_cast<char*>(data), str.c_str());
|
||||
write_string_overwrite(data,len,std::regex_replace(std::string(reinterpret_cast<char*>(data),*len), std::regex("\\\\\\{(.*?)\\|(.*?)\\}"), "$1"));
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
@ -630,9 +630,7 @@ namespace Private {
|
||||
*/
|
||||
//auto split = s->stack[0]; // retaddr is always the same anyway
|
||||
std::string oldData(trimmedText, trimmedSize);
|
||||
|
||||
strcpy((char*)data1,oldData.c_str());
|
||||
*len=oldData.size();
|
||||
write_string_overwrite(data1,len,oldData);
|
||||
return true;
|
||||
}
|
||||
void hookafter(hook_stack*s,void* data1, size_t len)
|
||||
@ -916,11 +914,7 @@ bool attach(ULONG startAddress, ULONG stopAddress)
|
||||
hp.type=EMBED_ABLE|EMBED_DYNA_SJIS|USING_STRING;
|
||||
hp.hook_font=F_ExtTextOutA|F_GetTextExtentPoint32A;
|
||||
hp.filter_fun=[](void* data, size_t* len, HookParam* hp){
|
||||
|
||||
static std::regex rx("\\[rb,(.*?),.+\\]");
|
||||
auto _=std::regex_replace(std::string((char*)data,*len), rx, "$1");
|
||||
|
||||
strcpy((char*)data,_.c_str());*len=_.size();
|
||||
write_string_overwrite(data,len,std::regex_replace(std::string((char*)data,*len), std::regex("\\[rb,(.*?),.+\\]"), "$1"));
|
||||
return true;
|
||||
};
|
||||
return NewHook(hp,"EmbedQLIE");
|
||||
|
@ -657,8 +657,7 @@ namespace Private {
|
||||
//ULONG split = arg->unknown2[0]; // always 2
|
||||
//ULONG split = s->stack[0]; // return address
|
||||
std::wstring newText;
|
||||
std::wstring old=trimmedText;
|
||||
wcscpy((LPWSTR)data1,old.c_str());*len1=old.size()*2;
|
||||
write_string_overwrite(data1,len1,trimmedText);
|
||||
return 1;
|
||||
|
||||
if (newText != trimmedText) {
|
||||
@ -766,8 +765,7 @@ namespace Private {
|
||||
if (arg->isValid()) {
|
||||
auto oldText =StringToWideString(std::string(arg->text),CP_UTF8).value();
|
||||
auto split = s->stack[0]; // return address
|
||||
std::wstring old=oldText;
|
||||
wcscpy((LPWSTR)data1,old.c_str());*len1=old.size()*2;
|
||||
write_string_overwrite(data1,len1,oldText);
|
||||
return 1;
|
||||
// std::wstring newText = EngineController::instance()->dispatchTextWSTD(oldText, role, sig);
|
||||
// if (newText != oldText) {
|
||||
@ -919,7 +917,7 @@ namespace Private {
|
||||
if (text && *text) {
|
||||
std::wstring oldText(text);
|
||||
if (oldText.size() > 1) {
|
||||
wcscpy((LPWSTR)data1,oldText.c_str());*len1=oldText.size()*2;
|
||||
write_string_overwrite(data1,len1,oldText);
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
@ -177,9 +177,7 @@ bool InsertShinaHook(int ver )
|
||||
{
|
||||
StringFilter(reinterpret_cast<LPSTR>(data), reinterpret_cast<size_t *>(size), "_r",2);
|
||||
|
||||
static std::regex rx("_t!.*?[/>]");
|
||||
auto _=std::regex_replace(std::string((char*)data,*size), rx, "");
|
||||
strcpy((char*)data,_.c_str());*size=_.size();
|
||||
write_string_overwrite(data,size,std::regex_replace(std::string((char*)data,*size), std::regex("_t!.*?[/>]"), ""));
|
||||
return true;
|
||||
};
|
||||
ConsoleOutput("triggered: adding dynamic reader");
|
||||
@ -324,10 +322,7 @@ namespace Private {
|
||||
// && text[NameCapacity - 1] == 0 && text[NameCapacity])
|
||||
// *role = Engine::NameRole;
|
||||
|
||||
std::string oldData = text;
|
||||
strcpy((char*)data,oldData.c_str());
|
||||
*len=oldData.size();
|
||||
|
||||
write_string_overwrite(data,len,text);
|
||||
|
||||
}
|
||||
void dispatchText2(LPSTR text, bool paddingSpace,std::string newData)
|
||||
@ -404,8 +399,7 @@ namespace Private {
|
||||
|
||||
|
||||
}
|
||||
strcpy((char*)data,save.c_str());
|
||||
*len=save.size();
|
||||
write_string_overwrite(data,len,save);
|
||||
}
|
||||
|
||||
//void dispatch(LPSTR text)
|
||||
@ -673,9 +667,7 @@ namespace Private {
|
||||
*role=argaddr;
|
||||
auto arg = (HookArgument *)argaddr;
|
||||
if(Engine::isAddressReadable((argaddr + textOffset_))==false){
|
||||
auto _=(LPSTR)s->stack[2];
|
||||
strcpy((char*)data,_);
|
||||
*len=strlen(_);
|
||||
write_string_overwrite(data,len,(LPSTR)s->stack[2]);
|
||||
return true;
|
||||
}
|
||||
LPSTR textAddress = (LPSTR)*(DWORD *)(argaddr + textOffset_),
|
||||
@ -930,11 +922,9 @@ bool attach(int ver)
|
||||
hp.newlineseperator=L"_r";
|
||||
hp.hook_font=F_GetGlyphOutlineA;
|
||||
hp.filter_fun=[](void* data, size_t* len, HookParam* hp){
|
||||
|
||||
static std::regex rx("_t!.*?[/>]");
|
||||
auto _=std::regex_replace(std::string((char*)data,*len), rx, "");
|
||||
strcpy((char*)data,_.c_str());*len=_.size();return true;
|
||||
};
|
||||
write_string_overwrite(data,len,std::regex_replace(std::string((char*)data,*len), std::regex("_t!.*?[/>]"), ""));
|
||||
return true;
|
||||
};
|
||||
return NewHook(hp,"EmbedShario");
|
||||
}
|
||||
|
||||
|
@ -1739,8 +1739,7 @@ bool text_fun(hook_stack*s,void* data, size_t* len,uintptr_t*role){
|
||||
if (!arg || !arg->isValid())
|
||||
return false;
|
||||
|
||||
wcscpy((wchar_t*)data,arg->getText());
|
||||
*len=arg->size *2;
|
||||
write_string_overwrite(data,len,std::wstring(arg->getText(),arg->size));
|
||||
return true;
|
||||
}
|
||||
void hookafter(hook_stack*s,void* data, size_t len){
|
||||
@ -1805,8 +1804,7 @@ namespace Private {
|
||||
//auto sig = Engine::hashThreadSignature(role, split);
|
||||
|
||||
std::wstring oldText = std::wstring(text, arg->size);//,
|
||||
wcscpy((wchar_t*)data,oldText.c_str());
|
||||
*len=oldText.size()*2;
|
||||
write_string_overwrite(data,len,oldText);
|
||||
return true;
|
||||
// newText = EngineController::instance()->dispatchTextWSTD(oldText, role, sig);
|
||||
|
||||
|
@ -253,7 +253,7 @@ static void SpecialHookSilkys(hook_stack* stack, HookParam *, uintptr_t *data,
|
||||
Engine::ScenarioRole;
|
||||
|
||||
std::string oldData(arg->getText(), arg->size);
|
||||
strcpy((char*)data1,oldData.c_str());*len=oldData.size();return 1;
|
||||
return write_string_overwrite(data1,len,oldData);
|
||||
}
|
||||
TextUnionA *arg_,
|
||||
argValue_;
|
||||
|
@ -1086,23 +1086,7 @@ namespace Private {
|
||||
else if (split >= 2 && split <= 0x14 && split != 3 && split != 0xb || split == 0x22)
|
||||
*role = Engine::ScenarioRole;
|
||||
}
|
||||
std::string oldData = arg->text;
|
||||
std::string newData = oldData+"XX";
|
||||
strcpy((char*)data,oldData.c_str());*len1=oldData.size();
|
||||
return true;
|
||||
if (*role == Engine::NameRole || oldData == newData) // do not translate name
|
||||
return false;
|
||||
|
||||
data_ = newData;
|
||||
|
||||
arg_ = arg;
|
||||
argValue_ = *arg;
|
||||
|
||||
arg->text = data_.c_str();
|
||||
arg->size = data_.size() + 1;
|
||||
arg->capacity = arg->size;
|
||||
|
||||
hashes_.insert(hashCharArray(arg->text));
|
||||
write_string_overwrite(data,len1,arg->text);
|
||||
return true;
|
||||
}
|
||||
bool hookAfter(hook_stack*s,void* data, size_t* len1,uintptr_t*role)
|
||||
@ -1587,20 +1571,7 @@ public:
|
||||
return false;
|
||||
|
||||
*role = Engine::ScenarioRole ;
|
||||
strcpy((char*)data,text);*len=strlen(text);
|
||||
/*
|
||||
auto sig = Engine::hashThreadSignature(role, split);
|
||||
//int size = arg->size; // size not used as not needed
|
||||
buffer_ = EngineController::instance()->dispatchTextASTD(text, role, sig);
|
||||
|
||||
if (editable_) {
|
||||
arg_ = arg;
|
||||
text_ = arg->text;
|
||||
size_ = arg->size;
|
||||
arg->text = buffer_.c_str(); // reset arg3
|
||||
arg->size = buffer_.size() + 1; // +1 for the nullptr
|
||||
}*/
|
||||
return true;
|
||||
return write_string_overwrite(data,len,text);
|
||||
}
|
||||
|
||||
bool hookAfter(hook_stack*s,void* data, size_t* len,uintptr_t*role)
|
||||
@ -1638,19 +1609,7 @@ public:
|
||||
LPCSTR text = arg->text;
|
||||
if (arg->size <= 1 || !text || !*text || all_ascii(text))
|
||||
return false;
|
||||
strcpy((char*)data,text);*len=strlen(text);
|
||||
/* enum { role = Engine::OtherRole };
|
||||
auto sig = Engine::hashThreadSignature(role, split2);
|
||||
buffer_ = g->dispatchTextASTD(text, role, sig);
|
||||
|
||||
if (editable_) {
|
||||
arg_ = arg;
|
||||
text_ = arg->text;
|
||||
size_ = arg->size;
|
||||
arg->text = buffer_.c_str(); // reset arg3
|
||||
arg->size = buffer_.size() + 1; // +1 for the nullptr
|
||||
}*/
|
||||
return true;
|
||||
return write_string_overwrite(data,len,text);
|
||||
}
|
||||
|
||||
bool hookAfter(hook_stack*s,void* data, size_t* len,uintptr_t*role)
|
||||
@ -1693,11 +1652,7 @@ bool fixedTextHook(hook_stack*s,void* data, size_t* len,uintptr_t*role)
|
||||
*role = Engine::OtherRole;
|
||||
|
||||
}
|
||||
strcpy((char*)data,text);*len=strlen(text);
|
||||
/*std::string buffer_ = EngineController::instance()->dispatchTextASTD(text, role, sig);
|
||||
::strncpy(text, buffer_.c_str(), FixedSize - 1);
|
||||
text[FixedSize - 1] = 0;*/
|
||||
return true;
|
||||
return write_string_overwrite(data,len,text);
|
||||
}
|
||||
|
||||
} // unnamed namespace
|
||||
|
@ -246,7 +246,8 @@ namespace{
|
||||
return false;
|
||||
|
||||
*role = Engine::OtherRole ;
|
||||
wcscpy((wchar_t*)data,text);*len=wcslen(text)*2;
|
||||
|
||||
write_string_overwrite(data,len,text);
|
||||
return true;
|
||||
}
|
||||
void afterAgsSpriteCreateTextExW(hook_stack*s,void* data1, size_t len)
|
||||
@ -282,7 +283,7 @@ namespace{
|
||||
*role = Engine::ScenarioRole;
|
||||
break;
|
||||
}
|
||||
wcscpy((wchar_t*)data,text);*len=wcslen(text)*2;
|
||||
write_string_overwrite(data,len,text);
|
||||
return true;
|
||||
}
|
||||
void afterAgsSpriteCreateTextW(hook_stack*s,void* data1, size_t len)
|
||||
@ -325,8 +326,7 @@ namespace{
|
||||
*role = Engine::ScenarioRole;
|
||||
break;
|
||||
}
|
||||
strcpy((char*)data,text);*len=strlen(text);
|
||||
return true;
|
||||
return write_string_overwrite(data,len,text);
|
||||
}
|
||||
}
|
||||
// jichi 7/26/2015: Backport logic in vnragent to vnrhook
|
||||
|
@ -305,9 +305,8 @@ namespace{
|
||||
|
||||
s = std::regex_replace(s, std::regex("(.*)\x81u([\\s\\S]*?)\x81v(.*)"), "\x81u$2\x81v"); //「 」
|
||||
s = std::regex_replace(s, std::regex("(.*)\x81i([\\s\\S]*?)\x81j(.*)"), "\x81i$2\x81j"); //( )
|
||||
*size = s.size();
|
||||
strcpy((char*)data, s.c_str());
|
||||
return true;
|
||||
|
||||
return write_string_overwrite(data,size,s);
|
||||
}
|
||||
bool Tamamogetname(LPVOID data, size_t *size, HookParam *)
|
||||
{
|
||||
@ -320,9 +319,7 @@ namespace{
|
||||
else if (s.find("\x81i")!=s.npos && s.find("\x81j")!=s.npos)
|
||||
s = std::regex_replace(s, std::regex("(.*)\x81i([\\s\\S]*?)\x81j(.*)"), "$1"); //( )
|
||||
else return false;
|
||||
*size = s.size();
|
||||
strcpy((char*)data, s.c_str());
|
||||
return true;
|
||||
return write_string_overwrite(data,size,s);
|
||||
}
|
||||
bool tamamo3(){
|
||||
//閃光の騎士 ~カリスティアナイト~
|
||||
|
@ -198,10 +198,8 @@ namespace Private {
|
||||
//auto split = s->edx;
|
||||
//auto sig = Engine::hashThreadSignature(role, split);
|
||||
enum { sig = 0 }; // split not used
|
||||
strcpy((char*)data1,text);
|
||||
*len=strlen(text);return true;
|
||||
|
||||
return true;
|
||||
|
||||
return write_string_overwrite(data1,len,text);
|
||||
}
|
||||
void hookafter(hook_stack*s,void* data1, size_t len)
|
||||
{
|
||||
|
@ -82,8 +82,7 @@ bool WendyBell_filter(void* data, size_t* len, HookParam* hp){
|
||||
|
||||
}
|
||||
}
|
||||
*len=wc.size()*2;
|
||||
wcscpy(reinterpret_cast<LPWSTR>(data),wc.c_str());
|
||||
write_string_overwrite(data,len,wc);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -99,8 +98,7 @@ bool tkbl_filter(void* data, size_t* len, HookParam* hp){
|
||||
if(last==str)return false;
|
||||
last=str;
|
||||
|
||||
*len=str.size()*2;
|
||||
wcscpy(reinterpret_cast<LPWSTR>(data),str.c_str());
|
||||
write_string_overwrite(data,len,str);
|
||||
return true;
|
||||
}
|
||||
bool tkbl(){
|
||||
|
@ -199,9 +199,7 @@ namespace Private {
|
||||
strReplace(oldData, "\x81\x40", "");
|
||||
//oldData.replace("\x81\x40", ""); // remove spaces in the middle of names
|
||||
|
||||
strcpy((CHAR*)data,oldData.c_str());
|
||||
*len1=oldData.size();
|
||||
return true;
|
||||
return write_string_overwrite(data,len1,oldData);
|
||||
|
||||
}
|
||||
void hookafter2(hook_stack*s,void* data, size_t len){
|
||||
@ -588,10 +586,8 @@ namespace Private {
|
||||
//|| isSkippedText(text))
|
||||
return false;
|
||||
enum { role = Engine::OtherRole };
|
||||
std::string oldData = text;
|
||||
strcpy((char*)data,oldData.c_str());
|
||||
*len=oldData.size();
|
||||
return true;
|
||||
|
||||
return write_string_overwrite(data,len,text);
|
||||
/* //oldData.replace("\\n", "\n"); // Remove new line. FIXME: automatically adjust line width
|
||||
std::string newData = EngineController::instance()->dispatchTextASTD(oldData, role, retaddr);
|
||||
if (newData == oldData)
|
||||
|
@ -181,9 +181,8 @@ namespace Private {
|
||||
|
||||
//auto sig = Engine::hashThreadSignature(role, reladdr);
|
||||
std::string oldData = arg->getText();
|
||||
strcpy((LPSTR)data,oldData.c_str());
|
||||
*len=oldData.size();
|
||||
return true;
|
||||
|
||||
return write_string_overwrite(data,len,oldData);
|
||||
}
|
||||
void hookafter(hook_stack*s,void* data, size_t len){
|
||||
|
||||
|
@ -271,10 +271,7 @@ bool WillPlus_extra_filter(void* data, size_t* size, HookParam*) {
|
||||
std::wregex reg2(L"%[A-Z]+");
|
||||
result1 = std::regex_replace(result1, reg2, L"");
|
||||
|
||||
|
||||
|
||||
*size = result1.size() * 2;
|
||||
wcscpy(text, result1.c_str());
|
||||
write_string_overwrite(data,size,result1);
|
||||
return true;
|
||||
};
|
||||
bool InsertWillPlusAHook()
|
||||
@ -532,8 +529,8 @@ bool hookBefore(hook_stack*s,void* data, size_t* len,uintptr_t*role)
|
||||
std::wregex reg11(L"\\{(.*?);(.*?)\\}");
|
||||
str = std::regex_replace(str, reg11, L"$1");
|
||||
|
||||
wcscpy((wchar_t*)data,str.c_str());
|
||||
*len=str.size()*2;
|
||||
write_string_overwrite(data,len,str);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
@ -777,8 +774,7 @@ namespace TextHookW
|
||||
if (!trimmedSize || !*trimmedText)
|
||||
return false;
|
||||
std::wstring oldText = std::wstring(trimmedText, trimmedSize);
|
||||
wcscpy((LPWSTR)data,oldText.c_str());*len=oldText.size()*2;
|
||||
|
||||
write_string_overwrite(data,len,oldText);
|
||||
return true;
|
||||
}
|
||||
template<int idx>
|
||||
@ -1260,9 +1256,7 @@ namespace Private {
|
||||
return false;
|
||||
std::string oldData(trimmedText, trimmedSize);
|
||||
|
||||
strcpy((char*)data,oldData.c_str());
|
||||
*len=oldData.size();
|
||||
return true;
|
||||
return write_string_overwrite(data,len,oldData);
|
||||
/*newData = EngineController::instance()->dispatchTextASTD(oldData, role, sig);
|
||||
if (newData == oldData)
|
||||
return;
|
||||
@ -1555,9 +1549,8 @@ namespace Private {
|
||||
if (!Engine::isAddressReadable(text) || !*text || ::strlen(text) <= 2) // do not translate single character
|
||||
return false;
|
||||
*role = Engine::OtherRole ;
|
||||
strcpy((char*)data,text);*len=strlen(text);
|
||||
|
||||
return true;
|
||||
|
||||
return write_string_overwrite(data,len,text);
|
||||
}
|
||||
|
||||
} // namespace Private
|
||||
|
@ -264,7 +264,8 @@ namespace Private {
|
||||
bool timeout;
|
||||
int prefixSize = text - self->text,
|
||||
capacity = self->capacity - prefixSize;
|
||||
strcpy((char*)data1,data.c_str());*len1=data.size();return 1;
|
||||
return write_string_overwrite(data1,len1,data);
|
||||
|
||||
// data = EngineController::instance()->dispatchTextASTD(data, role, sig, capacity, SendAllowed, &timeout);
|
||||
// if (timeout)
|
||||
// return true;
|
||||
|
@ -141,10 +141,8 @@ bool InsertYukaSystem2Hook()
|
||||
(wc=='"')||(wc=='.')||(wc=='-')||(wc=='#')||
|
||||
(wc==65533)||(wc==2))return false;
|
||||
}
|
||||
|
||||
*len = (str.size()) ;
|
||||
strcpy(reinterpret_cast<char*>(data), str.c_str());
|
||||
return true;
|
||||
|
||||
return write_string_overwrite(data,len,str);
|
||||
};
|
||||
//hp.text_fun = SpecialHookYukaSystem2;
|
||||
ConsoleOutput("INSERT YukaSystem2");
|
||||
|
@ -155,9 +155,7 @@ bool libcefhook(HMODULE module) {
|
||||
s += c;
|
||||
}
|
||||
}
|
||||
wcscpy((LPWSTR)data, s.c_str());
|
||||
*size = i * 2;
|
||||
return true;
|
||||
return write_string_overwrite(data,size,s);
|
||||
};
|
||||
hp.type = USING_STRING | CODEC_UTF16|NO_CONTEXT;
|
||||
ConsoleOutput("v8libcefhook %p", addr);
|
||||
|
@ -53,8 +53,7 @@ namespace{
|
||||
if(text[text.size()-1]=='$')
|
||||
text=text.substr(0,text.size()-1);
|
||||
|
||||
strcpy((char*)data,text.c_str());
|
||||
*len=text.size();
|
||||
write_string_overwrite(data,len,text);
|
||||
return true;
|
||||
}
|
||||
void hookafter_navel(hook_stack*s,void* data, size_t len)
|
||||
@ -293,8 +292,7 @@ namespace Private {
|
||||
if (!*text)
|
||||
return false;
|
||||
|
||||
std::string oldData = text;
|
||||
strcpy((char*)data,oldData.c_str());*len1=oldData.size();
|
||||
write_string_overwrite(data,len1,text);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -313,7 +311,7 @@ namespace Private {
|
||||
if (!*text)
|
||||
return false;
|
||||
std::string oldData = parseScenarioText(text, scenarioEnd);
|
||||
strcpy((char*)data,oldData.c_str());*len1=oldData.size();
|
||||
write_string_overwrite(data,len1,oldData);
|
||||
return true;
|
||||
}
|
||||
bool dispatchNameTextafter(char *text, ULONG split,hook_stack*s,void* data, uintptr_t len1 )
|
||||
@ -761,8 +759,7 @@ namespace Private {
|
||||
if (!text || !*text)
|
||||
return text;
|
||||
*role=Engine::ChoiceRole;
|
||||
std::string oldData =text;
|
||||
strcpy((char*)data,oldData.c_str());*len1=oldData.size();
|
||||
write_string_overwrite(data,len1,text);
|
||||
return true;
|
||||
}
|
||||
void hookafter(hook_stack*s,void* data, size_t len1){
|
||||
|
@ -1,9 +1,9 @@
|
||||
#include"5pb.h"
|
||||
#include"mages/mages.hpp"
|
||||
#include"mages/mages.h"
|
||||
|
||||
bool _5pb::attach_function() {
|
||||
//CHAOS;HEAD_NOAH
|
||||
bool b3=mages::MAGES();
|
||||
bool b3=hookmages::MAGES();
|
||||
return b3;
|
||||
}
|
||||
|
||||
|
@ -8,9 +8,7 @@ bool ENTERGRAMfilter(void* data, size_t* size, HookParam* hp) {
|
||||
std::wstring result1 = std::regex_replace(str, reg1, L"$1");
|
||||
std::wregex reg2(L"\x3000|\n");
|
||||
std::wstring result2 = std::regex_replace(result1, reg2, L"");
|
||||
|
||||
*size = (result2.size()) * 2;
|
||||
wcscpy(text, result2.c_str());
|
||||
write_string_overwrite(text,size,result2);
|
||||
return true;
|
||||
};
|
||||
bool InsertENTERGRAM() {
|
||||
|
@ -88,8 +88,7 @@ bool _2(){
|
||||
if(str.find(_)!=str.npos)
|
||||
return false;
|
||||
str = std::regex_replace(str, std::wregex(L"\\[(.*?)\\]<(.*?)>"), L"$1");
|
||||
wcscpy((wchar_t*)data,str.c_str());
|
||||
*len=str.size()*2;
|
||||
write_string_overwrite(data,len,str);
|
||||
return true;
|
||||
};
|
||||
return NewHook(hp, "LightVN2");
|
||||
|
@ -35,9 +35,7 @@ bool IG64filter(void* data, size_t* size, HookParam*) {
|
||||
|
||||
std::wregex reg2(L"@[^@]*@");
|
||||
std::wstring result2 = std::regex_replace(result1, reg2, L"");
|
||||
|
||||
*size = (result2.size()) * 2;
|
||||
wcscpy(text, result2.c_str());
|
||||
write_string_overwrite(text,size,result2);
|
||||
return true;
|
||||
};
|
||||
bool InsertIG64Hook2() {
|
||||
|
@ -68,8 +68,7 @@ _BYTE *__fastcall sub_18005B290(
|
||||
|
||||
std::regex_search(str, match,std::wregex(L" Text:(.*?)Next:(.*?)") );
|
||||
result1= match[1].str();
|
||||
*len = (result1.size()) * 2;
|
||||
wcscpy((LPWSTR)data, result1.c_str());
|
||||
write_string_overwrite(data,len,result1);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
127
LunaHook/engine64/yuzusuyu.cpp
Normal file
127
LunaHook/engine64/yuzusuyu.cpp
Normal file
@ -0,0 +1,127 @@
|
||||
#include"yuzusuyu.h"
|
||||
#include"mages/mages.h"
|
||||
namespace{
|
||||
|
||||
auto isFastMem = true;
|
||||
|
||||
auto isVirtual = true;//Process.arch === 'x64' && Process.platform === 'windows';
|
||||
auto idxDescriptor = isVirtual == true ? 2 : 1;
|
||||
auto idxEntrypoint = idxDescriptor + 1;
|
||||
|
||||
uintptr_t getDoJitAddress() {
|
||||
auto RegisterBlockSig1 = "E8 ?? ?? ?? ?? 4? 8B ?? 4? 8B ?? 4? 8B ?? E8 ?? ?? ?? ?? 4? 89?? 4? 8B???? ???????? 4? 89?? ?? 4? 8B?? 4? 89";
|
||||
auto RegisterBlock=find_pattern(RegisterBlockSig1,processStartAddress,processStopAddress);
|
||||
if (RegisterBlock) {
|
||||
auto beginSubSig1 = "CC 40 5? 5? 5?";
|
||||
auto lookbackSize = 0x400;
|
||||
auto address=RegisterBlock-lookbackSize;
|
||||
auto subs=find_pattern(beginSubSig1,address,address+lookbackSize);
|
||||
if(subs){
|
||||
return subs+1;
|
||||
}
|
||||
}
|
||||
|
||||
auto PatchSig1 = "4????? 4????? 4????? FF?? ?? 4????? ?? 4????? 75 ?? 4????? ?? 4????? ?? 4?";
|
||||
auto Patch = find_pattern(PatchSig1,processStartAddress,processStopAddress);
|
||||
if (Patch) {
|
||||
auto beginSubSig1 = "4883EC ?? 48";
|
||||
auto lookbackSize = 0x80;
|
||||
auto address = Patch-lookbackSize;
|
||||
auto subs = find_pattern(beginSubSig1,address,address+lookbackSize);
|
||||
if (subs) {
|
||||
idxDescriptor = 1;
|
||||
idxEntrypoint = 2;
|
||||
return subs;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
/*
|
||||
这块不知道怎么实现。
|
||||
// DebugSymbol: RegisterBlock
|
||||
// ?RegisterBlock@EmitX64@X64@Backend@Dynarmic@@IEAA?AUBlockDescriptor@1234@AEBVLocationDescriptor@IR@4@PEBX_K@Z <- new
|
||||
// ?RegisterBlock@EmitX64@X64@Backend@Dynarmic@@IEAA?AUBlockDescriptor@1234@AEBVLocationDescriptor@IR@4@PEBX1_K@Z
|
||||
const symbols = DebugSymbol.findFunctionsMatching('Dynarmic::Backend::X64::EmitX64::RegisterBlock');
|
||||
if (symbols.length !== 0) {
|
||||
return symbols[0];
|
||||
}
|
||||
|
||||
// DebugSymbol: Patch
|
||||
// ?Patch@EmitX64@X64@Backend@Dynarmic@@IEAAXAEBVLocationDescriptor@IR@4@PEBX@Z
|
||||
const patchs = DebugSymbol.findFunctionsMatching('Dynarmic::Backend::X64::EmitX64::Patch');
|
||||
if (patchs.length !== 0) {
|
||||
idxDescriptor = 1;
|
||||
idxEntrypoint = 2;
|
||||
return patchs[0];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
uintptr_t* argidx(hook_stack* stack,int idx){
|
||||
auto offset=0;
|
||||
switch (idx)
|
||||
{
|
||||
case 0:offset=get_reg(regs::rcx);break;
|
||||
case 1:offset=get_reg(regs::rdx);break;
|
||||
case 2:offset=get_reg(regs::r8);break;
|
||||
case 3:offset=get_reg(regs::r9);break;
|
||||
}
|
||||
return (uintptr_t*)((uintptr_t)stack+sizeof(hook_stack)-sizeof(uintptr_t)+offset);
|
||||
}
|
||||
|
||||
class emu_arg{
|
||||
hook_stack* stack;
|
||||
public:
|
||||
emu_arg(hook_stack* stack_):stack(stack_){};
|
||||
uintptr_t operator [](int idx){
|
||||
auto base=stack->r13;
|
||||
auto args=(uintptr_t*)stack->r15;
|
||||
return base+args[idx];
|
||||
}
|
||||
};
|
||||
std::unordered_map<uintptr_t,std::pair<LPCSTR,void*>>emfunctionhooks;
|
||||
|
||||
}
|
||||
bool yuzusuyu::attach_function()
|
||||
{
|
||||
auto DoJitPtr=getDoJitAddress();
|
||||
if(DoJitPtr==0)return false;
|
||||
HookParam hp;
|
||||
hp.address=DoJitPtr;
|
||||
hp.text_fun=[](hook_stack* stack, HookParam* hp, uintptr_t* data, uintptr_t* split, size_t* len){
|
||||
//hp->text_fun=nullptr;hp->type=HOOK_EMPTY;
|
||||
auto descriptor = *argidx(stack,idxDescriptor); // r8
|
||||
auto entrypoint = *argidx(stack,idxEntrypoint); // r9
|
||||
auto em_address = *(uintptr_t*)descriptor;
|
||||
em_address-=0x80004000;
|
||||
if(emfunctionhooks.find(em_address)!=emfunctionhooks.end() && entrypoint){
|
||||
auto op=emfunctionhooks.at(em_address);
|
||||
DWORD _;
|
||||
VirtualProtect((LPVOID)entrypoint,0x10,PAGE_EXECUTE_READWRITE,&_);
|
||||
HookParam hpinternal;
|
||||
hpinternal.address=entrypoint;
|
||||
hpinternal.type=CODEC_UTF16|USING_STRING|NO_CONTEXT;
|
||||
hpinternal.text_fun=(decltype(hpinternal.text_fun))op.second;
|
||||
NewHook(hpinternal,op.first);
|
||||
}
|
||||
|
||||
};
|
||||
return NewHook(hp,"YuzuDoJit");
|
||||
}
|
||||
// ==UserScript==
|
||||
// @name [0100978013276000] Memories Off
|
||||
// @version 1.0.0 - 1.0.1
|
||||
// @author Koukdw
|
||||
// @description Yuzu
|
||||
// * MAGES. inc.
|
||||
// * MAGES Engine
|
||||
void _0100978013276000(hook_stack* stack, HookParam* hp, uintptr_t* data, uintptr_t* split, size_t* len){
|
||||
auto s=mages::readString(emu_arg(stack)[0],0);
|
||||
write_string_new(data,len,s);
|
||||
}
|
||||
auto _=[](){
|
||||
emfunctionhooks={
|
||||
{0x8003eeac - 0x80004000,{"Memories Off 1.0.0",_0100978013276000}},
|
||||
{0x8003eebc - 0x80004000,{"Memories Off 1.0.1",_0100978013276000}},
|
||||
};
|
||||
return 1;
|
||||
}();
|
16
LunaHook/engine64/yuzusuyu.h
Normal file
16
LunaHook/engine64/yuzusuyu.h
Normal file
@ -0,0 +1,16 @@
|
||||
#include"engine.h"
|
||||
|
||||
class yuzusuyu:public ENGINE{
|
||||
public:
|
||||
yuzusuyu(){
|
||||
|
||||
is_engine_certain=false;
|
||||
check_by=CHECK_BY::CUSTOM;
|
||||
check_by_target=[](){
|
||||
|
||||
return (wcscmp(processName_lower, L"suyu.exe")==0 || wcscmp(processName_lower, L"yuzu.exe")==0);
|
||||
};
|
||||
};
|
||||
bool attach_function();
|
||||
};
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include"engine64/ENTERGRAM.h"
|
||||
#include"engine64/TYPEMOON.h"
|
||||
#include"engine64/LightVN.h"
|
||||
#include"engine64/yuzusuyu.h"
|
||||
std::vector<ENGINE*> ignore_engines(){ return{ }; }
|
||||
std::vector<ENGINE*> unsafe_check_atlast(){ return{ }; }
|
||||
|
||||
@ -36,7 +37,8 @@ std::vector<ENGINE*> check_engines(){
|
||||
new AGES7,
|
||||
new _5pb,
|
||||
new TYPEMOON,
|
||||
new ENTERGRAM
|
||||
new ENTERGRAM,
|
||||
new yuzusuyu
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
add_library(commonengine v8/v8.cpp python/python2.cpp python/python3.cpp python/python.cpp pchooks/pchooks.cpp)
|
||||
add_library(commonengine mages/mages.cpp v8/v8.cpp python/python2.cpp python/python3.cpp python/python.cpp pchooks/pchooks.cpp)
|
||||
target_precompile_headers(commonengine REUSE_FROM pch)
|
||||
|
||||
|
@ -1,20 +1,19 @@
|
||||
#include"engine.h"
|
||||
#include"mages/mages.h"
|
||||
|
||||
namespace mages{
|
||||
|
||||
regs reg=regs::invalid;
|
||||
int gametype=0;
|
||||
std::map<WORD, std::wstring> createTable() {
|
||||
std::map<WORD, std::wstring> createTable(int _idx) {
|
||||
|
||||
auto compound_charsA=LoadResData(std::vector<const wchar_t*>{
|
||||
L"compound_chars_default",
|
||||
L"compound_chars_Robotics_Notes_Elite",
|
||||
L"compound_chars_Robotics_Notes_Dash"
|
||||
}[gametype],L"COMPOUND_CHARS");
|
||||
}[_idx],L"COMPOUND_CHARS");
|
||||
auto charsetA=LoadResData(std::vector<const wchar_t*>{
|
||||
L"charset_default",
|
||||
L"charset_Robotics_Notes_Elite",
|
||||
L"charset_Robotics_Notes_Dash"
|
||||
}[gametype],L"CHARSET");
|
||||
}[_idx],L"CHARSET");
|
||||
|
||||
|
||||
auto compound_chars=StringToWideString(compound_charsA);
|
||||
@ -48,8 +47,8 @@ namespace mages{
|
||||
return table;
|
||||
}
|
||||
|
||||
std::wstring mages_decode(WORD charCode) {
|
||||
static auto table = createTable();
|
||||
std::wstring mages_decode(WORD charCode,int _idx) {
|
||||
static auto table = createTable(_idx);
|
||||
if (table.find(charCode) == table.end()) {
|
||||
std::wstringstream _;
|
||||
_ << std::hex << charCode;
|
||||
@ -59,10 +58,8 @@ std::wstring mages_decode(WORD charCode) {
|
||||
return table[charCode];
|
||||
}
|
||||
}
|
||||
template<int filter>
|
||||
void SpecialHookMAGES(hook_stack* stack, HookParam*, uintptr_t* data, uintptr_t* split, size_t* len)
|
||||
{
|
||||
auto edx = regof(reg,stack);//regof(edx, esp_base);
|
||||
std::wstring readString(uintptr_t address,int _idx) {
|
||||
auto edx=address;
|
||||
std::wstring s = L"", bottom = L"";
|
||||
while (1) {
|
||||
auto c = *(BYTE*)edx;
|
||||
@ -74,7 +71,7 @@ void SpecialHookMAGES(hook_stack* stack, HookParam*, uintptr_t* data, uintptr_t*
|
||||
if (c >= 0x80) {// readChar
|
||||
auto charCode = *(WORD*)edx;
|
||||
edx += 2;
|
||||
s += mages_decode(charCode);
|
||||
s += mages_decode(charCode,_idx);
|
||||
}
|
||||
else {// readControl
|
||||
edx += 1;
|
||||
@ -93,7 +90,7 @@ void SpecialHookMAGES(hook_stack* stack, HookParam*, uintptr_t* data, uintptr_t*
|
||||
else {
|
||||
auto charCode = *(WORD*)edx;
|
||||
edx += 2;
|
||||
bottom += mages_decode(charCode);
|
||||
bottom += mages_decode(charCode,_idx);
|
||||
}
|
||||
}
|
||||
if(bottom.size()) s = s + bottom + L": ";
|
||||
@ -164,7 +161,7 @@ void SpecialHookMAGES(hook_stack* stack, HookParam*, uintptr_t* data, uintptr_t*
|
||||
auto charCode = *(WORD*)edx;
|
||||
edx+=2;
|
||||
|
||||
rubi += mages_decode(charCode);
|
||||
rubi += mages_decode(charCode,_idx);
|
||||
}
|
||||
} // end while
|
||||
}
|
||||
@ -179,7 +176,7 @@ void SpecialHookMAGES(hook_stack* stack, HookParam*, uintptr_t* data, uintptr_t*
|
||||
auto charCode = *(WORD*)edx;
|
||||
edx+=2;
|
||||
|
||||
auto cc = mages_decode(charCode);
|
||||
auto cc = mages_decode(charCode,_idx);
|
||||
bottom += cc;
|
||||
s += cc;
|
||||
}
|
||||
@ -193,20 +190,35 @@ void SpecialHookMAGES(hook_stack* stack, HookParam*, uintptr_t* data, uintptr_t*
|
||||
// do nothing (one byte control)
|
||||
}
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace hookmages{
|
||||
|
||||
regs reg=regs::invalid;
|
||||
int gametype=0;
|
||||
|
||||
template<int filter>
|
||||
void SpecialHookMAGES(hook_stack* stack, HookParam*, uintptr_t* data, uintptr_t* split, size_t* len)
|
||||
{
|
||||
auto edx = regof(reg,stack);//regof(edx, esp_base);
|
||||
|
||||
auto s=mages::readString(edx,gametype);
|
||||
|
||||
if(filter){
|
||||
static std::wstring last=L"";
|
||||
if(last==s)return;
|
||||
last=s;
|
||||
}
|
||||
|
||||
wchar_t* _data=new wchar_t[s.size()+1];
|
||||
wcscpy(_data,s.c_str());
|
||||
*data=(uintptr_t)_data;
|
||||
*len=s.size()*2;
|
||||
write_string_new(data,len,s);
|
||||
}
|
||||
#ifndef _WIN64
|
||||
|
||||
bool MAGES() {
|
||||
#ifndef _WIN64
|
||||
auto dialogSigOffset = 2;
|
||||
BYTE dialogSig1 []={
|
||||
0x85,XX,0x74,XX,0x83,XX,0x01,0x74,XX,0x83,XX,0x04,0x74,XX,0xc7,0x05,XX,XX,XX,XX,0x01,0x00,0x00,0x00
|
||||
@ -287,11 +299,9 @@ bool MAGES() {
|
||||
hp.text_fun = SpecialHookMAGES<1>;
|
||||
_|=NewHook(hp, "5pb_MAGES");
|
||||
return _;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool MAGES() {
|
||||
auto dialogSigOffset = 2;
|
||||
BYTE dialogSig1 []={
|
||||
0x85,XX,0x74,XX,0x41,0x83,XX,0x01,0x74,XX,0x41,0x83,XX,0x04,0x74,XX,0x41
|
||||
@ -326,9 +336,10 @@ bool MAGES() {
|
||||
hp.text_fun = SpecialHookMAGES<0>;
|
||||
hp.type = CODEC_UTF16 | USING_STRING|NO_CONTEXT;
|
||||
return NewHook(hp, "5pb_MAGES");
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
}
|
8
LunaHook/engines/mages/mages.h
Normal file
8
LunaHook/engines/mages/mages.h
Normal file
@ -0,0 +1,8 @@
|
||||
#include"engine.h"
|
||||
namespace mages{
|
||||
|
||||
std::wstring readString(uintptr_t address,int _idx) ;
|
||||
}
|
||||
namespace hookmages{
|
||||
bool MAGES();
|
||||
}
|
@ -578,4 +578,30 @@ bool Engine::isAddressWritable(const char *p, size_t count)
|
||||
{ return p && count && !::IsBadWritePtr((LPVOID)p, sizeof(*p) * count); }
|
||||
|
||||
bool Engine::isAddressWritable(const wchar_t *p, size_t count)
|
||||
{ return p && count && !::IsBadWritePtr((LPVOID)p, sizeof(*p) * count); }
|
||||
{ return p && count && !::IsBadWritePtr((LPVOID)p, sizeof(*p) * count); }
|
||||
|
||||
|
||||
namespace{
|
||||
|
||||
wchar_t *Xstrcpy(wchar_t *s, const wchar_t *r){return wcscpy(s,r);}
|
||||
char *Xstrcpy(char *s, const char *r){return strcpy(s,r);}
|
||||
template<class CharT>
|
||||
void write_string_new_impl(uintptr_t* data, size_t* len,const std::basic_string<CharT>& s){
|
||||
CharT* _data=new CharT[s.size()+1];
|
||||
Xstrcpy(_data,s.c_str());
|
||||
*data=(uintptr_t)_data;
|
||||
if(len)
|
||||
*len=s.size()*sizeof(CharT);
|
||||
}
|
||||
template<class CharT>
|
||||
bool write_string_overwrite_impl(void* data, size_t* len,const std::basic_string<CharT>& s){
|
||||
Xstrcpy((CharT*)data,s.c_str());
|
||||
*len=s.size()*sizeof(CharT);
|
||||
return s.size();
|
||||
}
|
||||
}
|
||||
void write_string_new(uintptr_t* data, size_t* len,const std::wstring& s){write_string_new_impl<wchar_t>(data,len,s);}
|
||||
void write_string_new(uintptr_t* data, size_t* len,const std::string& s){write_string_new_impl<char>(data,len,s);}
|
||||
|
||||
bool write_string_overwrite(void* data, size_t* len,const std::wstring& s){return write_string_overwrite_impl<wchar_t>(data,len,s);}
|
||||
bool write_string_overwrite(void* data, size_t* len,const std::string& s){return write_string_overwrite_impl<char>(data,len,s);}
|
@ -77,3 +77,7 @@ inline bool isAddressWritable(const void *addr) { return isAddressWritable((cons
|
||||
inline bool isAddressWritable(uintptr_t addr) { return isAddressWritable((const void *)addr); }
|
||||
}
|
||||
|
||||
void write_string_new(uintptr_t* data, size_t* len,const std::wstring& s);
|
||||
void write_string_new(uintptr_t* data, size_t* len,const std::string& s);
|
||||
bool write_string_overwrite(void* data, size_t* len,const std::wstring& s);
|
||||
bool write_string_overwrite(void* data, size_t* len,const std::string& s);
|
Loading…
x
Reference in New Issue
Block a user